akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	string a,b,c;
	cin>>a>>b>>c;
	if(a[a.length()-1]==b[0]&&b[b.length()-1]==c[0])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        String planes = "";
        int row = 0;
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
            String str = scan.next();
            planes += str;
            if(row++ > 6){
                row = 0;
                if(planes.matches(".*1111.*"))System.out.println("C");
                else if(planes.matches(".*110000011.*"))System.out.println("G");
                else if(planes.matches(".*1100000011.*"))System.out.println("A");
                else if(planes.matches(".*11000000011.*"))System.out.println("E");
                else if(planes.matches(".*1000000110000001.*"))System.out.println("D");
                else if(planes.matches(".*100000001100000001.*"))System.out.println("F");
                else if(planes.matches(".*1000000010000000100000001.*"))System.out.println("B");
                planes = "";
            }
        }
    }
}



Measured memory_bytes: 29256
while input = gets

    n = input.to_f
    
    if n == 0
        exit
    end
    
    scores = gets.chomp.split(" ").map(&:to_i)
    
    sum1 = 0
    sum2 = 0
    scores.each do |x|
        sum1 += x
        sum2 += (x ** 2)
    end
    
    sx = ((sum2 / n) - (sum1 / n) ** 2.0) ** (1/2.0)
    
    puts sprintf("%.8f", sx)
end


Measured memory_bytes: 6972
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
#define REP(i,b,e) for(int i=b; i<e; i++)

int main(){
	int n;
	scanf("%d", &n);
	std::bitset<10> f[n];
	REP(i, 0, n){
		REP(j, 0, 10){
			getchar();
			if(getchar()%2) f[i].set(j);
			else f[i].reset(j);
		}
	}
	
	int p[n][11];
	REP(i, 0, n) REP(j, 0, 11) scanf("%d", &p[i][j]);

	int c[n], ans = -1e9;
	REP(i, 1, 1<<10){
		memset(c, 0, sizeof(c));
		REP(j, 0, 10) if((i>>j)&1) {
			REP(I, 0, n) if(f[I][j]) {
				c[I]++;
			}
		}
		int tmp = 0;
		REP(I, 0, n) tmp += p[I][c[I]];
		if(ans<tmp) ans = tmp;
	}

	printf("%d\n", ans);
	return 0;
}



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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> p(n,k-q);
    for (int i = 0;i < q;++i) {
        int a;
        cin >> a;
        p[a-1]++;
    }
    for (int i = 0;i < n;++i) {
        cout << (p[i] > 0 ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 1024
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { xs <-getInts
  ;  putInts (sort xs)
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")	
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
  
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
  
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next next
#define sz(x) ((int)x.size())
  
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
  
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int mod = 1000000007;

  
#define FILENAME ""
  
const ll MAXN = 1000000 + 10; 


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
  	ll a, b;
  	cin >> a >> b;
  	if (a >= b) cout << 10;
  	else cout << 0;
    re 0;
}

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



int main() {
    int a, b, c; cin >> a >> b >> c;
    if (a == b) cout << c << endl;
    else if (b == c) cout << a << endl;
    else cout << b << endl;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int res = 0;
  for (int x = 0; x < 1000; ++x) {
    string t = to_string(x);
    while (t.size() < 3) {
      t = '0' + t;
    }
    int i = 0, j = 0;
    while (i < n and j < 3) {
      while (i < n and s[i] != t[j]) {
        ++i;
      }
      ++i;
      ++j;
    }
    res += i <= n and j == 3;
  }
  cout << res << '\n';
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
int n,m,h,w;
char a[50][50];

bool check(){
  bool b[50][50];
  char c[50][50];
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)c[i][j]=a[i][j];
  while(1){
    bool up=0;
    for(int i=0;i<h-1;i++){
      for(int j=0;j<w;j++){
        if(c[i][j]!='.' && c[i+1][j]=='.'){
          swap(c[i][j],c[i+1][j]);
          up=1;
        }
      }
    }
    if(!up)break;
  }
  while(1){
    bool update=0;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)b[i][j]=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(j+n>w)continue;
        if(c[i][j]=='.')continue;
        int nowcolor;
        bool flag=1;
        for(int k=0;k<n;k++){
          if(k==0){
            nowcolor=c[i][j+k]-'a';
            continue;
          }
          if(c[i][j+k]!=(char)('a'+nowcolor))flag=0;
        }
        if(flag){
          for(int k=0;k<n;k++){
            b[i][j+k]=1;
          }
        }
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(i+n>h)continue;
        if(c[i][j]=='.')continue;
        int nowcolor;
        bool flag=1;
        for(int k=0;k<n;k++){
          if(k==0){
            nowcolor=c[i+k][j]-'a';
            continue;
          }
          if(c[i+k][j]!=(char)('a'+nowcolor))flag=0;
        }
        if(flag){
          for(int k=0;k<n;k++){
            b[i+k][j]=1;
          }
        }
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(b[i][j]==1){
          c[i][j]='.';
          update=1;
        }
      }
    }
    if(!update)break;
    while(1){
      bool up=0;
      for(int i=0;i<h-1;i++){
        for(int j=0;j<w;j++){
          if(c[i][j]!='.' && c[i+1][j]=='.'){
            swap(c[i][j],c[i+1][j]);
            up=1;
          }
        }
      }
      if(!up)break;
    }
  }
  bool ok=1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(c[i][j]!='.')ok=0;
    }
  }
  return ok;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>h>>w>>n;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w-1;j++){
      //if(a[i][j]!='.' && a[i][j+1]!='.'){
        swap(a[i][j],a[i][j+1]);
        if(check()){
          //cout<<i<<" "<<j<<endl;
          cout<<"YES"<<endl;
          exit(0);
        }
        swap(a[i][j],a[i][j+1]);
      //}
    }
  }
  cout<<"NO"<<endl;
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}







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

