akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a=nxtl(),b=nxtl(),c=nxtl();
    if(a>0)
    cout<<b/c-(a-1)/c<<endl;
    else
        cout<<b/c+1<<endl;
    
    return 0;   
}




 
 


Measured memory_bytes: 256
def main():
    s = input()
    t = input()
    length = len(t)
    mn = 9999
    for i in range(len(s) - length+1):
        counter = 0
        temp = s[i:i+length]
        #print(temp)
        for j,c in enumerate(temp):
            if t[j] != c:
                counter += 1
        mn = min(mn,counter)
    print(mn)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
int n,m;
int h[100010];
vector<int> G[100010];
int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> h[i+1];
    }
    for (int i = 0; i < m; i++) {
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        bool f = 1;
        for (int j = 0; j < G[i].size(); j++) {
            f &= (h[i] > h[G[i][j]]);
        }
        ans += f;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cout << name << " = " << arg1 << std::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...);
}
#else
#define debug(...)
#endif

int main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int x;
    cin >> x;
    cout << (x == 0) << "\n";
    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long

#define nl printf("\n")
#define pb(x) push_back(x)

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define P(a) printf("%d",a)

#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a<b)?a:b)

#define PL(a) printf("%lld",a)
#define PLN(a) printf("%lld\n",a)
#define PLC(a) printf("%lld ",a)
#define SL(a) scanf("%lld",&a)
#define SL2(a,b) scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SL4(a,b,c,d) scanf("%lld%lld%lld%lld",&a,&b,&c,&d)

#define CLR(a) memset(a,0,sizeof(a))
#define SET(a) memset(a,-1,sizeof(a))
#define FOOL(a) memset(a,false,sizeof(a))
#define fr(i,a,n) for(i=a;i<=n;i++)
#define frv(i,v) for(i=0;i<(int)v.size();i++)
#define pi acos(-1.0)
#define po 1000000
#define co 1000000
#define mod 786433

using namespace std;
int main()
{
    ll n,m,ans;
    SL2(n,m);
    if(n==1 and m==1)ans=1;
    else
    {
        if(n==1)ans = m-2;
        else if(m==1)ans = n-2;
        else ans=(n-2)*(m-2);
    }
    PLN(ans);
}

Measured memory_bytes: 256
r,g,b,n=map(int,input().split())

