akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.*;


public class Main {
    
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        Set<String> prize = new HashSet<String>();
        int times = scanner.nextInt();

        for(int i = 0; i < times; i++) {
            String str = scanner.next();
            prize.add(str);
        }

    System.out.println(prize.size());
    }
}

Measured memory_bytes: 76544
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vvi edge(n);
	rep(i,m){
		int p,q; cin>>p>>q;
		edge[p-1].push_back(q-1);
	}
	ll s,t; cin>>s>>t; s--,t--;
	vvl v(n,vl(3,-1));
	vl ans(n,-1);
	queue<tlll> q;
	q.emplace(s,0,0);
	while(!q.empty()){
		ll cur,mo,dis;
		tie(cur,mo,dis) =q.front();
		q.pop();
		if(v[cur][mo]!=-1)continue;
		v[cur][mo]=dis;
		for(auto&e:edge[cur]){
			if(v[e][(mo+1)%3]==-1){
				q.emplace(e, (mo+1)%3, mo==2?dis+1:dis);
			}
		}
	}
	puta(v[t][0]);
	return 0;
}

Measured memory_bytes: 12032
n = int(input())
a=[]
for _ in [0]*n:
  a += [int(input())]
s = sum(a)
if s%10>0:
  print(s)
  exit()
a.sort()
f = False
for x in a:
  if x%10>0:
    print(s-x)
    exit()
print(0)

Measured memory_bytes: 3060
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    println!("{}",48-a)
}

Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
int mod = 998244353;
long double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998626034825342117;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    long long N, A, B; cin >> N >> A >> B;
    if ((B - A) % 2 == 0)cout << (B - A) / 2 << endl;
    else {
        cout << min((A + B - 1) / 2, (N * 2 - A - B + 1) / 2) << endl;
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

const int MAX = 2000010;//設定して

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    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;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;//＊１
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

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

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  COMinit();
  ll r1,r2,c1,c2;cin>>r1>>c1>>r2>>c2;
  ll ans=COM(r2+c2+2,r2+1);
  ans+=mod-COM(r2+c1+1,r2+1);
  ans%=mod;
  ans+=mod-COM(r1+c2+1,r1);
  ans%=mod;
  ans+=COM(r1+c1,r1);
  ans%=mod;

  cout<<ans<<ENDL;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 47104
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

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

    int N = S.size();
    vector<int> ch;
    ch.push_back(0);
    for(int i=1; i<N; i++){
        if(S[i] != S[i-1]) ch.push_back(i);
    }

    int ans = 1e+9;
    for(int& c: ch){
        int m = max(c, N-c); ans = min(m, ans);
    }

    cout << ans << endl;
}

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

using namespace std;

const int N = 5e3 + 5;

int n;
pair <int, int> a[N];
long long dp[N][N];

bool cmp (pair <int, int> p1, pair <int, int> p2) {
    return p1.first + p1.second < p2.first + p2.second;
}

int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d %d", &a[i].first, &a[i].second);
    sort(a + 1, a + n + 1, cmp);

    memset(dp, 0x3f, sizeof(dp));
    dp[0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (dp[i][j] < 1e18) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
                if (a[i + 1].first >= dp[i][j]) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + a[i + 1].second);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i <= n; i++) if (dp[n][i] < 1e18) ans = max(ans, i);
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 195968
// C - Average Length

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

double calc_length(double x1, double y1, double x2, double y2) {
    return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}

int main()
{
    int N;
    double x[8], y[8];
    vector<int> route;
    double num_route = 0;
    double total_length = 0;

    cin >> N;

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

    for (int i=0; i<N; i++) {
        route.push_back(i);
    }

    do {
        double length = 0;
        for (int i=0; i<N-1; i++) {
            length += calc_length(x[route[i]], y[route[i]], x[route[i+1]], y[route[i+1]]);
        }

        total_length += length;
        num_route++;
    } while (next_permutation(route.begin(), route.end()));

    double ans = total_length / num_route;

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int h,w;
	while(1){
		scanf("%d %d", &h, &w);
		if(h == 0 && w == 0)	break;
		int i, j;
		for ( i = 0; i < h; i++ ){
			for ( j = 0; j < w; j++ ){
				(!i || i ==h-1 || !j || j==w-1)?printf("#"):printf(".");
			}
			printf("\n");
		}
			printf("\n");
	}
	return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int l = 0, r = 0, cnt = 0;

  for (int i = 0; i < S.length(); i++) {
    if (S[i] == '(') {
      if (S[i - 1] == ')') {
        if (cnt < 0) {
          l -= cnt;
          cnt = 0;
        }
      }
      cnt++;
    } else {
      cnt--;
    }
  }
  if (cnt < 0) l -= cnt;
  for (int i = 0; i < l; i++) {
    cout << '(';
  }
  for (int i = 0; i < S.length(); i++) {
    cout << S[i];
  }
  for (int i = 0; i < cnt; i++) {
    cout << ')';
  }
  cout << endl;
  return 0;
}

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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(),(x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
#define INF (1e9)

typedef pair<int,int> P;
typedef vector<int> vi;

int N,A,B;

signed main() {
    cin>>N>>A>>B;

    if(A*N>=B) {
        cout<<B;
    }else{
        cout<<A*N;
    }

    cout<<endl;
    return 0;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    set<ll> prime;
    
    auto res = prime_factorize(n);
    for(int i = 0; i < res.size(); i++){
        if(prime.find(res[i].first) != prime.end() ||  is_prime(res[i].first)){
            prime.insert(res[i].first);
            ll j = 1;
            ll cnt = res[i].second;
            while(cnt>=j){
                ans += 1;
                cnt -= j;
                j++;
            }
        }
    }

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

Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))
two, four = 0, 0
for a in A:
    if a % 4 == 0:
        four += 1
    elif a % 2 == 0:
        two += 1
