akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ANSWER(x) cout<<x<<endl
#define debug(x) cout<<#x<<": "<<x
const int BA = 1000;
const int INFTY = (1<<21);
int xg,yg,w,h,gc;
int maps[101][101];
int solve(int ys,int xs);
int main(){
  int tate[2] = {2,4},yoko[2] = {4,2};
  int xs,ys,n;
  int c[101],d[101],x[101],y[101];
  while(1){
    fill(maps[0],maps[101],0);
    cin >> w >> h;
    if(!w && !h)break;
    cin >> xs >> ys >> xg >> yg >> n;
    xs--;ys--;xg--;yg--;
    for(int i=0;i<n;i++){
      cin >> c[i] >> d[i] >> x[i] >> y[i];
      x[i]--;y[i]--;
    }
    for(int i=0;i<n;i++){
      for(int j=y[i];j<y[i]+tate[d[i]];j++){
	for(int k=x[i];k<x[i]+yoko[d[i]];k++){
	  if(j == ys && k == xs)gc = c[i];
	  maps[j][k] = c[i];
	}
      }
    }
    if(solve(ys,xs))cout << "OK\n";
    else cout << "NG\n";
  }
}
int solve(int ys,int xs){
  if(xs < 0 || ys < 0 || xs > w-1 || ys > h-1 || !maps[ys][xs] || maps[ys][xs] != gc){
    return 0;
  }
  else if(ys == yg && xs == xg){
    return 1;
  }
  maps[ys][xs] = 0;
  return solve(ys+1,xs) + solve(ys,xs+1)+ solve(ys-1,xs) + solve(ys,xs-1);
}

Measured memory_bytes: 1168
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int i,j,k;
string s;

