akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

#define MAX (1000000)
#define INF (1<<30)

int main() {
  
  int dp_all[MAX+2], dp_odd[MAX+2];
  
  fill(dp_all, dp_all+MAX+1, INF);
  fill(dp_odd, dp_odd+MAX+1, INF);
  
  dp_all[0] = dp_odd[0] = 0;
  
  for(int i=1; ; i++) {
    int num = i*(i+1)*(i+2) / 6;
    if(num > MAX) break;
    for(int j=num; j<=MAX; j++) {
      dp_all[j] = min(dp_all[j], dp_all[j-num]+1);
      if(num % 2)
	dp_odd[j] = min(dp_odd[j], dp_odd[j-num]+1);
    }
  }
  
  int n;
  while(cin >> n && n) {
    cout << dp_all[n] << " " << dp_odd[n] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 8972
//When I wrote this, only God and I understood what I was doing
//Now, God only knows :-)
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ch char
#define vc vector
#define str string
long long C(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }
    return ans;
}
int main() {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y;
    cin>>x>>y;
    ll sum=0;
    if(x>=2)
    sum+=C(x,2);
    if(y>=2)
    sum+=C(y,2);
    cout<<sum;

}


Measured memory_bytes: 256
using System;
using System.Linq;

public class AizuOnlineJudge {
    static void Main() {
        Console.WriteLine(
            Enumerable
                .Range(0, 6)
                .Select(q => int.Parse(Console.ReadLine()) | (q << 16))
                .GroupBy(q => (q >> 16) < 4)
                .Select(q => q.Select(v => v & 0xFF).OrderByDescending(v => v).Take(q.Count() - 1).Sum())
                .Sum()
        );
    }
}

Measured memory_bytes: 10196
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  ll s;
  cin>>s;
  ll d = 0;
  ll t = s;
  while(t > 0) {
    t /= 10;
    d++;
  }
  ll ans = 0;
  for(int i = 0; i < (1 << (d-1)); i++) {
    bool f[d];
    rep(j, d-1) {
      if(i >> j & 1) {
        f[j] = true;
      } else {
        f[j] = false;
      }
    }
    f[d-1] = false;
    t = s;
    ll r = 1;
    rep(j, d) {
      ans += t % 10 * r;
      t /= 10;
      if(f[j]) {
        r = 1;
      } else {
        r *= 10;
      }
    }
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
// なぞなぞ： メモリの海上で未使用部分を奪い合う人々は誰？　答え：ハイレーツ
#define DB cerr<<"D"<<endl // これはデバッグ用
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<int,int>;
//const ll M = 1e9+7;
ll M;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
ll adad(ll x) {return x*(x+1)/2;} // 1～xの総和
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}

int main() {
  int n; cin>>n;
  cout<<(10000-n)%1000<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
long M=1e9+7,n,k,ans=1,l,r,b=1,a[1<<18],x,y;
int main(){
  cin>>n>>k;
  r=n-1;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  if(k%2)ans=a[r],r--,k--,b=(ans<0?-1:1);
  while(k){
    x=a[l]*a[l+1],y=a[r]*a[r-1];
    if(x*b>y*b)ans*=x%M,ans%=M,l+=2;
    else ans*=y%M,ans%=M,r-=2;
    k-=2;
  }
  cout<<(ans+M)%M<<endl;
}


Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N = 1e3 + 5;
#define int long long int

int32_t main() {
    IOS ;
    // int t ; cin >> t ; while(t--) {}
    int n,x,t,a ; cin >> n >> x >> t ; 
    if(n%x == 0) a = n/x ; 
    else a = n/x + 1 ;
    cout << a*t ;
    return 0 ;
}


Measured memory_bytes: 3636
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	ll N,A;
	cin>>N>>A;
	VI X(N);
	ll B=0;
	REP(i,N){
		cin>>X[i];
		B=max(X[i],B);
	}
	B=max(B,A);
	ll dp[51][51][2501]={0};
	eREP(i,N){
		eREP(j,N){
			eREP(k,N*B){
				if(i==0 && j==0 && k==0)
					dp[i][j][k]=1;
				
				else if(i>=1 && X[i-1]>k)
					dp[i][j][k]=dp[i-1][j][k];
				
				else if(i>=1 && j>=1 && k>=X[i-1])
					dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-X[i-1]];
				
				else 
					dp[i][j][k]=0;
			}
		}
	}
	ll ans=0;
	
	eFOR(i,1,N)
		ans+=dp[N][i][i*A];
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 51072
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "m_solutions2020_b.cpp"

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

  int a, b, c;
  cin >> a >> b >> c;
  int k;
  cin >> k;

  int cnt = 0;
  while (b <= a) {
    cnt++;
    b *= 2;
  }
  while (c <= b) {
    cnt++;
    c *= 2;
  }
  say(cnt <= k);
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(){
int n,i,a[100000],max=0,nmh=0,mh,hjf=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(max<a[i])max=a[i];
}
if(max%2==1){
mh=(max+1)/2;}
else{mh=max/2;}
for(i=0;i<n-1;i++){
if(mh>a[i]&&a[i]>hjf){nmh=a[i];hjf=a[i];}
else if(mh<=a[i]&&max-a[i]>hjf){nmh=a[i];hjf=max-a[i];}
}
printf("%d %d",max,nmh);
return 0;
}

