akhauriyash/Code-Regression huggingface dataset:
// AOJ 2312: Magical Girl Sayaka-chan
// 2017.11.26 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int N, M, L;
int k[2001];
int s[100001];
long long sum[100002];
long long memo[2001][2001];

char buf[700001], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int cmp(int *a, int *b) { return *a - *b; }

long long kpart(int r, int l) { return (sum[r]-sum[l]) / L; }

long long calc(int l, int r)
{
	int i;
	long long ll, rr;
  
    if (memo[l][r] >= 0) return (memo[l][r]);
	i = r; if (i < l) i = l;
	if (++i == N - 1) return kpart(k[i], k[l]-1) + kpart(k[i], k[r]-1);
     
    ll = calc(i, r) + kpart(k[i], k[l] - 1);
    rr = calc(l, i) + kpart(k[i], k[r] - 1);
	if (ll > rr) ll = rr;
    return memo[l][r] = ll;
}

int main()
{
	int i;

	fgets(p=buf, 30, stdin);
	N = getint(), p++, M = getint(), p++, L = getint();
	fgets(p=buf, sizeof(buf), stdin);
	for (i = 0; i < N; i++) k[i] = getint(), p++;
	qsort(k, N, sizeof(int), cmp);
	fgets(p=buf, sizeof(buf), stdin);
	for (sum[0] = 0, i = 0; i < M; i++) {
		s[i] = getint(), p++;
		sum[i+1] = sum[i] + s[i];
	}
	memset(memo, -1, sizeof(memo));
	printf("%lld\n", calc(0, 0));
	return 0;
}

Measured memory_bytes: 35020
#include <stdio.h>
#include <string.h>
#define N 1000000
#define L 14
char A[N][L];
int getChar(char c);
long long getKey(char str[]);
int h1(int key){ return key%N; }
int h2(int key){ return 1+(key%(N-1)); }
int find(char str[]);
int insert(char str[]);
int main(){
  int i, n;
  char str[L], cmp[9];
  for(i = 0; i < N; i++){
    A[i][0] = '\0';
  }
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s %s", cmp, str);
    if(cmp[0] == 'i'){
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      } }
  }
  return 0; }
int getChar(char c){
  if( c == 'A') return 1;
  else if( c == 'C') return 2;
  else if( c == 'G') return 3;
  else if( c == 'T') return 4;
  else return 0;
}
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++){
    sum += p*(getChar(str[i]));
    p *= 5; }
  return sum; }
int find(char str[]){
  int i, h;
  h = (h1(getKey(str)) + i * h2(getKey(str))) % N;
  for(i = 0; i < 14; i++){
    h = (h1(getKey(str)) + i * h2(getKey(str))) % N;
    if(strcmp(A[h], str) == 0) return 1;
  }
  return 0; }

int insert(char str[]){
  int i;
  if(find(str)) return 0;
  for(i = 0; i < 14; i++){
    if(A[ (h1(getKey(str)) + i * h2(getKey(str))) % N ][0] == '\0'){
      strcpy(A[ (h1(getKey(str)) + i * h2(getKey(str))) % N ], str);
      return 1;
    } }
  return 0; }




