akhauriyash/Code-Regression huggingface dataset:
#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<lint>a(3*n); std::cin>>a;

  auto cal = [&] (auto a) {
    std::vector<lint>ans;

    std::multiset<lint> set{a.begin(), a.begin()+n};
    lint sum = std::accumulate(all(set), 0ll);
    ans.emplace_back(sum);

    for (lint x : std::vector<int>{a.begin()+n, a.begin()+2*n}) {
      debug(set,x);
      set.insert(x);
      lint min = *set.begin();
      set.erase(set.begin());
      sum += x - min;
      ans.emplace_back(sum);
    }
    return ans;
  };
  auto b = cal(a);
  std::reverse(all(a));
  for (lint& x : a) x = -x;
  auto c = cal(a);
  std::reverse(all(a));
  for (lint& x : a) x = -x;
  debug(b,c);

  lint ans = std::numeric_limits<lint>::min();
  rep(i,0,n+1) {
    lint now = b.at(i) + c.at(n-i);
    cmx(ans, now);
  }
  std::cout << ans << std::endl;
  return 0;
}

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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

int main(void){
    int N; cin >> N;
    //dp, 末尾にA, G, C, Tを追加していく
    ll dp[N+1][64];
    // 0: AAA 1: AAC 2: AAG 3: AAT 4: ACA ... 63: TTT
    rep(i, 64){
        if(i == 6 || i == 9 || i == 33) dp[3][i] = 0;
        else dp[3][i] = 1;
    }
    for(int i = 4; i <= N; i++){
        for(int j = 0; j < 64; j++){
            if(j == 6 || j == 9 || j == 33){
                dp[i][j] = 0;
                continue;
            }

            ll acc = 0;
            for(int k = j/4; k < 64; k+=16){
                acc += dp[i-1][k];
            }
            if(j == 41) acc -= dp[i-1][10];
            else if(j == 57) acc -= dp[i-1][14];
            else if(j == 45) acc -= dp[i-1][11];
            dp[i][j] = acc % mod;
        }
    }
    /*
    for(int i = 4; i <= N; i++){
        for(int j = 0; j < 64; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    
    

    ll acc = 0;
    rep(i, 64) acc = (acc + dp[N][i]) % mod;
    cout << acc % mod << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define int64 long long

int main()
{
  int64 xx, tmp;
  scanf("%lld", &xx);
  for(int64 ii = -120;ii <= 120;ii++)
  {
    for(int64 jj = -120;jj <= 120;jj++)
    {
      tmp = ii * ii * ii * ii * ii - jj * jj * jj * jj * jj;
      if(xx == tmp)
      {
        printf("%lld %lld\n", ii, jj);
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1728
def answer(n: int) -> str:
    for i in range(n // 4 + 1):
        for j in range(n // 7 + 1):
            if n == i * 4 + j * 7:
                return 'Yes'

    return 'No'


def main():
    n = int(input())
    print(answer(n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9116
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int H, W, N;
vector<vector<int>> field;

int main() {
	cin >> H >> W >> N;
	field.resize(H);
	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		if (x >= y) {
			field[x].push_back(y);
		}
	}

	int ans = H - 1;
	int wlimit = 0;
	
	for (int i = 0; i < H; i++)sort(field[i].begin(), field[i].end());
	for (int i = 1; i < H; i++) {
		if (field[i].size() == 0)wlimit++;
		else {
			if (field[i][0] <= wlimit) {
				cout << i << endl;
				return 0;
			}
			else if (field[i][0] == wlimit + 1) {
				//cannot do anything
			}
			else {
				wlimit++;
			}
		}
	}

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


Measured memory_bytes: 10240
while True:
	n = int(raw_input())
	if n == 0: break
	a = []
	for i in range(n):
		d = map(int, raw_input().split())
		t = 60*(d[1]+d[3]+d[5]+d[7])+d[2]+d[4]+d[6]+d[8]
		a.append([d[0],t])
	a = sorted(a,key=lambda x:x[1])
	print "{}\n{}\n{}".format(a[0][0],a[1][0],a[-2][0])

Measured memory_bytes: 5256
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var d = int.Parse(inputs[0]);
            var t = int.Parse(inputs[1]);
            var s = int.Parse(inputs[2]);
            var result = (d / (float)s) <= t;
            Console.WriteLine(result ? "Yes" : "No");
        }
    }
}


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

int main() {
  int A,B,C,D,N;
  cin>>A>>B>>C>>D>>N;
  if(D>B){
    cout<<(C-A-1)*60+(D-B+60)-N<<endl;
  }
  else{
    cout<<(C-A)*60+D-B-N<<endl;
  }
}



Measured memory_bytes: 3644
#include<stdio.h>
int main(){
  int n,i,j,k,s,max=-1e9,a,o[110][20],p[110][20],d[20];
  scanf("%d",&n);
  for(i=0;i<n*10;i++)scanf("%d",&o[i/10][i%10]);
  for(i=0;i<n*11;i++)scanf("%d",&p[i/11][i%11]);
  for(i=1;i<1024;i++){
    for(j=0;j<10;j++)d[j]=(i>>j)%2;
    // for(j=0;j<10;j++)printf("%d",d[j]);printf("\n");
    for(j=a=0;j<n;j++){
      for(k=s=0;k<10;k++)s+=o[j][k]*d[k];
      a+=p[j][s];
    }
    if(max<a)max=a;
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		int c = (a-1)*(b-1);
		System.out.println(c);
	}
}


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

#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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 trace(...)
#endif

#define ll   long long 
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;
 
#define md          1000000007
#define fmd         998244353 
#define M           1000011
#define N            18
ll exp(ll a,ll b){if(b<0)return 0;ll r=1;while(b){if(b&1)r=r*a%md,r%=md;a=a*a%md;b/=2;}return r;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
class BIT{
public:
    int n;
    vector<int> B;
    BIT(int sz){
        n=sz;
        B=vector<int> (n+1);
    }
    void up(int x,int y=1){
        for(;x<=n;x+=x&-x)B[x]+=y;
    }
    int sum(int x){int s=0;
        for(;x>=1;x-=x&-x)s+=B[x];
        return s;
    }

};
int bc;

int solve(){
    ll n,i,j,k,m,x,y,z;
    cin>>n>>k;
    vector<ll> a(n+1);
    for(i=1;i<=n;++i)cin>>a[i],a[i]+=a[i-1];
	map<ll,ll> mp;
	for(i=0;i<=n;++i)mp[a[i]-k*i];
	for(auto x:mp)mp[x.F]=++bc;
	BIT b(bc);
	ll ans=0;
	b.up(mp[0]);
	for(i=1;i<=n;++i){
		ll bef=a[i]-k*i;
		ans+=(b.sum(mp[bef]));
		b.up(mp[bef]);
	}
	cout<<ans<<"\n";

	die();
}
 
 
int main(){
 
 
#ifndef ONLINE_JUDGE
    double _tBeg=clock();
#endif

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

    int t;
    t=1;;
    // prec();
    // cin>>t;
 
    while(t--){

        solve();
    }
 
 
 
 


#ifndef ONLINE_JUDGE
    double _tEnd=clock();
    // printf("\ntotal time %.6f\n",(_tEnd-_tBeg)/CLOCKS_PER_SEC);
#endif
 
    die();
}

Measured memory_bytes: 17152
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
const int N = 100001;
int n,m;
vi g[N];
int dp[N];
bool vis[N];
int ans;
void dfs(int u){
    vis[u]=true;
    for(int i = 0; i < g[u].size(); i++){
        if(!vis[g[u][i]])
            dfs(g[u][i]);
        dp[u]=max(dp[u],1+dp[g[u][i]]);
    }
}
int main(){
    cin>>n>>m;
    for(int a, b, i = 0; i < m; i++){
        scanf("%d%d", &a, &b);
        a--;b--;
        g[a].pb(b);
    }
    for(int i=0;i<n;i++)
        if(!vis[i])
            dfs(i);
    for(int i=0;i<n;i++)
        ans=max(ans,dp[i]);
    printf("%d",ans);
}



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

using namespace std;

#define ll long long
#define int ll

typedef pair<int, int> pii;
typedef pair<ll, ll> pll; 

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define syso(n) cout<<n<<endl;  
#define sysom(message, n) cout<<message<<n<<endl;
#define all(c) c.begin(), c.end() 
#define tr(container, it )\
for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(aint(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 
#define all(c) c.begin(), c.end() 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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 trace(...)
#endif

int gcd(int a, int b){
    if (b==0) return a;
    return gcd(b, a%b);
} 

int lcm(int fir, int sec){
    return (fir*sec)/(gcd(fir, sec));
}

const int MOD = 1988;
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(26) << f << '\n';

// sort(arr, arr+n, greater<int>());

const int maxN = 1e3 + 12;
// const int maxVal = pow(2, 11);

// pii b[maxN];
// pii t[maxN];
// pii p[maxN];
int arr[maxN][3];
int ans[8][maxN];
signed main(){
	int n,m;
	cin>>n>>m;
	int x, y, z;
	for (int i = 0; i < n; ++i){
		cin>>x>>y>>z;
		arr[i][0] = x;
		arr[i][1] = y;
		arr[i][2] = z;
	}

	for (int j = 0; j < 8; ++j){
		for (int i = 0; i < n; ++i){
			for (int k = 0; k < 3; ++k){
				if(j&(1<<k)){
					ans[j][i] += arr[i][k];
				}else{
					ans[j][i] -= arr[i][k];
				}
			}
		}
	}

	int answer = 0;
	for (int i = 0; i < 8; ++i){
		sort(ans[i], ans[i]+n, greater<int>());
	}
	int temp;
	for (int i = 0; i < 8; ++i){
		temp = 0;
		for (int j = 0; j < m; ++j){
			temp+=ans[i][j];
		}
		answer = max(answer, temp);
	}
	cout<<answer<<endl;

}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;
constexpr int     MAX =       200'005;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int64_t COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
    int N, K;
    cin >> N >> K;
    COMinit();

    for(int i=1; i<=K; i++) {
        cout << (COM(K-1, i-1) * COM(N-K+1, i)) % MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>
#include <numeric>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define lint long long

using namespace std;
string s,t;
vector<int> al[30];
vector<int> al2[30];

int main(){
  cin >> s >> t;
  string ans = "Yes";
  REP(i,s.size()){
    char k = s[i];
    al[k-'a'].push_back(i);
    //cout << k-'a' << endl;
    if(al[k-'a'].size()>=2){
      if(t[al[k-'a'][0]]!=t[i]) ans = "No";
      //cout << t[al[k-'a'][0]] << " " << t[i] <<endl;
    }
  }
  REP(i,t.size()){
    char k = t[i];
    al2[k-'a'].push_back(i);
    //cout << k-'a' << endl;
    if(al2[k-'a'].size()>=2){
      if(s[al2[k-'a'][0]]!=s[i]) ans = "No";
      //cout << t[al[k-'a'][0]] << " " << t[i] <<endl;
    }
  }
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 2824
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n, c, val;
    cin >> n >> c;
    vector<vector<int>> D(c, vector<int>(c, 0));
    for(int i = 0; i < c; i++) {
        for(int j = 0; j < c; j++)
            cin >> D[i][j];
    }
    vector<vector<int>> cnt(3, vector<int>(c, 0));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            cin >> val;
            cnt[(i+j)%3][val-1] += 1;
        }
    }
    ll ans = INT_MAX;
    for(int i = 0; i < c; i++) {
        for(int j = 0; j < c; j++) {
            if (j == i) continue;
            for(int k = 0; k < c; k++) {
                if (k == i || k == j) continue;
                ll acc = 0;
                for(int x = 0; x < c; x++)
                    acc += cnt[0][x] * D[x][i];
                for(int x = 0; x < c; x++)
                    acc += cnt[1][x] * D[x][j];
                for(int x = 0; x < c; x++)
                    acc += cnt[2][x] * D[x][k];
                ans = min(ans, acc);
            }
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int[] f = new int[b];
		for(int i=0;i<a;i++){
			int c = scan.nextInt();
			for(int l=0;l<c;l++){
				int d = scan.nextInt();
				f[d-1]++;
			}
		}
		int ans=0;
		Arrays.sort(f);
		for(int i=b-1;i>=0;i--){
			if(f[i]!=a){break;}else{ans++;}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
M,D = map(int,input().split())
count = 0
if D < 22:
  print(count)
  exit()

for i in range(1,M+1):
  for j in range(22,D+1):
    if i == (j//10) * (j%10):
      if j%10 <= 1:
        continue
      else:
        count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N, K; cin >> N >> K;
	cout << (K==1?0:N - K) << endl;

}


Measured memory_bytes: 3564
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;


immutable long MOD = 10^^9+7;

void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0];
    auto M = s[1];
    auto X = readln.split.map!(to!long).array;
    auto Y = readln.split.map!(to!long).array;
    auto DX = new long[](N-1);
    auto DY = new long[](M-1);
    foreach (i; 0..N-1) DX[i] = (X[i+1] - X[i]) % MOD;
    foreach (i; 0..M-1) DY[i] = (Y[i+1] - Y[i]) % MOD;

    long width = 0;
    long left = 1;
    long right = N - 1;
    foreach (i; 0..N-1) {
        width += left * right % MOD * DX[i] % MOD;
        width %= MOD;
        left += 1;
        right -= 1;
    }

    long ans = 0;
    long up = 1;
    long down = M - 1;
    foreach (i; 0..M-1) {
        ans += up * down % MOD * width % MOD * DY[i] % MOD;
        ans %= MOD;
        up += 1;
        down -= 1;
    }

    ans.writeln;

}


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

#define BUF 12

int main(void) {
  long long int n;
  scanf("%lld", &n);
  char str[BUF];
  memset(str, '\0', BUF);

  int pointer = 0;
  while (((n - 1) / 26)) {
    str[pointer] = (char) ((n - 1) % 26 + 97);
    n /= 26;
    if (str[pointer] == 'z') n -= 1;
    pointer++;
  }
  str[pointer] = (char) ((n - 1) % 26 + 97);
  n /= 26;
  pointer++;

  for (int i = 0; i < pointer; i++) {
    printf("%c", str[pointer - i - 1]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 1664
n=int(input())
rest = 0
x = input().split()
rest = 0

for i in range((n-1)//2):
  rest = rest + int(x[2*i])
  rest = rest - int(x[2*i+1])
rest = rest + int(x[n-1])
a = rest // 2

ans = [0]*n
ans[0] = 2 * a
for i in range(1, n):
  #print(int(x[i-1]), " ", ans[i-1]//2)
  ans[i] = 2*(int(x[i-1]) - ans[i-1]//2)
for i in range(n):
  print(ans[i])

Measured memory_bytes: 15284
# -*- coding:utf-8 -*-
import itertools
H, W = map(int, input().split())
s = [ list(input()) for h in range(H) ]
for y in range(H):
    for x in range(W):
        if s[y][x] == '#':
            continue
        y1 = [ tmp for tmp in [ y-1, y, y+1 ] if tmp >= 0 and tmp < H ]
        x1 = [ tmp for tmp in [ x-1, x, x+1 ] if tmp >= 0 and tmp < W ]
        bomb = 0
        for pair in itertools.product(y1,x1):
            if pair[0] == y and pair[1] == x:
                continue
            if s[pair[0]][pair[1]] == '#':
                bomb += 1
            else:
                pass
        s[y][x] = str(bomb)
for y in range(H):
    print(''.join(s[y]))

Measured memory_bytes: 3188
h = int(input())
w = int(input())
n = int(input())
cnt = 0
if h > w:
    while True:
        if n <= 0:
            break
        n -= h
        cnt += 1
    while True:
        if n <= 0:
            break
        n -= (w - 1)
        cnt += 1
else:
    while True:
        if n <= 0:
            break
        n -= w
        cnt += 1
    while True:
        if n <= 0:
            break
        n -= (h - 1)
        cnt += 1
print(cnt)

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

int main(){
  string o, e;
  cin >> o >> e;
  if(o.size() == e.size()){
    for(int i = 0; i < o.size(); i++){
      cout << o[i] << e[i];
    }
    cout << endl;
  }
  else{
    for(int i = 0; i < o.size()-1; i++){
      cout << o[i] << e[i];
    }
    cout << o[o.size()-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int x; cin >> x;
    if((x-3)*(x-5)*(x-7) == 0 ) print("YES");
    else print("NO");
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}

ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

map<ll,ll> prime_factor(ll n){
    map<ll,ll> mp;
    for(ll i=2; i*i<=n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string s;
    cin >> s;
    for (ll i=0;i<3;i++){
        if (s[i]=='1')s[i]='9';
        else s[i]='1';
    }
    cout << s << endl;
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  long long total = 0;
  long long a, highest;
  cin >> highest;
  for (int i = 1; i < n; i++) {
    cin >> a;
    if (a > highest) {
      highest = a;
    } else {
      total += highest - a;
    }
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(VI::iterator it=(v).begin();it!=(v).end();++it)


int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char> > S;
  VVI WALL, WALL2;
  REP(j, W) {
    VI wall2;
    WALL2.PB(wall2);
  }
  REP(i, H) {
    vector<char> v;
    VI wall;
    REP(j, W) {
      char s;
      cin >> s;
      v.PB(s);
      if (s == '#') {
        wall.PB(j);
        WALL2[j].PB(i);
      }
    }
    S.PB(v);
    WALL.PB(wall);
  }
  int res = 0;
  REP(i, H) {
    REP(j, W) {
      if (S[i][j] == '#')
        continue;
      int count = 0;
      int start = -1, end = W;
      VI::iterator it;
      it= lower_bound(ALL(WALL[i]), j); // j以上の最小
      if (it != WALL[i].begin())
        start = *(it-1);
      if (it != WALL[i].end())
        end = *it;
      count += end - start - 1;

      start = -1, end = H;
      it = lower_bound(ALL(WALL2[j]), i);
      if (it != WALL2[j].begin())
        start = *(it-1);
      if (it != WALL2[j].end())
        end = *it;
      count += end - start - 1;

      res = max(res, count - 1);
    }
  }
  // REP(i, H) {
  //   REP(j, W) {
  //     if (S[i][j] == '#')
  //       continue;
  //     int count = 1;
  //     REP(x, 2) {
  //       int dx = 2 * x - 1;
  //       FOR(k, 1, H) {
  //         if (0 > i + dx * k || i + dx * k >= H)
  //           break;
  //         if (S[i + dx * k][j] == '#')
  //           break;
  //         ++count;
  //       }
  //       FOR(k, 1, W) {
  //         if (0 > j + dx * k || j + dx * k >= W)
  //           break;
  //         if (S[i][j + dx * k] == '#')
  //           break;
  //         ++count;
  //       }
  //     }
  //     res = max(res, count);
  //   }
  // }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 36352
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

struct ft {
	vector <int> BIT;
	int sz;
	
	void init(int n) {
		BIT.resize(n + 1, 0);
		sz = n;
	}
	
	void upd(int i, int val) {
		for(; i <= sz; i += i&-i)
		BIT[i] = max(BIT[i], val);
	}
	
	int qry(int i) {
		int mx = 0;
		for(; i; i -= i&-i)
		mx = max(mx, BIT[i]);
		return mx;
	}
};

int main()
{
	boost;
	ll t, n, q, x, i;
	cin >> n >> q;
	
	ll res = (n - 2) * (n - 2);
	
	ft row, col;
	row.init(n);
	col.init(n);
	
	col.upd(n, n);
	row.upd(n, n);
	
	while(q--) {
		cin >> t >> x;
		int ans = 1;
		if(t == 1) {
			int f = 2, l = n, mid;
			while(f <= l) {
				mid = (f + l) / 2;
				if(row.qry(mid) < x) {
					ans = mid;
					f = mid + 1;
				}
				else
				l = mid - 1;
			}
			col.upd(x, ans);
			res -= (ans - 1);
		}
		else {
			int f = 2, l = n, mid;
			while(f <= l) {
				mid = (f + l) / 2;
				if(col.qry(mid) < x) {
					ans = mid;
					f = mid + 1;
				}
				else
				l = mid - 1;
			}
			row.upd(x, ans);
			res -= (ans - 1);
		}
	}
	cout << res;
}


Measured memory_bytes: 4772
#include <stdio.h>

int main() {
	int array[10];
	int max;
	int max_number;

	for(int i = 0; i < 10; i++)
		scanf("%d", &array[i]);	

	for(int i = 0; i < 3; i++) {
		max = array[0];
		max_number = 0;
		for(int j = 1; j < 10; j++) {
			if(max < array[j]) {
				max = array[j];
				max_number = j;
			}		
		}
		printf("%d\n", max);
		array[max_number] = 0;
	}						
	
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int n, k;
vi w;

bool ok(i64 m) {
    int cnt = 0;
    i64 tmp = 0;
    for (int i = 0; i < n; i++) {
        if (tmp + w[i] <= m) {
            tmp += w[i];
        } else {
            cnt++;
            tmp = 0;
            i--;
        }
        if (cnt > k) {
            return false;
        }
    }
    if (tmp) {
        cnt++;
    }
    return cnt <= k;
}

int main() {
    cin >> n >> k;
    i64 l = 0, r = 0;
    for (int i = 0; i < n; i++) {
        int ww;
        cin >> ww;
        w.push_back(ww);
        r += ww;
    }
    while (l < r - 1) {
        i64 m = (l + r) / 2;
        if (ok(m)) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << r << endl;
}


Measured memory_bytes: 3940
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
pre = -10
for aa in a:
    ans += b[aa-1]
    if aa-1 == pre + 1:
        ans += c[pre]
    pre = aa-1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int A, B, C; cin >> A >> B >> C;
	cout << A + B + C - max({A, B, C}) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

 int main(){
  int W, H, x, y, r;

 scanf("%d %d %d %d %d", &W,&H,&x,&y,&r);
 if((x-r < 0 || x+r > W) || (y-r < 0 || y+r > H)){
 printf("No\n");
 }
 else{
 printf("Yes\n");
 }
 return 0;
}
 


Measured memory_bytes: 2048
#include <stdio.h>

int main(){

	int	w, h, x, y, r;

	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

	if ((x - r) < 0 || (x + r) > w){
		printf("No\n");
		return 0;
	}

	if ((y - r) < 0 || (y + r) > h){
		printf("No\n");
		return 0;
	}

	printf("Yes\n");

	return 0;
}

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

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

  vector<int> bridge_count(N);

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    bridge_count.at(a - 1)++;
    bridge_count.at(b - 1)++;
  }

  for (int i = 0; i < N; i++) {
    cout << bridge_count.at(i) << endl;
  }
}

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

// 繰り返し自乗法 mod なし
ll repeatSquaring(ll x, ll n) {
  if (n == 1) return x;
  if (n % 2 == 1) return (x * repeatSquaring(x, n - 1));

  ll half = repeatSquaring(x, n / 2);
  return half * half;
}

int main() {
  ll x;
  cin >> x;

  for (int a = 0; a <= 1000; a++) {
    for (int b = -1000; b <= a; b++) {
      ll a5 = repeatSquaring(a, 5);
      ll b5 = repeatSquaring(b, 5);
      if (a5 - b5 == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3596
N,K,Q = a = map(int,input().split())
a = list(map(int,input().split()))
inf = 10**10
ans = inf
for i in range(N):
    small = a[i]
    seq = []
    seqq = []
    for j in range(N):
        if a[j] < small:
            seq.append(seqq)
            seqq = []
        else:
            seqq.append(a[j])
    seq.append(seqq)
    aaa = []
    for s in seq:
        if len(s)>=K:
            s.sort()
            aaa += s[:len(s)-K+1]
    if len(aaa)>=Q:
        aaa.sort()
        ans = min(ans,aaa[Q-1]-aaa[0])
print(ans)

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

using namespace std;

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

	int n, l;
	vector<string> vec;

	cin >> n >> l;
	vec.resize(n);

	for (auto& a : vec)
		cin >> a;
	sort(vec.begin(), vec.end());
	for (auto a : vec)
		cout << a;
	cout << endl;

	return 0;

}

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

int  main() {
	int n;
	int mod4=0, mod2=0, odd=0;
	int a[10] = { 0 };
	scanf("%d", &n);
	/*for (int i = 0; i < n; i++) {
		scanf("%d", a[i]);
		if (a[i] % 4 == 0)
			mod4++;
		else if (a[i] % 2 == 0)
			mod2++;
		else
			odd++;
	}*/
	int x;
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		if (x % 4 == 0)
			mod4++;
		else if (x % 2 == 0)
			mod2++;
		else
			odd++;
	}
	if (mod4 >= odd)
		printf("Yes");
	else if (odd - mod4 == 1 && mod2 == 0)
		printf("Yes");
	else
		printf("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int main(){
    int n,m;
    cin >> n >> m;
    cout << (n*(n-1) + m*(m-1))/2 << endl;
}