using namespace std;

int main() {
  int N;
  cin >> N;
  unordered_set<string> used;
  string last_word = "";
  for (int i = 0; i < N; i++) {
    string W;
    cin >> W;

    if (used.count(W)) {
      cout << "No";
      return 0;
    }
    if (i > 0) {
      if (last_word.back() != W.front()) {
        cout << "No";
        return 0;
      }
    }
    used.insert(W);
    last_word = W;
  }
  cout << "Yes";

  return 0;
}


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

int main() {
    int N;
    int a[110];
    int b[110];
    int avg = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        avg += a[i];
        b[i] = a[i]*N;
    }
    
    int absmin = 100*N;
    int minpos = 0;
    int tmp;
    for (int i = 0; i<N; i++) {
        tmp = abs(b[i]-avg);
        if (tmp < absmin) {
            absmin = tmp;
            minpos = i;
        }
    }

    cout << minpos << endl;
}

Measured memory_bytes: 256
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

import copy

N = ri()
relation = [[] for _ in range(N+1)]
dist = [[0 for i in range(N+1)] for j in range(2)]
for i in range(N-1):
    a,b = rli()
    relation[a].append(b)
    relation[b].append(a)

def dfs_visit(u):
    start = u
    rel = copy.deepcopy(relation)
    s = []
    color = [-1 for _ in range(N+1)]
    s.append(u)
    color[u] = 0
    while(s != list()):
        u = s[-1]
        try:
            v = rel[u].pop()
        except IndexError:
            dist[0 if start == 1 else 1][s[-1]] = len(s)
            s.pop()
            color[u] = 1
            continue
        if(color[v] == -1):
            color[v] = 0
            s.append(v)
 
def dfs():
    dfs_visit(1)
    dfs_visit(N)

dfs()
fe = 0
sn = 0

for i in range(1, N+1):
    if(dist[0][i] <= dist[1][i]):
        fe += 1
    else:
        sn += 1
print("Fennec" if fe > sn else "Snuke")


Measured memory_bytes: 54912
fun main(args: Array<String>) {
    val (N, K, C) = listOfInt()
    val S = next().map { it == 'o'}
    val L = IntArray(N)
    val R = IntArray(N)
    var cnt = 1
    var s = 0
    while (s < N && cnt <= K) {
        if (S[s]) {
            L[s] = cnt++
            s += C + 1
        } else s += 1
    }
    cnt = K
    s = S.size - 1
    while (s >= 0 && cnt > 0) {
        if (S[s]) {
            R[s] = cnt--
            s -= C + 1
        } else s -= 1
    }
    val sb = StringBuilder()
    (0 until N).forEach { n ->
        if (L[n] > 0 && L[n] == R[n]) sb.appendln(n + 1)
    }
    println(sb.toString())
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)