Measured memory_bytes: 15408
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll v[105], w[105];
ll dp[10005][10005];
int main() {
	int n, W;
	cin >> n >> W;
	for (int i = 0; i < n; i++) {
		cin >> v[i] >> w[i];
	}
	for (int i = 0; i <= W; i++) {
		dp[0][i] = 0;
	}
	for (int i = 0; i <n; i++) {
		for (int j = 0; j <= W; j++) {
			if (j >= w[i]) {
				dp[i + 1][j] = max({ dp[i][j], dp[i][j - w[i]] + v[i],dp[i + 1][j - w[i]] + v[i] });
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	cout << dp[n][W] << endl;
	return 0;
}


Measured memory_bytes: 11024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << w / 2.0 * h << " ";
    if (w % 2 == 0 && h % 2 == 0 && x * 2 == w && y * 2 == h) {
        cout << 1 << endl;
    } else cout << 0 << endl;
}


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

#define ll long long int
int main() {
	// your code goes here
	ll n,w;
	    cin>>n>>w;
	    ll wt[n],val[n];
	    for(int i=0;i<n;i++){
	    	cin>>wt[i];
	        cin>>val[i];
	    }
	    
	    ll dp[n+1][w+1];
           for(int i=0;i<=n;i++){
               dp[i][0]=0;
           }
           for(int i=0;i<=w;i++){
               dp[0][i]=0;
           }
           for(int i=1;i<=n;i++){
               for(int j=1;j<=w;j++){
                   if(wt[i-1]>j){
                       dp[i][j]=dp[i-1][j];
                   }
                   else{
                       dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+val[i-1]);
                   }
               }
           }
           cout<<dp[n][w]<<endl;
}

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

int main(){
    int n, x, y;
    string s = "No";
    
    cin >> n;
    x = y = 0;
    while ( x <= n && s == "No") {
        y = 0;
        while ( x+y <= n && s == "No" ) {
            if ( x+y == n ) {
                s = "Yes";
            }
            y+=7;
        }
        x+=4;
    }
    
    cout << s << endl;
    
    return (0);
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int long t, i, c1=0,c2=0,c3=0,c4=0;
	string s;
	cin>>t;
	for(i=1;i<=t+1;i++)
	{
		getline(cin,s);
		if(s=="AC")
		++c1;
		if(s=="WA")
		++c2;
		if(s=="TLE")
		++c3;
		if(s=="RE")
		++c4;
	}
	cout<<"AC x "<<c1<<"\n";
	cout<<"WA x "<<c2<<"\n";
	cout<<"TLE x "<<c3<<"\n";
	cout<<"RE x "<<c4<<"\n";
	return 0;
}


Measured memory_bytes: 3664
import java.util.*;
import java.io.*;
public class Main{
  public static void main(String[] args) throws Exception{
Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    int length = s.length();
    int i = (length-1)/2-1;
    int j = (length+3)/2-1;
    boolean flag = false;
    if(isPalindrome(s,0,length-1) && isPalindrome(s,0,i) && isPalindrome(s,j,length-1)){
      System.out.println("Yes");
      flag = true;
    }  
    if(!flag){
      System.out.println("No");
    }
  
  
  
  }
  
    public static boolean isPalindrome(String s,int i,int j){
      while(i<=j){
        if(s.charAt(i)!=s.charAt(j)){
          return false;
        }
        i++;
        j--;
      
    }
      if(i>j){
        return true;
      }
    return false;
      
}
  }


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

using namespace std;

long long int gcd(long long int a,long long int b)
{
    while(a!=b)
    {
        if(a>b){ a=a-b; }
        else {b=b-a;}
    }
    return a;
}


int main()
{
    long long int a,b;
    cin >> a >> b;
    long long int g=gcd(a,b);
    cout << (a*b)/g;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
   int a,b,c,i,count=0;
   scanf("%d %d %d\n",&a,&b,&c);
   for(i=a;i<=b;i++){
       if(c%i==0){
           count++;
       }
   }
   printf("%d\n",count);
   return 0; 
}


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

typedef long long ll;
#define mod 1000000007

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void solve() {
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    vector<ll> ans;
    ans.push_back(a*c);
    ans.push_back(a*d);
    ans.push_back(b*c);
    ans.push_back(b*d);
    sort(ans.rbegin(), ans.rend());
    cout<<ans[0]<<"\n";
}
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    // pre();
    while (t--)
        solve();

    return 0;
}

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

typedef long long ll;
typedef double db;

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, MOD = 1e9 + 7, N = 1e5 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

void test() {
    int x; cin >> x;
    if (x) cout << "0\n";
    else cout << "1\n";
}

int main() {
      fast_io();
      #ifdef HOME
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
      #endif
      cout << fixed << setprecision(15);
      int t = 1;
      // cin >> t;
      for (int i = 1; i <= t; ++i) {
          test();
      }
      #ifdef HOME
          cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
      #endif
      return 0;
}


Measured memory_bytes: 3644
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

cnt = 0

(0..a).each{|i|
  (0..b).each{|j|
    (0..c).each{|k|
      if i * 500 + j * 100 + k *50 == x
        cnt += 1
      end
    }
  }
}

p cnt

