akhauriyash/Code-Regression huggingface dataset:
#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);
#define max3(a,b,c) max(a,max(b,c)) 
#define mix3(a,b,c) mix(a,mix(b,c))

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 a,b,x;cin>>a>>b>>x;
    double ans;

    if(2*x<=a*a*b){
        ans = atan((double)a*b*b/(2*x))*180/M_PI;
    }else{
        ans = atan((2.0*a*a*b-2.0*x)/(a*a*a))*180/M_PI; 
    }
    
    printf("%0.10f\n",ans);

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define esp 1e-6
using namespace std;
long long  read(){
	long long x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

char s[100];
char t[10]={'Y','A','K','I',};

int main(){
	cin>>s;
	for (int i=0;i<=3;i++){
		if(s[i]!=t[i]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	var n, l int
	fmt.Scan(&n, &l)
	s := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s[i])
	}
	sort.Strings(s)
	fmt.Println(strings.Join(s, ""))
}


Measured memory_bytes: 640
N, M = map(int,input().split())


LR = [list(map(int,input().split())) for _ in range(M)]


    

L = [x[0] for x in LR]
R = [x[1] for x in LR]


if  min(R) - max(L)>=0:
  print(min(R)-max(L)+1)
else:
  print(0)


Measured memory_bytes: 29048
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
//#define bint int1024_t
#define ld long double
#define vect vector<ll>
#define unmap unordered_map
#define pb push_back
#define F first
#define pll pair<ll,ll>
#define S second
#define pi 3.1415926536
#define mod int(1e9+7)
#define mp make_pair
//ios_base::sync_with_stdio(false);cin.tie(NULL);
#define testcases ll t; cin>>t; while(t--)

using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    char a;
    cin>>a;

    if(a>='A'&&a<='Z') cout<<"A";
    else cout<<"a";

    return 0;
}


Measured memory_bytes: 3608
// 両側探索というアルゴリズムらしい(初めて知った)
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;

int dp[3628801][2] = {};
int fact[10];

int enc(string s){
    int cnt[10] = {};
    int ret = 0;
    for(int i = 0; i < s.length(); i++){
        int tmp = 0;
        for(int j = 0; j < s[i]-'0'; j++)   tmp += 1-cnt[j];
        ret += fact[s.length()-1-i]*tmp;
        cnt[s[i]-'0'] = 1;
    }
    return ret;
}

void f(int id, string ini, int n){
    dp[enc(ini)][id] = 0;
    queue<pair<string,int>> q;
    q.push({ini, enc(ini)});
    while(!q.empty()){
        pair<string,int> p = q.front();   q.pop();
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                string cp = p.first;
                reverse(cp.begin()+i, cp.begin()+j+1);
                int ni = enc(cp);
                if(dp[ni][id] > dp[p.second][id]+1){
                    dp[ni][id] = dp[p.second][id]+1;
                    if(dp[ni][id] == 4) continue;
                    q.push({cp, ni});
                }
            }
        }
    }
}

int main(){
    fact[1] = 1;
    for(int i = 2; i < 10; i++) fact[i] = fact[i-1]*i;

    memset(dp, 0x3f, sizeof(dp));
    
    int n;
    cin >> n;
    
    string tmp = "", ideal = "";
    for(int i = 0; i < n; i++){
        int a;  cin >> a;
        tmp += ('0' + --a);
        ideal += ('0' + i);
    }
    
    f(0, tmp, n);
    f(1, ideal, n);
    
    int ans = n-1;
    for(int i = 0; i < 3628801; i++)    ans = min(ans, dp[i][0]+dp[i][1]);
    cout << ans << endl;
}



Measured memory_bytes: 33060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int s, w;
  cin >> s >> w;
  if (s <= w) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
}

Measured memory_bytes: 3636
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 200100;

char s[N];

int main() {

	scanf("%s", s);

	int n = strlen(s);
	int c = 0;
	long long res = 0;

	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'W') {
			c++;
		} else {
			res += c;
		}
	}

	printf("%lld\n", res);

	return 0;

}

Measured memory_bytes: 384
#include <cstdio>
int main() {
	int n, num, mx = -1, mn = 1e9;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &num);
		if(num > mx) mx = num;
		if(mn > num) mn = num; 
	}
	printf("%d\n", mx - mn);
	return 0;
} 

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

ll mod = 1e9 + 7;
ll dp[1000005][2][2];