Measured memory_bytes: 256
OFFSET = 80*80

class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)

  def initialize
    @h, @w = gets.split.map &:to_i
    @a = Array.new(h) { gets.split.map &:to_i }
    @b = Array.new(h) { gets.split.map &:to_i }
    @c = Array.new(h){ |y| Array.new(w){ |x| a[y][x] - b[y][x] } }
  end
  
  def each_grid
    h.times do |y|
      w.times do |x|
        yield y - 1, x, y, x if y != 0
        yield y, x - 1, y, x if x != 0
      end
    end
  end

  def solve
    dp = Array.new(h) { Array.new(w, 0) }
    dp[0][0] |= 1 << (OFFSET + c[0][0])
    dp[0][0] |= 1 << (OFFSET - c[0][0])
    
    each_grid do |y, x, ny, nx|
      dp[ny][nx] |= dp[y][x] << c[ny][nx].abs
      dp[ny][nx] |= dp[y][x] >> c[ny][nx].abs
    end
    
    dp[-1][-1]
  end  

  def show(ans)
    0.upto(OFFSET) do |i|
      if ans[OFFSET + i] | ans[OFFSET - i] == 1
        puts i
        exit
      end
    end
  end  
end  

Problem.new.instance_eval do
  show(solve)
end  


Measured memory_bytes: 44492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD { (int)1e9 + 7 };