Measured memory_bytes: 44964
h, w = map(int, input().split())
a = [input() for i in range(h)]
w_row = []
w_column = []
for i in range(h):
  black = False
  for j in range(w):
    if a[i][j] == '#':
      black = True
      break
  if not black:
    w_row.append(i)
for i in range(w):
  black = False
  for j in range(h):
    if a[j][i] == '#':
      black = True
      break
  if not black:
    w_column.append(i)
for i in range(h):
  if i in w_row:
    continue
  s = ''
  for j in range(w):
    if j in w_column:
      continue
    s += a[i][j]
  print(s)


Measured memory_bytes: 3064
{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -O2 #-}

import qualified Data.Vector.Unboxed as VU
import Data.Bits
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.List


-- 1 <= damageOther < damageTarget <= 10^9
isPossibleWith :: VU.Vector Int -> Int -> Int -> Int -> Bool
isPossibleWith !hps !damageTarget !damageOther !numMagics
  = (<= numMagics) $ VU.sum $ VU.filter (> 0)
    $ VU.map (\hp -> (hp - damageMin + damageDiff - 1) `div` damageDiff)
    $ hps
  where
    !damageMin = damageOther * numMagics
    !damageDiff = damageTarget - damageOther

query :: VU.Vector Int -> Int -> Int -> Int
query !hps !damageTarget !damageOther = binSearch 0 (10 ^ 9)
  where
    binSearch !ng !ok
      | ok - ng <= 1 = ok
      | isPossibleWith hps damageTarget damageOther mid = binSearch ng mid
      | otherwise = binSearch mid ok
      where
        !mid = (ng + ok) `shiftR` 1

main :: IO ()
main = do
  [n, damageTarget, damageOther]
    <- unfoldr (BS.readInt . BS.dropWhile (==' ')) <$> BS.getLine
  hps <- VU.unfoldrN n (BSL.readInt . BSL.dropWhile (< '-'))
         <$> BSL.getContents
  print $ query hps damageTarget damageOther

Measured memory_bytes: 2684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 1007;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,l,r;
	while(1){
		ll ans = 0;
		cin>>n>>l>>r;
		if(n==0&&l==0&&r==0)break;
		vector<ll> a(n);
		FOR(i,0,n){
			cin>>a[i];
		}
		FOR(i,l,r+1){
			bool bl=true;
			FOR(j,0,n){
				if(i%a[j]==0){
					bl=false;
					if(j%2==0)ans++;
					break;
				}
			}
			if(bl&&n%2==0)ans++;
		}
		cout<<ans<<endl;
	}

}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e18
#define g(x) cout<<x<<" "<<endl;
#define gg(x,y) cout<<x<<" & "<<y<<" "<<endl
#define jam(t) cout<<"Case #"<<t<<": "
#define ggg(x,y,z) cout<<x<<" & "<<y<<" & "<<z<<" "<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define mod 998244353
#define sz 400005
#define bitcnt(x) __builtin_popcountll(x)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

ll dp[sz];

ll t[sz * 4];
ll lazy[sz * 4];
void push(int v) {
    t[v*2] += lazy[v];
    lazy[v*2] += lazy[v];
    t[v*2+1] += lazy[v];
    lazy[v*2+1] += lazy[v];
    lazy[v] = 0;
}

void update(int v, int tl, int tr, int l, int r, int updateend) {
    if (l > r) 
        return;
    if (l == tl && tr == r) {
        t[v] += updateend;
        lazy[v] += updateend;
    } else {
        push(v);
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), updateend);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, updateend);
        t[v] = max(t[v*2], t[v*2+1]);
    }
}