cnt=0
for i in range(n//r+1):
  for j in range((n-i*r)//g+1):
    
      #print("i,j,k",i,j,k)
    if (n-(i*r+j*g))%b==0:
        cnt+=1
        #print("ijk",i,j,k)
print(cnt)

Measured memory_bytes: 2940
#include <stdio.h>
int memo[1000001] = {0};
int main(){
  int n;
  int i,j,k;
  int sum;
  for(i = 2;i <= 1000001;i++){
    if(memo[i] == 1)continue;
    for(k = i * 2;k <= 1000001;k += i)memo[k] = 1;
  }
  while(scanf("%d",&n) != EOF){
    sum = 0;
    for(i = 2;i <= n;i++){
      if(memo[i] == 1)continue;
      sum++;
    }
    printf("%d\n",sum);
  }
  return(0);
}

Measured memory_bytes: 4500
a=int(input())
b=int(input())
c=int(input())
x=int(input())/50
#10a+2b+c=x
i=0
aam=int(x//10)
if aam > a:
    aam=a
for aa in range(aam+1):
    y=x-10*aa
    bbm=y//2

    if bbm > b:
        bbm=b
        #y-2bb>c NG
    for bb in range(int(bbm)+1):
    	if y-2*bb<=c:
        	i+=1
print(int(i))



Measured memory_bytes: 3064
#!/usr/bin/env python3
import numpy as np

n, d = map(int, input().split())
x = [np.array([*map(int, input().split())]) for _ in range(n)]
c = 0
for i in range(n):
    for j in range(i + 1, n):
        c += np.linalg.norm(x[i] - x[j]).is_integer()
print(c)


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> food(m);
  rep(i, n){
    int k;
    cin >> k;
    rep(j, k){
      int a;
      cin >> a;
      food[a-1]++;
    }
  }
  int ans = 0;
  rep(i, m){
    if(food[i] == n) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N, K = (int(i) for i in input().split())
l, r = [0]*K, [0]*K
for k in range(K):
    l[k], r[k] = (int(x) for x in input().split())

# dp : マスiまで移動する方法のパターン数
# TLE
'''
import numpy as np
dp = [0]*N
dp[0] = 1
for i in range(N):
    for k in range(K):
        for j in range(l[k], r[k]+1):
            if (i+j < N):
                dp[i+j] = dp[i+j] + dp[i]
            if j == r[k]:
                print(i, (l[k], r[k]), dp, np.diff(dp))
print(dp[-1]%998244353)
'''

# dp : マスiまで移動する方法のパターン数
# dps : dp[i] と dp[i+1] の 差
dp = [0]*N
dps = [0]*(N-1)
dp[0] = 1
dps[0] = -1
for i in range(N-1):
    for k in range(K):
        if i + l[k] - 1 < (N - 1):
            dps[i + l[k] - 1] += dp[i]
        if i + r[k] < (N - 1):
            dps[i + r[k]    ] -= dp[i]
        #print(i, (l[k], r[k]), dp, dps)
    dp[i+1] = (dps[i] + dp[i])%998244353
print(dp[-1]%998244353)

Measured memory_bytes: 24808
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <map>
#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 FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<long long>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
int MOD=1e9+7;
int INF=1e9+7;
//
int main(){
  long long A,B,C;
  cin>>A>>B>>C;
  if(A%2==0||B%2==0||C%2==0){
    cout<<0<<endl;
  }else{
    cout<<min(A*B,min(B*C,C*A))<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main() {
	
	int N,M,P;

	while(cin >> N >> M >> P)
	{
		vector<int> athlete(N,0);
		if(N==0 && M==0 && P==0){ break; }
		rep(i,N){ cin >> athlete[i];}

		int total = accumulate(ALL(athlete),0)*100;
		int gold = total - ((total*P)/100);
	
		int ans;
		if(athlete[M-1] == 0){
			ans = 0;
		}else{
			ans = gold / athlete[M-1];
		}
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 1196
/* 
    AtCoder Beginner Contest 086
    A:Product
    AC
*/

#include <iostream>
using namespace std;

int main(void){
    int a, b;
    cin >> a >> b;
    int mul = a * b;
    if(mul%2 == 0){
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;        
    }
}

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

int N;
vector<int> A[100000];
map<int, int> L;
int R;

int main() {
  cin >> N;
  for(int i = 0; i < N - 1; ++i) {
    int a, b; cin >> a >> b; A[a].push_back(b); A[b].push_back(a);
  }
  for(int v = 0; v < N; ++v) {
    if((int)A[v].size() == 1) {
      int w = v, p = -1;
      do {
        int u = w; w = A[w][0] != p ? A[w][0] : A[w][1]; p = u;
      } while((int)A[w].size() == 2);
      if(A[w].size() == 1) { cout << 1 << endl; return 0; }
      ++L[w];
    }
  }
  for(auto& kv : L) R += kv.second - 1;
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <cctype>

int main(int argc, char const *argv[]) {
  char alpha = 'a';
  int count[26]={};
  std::string s;
  while(std::getline(std::cin, s)){
    std::string::const_iterator it = s.begin();
    while(it != s.end()){
      char c = *it;
      if(std::isupper(c)){
        c = (char)std::tolower(c);
      }
      int num = c - 'a';
      count[num]++;
      it++;
    }
  }

  for(int i=0;i<26;i++){
    std::cout << alpha << " : " << count[i] << std::endl;
    alpha++;
  }
  return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    string a , b ;
    cin >> a >> b ;

    int aa = a.size() ;
    int bb = b.size() ;

    if ( bb - aa != 1 ) { cout << "No" ; line ; return ; }

    string s = b.substr ( 0 , aa ) ;

    if ( s == a ) cout << "Yes" ;
    else cout << "No" ;

    line ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


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

constexpr int mod = 1e9 + 7;

int bekizyo(int64_t x, int64_t n){
    int64_t res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}


int main(){
    int64_t n,k,num;
    cin >> n >> k;
    vector<int64_t> l(k+1);
    for(int i=k; i>0; i--){
        num = bekizyo(k/i, n);
        for(int j=0; j<k/i - 1; j++){
            num -= l.at(i * (j+2));
            num = (num + mod) % mod;
        }
        l.at(i) = num;
    }

    int64_t ans = 0;

    for(int i=1; i <= k; i++){
        ans += i * l.at(i);
        ans %= mod;
    }

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


Measured memory_bytes: 4048
import sys
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

def main():
    N = int(input())
    S1 = input()
    S2 = input()
    cut = []
    pre = None
    for i, c in enumerate(S1):
        if c != pre: cut.append(i)
        pre = c
    cut.append(N)
    ans = 1
    l = len(cut)
    pre = True  # vertical domino
    for i in range(l - 1):
        if i == 0 and cut[1] - cut[0] == 1:
            ans = 3
            pre = True
            continue
        if i == 0 and cut[1] - cut[0] == 2:
            ans = 6
            pre = False
            continue
        if pre and cut[i + 1] - cut[i] == 1:
            ans *= 2
            pre = True
        elif pre:
            ans *= 2
            pre = False
        elif not pre and cut[i + 1] - cut[i] == 1:
            pre = True
        else:
            ans *= 3
            pre = False
        ans %= mod
    print(ans)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 62104
import sys
import numpy as np
sys.setrecursionlimit(10 ** 5)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def main():
    H, W = LI()
    S = np.ones((H, W), dtype=int)
    for i in range(H):
        str = input()
        for j, s in enumerate(str):
            if s == '#':
                S[i][j] = 0

    L = S.copy()
    R = S.copy()
    U = S.copy()
    D = S.copy()
    for j in range(1, W):
        L[:, j] = (L[:, j-1] + 1)*S[:, j]
        R[:, W-j-1] = (R[:, W-j] + 1) * S[:, W-j-1]

    for i in range(1, H):
        U[i][:] = (U[i-1][:] + 1)*S[i][:]
        D[H-i-1][:] = (D[H-i][:] + 1)*S[H-i-1][:]

    ans = (L+R+U+D).max() - 3
    print(ans)


main()

Measured memory_bytes: 231240
import numpy as np

D = int(input())
c = np.array(list(map(int, input().split())))
s = np.array([list(map(int, input().split())) for _ in range(D)])


def s2(c, s, last_date, di, i):
    score = s[di - 1][i]
    score += 100 * c[i - 1] * (di - last_date[i - 1])
    return score


def f2(D, c, s):
    last_date = np.zeros(26)

    t = []
    for di in range(1, D + 1):
        score_list = []
        for i in range(26):
            score_list.append(s2(c, s, last_date, di, i))

        select_index = score_list.index(max(score_list))
        t.append(select_index)
        last_date[select_index] = di

    return t


for ti in f2(D, c, s):
    print(ti + 1)

Measured memory_bytes: 27444
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES

using namespace std;




int main()
{
    int x,n;
    unordered_map<int,int>mp;
    cin>>x>>n;
    int a[n],i;
    for(i=0;i<n;i=i+1){ cin>>a[i]; mp[a[i]]++;}
    int val = 0, minm = 1000;
    for(int i=-101;i<=101;i=i+1)
    {
        if(mp[i]==0)
        {
            if(abs(i-x)<minm){minm=abs(i-x);val=i;}
        }
    }
    cout<<val<<endl;
}




Measured memory_bytes: 3648
#include <stdio.h>

int main()
{
    while(1){
        int med,fin,re;
        scanf("%d %d %d",&med,&fin,&re);
        if(med==-1 && fin==-1 && re==-1){
            break;
        }
        else if(med==-1 || fin==-1){
            printf("F\n");
        }
        else if((med+fin)>=80){
            printf("A\n");
        }
        else if((med+fin)<80 && (med+fin)>=65){
            printf("B\n");
        }
        else if((med+fin)<65 && (med+fin)>=50){
            printf("C\n");
        }
        else if((med+fin)<50 && (med+fin)>=30){
            if(re>=50){
                printf("C\n");
            }else{
                printf("D\n");
            }
        }
        else{
            printf("F\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
	int n;
	cin>>n;
	int a=n%10;
	if(a==2 || a==4 || a==5 || a==7 || a==9){
		cout<<"hon"<<endl;
	}else if(a==3){
		cout<<"bon"<<endl;
	}else{
		cout<<"pon"<<endl;
	}
}

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

typedef long long i64;
set <i64> sumst, sumdr;

vector <pair <i64, i64>> bestst[200010], bestdr[200010];
int a[200010];

i64 proc(pair <i64, i64> a, pair <i64, i64> b)
{
    i64 mx = max(max(a.first, a.second), max(b.first, b.second));
    i64 mi = min(min(a.first, a.second), min(b.first, b.second));
    return mx - mi;
}

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

    int n;
    cin >> n;

    for (int i = 1; i <= n; i++)
        cin >> a[i];

    i64 sumact = 0;

    for (int i = 1; i <= n; i++) {
        sumact += a[i];

        if (i > 1) {
            auto x = sumst.upper_bound(sumact / 2);
            if (x != sumst.end())
                bestst[i].push_back({ *x, sumact - *x });
            if (x != sumst.begin())
            bestst[i].push_back({ *prev(x), sumact - *prev(x) });
        }
        sumst.insert(sumact);
    }

    sumact = 0;

    for (int i = n; i >= 1; i--) {
        sumact += a[i];

        if (i < n) {
            auto x = sumdr.upper_bound(sumact / 2);
            if (x != sumdr.end())
                bestdr[i].push_back({ *x, sumact - *x });
            if (x != sumdr.begin())
            bestdr[i].push_back({ *prev(x), sumact - *prev(x) });
        }
        sumdr.insert(sumact);
    }

    i64 best = 1LL << 60;

    for (int i = 1; i < n; i++)
        for (auto k : bestst[i])
            for (auto l : bestdr[i + 1])
                best = min(best, proc(k, l));

    cout << best << '\n';

    return 0;
}


Measured memory_bytes: 47872
#include <iostream>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
long long int n, a, b, m[100000], rem[100000];

bool check(int c)
{
    for (int i = 0; i < n; ++i)
        rem[i] = m[i] - (c * b);
    sort(rem, rem + n, greater<int>());
    bool s = 1;
    long long int d = a - b;
    for (int i = 0; i < n; ++i)
    {
        if (rem[i] <= 0)
            continue;
        int ne = ceil((float)rem[i] / d);
        if (ne > c)
            break;
        rem[i] = 0;
        c -= ne;
        if (c <= 0)
            break;
    }
    for (int i = 0; i < n; ++i)
    {
        if (rem[i] > 0)
        {
            s = 0;
            break;
        }
    }
    return s;
}

int main()
{
    cin >> n >> a >> b;
    for (int i = 0; i < n; ++i)
        cin >> m[i];
    int l = 1, r = 1e9;
    while (l <= r)
    {
        int m = (l + r) / 2;
        if (!check(m - 1) && check(m))
            return (cout << m << endl, 0);
        else if (check(m))
            r = m - 1;
        else
            l = m + 1;
    }
    return 0;
}

Measured memory_bytes: 1792
pos = [0,1,2,0,-1,2,0,1,2]
while 1:
    s = raw_input()
    if s == "#": break
    ans = 10**9
    for ini in range(2):
        tmp = 0
        b = pos[int(s[0])-1]
        lr = ini
        for i in s[1:]:
            f = pos[int(i)-1]
            if [b<f, b>f][lr]: tmp += 1
            else: lr = 1-lr
            b = f
        ans = min(ans, tmp)
    print ans

Measured memory_bytes: 4448
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}

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

int main(){
	string s;
  	cin>>s;
  
  	long long int L=s.size();
  	long long int n=0;
  	long long int p=1;
  	int d[2019]={0};
  	long long int cnt=0;
  	d[0]++;
    for(int i=L-1;i>=0;i--){
        n=(n+(s[i]-'0')*p)%2019;
      	p=(p*10)%2019;
      	cnt+=d[n];
        d[n]++;
    }
	
  	cout<<cnt<<endl;
}


Measured memory_bytes: 3764
// https://atcoder.jp/contests/abc081/tasks/arc086_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, t;
    cin >> n >> k;
    unordered_map<int, int> mp;
    vector<pair<int, int>> v;
    REP(i, n) {
        cin >> t;
        mp[t]++;
    }
    for (auto &x : mp) {
        v.push_back({x.second, x.first});
    }
    sort(ALL(v));
    ll ans = 0;
    REP(i, mp.size() - k) { ans += v[i].first; }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef pair<int,int> P;

int dp[101][101];
vector<P> v;

const int INF=(1<<31)-1;

int dfs(int d,int u){
	if(u==d)
		return 0;
	if(dp[d][u]!=INF)
		return dp[d][u];
	int minCost=INF;
	for(int i = d; i < u; i++){
		minCost=min(minCost,v[d].second*v[u].first*v[i].first*v[i+1].second+dfs(d,i)+dfs(i+1,u));
	}
	dp[d][u]=minCost;
	return dp[d][u];
}

int main(){

	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		int over,down;
		cin>>over>>down;
		v.push_back(P(over,down));
	}
	reverse(v.begin(),v.end());
	for(int i = 0; i < 101; i++)
		fill(dp[i],dp[i]+101,INF);
	cout<<dfs(0,n-1)<<endl;

	return 0;
}

Measured memory_bytes: 0
n = gets.chomp.to_i
ans = Array.new(n,0)
for i in 0..n-1 do
	arr = []
	arr = gets.chomp.split.map(&:to_i)
	arr.sort!
	if arr[2]**2 == arr[0]**2 + arr[1]**2
		ans[i] += 1
	end
end
for i in 0..n-1 do
	if ans[i] == 1
		puts "YES"
	else
		puts "NO"
	end
end

Measured memory_bytes: 8700
//~#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//~#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//~#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=998244353;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

void clr(auto &a,int n){
  a.clear();
  a.resize(n);
}

void unq(auto &a){
  sort(all(a));
  a.resize(unique(all(a))-a.begin());
}

const int N=300005;	

void solve(){
	int x;
	cin>>x;
	cout<<((x/500)*1000)+((x%500)/5)*5;
}


signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //~cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}
 


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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int A[3][3];
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++) {
			cin >> A[i][j];
		}
	}
	int N;
	cin >> N;
	vector<int>b(N);
	for (int i = 0; i < N; i++){
		cin >> b[i];
	}

	for (int i = 0; i < N; i++){
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (A[j][k] == b[i]) {
					A[j][k] = 1;
				}
			}
		}
	}
	if (A[0][0] == 1 && A[0][1] == 1 && A[0][2] == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	if (A[1][0] == 1 && A[1][1] == 1 && A[1][2] == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	if (A[2][0] == 1 && A[2][1] == 1 && A[2][2] == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	if (A[0][0] == 1 && A[1][0] == 1 && A[2][0] == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	if (A[0][1] == 1 && A[1][1] == 1 && A[2][1] == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	if (A[0][2] == 1 && A[1][2] == 1 && A[2][2] == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	if (A[0][0] == 1 && A[1][1] == 1 && A[2][2] == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	if (A[0][2] == 1 && A[1][1] == 1 && A[2][0] == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ll long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define rep(i, init, n) for (int i = init; i < (int)n; i++)
#define rev(i, n, init) for (int i = (int)n; i >= init; i--)
#define MOD1 1e9 + 7
#define MOD2 998244353
#define f first
#define s second
#define endl '\n'
#define pii pair<int, int>
#define piii pair<pii, int>
#define precise(i) cout << fixed << setprecision(i)
#define codejam cout << "Case #" << ii + 1 << ": ";
#define impossible cout << "IMPOSSIBLE" << endl;
#define error(s) throw runtime_error(s)
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int myRand(int R){int val=rng()%R;assert(val >= 0);return val;}

const long double PI = atan(1.0) * 4;
const int64_t INF64 = 3e18;
const int32_t INF32 = 2e9 + 7;
const int32_t LOG = 21;
const int32_t MOD = MOD1;

using namespace std;


//-------------------DEBUGGING-------------------------
void my_debugger(string s,int LINE_NUM){cerr<<endl;}
template<typename start,typename... end>
void my_debugger(string s,int LINE_NUM,start x,end... y) 
{
    if(s.back()!=',') {s+=',';cerr<<"LINE("<<LINE_NUM<<"): ";}
    int i=s.find(',');
    cerr<<s.substr(0,i)<<" = "<<x;
    s=s.substr(i+1);
    if(!s.empty()) cerr<<", ";
    my_debugger(s,LINE_NUM,y...);
}

#ifdef AJIT
#define debug(...) my_debugger(#__VA_ARGS__,__LINE__,__VA_ARGS__);
#else
#define debug(...) ;
#endif

//-----------------------------------------------------



int32_t main()
{
      getFaster;
      //files_init();
      int tests = 1;
      //cin >> tests;
      rep(ii, 0, tests)
      {
           int n,x,m;
           cin>>n>>x>>m;
           vector<int> seq;
           vector<bool> check(m,false);
           vector<int> ind(m,0);

           int cur=x;
           int it=0;
           
           while(!check[cur])
           {
                check[cur]=true;
                ind[cur]=it;
                seq.push_back(cur);
                cur=(cur*cur)%m;
                it++;
           }


           bool start=false;
           int ind1=-1;
           int len=0;
           int sum_loop=0;

           rep(i,0,seq.size())
           {
                 if(seq[i]==cur){start=true;ind1=i;}
                 if(start){sum_loop+=seq[i];len++;}  
           }


           int siz=seq.size();

           if(n<=siz)
           {
               int ans=0;
               rep(i,0,n)ans+=seq[i];
               cout<<ans<<endl;
               return 0;
           }


           int ans=0;
           rep(i,0,seq.size())ans+=seq[i];

           n-=siz;
           
           int div=n/len;
           ans+=div*sum_loop;

           int rem=n%len;
           rep(i,ind1,seq.size())
           {
               if(rem==0)break;
               rem--;
               ans+=seq[i];
           }

           cout<<ans<<endl;


           

      }
      return 0;
}


Measured memory_bytes: 4700
#include <iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;



int main() {
    string s,t;
    cin>>s>>t;
    int cnt=0;
    rep(i,s.size()){
        if(s[i]!=t[i])cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 3920
try :
    from math import gcd
except ImportError :
    from fractions import gcd

N = int(input())
A = list(map(int,input().split()))

L = [0]
R = [0]

for i in range(N) :
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[N-1-i]))

M = []
R = R[::-1]
for i in range(N) :
    M.append(gcd(L[i], R[i+1]))


print(max(M))


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

int main(){
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  int ans = 0;
  if(v[0] % 2 == v[1] % 2 && v[1] % 2 == v[2] % 2){
    ans += (v[2] - v[1]) / 2 + (v[2] - v[0]) / 2;
  }else if(v[0] % 2 == v[1] % 2){
    ++v[0];
    ++v[1];
    ++ans;
    ans += (v[2] - v[1]) / 2 + (v[2] - v[0]) / 2;
  }else if(v[1] % 2 == v[2] % 2){
    ++v[1];
    ++v[2];
    ++ans;
    ans += (v[2] - v[1]) / 2 + (v[2] - v[0]) / 2;
  }else{
    ++v[0];
    ++v[2];
    ++ans;
    ans += (v[2] - v[1]) / 2 + (v[2] - v[0]) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)

{

 int n,x,min,max;

 long sum;


 int i;


 scanf("%d %d",&n,&x);

 min=max=sum=x;


 for(i=1; i<n; i++){

  scanf("%d",&x);

  sum +=x;


  if(max<x)


   max=x;


  if(min>x)


   min=x;


  }


  printf("%d %d %ld\n",min,max,sum);


 return 0;


}


 


 

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

#define MXN 100005
string str;
int N;
ll DP[2][13];
bool qu[MXN];
ll mpo[MXN];
ll K;

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

    cin>>str;
    reverse(ALL(str));

    N = SZ(str);
    ll po = 1;
    FOR(i,0,N-1)
    {
        mpo[i]=po;
        if( str[i]=='?' )qu[i]=true;
        else K=(K+po*( str[i]-'0' ))%13;
        po=po*10%13;
    }

    DP[0][K]=1;
    int cur = 1, prv = 0;
    FOR(i,0,N-1)
    {
        if( !qu[i] )continue;
        po = mpo[i];

        //put 0
        FOR(m,0,12)DP[cur][m]=DP[prv][m];
        //put > 0
        FOR(d,1,9)
        {
            ll v = (po*d)%13;
            FOR(m,0,12)
            {
                DP[cur][(m+v)%13]=(DP[cur][(m+v)%13]+DP[prv][m])%MOD;
            }
        }
        swap(cur,prv);
    }
    cout<<DP[prv][5]<<'\n';

    return 0;
}


Measured memory_bytes: 1360
program prob2
    implicit none
    integer :: N,L,ans
    read(*,*) N,L
    ans = (2*L+N-1)*N/2

    if(L > 0) then
        ans = ans - L
    else if(L+N-1 < 0) then
        ans = ans - (L+N-1)
    else
        ans = ans
    end if
    write(*,*) ans

    stop
contains
end program prob2

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    bool ans = (n%2==0 && s.substr(0,n/2)==s.substr(n/2));
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int x,a,b,d,e;
  scanf("%d %d %d",&x,&a,&b);
  d= x>=a ? x-a:a-x;
  e= x>=b ? x-b:b-x;
  if(d<e) printf("A\n");
  else printf("B\n");
  return 0;
}

Measured memory_bytes: 1644
#include <iostream>

using namespace std;

int main() {
	int n, *a;
	cin >> n;
	a = new int[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cout << a[n-1];
	for (int i = n-2; i >= 0; i--)
		cout << " " << a[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

ll gcb(ll a, ll b){/// ユークリッドの互除法: O(log)
    
    if(b == 0) return a;
    
    return gcb(b,a%b);
}


ll lcm(ll a, ll b){
    
    return  a/gcb(a,b) * b; ///gcbは約数
}

int getDigit(ll num){
    return log10(abs(num))+1;
}


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

    int c[128]={0};
    for(auto ch:s){
        c[ch]++;
    }
    
    if(s.size()==26){
        
        bool f= next_permutation(all(s));
        
        if(!f) {cout<<-1<<endl; return 0;}
        
        for(auto i = 0; i<26;i++){
            
            if(s[i]==S[i]){cout<<S[i];continue;}
            cout<<s[i]<<endl;
            return 0;
        }
        
    }else{
        
        cout<<s;
        
        for(auto ch = 'a'; ch<='z';ch++){
            if(c[ch]==0){cout<<ch<<endl;return 0;}
        }
        
        
    }
    
    return 0;
}










Measured memory_bytes: 256
function main(input) {
  const args = input.split('\n')
  const s = args[0]
  const t = args[1]
  if (t.slice(0, s.length) === s) {
    console.log('Yes')
  } else {
    console.log('No')
  }
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29588
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;//T
 
Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}
 
Node treeSearch(Node u, int k){
  while((u != NIL) && (k != u->key)){
    if (k < u->key){
    u = u->left;
    } 
    else u = u->right;
  }
  return u;
}
 
Node treeSuccessor(Node x){
  Node y;
 
  if(x->right != NIL)
    return treeMinimum(x->right);
  y = x->parent;
 
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
 
  if(z->left == NIL || z->right ==NIL)
    y = z;
  else y = treeSuccessor(z);
 
  if(y->left != NIL)
    x = y->left;
  else x = y->right;
 
  if(x != NIL)
    x->parent = y->parent;
  if(y->parent == NIL)
    root = x;
  else if(y == y->parent->left)
    y->parent->left = x;
  else y->parent->right = x;
 
  if(y != z)
    z->key = y->key;
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
   
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
   
  /*??´????????¢????????????*/
  while(x != NIL){
    y = x;
    if (z->key < x->key)
    x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if (y == NIL)
  root = z;
  else if(z->key < y->key)
    y->left = z;
  else y->right = z;
}
 
void inorder(Node u){
  if(u != NIL) {
    if(u->left != NIL) inorder(u->left);
    printf(" %d",u->key);
    if(u->right != NIL) inorder(u->right);
  }
}
void preorder(Node u){ 
  if(u != NIL) {
    printf(" %d",u->key);
    if(u->left != NIL) preorder(u->left);
    if(u->right != NIL) preorder(u->right);
  }
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
char a[N];
const LL M=1e9+7;
LL dp[N][15];
int g(int j,int k){
	for(int i=0;i<13;i++){
		if(((i*10)%13+j)%13==k)return i;
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>a+1;
	int n=strlen(a+1);
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		if(a[i]=='?'){
			for(int j=0;j<=9;j++){
				for(int k=0;k<13;k++){
					dp[i][k]+=dp[i-1][g(j,k)];
					dp[i][k]%=M;
				}
			}
		}else{
			for(int k=0;k<13;k++){
				dp[i][k]+=dp[i-1][g(a[i]-'0',k)];
				dp[i][k]%=M;
			}			
		}
	}	
	cout<<dp[n][5];
	return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int main(){
  int k, x;
  cin >> k >> x;
  
  if(k*500 >= x){
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
  
  return 0;
  
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void){
    int N,M; cin >> N >> M;
    ll A[N][3];
    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++){
            cin >> A[i][j];
        }
    }

    ll ans=0;

    for(int i=0; i<8; i++){
        vector<ll> V;

        for(int j=0; j<N; j++){
            ll tmp=0;
            for(int k=0; k<3; k++){
                if((i&(1<<(2-k)))!=0) tmp+=A[j][k];
                else tmp-=A[j][k];
            }
            V.push_back(tmp);
        }

        sort(V.begin(), V.end()); reverse(V.begin(),V.end());
        ll t=0;
        for(int j=0; j<M; j++) t+=V[j];

        ans=max(ans,t);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] -= (i + 1);
    }
    sort(A, A + N);
    ll ans = 0;
    ll num = A[N / 2];
    for (int i = 0; i < N; i++) {
        ans += abs(A[i] - num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
	int n, s;
	int c[105], t[105];
	int ans = 10000;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		cin >> c[i] >> t[i];
		if (t[i] <= s&&c[i] < ans) {
			ans = c[i];
		}
	}
	if (ans == 10000) {
		cout << "TLE" << endl;
	}
	else if (ans!=10000) {
		cout << ans << endl;
	}
	return 0;

}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, k; cin >> n >> k;

    ll ans = 0;
    for (ll i = k; i <= n + 1; ++i) {
        ans += i * (n + 1 - i + n) / 2 - i * (i - 1) / 2 + 1;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	private static final int UP = 'A' - 'a';
	private static final int LOW = -UP;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		char s[];
		char targetType;
		StringBuilder sb = new StringBuilder(100);
		while (in.hasNext()) {
			s = in.next().toCharArray();
			sb.setLength(0);
			targetType = in.next().charAt(0);
			if (targetType == 'X') {
				break;
			}
			if (targetType == 'U') {
				if (!(s[0] <= 'Z')) {
					s[0] += UP;
				}
			} else {
				if (s[0] <= 'Z') {
					s[0] += LOW;
				}
			}
			sb.append(s[0]);
			for (int i = 1; i < s.length; i++) {
				if (s[i] == '_') {
					s[i + 1] += UP;
				} else if (s[i] <= 'Z' && targetType == 'D') {
					s[i] += LOW;
					sb.append('_').append(s[i]);
				} else {
					sb.append(s[i]);
				}
			}
			System.out.println(sb.toString());
		}
	}
}

Measured memory_bytes: 17172
k=int(input())

dp=[[] for i in range(10**4)]

if k<=9:
    print(k)
    exit()

dp[1]=[str(i) for i in range(1,10)]

n=9
i=1
while n<k:
    for mo in dp[i]:
        simo=int(mo[-1])
        rr=[str(simo-1),str(simo),str(simo+1)]
        for r in rr:
            if 0<=int(r)<=9:
                n+=1
                gen=mo+r
                dp[i+1].append(gen)
                if n==k:
                    ans=gen
                    print(ans)
                    exit()
    i+=1

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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    string s;
    cin>>s;
    int idxa, idxz;
    for(int i = 0; i < sz(s); i++)
    {
        if(s[i]=='A'){
            idxa=i;
            break;
        }
    }

    for(int i = sz(s)-1; i >= 0; i--)
    {
        if(s[i]=='Z'){
            idxz=i;
            break;
        }
    }
    
    cout<<idxz-idxa+1<<endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (B % A == 0) {
            System.out.println(A + B);
        } else {
            System.out.println(B - A);
        }
    }
}

Measured memory_bytes: 21588
import sys
N=int(input())
"""
if N<=26:
  l=[]
  l.append(N)
  i=0
  print(chr(l[i]+96))
  sys.exit()
"""
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        if X_dumy%n==0:
          out= str(n)+','+out
          X_dumy = int(X_dumy//n)-1
        else:
          out = str(X_dumy%n)+','+out
          X_dumy = int(X_dumy//n)
    return out
ans=Base_10_to_n(N,26)
l=list(ans.split(","))
for i in range(len(l)-1):
  print(chr(int(l[i])+96),end="")


Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;
 
int main(){
  deque<char> abc[3];
  rep(i,3){
    str line;
    cin >> line;
    for(auto c : line)
      abc[i].push_back(c);
  }

  function<void(char)> dfs = [&](char turn_person){
    char tmp = abc[turn_person - 'a'].front();
    if(abc[turn_person - 'a'].size() > 0){
      abc[turn_person - 'a'].pop_front();
      dfs(tmp);
    }
    else 
      cout << (char)toupper(turn_person);
  };

  dfs('a');
  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<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll n; cin >> n;
    vector<ll> a(n-1);
    vector<ll> res(n);
    rep(i,n-1){
        cin>>a[i];
        res[a[i]-1]++;
    }
    rep(i,n) cout<<res[i]<<endl;
    return 0;
}

Measured memory_bytes: 6424