int main() {
  int N; cin >> N;
  vector<P> x(2 * N);
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    x[i] = {a, 0};
  }
  for (int i = 0; i < N; i++) {
    int b; cin >> b;
    x[i + N] = {b, 1};
  }
  sort(x.begin(), x.end());
  int ac {}, bc {};
  ll ans { 1 };
  for (int i = 0; i < 2 * N; i++) {
    if (x[i].second) {
      if (ac) {
        ans *= ac;
        ans %= MOD;
        ac--;
      } else {
        bc++;
      }
    } else {
      if (bc) {
        ans *= bc;
        ans %= MOD;
        bc--;
      } else {
        ac++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
	int n,x;
	int f = 1;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 10 == 3) {
			cout << " " << i;
			continue;
		}

		x = i;
		while (x /= 10) {
			if (x % 10 == 3) {
				cout << " " << i;
				break;
			}
		}
	}
	cout << "\n";
}


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

using namespace std;

int main()
{
    map <string,int> m;
    int q;
    cin>>q;
    while(q--)
    {
        int a;
        cin>>a;
        if(a==0)
        {
            string key;
            long long x;
            cin>>key>>x;
            m[key]=x;
        }
        else if(a==1)
        {
            string key;
            cin>>key;
            cout<<m[key]<<endl;
        }
        else
        {
            string key;
            cin>>key;
            m.erase(key);
        }
    }
    return 0;
}



