akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    ll n;
    cin>>n;
    vector<ll> v;
    ll sum = 0;
    rep(i, n) {
        ll x;
        cin>>x;
        v.emplace_back(x);
        sum+=x;
    }
    ll tmp = 0;
    ll mm = sum;
    
    for(auto it:v){
        tmp +=it;
        mm = min(mm, abs(tmp - (sum - tmp)));
    }
        pr(mm);
}


Measured memory_bytes: 2420
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [ for i in 1..n -> stream.ReadLine() |> f ]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let N = util.Scan1 int64

let rec countR cs =
  if (cs <> List.empty) && (List.fold (fun a -> fun c -> a + string c) "" cs |> int64) > N 
  then 0
  else 
    let me = if (List.contains '3' cs) && (List.contains '5' cs) && (List.contains '7' cs)
             then 1
             else 0
    me + (countR ('3'::cs)) + (countR ('5'::cs)) + (countR ('7'::cs))

countR List.empty
|> printfn "%d"

util.Close()


Measured memory_bytes: 18904
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll,ll> pll;


vector< pll > v;
ll n;
ll h[5005], p[5005];
ll dp[5005][5005];
const ll inf = 1e16;
int main()
{
        cin >> n;
        v.pb(make_pair(-2LL , -2LL));
        for(ll i=1;i<=n;i++) {
                cin >> h[i] >> p[i];
                v.pb(make_pair(h[i]+p[i], i));
        }
        sort(v.begin(), v.end());
        for(ll i=1;i<=n;i++) dp[0][i] = inf;
        dp[0][0] = 0;
        for(ll i=1;i<=n;i++) {
                ll id = v[i].second;
                for(ll j = 0; j <= n; j++) {
                        dp[i][j] = dp[i-1][j];
                        if(j && dp[i-1][j-1] <= h[id]) dp[i][j] = min(dp[i][j], p[id] + dp[i-1][j-1]);
                }
        }
        for(ll i=n;i>=0;i--){
                if(dp[n][i] != inf) {
                        cout << i << endl; return 0;
                }
        }
        return 0;
}


Measured memory_bytes: 196096
#include <iostream>
#include <climits>
using namespace std;

int main() {
  int n, m;
  while (true) {
    cin >> n >> m;
    if (n==0 && m==0) {
      break;
    }
    int a[n];
    for (int i=0; i<n; i++) {
      cin >> a[i];
    }
    int ans = -INT_MAX;
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
	if (i!=j && a[i]+a[j]<=m) {
	  ans = max(ans,a[i]+a[j]);
	}
      }
    }
    if (ans<0) {
      cout << "NONE" << endl;
    } else {
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3088
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ZYCSwing
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            out.println(n / 3);
        }

    }
}



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

int main(){

  int N;
  cin >> N;
  vector<int> cards(N);
  for(int i = 0; i < N; i++) cin >> cards.at(i);

  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());

  int suma = 0, sumb = 0;
  for(int i = 0; i < N; i++){
    if(i % 2 == 0) suma += cards.at(i);
    else sumb += cards.at(i);
  }

  cout << suma - sumb << endl;

}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String A = sc.next();
    String B = sc.next();
    String C = sc.next();
    
    Map<Character, Integer> map = new HashMap<>();
    int count = 0;
    for(int i = 0; i < N; i++){
      if(A.charAt(i) == B.charAt(i) && B.charAt(i) == C.charAt(i)){
        
      }else if(A.charAt(i) == B.charAt(i) || B.charAt(i) == C.charAt(i) || C.charAt(i) == A.charAt(i)){
        count++;
      }else{
        count += 2;
      }
    }
    
    System.out.println(count);
  }
}

Measured memory_bytes: 23892
import math
N = int(input())
A = list(map(int,input().split()))

four = 0
two = 0

for i in range(len(A)):
  if A[i]%4 == 0:
    four += 1
  if A[i]%2 == 0:
    two += 1
n = math.floor(N/2)
two -= four
x = (n - four) * 2

# print(four, two, n, x)
if four >= n:
  print("Yes")