int query(int v, int tl, int tr, int l, int r) {
    if (l > r)
        return -inf;
    if (l <= tl && tr <= r)
        return t[v];
    push(v);
    int tm = (tl + tr) / 2;
    return max(query(v*2, tl, tm, l, min(r, tm)), 
               query(v*2+1, tm+1, tr, max(l, tm+1), r));
}
vector <pair <ll,ll > > ve;
ll destn[sz];
void solve(){
    ll n;
    cin >> n;
    for(ll i=1;i<=n;i++){
        ll x,d;
        cin >> x >> d;
        ve.pb({x,d});
    }
    ve.pb({inf,0});
    sort(all(ve));

    dp[n] = 1;
    //destn[n] = n;
    destn[n] = n;
    update(1,0,n,n,n,n);
    for(ll j=n-1;j>=0;j--){
       ll next = ve[j].F + ve[j].S;
       pair <ll,ll> pp = {next,-inf};
       ll idx = lower_bound(ve.begin() + j,ve.end(),pp) - ve.begin();
       if(ve[idx].F >= ve[j].F + ve[j].S)
        idx--;
       destn[j] = j+1;
       ll qr = query(1,0,n,j,idx);
       destn[j] =  max(qr,destn[j]);
       update(1,0,n,j,j,destn[j]);
    }
    for(ll j=n-1;j>=0;j--){
       // trace(destn[j]);
        dp[j] = dp[destn[j]] + dp[j+1];
        dp[j]%=mod;
    }
    g(dp[0]);
}
int main()
{

 
    FASTIO
    cin.tie(NULL);
    fflush(stdout);
    ll t = 1;
    //cin >> t;
    for(ll tcase = 1;tcase <= t;tcase++){
        solve();
        
    }
return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N; cin >> N;
	string s; cin >> s;
	int Q; cin >> Q;
	vector<LL> dsum(N + 1, 0);
	vector<LL> csum(N + 1, 0);
	vector<LL> cMsum(N + 1, 0);
	vector<int>dpos;
	FOR(i, 0, N) {
		dsum[i + 1] = dsum[i] + (s[i] == 'D');
		csum[i + 1] = csum[i] + (s[i] == 'C');
		cMsum[i + 1] = cMsum[i] + (s[i] == 'M');
		if (s[i] == 'D') {
			dpos.push_back(i);
		}
	}
	vector<LL>csumcsum(N + 1, 0);
	FOR(i, 0, N) {
		csumcsum[i + 1] = csumcsum[i];
		if (s[i] == 'C') {
			csumcsum[i + 1] += cMsum[i];
		}
	}
	DD(De(dsum, csum, cMsum, csumcsum, dpos));
	auto query = [&N](const vector<LL>&data, int l, int r) {
		r = min((int)N, r);
		return data[r] - data[l];
	};
	FOR(_, 0, Q) {
		int k; cin >> k;
		LL ans = 0;
		for (int i : dpos) {
			LL Ccnt = query(csum, i, i + k);
			LL msumsum = query(csumcsum, i, i + k);
			LL fron = query(cMsum, 0, i);
			LL ret = msumsum - Ccnt * fron;
			DD(de(Ccnt, msumsum, fron, ret));
			ans += ret;
		}
		cout << ans << endl;
	}
	return 0;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    int n,m;cin>>n>>m;

    int result = 0;
    result += n*(n-1)/2;
    result += m*(m-1)/2;

    cout<<result<<endl;

	return;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,c;
    cin>>n>>m>>c;
    int b[m];
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    int a[n][m],ans=0,num=c;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            num+=a[i][j]*b[j];
        }
        if(num>0){
            ans++;
        }
        num=c;
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int A, B;
	std::cin >> A >> B;
	if (A%3==0 || B%3==0 || (A+B)%3==0)
		std::cout << "Possible\n";
	else
		std::cout << "Impossible\n";
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <bitset>
#include <functional>
#include <tuple>
#include <complex>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef unsigned int uint;

mt19937 rnd(random_device{}());