Measured memory_bytes: 27808
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let n:i64 = read();
    let m:usize = read();
    let a:Vec<i64> = (0..m).map(|_| read()).collect();

    let sum = a.iter().sum();
    if n >= sum {
        println!("{}",n-sum);
    }else{
        println!("{}",-1);
    }
}


Measured memory_bytes: 2188
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=310;
int n,minl[N][N];
bool imp[N][N];
ll ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			scanf("%d",&minl[i][j]);
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++){
				if(minl[i][k]+minl[k][j]<minl[i][j]){
//					cout<<i<<" "<<j<<" "<<k<<endl;
					puts("-1\n");
					return 0;
				}
			}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++){
				if(i==j||i==k||j==k) continue;
				if(minl[i][k]+minl[k][j]==minl[i][j]) imp[i][j]=1; 
			}
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++) if(!imp[i][j]) ans+=minl[i][j];
	cout<<ans<<endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(false); 

    int n,m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i,n) cin >> h[i]; 
    vector<vector<int>> r(n);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        r[a-1].push_back(b-1);
        r[b-1].push_back(a-1);
    }
    int ans=0;
    rep(i,n) {
        bool flag=1;
        rep(j,r[i].size()) {
            if (h[i]<=h[r[i][j]]) flag=0;
        }
        if (flag) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8740
#include <stdio.h>
#include <math.h>
#include<bits/stdc++.h>
using namespace std;
#define int long long int

int i,j,k,m;
main()
{
   int n;
   cin>>n;
   map<int,int> m;
   for(i=0;i<n;i++)
   {
       int x;cin>>x;
       m[x]++;
   }
   map<int,int>::iterator it;

   int s=0;
   for(it=m.begin();it!=m.end();it++)
   {
      if((*it).first==(*it).second) continue;
       if((*it).first>(*it).second) s+=(*it).second;
       if((*it).first<(*it).second)  s+=((*it).second-(*it).first);

   }
cout<<s<<endl;
}


Measured memory_bytes: 9536
#include<iostream>
#include<string>
using ll=long long;
using namespace std;
ll fun(ll a){
	if (a == 1)return 0;
	if (a == 0)return 0;
	return a*(a - 1) / 2;
}
int main(){
	string str;
	cin >> str;
	ll out = 0, me[str.length()] ;

	char c[str.length()];
	ll cnt[str.length()], count = 0;
	char tmp = str[0];
	for (int i = 0; i < str.length(); i++){
		cnt[i] = 0;
		
	}
  for (char ca = 'a'; ca <= 'z'; ca++){
    me[ca]=0;
  }
	for (int i = 0; i < str.length(); i++){

	
			c[i] = str[i];
			
		
	}
	
	
		for (int i = 0; i < str.length(); i++){
			for (char ca = 'a'; ca <= 'z'; ca++){
				if (c[i] == ca){
					me[ca]++;
				}
		}
	}
		out = fun(str.length());
		for (char ca = 'a'; ca <= 'z'; ca++){
          
			out -= fun(me[ca]);
		}







	
	cout << out+1  << endl;

	
	return 0;


}

Measured memory_bytes: 3716
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut map = HashMap::new();
    for _ in 0..n{
        let count = map.entry(read::<String>()).or_insert(0);
        *count += 1;
    }

    println!("AC x {}",map.get("AC").unwrap_or(&0));
    println!("WA x {}",map.get("WA").unwrap_or(&0));
    println!("TLE x {}",map.get("TLE").unwrap_or(&0));
    println!("RE x {}",map.get("RE").unwrap_or(&0));
}


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