Measured memory_bytes: 1788
suits = ["S", "H", "C", "D"]
cards = {}
for s in suits:
    cards[s] = list(range(1, 14))

n = int(input())
for i in range(n):
    card = input().split()
    suit, rank = card[0], int(card[1])
    cards[suit].remove(rank)

for suit, ranks in cards.items():
    if ranks:
        for r in ranks:
            print(suit, r)



Measured memory_bytes: 5596
//package atcoder;

import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			long N = sc.nextLong();
			ArrayList<Integer> array = new ArrayList<Integer>();
	        long i,j;
	        int count = 0;
			for(int x=1;x<=Math.sqrt(N);x++) {
				if(N%x==0) {
					array.add(x);
					//System.out.println(x);
					count ++;	
					//System.out.println(count);
		        }
         	}
			
			i = array.get(count-1);
			j = N/i;
			
			
			System.out.println((i-1)+(j-1));

	}
}

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

int main() {
  int n;
  cin>>n;
  int b,c,d;
  b=n/100;
  c=(n-b*100)/10;
  d=n-b*100-c*10;
  if(b==7||c==7||d==7){
    cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl; }
}


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

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

#define ll long long

#define sl(n) scanf("%lld", &n)
#define ss(n) scanf("%s", n)
#define sf(n) scanf("%lf", &n)

#define PI 2*acos(0.0)
#define INF (1LL<<62)

#define pll pair<ll,ll>

#define pb push_back
#define fr first
#define sc second
#define srt(v) sort(v.begin(), v.end())
using namespace std;

ll checkBit(ll mask, ll pos)
{
    return ((mask&(1LL << pos)) != 0);
}

char grid[7][7];

ll H, W, K;

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

    ll n, i, j, k, x, y, z, cs = 0, ts, l, r;

    sl(H);
    sl(W);
    sl(K);

    for (i = 0; i < H; i++)
        ss(grid[i]);

    z = 0;

    for (ll rm = 0; rm < (1LL << H); rm++)
        for (ll cm = 0; cm < (1LL << W); cm++) {
            ll cnt = 0;
            for (i = 0; i < H; i++)
                for (j = 0; j < W; j++)
                {
                    if (checkBit(rm, i) && checkBit(cm, j) && grid[i][j] == '#')
                        cnt++;
                }

            if (cnt == K)
                z++;
        }

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

    return 0;
}


Measured memory_bytes: 3756
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
def bs_left(l, target):
    low, high = 0, len(l)
    while low < high:
        mid = (low+high)//2
        if l[mid] < target:
            low = mid+1
        else:
            high = mid
    return low

def bs_right(l, target):
    low, high = 0, len(l)
    while low < high:
        mid = (low+high)//2
        if target < l[mid]:
            high = mid
        else:
            low = mid+1
    return low
for j in range(N):
    i = bs_left(A,B[j]) 
    k = bs_right(C,B[j])
    if i != 0 and k != -1:
        ans += i*(N-k)
print(ans)

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a = 0;
	int t[100002] = {};
	for (int i = 0; i < n; i++) {
		cin >> a;

		t[a]++;
		t[a + 1]++;
		t[a + 2]++;
	}

	int mx = 0;
	for (int i = 0; i < 100002; i++) {
		mx = max(mx, t[i]);
	}
	cout << mx << endl;

	return 0;
}

Measured memory_bytes: 640
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

M, D = mapint()

ans = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d = str(d)
        if len(d)!=2:
            continue
        d1 = int(d[1])
        d10 = int(d[0])
        if d1<2 or d10<2: continue
        if m==d1*d10:
            ans += 1

print(ans)