const ll INF = 1e18;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);

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

    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<ll> pref(n + 1);
    for (int i = 0; i < n; ++i) {
        pref[i + 1] = pref[i] + a[i];
    }

    ll res = INF;
    for (int k = 1; k <= n; ++k) {
        ll cur = (n + k) * x + (pref[n] - pref[n - k]) * 2;
        bool ok = true;
        for (int l = n, i = 3; l > 0; l -= k, i += 2) {
            if (pref[l] - pref[max(l - k, 0)] > INF / i) {
                ok = false;
                break;
            }
            cur += (pref[l] - pref[max(l - k, 0)]) * i;
            if (cur > INF) {
                ok = false;
                break;
            }
        }
        if (ok) {
            res = min(res, cur);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3456
import java.io.IOException;
import java.util.NavigableSet;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		NavigableSet<Time> set = new TreeSet<Time>();
		while (n-- > 0)
			set.add(new Time(scanner.nextInt(), scanner.nextInt()));

		int m = scanner.nextInt();
		while (m-- > 0)
			set.add(new Time(scanner.nextInt(), scanner.nextInt()));
		System.out.print(set.pollFirst());
		while (!set.isEmpty())
			System.out.print(" " + set.pollFirst());
		System.out.println();
	}

	class Time implements Comparable<Time> {
		int h, m;

		public Time(int h, int m) {
			super();
			this.h = h;
			this.m = m;
		}

		@Override
		public String toString() {
			return String.format("%d:%02d", h, m);
		}

		@Override
		public int compareTo(Time o) {
			if (this.h == o.h)
				return this.m - o.m;
			return this.h - o.h;
		}

	}
}

Measured memory_bytes: 20972
N = int(input())
V = list(map(int, input().split()))

count = [
    {s: 0 for s in set(V[::2])},
    {s: 0 for s in set(V[1::2])},
]

for i, v in enumerate(V):
    count[i % 2][v] += 1

count[0] = sorted(count[0].items(), key=lambda x: -x[1])
count[1] = sorted(count[1].items(), key=lambda x: -x[1])

a = count[0][0]
b = count[1][0]

if a[0] == b[0]:
    try:
        if count[0][1][1] > count[1][1][1]:
            a = count[0][1]
        else:
            b = count[1][1]
    except IndexError:
        a = (-1, 0)

print(N - a[1] - b[1])


Measured memory_bytes: 20168
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int[][][] info = new int[4][3][10];
        int i=0,j=0,k=0;

        for(i=0; i < 4; i++){
            for(j=0; j < 3; j++){
                for(k=0; k < 10; k++)info[i][j][k] = 0;
            }
        }
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(i=0; i < n; i++){
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();
            info[b-1][f-1][r-1] += v;
        }
        
        for(i=0; i < 4; i++){
            for(j=0; j < 3; j++){
                for(k=0; k < 10; k++){
                    System.out.print(" " +info[i][j][k]);
                }
                System.out.println();
            }
            if(i<3) System.out.println("####################");
        }
    }
        
}


Measured memory_bytes: 29180
#include <iostream>
#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 <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    printf("%d %d %d\n", z, x, y);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long long width[300005],height[300005],bombw[300005],bombh[300005];
int main(){
    long long h,w,m,max1=0,max2=0,a=0,b=0,cnt=0;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>w>>h>>m;
    for(int i=1;i<=m;i++){
        cin>>bombw[i]>>bombh[i];
        width[bombw[i]]++;
        height[bombh[i]]++;
    }
    for(int i=1;i<=w;i++){
        max1=max(max1,width[i]);
        //max2=max(max2,bombh[i]);
    }
    for(int i=1;i<=w;i++){
        if(max1==width[i]){
            a++;
        }
    }
    for(int i=1;i<=h;i++){
        max2=max(max2,height[i]);
    }
    for(int i=1;i<=h;i++){
        if(max2==height[i]){
            b++;
        }
    }
    for(int i=1;i<=m;i++){
        if(width[bombw[i]]==max1 && height[bombh[i]]==max2)
            cnt++;
    }
    if(cnt==a*b)
        cout<<max1+max2-1;
    else
    {
        cout<<max1+max2;
    }
    //getchar();
    return 0;
    
}

Measured memory_bytes: 12972
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//imos
int main(){
    ll a,b;
    cin >> a >> b;

    ll res;
    if(a <= b)
    {
        res = a;
    }
    else
    {
        res = a - 1;
    }

    cout << res << endl;

    return 0;    
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main (){
    int a,b;
    int m[3];
    int max;
    cin>>a>>b;
    m[0]=a+b;
    m[1]=a-b;
    m[2]=a*b;
    max=m[0];
    for(int i=0;i<=2;i++)
    {
        if(m[i]>=max){
            max=m[i];
        }
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			int a = sc.nextInt();
			if (a == 0) break;
			double sum = 0;
			int[] scores = new int[a];
			for (int i = 0; i < a; i++) {
				scores[i]=sc.nextInt();
				sum+=scores[i];
			}
			double m = sum/a;
			double variance = 0;
			for (int i = 0; i < a; i++) {
				variance += Math.pow(scores[i]-m, 2)/a;
			}
			System.out.println(Math.sqrt(variance));
		}
	}
}