#define f first
#define s second
#define p pair<int,int>
#define P pair<ll,ll>
#define pb push_back
#define ll long long
#define db double
#define zero(a) memset(a,0,sizeof(a))
#define inff(a,n) fill(a,a+n+1,inf)
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define read(x) scanf("%lld",&x)
#define read2(x,y) scanf("%lld%lld",&x,&y)
#define write(x) printf("%lld\n",x)

const int maxn=2e5+5;
const ll inf=1e9;

ll n,m,k,flag,a,b,c,d,ans,cnt,ok,num,dp[maxn];
string s,t;

int main()
{
    vector<P>v(4),v1(4);
    for(int i=0;i<4;i++)
    {
        cin>>v[i].f;
        v[i].s=i;
        v1[i]=v[i];
    }
    cin>>n;
    v1[0].f*=8;
    v1[1].f*=4;
    v1[2].f*=2;
    sort(all(v1));
    //for(int i=0;i<4;i++)cout<<v1[i].f<<" "<<v1[i].s<<endl;
    if(v1[0].s==0)
    {
        cout<<n*4*v[0].f;
    }
    else if(v1[0].s==1)
    {
         cout<<n*2*v[1].f;
    }
    else if(v1[0].s==2)
    {
        cout<<n*v[2].f;
    }
    else if(v1[0].s==3)
    {
        int t=n%2,tt=n/2;
        if(v1[1].s==0)cout<<tt*v[3].f+t*4*v[0].f;
        if(v1[1].s==1)cout<<tt*v[3].f+t*2*v[1].f;
        if(v1[1].s==2)cout<<tt*v[3].f+t*v[2].f;
    }
    return 0;
}

Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    ans = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    ans += 1
    print(ans)