Measured memory_bytes: 71076
#include <stdio.h>
#include<string.h>
int main(void) {
  int a, b, c, tmp;
  scanf("%d %d %d", &a, &b, &c);
  if(a > b){
    tmp = b;
    b = a;
    a = tmp;
  }
  if(b > c){
    tmp = c;
    c = b;
    b = tmp;
  }
  if(a == 5 && b == 5 && c == 7)
    printf("YES\n");
  else {
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 1628
N,M = map(int,input().split())
A = []
for i in range(N):
    a = list(input())
    A.append(a)
B = []
for i in range(M):
    b = list(input())
    B.append(b)
ans = "No"
for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j] == B[0][0]:
            count = 0
            for k in range(M):
                for l in range(M):
                    if A[i+k][j+l] == B[k][l]:
                        count += 1
            if count == M*M:
                ans = "Yes"
                break
print(ans)

Measured memory_bytes: 9168
from sys import stdin
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(stdin.readline().rstrip())

d = 0
for i in range(1,k+1):
    for j in range(i+1,k+1):
        for l in range(j+1,k+1):
            d = d + 6*reduce(gcd, [i,j,l])

for i in range(1,k+1):
    for j in range(1,k+1):
        if j != i: d = d + 3*reduce(gcd, [i,j])

for i in range(1,k+1):
    d = d + i

print (d)

Measured memory_bytes: 9536
#include<iostream>

using namespace std;

const int N = 100000;
int T[N];
bool check(int p, int k, int n){
    int i = 0;
    for (int j = 0; j < k; j++)
    {
        int s = 0;
        while (s + T[i] <= p)
        {
            s += T[i];
            i++;
            if (i == n)
            {
                return true;
            }
        }
    }
    return false;
}

int main(){
    int n, k; cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> T[i];
    }
    int ans = 0;
    int left = 0, right = 100000 * 10000, mid;
    while (right - left > 1)
    {
        mid = (right + left) / 2;
        if(check(mid, k, n)) right = mid;
        else left = mid;
    }
    cout << right << endl;
    
}


Measured memory_bytes: 3504
import sys
from collections import deque, Counter, defaultdict
from itertools import accumulate  # 累積和
from bisect import bisect_left, bisect
from heapq import heappop, heappush  # 優先度付きキュー
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy

N = int(input())
li = []
for i in range(N):
    li.append(int(input()))

idx = 0
for i in range(N):
    if li[idx] == 2:
        print(i + 1)
        sys.exit()
    else:
        idx = li[idx] - 1

print(-1)


Measured memory_bytes: 75348
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include <tuple>
#define int long long 
long long  INF=1'0000'0000'0000'0000'00;
using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int>size;

    UnionFind(int N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
            par[i] = i;
            size[i]=1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        size[x]=par[x];
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        int t=size[root(x)];
        size[root(y)]+=t;
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
       
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    long long multin(long long  x,long long  y){
        return size[root(x)]*size[root(y)];
    }
   
};
signed   main(){

int n,m;
cin>>n>>m;

UnionFind tree(n+1);

long long  a,b;
vector<pair<long long,long long >>bridge;
for(int i=0;i<m;i++){
cin>>a>>b;
bridge.push_back(make_pair(a,b));
}
long long  Ans[m];
Ans[m-1]=(n*(n-1))/2;
a=m-1;
long long k=0;
for(auto iter=bridge.end()-1;iter>=bridge.begin();iter--){
if(tree.same(iter->first,iter->second)){
    Ans[a-1]=Ans[a];
}
else{
Ans[a-1]=max(Ans[a]-tree.multin(iter->first,iter->second),k);
}
tree.unite(iter->first,iter->second);
a--;
}   


for(int i=0;i<m;i++){
    cout<<Ans[i]<<endl;
}
 return 0;
}

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	ll n;
	string str;
	cin >> str >> n;
	int len = str.size();
	ll i = 0;

	while (n > 0 && i < len) {
		if (123 <= n + (ll)str[i] && str[i] != 'a') {
			n -= 123 - (ll)str[i];
			str[i] = 'a';
		}
		i++;
	}
	if (n > 0) {
		n = n % 26;
		str[len - 1] = (char)(((ll)str[len - 1] + n - 'a') % 26 + 'a');
	}
	cout << str << endl;
}




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


	solve();
	system("PAUSE");
	return 0;
}

Measured memory_bytes: 740
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
    int h,a;
    cin >> h >> a;
    int cnt = 0;
    while(h>0) {
        h -= a;
        cnt++;
    }
    cout << cnt << endl;
}


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

int main()
{
    int k, s;
    cin >> k >> s;
    int x,y,z;
    int count=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            x=i;
            y=j;
            z=s-i-j;
            if(z>=0&&z<=k){
                count++;
            }
        }
    }
    cout<<count;
}