Measured memory_bytes: 31288
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let x: usize = sc.get();
    if x == 0 {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2084
def main():
    N = int(input())
    S = input()

    ans = 0
    dp = [[0] * (N+1) for _ in range(N+1)]
    for i in range(N-1, -1, -1):
        for j in range(N-1, i, -1):
            if S[i] == S[j]:
                dp[i][j] = dp[i+1][j+1] + 1
                tmp = min(dp[i][j], j-i)
                ans = max(ans, tmp)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 270104
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
using namespace std;

int main(){
  int n;
  while(cin >> n){
    if(n==0)break;
    vector<string> talk(n);
    vector<int> depth(n,0);

    rep(i,n){
      cin >> talk[i];

      rep(j,talk[i].size()){
	if(talk[i][j] == '.' && talk[i][j+1] != '.'){
	  talk[i][j] = '+';
	  depth[i] = j+1; break;
	}
      }

      rrep(j,i){
	if(depth[i] > depth[j])break;
	if(depth[i] == depth[j]){
	  for(int k=j+1;k<i;k++)talk[k][depth[j]-1] = '|';
	  break;
	}
      }
    }
    
    rep(i,n){
      rep(j,talk[i].size()){
	if(talk[i][j] == '.')talk[i][j] = ' ';
      }
    }

    rep(i,n)cout << talk[i] << endl;
    //cout << endl;
  }
}

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

					using namespace std;
					typedef long long ll;
					string s;
					int n;
					bool p(int l, int r)
					{
						for(int i = l; i < r; i++)
							if(s[i] != s[r-i-1])
								return 0;
						return 1;		
					}
					int main()
					{
						cin >> s;
						n = s.size();
						if(p(0, ((n-1)/2)) && p(((n+3)/2)-1, n) && p(0, n))
							cout << "Yes";
						else cout << "No";							
					}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc118/tasks/abc118_c

// http://ctylim.hatenablog.com/entry/2015/08/30/191553
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>

#define ALL(a) (a).begin(), (a).end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define MAXINDEX(c) distance((c).begin(), max_element((c).begin(), (c).end()))
#define MININDEX(c) distance((c).begin(), min_element((c).begin(), (c).end()))
#define DEBUG(x) std::cerr << #x << " = " << (x) << " (" << __FILE__ << "::" << __LINE__ << ")" << std::endl;
#define ERROR(s) std::cerr << "Error::" << __FILE__ << "::" << __LINE__ << "::" << __FUNCTION__ << "::" << (s) << std::endl;
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

template <typename T>
T inputValue()
{
  T a;
  std::cin >> a;
  // scanf("%llu", &a);
  return a;
}

void inputArray(int *p, int a)
{
  rep(i, a)
  {
    std::cin >> p[i];
    // scanf("%d",p+i);
  }
}

template <typename T>
void inputVector(std::vector<T> *p, int a)
{
  rep(i, a)
  {
    T input;
    std::cin >> input;
    // scanf("%llu", &input);
    p->push_back(input);
  }
}

template <typename T>
void output(T a, int precision)
{
  if (precision > 0)
  {
    std::cout << std::setprecision(precision) << a << "\n";
  }
  else
  {
    std::cout << a << "\n";
  }
}

using namespace std;

int gcd(int a, int b)
{
  while (1)
  {
    if (a < b)
      swap(a, b);
    if (!b)
      break;
    a %= b;
  }
  return a;
}

void out(int p){
  if(p==0){
    cout << "First"<< endl;
  } else {
    cout << "Second" << endl;
  }
}

typedef unsigned long long int ulli;
int main(int argc, char **argv)
{
  // int N = inputValue<int>();
  // vector <int> v;
  // inputVector(&v, N);

  

  char c;
  int N = 0;
  char first, last;
  while ((c = getc(stdin)) != EOF && (c >= 'a' && c <= 'z'))
  {
    if (N == 0) {
      first = c;
    }
    N++;
    last = c;
  }

  if (N<=2){
    out(1);
  } else{
    // out(((first != last) && !(N & 1)) || ((first == last) && (N & 1)));
    out(!((first == last)^(N & 1)));
  }

  //   if (N <= 2)
  //   {
  //     out(1);
  //   } else if (first != last) {
  //   if(N&1){
  //     out(0);
  //   }else{
  //     out(1);
  //   }
  // } else {
  //   if(N&1){
  //     out(1);
  //   }else{
  //     out(0);
  //   }
  // }


  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	ans := 0

	for i := 1; i <= N; i++ {
		if (i >= 1 && i <= 9) || (i >= 100 && i <= 999) || (i >= 10000 && i <= 99999) {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
import sys
n,y = map(int,input().split())
y //= 1000
for k in range(min(n,y//10)+1):
    nn = n-k
    yy = y-10*k
    i = (yy - nn) // 4
    if (yy-nn)%4 == 0 and nn-i >= 0 and i >= 0:
        print(k,i,nn-i)
        sys.exit()
print(-1,-1,-1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int f(int n)
{
    int ans=1,base=10;
    while(n)
    {
        if(n&1)
            ans*=base;
        base*=base;
        n>>=1;
    }
    return ans;
}
int main()
{
    int n;
    scanf("%d",&n);
    int x=n;
    int k=0;
    while(x)
    {
        x/=10;
        k++;
    }
    int sum=0;
    for(int i=1;i<k;i++)
    {
        if(i==1)
            sum+=9;
        else if(i%2==1)
            sum+=f(i)-f(i-1);
    }
    if(k%2==1)
        sum+=n-f(k-1)+1;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    int N = s.size();
    if(N == 26){
        bool able = false;
        rep3(i, 25, 1){
            if(s[i] < s[i-1]) continue;
            able = true;
            int en = i;
            while(en<25 && s[en+1] > s[i-1]) en++;
            rep(j, i-1) cout << s[j];
            cout << s[en];
            break;
        }
        if(!able) cout << -1 << endl;
    }
    else{
        rep(i, 26){
            bool used = false;
            rep(j, N){
                if(s[j] == alpha[i]) used = true;
            }
            if(!used){
                s += alpha[i];
                cout << s << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	private static int[] cache;
	private static char[] x;
	private static char[] y;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int set = sc.nextInt();

		for (int k = 0; k < set; k++) {
			x = sc.next().toCharArray();
			y = sc.next().toCharArray();
			if (y.length > x.length) {
				char[] temp = x;
				x = y;
				y = temp;
			}
			int m = x.length;
			int n = y.length;
			
			// ボトムアップ型、メモリ節約２
			cache = new int[n + 1];
			// 初期化不要(0)

			for (int i = 1; i <= m; i++) {
				int temp_1 = 0;
				int temp = 0;
				for (int j = 1; j <= n; j++) {
					if (x[i - 1] == y[j - 1]) {
						temp = cache[j - 1] + 1;
					} else {
						temp = Math.max(cache[j], temp_1);
					}
					cache[j - 1] = temp_1;
					temp_1 = temp;
				}
				cache[n] = temp;
			}
			
			System.out.println(cache[n]);
		}
		
         sc.close();
	}
}

Measured memory_bytes: 21284
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 N,A,B,C;
vector<i64> l;

i64 rec(i64 i,i64 a,i64 b,i64 c) {
  if(i == N) {
    if(a == 0 || b == 0 || c == 0) return 1e18;
    return abs(A - a) + abs(B - b) + abs(C - c);
  }
  return min({ rec(i + 1, a, b, c), 
      rec(i + 1, a + l[i], b, c) + 10,
      rec(i + 1, a, b + l[i], c) + 10,
      rec(i + 1, a, b, c + l[i]) + 10});
}

int main() {
  cin >> N >> A >> B >> C;
  l.resize(N);
  rep(i,0,N - 1) cin >> l[i];
  cout << rec(0,0,0,0) - 3 * 10 << endl;
}


Measured memory_bytes: 256
n = int(input())
flag = 0
def dfs(val):
    global flag
    if val == n:
        flag = 1
        return
    if val>n:
        return
    if val<0:
        return
    dfs(val+4)
    dfs(val+7)
dfs(0)
if flag == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    int p[n],q[n];
    rep(i,n){
        cin>>p[i];
        p[i]--;
    }
    rep(i,n){
        cin>>q[i];
        q[i]--;
    }

    vector<int> order(n);
    rep(i,n) order[i]=i;
    int cnt=1;
    int a,b;
    do{
        bool ok1=true,ok2=true;
        rep(i,n){
            if(p[i]!=order[i]) ok1=false;
        }
        if(ok1) a=cnt;
        rep(i,n){
            if(q[i]!=order[i]) ok2=false;
        }
        if(ok2) b=cnt;
        cnt++;
    }while(next_permutation(all(order)));

    cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc080/tasks/abc080_d

#include "algorithm"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, C;
  cin >> N >> C;

  struct Program {
    ll s;
    ll t;
    ll c;
  };

  V<Program> ps(0);

  {
    // 同一チャンネルの連続した番組をまとめる

    V<Program> ps_original(N);

    rep(i, N) {
      ll s, t, c;
      cin >> s >> t >> c;

      ps_original[i] = {s, t, c};
    }

    sort(all(ps_original), [](Program a, Program b) {
      if (a.c != b.c) return a.c < b.c;
      return a.s < b.s;
    });

    rep(i, N) {
      auto p = ps_original[i];

      if (ps.size() > 0) {
        auto last_p = ps[ps.size() - 1];

        if (last_p.c == p.c && last_p.t == p.s) {
          ps[ps.size() - 1].t = p.t;
          continue;
        }
      }

      ps.push_back(p);
    }
  }

  sort(all(ps), [](Program a, Program b) { return a.s < b.s; });

  ll res = 0;
  ll available = 0;
  priority_queue<ll, VL, greater<ll>> add_event;  // 追加する時刻

  for (auto p : ps) {
    while (!add_event.empty() && add_event.top() <= p.s) {
      add_event.pop();
      available++;
    }

    if (available == 0) {
      res++;
    } else {
      available--;
    }

    add_event.push(p.t + 1);
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 6516
#include<stdio.h>
int main(){
  int i,j;
  int c[8],l[8]={1,4,1,4,1,2,1,2},n,m,max;
  while(scanf("%d%d%d%d%d%d%d%d",&c[0],&c[1],&c[2],&c[3],&c[4],&c[5],&c[6],&c[7])!=-1){
    max=0;
    m=0;
    for(i=0;i<8;i++){
      n=0;
      for(j=0;j<8;j++)
	n+=l[(i+j)%8]<c[j]?l[(i+j)%8]:c[j];
      if(max<n){
	max=n;
	m=i;
      }else if(max==n){
	for(j=0;j<8;j++){
	  if(l[(m+j)%8]>l[(i+j)%8]){
	    m=i;
	    break;
	  }else if(l[(m+j)%8]<l[(i+j)%8])
	    break;
	}
      }
    }
    for(i=0;i<8-1;i++)
      printf("%d ",l[(m+i)%8]);
    printf("%d\n",l[(m+i)%8]);
  }
  return 0;
}

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

using namespace std;
const int maxn = 100000 + 10;
long long a[maxn];
int n;
int main()
{
    cin >> n;
    int s = 0, k = 0, h = 0;       // s四的倍数的个数
    for (int i = 0; i < n; i++) {
        scanf("%lld", a + i);
        if (a[i] % 4 == 0)
            s++;
        else if (a[i] % 2 == 0)
            k++;
        else
            h++;
    }
    if (k == 0) {
        if (h - 1 == s || s >= h)
            printf("Yes\n");
        else
            printf("No\n");
    }
    else {
        if (s >= h)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    sort(all(a));

    cout << a[n-1] - a[0] << endl;
}

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

int main() {
  int N, S = 1, m;
  cin >> N;
  vector<int> v(N);
  for(int i = 0;i < N;i++) {
    cin >> v[i];
  }
  m = v[0];
  for(int i = 1;i < N;i++) {
    if(m > v[i]) {
      S++;
      m = v[i];
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 4020