Measured memory_bytes: 5592
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

vector<int> vec;

void dfs(string s, int n, bool flg3, bool flg5, bool flg7){
	if (n == 0){
		if (flg3 == true && flg5 == true && flg7 == true){
			vec.push_back(stoi(s));
		}
		return;
	}
	dfs(s + '7', n-1, flg3, flg5, true);
	dfs(s + '5', n-1, flg3, true, flg7);
	dfs(s + '3', n-1, true, flg5, flg7);
}

int main(){
	int n;
	cin >> n;
	int len = to_string(n).length();
	int ans = 0;

	for (int i = 3; i <= len; i++){
		string s;
		bool flg3 = false, flg5 = false, flg7 = false;
		dfs(s, i, flg3, flg5, flg7);
	}
	for (int i = 0; i < vec.size(); i++){
		if (vec[i] <= n){
			ans++;
		}
	}
	cout << ans << endl;
 	return 0;
 }


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
void solve(){
	
	ll N;
	cin>>N;
	string s;
	cin>>s;
	ll count=0;
	for(int i=0;i<N;i++)
	{
		if(s[i] == 'R')
			count++;
	}
	int ans=0;
	for(int i=0;i<count;i++)
		if(s[i]=='W')
			ans++;

	cout<<ans<<"\n";
	
}
int main()
{
	solve();
	return 0;
}