int main() {
    int N; cin >> N;
    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++){
        dp[i+1][0][0] += dp[i][0][0]*8;
        dp[i+1][0][0] %= mod;

        dp[i+1][0][1] += dp[i][0][0] + dp[i][0][1]*9;
        dp[i+1][0][1] %= mod;

        dp[i+1][1][0] += dp[i][0][0] + dp[i][1][0]*9;
        dp[i+1][1][0] %= mod;

        dp[i+1][1][1] += dp[i][0][1] + dp[i][1][0] + dp[i][1][1]*10;
        dp[i+1][1][1] %= mod;
    }

    cout << dp[N][1][1] << endl;

    return 0;
}

Measured memory_bytes: 34836
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class Store
{
	public long A { get; private set; }
	public long B { get; private set; }
	
	public Store(long a, long b)
	{
		A = a;
		B = b;
	}
}


public class C
{
	public static void Main()
	{
		string[] args;

		args = Console.ReadLine().Split(' ');
		int N = Int32.Parse(args[0]);
		int M = Int32.Parse(args[1]);
		
		List<Store> storeList = new List<Store>(N);
		for(int i = 0; i < N; i++)
		{
			args = Console.ReadLine().Split(' ');
			long a = Int32.Parse(args[0]);
			long b = Int32.Parse(args[1]);
			storeList.Add(new Store(a,b));
		}
		storeList.Sort((x,y) => (int)(x.A - y.A));
		
		long rest = M;
		long ans = 0;
		int index = 0;
		while(rest > 0)
		{
			Store current = storeList[index];
			index++;
			long a = current.A;
			long b = current.B;
			
			long numBuy = Math.Min(rest, b);
			ans += numBuy * a;
			rest -= numBuy;			
		}		
		
		Console.WriteLine(ans);
	}	
}