Measured memory_bytes: 256
import java.util.*;

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

      int n = Integer.parseInt(sc.next());

      double[] x = new double[n];
      double[] y = new double[n];
      for(int i=0;i<n;i++){
        x[i] = Double.parseDouble(sc.next());
        y[i] = Double.parseDouble(sc.next());
      }

      double[] z = new double[n];

      double sum = 0;

      //全2点間の距離を加算
      for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
          double dx = x[i]-x[j%n];;
          double dy = y[i]-y[j%n];
          z[i] = Math.sqrt(Math.pow(dx,2)+Math.pow(dy,2));
          sum += z[i];
        }
      }

      //どの2点間に関しても、2(n-1)!回通る。
      //全通りはn!
      //sum*2(n-1)!/n!=sum*2/n;

      sum = sum*2/n;

      System.out.println(sum);

    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

const int MAXN = 200200;
const int MOD = 1000000007;
const int INF = 2000000000;
const double PI = 3.14159265358979;
const int dir_4r[] = { -1, 1, 0, 0 };
const int dir_4c[] = { 0, 0, -1, 1 };
const int dir_8r[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int dir_8c[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

vector<int> mat[MAXN];
int n, m, a, b;

bool dfs(int k, int t)
{
	if (k == n)
		return true;
	if (t > 2)
		return false;
	for (int i = 0; i < mat[k].size(); ++i)
		if (dfs(mat[k][i], t + 1))
			return true;
	return false;
}
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i)
	{
		scanf("%d%d", &a, &b);
		mat[a].push_back(b);
		mat[b].push_back(a);
	}

	if (dfs(1, 1))
		cout << "POSSIBLE" << endl;
	else
		cout << "IMPOSSIBLE" << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 12016
#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>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    rep(i,n) p[i]--;
    UnionFind uf(n);
    rep(i,m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        uf.unite(x,y);
    }
    int ans = 0;
    rep(i,n) {
        if (uf.same(p[i],i)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3976
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


h, w, k = map(int, input().split())
A = [input() for i in range(h)]
ans = 0

for a in range(1<<h):
    for b in range(1<<w):
        M = [[0] * w for _ in range(h)]
        for i in range(h):
            for j in range(w):
                if A[i][j] == "#":
                    M[i][j] = 1
        for i in range(h):
            if (a >> i) & 1:
                for j in range(w):
                    M[i][j] = 0

        for j in range(w):
            if (b >> j) & 1:
                for i in range(h):
                    M[i][j] = 0

        count = 0
        for i in range(h):
            for j in range(w):
                if M[i][j] == 1:
                    count += 1
        # print(bin(a)[2:], bin(b)[2:], count)

        if count == k:
            ans += 1

print(ans)


Measured memory_bytes: 69928
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
maxn = max(max(X), A)

dp = [[0] * (2 * N * maxn + 1) for _ in range(N + 1)]
dp[0][N * maxn] = 1

for i in range(N):
    for k in range(2 * N * maxn + 1):
        dp[i + 1][k] = dp[i][k]
        if 0 <= k - X[i] <= 2 * N * maxn:
            dp[i + 1][k] += dp[i][k - X[i]]

print(dp[N][N * maxn] - 1)


Measured memory_bytes: 5104
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e-a> k) print(":(");
    else print("Yay!");
    return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use std::collections::BinaryHeap;

#[fastout]
fn main() {
    /*
     * $BJ}?K(B
     *
     *  - $BBg$-$$$b$N$+$i=g$KF~$l$F$$$/(B
     *  - $BF~$l$k>l=j$O:GBg$N$b$N$HFsHVL\$KBg$-$$$b$N$N4V(B
     *  - $B:GBg$N$b$N$,(B 2 $B$D0J>e$"$k>l9g$O$=$N4V$KF~$l$k(B
     *  - $B:GBg$N$b$N$,(B 1 $B$D$7$+$J$/!"$^$?FsHVL\$N$b$N$,(B 2 $B$D0J>e$"$k>l9g$OFsHVL\$N$b$N$N4V$KF~$l$k(B
     *  ($BFsHVL\$N$b$N$OO"B3$7$F$$$k$O$:!#$?$@$7!"(B)
     *
     *  $B$F$+(B greedy $B$K2r$1$k!)(B
     *  priority queue $B$K(B pair $B$N:G>.CM$rF~$l$k(B
     *   $B"*(B $B9b$$$b$N$+$i=g$K(B pop $B$7!"(Bres+=1 $B$7!"(Bnew pair $B$N:G>.CM(B*2 $B$r(B push
     *
     * */
    input! {
        n: usize,
        mut a: [usize; n],
    }
    a.sort();
    a.reverse();

    let mut res = 0;
    let mut bh = BinaryHeap::new();

    for a_i in a {
        if bh.len() == 0 {
            bh.push(a_i);
        } else {
            let confort = bh.pop();
            if let Some(confort_cnt) = confort {
                res += confort_cnt;
            } else {
                panic!("None has poped from the bh.")
            }
            bh.push(a_i);
            bh.push(a_i);
        }
    }

    println!("{}", res);
}


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

namespace B_015_46
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            new Logic_A().Start();
            Console.ReadLine();
        }

        public class Logic_A
        {
            public void Start()
            {
                var str = Console.ReadLine().Split(' ');
                var a = Convert.ToInt32(str[0]);
                var b = Convert.ToInt32(str[1]);
                var c = Convert.ToInt32(str[2]);

                Console.WriteLine((a == b && a != c || b == c && a != b || c == a && a != b) ?
                    2 : a == b && b == c ? 1 : 3);
            }
        }
    }
}

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