Measured memory_bytes: 512
def resolve():
    '''
    code here
    '''
    K, A, B = [int(item) for item in input().split()]

    if B - A > 1:
        num = K - (A - 1)
        print(num//2 * (B-A) + num%2 + A)
    else:
        print(1 + K)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9164
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	int L,R,d; cin >> L >> R >> d;

	int ans = 0;
	for (int i = L; i <= R; i++) {
		if (i % d == 0) {
			ans++;	
		}
	}


	
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>

int main(){
    long n;
    std::cin >> n;

    long i = 0;
    while((long)std::pow(i, 2) <= n){
        ++i;
    }

    std::cout << (long)std::pow(i - 1, 2) << std::endl;

    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<math.h>
 
int main(void){
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if(abs(c-a) <= d){
        printf("Yes");
    }else if(abs(b-a)<=d && abs(c-b) <= d){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

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

using namespace std;

int L[10];

int main()
{
	int N;
	int sum = 0;

	cin >> N;

	for (int i = 0; i < N; i++) cin >> L[i];

	sort(L, L + N);

	for (int i = 0; i < N - 1; i++) sum += L[i];

	if (L[N - 1] < sum) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
N = 1000001
a = [0]* N
_, s = open(0)
for x in s.split():
  a[int(x)] += 1
for i in range(1, N):
  for j in range(i + i, N, i):
    if a[i]:
      a[j] = 0
print(a.count(1))


Measured memory_bytes: 98156
var
  n,i,mid:longint;
  flag:boolean;
  s:string;
begin
  readln(n);
  readln(s);
  if (odd(n)=true) then writeln('No')
  else
  begin
    flag:=true;
    mid:=n div 2;
    for i:=1 to mid do
      if (s[i]<>s[i+mid]) then flag:=false;
    if (flag=true) then writeln('Yes')
    else writeln('No');
   end;
 end.

Measured memory_bytes: 128
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

a,b = MI()
print(a*b)


Measured memory_bytes: 27224
N, K = map(int, input().split())
A = [tuple(int(x) for x in input().split()) for _ in range(N)]
A = [(a, b) for a, b in A if a <= K]
L = K.bit_length()
ans = sum(b for a, b in A if (a | K) <= K)
for i in reversed(range(L)):
    bit = (1 << i) & K
    if bit != 1:
        cand = 0
        bor = 0
        tmp_K = K & ~(1 << i) | ((1 << i) - 1)
        ans = max(ans, sum(b for a, b in A if (a | tmp_K) <= K))
print(ans)


Measured memory_bytes: 23764
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

(x1,y1) >+< (x2,y2) = (x1+x2,y1+y2)
(x1,y1) >-< (x2,y2) = (x1-x2,y1-y2)


main = do
    n <- getInt
    when (n/=0) $ do
        ts <- map (apply2 (,)) <$> replicateM n getInts
        let base = head ts
        let dts = map (>-<base) ts
        m <- getInt
        ws <- map (apply2 (,)) <$> replicateM m getInts
        let wset = Set.fromList ws
        let (x,y) = (>-<base) $ fromJust $ find (\p -> all (flip Set.member wset) [p >+< d | d <- dts]) ws in putStrLn $ show x ++ " " ++ show y
        main

Measured memory_bytes: 5792
N, M = map(int, raw_input().split())

ans = ""
for i in range(N):
     ans = ans + "a"

ans = list(ans)
flag = True

for i in range(M):
     s, c = map(int, raw_input().split())
     if ans[s-1] == "a":
          ans[s-1] = c
     elif ans[s-1] != c:
          flag = False

if N == 1:
     if ans[0] == "a" or ans[0] == 0:
          print "0"
          exit()


new = ""
if ans[0] == "a":
     ans[0] = 1
for i in range(N):
     if ans[i] == "a":
          new = new+"0"
     else:
          new = new + str(ans[i])

if new[0] == "0":
     flag = False

if N == 1:
     if new[0] == 0:
          flag = True

if flag == True:
     print new
else:
     print "-1"


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

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

    ll x = 0;
    while(x < N)
        x += 1000;
    cout << x - N << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


int main(int argc, char**argv){
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    ll ans = 0;
    for (int i = 0; i <= n / r; i++){
        for (int j = 0; j <= n / g; j++){
            int sum = r*i + g*j;
            if (n - sum >= 0 && (n - sum) % b == 0){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}















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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (long long)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back


int32_t main(){
sp;
    int x,k;
    cin>>k>>x;
    int lower=-1000000;
    int upper=1000000;
    for(int i=max(lower,x-k+1); i<=x; ++i)
        cout<<i<<" ";
    for(int i=x+1; i<=min(upper,x+k-1); ++i)
        cout<<i<<" ";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int n,d;
int main()
{
    int dem=0;
    cin>>n>>d;
    while(n--)
    {
        long long int a,b;
        cin>>a>>b;
        if(sqrt(a*a + b*b) <= d) dem++;
    }
    cout<<dem;
}


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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100

int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    for(int i = 2; i <= n; i++)
    {
        if(ans >= 1000000007/i)
        {
            ans %= 1000000007;
        }
        ans *= i;
    }

    ans %= 1000000007;

    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

int DP[101][10001];

int main(int argc, const char * argv[]) {
    int N, T;
    cin >> N >> T;
    vector<int> V(N), W(N);
    for (int n = 0; n < N; ++n) {
        cin >> V[n] >> W[n];
    }
    for (int n = 1; n <= N; ++n) {
        for (int t = 0; t <= T; ++t) {
            if (t >= W[n-1]) {
                DP[n][t] = max(DP[n-1][t], DP[n-1][t-W[n-1]] + V[n-1]);
            } else {
                DP[n][t] = DP[n-1][t];
            }
        }
    }
    cout << DP[N][T] << endl;
    return 0;
}



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    string S;
    cin >> S;
    int ans = 0;
    if(S == "SUN") {
        ans = 7;
    }
    else if(S == "MON") {
        ans = 6;
    }
    else if(S == "TUE") {
        ans = 5;
    }
    else if(S == "WED") {
        ans = 4;
    }
    else if(S == "THU") {
        ans = 3;
    }
    else if(S == "FRI") {
        ans = 2;
    }
    else if(S == "SAT") {
        ans = 1;
    }

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

    return 0;
}


Measured memory_bytes: 256
n = int(input())
strings = [[] for _ in range(n)]
for i in range(n):
    if not i:
        strings[i].append("a")
        continue
    for s in strings[i-1]:
        for j in range(ord("a"),ord(max(s))+2):
            c = chr(j)
            strings[i].append(s+c)
print(*strings[-1])
        

Measured memory_bytes: 62300
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;


int main(){
  ll n; cin >> n;
  int ans = 11;
  for(ll i = 1; i <= pow(n, 0.5) ; i++){
    if(n % i == 0){
      string s = to_string(i);
      string t = to_string(n / i);
      int res = max(s.size(), t.size());
      if(res < ans){ans = res;}
    }
  }
  cout << ans << endl;

}

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

int main(){
	int N,i,j,k;
	long long x,y,z;
	cin >> N;
	vector<long long> a(N);
	for(i=0;i<N;i++){
		cin >> a[i];
	}
	//vector<int> temp(100,10);
	//sort(temp.begin(),temp.end());
	x=0;
	y=0;
	
	for(i=0;i<N;i+=2){
		if(a[i]>0){
			x +=a[i];
		}
	}
	for(i=0;i+1<N;i+=2){
		if(a[i+1]>0){
			y +=a[i+1];
		}
	}
	if(x==0 && y==0){
		z=a[0];
		j=0;
		for(i=0;i<N;i++){
			if(a[i]>z){
				z=a[i];
				j=i;
			}
		}
		cout << z << endl;
		cout<< N-1 << endl;
		for(i=0;i<=j-1;i++){
			cout << 1 << endl;
		}
		for(i=j;i<=N-2;i++){
			cout << N-i << endl;
		}
	}else if(x>=y){
		cout << x << endl;
		if(N%2==0){
		for(i=0;i<10000;i++){
			if(a[N-2*i-2]>0){
				k=2*i+1;
				break;
							}
							}			
		for(i=0;i<a.size();i++){
			if(a[2*i]>0){
				j=2*i;
				break;
						}
							}		
		cout << (N+k+j-1)/2  << endl;
			for(i=0;i<k;i++){
				cout << N-i << endl;
							}
		for(i=0;i<j;i++){
			cout << 1 << endl;
							}
		for(i=1;i<=(N-1-k-j)/2;i++){
				if(a[j+2*i]>0){
					cout << 2 << endl;
							}else{
					cout << 3 << endl;
					}
			}
		}else{ //N%2==1	&& x>=y
				for(i=0;i<10000;i++){
				if(a[N-2*i-1]>0){
					k=2*i;
					break;
				}
			}
		for(i=0;i<10000;i++){
			if(a[2*i]>0){
				j=2*i;
				break;
			}
		}	
		cout << (N+k+j-1)/2  << endl;
			for(i=0;i<k;i++){
				cout << N-i << endl;
			}
		for(i=0;i<j;i++){
			cout << 1 << endl;
		}
		for(i=1;i<=(N-1-k-j)/2;i++){
				if(a[j+2*i]>0){
					cout << 2 << endl;
				}else{
					cout << 3 << endl;
				}
			}
		}
		}else{ //(y>x)
		cout << y << endl;
			if(N%2==0){
			for(i=0;i<10000;i++){
				if(a[N-2*i-1]>0){
					j=2*i;
					break;
				}
			}
			for(i=0;i<10000;i++){
				if(a[2*i+1]>0){
					k=2*i+1;
					break;
				}
			}
			cout << (N-1+k+j)/2	<< endl;
			for(i=0;i<j;i++){
				cout << N-i << endl;
			}
			for(i=0;i<k;i++){
				cout << 1 << endl;
			}
				for(i=1;i<=(N-j-k-1)/2;i++){
				if(a[k+2*i]>0){
					cout << 2 << endl;
				}else{
					cout << 3 << endl;
				}
			}
		}else{//N%2==1 && y>x
			for(i=0;i<10000;i++){
				if(a[N-2*i-2]>0){
					j=2*i+1;
					break;
				}
			}
			for(i=0;i<10000;i++){
				if(a[2*i+1]>0){
					k=2*i+1;
					break;
				}
			}
			cout << (N-1+k+j)/2	<< endl;
			for(i=0;i<j;i++){
				cout << N-i << endl;
			}
			for(i=0;i<k;i++){
				cout << 1 << endl;
			}
				for(i=1;i<=(N-j-k-1)/2;i++){
				if(a[k+2*i]>0){
					cout << 2 << endl;
				}else{
					cout << 3 << endl;
				}
			}
		}
	}
	}

Measured memory_bytes: 256
dp = [-1 for i in range(2005)]
dp[0] = 0

def ok(s):
	if s==0:
		return 1
	elif s==1 or s==2:
		return 0
	elif s>=3 and s<=5:
		return 1
	elif dp[s] != -1 :
		return dp[s]
	else:
		total = 0
		for i in range(3,s+1):
			if s-i >=0 :
				total = total + ok(s-i)

		dp[s]=total

		return total



s = int(input())
print(ok(s)%((10**9) + 7))

Measured memory_bytes: 9212
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#include<set>
multiset<int> st;
int main(){
	int n;
	cin>>n;
	lol(i,n){
		int a;cin>>a;
		st.insert(a);
	}
	int m;
	cin>>m;
	bool ok=true;
	lol(i,m){
		int a;
		cin>>a;
		if(st.find(a)==st.end())ok=false;
		else st.erase(st.find(a));
	}
	if(ok)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int f(int x, int y, int z) {
	return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main() {
	int a, b, c, x, y,ans;
	cin >> a >> b >> c >> x >> y;
	if (a + b > 2*c) {//a,b1枚ずつ買う方がABを組み替えて1枚づつにするより高い場合
		int tmp1, tmp2,tmp,dai;
		if (x >= y) {
			tmp1 = 2 * c * y + a * (x - y);
			tmp2 = 2 * c * x;
		}
		else {
			tmp1 = 2 * c * x + b * (y - x);
			tmp2 = 2 * c * y;
		}
		ans = min(tmp1, tmp2);
	}
	else {
		ans = a * x + b * y;
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 3632
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
from fractions  import gcd
#input=sys.stdin.readline
import bisect
a,b,c=map(int,input().split())
k=int(input())
cnt=0
y=0
while True:
    x=pow(2,y)
    if a<b*x:
        b*=x
        break
    else:
        cnt+=1
        y+=1
y=0

while True:
    x=pow(2,y)
    if b<c*x:
        c*=x
        break
    else:
        cnt+=1
        y+=1
if cnt<=k:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 72760
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n,x,t;
    cin >> n >> x >> t;

    cout << ((n + x - 1) / x) * t << endl;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
string str;
void solve()
{
    vector < int > inp,tmp;
    int i,temp,len=str.length();
    for (i=0;i<len;i++)
        inp.push_back(str[i]-'0');
    if (inp[0]+inp[1]+inp[2]+inp[3]==7) cout<<inp[0]<<"+"<<inp[1]<<"+"<<inp[2]<<"+"<<inp[3]<<"=7";
    else if (inp[0]-inp[1]+inp[2]+inp[3]==7) cout<<inp[0]<<"-"<<inp[1]<<"+"<<inp[2]<<"+"<<inp[3]<<"=7";
    else if (inp[0]+inp[1]-inp[2]+inp[3]==7) cout<<inp[0]<<"+"<<inp[1]<<"-"<<inp[2]<<"+"<<inp[3]<<"=7";
    else if (inp[0]-inp[1]-inp[2]+inp[3]==7) cout<<inp[0]<<"-"<<inp[1]<<"-"<<inp[2]<<"+"<<inp[3]<<"=7";
    else if (inp[0]+inp[1]+inp[2]-inp[3]==7) cout<<inp[0]<<"+"<<inp[1]<<"+"<<inp[2]<<"-"<<inp[3]<<"=7";
    else if (inp[0]+inp[1]-inp[2]-inp[3]==7) cout<<inp[0]<<"+"<<inp[1]<<"-"<<inp[2]<<"-"<<inp[3]<<"=7";
    else if (inp[0]-inp[1]+inp[2]-inp[3]==7) cout<<inp[0]<<"-"<<inp[1]<<"+"<<inp[2]<<"-"<<inp[3]<<"=7";
    else if (inp[0]-inp[1]-inp[2]-inp[3]==7) cout<<inp[0]<<"-"<<inp[1]<<"-"<<inp[2]<<"-"<<inp[3]<<"=7";
    cout<<endl;
}
int main()
{
    while(cin>>str)
        solve();
}

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

int main() {
    vector<int>v, seen;
    
    ll ans = 0;
    ll l;
    int h,w;
    cin >> h >> w;
    string s;
    v.resize(h*w, 0);
    seen.resize(h*w, 0);
    rep(i, h) {
        cin >> s;
        rep(j, w) {
            if (s[j] == '#') {
                v[w*i + j] = -1;
            }
        }
    }
    rep(x, w) {
        rep(y, h) {
            if(v[w*y + x] == -1) continue;
            queue<int>q;
            seen.clear();
            seen.resize(w*h, 0);
            q.push(w*y + x);
            q.push(-1);
            seen[w*y + x] = 1;
            l = 0;
            while (!q.empty()) {
                //cout << q.size() << endl;
                int now = q.front();
                q.pop();
                if(now == -1) {
                    //cout << q.size() << '&';
                    l++;
                    q.push(-1);
                    now = q.front();
                    q.pop();
                    if (now == -1) {
                        l--;
                        break;
                    }
                }
                if (now%w != 0) {
                    if (v[now - 1] == 0 && seen[now - 1] == 0) {
                        q.push(now - 1);
                        seen[now - 1] = 1;
                    }
                }
                if (now%w != w-1) {
                    if (v[now + 1] == 0 && seen[now + 1] == 0) {
                        q.push(now + 1);
                        seen[now + 1] = 1;
                    }
                }
                if (now - w >= 0) {
                    if (v[now-w] == 0 && seen[now-w] == 0) {
                        q.push(now-w);
                        seen[now-w] = 1;
                    }
                }
                if (now + w < w*h) {
                    if (v[now+w] == 0 && seen[now+w] == 0) {
                        q.push(now+w);
                        seen[now+w] = 1;
                    }
                }
            }
            //cout << x << ',' << y << ':' << l << endl;
            ans = max(ans, l);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <stdio.h>
#include <cstring>
#include <math.h>
using namespace std;
int n,kt[int(1e5)+11],l,r,b[int(1e5)+11],c[int(1e5)+11];

void sang()
{
    fill(kt+1,kt+100007,true);
    kt[1] = false;
    for (int i = 2; i <= sqrt(int(1e5)+7) ; i++)
       if (kt[i] == true)
       for (int j = 2; j <= int ((int(1e5)+7) / i); j++)
        {
            kt[i*j] = false;
        }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    sang();
    int tam = 0;
    for (int i = 2; i <= int(1e5)+7; i++)
    {
        if (kt[i] == true && (i+1) % 2 == 0 && kt[(i+1) / 2] == true) tam++;
        c[i] = tam;
    }

    for (int i = 1; i <= n; i++)
    {
      cin >> l >> r;
      b[i] = c[r] - c[l-1];
    }
    for (int i = 1 ; i <= n; i++)
        cout << b[i] << "\n";
}


Measured memory_bytes: 1792
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

ll N;
ll D;
vl X;
vl Y;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    cin >> D;
    X = vl(N);
    Y = vl(N);
    for(int i = 0; i < N; ++i){
        cin >> X[i];
        cin >> Y[i];
    }
    solve();
}

// 1 <= N <= 2× 10^5
// 0 <= D <= 2× 10^5
// |X_i|,|Y_i| <= 2× 10^5
// 入力は全て整数

// ll N, ll D, vl X, vl Y
// 原点からの距離が D 以下であるような点の個数を整数で出力せよ。
void solve(){
    ll ans=0;
    rep(i,N){
        if(X[i]*X[i]+Y[i]*Y[i]<=D*D)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6348
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{
	string s;
	cin >> s;
	vector<int> v(26, 0);
	rep(i, sz(s)) v[s[i] - 'a']++;
	int ok = 1;
	for(int x : v) ok &= (x % 2 == 0);
	cout << (ok ? "Yes" : "No");
}


 // a b c a b c a b c a b c
 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  //	cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 9;
int n, dp[maxn][2], parent[maxn], vis[maxn];
//0 black / 1 white
vi tree[maxn], g[maxn];

int solve(int i, int color){
    if (dp[i][color] != -1) return dp[i][color];
    if (!sz(g[i]))  {        
        return dp[i][color] =  1;
    }
    int res = 1;
    if (color){
        trav(a, g[i]){
            res = ((ll)res * (ll)((solve(a, color) % mod + solve(a, !color) % mod ) % mod)) % mod;
        }
        return dp[i][color] = res;
    }
    trav(a, g[i]){
        res = ((ll)res * (ll)solve(a, !color)) % mod;
    }
    return dp[i][color] = res;
}

void dfs(int u){
    vis[u] = 1;
    trav(a, tree[u]){
        if (!vis[a]){
            g[u].push_back(a);
            dfs(a);
        }
    }
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    cin >> n;
    memset(dp, -1, sizeof dp);
    memset(vis, 0, sizeof vis);
    rep(i, 0, n- 1){
        int u, v;
        cin >> u >> v;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    dfs(1);
    /*rep(i, 1, 4){
        trav(a, g[i])
            cout << a<< ' ';
        cout << '\n';
    }*/
    cout << (solve(1, 0) + solve(1, 1) ) % mod << '\n';
    return 0;
}


Measured memory_bytes: 19712
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	string N;

	cin >> N;

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

}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

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")
}

fn main() {
    let s:Vec<char>=read::<String>().chars().collect();
    let f=|v: &[char]|{
        for i in 0..v.len()/2{
            if v[i] != v[v.len()-i-1] {
                return false;
            }
        }
        true
    };

    println!("{}",if f(&s[..]) && f(&s[..(s.len()-1)/2]) && f(&s[(s.len()+3)/2-1..]) {"Yes"} else{"No"});
}

Measured memory_bytes: 2144
# B - Time Limit Exceeded

N, T = map(int, input().split())
INF = 10**18
min_cost = INF
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
        min_cost = min(min_cost, c)

if min_cost == INF:
    print('TLE')
else:
    print(min_cost)

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

int main(){
    int P, Q, R;
    cin >> P >> Q >> R;

    int count = 0;

    count += min({P, Q ,R});

    if(P == count) {
        if(Q < R) {
            count += Q;
        } else {
            count += R;
        }
    } else if(Q == count) {
        if(P < R) {
            count += P;
        } else {
            count += R;
        }
    } else if(R == count) {
        if(P < Q) {
            count += P;
        } else {
            count += Q;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    int n;
    cin >> n;
    int ans = 0;
    rep(i, 1, n + 1)
    {
        int j = n/i;
        ans += j*(j+1)*i/2;
    }
    cout << ans;
    return 0;
}

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

#define INF 1e9
#define LLINF 1e18
#define pi 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    int x;
    cin >> x;
    int a = x % 100;
    int b = x / 100;
    int hund = 0;
    while(a >= 5) {
        a -= 5;
        hund++;
    }
    while(a >= 4) {
        a -= 4;
        hund++;
    }
    while(a >= 3) {
        a -= 3;
        hund++;
    }
    while(a >= 2) {
        a -= 1;
        hund++;
    }
    while(a >= 1) {
        a -= 1;
        hund++;
    }
    if (hund > b) {
        cout << 0 << endl;
    }
    else cout << 1 << endl;
}

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

#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int;  // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    pair<ll, ll> a = make_pair(i, 0);
    while ((n % i) == 0) {
      n /= i;
      a.second += 1;
    }
    p.push_back(a);
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) {
    u += MOD;
  }
  return u;
}
// 順列
ll permutation(const ll n, const ll m) {
  ll result = 1;
  for (ll i = n; i > n - m; i--) {
    result = (result * i) % MOD;
  }
  return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
  if (x == 0) return 1;
  ll res = repeat_square(n, x / 2);
  res = res * res % MOD;
  if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
  ll p = permutation(n, m);
  ll div = 1;
  for (ll i = 2; i <= m; i++) {
    div = (div * i) % MOD;
  }
  return (p * modinv(div)) % MOD;
}

// アルファベットの取得
string get_alphabet(ll n) {
  n--;
  return string(1, 'a' + (n % 26));
}

int main() {
  ll ans = 0;
  int N;
  cin >> N;
  vector<int> a(N);
  
  rep(i, N) cin >> a[i];
  
  int prev = a[0];
  rep(i, 1, N) {
    if (prev < a[i]) {
      prev = a[i];
      continue;
    }
    
    ans += (prev - a[i]);

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


Measured memory_bytes: 3964
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;

class City {
public:
	int ken;
	int year;
	int num;
	City(int _ken, int _year) :
		ken(_ken),
		year(_year) {

	}
};



int main() {

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

	vector<shared_ptr<City>> input;
	vector<shared_ptr<City>> s;
	int p, y;
	for (int i = 0; i < m; i++) {
		cin >> p >> y;
		input.emplace_back(make_shared<City>(p, y));
		s.emplace_back(input[i]);
	}


	std::sort(s.begin(), s.end(), [](shared_ptr<City>& a, shared_ptr<City>& b) {
		if (a->ken < b->ken) {
			return true;
		}
		else if(a->ken > b->ken){
			return false;
		}
		else {
			return a->year < b->year;
		}
		});



	int pre_k = s[0]->ken;
	int num = 1;
	for (auto && i : s) {
		if (pre_k != i->ken) {
			pre_k = i->ken;
			num = 1;
		}
		i->num = num;
		num++;
	}

	for (auto && i : input) {
		cout << std::setfill('0') << std::setw(6) << i->ken << std::setfill('0') << std::setw(6) << i->num << endl;
	}

	return 0;

}

Measured memory_bytes: 9312
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	bool besucht[n];
	int bel[n];
	for( int i = 0; i < n; ++i ){
		int temp;
		cin >> temp;
		bel[i] = temp-1;
		besucht[i] = false;
	}
	besucht[0] = true;
	int memo = 0;
	int temps = 0;
	while(true){
		memo = bel[memo];
		++temps;
		if( besucht[memo] ){
			cout << -1 << endl;
			return 0;
		} else if( memo == 1 ){
			cout << temps << endl;
			return 0;
		} else {
			besucht[memo] = true;
		}
	}
	return 0;
}

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

#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define matrix(x) vector<vector<x>>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 1000000007
#define MOD(a,b) (a%b + b)%b

using namespace std;

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

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


int main()
{
    //fastio
    string s;
    cin>>s;
    ll ans=0;
    ll sz = s.size();
    for(ll i=0;i<sz;i++)
    {
        ans+=s[i]-'0';
    }
    if(ans%9==0) printf("Yes\n");
    else printf("No\n");

    return 0;
}

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

long long n,a,b;

long long A(){
	return a+(b-a-1)/2;
}

long long B(){
	return (n-(a+n-b+1))/2+n-b+1;
}

int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	if((b-a)%2==0) printf("%lld\n",(b-a)/2);
	else printf("%lld\n",min(A(),B()));
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
field = [input() for _ in range(h)]

dp = [[float('inf') for _ in range(w)] for _ in range(h)]
if field[0][0] == '#':
    dp[0][0] = 1
else:
    dp[0][0] = 0

for i in range(h):
    for j in range(w):
        for di, dj in ((1, 0), (0, 1)):
            next_i = i + di
            next_j = j + dj
            if next_i >= h or next_j >= w:
                continue
            if field[i][j] == '.' and field[next_i][next_j] == '#':
                dp[next_i][next_j] = min(dp[next_i][next_j], dp[i][j] + 1)
            else:
                dp[next_i][next_j] = min(dp[next_i][next_j], dp[i][j])

print(dp[h - 1][w - 1])


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

long long M  = 1e9+7;
int n,m,q; 
vector < pair < pii, pii > > v;
vector <int> arr;
int ans;
void fx(int curr, vector <int> a){
    if(a.size() > n)
        return ;
   // cout << curr << endl;
    
    if(a.size() == n){
        // for(auto x : a)
        //     cout << x << " * ";
        // cout << endl;
        int res = 0;
        reverse(all(a));
        a.pb(-1);
        reverse(all(a));
        for(int i=0 ; i<q ; i++){
            if(v[i].f.s<=a.size() && v[i].f.f<=a.size() && a[v[i].f.s] - a[v[i].f.f] == v[i].s.f)
                res += v[i].s.s; 
        }
       //cout << res << "**" << endl;
        ans = max(ans, res);
        return ;
    }
    for(int i=curr ; i<=m ; i++){
        vector <int> t = a;
        t.pb(i);
        fx(i,t);
    }
}
signed main(){
    fast;
    cin >> n >> m >> q;
    for(int i=0 ; i<q ; i++){
        int x,y,z,w; cin >> x >> y >> z >> w;
        v.pb({{x,y} , {z,w}});
    }
    ans = 0;
    vector <int> t;
    fx(1,t);
    cout << ans << endl;
}


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

int main(){
  int64_t N, M;
  cin >> N >> M;
  int ans = 0;
  for(int64_t i=M/N; i>=1; i--){
    if(i*N <= M && M %i == 0){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;



int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
ll r, d, x;
cin >> r >> d >> x;
for(int i =0; i<10; i++){
	ll next= (r*x)-d;
	cout << next << endl;
	x=next;
}
return 0;
}



Measured memory_bytes: 256