elif two >= x:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 84692
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007LL
#define all(x) x.begin() , x.end()
#define ld long double
void solve();
int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int t = 1; //cin >> t;
	while (t--)
		solve();
	return 0;
}
void solve()
{
	ll d, t, s; cin >> d >> t >> s;
	if (ceil(d * 1.0 / s) <= t) cout << "Yes";
	else cout << "No";

	cout << "\n";
	return ;
}

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

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

#define INF LONG_MAX
#define mod 1000000007
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

ll modpow(ll x,ll n){
  if(n==0)return 1;
  if(n%2)return ((x%mod)*(modpow(x,n-1)%mod))%mod;
  else {
    ll half=modpow(x,n/2)%mod;
    return (half*half)%mod;
  }
}

struct Modcomb{
  std::vector<long long int>fac;  //$B3,>h(B
  std::vector<long long int>finv; //$B3,>h$N5U85(B
  std::vector<long long int>inv;  //$B5U85(B

  //nCr=n!/r!(n-r)!
  Modcomb(int max){
    fac.resize(max+1,0);
    finv.resize(max+1,0);
    inv.resize(max+1,0);
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<=max;i++){
      fac[i]=(fac[i-1]*i%mod)%mod;
      inv[i]=mod-inv[mod%i]*(mod/i)%mod;
      finv[i]=finv[i-1]*inv[i]%mod;
    }
  }

  long long int slove(int n,int r){
    if(n<r)return 0;
    if(n<0||r<0)return 0;
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod;
  }
};

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

  int n,a,b;
  cin>>n>>a>>b;
  ll ans=modpow(2,n);
  ans--;
  Modcomb comb(200000);
  ll Aup=1;
  for(int i=0;i<a;i++){
    Aup=(Aup*(n-i))%MOD;
    Aup%=MOD;
  }
  ll Adown=1;
  for(int i=1;i<=a;i++){
    Adown=(Adown*i)%MOD;
    Adown%=MOD;
  }
  ll A=(Aup*modpow(Adown,MOD-2));
  ll Bup=1;
  for(int i=0;i<b;i++){
    Bup=(Bup*(n-i))%MOD;
    Bup%=MOD;
  }
  ll Bdown=1;
  for(int i=1;i<=b;i++){
    Bdown=(Bdown*i)%MOD;
    Bdown%=MOD;
  }
  ll B=(Bup*modpow(Bdown,MOD-2));
  ans-=A;
  ans%=MOD;
  if(ans<0)ans+=MOD;
  ans%=MOD;
  ans-=B;
  ans%=MOD;
  if(ans<0)ans+=MOD;
  ans%=MOD;
  cout<<ans%MOD<<endl;
  return 0;
}


Measured memory_bytes: 4992
def main():
    from itertools import combinations

    N = int(input())
    F = []
    for _ in range(N):
        t = 0
        for j, b in enumerate(map(int, input().split())):
            if b:
                t |= (1 << j)
        F.append(t)
    # F[i]:=店舗iの営業時間情報
    P = [list(map(int, input().split())) for _ in range(N)]
    # P[i]:=店舗iと営業時間が重なる個数に対する利益

    ans = -10 ** 9 - 1
    for open_ in range(1, 10 + 1):
        for comb in combinations(range(10), r=open_):
            t = 0
            for j in comb:
                t |= (1 << j)

            p = 0
            for i, f in enumerate(F):
                x = bin(t & f).count('1')
                p += P[i][x]

            ans = max(ans, p)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n, m = map(int, input().split())
p = list(map(int, input().split()))
g = [[] for _ in range(n+1)]
for _ in range(m):
    x, y = map(int, input().split())
    g[x].append(y)
    g[y].append(x)
s = [0]*(n+1)
r = 0
for i, j in enumerate(p, 1):
    q = [i]
    for k in q:
        if s[k]:
            continue
        s[k] = i
        q.extend(g[k])
    r += s[j] == s[i]
print(r)

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

long long int d[3*1000000 + 2];