using ll = long long;
#define MOD 1000000007

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

/***** MAIN *****/
signed main() {
  int n; cin >> n;
  mint ans = mint(10).pow(n);
  ans -= mint(9).pow(n) * 2;
  ans += mint(8).pow(n);
  cout << ans << endl;
  return 0;
}
/***** MAIN *****/

Measured memory_bytes: 3584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            out.println(b + Math.min(c, a + b + 1));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22996
#include<stdio.h>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
map<ll,int>mp;
ll a[200000+100];
ll power[40];
int len=0;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",&a[i]),mp[a[i]]++;
    sort(a,a+n);
    for(ll i=2;i<=2000000000;i*=2)
        power[len++]=i;
    ll sum=0;
    for(int i=n-1;i>=0;i--)
    {
        for(int k=0;k<len;k++)
        {
            
            if(power[k]>a[i])
            {
                ll q=a[i];
                ll b=power[k]-q;
                ll c,d;
                
                c=mp[q];
                d=mp[b];
                if(d!=0 && c!=0)
                {
                    //    printf("%d %d %d %d\n",q,b,c,d);
                    if(b==q)
                    {
                        sum+=c/2;
                        mp[b]%=2;
                    }
                    else
                    {
                        ll a=c<d?c:d;
                        sum+=a;
                        mp[q]-=a;
                        mp[b]-=a;
                    }
                }
            }
        }
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 45312
n,m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))
ans = 0

for i in range(m):
    s[i].pop(0)

#print(s)
for i in range(2**n):
    tmp = [False] * m
    #print(bin(i))
    for j in range(n):
        if (i>>j) & 1:
            for k in range(m):
                if (j+1) in s[k]:
                    tmp[k] = not tmp[k]
    #print(tmp,p,tmp == p)
    if tmp == p:
        ans += 1
print(ans)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    ll dx = tx - sx, dy = ty - sy;

    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx, 'L');
    cout << 'L' << string(dy + 1, 'U') << string(dx+1, 'R') << 'D';
    cout << 'R' << string(dy + 1, 'D') << string(dx+1, 'L') << 'U';
    cout << endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <stdio.h>

#define BUF_SIZE 20008

using namespace std;

stack<int> ST;

void calcS(){

}