if two == 0:
    can = four * 2 + 1
else:
    can = four * 2 + two

if can >= N:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

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

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<pair<ll,ll>> A,B,C,D;
    map<pair<ll,ll>,int> MA;
    for(int i=0;i<N;i++){
        ll a,b;cin>>a>>b;
        if(a==0&&b==0) A.push_back({a,b});
        else if(a==0){
            b=1;
            B.push_back({a,b});
        }else if(b==0){
            a=1;
            C.push_back({a,b});
        }else{
            if(a<0){
                a*=-1;
                b*=-1;
            }
            ll g=abs(gcd(a,b));
            
            a/=g;
            b/=g;
            
            D.push_back({a,b});
            MA[{a,b}]++;
        }
    }
    
    ll ans=0;
    
    ans+=si(A);
    
    ll sum=1;
    
    for(auto it=MA.begin();it!=MA.end();it++){
        ll a=(*it).fi.fi,b=(*it).fi.se,c=(*it).se;
        if(c==0) continue;
        
        sum*=(rui(2,c+MA[{-a,-b}])+rui(2,MA[{b,-a}]+MA[{-b,a}])-1)%mod;
        sum%=mod;
        MA[{a,b}]=0;
        MA[{-a,-b}]=0;
        MA[{b,-a}]=0;
        MA[{-b,a}]=0;
        
        //cout<<a<<" "<<b<<" "<<sum<<endl;
    }
    
    //cout<<sum<<endl;
    
    ans+=sum*(rui(2,si(B))+rui(2,si(C))-1)%mod;
    ans%=mod;
    
    ans+=mod-1;
    ans%=mod;
    
    cout<<ans<<endl;
    
}



Measured memory_bytes: 56356
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();

            if (m == -1 && f == -1 && r == -1) {
                break;
            } else if (m == -1 || f == -1) {
                System.out.printf("F\n");
                continue;
            }

            if (m + f >= 80) {
                System.out.printf("A\n");
            } else if (m + f >= 65 && m + f < 80) {
                System.out.printf("B\n");
            } else if (m + f >= 50 && m + f < 65) {
                System.out.printf("C\n");
            } else if (m + f >= 30 && m + f < 50) {
                if (r >= 50) {
                    System.out.printf("C\n");
                } else {
                    System.out.printf("D\n");
                }
            } else {
                System.out.printf("F\n");
            }
        }
    }
}



Measured memory_bytes: 26452
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 1000 + 5;
char grid[MAX][MAX];
int dis[MAX][MAX];
int n, m;

bool inside(int x, int y) {
    return x >= 1 && x <= n && y >= 1 && y <= m;
}