int main() {

    int n;

    cin >> n;

    for(int i=0;i<n;i++){
       cin >> d[i];
    }

    bool flag = false;

    int npos = 0;

    while(!flag){

        long long int mj = 0;
        int maxpos=0;

        for(int i=npos;i<=npos+d[npos]/10;i++){
            if(i == n-1){
                flag = true;
                break;
            }
            if(i==npos) continue;
            if(mj/10 + maxpos <= i + d[i]/10){
                mj = d[i];
                maxpos = i;
            }
        }
        if(mj<10){
            break;
        }
        npos = maxpos;

    }

    if (!flag) {
        cout << "no" << endl;
        return 0;
    }

    reverse(d,d+n);


    flag = false;

    npos = 0;

    while(!flag){

        long long int mj = 0;
        int maxpos=0;

        for(int i=npos;i<=npos+d[npos]/10;i++){
            if(i == n-1){
                flag = true;
                break;
            }
            if(i==npos) continue;
            if(mj/10 + maxpos <= i + d[i]/10){
                mj = d[i];
                maxpos = i;
            }
            //mj = max(mj,d[i]);
        }
        if(mj<10){
            break;
        }
        npos = maxpos;

    }

    if (!flag) {
        cout << "no" << endl;
    }
    else{
        cout << "yes" << endl;
    }


    return 0;
}

Measured memory_bytes: 5432
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;

#define N 3
#define N2 9

struct puzzle{
    int F[N2];
    int space;
    string path;
    
    bool operator < (const puzzle &p) const{
        for(int i=0; i<N2;i++){
            if(F[i]==p.F[i])continue;
            return F[i] > p.F[i];
        }
        return false;
    }
};

static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const char dir[4]={'u','l','d','r'};

bool Target(puzzle p){
    for(int i=0; i<N2; i++)
    if(p.F[i]!=(i+1)) return false;
    return true;
}

string bfs(puzzle s){
    queue<puzzle> Q;
    map<puzzle,bool> V;
puzzle u,v;
s.path="";
Q.push(s);
V[s]=true;

while(!Q.empty()){
    u=Q.front(); Q.pop();
    if(Target(u))return u.path;
    int sx = u.space / N;
    int sy = u.space % N;
    
    for(int r=0; r<4; r++){
        int tx=sx+dx[r];
        int ty=sy+dy[r];
        if(tx<0 || ty<0 || tx>=N || ty>=N) continue;
        v=u;
        swap(v.F[u.space],v.F[tx*N+ty]);
        v.space=tx*N+ty;
        if(!V[v]){
            V[v]=true;
            v.path +=dir[r];
            Q.push(v);
        }
    }
}

return "unsolvable";
}

int main(){
    puzzle in;
    for(int i=0;i<N2;i++){
        cin >> in.F[i];
        if(in.F[i]==0){
            in.F[i]=N2;
                in.space=i;
            }
        }
        string ans = bfs(in);
        cout << ans.size() << endl;
        
        return 0;
    }


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k;
string s;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s >> n;
	m = s.length();
	for(ll i=0;i<m;i+=n) cout<<s[i];
}