int main(){

	char buf[BUF_SIZE];
	int heightTable[BUF_SIZE],maxHeightTable[BUF_SIZE],height = 0,maxHeight = 0,i;

	fgets(buf,BUF_SIZE,stdin);

	char current,history = 's';

	for(i = 0;;i++){
		current = buf[i];
		if(history == '/'){
			height += 1;
		}else if(history == '\\'){
			height -= 1;
		}else{
			//Do nothing
		}
		heightTable[i] = height;
		if(i == 0){
			if(buf[0] == '\\'){
				maxHeightTable[i] = 0;
			}else{
				maxHeightTable[i] = -1;
			}

		}else{
			maxHeightTable[i] = maxHeightTable[i-1];
		}

		if(maxHeight <= height && ((history == '/' && current == '\\')
				|| (history == '_' && current == '\\') || (history == '/' && current== '\n'))){
			maxHeightTable[i] = i;
			maxHeight = height;
		}
		history = current;

		if(current ==  '\n'){
			break;
		}
	}


	int total = 0,left = 0,baseHeight = 0,S = 0,tmp,joutei = 0,katei = 0,k = 0,pool_count = 0;

	for(; i > 0; ){

		if(maxHeightTable[i-1] == -1){
				break;
		}else{

			if(buf[i-1] == '/'){
				tmp = 0;
				if(maxHeightTable[i] == i || heightTable[i] > heightTable[maxHeightTable[i-1]]){
					left = maxHeightTable[i-1];
					baseHeight = heightTable[left];
					k = left;
					while(true){
						joutei = 10*(baseHeight - heightTable[k]);
						katei = 10*(baseHeight - heightTable[k+1]);
						tmp += (joutei+katei)/2;
						if(baseHeight ==  heightTable[k+1]){
							break;
						}
						k++;
					}
					S = tmp/10;
					if( S!= 0){
						total += S;
						ST.push(S);
						pool_count++;
					}
					i = left;
				}else{
					for(k = i-1; k >= 0; k--){
						if(heightTable[k] == heightTable[i]){
							break;
						}
					}
					left = k;
					baseHeight = heightTable[left];
					while(true){
							joutei = 10*(baseHeight - heightTable[k]);
							katei = 10*(baseHeight - heightTable[k+1]);
							tmp += (joutei+katei)/2;
							if(baseHeight ==  heightTable[k+1]){
								break;
							}
							k += 1;
					}
					S = tmp/10;
					if( S!= 0){
						total += S;
						ST.push(S);
						pool_count++;
					}
					i = left;
				}
			}else{
				i--;
			}
		}
	}

	printf("%d\n",total);
	printf("%d",pool_count);
	while(!ST.empty()){
		printf(" %d",ST.top());
		ST.pop();
	}
	printf("\n");
}

Measured memory_bytes: 1352
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;


const int INF = 1000000000;
const ll BIG_NUM = 1000000000000000000;



struct UnionFind
{
	vector<int> p;
	vector<int> s;
	UnionFind(int n) :p(n), s(n,1) {
		for (int i = 0; i < n; i++) {
			p[i] = i;
			
		}
	}

	int root(int x) {
		if (p[x] == x) {
			return x;
		}

		p[x] = root(p[x]);
		return p[x];
	}

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) {
			return;
		}

		p[rx] = ry;
		s[ry] += s[ry];
	}

	int size(int x) {
		return s[x];
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}
};


int main() {
	int n, m;
	cin >> n >> m;


	UnionFind uni(n);

	for (int i = 0; i < m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		x--;
		y--;
		uni.unite(x, y);
	}

	set<int> r;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		
		if (uni.root(i) == i) {
			sum++;
		}
	}

	cout << sum << endl;
}




Measured memory_bytes: 1664
from collections import defaultdict
n = int(input())
d = defaultdict(list)
for i in range(n-1):
    u, v, w = map(int, input().split())
    d[u-1].append([v-1, w])
    d[v-1].append([u-1, w])
color = [0] * n
q = [0]
seen = set()
while q:
    parent = q.pop()
    for child in d[parent]:
        j, w = child
        if j not in seen:
            color[j] = color[parent]+w
            seen.add(j)
            q.append(j)
for cnt in color:
    if cnt%2 == 0:
        print('0')
    else:
        print('1')
        
        