int main() {
  cin >> s;
  vector<int> v;
  for (i=0;i<s.length();i++) v.push_back(stoi(s.substr(i,1)));
  for (int bit=0;bit < (1<<s.length()-1); ++bit) {
    int sum = v[0];
    string out = to_string(v[0]);
    for (i = 0; i < v.size() - 1; ++i) {
      if (bit & (1<<i)) {
        sum += v[i+1];
        out = out + "+";
      } else {
        sum -= v[i+1];
        out = out + "-";
      }
      out = out + to_string(v[i + 1]);
    }
    out = out + "=7";
    if (sum == 7) {
      cout << out << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
long long mod = 1e9+7;

int main(void) {

  int n, d; cin >> n >> d;
  int p = 1 + 2 * d;
  cout << (n+p-1) / p << endl;

  return 0;
}

// EOF


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#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 per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template<class T,class U>bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(n);
    VI vi(n+5);
    rep(i, n-1){
        cill(a);
        vi[a-1]++;
    }
    rep(i, n){
        co(vi[i]);
    }

    return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<int> A(N),B(N),C(N);
    int dp[3][N+1];
    for(int i=0;i<N;i++){
        cin>>A[i]>>B[i]>>C[i];
    }
    for(int i=0;i<N+1;i++){
        for(int j=0;j<3;j++){
            dp[j][i]=-INF;
        }
    }
    dp[0][0]=A[0];dp[1][0]=B[0];dp[2][0]=C[0];
    for(int i=0;i<N;i++){
        dp[1][i+1]=max(dp[1][i+1],dp[0][i]+B[i+1]);
        dp[2][i+1]=max(dp[2][i+1],dp[0][i]+C[i+1]);
        dp[0][i+1]=max(dp[0][i+1],dp[1][i]+A[i+1]);
        dp[2][i+1]=max(dp[2][i+1],dp[1][i]+C[i+1]);
        dp[0][i+1]=max(dp[0][i+1],dp[2][i]+A[i+1]);
        dp[1][i+1]=max(dp[1][i+1],dp[2][i]+B[i+1]);
    }
    cout<<max(dp[0][N-1],max(dp[1][N-1],dp[2][N-1]))<<endl;
    
}


Measured memory_bytes: 2560
n,m = map(int,input().split())
h = list(map(int,input().split()))
g = [0]*n
co = 0
for _ in range(m):
    a,b = map(int,input().split())
    g[a-1] = -1 if h[a-1]<=h[b-1] or g[a-1]==-1 else 1
    g[b-1] = -1 if h[b-1]<=h[a-1] or g[b-1]==-1 else 1


for i in range(n):
    if g[i] < 0:
        continue
    co+=1

print(co)

Measured memory_bytes: 20000
from collections import deque

S = deque(input())
num_of_query = int(input())
querys = []
is_reverse = False

for _ in range(num_of_query):
    # querys.append(list(input().split()))
    query = list(input().split())
    
    if query[0] == '1':
        is_reverse = not is_reverse
    else:
        if query[1] == '1':
            if is_reverse:
                S.append(query[2])
            else:
                S.appendleft(query[2])

        else:
            if is_reverse:
                S.appendleft(query[2])
            else:
                S.append(query[2])

S = list(S)
if is_reverse:
    S = S[::-1]

# for query in querys:
#     if query[0] == '1':
#         S = S[::-1]
#     else:
#         if query[1] == '1':
#             S = deque(S)
#             S.appendleft(query[2])
#             S = list(S)
#         else:
#             S = deque(S)
#             S.append(query[2])
#             S = list(S)

print(''.join(S))

Measured memory_bytes: 8436
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_N 200000

using namespace std;
typedef pair<int, int> ipair;

int main(int argc, char **argv) {
    int N, x[MAX_N];

    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> x[i];
        x[i] -= i + 1;
    }

    sort(x, x + N);

    int b = x[N/2];
    /*
    if(N % 2 == 1)
        b = x[N/2];
    else
        b = (x[N/2 - 1] + x[N/2]) / 2;
    */

    llong res = 0;
    for(int i = 0; i < N; ++i)
        res += abs(x[i] - b);

    cout << res << endl;
    system("pause");
}

Measured memory_bytes: 1272
from math import floor
a,b,n = map(int,input().split())
if a == 1 or b == 1:
    print(0)
    exit()

prev = 0

for x in range(min(b-1,n),n+1, b):
    val = floor(a*x/b) - a*floor(x/b)
    if val < prev:
        print(prev)
        exit()
    prev = val

val = floor(a*n/b) - a*floor(n/b)
print(max(prev,val))



Measured memory_bytes: 9204
a, b , k = map(int, input().split())

#約数取得
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

a_yakusu = make_divisors(a)
b_yakusu = make_divisors(b)
ab_yakusu = sorted(set(a_yakusu) & set(b_yakusu), reverse=True)

print(ab_yakusu[k-1])


Measured memory_bytes: 9132
#include<stdio.h>
#include<math.h>

 int main(){
     double s[10009],m;
     int i,n;
     for(;;){
         double m=0,a=0;
         scanf("%d",&n);
         if(n==0)break;
         for(i=1;i<=n;i++){
                 scanf("%lf",&s[i]);
                 m=m+s[i];
                 }
         m=m/n;
         for(i=1;i<=n;i++){
               a=a+(s[i]-m)*(s[i]-m);
               }
         a=a/n;
         printf("%lf\n",sqrt(a));
         }
      return 0;
      }


Measured memory_bytes: 2056
#!/usr/bin/env python3
import sys

NO = "IMPOSSIBLE"  # type: str


def solve(A: int, B: int):
    if (A + B) % 2 == 0:
        print(int((A + B) / 2))
    else:
        print('IMPOSSIBLE')
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, r;
    cin >> n >> r;
    if( n >= 10 ) cout << r;
    else cout << r + (100 * (10 - n));
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int H, W; cin >> H >> W;
    for (int i = 0; i < W + 2; ++i) printf("%c", '#');
    printf("\n");
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W + 2; ++j) {
            if (j == 0 || j == W + 1) printf("%c", '#');
            else {
                char a; cin >> a;
                printf("%c", a);
            }
        }
        printf("\n");
    }
    for (int i = 0; i < W + 2; ++i) printf("%c", '#');
    printf("\n");
}


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