Measured memory_bytes: 22724
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N,M,l,r;
int main(){
    cin >> N >> M;
    int judge[N+1000];
    rep1(i,M) cin >> l >> r, judge[l]++, judge[r+1]--;
    rep1(i,N+999) judge[i+1] += judge[i];
    int ct = 0;
    rep1(i,N) if(judge[i] == M) ct++;
    cout << ct << '\n';
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int a, b, x;
    cin >> a >> b >> x;
    cout << ((a + b >= x && a <= x) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();

signed visited[3][100001];
int S, T;
vector<vector<int>> V;

void solve() {
  int N, M;
  cin >> N >> M;

  V.resize(N);
  for (int i = 0; i < M; i++) {
    int u, v;
    cin >> u >> v;
    V[u - 1].push_back(v - 1);
  }

  cin >> S >> T;
  S--;
  T--;

  queue<tuple<int, int, int>> queue;
  queue.emplace(S, 0, 0);

  int ans = -1;
  while (!queue.empty()) {
    auto t = queue.front();
    queue.pop();

    int n = get<0>(t);
    int depth = get<1>(t);
    int len = get<2>(t);

    if (visited[depth][n]) {
      continue;
    }
    visited[depth][n] = 1;

    if (depth == 0 && n == T) {
      ans = len;
      break;
    }

    if (depth == 0) {
      depth = 2;
      len++;
    } else {
      depth--;
    }

    for (int v : V[n]) {
      queue.emplace(v, depth, len);
    }
  }

  cout << ans << endl;
}

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


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

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

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  rep(x, h) rep(y, w) {
    if (s[x][y] == '#') continue;
    char c = '0';
    for (int dx = -1; dx <= 1; ++dx) {
      for (int dy = -1; dy <= 1; ++dy) {
        int nx = x + dx;
        int ny = y + dy;
        if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
        if (s[nx][ny] == '#') ++c;
      }
    }
    s[x][y] = c;
  }

  rep(i, h) cout << s[i] << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    string s;
    cin >> s;
    int flag = 0;
    for(int i = 1; i < 4; i++){
    	if(s[i] == s[i - 1]) {
    		flag = 1;
    		break;
    	}
    }
    if(flag == 1) cout << "Bad" << endl;
    else cout << "Good" << endl;
	return 0;
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		var V = GetInts(N);
		var C = GetInts(N);
		WriteLine(V.Zip(C, (x, y) => x - y).Where(x => (x > 0)).Sum());
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13524
#include <stdio.h>

int main(void)
{
  char S[20];
  scanf("%s",S);
  
  int i=0;
  while(S[i] != '\0'){
    if((i%2 == 0) && (S[i] == 'h')){
      i++;
    }
    else if((i%2 == 1) && (S[i] == 'i')){
      i++;
    }
    else{
      printf("No\n");
      return 0;
    }
  }
    
  if(i % 2 == 0){  
  printf("Yes\n");
  }
  else if(i % 2 == 1){
    printf("No\n");
  }
  return 0;
}
  
    

Measured memory_bytes: 128
import numpy as np

n = map(int, input())
h_list = [int(i) for i in input().split()]
h_list = np.array(h_list)

dp = np.zeros((len(h_list)))
dp[1] = np.abs(h_list[1]-h_list[0])

for i in range(2,len(h_list)):
    temp1 = dp[i-1] + np.abs(h_list[i] - h_list[i-1])
    temp2 = dp[i-2] + np.abs(h_list[i] - h_list[i-2])
    dp[i] = min(temp1, temp2)
    
    
print(int(dp[-1]))

Measured memory_bytes: 23092
#include<iostream>
using namespace std;
int n,totalc,totald;
double B,total,mx,t[100],tmp;
int main(){
  cin>>n;
  cin>>totald>>B>>totalc;
  total=(double)totalc/totald;
  for(int i=0;i<n;i++)cin>>t[i];
  for(int i=n-1;i>0;i--){
    for(int j=0;j<i;j++){
      if(t[j]<t[j+1]){
	tmp=t[j];
	t[j]=t[j+1];
	t[j+1]=tmp;
      }
    }
  }
  for(int i=0;i<n;i++){
    if(t[i]/B>total){
      totalc+=t[i];
      totald+=B;
      total=totalc/totald;
    }
  }
  cout<<(int)total<<endl;
  return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define w(x) cout << (#x) << " is " << x << "\n" ;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
#endif
    int n,mx=0;
    string s ;
    map<string,int>m;
    cin >> n ;
    while(n--)
    {
        cin >> s ;
        mx=max(++m[s],mx);
    }
    for(auto i:m)
    {
        if(i.second==mx)
            cout << i.first << "\n";
    }
    return 0;
}

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

int main(){
    int n;
    while(cin >> n, n){
        int sum = 0, mi = 1000, ma = 0, x;
        for(int i = 0; i < n; i++){
            cin >> x;
            sum += x;
            mi = min(mi, x);
            ma = max(ma, x);
        }
        cout << (sum-mi-ma)/(n-2) << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(0, N):
    inp = input()
    if (inp=='AC'):
        AC = AC + 1
        continue
   
    if (inp=='WA'):
        WA = WA + 1
        continue
    
    if (inp=='TLE'):
        TLE = TLE + 1
        continue
        
    RE = RE + 1
    
print(f'AC x {AC}')
print(f'WA x {WA}')
print(f'TLE x {TLE}')
print(f'RE x {RE}')
 

Measured memory_bytes: 9196
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 1 << 19, MOD = 924844033, G = 5;
typedef long long i64;

class Edge {
public:
  int nxt, to;
} e[MAX_N << 1];

int head[MAX_N], cnt;
void addedge(int u, int v) {
  e[++cnt] = (Edge){head[u], v}, head[u] = cnt;
  e[++cnt] = (Edge){head[v], u}, head[v] = cnt;
}

int N, sz[MAX_N];
i64 val[MAX_N];

void dfs(int u, int v) {
  sz[u] = 1, val[N]++;
  for (int i = head[u]; i; i = e[i].nxt)
    if (e[i].to != v) {
      dfs(e[i].to, u);
      sz[u] += sz[e[i].to];
      val[sz[e[i].to]]--;
    }
  val[N - sz[u]]--;
}

void rader(i64 *y, int len) {
  for (int i = 1, j = len >> 1; i < len - 1; ++i) {
    if (i < j) swap(y[i], y[j]);
    int k = len >> 1;
    while (j >= k) {
      j -= k;
      k >>= 1;
    }
    if (j < k) j += k;
  }
}

i64 fpm(i64 x, i64 y) {
  i64 res = 1;
  while (y) {
    if (y & 1) res = res * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return res;
}

void DFT(i64 *y, int len, int op) {
  rader(y, len);
  for (int h = 2; h <= len; h <<= 1) {
    i64 wn;
    if (op == 1) wn = fpm(G, (MOD - 1) / h);
    else wn = fpm(G, MOD - 1 - (MOD - 1) / h);

    for (int j = 0; j < len; j += h) {
      int l = h >> 1;
      i64 w = 1;
      for (int k = j; k < j + l; ++k) {
	i64 u = y[k], v = y[k + l] * w % MOD;
	y[k] = (u + v) % MOD, y[k + l] = (u - v) % MOD;
	w = w * wn % MOD;
      }
    }
  }
  if (op == -1) {
    i64 INV = fpm(len, MOD - 2);
    for (int i = 0; i < len; ++i)
      y[i] = y[i] * INV % MOD;
  }
}

i64 fac[MAX_N], ifac[MAX_N], inv[MAX_N];

int main() {
  scanf("%d", &N);
  for (int i = 1, u, v; i < N; ++i) {
    scanf("%d%d", &u, &v);
    addedge(u, v);
  }

  int len = 1;
  while (len <= N + N) len <<= 1;
  
  dfs(1, 0);
  fac[0] = ifac[0] = inv[1] = 1;
  for (int i = 1; i <= N; ++i) fac[i] = fac[i - 1] * i % MOD;
  for (int i = 2; i <= N; ++i) inv[i] = -(MOD / i) * inv[MOD % i] % MOD;
  for (int i = 1; i <= N; ++i) ifac[i] = ifac[i - 1] * inv[i] % MOD;

  static i64 B[MAX_N];
  for (int i = 1; i <= N; ++i) val[i] = val[i] * fac[i] % MOD;
  for (int i = 1; i <= N; ++i) B[i] = ifac[N - i];

  DFT(val, len, 1), DFT(B, len, 1);
  for (int i = 0; i < len; ++i)
    B[i] = val[i] * B[i] % MOD;
  DFT(B, len, -1);

  for (int i = 1; i <= N; ++i) {
    i64 result = B[i + N] * ifac[i] % MOD;
    printf("%lld\n", (result + MOD) % MOD);
  }
  
  return 0;
}


Measured memory_bytes: 32128
N = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

before_sum = 0; a.each{|i| before_sum += i }

if a[0] > b[0]
  a[0] = a[0] - b[0]
  b[0] = 0
else
  b[0] = b[0] - a[0]
  a[0] = 0
end

1.upto(N) do | i |
  # b[i-1]
  if a[i] > b[i-1]
    a[i]   = a[i] - b[i-1]
    b[i-1] = 0
  else
    b[i-1] = b[i-1] - a[i]
    a[i]   = 0
  end

  # b[i]
  next if i == N
  if a[i] > b[i]
    a[i] = a[i] - b[i]
    b[i] = 0
  else
    b[i] = b[i] - a[i]
    a[i] = 0
  end
end

after_sum = 0; a.each{|i| after_sum += i }

p before_sum - after_sum

Measured memory_bytes: 15404
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main() {
  cin.sync_with_stdio(0);
  ll k;
  cin >> k;

  ll x = 0;
  FOR(i,1,1000001) {
	  x = (x * 10 + 7) % k;

	  if(x == 0) {
		  cout << i << endl;
		  return 0;
	  }
  }

  cout << -1 << endl;
}


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

using namespace std;

int main(void) {
    int N, sum = 0, flag = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        if (s == "A") sum++;
        else sum--;
        if (sum < 0) flag = 1;
    }
    if (sum != 0) flag = 1;

    if (flag) cout << "NO\n";
    else cout << "YES\n";

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  
  for(int i=0; i<3; i++){
   	int tmp = n % 10;
    n /= 10;
    if(tmp == 7){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main()
{
    int n, a[200001];
    cin >> n;
    const bool m = n % 2;
    for(int i = m; (m == 0 ? i < n : i <= n); i++){
        cin >> a[i];
    }
    for(int i = (m == 0 ? n-1 : n); i >= 0; i-=2){
            cout << a[i] << ' ';
    }
    for(int i = (m == 0 ? 0 : 2); i < n; i+=2){
            cout << a[i] << ' ';
    }
    return 0;   
}

Measured memory_bytes: 2944
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 200000;

int n;
ll x[MAXN];
int val[MAXN];
ll sum[MAXN + 1];

void run() {
	scanf("%d", &n); REP(i, n) scanf("%lld%d", &x[i], &val[i]);
	sum[0] = 0; REP(i, n) sum[i + 1] = sum[i] + val[i];

	// (sum[r+1]-x[r])+(x[l]-sum[l])
	ll lmx = LLONG_MIN, ret = LLONG_MIN;
	REP(i, n) {
		lmx = max(lmx, x[i] - sum[i]);
		ll r = sum[i + 1] - x[i];
		ll cur = lmx + r; if (cur > ret) ret = cur;
	}
	printf("%lld\n", ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
#include<string.h> 
 
int main()
{
	int N;
	scanf("%d", &N);
	int a[N];
	int r;
	
	for(r=0; r<N; r++){
		scanf("%d", &a[r]);
	}
	
	int c = 0;
	
	for(r=0; r<N; r++){
		if(a[r] == c+1){
			c++;
		}
	}
	
	if(c==0) printf("-1"); 
	else printf("%d",N-c);
	
	
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std ;
#define rep(i,a,n) for(int i =a;i<n;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	ios;
	long long int n;
	cin>>n;
	cout<<(n*(n-1))/2;
	return 0;
	
}

Measured memory_bytes: 256
s = input()
if s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)
elif s == 'SAT':
    print(1)


Measured memory_bytes: 2940
#include <stdio.h>
#define CALC(a, b) (((a)-(b))*((a)-(b)))

int Num[110];

int N;

int main(void) {
	int i, j, tmp;
  	int min = 300, max = -300;
	int tot_min = 987654321;

  	scanf("%d", &N);
  	for (i = 0; i < N; i++) {
    		scanf("%d", &tmp);
		Num[i] = tmp;
		if (tmp < min) min = tmp;
		if (tmp > max) max = tmp;
    	}

	for (i = min; i <= max; i++) {
		tmp = 0;
		for (j = 0; j < N; j++) { 
			tmp += CALC(Num[j], i);
			if (tmp > tot_min) break;
		}
		if (j == N) tot_min = tmp;
	}	
  	
	printf("%d\n", tot_min);

	return 0;
}

Measured memory_bytes: 128
L = input()
n = len(L)
onecnt = 0
ans = 0

MOD = 10 ** 9 + 7
for i in range(n):
    if(L[i] == '0'):continue
    onecnt += 1
    rest = n - i - 1
    ans += pow(2, onecnt-1, MOD) * pow(3, rest, MOD) % MOD
    ans %= MOD

ans += pow(2, onecnt, MOD)
    
print(ans % MOD)


Measured memory_bytes: 3316
H = int(input())

ans = 1
if H != 1:
    h = H
    for i in range(1, 40):
        if int(h/2) >= 2:
#            print(i, ans, h, 'a')
            ans += 2**i
            h = int(h/2)
        else:
#            print(i, ans, h, 'b')
            ans += 2**i
            break

print(ans)

Measured memory_bytes: 9084
import std;

void main() {
    int n; scan(n);
    auto a = readints;

    int[int] d;
    foreach (x; a) d[x]++;
    for (int i = 1; i <= n; i++) {
        writeln(d.get(i, 0));
    }
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


Measured memory_bytes: 24080
n=int(input())
a=[0]*n
b=[0]*n
c=[0]*n
for i in range(n):
    a[i],b[i],c[i]=map(int,input().split())

dp=[[0,0,0] for _ in range(n+1)]
for i in range(1,n+1):
    dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a[i-1]
    dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b[i-1]
    dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c[i-1]

print(max(dp[n]))

Measured memory_bytes: 35904
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <cstring>
#include <vector>
#include <queue>
#include <iomanip>
#include <stack>
#include <unordered_set>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e14, flag,cnt;

int main(){
	ll n;
	cin>>n;
	string s;
	cin>>s;
	for(ll i=0; i<n; i++){
		if(s[i]=='R') ans++;
	}
	flag=ans;
	for(ll i=0; i<flag; i++){
		if(s[i]=='R') ans--;
	}
	cout<<ans;
}


Measured memory_bytes: 3732
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int dp[110][10010];

int main(){
    int N,W;
    cin >> N >> W;
    using pii = pair<int,int>;
    vector<pii> goods(N);
    rep(i,N){
        int a,b;
        cin >> a >> b;
        goods[i]=make_pair(a,b);
    }
    dp[0][0]=0;
    for(int i=1;i<=N;i++){
        for(int j=0;j<=W;j++){
            if(j-goods[i-1].second>=0)dp[i][j]=max(dp[i-1][j],dp[i-1][j-goods[i-1].second]+goods[i-1].first);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


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

int num[1000],t=0;

void push(int x){
  t++;
  num[t]=x;
}

int pop(){
  t--;
  return num[t+1];
}

int main(){
  int a,b;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }
 
  printf("%d\n",pop());

  return 0;
}



Measured memory_bytes: 1988
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
  set<string>set;
  ll n;cin>>n;
  rep(i,n){
    string s;cin>>s;
    set.insert(s);
  }
  cout<<set.size()<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 19236
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
    int n,m;
    cin >> n >> m;
    int c = 1e6,che = -1;
    for(int i=0;i<m;i++){
        int l,r;
        cin >> l >> r;
        che = max(che,l);
        c = min(c,r);
    }
    int ans = c-che+1;
    ans = max(0,ans);
    cout << ans << endl;
}
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int SET(int N, int pos)  {return N=N | (1<<pos);}
int RSET(int N,int pos)  {return N= N & ~(1<<pos);}
bool CHK(int N,int pos)  {return (bool)(N & (1<<pos));}

#define ll             long long
#define pll            pair<ll,ll>
#define unique(a)      a.resize(unique(a.begin(), a.end()) - a.begin())
#define fill(v, p)     memset(v,p,sizeof v)
#define all(x)         x.begin(), x.end()
#define index(x,i)     x.find_by_order(i)
#define lesscount(x,i) x.order_of_key(i)
#define PI             acos(-1.0)
#define EPS            0.000000001
#define INF            1e18+10
#define MAX            300005
#define MOD            1000000007


signed int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(0);
	
	ll n, m;
	cin >> n >> m;
	
	long double a[n];
	for(int i=0;i<n;i++) cin>> a[i];
	
	long double sum=0;
	for(int i=0;i<m;i++)
		sum+= (a[i]+1)/2;
	
	long double last=(a[0]+1)/2;
	long double ans=sum;
	int in=1;
	for(int i=m;i<n;i++)
	{
		sum+= (a[i]+1)/2 - last;
		ans=max(ans,sum);
		last=(a[in++]+1)/2;
	}
	
	cout << fixed << setprecision(20) << ans << endl;
	
	
	return 0;
}


Measured memory_bytes: 3456
n = gets.to_i
a = gets.split.map(&:to_i)
lcm = a[0]
if n >= 2
    (1..n-1).each {|i| lcm = lcm * a[i] / lcm.gcd(a[i]) }
end

ans = 0
(0..n-1).each {|i|
    ans += lcm / a[i]
}
puts(ans%1000000007)


Measured memory_bytes: 65740
n, m = map(int, input().split())
h = [0] + list(map(int, input().split()))
ab = sorted([sorted(list(map(int, input().split())))
             for _ in range(m)])

l = [[] for _ in range(n + 1)]

for a, b in ab:
    l[a].append(b)
    l[b].append(a)

cnt = 0
f = 0
for i, v in enumerate(l):
    for k in v:
        if h[i] <= h[k]:
            f = 1
            break
    if f == 0:
        cnt += 1
    f = 0
print(cnt - 1)

Measured memory_bytes: 41484
n, d, a = map(int, input().split())
xh = []
for i in range(n):
    xi, hi = map(int, input().split())
    xh.append([xi, hi])

xh.sort(key=lambda x: x[0])
x, h = [], []
for i in range(n):
    x.append(xh[i][0])
    h.append(xh[i][1])

cnt = 0
dmg = [0 for i in range(n+1)]
for i in range(n):
    xi, hi = x[i], h[i]
    dmg[i] += dmg[i-1]
    hi -= dmg[i]
    if hi <= 0:
        continue
    else:
        num = (hi+a-1)//a
        cnt += num
    point = xi + 2*d
    left = i
    right = n
    while left+1 < right:
        mid = (left+right)//2
        if x[mid] <= point:
            left = mid
        else:
            right = mid
    dmg[i] += num*a
    dmg[left+1] -= num*a
print(cnt)

Measured memory_bytes: 152212
#include <iostream>

using namespace std;

int n, m, ans, table[9][9];

int chack(){
	for(int i=0; i<n; i++){
		int tmp=0;
		for(int j=0; j<n; j++) tmp += table[i][j];
		if(tmp) return 0;
	}
	return 1;
}


void dfs(int x, int y){
	if(y < n-1) y++;
	else if(x < n-1){
		y=0;
		x++;
	} else{
		ans += chack();
		return;
	}

	if(y==0 && 0<x){
		int tmp =0;
		for(int i=0; i<n; i++) tmp += table[x-1][i];
		if(tmp) return;
	}

	if(table[x][y] == 0 && x != y){
		table[x][y] = 1;
		table[y][x] = -1;
		dfs(x, y);

		table[x][y] = -1;
		table[y][x] = 1;
		dfs(x, y);

		table[x][y] = table[y][x] = 0;
	} else dfs(x, y);
}


int main(void) {
	while(1) {
		cin >> n;
		if(!n) break;
		fill(table[0], table[8], 0);
		cin >> m;
		for(int i=0; i<m; i++){
			int x, y; cin >> x >> y;
			x--; y--;
			table[x][y] = 1;
			table[y][x] = -1;
		}

		ans = 0;
		dfs(0, 0);
		cout << ans << endl;
	}
	return 0;
}


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

int main(void){
        int n,x;
        int i,j,k;//i+j+k=x
        int retval;
        while(1) {
                cin>>n>>x;
                retval=0;
                if(n==0 and x==0) {
                        return 0;
                }
                for(i=1;i<=n;i++){
                    for(j=i+1;j<=n;j++){
                        for(k=j+1;k<=n;k++){
                            if(i+j+k==x){
                                retval+=1;
                            }
                        }
                    }
                }
                cout<<retval<<endl;
        }

}



Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

ll dp[2010][2010]={0};
void solve(){
    ll N,M;
    cin>>N>>M;
    vl S(N);
    vl T(M);
    F0R(i,N){
        cin>>S[i];
    }
    F0R(i,M){
        cin>>T[i];
    }
    dp[0][0]=1;
    for(ll i=0;i<=N;i++){
        for(ll j=0;j<=M;j++){
            if(i>0) dp[i][j]+=dp[i-1][j];
            if(j>0) dp[i][j]+=dp[i][j-1];
            if(i>0&&j>0&&S[i-1]!=T[j-1])dp[i][j]+=MOD-dp[i-1][j-1];
            dp[i][j]%=MOD;
        }
    }
    dp[N][M]=(MOD+dp[N][M])%MOD;
    out(dp[N][M]);
}

int main(){
    solve();
    return 0;
}

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

int main() {
  int dan;
  while (cin >> dan && dan>0) {
    int array[dan];
    for (int i=0;i<=dan;++i) {
      if (i==0)
	array[i] = 1;
      else if (i==1)
	array[i] = array[i-1];
      else if (i==2)
	array[i] = array[i-1]+array[i-2];
      else
	array[i] = array[i-1]+array[i-2]+array[i-3];
    }
    cout << (((array[dan]+9)/10)+364)/365 << endl;
  }
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

bool flag[1919];

string chk(string s, int pos, int len) {
	string s1, s2;
	s1 = s.substr(0, pos);
	s2 = s.substr(pos + len);
	return s1 + s2;
}

signed main() {
	string s;
	cin >> s;
	bool flag = false;
	for (int i = 0; i < s.length(); i++) {
		for (int j = 0; j < s.length()-i+1; j++) {
			if (chk(s, i, j) == "keyence") flag = true;
		}
	}
	if (flag) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}

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

using namespace std;

struct random_class {
	struct xorshift {
		using result_type = unsigned int;
		result_type x=123456789u,y=362436069u,z=521288629u,w;
		static constexpr result_type min() {return 0u;}
		static constexpr result_type max() {return UINT_MAX;}
		xorshift(result_type a) : w(a) {}
		result_type operator()() {
			result_type t;
			t = x ^ (x << 11);
			x = y; y = z; z = w;
			return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
		}
	};
	random_device rd;
	xorshift xor128;
	using u64 = uint_fast64_t;
	random_class() : rd(), xor128(rd()) {}
	random_class(unsigned int seed) : rd(), xor128(seed) {}
	u64 make_random(u64 min_v, u64 max_v) { return uniform_int_distribution<u64>(min_v, max_v)(xor128);}
	u64 make_random_max() { return uniform_int_distribution<u64>(numeric_limits<u64>::min(), numeric_limits<u64>::max())(xor128);}
};

random_class R;

template<class T>
struct Treap {
	struct node {
		T val;
		double pri;
		node *lch, *rch;
		int cnt;
		node(T v) : val(v), lch(nullptr), rch(nullptr), cnt(1) {
			pri = R.make_random_max();
		}
	};
	node* top;
	Treap(node* t = nullptr) : top(t) {}
	node* update(node* n) {
		n->cnt = count(n->lch) + count(n->rch) + 1;
		return n;
	}
	inline int count(node* n) {
		return !n ? 0 : n->cnt;
	}
	node* merge(node* l, node* r) {
		if (!l || !r) return !l ? r : l;
		if (l->pri > r->pri) {
			l->rch = merge(l->rch, r);
			return update(l);
		} else {
			r->lch = merge(l, r->lch);
			return update(r);
		}
	}
	pair<node*, node*> split(node* t, int k) {
		if (!t) return make_pair(nullptr, nullptr);
		if (k <= count(t->lch)) {
			pair<node*, node*> s = split(t->lch, k);
			t->lch = s.second;
			return make_pair(s.first, update(t));
		} else {
			pair<node*, node*> s = split(t->rch, k - count(t->lch) - 1);
			t->rch = s.first;
			return make_pair(update(t), s.second);
		}
	}
	void insert(const T&& val) {
		int pos = 0;
		node* n = top;
		while (n) {
			if (val < n->val) n = n->lch;
			else pos += count(n->lch) + 1, n = n->rch;
		}
		auto t = split(top, pos);
		n = merge(t.first, new node(val));
		top = merge(n, t.second);
	}
	void insert(const T& val) { insert((T&&) val);}
	const T& at(int idx) {
		assert(0 <= idx && idx < size());
		node* n = top;
		for (int sz = count(n->lch) + 1; sz != idx + 1; sz = count(n->lch) + 1) {
			if (sz <= idx) idx -= sz, n = n->rch;
			else n = n->lch;
		}
		return n->val;
	}
	inline const int size() {
		return count(top);
	}
};

int main() {
	Treap<int> T;
	int N;
	cin >> N;
	vector<int> v;
	for (int i = 0; i < N; i++) {
		int t; cin >> t;
		t -= i;
		T.insert(t);
		v.push_back(t);
	}
	int b = T.at(N / 2);
	long long res = 0;
	for (auto x : v) {
		res += abs(x - b);
	}
	cout << res << endl;
}

Measured memory_bytes: 10356
#include<stdio.h>
int dp[501][501];
char s[501];

int f(int l, int r){
 int m;
//puts("#");
 if(dp[l][r] >= 0) return dp[l][r];
//puts("##");
 if(r-l == 0){dp[l][r]=1;return dp[l][r];}
 if(s[l] != 'm' || s[r-1] !='w')
  {dp[l][r]=0;return dp[l][r];}
 for(m = l+1; m < r-1; m++){
  if(s[m] == 'e'){
   if(f(l+1, m) && f(m+1, r-1)){
    dp[l][r]=1;return dp[l][r];
   }
  }
 }
 dp[l][r]=0;return dp[l][r];
}

 int main(){
  int i,j,k;
  scanf("%s",s);
  for(i=0;s[i]!='\0';i++);
for(j=0;j<501;j++)
  for(k=0;k<501;k++)
    dp[j][k]=-1;
  if(f(0,i)==1) puts("Cat");
  else puts("Rabbit");
//for(j=0;j<i;j++)
//  for(k=0;k<i;k++)
//    printf("%d %d,%d->%d\n",i,j,k,dp[j][k]);
  return 0;
 }

Measured memory_bytes: 1500
#include <stdio.h>

int main(){
	int num;
    int ans = 0;
    char mark;
	char enter;
    
    scanf("%d", &ans);
    
    while(1){
        scanf("%c%c", &enter, &mark);
		scanf("%d", &num);
        switch(mark){
        case '+':
            ans += num;
            break;
        case '-':
            ans -= num;
            break;
        case '/':
            ans /= num;
            break;
        case '*':
            ans *= num;
            break;
        case '=':
            goto end;
        default:;
        }
    }
end:
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 2060
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim();
  var S = Number(inputs);
  var h = Math.floor(S/3600);
  
  var m=Math.floor(S%3600/60);
  var s=S%60;

console.log([h,m,s].join(':'));
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

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

int main(void){
  string S,T;
  cin>>S;
  cin>>T;
  int retval=0;
  for(int i=0;i<S.size();i++){
    if(S[i]!=T[i]){
      retval++;
    }
  }
  cout<<retval<<endl;
  return 0;
}


Measured memory_bytes: 3816
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;

int main(){

    string s;
    cin >> s;

    if(s == "BBB" or s == "AAA"){
        p("No");
    } else {
        p("Yes");
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
using graph = vector<vector<ll>>;


int main() {
	ll n, m,ans=0,mem,a,b;
	vector<ll> h;
	cin >> n >> m;
	vector<ll> answer(n+1,0);
	for (ll i = 0; i < n; i++) {
		cin >> mem;
		h.push_back(mem);
	}
	graph g(n+1);
	for (ll i = 0; i < m; i++) {
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (ll i = 1; i <= n; i++) {
		for (ll j = 0; j < g[i].size(); j++) {
			if (h[g[i][j]-1] < h[i-1]) {
			}
			else {
				answer[i]++;
				break;
			}
		}
	}
	for (ll i = 1; i <= n; i++) {
		if (answer[i] == 0) {
			ans++;
		}
	 }
	cout << ans << endl;
}

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

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}


int a[200000];
int b[200000];
signed main(){
  int n,m,v,p;
  cin >> n >> m >> v >> p;
  REP(i,n){
    cin >> a[i];
  }
  sort(a,a+n);
  reverse(a,a+n);


  int left = 0;
  int right = n;
  while(right - left >= 2){
    int v2 = v;
    int mid = (left+right)/2;
    if(mid < p){
      left = mid;
      continue;
    }
    v2 -= p-1;
    v2 -= n-mid;
    if(v2 <= 0 && a[mid] + m-a[p-1]>=0){
      left = mid;
      continue;
    }
    else if(v2 <= 0 && a[mid] + m-a[p-1]<0){
      right = mid;
      continue;
    }
    int nokori = 0;
    int f = 0;
    for(int i = p-1;i<=mid-1;i++){
      int now = a[mid] + m - a[i];
      if(now < 0) f=1;
      nokori += min(now,m);
    }
    if(f==1){
      right = mid;
      continue;
    }
    if(nokori >= m*v2){
      left = mid;
      continue;
    }
    else{
      right = mid;
      continue;
    }
  }
  cout << right << endl;




    return 0;
}

Measured memory_bytes: 1024