Measured memory_bytes: 98264
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a <= b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int n,m;cin >> n >> m;
    vvi s(m);
    rep(i, m){
        int k;cin >> k;
        rep(j, k)  {
            int a;cin >> a;a--;
            s[i].pb(a);
        }
    }
    vi p(m);
    rep(i, m) cin >> p[i];
    int count = 0;
    for(int bit = 0;bit < (1<<n);bit++) {
        bool ok = true;
        for(int i = 0;i < m; i++) {
            int cnt = 0;
            for(int j = 0;j < s[i].size(); j++) {
                if(1 & (bit>>s[i][j])) {
                    cnt++;
                }
            }
            if(cnt%2!=p[i]) ok = false;
        }
        if(ok)count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3632
oni = list(map(int, input().split()))
nige = list(map(int, input().split()))
time = int(input())

if nige[1]>=oni[1]:
    print("NO")
else:
    distance = abs(oni[0]-nige[0])
    diff = oni[1]-nige[1]
    need_time = distance / diff
    if need_time > time:
        print("NO")
    else:
        print("YES")

Measured memory_bytes: 61676
cell_num = int(input())
height = list(map(int, input().split()))
flag = True

if cell_num != 1:
    if height[0] - height[1] <= 1:
        height[0] -= 1
    elif height[0] - height[1] > 1:
        flag = False
    
    for i in range(1,cell_num-1):
        if height[i] - height[i+1] > 1:
            flag = False
            break
        elif height[i] -  height[i+1] <= 1 and height[i-1] < height[i]:
            height[i] -= 1
        elif height[i] -  height[i+1] == 1 and height[i-1] == height[i]:
            flag = False
            break
            
if flag: print("Yes")
else: print("No")

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

int main(){
    int n;
    cin >> n;
    vector<double> a(n);
    int i;
    for(i = 0; i < n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    for(i = 0; i < n-1; i++){
        a.at(i+1) = (a.at(i)+a.at(i+1))/2.0;
    }
    cout << a.at(n-1) << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

ll f(string s) {
	ll res = 0;
	for (int i = 0; i < (int)s.size() - 1; i++) {
		if (s[i] == s[i + 1]) {
			s[i + 1] = '#';
			res++;
		}
	}

	return res;
}

ll solve(string s, ll k) {
	ll n = s.size();
	if (s == string(n, s[0])) {
		return n * k / 2LL;
	}

	ll scoreA = f(s);
	ll scoreB = f(s + s);

	return scoreA + (scoreB - scoreA) * (k - 1);
}

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

	string s;
	ll k;
	cin >> s >> k;

	ll ans = solve(s, k);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
        while (true) {
            int n = sc.nextInt(), x = sc.nextInt();
            if (n == 0 && x == 0) {
                break;
            }
            int count = 0;
            for (int a = 1; a <= n; a++)
                for (int b = a + 1; b <= n; b++)
                    for (int c = b + 1; c <= n; c++) {
                        if (a + b + c == x) {
                            count++;
                        }
                    }
            ln(count);
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}


Measured memory_bytes: 26772
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
constexpr ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}
 
#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll ans=10000;

    string s,t;

    cin >> s >> t;

    ll sum = 0;

    for(ll i=0; i<=s.size()-t.size(); i++){
        ll cnt=0;
        for(ll j=0; j<t.size(); j++){
            if(s[i+j]!=t[j]){
                cnt++;
            }
        }
        ans = min(ans, cnt);
    }

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



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int n,m,x;
  cin>>n>>m>>x;
  int cnt=0;
  veci v(n,0);
  rep(i,m){
    int cur;
    cin>>cur;
    v[cur]=1;
  }
  int cur=x;
  rep(i,x){cur--;cnt+=v[cur];}
  cur=x;
  int cnt2=0;
  for(cur=x;cur<n;cur++)cnt2+=v[cur];cerr<<cnt<<' '<<cnt2;
  cnt=min(cnt,cnt2);
  cout<<cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 1000000007;

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

	int n, p;
	string s;
	cin >> n >> p >> s;

	ll ans = 0;

	if (p == 2 || p == 5) {
		rrep(i, n - 1) if ((s[i]-'0') % p == 0) ans += (ll)(i + 1);
	}
	else {
		map<int, int> q;
		ll sum = 0;
		int ten = 1;
		rrep(i, n - 1) {
			sum += ten * (int)(s[i]-'0');
			sum %= p;
			if (sum == 0) ++ans;
			ans += (ll)q[sum];
			q[sum] += 1;
			ten *= 10;
			ten %= p;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 916