Measured memory_bytes: 3752
s=str(input())
word=["A","C","G","T"]
con,ans=0,0
for i in range(len(s)):
    if s[i] in word:
        for x in range(len(s)-i):
            if s[i+x] in word:
                con+=1
            else:
                break
        if con > ans:
            ans=con
        con=0
print(ans)

Measured memory_bytes: 9060
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

int w, h;
vector<vector<char>> c;

void dfs(int i, int j) {
    c[i][j] = '0';
    rep(k, 8) {
        int ni = i + dx[k], nj = j + dy[k];
        if(0 <= ni and ni < h and 0 <= nj and nj < w and c[ni][nj] == '1') {
            dfs(ni, nj);
        }
    }
}

void solve() {
    while(cin >> w >> h) {
        if(w == 0 and h == 0) break;
        c.assign(h, vector<char>(w));
        rep(i, h) {
            rep(j, w) {
                cin >> c[i][j];
            }
        }
        int ans = 0;
        rep(i, h) {
            rep(j, w) {
                if(c[i][j] == '1') dfs(i, j), ++ ans;
            }
        }
        cout << ans << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll n,m,l;
vector<ll> k;
vector<ll> s;
vector<ll> acm;
vector<vector<vector<ll>>> memo(2000,vector<vector<ll>>(2,vector<ll>(2000,-1)));

ll sum(ll _l, ll _r) {
	ll ret=0;
	if(_l==0) ret=acm[_r];
	else ret=acm[_r]-acm[_l-1];
	ret-=ret%l;
	return ret;
}

ll dfs(ll pos, ll col, ll bef) {
	if(memo[pos][col][bef]!=-1) return memo[pos][col][bef];
	if(pos==1) return memo[pos][col][bef]=sum(k[0],k[1]);
	if(bef+1!=pos) return memo[pos][col][bef]=sum(k[pos-1],k[pos])+dfs(pos-1,col,bef);
	else {
		ll mini=INF*INF;
		REP(i,pos-1) {
			mini=min(mini,sum(k[i],k[pos])+dfs(pos-1,!col,i));
		}
		return memo[pos][col][bef]=mini;
	}
}

ll solve() {
	vector<ll> vec;
	sort(ALL(k));
	ll ret=INF*INF;
	REP(i,2) REP(j,n-2) {
		ret=min(ret,sum(k[j],k[n-1])+sum(k[n-2],k[n-1])+dfs(n-2,i,j));
	}
	return ret/l;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n>>m>>l;
	k.assign(n,0);
	s.assign(m,0);
	acm.assign(m,0);
	REP(i,n) cin>>k[i];
	REP(i,n) k[i]--;
	REP(i,m) cin>>s[i];
	acm[0]=s[0];
	FOR(i,1,m) acm[i]=acm[i-1]+s[i];
	cout<<solve()<<endl;
}


Measured memory_bytes: 67304
solve :: [Int] -> Int
solve a = min (f a1) (f a2)
  where
    f t = foldl (\acc i -> acc + (i - t)^2) 0 a
    ceilDiv t s = (t + s - 1) `div` s
    a1 = ceilDiv (sum a) (length a)
    a2 = div (sum a) (length a)

main :: IO ()
main = do
    _ <- getLine
    a <- map read . words <$> getLine :: IO [Int]
    print $ solve a

Measured memory_bytes: 1020
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n,k,r,s,p;
  cin >> n >> k >> r >> s >> p;
  string t;
  cin >> t;
  int chk = 0;
  int cnt = 1;
  int ans = 0;
  rep(i,k){
    cnt = 1;
    chk = i;
    rep(j,n){
      if(chk+k > n-1){
        if(t.substr(chk,1) == "r") ans += p*(cnt - (cnt/2));
        else if(t.substr(chk,1) == "s") ans += r*(cnt - (cnt/2));
        else ans += s*(cnt - (cnt/2));
        cnt = 1;
        break;
      }
      if(t.substr(chk,1) == t.substr(chk+k,1)){
        cnt++;
        chk += k;
      }else{
        if(t.substr(chk,1) == "r") ans += p*(cnt - (cnt/2));
        else if(t.substr(chk,1) == "s") ans += r*(cnt - (cnt/2));
        else ans += s*(cnt - (cnt/2));
        cnt = 1;
        chk += k;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 512