int main() {
  int n;
  cin >> n;
  bool unfinished = true;
  while (unfinished){
    if (n%10 == (n/10)%10 && (n/10)%10 == ((n/10)/10)%10){
      cout << n << endl;
      unfinished = false;
    }
    n ++;
  }
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 998244353

int main() {
	int a,b;
	cin >> a >>b;
	cout << (a - 1)*(b - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int c[3][3];
    repi(i, 3, 0)
    {
        repi(j, 3, 0)
        {
            cin >> c[i][j];
        }
    }
    repi(i, 101, 0)
    {
        repi(j, 101, 0)
        {
            repi(k, 101, 0)
            {
                bool ok = true;
                repi(l, 3, 0)
                {
                    if (c[l][0] - i != c[l][1] - j || c[l][1] - j != c[l][2] - k)
                    {
                        ok = false;
                        break;
                    }
                }
                if (ok)
                {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int h[n];
    rep(i, n) cin >> h[i];
    sort(h, h + n);

    int ans = 1e9;
    rep(i, n - k + 1) ans = min(ans, h[i + k - 1] - h[i]);

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


Measured memory_bytes: 640
#include <stdio.h>


void main(void){
    char str[10];

    scanf("%s",str);
    int i;
    int ans = 1;
    for(i = 1;i <= 5;i++){     
        if(str[i*2-2] != 'h'){
            if(str[i*2-2] == '\0'){
                break;
            }
            ans = 0;
            break;
        } else if( str[i*2-1] != 'i'){
            ans = 0;
            break;
        }
    }
    printf("%s",ans ? "Yes" : "No");
    return;
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

int lcm(int a,int b){
   return a*b/gcd(a,b);
}

bool prime_number(int n){
   vector<bool> i;
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   int out=0, point=0, base=0,n=0;
   string s;
   
   
   cin>> n;
   while(getline(cin,s)){
      if(s=="HIT"){
         if(base==3){
            point++;
         }else{
            base++;
         }
      }else if(s=="OUT"){
         out++;
      }else if(s=="HOMERUN"){
         point+=base+1;
         base=0;
      }
      if(out==3){
         cout << point << endl;
         point=0;
         out =0;
         base=0;
      }
   }
   
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char s[MAXN];
int main() {
	scanf("%s", s + 1), s[4] = 0;
	printf("%s\n", s + 1);
	return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long
//#define int long long

static const int MAX = 100005;
static const int INFTY = (1 << 20);

int N, K;
int ans;

signed main() {
	cin >> N >> K;

	if (N%K == 0) {
		cout << 0 << endl;
		return 0;
	}

	cout << 1 << endl;

	return 0;
}

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

using namespace std;

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

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

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

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

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

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

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

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

    string s;
    cin>>s;
    string x;

    bool can = false;
    if(s=="keyence")can=true;
    rep(j, s.size()){
        rep(i, j+1) {
            // iから//jを削除
            if(i==0){
                x = s.substr(j+1);
            }else if(j==s.size()-1){
                x = s.substr(0,i);
            }else{
                x = s.substr(0,i) + s.substr(j+1);
            }
            if(x=="keyence")can=true;
        }
    }
    YES(can);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n;
    bool ans = false;
    cin >> n;
    for(int i = 0;7*i <= n;i++){
        if((n - (7*i))%4 == 0){
            ans = true;
        }
    }
    if(ans){
        cout << "Yes" <<endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,m; cin>>n>>m;
	VI a(m); rep(i,m) cin>>a[i];
	ll ans = n;	rep(i,m) ans-=a[i];
	if(ans>=0) cout<<ans<<endl;
	else cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int N;
int A[110];

signed main()
{
    cin >> N;

    int cnt=0;
    int cnt2=0;
    rep(i,N)
    {
        cin >> A[i];

        if(A[i]%2==0)
        {
            cnt++;
            if(A[i]%3==0||A[i]%5==0)
            {
                cnt2++;
            }
        }
    }

    if(cnt==cnt2)cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    REP(i, n){
        cin >> p[i];
    }
    vector<double> accum(n+1, 0.0);
    IFOR(i, 1, n){
        accum[i] = accum[i-1] + (p[i-1]+1)/2.0;
    }
    double maxx = 0.0;
    for(int i=0;i+k<=n;i++){
        maxx = max(maxx, accum[i+k] - accum[i]);
    }

    printf("%.14f\n", maxx);
    return 0;
}

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

class Program
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());

        int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] a = new int[n];

        for (int i = 0; i < n - 1; i++)
        {
            if (i == 0) a[0] = b[0];
            else
            {
                a[i] = Math.Min(b[i - 1], b[i]);
            }
        }

        a[n - 1] = b[b.Length - 1];
        int sum = 0;
        foreach (var buf in a)
            sum += buf;

        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 13396
#include<cstdio>
typedef long long ll;
inline ll in();
inline void wr(ll);
int main(int argc,char**argv){
#ifndef ONLINE_JUDGE
//	freopen("C.in","r",stdin);
//	freopen("C.ans","w",stdout);
#endif
	register ll n=in(),ans=0;
	for(register ll i=1;i*i<=n;++i)
		if(n%i==0)ans=i+n/i-2;
	wr(ans),putchar('\n');
}
inline ll in(){
	register char c=getchar();
	register ll x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())
		if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1ll)+(x<<3ll)+(c&15);
	return x*f;
}
inline void wr(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x/10ll)wr(x/10ll);
	putchar(x%10ll+'0');
}


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

int main(int argc, char *argv[])
{
	int k;
	string s;
	cin >> k >> s;
	if (s.length() <= k) {
		cout << s;
	} else {
		s.resize(k);
		cout << s << "...";
	}
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,pii> piiii; 
const int INF=1e9;
#define fi first
#define se second
#define mkp make_pair
const int dir[4][2]={{0,1},{1,0},{-1,0},{0,-1}};
int n,m,K,X1,X2,Y1,Y2;
pii rev[1000004]; 
int getID(int x,int y){
	return (x-1)*m+y;
}
pii d[1000004][4];
bool ok[1000004],vis[1000004][4];
priority_queue<piiii,vector<piiii>,greater<piiii> >pq;
char c[1000004];
void add(int A,int B,int C,int D,int E,int F){
//	cout<<A<<" "<<B<<" "<<C<<" "<<D<<" "<<E<<" "<<F<<d[A][B].fi<<" "<<d[C][D].fi<<"\n"; 
	if(d[A][B].fi+E<d[C][D].fi || (d[A][B].fi+E==d[C][D].fi&&F<d[C][D].se)){
		d[C][D]=mkp(d[A][B].fi+E,F);	
		pq.push(mkp(d[C][D],mkp(C,D)));
	}
}
int main(){
	cin>>n>>m>>K>>X1>>Y1>>X2>>Y2;
	for(int i=1;i<=n;i++){
		scanf("%s",c+1);
		for (int j=1;j<=m;j++)
			rev[getID(i,j)]=mkp(i,j),ok[getID(i,j)]=(c[j]=='.'?1:0);
	}
	for(int i=1;i<=n*m;i++)for(int j=0;j<4;j++)d[i][j]=mkp(INF,0);
	for(int i=0;i<4;i++){
		d[getID(X1,Y1)][i]=mkp(1,-K);
		pq.push(mkp(d[getID(X1,Y1)][i],mkp(getID(X1,Y1),i)));
	}
	while(!pq.empty()){
		piiii u=pq.top();pq.pop();
		pii pos=u.se,val=u.fi;
		if(vis[pos.fi][pos.se])continue;
		vis[pos.fi][pos.se]=1;
//		cout<<u.fi.fi<<" "<<u.fi.se<<" "<<u.se.fi<<" "<<u.se.se<<"\n";
		for(int i=0;i<4;i++){
			if(pos.se!=i){
				add(pos.fi,pos.se,pos.fi,i,1,-K);
			//	cout<<i<<"\n";
			}else{
				int add1,add2;
				if(val.se==0)add1=1,add2=-K+1;
				else add1=0,add2=val.se+1;
				pii path=mkp(dir[i][0]+rev[pos.fi].fi,dir[i][1]+rev[pos.fi].se);
				if(path.fi<1 || path.se<1 || path.fi>n || path.se>m || !ok[getID(path.fi,path.se)])continue;
				add(pos.fi,pos.se,getID(path.fi,path.se),i,add1,add2);
			}
		}
	}
	int ans=1e9;
	for(int i=0;i<4;i++)ans=min(d[getID(X2,Y2)][i].fi,ans);
	if(ans<1e9)cout<<ans;
	else cout<<"-1";
}

Measured memory_bytes: 52892
#include<iostream>
using namespace std;
int a[12345];
int flag[12345];
long long mod=1e9+7;
int main()
{
	long long n,k,sum1=0;
	cin>>n>>k;
	k=k%mod;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		for(int j=0;j<i;j++)
			if(a[j]<a[i])
				flag[i]++;
	}
	
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		if(a[i]>a[j])
			sum1++;
	}
	long long t=(k+k*(k-1)/2)%mod;
	sum1=sum1*t%mod;//section one
	
	long long sum2=0;
	for(int i=0;i<n;i++)
	{
		sum2+=flag[i];
	}
	t=((k-1)+(k-1)*(k-2)/2)%mod;
	sum2=sum2*t%mod;//scetion two
	
	long long sum=(sum1+sum2)%mod;
	cout<<sum%mod<<endl;
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007

int main() {
    string s;cin>>s;

    if(s.size()==2){
        cout<<s<<endl;
    }
    else {
        reverse(s.begin(),s.end());
        cout<<s<<endl;
    }
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
// #include "ext/pb_ds/assoc_container.hpp"
// #include "ext/pb_ds/tree_policy.hpp"
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 29996224275833
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int mI(int a, int m)  {return power(a, m - 2, m);}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> v(1e3);
    fo(i,1e3){
        v[i] = i * i * i * i * i;
    }
    int x;
    cin >> x;
    for(int i=1e3-1;i>=0;i--){
        fo(j,i+1){
            if(v[i]-v[j]==x){
                cout << i << " " << j;
                return 0;
            }
            if(v[i]+v[j]==x){
                cout << i << " " << -j;
                return 0;
            }
        }
    }
}
    


Measured memory_bytes: 3620
def main():
    import sys
    input = sys.stdin.buffer.readline
    
    r, c, k = map(int, input().split())
    tizu = [0 for _ in range(r * c)]
    for _ in range(k):
        rr, cc, v = map(int, input().split())
        tizu[(rr - 1) * c + (cc - 1)] = v
        
    dp = [[0, 0, 0, 0] for _ in range(c)]
    dp[0][1] = tizu[0]
    
    for i in range(r):
        for j in range(c):
            v = tizu[i * c + j]
            if v:
                if i != 0:
                    tmp = max(dp[j])
                    dp[j] = [tmp, tmp + v, 0, 0]
                if j != 0:
                    tmp0 = dp[j - 1][0]
                    tmp1 = dp[j - 1][1]
                    tmp2 = dp[j - 1][2]
                    lst = [max(dp[j][0], tmp0), max(dp[j][1], tmp1, tmp0 + v), max(tmp2, tmp1 + v), max(dp[j - 1][3], tmp2 + v)]
                    dp[j] = lst
            else:
                if i != 0:
                    tmp = max(dp[j])
                    dp[j] = [tmp, 0, 0, 0]
                if j != 0:
                    lst = [max(dp[j][0], dp[j-1][0]), dp[j-1][1], dp[j-1][2], dp[j - 1][3]]
                    dp[j] = lst
    print(max(dp[-1]))
    
main()


Measured memory_bytes: 270452
use std::io::{stdin, Read};
use std::str::FromStr;

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

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let xx = (0..n).map(|_| read::<u64>()).collect::<Vec<_>>();
    let mut xs = xx
        .iter()
        .enumerate()
        .map(|(i, &v)| (v, i))
        .collect::<Vec<_>>();
    xs.sort();
    let (mid_l, _) = xs[(n - 1) / 2];
    let (mid_r, _) = xs[n / 2];

    let mut ans = vec![0; n];
    for i in 0..n {
        let (v, ii) = xs[i];
        if i < n / 2 {
            ans[ii] = mid_r
        } else {
            ans[ii] = mid_l
        }
    }
    for a in ans {
        println!("{}", a)
    }
}


Measured memory_bytes: 16508
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long LL;
LL Sum(int a,int b)
{
	LL res=0;
	if(b-a<5)
	{
		for(int i=a;i<=b;i++)res+=i+1>>1;
		return res;
	}
	if((a&1)==0)res+=(a++)+1>>1;
	if((b&1)==1)res+=(b--)+1>>1;
	res+=(LL)((a+1>>1)+(b+1>>1))*(b-a+1>>1);
	return res;
}
LL Max(int now,int l,int r)
{
	if(now<0)r+=now,now=0;
	if(r<0)return 0;
	LL res=Sum(now+1,now+r);
	now+=r;
	l=min(l,now);
	res+=Sum(now-l,now-1);
	return res;
}
char s[1000005];
int main()
{
	int A,n;
	cin>>A;
	for(n=1;Max(0,n,n)<A;n++);
	int l=n,r=n,t=0;
	LL sum=0;
	for(int i=1;i<=n+n;i++)
	{
		if(l>0&&sum+max(0,t>>1)+Max(t-1,l-1,r)>=A)
		{
			s[i]='(';
			t--,l--;
			sum+=max(0,t+1>>1);
		}
		else
		{
			s[i]=')';
			t++,r--;
			sum+=max(0,t+1>>1);
		}
	}
	puts(s+1); 
	return 0;
}

Measured memory_bytes: 3152
# frozen_string_literal: true

s = gets.chomp.chars

a = s.count('a')
b = s.count('b')
c = s.count('c')

m = [a, b, c].min
n = [a, b, c].max

if (m - n).abs <= 1
  puts 'YES'
else
  puts 'NO'
end


Measured memory_bytes: 6908
#include<iostream>
#include<string>

using namespace std;

int main(void)
{
	string s;
	cin >> s;
	bool f1,f2,f3;
	f1=(s[0]=='A' ? true:false);
	f2=false;
	f3=true;
	for(int i=3;i<=s.size()-1;i++)
	{
		if(s[i-1]=='C')
		{
			if(f2==false)
				f2=true;
			else
				f3=false;
		}
		else if(!('a'<=s[i-1] and s[i-1]<='z'))
			f3=false;
	}
	if(!('a'<=s[1] and s[1]<='z') or !('a'<=s[s.size()-1] and s[s.size()-1]<='z'))
		f3=false;

	cout << ((f1==true and f2==true and f3==true) ? "AC" : "WA") << endl;
}
				

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
X = int(input())
items = (100, 101, 102, 103, 104, 105)
seen = set()
def dfs(n):
    if(n>100000):
        return 0
    if(n not in seen):
        seen.add(n)
        for i in items:
            dfs(n+i)

dfs(0)
if(X in seen):
    print(1)
else:
    print(0)


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

using namespace std;

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

    int cnt = 0;
    for(int i = 1; i <= N; i++){
        if(i % 2 == 1){
            cnt++;
        }
    }

    printf("%.10f", (double)cnt/N);


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()

{

    int r ;

    scanf("%d",&r) ;

    if( r < 1200 )          printf("ABC\n") ;

    else if( r >= 1200 && r < 2800 )       printf("ARC\n") ;

    else if( r >= 2800 && r<=4208 )      printf("AGC\n") ;

    return 0 ;

}


Measured memory_bytes: 128
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		
		solve();flush();
		
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		int N = nextInt();
		int[][] list = new int[10][10];
		for(int i = 1; i <= N; i++){
			int tmp = i;
			while(tmp >= 10){
				tmp /= 10;
			}
			list[i % 10][tmp]++;
		}
		long output = 0;
		for(int i = 1; i <= 9; i++){
			for(int j = 1; j <= 9; j++){
				output += list[i][j] * list[j][i];
			}
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


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

struct Node;
typedef unique_ptr<Node> NP;
struct Node {
  NP l, r;
};

void test() {
  for (int i = 0; i < 2000000; ++i) new Node();
}

int main() {
  test();
  int a, b, c;
  cin >> a >> b >> c;
  cout << ((a+b+c) == max({a,b,c})*2 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 62720
from copy import deepcopy
n = str(input().rstrip())

def solve1(n):
    ans = 0

    a = list(map(int, list(n)))
    a = a[::-1]
    a.append(0)
    for i in range(len(a) - 1):
        c = a[i]
        if c < 5:
            ans += c
        else:
            if c == 5 and a[i+1] < 5:
                ans += 5
            else:
                a[i+1] += 1
                ans += 10 - c
    ans += n_list[-1]

    print(ans)

def solve2(n):
    INF = 10**9
    n = n[::-1]
    n += '0'
    n_len = len(n)
    dp = [INF for _ in range(2)]
    dp[0] = 0

    for i in range(n_len):
        pre_dp = deepcopy(dp)
        dp = [INF, INF]
        for j in range(2):
            x = int(n[i])
            x += j
            if x < 10:
                dp[0] = min(dp[0], pre_dp[j]+x)
            if x > 0:
                dp[1] = min(dp[1], pre_dp[j]+(10-x))

    print(dp[0])
solve2(n)

Measured memory_bytes: 114020
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int x;
    scanf("%d",&x);
    int flag=0,val;
    for (int i=x;;i++)
    {
        flag=0;
        for (int j=2;j*j<=i;j++)
        {
            if (i%j==0)
            {
                flag=1;
                break;
            }
        }
        if (flag==0)
        {
            val=i;
            break;
        }
    }
    printf("%d\n",val);
    return 0;
}


Measured memory_bytes: 3828
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

mod = 10**9 + 7

# x ** a をmodで割った余りを、O(log(a))時間で求める。
def power(x, a):
    if a == 0:
        return 1
    elif a == 1:
        return x
    elif a % 2 == 0:
        return power(x, a//2) **2 % mod
    else:
        return power(x, a//2) **2 * x % mod

# xの逆元を求める。フェルマーの小定理より、 x の逆元は x ^ (mod - 2) に等しい。計算時間はO(log(mod))程度。
# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
def modinv(x):
    return power(x, mod-2)

def binomial_coefficients(n, k):
    numera = 1  # 分子
    denomi = 1  # 分母

    for i in range(k):
        numera *= n-i
        numera %= mod
        denomi *= i+1
        denomi %= mod
    return numera * modinv(denomi) % mod
N,K=mp()
for i in range(1,K+1):
    print((binomial_coefficients(K-1,i-1)*binomial_coefficients(N-K+1,i))%mod)

Measured memory_bytes: 81560
N = int(input())

a=0
w=0
t=0
r=0

for vreioieiov in range(N):
	I = str(input())
	if I=="AC":
		a+=1
	elif I=="WA":
		w+=1
	elif I=="TLE":
		t+=1
	else:
		r+=1


print("AC x "+str(a))
print("WA x "+str(w))
print("TLE x "+str(t))
print("RE x "+str(r))



# 2darray [[0] * 4 for i in range(3)]

Measured memory_bytes: 9208
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n+1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table
def main():
    N = int(input())
    tmp = num_divisors_table(N)
    ans = 0
    for i in range(1,N+1):
        ans += i * tmp[i]

    print(ans)





if __name__ == "__main__":
    main()

Measured memory_bytes: 145784
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 1e5+5;
int a[N];
int main()
{
  int n; scanf("%d", &n);
  for(int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a+n);
  int m1, m2; m1 = m2 = 0;
  for(int i = 1; i < n; i++){
    if(a[i-1] == a[i]){m2 = m1; m1 = a[i]; i++;}
  }
  printf("%lld\n", (ll)m1*m2);
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a,b;
        scanf("%d %d",&a,&b);
        if (b%a == 0)
        {
            printf("%d\n",a+b);
        }

        else
        {
            printf("%d\n",b-a);
        }

    return 0;
}


Measured memory_bytes: 128
main(){int a[5],e,x,t;for(e=0;e<5;e++)scanf("%d",&a[e]);for(e=0;e<4;e++)for(x=e+1;x<5;x++){if(a[e]<a[x]){t=a[e];a[e]=a[x];a[x]=t;}}for(e=0;e<5;e++){printf("%d",a[e]);(e == 4)?printf("\n"):printf(" ");}return 0;}

Measured memory_bytes: 0
from bisect import bisect
from operator import itemgetter

import sys
input = sys.stdin.readline

def inpl(): return list(map(int, input().split()))


class BIT:
    def __init__(self, N):
        self.size = 2 ** (int.bit_length(N)+1)
        self.tree = [0]*(self.size + 1)

    def sum(self, i):
        res = 0
        while i:
            res += self.tree[i]
            i -= (i & -(i))
        return res

    def add(self, i, x):
        if i == 0:
            return
        while i <= self.size:
            self.tree[i] += x
            i += (i & -(i))


class RABIT():
    # range add BIT
    def __init__(self, N):
        self.bit0 = BIT(N)
        self.bit1 = BIT(N)

    def sum(self, i):
        return i*self.bit1.sum(i) + self.bit0.sum(i)

    def add_range(self, l, r, x):
        self.bit0.add(l, -x*(l-1))
        self.bit1.add(l, x)
        self.bit0.add(r+1, x*r)
        self.bit1.add(r+1, -x)

    def get_range(self, l, r):
        return self.sum(r) - self.sum(l-1)


N, M = inpl()
R, L, S = [], [], []
Q = []
for _ in range(N):
    l, r = inpl()
    Q.append((l, r, (r-l+1)))

Q = sorted(Q, key=itemgetter(2), reverse=True)
rabit = RABIT(M+1)

Lmin = M
Rmax = 0
for i in range(1, M+1):
    while Q and Q[-1][2] < i:
        l, r, _ = Q.pop()
        rabit.add_range(l, r, 1)
        Lmin = min(Lmin, l)
        Rmax = max(Rmax, r)
    ans = len(Q)
    for j in range(-(-Lmin//i) * i, Rmax+1, i):
        ans += rabit.get_range(j, j)
    print(ans)


Measured memory_bytes: 122196
#include<bits/stdc++.h>
using namespace std;
int n,k,a[200005];
bool check(int x){
    int left=k;
    for(int i=1;i<=n;i++){
        left-=(a[i]-1)/x;
        if(left<0)return 0;
    }
    return 1;
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	int l=1,r=1e9;
	while(l<r){
	    int mid=l+r>>1;
	    if(check(mid))r=mid;
	    else l=mid+1;
	}
	cout<<l;
}


Measured memory_bytes: 4360
#include <stdio.h>

int main(void){
  int r,c,i,j;
  static int s[101][101];

  scanf("%d%d",&r,&c);

  for(i=0;i<=r;i++){
    for(j=0;j<c;j++){
      scanf("%d", &s[i][j]);
      printf("%d ", s[i][j]);
      s[i][c] += s[i][j];
      s[r][j] += s[i][j];
    }
    printf("%d\n",s[i][c]);
  }

  return 0;
}

Measured memory_bytes: 640
import sys


def main():
    # input = sys.stdin.readline
    money = int(input())

    answer = '0'

    for i in range(1, 1001):
        low = i * 100
        high = i * 105
        if low <= money <= high:
            answer = '1'

    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int) (n); i++)
#define _GLIBCXX_DEBUG

int n, ans=0;
vector<int> a;

int main(){
    cin >> n;
    rep(i, n){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    for(int i = 1; i < n+1; i++){
        if(i % 2 != 0 && a.at(i-1) % 2 != 0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;
template<class T> T ika_max(set<T> &S, const T &x){
    typename set<T>::iterator it = S.lower_bound(x);
    if(it == S.end())it--;
    else if(*it > x)it--;
    return *it;
}
template<class T> T ijo_min(set<T> &S, const T &x){
    return *S.lower_bound(x);
}
int main(){

    ll N;
    cin >> N;
    vector<P>v;
    rep1(i, N){
        ll x;
        cin >> x;
        v.push_back(P(x, i));
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    set<ll>S;
    S.insert(0);
    S.insert(N + 1);
    rep(i, N){
        ll x = v[i].first;
        ll idx = v[i].second;
        ans += x * (idx - ika_max(S, idx)) * (ijo_min(S, idx) - idx);
        S.insert(idx);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 13548