int main() {
	fastio; randomINT;
	//cin>>T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 238004
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
int main(){
    int n;
    cin>>n;
    vpii red(n),blue(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        red[i]=mp(a,b);
    }
    rep(i,n){
        int c,d;
        cin>>c>>d;
        blue[i]=mp(d,c);
    }
    sort(all(red));
    reverse(all(red));
    sort(all(blue));
    rep(i,n){
        int c,d;
        tie(d,c)=blue[i];
        blue[i]=mp(c,d);
    }
    vbo tmp(n,true);
    int ans=0;
    rep(i,n){
        rep(j,n){
            if(red[i].first<blue[j].first&&red[i].second<blue[j].second&&tmp[j]){
                ans++;
                tmp[j]=false;
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def solve():
    N = int(input())

    # 約数のペア(a,b)で、a+bが最小となるものが答え
    ans = float("inf")
    for i in range(1, N):
        if i > N**(1/2):
            break

        if N%i == 0:
            ans = min(ans, (i-1)+(N//i-1))
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#define REP(i, n) for(int i=0;i<n;++i)
#define INF 100000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

ll int n;
int ans;
bool b;

int main(){
    cin >> n;
    b = true;

    while(n / 10 != 0){
        ans += 9;
        if(n % 10 != 9) b = false;
        n /= 10;
    }

    if(b){
        cout << ans + n << endl;
    } else {
        cout << ans + n - 1 << endl;
    }

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
  ll n,i;
  cin >> n;
  ll a[n+1],b[n+1],c[n+1];
  for(i=0;i<n;i++) cin >> a[i] >> b[i] >> c[i];
  ll dp[n+1][3];
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for(i=1;i<n;i++)
  {
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
  }
  ll ans = max(dp[n-1][0], dp[n-1][1]);
  ll ans2 = max(ans, dp[n-1][2]);
  cout << ans2 << endl;
  return 0;
}

Measured memory_bytes: 8228
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

X, Y = read_ints()

# x...つるの数
# y...亀の数
for x in range(X + 1):
    y = X - x
    if Y == y * 4 + 2 * x:
        print('Yes')
        exit()
print("No")


Measured memory_bytes: 65300
#include<bits/stdc++.h>
using namespace std;
#define ll long long
auto speedup = [](){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
	#endif
	return 0;
}();


int main(){
	int n;
	cin>>n;
	int heights[n];
	for(int i=0; i<n; ++i)
		cin>>heights[i];
	int max_till_now = heights[0];
	ll res = 0;
	for(int i=1; i<n; ++i){
		if(heights[i] < max_till_now){
			res += max_till_now - heights[i];
		}
		else
			max_till_now = heights[i];
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 4332
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] h = new long[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextLong();
        }
        long max = 0;
        for (int i = 0; i < n; i++) {
            if (h[i] >= max) {
                max = h[i];
                continue;
            }
            if (max - h[i] > 1) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }

}


Measured memory_bytes: 50252
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>

using namespace std;

int gcd(int a, int b) {
	while (a % b != 0 && b % a != 0) {
		if (a > b) {
			a %= b;
		} else {
			b %= a;
		}
	}
	return min(a, b);
}

int mygcd(int a, int b, int c) {
	return gcd(gcd(a, b), c);
}

int main(int argc, char *argv[]) {
	long long int res = 0;
	int k;
	cin >> k;
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			for (int kk = 1; kk <= k; kk++) {
				res += mygcd(i, j, kk);
			}
		}
	}
	cout << res << endl;
}


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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int has[1000005];
int sieve[1000005];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	rep(i, 0, n) {
		int a; read(a);
		has[a]++;
	}

	for (int i = 1; i <= 1000000; i++) if (has[i]) {
		for (int j = 2 * i; j <= 1000000; j += i) sieve[j] = 1;
	}

	int ans = 0;
	for (int i = 1; i <= 1000000; i++) if (has[i] == 1 && !sieve[i]) ans++;
	write(ans);
}


Measured memory_bytes: 11452
h=int(input())
w=int(input())
n=int(input())
if h>=w:
    if n%h==0:
        print(n//h)
    else:
        print(n//h+1)
else:
    if n%w==0:
        print(n//w)
    else:
        print(n//w+1)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int

using namespace std;
void code()
{
        int n;
        int s;
        int c;
        int z;
        cin>>n>>s>>c>>z;
        int nd=z-n,sd=nd-s;
        if(sd>0)
                cout<<n-sd<<endl;
        else
        {
                cout<<min(z,n)<<endl;
        }
}
signed main()

{
        FAST_IO;
        int t = 1;

        // cin>>t;

        while(t--)
        {
                code();
        }

        return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
	    int a, b, c, d, e, f;
	    double x, y;
	    Scanner s = new Scanner(System.in);
	    while (s.hasNext()) {
	    	a = s.nextInt();
	    	b = s.nextInt();
		    c = s.nextInt();
		    d = s.nextInt();
	    	e = s.nextInt();
	    	f = s.nextInt();
	    	x = (c * e - b * f) * 10000 / (a * e - d * b);
        	y = (c * d - a * f) * 10000 / (b * d - a * e);
	        System.out.printf("%.3f %.3f\n", x / 10000, y / 10000);
	    }
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return (key%(M-1)+1); }

int find(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0){
      return 1;
    }
    else if(strlen(H[h])==0){
      return 0;
    }
  }
    return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0){
      return 1;
    }
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
    return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 15388
import java.util.*;

public class Main {
    public static void main(String[] args)
    {
        Scanner scanner = new Scanner(System.in);
        String N = scanner.next();
        if(N.substring(0,1).equals("7"))
            System.out.println("Yes");
        else if(N.substring(1,2).equals("7"))
            System.out.println("Yes");
        else if(N.substring(2,3).equals("7"))
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

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

int main ()
{
    fastio
    lli num ;
    cin >> num ;
    cout << "ABC" << num ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 384
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    V vec(n);
    rep(i, n) cin >> vec[i];
    VV dp(n + 1, V(k + 1));
    rep(i,n+1)dp[i][0]=1;
   // cout<<dp[2][0]<<endl;
    rep(i,n){
        V vec2(k + 1);
        vec2[0] = dp[i][0];
        rep3(j, 1, k+1)vec2[j] = dp[i][j]+vec2[j-1];
        rep3(j,1,k+1){
            if(j-vec[i]<=0){
                dp[i+1][j]=vec2[j];
                dp[i+1][j]%=mod;
            }else{
                dp[i + 1][j]=vec2[j] - vec2[j - vec[i]-1];
                dp[i+1][j]%=mod;
            }
            
        }
    }
    cout << dp[n][k] << endl;
}


Measured memory_bytes: 80256
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
 
struct _node_table {
    int* next_node;
    int* cost;
    int size;
    int capacity;
} node_table[100005];
 
long long int dp[100005];
 
void init_node(int i) {
    node_table[i].capacity = 10;
    node_table[i].next_node = (int*)malloc(node_table[i].capacity*sizeof(int));
    node_table[i].cost = (int*)malloc(node_table[i].capacity*sizeof(int));
    node_table[i].size = 0;
}
 
void free_node(int i) {
    free(node_table[i].next_node);
    free(node_table[i].cost);
}
 
void grow_node(int s) {
    if(node_table[s].capacity < node_table[s].size * 1.25) {
        int size, i;
        int* next_node = node_table[s].next_node;
        int* cost = node_table[s].cost;
        node_table[s].capacity *= 1.5;
        node_table[s].next_node = (int*)malloc(node_table[s].capacity*sizeof(int));
        node_table[s].cost = (int*)malloc(node_table[s].capacity*sizeof(int));
        for(i=0,size=node_table[s].size;i<size;i++) {
            node_table[s].next_node[i] = next_node[i];
            node_table[s].cost[i] = cost[i];
        }
        free(next_node);
        free(cost);
    }
}
 
void add_next_node(int s, int t, int d) {
    int size = node_table[s].size;
    node_table[s].next_node[size] = t;
    node_table[s].cost[size] = d;
    node_table[s].size++;
 
    grow_node(s);
}
 
#define QUEUE_MAX 1000000
void solve(int r, int V) {
    int i, size, from, to, cost;
    int queue[QUEUE_MAX];
    long long int wp, rp;
 
    for(i=0;i<V;i++) dp[i] = INT_MAX;
    dp[r] = 0;
 
    wp = rp = 0;
    queue[wp++%QUEUE_MAX] = r;
 
    while(wp>rp) {
        from = queue[rp++%QUEUE_MAX];
 
        for(i=0,size=node_table[from].size;i<size;i++) {
            to = node_table[from].next_node[i];
            cost = node_table[from].cost[i];
 
            if(cost+dp[from] < dp[to]) {
                queue[wp++%QUEUE_MAX] = to;
                dp[to] = cost+dp[from];
            }
        }
    }
}
 
int main(void) {
    int i, V, E, r;
    scanf("%d %d %d\n", &V, &E, &r);
    for(i=0;i<V;i++) init_node(i);
 
    for(i=0;i<E;i++) {
        int s, t, d;
        scanf("%d %d %d\n", &s, &t, &d);
        add_next_node(s, t, d);
    }
 
    solve(r, V);
 
    for(i=0;i<V;i++) {
        free_node(i);
        if(dp[i] == INT_MAX) {
            printf("INF\n");
        } else {
            printf("%d\n", dp[i]);
        }
    }
 
    return 0;
}


Measured memory_bytes: 15724
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ct = vec![vec![0; 10]; 10];
    for i in 1..n + 1 {
        let t = i % 10;
        let mut h = i;
        while h >= 10 {
            h /= 10;
        }
        ct[h][t] += 1;
    }

    let mut ans: u64 = 0;
    for i in 0..10 {
        for j in 0..10 {
            ans += ct[i][j] * ct[j][i]
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
	int A,B,C,D,P,y,x,w;
	w=0;
	scanf("%d %d %d %d %d",&A,&B,&C,&D,&P);
	x=P*A;
	if(P<=C){
		y=B;
	}
	else{
		w=P-C;
		y=w*D+B;
	}
	
	if(x<y){
		printf("%d\n",x);
	}
	else{
		printf("%d\n",y);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
string s;
int n;
ll  res=0;
void dfs(int len,ll sum,ll tmp)
{
  if(len==n+1){res+=sum;return;}
  int sl=s[len]-'0';
  dfs(len+1,sum+tmp*9+sl,tmp*10+sl);
  dfs(len+1,sum+sl,sl);
}
int main()
{
  cin>>s;
  n=s.length()-1;
  int a=s[0]-'0';
  dfs(1,a,a);
  cout<<res;
}


Measured memory_bytes: 256
N = int(input())
a = 0
if (N > 0):
  L = list(map(int, input().split()))
  if N > 2:
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                if L[i] == L[j] or L[i] == L[k] or L[j] == L[k]:
                    continue
                if L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and L[j] + L[k] > L[i]:
                    a = a + 1
print(a)

Measured memory_bytes: 9212
import sys
import bisect
nq = int(input())
lines = sys.stdin.readlines()
ans = [None] * nq
arr = []
for i in range(nq):
    q, *arg = lines[i].split()
    x = int(arg[0])
    idx = bisect.bisect_left(arr,x)
    if q == '0':    # insert x
        if idx == len(arr) or arr[idx] != x:
            arr.insert(idx, x)
        ans[i] = str(len(arr))
    elif q == '1':   # find x
        ans[i] = '1' if idx < len(arr) and arr[idx] == x else '0'
    elif q == '2':           # delete x
        if idx < len(arr) and arr[idx] == x:
            del arr[idx]
    else:                   # dump L R
        l_idx = bisect.bisect_left(arr, x)
        r_idx = bisect.bisect_right(arr, int(arg[1]))
        ans[i] = '\n'.join(map(str, arr[l_idx:r_idx]))
    #print(q, *arg, '\t', arr)

[print(x) for x in ans if x]


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

using namespace std;

#define ll long long
#define  ON_THE_WAY_TO_SPECIALIST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007

int main()
{
	int t[15], x;
	
	cin >> x;
	
	for(int i = 0; i < x; i++)
	{
		cin >> t[i];
	}
	
	sort(t, t + x);
	
	
	//for(int i  =1; i <= x; i++) cout << t[i] << " ";
	
	int sum = 0;
	
	for(int i = 0; i < x-1; i++)
	{
		sum+=t[i];
	}
	
	//cout << sum << " " << t[x] << endl;
	
	if(sum > t[x-1]) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}


Measured memory_bytes: 384
#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 ll long long int

using namespace std;

int main()
{
  int r, d, x;
  cin >> r >> d >> x;
  REP(i, 10)
  {
    x = r * x - d;
    cout << x << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; 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 FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll d(n);
    REP(i, n) cin >> d[i];
    ll res = 0;
    REP(i, n){
        REP(j, n){
            if(j <= i) continue;
            res += d[i] * d[j];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int NMAX=1e5;
int n;
ll compteur[5];
string nom;
char debut[5]={'M','A','R','C','H'};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	
	for(int i=0;i<n;i++){
		cin >> nom;
		
		for(int j=0;j<5;j++){
			if(nom[0]==debut[j]) compteur[j]++;
		}
		
	}
	ll ans=0;
	
	for(int i=0;i<5;i++){
		for(int j=i+1;j<5;j++){
			for(int k=j+1;k<5;k++){
				ans+=compteur[i]*compteur[j]*compteur[k];
			}
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
 
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
int main(){
    int n;
    cin >> n;
    int a;
    int m = 0;
    for(int i = 0 ; i < n; i ++ ){
        cin >> a;
        m ^= a;
    }
    if(m == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;
ll power(ll x,ll y) 
{ 
    ll res = 1;    
    x = x % mod;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % mod; 
        y = y>>1;
        x = (x*x) % mod;   
    } 
    return res; 
} 	
signed main()
{
    fast;
    
    ll n,i,k,j,ans=0;
    cin>>n>>k;
    vi(ll) dp(k+2,0);
    for(i=k;i>=1;i--)
    {
    	dp[i] = power(k/i,n);
    	for(j=2*i;j<=k;j += i)
    	{
    		dp[i] = (dp[i] - dp[j]%mod + mod)%mod;
    	}
    	ans = (ans + (i%mod * dp[i]%mod)%mod)%mod;
    }
    cout<<ans;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

template<unsigned MOD>
class ModInt {
public:
  unsigned x;
  ModInt(): x(0) { }
  ModInt(signed sig) { if((x = sig % MOD + MOD) >= MOD) x -= MOD; }
  unsigned get() const { return x; }

  ll binpow(ll y, ll e) {
    ll a = 1, p = y;
    while(e > 0) {
      if(e%2 == 0) {p = (p*p) % MOD; e /= 2;}
      else {a = (a*p) % MOD; e--;}
    }
    return a % MOD;
  }

  ModInt &operator+=(ModInt that) {
    if((x += that.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt &operator-=(ModInt that) {
    if((x -= that.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt &operator*=(ModInt that) {
    x = (unsigned long long)x * that.x % MOD;
    return *this;
  }
  ModInt &operator/=(ModInt that) {
    x = (unsigned long long)x * (binpow(that.x, MOD-2)) % MOD;
    return *this;
  }

  ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
  ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
  ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
  ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
};
typedef ModInt<1000000007> mint;

int a[105];
mint dp[105][260][105], fact[105];
signed main(void)
{
  int n, x;
  cin >> n >> x;
  REP(i, n) cin >> a[i];

  dp[0][0][0] = 1;
  REP(i, n) REP(j, 260) REP(k, n+1) {
    if(dp[i][j][k].get() > 0) {
      dp[i+1][j^a[i]][k+1] += dp[i][j][k];
      dp[i+1][j][k] += dp[i][j][k];
    }
  }

  // REP(i, 126) {
  //   cout << "xor:" << i << " ";
  //   REP(j, n+1) {
  //     cout << dp[n][i][j].get() << " ";
  //   }
  //   cout << endl;
  // }

  fact[0] = 1;
  FOR(i, 1, n+1) fact[i] = fact[i-1]*i;

  mint ret = 0;
  REP(i, n+1) {
    ret += dp[n][x][i]*fact[i];
  }
  cout << ret.get() << endl;

  return 0;
}


Measured memory_bytes: 11520
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var st = new Stack<string>();
        var s = Console.ReadLine().Trim();
        var t = "";
        for (int i = 0; i < s.Length; i++)
            if (s[i] != 'B') t += s[i];
            else if (t.Length >= 1)
            {
                var w = t.Substring(0, t.Length - 1);
                t = w;
            }
        Console.WriteLine(t);
    }
}

Measured memory_bytes: 11220
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> a;
  set<int> s;
  int q,c,x,l,r;

  cin >> q;
  set<int>::iterator it;
  set<int>::iterator lit,rit;  
  for(ii=0;ii<q;ii++){
    cin >> c >> x;
    if(c == 0){
      s.insert(x);
      cout << s.size() << endl;
    }
    else if(c == 1){
      it = s.find(x);
      if(it != s.end()){
        cout << 1 << endl;
      }
      else{
        cout << 0 << endl;
      }
    }
    else if(c == 2){
      s.erase(x);
    }
    else{
      l = x;
      cin >> r;
      lit = s.lower_bound(l);
      rit = s.lower_bound(r);

      while(lit != rit){
        cout << *lit << endl;
        lit++;
      }
      if(*lit <= r && lit!=s.end()){
        cout << *lit << endl;
      }
    }
  }
  
  return 0;
}



Measured memory_bytes: 12460
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int f(char* s){
  return (s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+s[3]-'0';
}
int main(){
  int i;
  for(;;){
    char s[5];
    cin>>s;
    if(s[0]=='0'&&s[1]=='0'&&s[2]=='0'&&s[3]=='0')break;
    if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]){
      cout<<"NA"<<endl;
      continue;
    }
    for(i=0;f(s)!=6174;++i){
      char t[5],u[5];
      memcpy(t,s,sizeof(s));
      sort(t,t+4);
      memcpy(u,s,sizeof(s));
      sort(u,u+4,greater<char>());

      int p=f(u)-f(t);
      s[0]=p/1000+'0';
      s[1]=p/100%10+'0';
      s[2]=p/10%10+'0';
      s[3]=p%10+'0';
    }
    cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>

using namespace std;

int main ()
{
    int a,b,c,x,y;
    cin >> a >> b >> c ;
    x=b-a ;
    y=c-b ;

    if((y)==(x))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

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

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M, K = map(int, readline().split())
MOD = 998244353
numden = [(1, 1)]

# Combination under a prime modulo: nCk % mod
def combmod(n, k, mod=MOD):
    if k > n:
        return 0
    if k > n - k:
        k = n - k
    # Reuse precalculated numerators and denominators.
    if k < len(numden):
        num, den = numden[k]
    else:
        # Resume from len(numden).
        num, den = numden[-1]
        for i in range(len(numden) - 1, k):
            num = num * (n - i) % mod
            den = den * (i + 1) % mod
            numden.append((num, den))
    # By Fermat's little theorem,
    # a^(p-1) ≡ 1 mod p
    # i.e. a^(p-2) ≡ a^(-1) mod p
    inv_dev = pow(den, mod - 2, mod)
    return num * inv_dev % mod


def solve():
    ans = 0
    for i in range(K + 1):
        cs = combmod(N - 1, i)
        ans += cs * M % MOD * pow(M - 1, N - 1 - i, MOD) % MOD
        ans %= MOD
    return ans


if __name__ == "__main__":
    print(solve())


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

int main() {
  ll n,m,l,q,s,t,buf1,buf2,buf3,ans,INF;
  cin >> n >> m >> l;
  INF=10000000000;
  vector<vector<ll>>ab(n,vector<ll>(n,INF));
  rep(i,m) {
  	cin >> buf1 >> buf2 >> buf3;
  	ab.at(buf1-1).at(buf2-1)=buf3;
  	ab.at(buf2-1).at(buf1-1)=buf3;
  }
  rep(i,n) ab.at(i).at(i)=0;
  rep(k,n) rep(i,n) rep(j,n) ab.at(i).at(j)=min(ab.at(i).at(j),ab.at(i).at(k)+ab.at(k).at(j));
  rep(i,n) rep(j,n){
    if(ab.at(i).at(j)<=l) ab.at(i).at(j)=1;
    else ab.at(i).at(j)=INF;
  }
  rep(k,n) rep(i,n) rep(j,n) 
    ab.at(i).at(j)=min(ab.at(i).at(j),ab.at(i).at(k)+ab.at(k).at(j));  					
  cin >> q;
  rep(i,q) {
  	cin >> s >> t;
    if(ab.at(s-1).at(t-1)==INF) ans=-1;
    else ans=ab.at(s-1).at(t-1)-1;
  	cout << ans << endl;
  }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
char s[200][200];
int h_flag[200];
int w_flag[200];
int main(){
	int h,w;
	//cin>>h>>w;
	scanf("%d%d",&h,&w);
	//cout<<h<<" "<<w<<endl;
	for(int i=0;i<h;i++){
		
		for(int j=0;j<=w;j++){
			scanf("%c",&s[i][j]);
			
			if(s[i][j]=='.'){
				h_flag[i]++;
				w_flag[j]++;
			}
		}
	}
	/*for(int i=0;i<=h;i++){
		for(int j=0;j<=w;j++){
			printf("%c",s[i][j]);
		}
		printf("\n");
	}
	for(int i=0;i<h;i++)cout<<h_flag[i]<<" ";
	cout<<endl;*/
	for(int i=0;i<h;i++){
		if(h_flag[i]==w)continue;
		for(int j=0;j<=w;j++){
			if(w_flag[j]==h)continue;
			printf("%c",s[i][j]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 256