int bfs() {
    memset(dis, 0x3F, sizeof dis); 
    queue<ii> q;
    fori(i, 1, n + 1) {
        fori(j, 1, m + 1) {
            if(grid[i][j] == '#') {
                dis[i][j] = 0;
                q.emplace(i, j);
            }
        }
    }
    int max_dis = 0;
    while(!q.empty()) {
        int x, y;
        tie(x, y) = q.front(); q.pop();
        max_dis = max(max_dis, dis[x][y]);
        fori(i, -1, 2) {
            fori(j, -1, 2) {
                if((!i and !j) or (i and j)) {
                    continue;
                }
                int nx = x + i;
                int ny = y + j;
                if(inside(nx, ny) && dis[nx][ny] > dis[x][y] + 1) {
                    dis[nx][ny] = dis[x][y] + 1;
                    q.emplace(nx, ny);
                }
            }
        }
    }
    return max_dis;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    fori(i, 1, n + 1) fori(j, 1, m + 1) cin >> grid[i][j];
    int ans = bfs();
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 13328
#include<stdio.h>
#include<algorithm>
#include<set>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n,q,ss,tt,xx,et,dd,now;
set<int> s;
struct nod{
	int t,x;
	bool operator <(const nod &a)const{
		if (t==a.t) return x<a.x;
		return t<a.t;
	}
}e[510000];
int main(){
	scanf("%d%d",&n,&q);
	fo(i,1,n){
		scanf("%d%d%d",&ss,&tt,&xx);
		e[++et].t=ss-xx;
		e[et].x=xx;
		e[++et].t=tt-xx;
		e[et].x=-xx;
	}
	sort(e+1,e+et+1);
	now=1;
	while (q--){
		scanf("%d",&dd);
		while (now<=et&&e[now].t<=dd){
			if (e[now].x<0){
				s.erase(-e[now].x);
			}else{
				s.insert(e[now].x);
			}
			now++;
		}
		if (s.empty()) printf("-1\n");else printf("%d\n",*(s.begin()));
	}
	return 0;
}

Measured memory_bytes: 13696
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <set>
#include <list>
#include <map>
#include <queue>
#include <iterator>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <utility>
#include <functional>
#include <stack>
#include <deque>
#include <sstream>
using namespace std;

#define ll long long
#define mod 1000000007
#define ld long double
#define infinity (ll)1e18+1
#define PI 3.14159265358979

#define pdd pair<double,double>
#define pll pair<ll, ll>
#define pii pair<int,int>

#define MP make_pair
#define SZ size()
#define PB push_back

#define vi vector<int>//ll
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define vch vector<char>
#define vb vector<bool>
#define vld vector<ld>
#define vs vector<string>

#define FOR(i,a,b) for(ll i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(ll i = (b) - 1; i >= (a); --i)
#define REPEAT(i) FOR(counter1234,0,i)
#define ALL(a) a.begin(), a.end()
#define X first
#define Y second
#define MAXN 10001
/*
ll power(ll n, ll to)
{
	if (to == 0) return 1;
	if (to == 1) return n;
	int exp = 1;
	ll ans = n;
	while (2 * exp <= to)
	{
		ans *= ans;
		ans %= mod;
		exp *= 2;
	}
	return ((ans*power(n, to - exp)) % mod);
}

ll gcd(ll a, ll b)
{
	if (a < b)
		swap(a, b);

	if (b == 0)
		return a;

	if (a < b)
		swap(a, b);

	return gcd(b, a%b);
}

pll add(int a, int b)
{
	if (a > b)
		swap(a, b);

	ll mult = 1;
	FOR(i, a, b + 1)
	{
		mult *= i;
		mult %= mod;
	}

	ll num = 0;
	FOR(i, a, b + 1)
	{
		num += (mult * power(i, mod - 2));
		num %= mod;
	}

	return MP(num, mult);
}

ll n;
vll a, b;

int main()
{
	srand(time(NULL));
	clock_t startTime = clock();
	ios_base::sync_with_stdio(false), cin.tie(0);
	//ifstream in("In.txt");

	cin >> n;
	a.assign(n, 0);
	b.assign(n - 1, 0);
	FOR(i, 0, n)
		cin >> a[i];

	FOR(i, 0, n - 1)
		cin >> b[i];

	sort(ALL(a));

	if (n == 2)
	{
		ll p, q;

		p = b[0];
		q = a[1] - a[0];

		auto sum = add(a[0] + 1, a[1]);
		
		p *= sum.first;
		q *= sum.second;
		p %= mod;
		q %= mod;

		ll res = p % mod;
		res *= power(q, mod - 2);
		cout << res%mod;
	}
	else
	{
		if (n == 3)
		{
			pll c1, c2, c3;
			c2.X = a[1] * b[1] - b[0];
			c2.Y = (a[2] - a[1])*(a[1] - a[0]);

			c1.X = a[0] * b[1] - b[0];
			c1.Y = (a[2] - a[0])*(a[0] - a[1]);

			c1.X %= mod;
			c1.Y %= mod;
			c2.Y %= mod;
			c2.X %= mod;

			c3.Y = c1.Y * c2.Y;
			c3.X = mod * mod - (c1.Y * c2.X + c1.X * c2.Y);

			c3.X %= mod;
			c3.Y %= mod;




		}
	}
	

	
	return 0;
}*/

int main()
{
	srand(time(NULL));
	clock_t startTime = clock();
	ios_base::sync_with_stdio(false), cin.tie(0);
	//ifstream in("In.txt");

	int r, g, b;
	cin >> r >> g >> b;

	int x = 10 * g + b;
	if (x % 4 == 0)
		cout << "YES";
	else
		cout << "NO";



	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int totalSecond;
	int hr, min, scnd;

	scanf("%d", &totalSecond);

	hr = (totalSecond/(60*60));
	scnd = totalSecond-(hr*60*60);
	min = scnd/60;
	scnd = scnd - (min*60);

	printf("%d:%d:%d\n", hr, min, scnd);

	return 0;
}


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

int n,m;
vector<vector<int>>g;
vector<int>seen;

int dfs(int v,int depth){
    if(seen[v]==1)return 0;
    else if(depth==n)return 1;
    seen[v]=1;
    int ans=0;
    for(auto x:g[v]){
        if(seen[x]==1)continue;
        else ans+=dfs(x,depth+1);
    }
    seen[v]=0;
    return ans;
}

int main(){
    cin>>n>>m;
    g.resize(n);
    seen.resize(n,0);
    for(int i=0;i<m;++i){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cout<<dfs(0,1)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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

struct UnionFind {
  vector<int> parent;

  UnionFind(int N) : parent(N) {
    for(int i = 0; i < N; i++) parent[i] = i;
  }

  /**
    要素xの根を求める
    */
  int root(int x) {
    if(parent[x] == x) return x;
    return parent[x] = root(parent[x]);  // 経路圧縮しつつ根を返す
  }

  /**
    要素xと要素yの木を併合
    */
  void unite(int x, int y) {
    int x_root = root(x);
    int y_root = root(y);
    if(x_root == y_root) return;
    parent[x_root] = y_root;
  }

  /**
    要素xと要素yが同じ木に属しているか
    */
  bool same(int x, int y) {
    int x_root = root(x);
    int y_root = root(y);
    return x_root == y_root;
  }
};

int n, m;
bool is_consolidated(UnionFind uf) {
  rep(i, n) {
    rep(j, n) {
      if(i == j) continue;
      if(!uf.same(i, j)) return false;
    }
  }
  return true;
}

int main() {
  cin >> n >> m;
  vector< pair<int, int> > edges;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    edges.pb(mp(a-1, b-1));
  }

  int ans = 0;
  rep(i, m) {
    UnionFind uf = UnionFind(n);
    rep(j, m) {
      if(i == j) continue;
      uf.unite(edges[j].first, edges[j].second);
    }
    if(!is_consolidated(uf)) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
a = set([int(input()) for i in range(M)])
dp = [0]*(N+1)
dp[0] = 1
dp[1] = 1
if 1 in a:
    dp[1] = 0
for i in range(2,N+1):
    if i in a:
        continue
    
    dp[i] = (dp[i-2]+dp[i-1])%1000000007
ans = dp[N]
print(ans)



Measured memory_bytes: 13192
from collections import Counter, defaultdict

class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7
comb = Combination(N + 100)

cntA = Counter(A)
I = [a for a, c in cntA.items() if c == 2][0]
L, R = [i for i, a in enumerate(A) if a == I]
S = L + (N - R)

for i in range(1, N + 2):
    if i == 1:
        print(N)
        continue

    ans = comb.ncr(N + 1, i) - comb.ncr(S, i - 1)
    print(ans % MOD)


Measured memory_bytes: 30560
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
ll mod=1e9+7;
ll qpow(ll a,ll b){ll res=1;while(b){if(b&1) res=res*a%mod;a=a*a%mod;b/=2;}return res%mod;}
int main(){
    ll n;cin>>n;
    cout<<((qpow(10,n)-qpow(9,n)-qpow(9,n)+qpow(8,n))%mod+mod)%mod<<endl;
} 

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

int main(){
  ll n;cin>>n;
  deque<ll> b;
  rep(i,n){
    ll a;
    cin>>a;
    if(i%2==0) b.push_front(a);
    else b.push_back(a);
  }
  if(n%2==0) reverse(b.begin(),b.end());
  rep(i,b.size()){
    cout << b[i] << " ";
  }
  cout<<endl;
}

Measured memory_bytes: 3840
#include <stdio.h>

int Combination(int left, int right){
    int x = 1;
    int y = 1;
    int ans;

    for(int i = 0; i < right; i++){
        x *= left - i;
        y *= i + 1;
    }

    ans = x/y;
    return ans;
}

int main(){
    int M, N;
    int ans = 0;
    scanf("%d%d", &N, &M);

    if(M >= 2 )ans += Combination(M, 2);
    if(N >= 2)ans += Combination(N, 2);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
ss = 0
se = N-1
print(ss,'\n')
sf = input()
if sf == 'Vacant':
    exit(0)
while True:
    if se - ss == 1:
        q = se
    else:   
        q=(ss+se)//2
    print(q,'\n')
    s = input()
    if s == 'Vacant':
        exit(0)
    elif (s == sf and (q-ss+1)%2==1 ) or (not s == sf and (q-ss+1)%2==0):
        ss = q
        sf = s
    else:
        se = q


Measured memory_bytes: 3660
n,s,_,*t=open(0).read().split()
n=int(n)
d=[0]*n+[1<<ord(c)-97for c in s]
for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
for q,a,b in zip(*[iter(t)]*3):
  i,s=int(a)+n-1,0
  if'2'>q:
    d[i]=1<<ord(b)-97
    while i>1:
      i//=2
      d[i]=d[i+i]|d[i-~i]
    continue
  j=int(b)+n
  while i<j:
    if i&1:
      s|=d[i]
      i+=1
    if j&1:
      j-=1
      s|=d[j]
    i//=2
    j//=2
  print(bin(s).count('1'))

Measured memory_bytes: 46876
#include <iostream>
#include <sstream>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <stdexcept>
#include <algorithm>
#include <set>
#include <map>
#include <stdlib.h>
using namespace std;
int main(){
    long int A,B,C,p,i;
    p = 0;
    cin >> A >> B >> C;
    for(i = A;i <= A * B + 2;i += A){
        if(i % B == C){
            cout << "YES" << endl;
            p = 1;
            break;
        }
    }
    if(p != 1){
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3492
import string
import collections
n=int(input())
A=list(string.ascii_lowercase)
d={}
for _ in range(n):
    s=input()
    c=collections.Counter(s)
    for i in A:
        if i in c.keys():
            if i not in d:
                d[i]=c[i]
            else:
                d[i]=min(d[i],c[i])
        else:
            d[i]=0
ans=[]
for i in d:
    ans+=i*d[i]
ans.sort()
print(*ans,sep='')

Measured memory_bytes: 3768
#include<stdio.h>
int main(){
  int n,i;
  int fib[50];
  scanf("%d",&n);
  fib[0]=fib[1]=1;
  for(i=2;i<=n;i++) fib[i]=fib[i-1]+fib[i-2];
  printf("%d\n",fib[n]);
  return 0;
}


Measured memory_bytes: 2112
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

#------------------------------------------#

BIG_NUM = 2000000000
HUGE_NUM = 9999999999999999
MOD = 1000000007
EPS = 0.000000001

#------------------------------------------#

class Edge:
    def __init__(self,arg_to,arg_cost):
        self.to = arg_to
        self.cost = arg_cost

class Info:
    def __init__(self,arg_node_id,arg_sum_cost):
        self.node_id = arg_node_id
        self.sum_cost = arg_sum_cost

    def __lt__(self,arg):
        return self.sum_cost < arg.sum_cost


V = int(input())
min_dist = [BIG_NUM]*V
G = [[] for i in range(V)]

for loop in range(V):
    node_id,tmp_num,*table = list(map(int,input().split()))
    for i in range(0,len(table),2):
        G[node_id].append(Edge(table[i],table[i+1]))


min_dist[0] = 0
Q = []

heappush(Q, Info(0,0))

while len(Q) > 0:
    info = heappop(Q)
    if info.sum_cost > min_dist[info.node_id]:
        continue
    for edge in G[info.node_id]:
        if min_dist[edge.to] > info.sum_cost+edge.cost:
            min_dist[edge.to] = info.sum_cost+edge.cost
            heappush(Q, Info(edge.to,min_dist[edge.to]))


for i in range(V):
    print("%d %d"%(i,min_dist[i]))






Measured memory_bytes: 121208
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,n,m,n1,m1,max,car=0,hantei=0;
	cin>>n;
	cin>>m;
	max=m;
	car=m;
	for(i=1;i<=n;i++){
		cin>>n1>>m1;
		car=car+n1-m1;
		if(car<0){
			hantei=1;
		}
		if(car>max){
			max=car;
		}
	}
	if(hantei==0)
		cout<<max<<endl;
	if(hantei==1)
		cout<<0<<endl;
		
	return 0;
}


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


int main(int argc, char** argv){
  int N, M;
  cin >> N >> M;
  int X[M];
  int dX[M-1];
  for(int cnt0=0; cnt0<M; cnt0++) cin >> X[cnt0];
  sort(X, X+M);
  for(int cnt0=0; cnt0<M-1; cnt0++) dX[cnt0] = X[cnt0+1]-X[cnt0];
  sort(dX, dX+M-1);
  int sum = 0;
  for(int cnt0 = 0; cnt0 < M - N; cnt0++) sum += dX[cnt0];

  printf("%d", sum);
  return 0;
}

Measured memory_bytes: 1024
// ref: https://img.atcoder.jp/arc089/editorial.pdf

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int64 slove(const vector<vector<int64>>& vvXY_cSum, const int K, const int x, const int y){
    int xB = max(x, 0);
    int yB = max(y, 0);
    
    int xE = x+K;
    int yE = y+K;
    xE = max(xE, 0); xE = min(xE, 2*K);
    yE = max(yE, 0); yE = min(yE, 2*K);
    
    return vvXY_cSum[xE][yE] - vvXY_cSum[xE][yB] - vvXY_cSum[xB][yE] + vvXY_cSum[xB][yB];
}

int64 max(const int64& lhs, const int64& rhs){ return (lhs > rhs ? lhs : rhs); }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, K; cin >> N >> K;
    
    int K2=K*2;
    vector<vector<int64>> vvXY(K2, vector<int64>(K2, 0ll));
    for(int i=0; i<N; ++i){
        int x, y; char c; cin >> x >> y >> c;
        if(c == 'W'){ y += K; }
        x %= K2;
        y %= K2;
        ++vvXY[x][y];
    }
    
    vector<vector<int64>> vvXY_cSum(K2+1, vector<int64>(K2+1, 0ll));
    for(int xk=0; xk<K2; ++xk){
        for(int yk=0; yk<K2; ++yk){
            vvXY_cSum[xk+1][yk+1] = vvXY[xk][yk] + vvXY_cSum[xk+1][yk] + vvXY_cSum[xk][yk+1] - vvXY_cSum[xk][yk];
        }
    }
    
    int64 sum_max=0ll;
    for(int x=0; x<K; ++x){
        for(int y=0; y<K; ++y){
            int64 tmp = 0ll;
            tmp += slove(vvXY_cSum, K, x-K, y-K);
            tmp += slove(vvXY_cSum, K, x+K, y-K);
            tmp += slove(vvXY_cSum, K, x-K, y+K);
            tmp += slove(vvXY_cSum, K, x  , y  );
            tmp += slove(vvXY_cSum, K, x+K, y+K);
            sum_max = max(sum_max,     tmp);
            sum_max = max(sum_max, N - tmp);
        }
    }
    
    cout << sum_max << endl;
    
    return 0;
}

Measured memory_bytes: 62976
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    
    vector<int> A(N);
    for(int i=0;i<N;++i)cin>>A[i];
    
    auto a=*min_element(A.cbegin(),A.cend());
    auto b=*max_element(A.cbegin(),A.cend());
    cout<<abs(a-b)<<endl;
}


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

int main() {
    string S;
    cin >> S;
    int cnt = 0;
    int index = 0;

    for (int i = 2; i <= S.size() -2 ; i++) {
        if (S[0] == 'A'){
            if(S[i] == 'C') {
                cnt++;
               index = i;
                
            }
        }
    }
    if (cnt == 1) {
        for(int i = 1; i < S.size(); i++){
            if (S[i] == 'C' ) {
                 
            } else {
                if(isupper(S[i])) {
                    cout << "WA" << endl;
                    return 0;
                }
            }
        }
        cout << "AC" << endl;
        return 0;
    }
    cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a,b;
  cin>>N>>a;
  b=a;
  for(int i=0;i<N-1;i++){
    int A;
    cin>>A;
    if(a<A){
      a=A;
    }
    if(b>A){
      b=A;
    }
  }
  cout<<a-b<<endl;
}

Measured memory_bytes: 256
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;

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


    ll ans=0;
    ll anss =0;
    ll count=0;
    ll i,j,h;
    ll Q,N,K;
    
    long double a, b;
    long double x;

    vector<ll> aa;
    string S;

    ll flag=0;
    ll temp=0;

    cin  >> N>>K;
    for(i=K;i<N+2;i++){
    anss=(N+(N-i+1))*i/2-(i-1)*i/2 +1;
    ans+=anss;
    ans=ans%(1000000000+7);
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define reps(i,j,k) for(int i=j;i<k;++i)
int main(){
	string str;
	while(true) {
		cin >> str;
		if(str == "#"){
			break;
		}
		
		reverse(str.begin(),str.end());

		vector < int > arr;
		int idx = 0;
		while(idx <  str.size()) {
			if(str[idx] == 'h'){
				idx += 5;
				arr.push_back(0);
			}
			else{
				idx += 4;
				arr.push_back(1);
			}
		}
		int a = arr[0]==0? 0 : 90;
		a *= 1<<20;
		int prev = arr[0];
		int t = 1<<20;
		reps(i,1,arr.size()){
			if(arr[i] == 0) {
				a -= 90 * (t>>i);
			}
			else{
				a += 90 * (t>>i); 			
			}
		}
		int s = __gcd(t,a);
		if(t == s){
			cout << a/s << endl;
		}
		else cout << a/s << "/" << t/s << endl;
	}	
	return 0;
}

Measured memory_bytes: 2952
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scan = new Scanner (System.in);
		int sum = 0;
		int capacity;
		boolean flg = true;
		final int baggage = scan.nextInt();
		final int truck = scan.nextInt();
		final int[] weight= new int[baggage];
		
		
		for (int i = 0; i < baggage; i++) {
			weight[i] = scan.nextInt();
			sum += weight[i];
		}
		scan.close();
		capacity = sum / truck;
		
		while (flg) {
			int starttruck = 0;
			for ( int car = 0; car < truck; car++) {
				int sumweight = 0;
				for (int bag = starttruck; bag < baggage; bag++) {
					sumweight += weight[bag];
					if ( sumweight > capacity) {
						starttruck = bag;
						break;
					} else if (car == truck - 1 && bag == baggage - 1) {
						flg = false;
					}
				}
			}
			if ( flg == true) capacity++;
		}
		
		System.out.println(capacity);
		
	}
}



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


int main()
{
  int n;
  cin >> n;
  vector<queue<int>> a(n);
  rep(i, n)
    rep(j, n - 1)
    {
      int ipt;
      cin >> ipt;
      ipt--;
      a[i].push(ipt);
    }
  set<pair<int, int>> s;
  rep(i, n - 1)
  {
    int op = a[i].front();
    if (i == a[op].front() && i < op)
      s.emplace(i, op);
  }
  int ans = 0;
  while (!s.empty())
  {
    ans++;
    set<pair<int, int>> s2;
    while (!s.empty())
    {
      auto p = *s.begin();
      s.erase(s.begin());
      a[p.first].pop();
      a[p.second].pop();
      if (!a[p.first].empty())
      {
        int op = a[p.first].front();
        if (!a[op].empty() && p.first == a[op].front())
          s2.emplace(p.first, op);
      }
      if (!a[p.second].empty())
      {
        int op = a[p.second].front();
        if (!a[op].empty() && p.second == a[op].front())
          s2.emplace(p.second, op);
      }
    }
    s.swap(s2);
  }
  rep(i, n)
    if (!a[i].empty())
    {
      puts("-1");
      return 0;
    }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4736
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    ll N;
    cin >> N;
    ll a=1;
    ll b=1;
    ll c=1;
    rep(i,N){
        a*=10;
        b*=9;
        c*=8;
        a %= MOD;
        b %= MOD;
        c %= MOD;
    }
    ll ans = a-2*b+c;
    while(ans < 0){
        ans += MOD;
    }
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 3620
use proconio::marker::Usize1;
use petgraph::unionfind::UnionFind;
use superslice::Ext;
fn main() {
    proconio::input! {
        n: usize,
        k: usize,
        l: usize,
        pq: [(Usize1,Usize1);k],
        rs: [(Usize1,Usize1);l],
    }
    let mut ufk=UnionFind::new(n);
    for (p,q) in pq {
        ufk.union(p, q);
    }
    let mut ufl=UnionFind::new(n);
    for (r,s) in rs {
        ufl.union(r, s);
    }
    let mut v=Vec::with_capacity(n);
    for i in 0..n {
        v.push((ufk.find_mut(i),ufl.find_mut(i)));
    }
    v.sort_unstable();
    let mut a=Vec::with_capacity(n);
    for i in 0..n {
        a.push(v.equal_range(&(ufk.find(i),ufl.find(i))).len());
    }
    println!("{}",itertools::join(a, " "));
}

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    int N;
    lint A[200000],B[200000];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
        B[i]=A[i];
    }
    sort(A,A+N);
    for(int i=0;i<N;i++){
        if(B[i]<A[N/2]) cout << A[N/2] << endl;
        else cout << A[N/2-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h> 
#define ll long long
#define pb push_back
using namespace std;
ll a[500005],M=1000000007;
ll power(ll x,ll y)
{
	ll res=1;
	while(y)
	{
		if(y%2==1) res=(res*x)%M;
		x=(x*x)%M;
		y/=2;	
	}
	return res;
}
ll C(ll n,ll k)  
{  
    ll res=1;    
    if(k>n-k) k=n-k;  
    for(ll i = 0;i<k;i++)  
    {  
        res=(res*(n-i))%M;  
        res=(res*power(i+1,M-2))%M;  
    }  
    return res;  
}  
int main() 
{ 
	ll x,y;
	cin>>x>>y;
	if((x+y)%3==0)
	{
		if(x>=(x+y)/3&&x<=2*((x+y)/3)) cout<<C((x+y)/3,2*((x+y)/3)-x);
		else cout<<"0";
	}
	else cout<<"0";
	return 0; 
} 

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

int main() {
    int n; cin >> n;
    map<string, int> m;
    
    for (int i = 0; i < n; ++i) {
        string S; cin >> S;
        sort(S.begin(), S.end());
        ++m[S];
    }
    long long ans = 0;
    for (auto it = m.begin(); it != m.end(); ++it) {
        long long x = (*it).second;
        ans += (x * (x - 1))/2;
    }
    cout << ans;
}

Measured memory_bytes: 11136
n = int(input())
h = list(map(int,input().split()))

inf = n * (10**4)
c = [inf] * n

c[0] = 0
c[1] = abs(h[1]-h[0]) + c[0]

for i in range(2,n):
    c[i] = min(abs(h[i]-h[i-2]) + c[i-2],abs(h[i]-h[i-1]) + c[i-1])

print(c[n-1])


Measured memory_bytes: 13924
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
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;}
 
const ll INF=1e9+7;

int main(){
    string s,t;
    cin >> s >>t;
    ll n=s.length();
    ll m=t.length();
    vector<vector<ll>> dp(n+1,vector<ll>(m+1));
    rep(i,n){
        rep(j,m){
            if(s[i]==t[j]){
                dp[i+1][j+1]=dp[i][j]+1;
            }
            else{
                dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }
    string ans="";
    while(n!=0 && m!=0){
        if(dp[n][m]==dp[n-1][m]){
            n--;
        }
        else if(dp[n][m]==dp[n][m-1]){
            m--;
        }
        else{
            ans+=s[n-1];
            n--;
            m--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 70784
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;


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

    int ans = 0;
    int now = 0;
    rep(i,N){
        if (S[i] == 'I') now++;
        else now--;
        ans = max(ans, now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
 
#define rep(i,x) for(int i=0;i<x;i++)
 
int main(){
	while(1){
		string s,t;
		cin>>s>>t; if(s=="0"&&t=="0")break;
		int r[5],a[5];
		rep(i,4){
			r[i]=s[i]-48;
			a[i]=t[i]-48;
		}
		int c=0,d=0;
		rep(i,4){
			if(r[i]==a[i])c++;
			else {
				rep(j,4)if(r[i]==a[j])d++;
			}
		}
 
		printf("%d %d\n",c,d);
	}
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL fun(LL n, LL m)
{
    if((m/2)<n)return m/2;
    LL ans=n;
    m=m-n*2;
    ans=ans+m/4;
    return ans;
}
int main(void)
{
    LL n, m;
    scanf("%lld%lld", &n, &m);
    LL ans = fun(n, m);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
exception Exodus
let call_cc f =
  let return = ref (fun () -> raise Not_found) in
  try f (fun x -> (return := fun () -> x); raise Exodus)
  with Exodus -> !return ()

let () = print_endline @@ Scanf.scanf "%d %d" (fun n y ->
  call_cc (fun k ->
    for i = 0 to min n ((y / 1000 - n) / 9) do
      for j = 0 to min (n - i) ((y / 1000 - n - 9 * i) / 4) do
        if 9 * i + 4 * j = y / 1000 - n then
          k (Printf.sprintf "%d %d %d" i j (n - i - j))
      done
    done;
    "-1 -1 -1"))

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

int main(void){
  char s[100010];
  int num[100010];
  scanf("%s",s);
  int k;
  scanf("%d",&k);
  int n;
  int i;
  n = strlen(s);
  for(i=0;i<n;i++){
    num[i] = (s[i]-'a');
  }
  
  for(i=0;i<n;i++){
    if(k>=(26-num[i])%26){  
      k -= (26 - num[i])%26;
      num[i] = 0;
    }
  }
  
  /*
  if(k>0){
    for(i=n-1;i>=0;i--){
      if(k>=(25-num[i])){
	k -= (25-num[i]);
	num[i] = 25;
      }else{
	num[i] += k;
	k = 0;
      }   
    }
  }
  */

  if(k>0){
    num[i-1] += (k%26);
  }

  for(i=0;i<n;i++){
    s[i] = (num[i]+'a');
  }

  printf("%s\n",s);
  

  return 0;
}


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

using namespace std;

long long n, s;

bool ok(long long x){
	long long tmp = n, ss = 0;
	while (tmp){
		ss += tmp % x;
		tmp /= x;
	}
	return ss == s;
}

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%lld%lld",&n,&s);
	if (n == s){
		printf("%lld",n + 1);
		return 0;
	}
	for(int i = 2; i <= int(sqrt(n)) + 1; ++i){
		if (ok(i)){
			printf("%d",i);
			return 0;
		}
	}
	if (n - s > 0) for(int i = sqrt(n - s); i >= 1; --i){
		if ((n - s) % i == 0){
			if (ok((n - s) / i + 1)){
				printf("%lld",(n - s) / i + 1);
				return 0;
			}
		}
	} 
	printf("-1");
	return 0;
}

Measured memory_bytes: 256