akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl flag(114514);
ll dp[114514];
vvl G(114514);
ll f(ll x){
  if(flag[x])return dp[x];
  flag[x]=1;
  ll res=0;
  for(auto t:G[x]){
    res=max(res,f(t)+1);
  }
  dp[x]=res;
  return res;
}
  
  
int main(){
  ll n,m;cin>>n>>m;
  rep(i,n)dp[i]=0;
  rep(i,m){
    ll a,b;cin>>a>>b;
    a--;b--;
    G[b].push_back(a);
  }
  ll MAX=0;
  rep(i,n){
    MAX=max(MAX,f(i));
  }
  //rep(i,n)cout<<dp[i]<<endl;
  cout<<MAX<<endl;
}

  
  

Measured memory_bytes: 12288
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int sum = 0;
        for (int i = 1; i <= k; i++) {
            for (int j = 1; j <= k; j++) {
                int tmp = (int)gcd(i,j);
                for (int l = 1; l <= k; l++) {
                    int num = (int)gcd(tmp,l);
                    sum += num;
                }
            }
        }
        System.out.println(sum);
    }
    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
}



Measured memory_bytes: 27364
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main() {
    string S; cin>>S;
    if(S=="RRR")cout<<3<<endl;
    else if(S=="SRR"||S=="RRS")cout<<2<<endl;
    else if(S=="SSS")cout<<0<<endl;
    else cout<<1<<endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

ll N;
string S;
vector<char> red, blue;

ll dp[20][20];

ll dpmem(ll redrem, ll bluerem) {
    if (dp[redrem][bluerem] != -1) {
        return dp[redrem][bluerem];
    }
    if (redrem < 0 || bluerem < 0) {
        return 0;
    }
    if (redrem == 0 && bluerem == 0) {
        return 1;
    }
    ll tmp = 0;
    char c = S[N + redrem + bluerem - 1];
    if (redrem > 0 && red[red.size() - redrem] == c) {
        tmp += dpmem(redrem - 1, bluerem);
    }
    if (bluerem > 0 && blue[blue.size() - bluerem] == c) {
        tmp += dpmem(redrem, bluerem - 1);
    }
    return dp[redrem][bluerem] = tmp;
}

int main() {
    cin >> N;
    cin >> S;
    ll ans = 0;
    REP(i, 0, (1 << N)) {
        red.clear();
        blue.clear();
        REP(j, 0, N) {
            if (i & (1 << j)) {
                red.push_back(S[j]);
            } else {
                blue.push_back(S[j]);
            }
        }
        REP(i, 0, 20) {
            fill(dp[i], dp[i] + 20, -1);
        }
        ll redlen = red.size();
        ll bluelen = blue.size();
        ans += dpmem(redlen, bluelen);
    }
    cout << ans << endl;
}


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

#define ll long long int
using namespace std;
int main()
{
    ll n,i,j,k,a,p,c=0;
    map<char,ll>m;
    string s;
    cin>>s;
    for(i=0;i<4;i++)
    {
        m[s[i]]++;
    }
    for(auto x:m)
    {
        if(x.second==2)
        {
            c++;
        }
    }
    if(c==2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


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

const int inf = 1001001001;

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

  vector<int> t(1 << 26, inf), dp(s.size() + 1, inf);
  dp[0] = t[0] = 0;

  int x = 0;
  for (int i = 1; i <= s.size(); ++i) {
    x ^= (1 << (s[i - 1] - 'a'));
    for (int j = 0; j < 26; ++j) {
      dp[i] = min(dp[i], t[x ^ (1 << j)] + 1);
    }
    dp[i] = min(dp[i], t[x] + 1);

    t[x] = min(t[x], dp[i]);
  }

  cout << dp[s.size()] << endl;
}


Measured memory_bytes: 263556
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);

  const L = [2n, 1n];

  for (let i = 2; i <= N; i++) {
    L[i] = L[i - 1] + L[i - 2];
  }

  return L[N].toString();
};

console.log(main(read()));


Measured memory_bytes: 29632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		sc.close();
		int pre = Integer.parseInt(str.substring(0, 2));
		int suf = Integer.parseInt(str.substring(2, 4));

		if (pre > 0 && pre < 13) {
			if (suf > 0 && suf < 13) {
				System.out.println("AMBIGUOUS");
				return;
			}
			System.out.println("MMYY");
			return;
		} else {
			if (suf > 0 && suf < 13) {
				System.out.println("YYMM");
				return;
			}
			System.out.println("NA");
			return;
		}
	}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mx=10000001; 
ll factor[mx]; 
void sieve()
{
    factor[1]=1; 
    for (ll i=2;i<mx;i++) 
        factor[i] = i;
    for (ll i=4;i<mx;i+=2) 
        factor[i] = 2; 
    for (ll i=3;i*i<mx;i++) { 
        if (factor[i] == i) {
            for (ll j=i*i;j<mx;j+=i) { 
                if (factor[j] == j) 
                factor[j] = i; 
            }
        }
    }
} 
ll fact(ll n) 
{ 
    if (n == 1) 
        return 1; 
    ll ans = 1;
    ll d=factor[n];
    ll c= 1;
    ll j=n/factor[n]; 
    while (j != 1) {
        if (factor[j]==d) 
            c += 1;
        else { 
            d=factor[j]; 
            ans*=(c + 1); 
            c=1; 
        } 
		j=j/factor[j]; 
    }
	ans = ans * (c + 1); 
    return ans; 
} 
int main() {
	cin.tie(NULL);
	cout.tie(NULL);
	sieve();
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		ans+=i*(fact(i));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 81740
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define int long long
 
using namespace std;
 
int a[123456];

 
signed main()
{
    int flag=0;
    int n,c,k;
    scanf("%lld %lld %lld",&n,&c,&k);
    for(int i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    int sum=0;
    for(int i=0; i<n; i++)
    {
        int f=a[i]+k;
        int h=0;
        while(i<n)
        {
            if(a[i]<=f)
            {
                h++;
            }
            if(h==c)
            {
                if(i==n-1)
                    flag=1;
                sum++;
                break;
            }
            if(a[i] > f)
            {
                i--;
                sum++;
                break;
            }
            i++;
        }
    }
    if(flag==0) sum++;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1024
from math import ceil
N,D,A = list(map(int, input().split()))
P = []
for _ in range(N):
  P.append(list(map(int, input().split())))
  # X,H

P.sort()

#for p in P:
#  print(p)
  
# Attack[i] : i番目（Xi）を左端に爆弾を投げたとき、巻き込める最大の番号Xj
Attack = [-1 for _ in range(N)]
leftx, leftj = 0,0
for i in range(N):
  now = P[i][0]
  leftx = now + 2*D
  while leftj < N:
    if P[leftj][0] <= leftx:
      leftj += 1
    else:
      break
  Attack[i] = leftj - 1
  
#print(Attack)
# damage管理
# 範囲攻撃はimosっぽくやる。届いた左端に+Dして、届いた右端の右隣に-Dする
# 今までのダメージ総和をworkとして持ちつつ、imosで回復すればよい
wk_dam = 0
imos = [0] * (N+1)
ans = 0
for i in range(N):
  wk_dam += imos[i]
  #print(i,wk_dam,P[i][1],ans)
  if P[i][1] <= wk_dam:
    # すでに累積ダメージで死んでる
    continue
  cnt = (P[i][1] - wk_dam + A-1) // A # ceil(zanHP / A)
  wk_dam += cnt * A
  imos[i] += cnt * A
  imos[Attack[i]+1] -= cnt * A
  ans += cnt
  
print(ans)
#print(imos)

Measured memory_bytes: 60388
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            1e18


void solve()
{
  int a,b;
  cin>>a>>b;
  if(b%2!=0) cout<<"No"<<endl;
  else if(b%2==0&&b/2==a) cout<<"Yes"<<endl;
  else if(b%4==0&&b/4==a) cout<<"Yes"<<endl;
  else
  {
      int A=a;
      int B=b;
      while(1)
      {
          b-=4;
          a--;
          if(b%2==0&&b/2==a) { cout<<"Yes"<<endl; return; }
          if(a<=0||b<=0) break;
      }
      while(1)
      {
          B-=2;
          A--;
          if(B%4==0&&B/4==A) { cout<<"Yes"<<endl; return; }
          if(A<=0||B<=0) break;
      }
      cout<<"No"<<endl;
  }
}

int main()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    //sieve();
    //int cnt=1;
    //int t; scanf("%d",&t); while(t--) solve();
    solve();
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int N, T, minCost;
    minCost = N_MAX;
    cin >> N >> T;
    
    for (int i = 1; i <= N; i++) {
        int ci, ti;
        cin >> ci >> ti;
        if (ti <= T && minCost > ci) {
            minCost = ci;
        }
    }
    if (minCost == N_MAX) {
        cout << "TLE" << endl;
    } else {
        cout << minCost << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
using namespace std;

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

#define MAX_N 200000

int par[MAX_N];
int rnk[MAX_N];

// 初期化
void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		rnk[i] = 0;
	}
}

// x の親を返す
int find(int x){
	if(par[x] == x){
		return x;
	}
	return par[x] = find(par[x]);
}

// x と y を併合する
void unite(int x, int y){
	int x_par = find(x);
	int y_par = find(y);
	if(x_par == y_par){
		return;
	}
	
	if(rnk[x_par] < rnk[y_par]){
		par[x_par] = y_par;
	}else{
		par[y_par] = x_par;
		if(rnk[x_par] == rnk[y_par]){
			rnk[x_par]++;
		}
	}
}

// x, y が同じグループか判定
bool same(int x, int y){
	return (find(x) == find(y));
}

int main(){
	
	int n, m;
	cin >> n >> m;
	
	init(n);
	
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		unite(x, y);
	}
	
	int q;
	cin >> q;
	
	for(int i = 0; i < q; i++){
		int x, y;
		cin >> x >> y;
		if(same(x, y)){
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		}
	}
	
	return 0;
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{
    gearup;
    ll n; cin >> n;
    vl t(n),a(n);
    rep(i,n)cin>>t[i]>>a[i];
    ll x = 1,y = 1;
    rep(i,n){
        ll nx = (x + t[i] -1)/t[i];
        ll ny = (y + a[i] -1)/a[i];
        ll nz = max(nx,ny);
        x = nz*t[i];
        y = nz*a[i];
    }
    out(x+y);
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  string s,t; cin >> s >> t;
  bool ok = false;
  for(int i = s.size()-t.size(); 0 <= i; i--){
    bool fit = true;
    rep(j,t.size()){
      if(s[i+j] == '?') continue;
      if(s[i+j] != t[j]) fit = false;
    }
    if(fit){
      rep(j,t.size()) s[i+j] = t[j];
      ok = true;
      break;
    }
  }
  if(ok){
    rep(i,s.size()) if(s[i] == '?') s[i] = 'a';
    cout << s;
  }else{
    cout << "UNRESTORABLE";
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
const int N = 2005;
const int inf = 1e18;
int n, head[N], tot, dis[N], f[N], siz[N], v[N], ans = inf;
char s[N];
struct node{int to, nex;}a[N << 1];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
void init() {for(int i = 1; i <= n; i ++) dis[i] = siz[i] = f[i] = 0;}
void add(int x, int y) {a[++ tot].to = y; a[tot].nex = head[x]; head[x] = tot;}
void dfs(int x, int fa)
{
	siz[x] = v[x]; int pos = 0;
	for(int i = head[x]; i; i = a[i].nex)
	{
		int y = a[i].to; if(y == fa) continue;
		dfs(y, x); siz[x] += siz[y];
		dis[y] += siz[y]; dis[x] += dis[y];
		if(dis[y] > dis[pos]) pos = y;
	}
	if(pos == 0) return f[x] = 0, void();
	if(dis[pos] * 2 <= dis[x]) f[x] = dis[x] / 2;
	else f[x] = dis[x] - dis[pos] + min(f[pos], (2 * dis[pos] - dis[x]) / 2);
}
signed main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); scanf("%s", s + 1);
	for(int i = 1; i <= n; i ++) v[i] = s[i] - '0';
	for(int i = 1, x, y; i <= n - 1; i ++) {x = read(); y = read(); add(x, y); add(y, x);}
	for(int i = 1; i <= n; i ++)
	{
		init(); dfs(i, 0); if(dis[i] & 1) continue;
		if(f[i] * 2 >= dis[i]) ans = min(ans, dis[i] / 2);
	}
	printf("%lld\n", ans == inf ? - 1 : ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


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

using namespace std;

int main()
{
	string cards;
	int m, n;

	while (cin >> cards)
	{
		if (cards == "-") break;

		cin >> m;
		for (int i = 0; i < m; ++i)
		{
			cin >> n;
			cards = cards.substr(n) + cards.substr(0, n);
		}
		cout << cards << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
//============================================================================
// Name        : competitive_programing.cpp
// Author      : .Data_Nerd.
// Description : problem solving training
//============================================================================

#include <bits/stdc++.h>
#define Data_Nerd ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define files freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define MOD 1000000007
#define OO 0x3f3f3f3f
#define NIL -1
using namespace std;
typedef long long ll;
typedef long double ld;

int n, m;

ll ans;

priority_queue <int> pq;

int main() {
    Data_Nerd

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

    for(int i = 0, x; i < n; ++i) {
    	scanf("%d", &x);
    	pq.push(x);
    }

    for(int i = 0; i < m; ++i) {
    	int tmp = pq.top();
    	pq.pop();
    	pq.push(tmp / 2);
    }

    while(!pq.empty()) {
    	ans += pq.top();
    	pq.pop();
    }

    printf("%lld", ans);

    return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;

    vector<i64> b(N);
    rep(i,0,N){
        cin >> b[i];
        --b[i];
    }

    vector<i64> cnt(N);
    rep(i,0,N){
        ++cnt[b[i]];
    }

    rep(i,0,N){
        if(cnt[i]>N-i){
            cout << -1 << endl;
            return;
        }
    }

    vector<i64> v=b,ans;
    rep(i,0,N){
        i64 maxi=-1,pos=-1;
        rep(j,0,v.size()){
            if(j!=v[j]) continue;
            if(maxi<v[j]){
                maxi=v[j];
                pos=j;
            }
        }
        if(maxi>N-1-i or pos==-1){
            cout << -1 << endl;
            return;
        }
        ans.emplace_back(v[pos]);
        v.erase(begin(v)+pos);
    }

    reverse(begin(ans),end(ans));
    rep(i,0,N){
        cout << ans[i]+1 << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include <numeric>
using namespace std;

int main()
{	
	char S[100];
	scanf("%s",S);
	long long int l;
	l=strlen(S);
	long long int keta[l];
	long long int ket=atoll(S);
	for(int i=0;i<l;i++){
		keta[i]=ket/pow(10,l-i-1);
		ket=ket-keta[i]*pow(10,l-i-1);
	}
	
	long long int mina=1000;
	for(int i=0;i<l-2;i++){
		mina=min(mina,abs(753-100*keta[i]-10*keta[i+1]-keta[i+2]));
	}
	printf("%lld", mina);
	
}


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

#define ll long long
#define pll pair<ll,ll> 

ll M[3003][3003];
void dfs(string s,string w,ll n,ll  m,string ans){
	if(n==0 || m==0){
		reverse(ans.begin(), ans.end());
		cout<<ans;
		exit(0);
		return ;
	}
	if(s[n-1]==w[m-1])
		dfs(s,w,n-1,m-1,ans+s[n-1]);
	else{
		if(M[n-1][m]==M[n][m])
			dfs(s,w,n-1,m,ans);
		else
			dfs(s,w,n,m-1,ans);
	}
}
	
int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string s, w;
	cin>>s>>w;
	ll n=s.size();
	ll m=w.size();
	memset(M,0,sizeof M);
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=m;j++){
			if(s[i-1]==w[j-1])
				M[i][j]=1+M[i-1][j-1];
			else M[i][j]=max(M[i-1][j], M[i][j-1]);
		}
	}

	dfs(s,w,n, m,"");
	cout<<M[n][m];
	int flag=1;


}


Measured memory_bytes: 107380
#include <iostream>

using namespace std;

int main()
{
    char ch;
    cin>>ch;
    char ans;
    if(ch=='A')
        ans='T';
    else if(ch=='C')
        ans='G';
        else if(ch=='G')
            ans='C';
        else if(ch=='T')
            ans='A';
        cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main() {
	long int ans;
	long int aa;
	long int n ,a,b;
	cin >> n >> a >> b;
	aa = n % (a + b);
	if (aa > a)aa = a;
	ans = ((n / (a + b)) * a) + aa;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    x1 = A + (B - A - 1) // 2
    a, b = N - B + 1, N - A + 1
    x2 = a + (b - a - 1) // 2
    print(min(x1, x2))

Measured memory_bytes: 38736
to_middle = set()           #  島1から渡ることのできる島
from_middle = set()         #  島Nへ渡ることのできる島
N, M = map(int, (input().split()))
for _ in range(M):
    f, t = map(int, (input().split()))
    if f == 1:
        to_middle.add(t)
    elif t == N:
        from_middle.add(f)

if to_middle & from_middle:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 18936
# -*- coding: utf-8 -*-
sx,sy,tx,ty=map(int,input().split())

#pattern1,2
str1=""
str2=""
for i in range(abs(tx-sx)):
  str1+="R"
  str2+="L"
for i in range(abs(ty-sy)):
  str1+="U"
  str2+="D"

#pattern3,4
str3="D"
str4="U"
for i in range(abs(tx-sx+1)):
  str3+="R"
  str4+="L"
for i in range(abs(ty-sy+1)):
  str3+="U"
  str4+="D"

str3+="L"
str4+="R"

print("{}{}{}{}".format(str1,str2,str3,str4))

Measured memory_bytes: 3064
def orderN(N,L,ices):
    upPeak = L - ices[0]
    downPeak = L - ices[0]
    peaks = []
    for i in range(len(ices)):
        if i < N-1:
            if ices[i] < ices[i+1]:
                peaks.append(downPeak)
                downPeak = L - ices[i+1]
                upPeak += L - ices[i+1]
            elif ices[i] > ices[i+1]:
                peaks.append(upPeak)
                upPeak = L - ices[i+1]
                downPeak += L - ices[i+1]
        elif i == N-1:
            peaks.append(upPeak)
            peaks.append(downPeak)
    print(max(peaks))

N,L = map(int,input().strip().split())
ices = [int(input().strip()) for _ in range(N)]


orderN(N,L,ices)

Measured memory_bytes: 15612
a, b, m = gets.chop.split.map(&:to_i)
arr_a = gets.chop.split.map(&:to_i)
arr_b = gets.chop.split.map(&:to_i)
res = [arr_a.min+arr_b.min]
m.times do
  an, bn, dis = gets.chop.split.map(&:to_i)
  res << arr_a[an-1]+arr_b[bn-1]-dis
end
puts res.min


Measured memory_bytes: 22284
n=int(input())
l=list(map(int,input().split()))
l.sort()
if n<=2:
  print(0)
  exit()
cnt=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if l[i]+l[j]>l[k] and len(set([l[i],l[j],l[k]]))==3:
        cnt+=1
print(cnt)

Measured memory_bytes: 9228
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N,K;
ll a[1000],s[1001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>K;
    rep(i,0,N){
        cin>>a[i];
        s[i+1]=s[i]+a[i];
    }
    vector<ll> V[42];
    rep(i,0,N){
        rep(j,i,N){
            V[41].pb(s[j+1]-s[i]);
        }
    }
    ll ans=0;
    rer(i,41,0){
        ll res=0;
        for(ll d: V[i+1]){
            if(d&(1LL<<i)) res++;
        }
        if(res>=K){
            ans+=1LL<<i;
            for(ll d: V[i+1]){
                if(d&(1LL<<i)) V[i].pb(d);
            }
        }
        else{
            V[i]=V[i+1];
        }
    }
    cout <<ans<<"\n";
}

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a==c){
    cout<<0<<endl;
  }
  else{cout<<1<<endl;}
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;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 ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

// int n;
// cin >> n;
// vector<int> v(n);
// REP(i, n) {
//   cin >> v[i];
// }
// cout << n << endl;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n) {
      cin >> v[i];
    }
    VSORT(v);
    float ans = v[0];
    REP(i, n - 1) {
        ans =  (ans + v[i + 1]) / 2;
    }
    cout << ans << endl;
}

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
typedef pair<lli, int> pii;


int main()
{
    lli x;
    cin >> x;
    for(lli i=0; i<=500; i++){
        for(lli j=0; j<=500; j++){
            lli u = i*i*i*i*i;
            lli v = j*j*j*j*j;
            if(u-v == x){
                cout << i << " " << j << endl;
                return 0;
            }
            else if(u+v == x && u>v){
                cout << i << " -" << j << endl;
                return 0;
            }
        }
    }

    return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

    string s;
    cin >> s;

    cout << ((s == "ABC") ? "ARC" : "ABC") << "\n";

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    ll inc = 0;
    for (int i = n - 1; i >= 0; --i) {
        a[i] += inc;
        ll amari = a[i] % b[i];
        ll need = 0;
        if (amari != 0) need = b[i] - amari;
        inc += need;
    }
    cout << inc << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
int main(){std::string S;std::cin>>S;int64_t ans=0;std::vector<int>A(S.size()+1);for(int i=0;i<S.size();i++)if(S.at(i)=='<')A[i+1]=std::max(A[i+1],A[i]+1);for(int i=S.size()-1;i>=0;i--)if(S.at(i)=='>')A[i]=std::max(A[i],A[i+1]+1);for(int i=0;i<=S.size();i++)ans+=A[i];std::cout<<ans<<std::endl;}

Measured memory_bytes: 5852
#include <bits/stdc++.h>
using namespace std;
#define int long long

struct UnionFind{
    vector<int> par;

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

    int root(int i){
        if(par[i] == i) return i;
        else return par[i] = root(par[i]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx != ry){
            par[rx] = ry;
        }
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    
    vector<pair<int, int>> x(n), y(n);
    for(int i=0; i<n; i++){
        int xx, yy;
        cin >> xx >> yy;
        x[i] = make_pair(xx, i);
        y[i] = make_pair(yy, i);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    vector<tuple<int, int, int>> dis;

    for(int i=1; i<n; i++){
        int dx = x[i].first - x[i-1].first;
        int ind1 = x[i].second;
        int ind2 = x[i-1].second;
        dis.push_back(make_tuple(dx, ind1, ind2));
        
        int dy = y[i].first - y[i-1].first;
        int ind3 = y[i].second;
        int ind4 = y[i-1].second;
        dis.push_back(make_tuple(dy, ind3, ind4));
    }
    sort(dis.begin(), dis.end());

    // Kruskal
    UnionFind uf(n);
    int ans = 0;
    for(int i=0; i<dis.size(); i++){
        int d = get<0>(dis[i]);
        int s = get<1>(dis[i]);
        int t = get<2>(dis[i]);
        if(!uf.same(s, t)){
            uf.unite(s, t);
            ans += d;
        }
    }
    cout << ans << endl;
    return 0;
}

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

string A, B;
int K, N;
int ten[11];
bool flag[11];

int rec(int p, int k) {
  if(p == N) {
    int res = 0;
    for(int i = 0, borrow = 0; i < N; ++i) {
      int a, b;
      a = A[i]-'0', b = B[i]-'0';
      if(a-borrow >= b) {
	res += ten[i]*(a-borrow-b);
	borrow = 0;
      } else {
	res += ten[i]*(a-borrow+10-b);
	if(flag[i]) borrow = 0;
	else        borrow = 1;
      }
    }
    return res;
  }
  int res;
  flag[p] = false;
  res = rec(p+1,k);
  if(k < K) {
    flag[p] = true;
    res = max(res,rec(p+1,k+1));
  }
  return res;
}

int main() {
  ten[0] = 1;
  for(int i = 1; i < 11; ++i) ten[i] = ten[i-1]*10;

  cin >> A >> B >> K;
  N = A.size();
  reverse(A.begin(), A.end());
  reverse(B.begin(), B.end());
  while(A.size() != B.size()) B += "0";

  int ans = 0;
  for(int k = 0; k <= K; ++k) ans = max(ans,rec(0,0));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 0
a, b, k = gets.split.map(&:to_i)
if a >= k
        a -= k
        k = 0
else
        k -= a
        a = 0
        if b >= k
                b -= k
                k = 0
        else
                k -= b
                b = 0
        end
end

puts "#{a} #{b}"

Measured memory_bytes: 1788
#include<stdio.h>
int main(){
    int n;
    char s[50+1];
    int count=0;
    scanf("%d",&n);
    scanf("%s",s);
    for(int i=0;i<n;i++){
        if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C')){
            count=count+1;
        }else{

        }
    }
    printf("%d\n",count);
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
using namespace std;

int main()
{
	ll n,a;
	ld b;
	cin>>a>>b;
	n=round(b*100);
	cout<<fixed<<setprecision(0)<<(a*n)/100<<endl;
	return 0;
}

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

int main() {
    int n, val, count=0;
    vector<int> arr;
    cin>>n;
    for(int i=0; i<n; ++i) {
        cin>>val;
        arr.push_back(val);
    }
    for(int i=0; i<n-2; ++i) {
        for(int j=i+1; j<n-1; ++j) {
            for(int k=j+1; k<n; ++k) {
                if(arr[i]+arr[j]>arr[k] && arr[i]+arr[k]>arr[j] && arr[j]+arr[k]>arr[i] && arr[i]!=arr[j] && arr[j]!=arr[k] && arr[i]!=arr[k]) {
                    ++count;
                    //cout<<i+1<<" "<<j+1<<" "<<k+1<<endl;
                }
            }
        }
    }
    cout<<count;
	return 0;
}

Measured memory_bytes: 3600
"use strict";
function main(input) {
    var line = input.split(/\r?\n/g);
    var arr = line[0].split(" ");
    const S = arr[0], T = arr[1];
    arr = line[1].split(" ")
    var A = parseInt(arr[0]), B = parseInt(arr[1]);
    const U = line[2];
    if (S == U) A--;
    else B--;
    console.log(A + " " + B);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11468
#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.at(i);
    bool ok = true;
    
    for (int i = 0; i < n; i++){
        if (a.at(i) % 2 == 0){
            if ((a.at(i) % 3 != 0) && (a.at(i) % 5 != 0)){
                ok = false;
            }
        }
    }
    if (ok) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




using T = tuple<int, int, int>;
int Y, M, D;
//---------------------------------------------------------------------------------------------------
void _main() {
    scanf("%d/%d/%d", &Y, &M, &D);

    T cur(Y, M, D);
    T hei(2019, 4, 30);

    if (cur <= hei) printf("Heisei\n");
    else printf("TBD\n");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;

int main()
{

int x,y,a,b,c;
cin>>x>>y;
cin>>a>>b>>c;
vector <int> p(a);
vector <int> q(b);
vector <int> r(c);
vector <int> s;
rep(i,a)cin>>p[i];
rep(i,b)cin>>q[i];
rep(i,c)cin>>r[i];
sort(p.begin(),p.end());
reverse(p.begin(),p.end());
sort(q.begin(),q.end());
reverse(q.begin(),q.end());
rep(i,x)s.push_back(p[i]);
rep(i,y)s.push_back(q[i]);
rep(i,c)s.push_back(r[i]);
sort(s.begin(),s.end());
reverse(s.begin(),s.end());
ll sum=0;
rep(i,x+y)sum+=s[i];
cout <<sum;
}

Measured memory_bytes: 3572
#include <cstdio>

int main()
{
	int N;
	scanf("%d", &N);
	int ans = 0;
	while (N--)
	{
		int A;
		scanf("%d", &A);
		ans ^= A & 1;
	}
	puts(ans ? "NO" : "YES");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
using namespace std;

int main(){
    string S;
    cin >> S;
    int len = S.length() - 1;
    int num;
    for(int i = 0; i < pow(2, len); i ++){
        num = S[0]-'0';
        for(int j = 0; j < len; j ++){
            if((i >> j) & 1){
                num += S[j + 1] - '0';
            }else{
                num -= S[j + 1] - '0';
            }
        }
        if(num == 7){
            cout << S[0];
            for(int j = 0; j < len; j ++){
                if ((i >> j) & 1){
                    cout << "+" << S[j+1];
                }else{
                    cout << "-" << S[j+1];
                }
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

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

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

    int n;
    cin >> n;
    vector<int> A(n), B(n), C(n);
    REP(i, n) cin >> A[i];
    REP(i, n) cin >> B[i];
    REP(i, n) cin >> C[i];
    
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    
    long long ans = 0;
    REP(i, n){
        long long cnt;
        cnt = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        cnt *= n - (upper_bound(C.begin(), C.end(), B[i]) - C.begin());
        ans += cnt;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
n = int(input())
first = 0
second = 0
first_index = 0
second_index = 0
for i in range(n):
    x = int(input())
    if x > first:
        second_index = first_index
        second = first
        first = x
        first_index = i
    elif x > second:
        second = x
        second_index = i
for i in range(n):
    if i == first_index:
        print(second)
    else:
        print(first)


Measured memory_bytes: 4668
S = input()
N = len(S)
S_list=[]
for i in S:
    S_list.append(i)   
rS_list = list(reversed(S_list))
second_list = S_list[:(int((N-1)/2))]
#print(f'second: {second_list}')
rsecond_list = list(reversed(second_list))
third_list = S_list[(int(((N+3)-1)/2)):N]
#print(f'third: {third_list}')
rthird_list = list(reversed(third_list))
if S_list == rS_list:
    #print(f'壱: OK')
    if second_list == rsecond_list:
        #print(f'弐: OK')
        if third_list == rthird_list:
            #print(f'参: OK')
            print('Yes')       
    else:
            print('No')   
else:
            print('No')    

Measured memory_bytes: 9116
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}


void solve(long long A, long long B){
    if(A<=8 && B<=8)cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
    return;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int count8bit( unsigned char v ){
	unsigned int count = ( v & 0x55 ) + ( ( v >> 1 ) & 0x55 );
	count = ( count & 0x33 ) + ( ( count >> 2 ) & 0x33 );
	return ( count & 0x0f ) + ( ( count >> 4 ) & 0x0f );
}

int main()
{
	int n;

	cin >> n;

	for( int inning_cnt = 0; inning_cnt < n; ++inning_cnt ){
		int point = 0;
		int out_cnt = 0;
		unsigned char base = 0;
		while( out_cnt < 3 ){
			base |= 1;
			string s;
			cin >> s;
			if( s == "HIT" ){
				base <<= 1;
				if( base & 1 << 4 ){
					base -= ( 1 << 4 );
					++point;
				}
			}else if( s == "HOMERUN" ){
				point += count8bit( base );
				base = 0;
			}else if( s == "OUT" ){
				++out_cnt;
			}
		}
		cout << point << endl;
	}
}

Measured memory_bytes: 0
def fact(A):
    c0 = A
    r = 2
    lis = []
    count = 1
    while A != 1:
        if A%r == 0:
            A = A//r
            lis.append(r)
            r = 2
        else:
            r += 1
        if r > int(pow(c0,0.5))+1:
            lis.append(A)
            break
    return(lis)
n,p = map(int,input().split())
lis = fact(p)
L = list(set(lis))
import collections
c = collections.Counter(lis)
ans = 1
for x in L:
    if c[x] >= n:
        ans *= x**(c[x]//n)
print(ans)

Measured memory_bytes: 9668
#include <iostream>
#include "math.h"

#define PI 3.141592653589793

using namespace std;
int main(int argc, const char * argv[]) {
    
    double a,b,C,S,L,h,rad;
    cin >> a >> b >>C;
    rad = C * PI / 180.0;
    
    
    S = (a*b*sin(rad))/2.0;
    L = a + b + sqrt(pow(a, 2) + pow(b, 2) - (2 * a * b * cos(rad)));
    h =  b * sin(rad);
    
    cout.precision(15);
    cout << S << endl;
    cout << L << endl;
    cout << h << endl;
    
    return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  
  int count =  0;
  if (N > 0) {
  	count += ((N * (N - 1)) / 2);
  }
  if (M > 0) {
    count += ((M * (M - 1)) / 2);
  }
  cout << count << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC115
{
	class Program
	{
		static void Main(string[] args)
		{
			int d;

			d = int.Parse(Console.ReadLine());

			if (25 - d == 0)
			{
				Console.WriteLine("Christmas");
			}
			else if (25 - d == 1)
			{
				Console.WriteLine("Christmas Eve");
			}
			else if (25 - d == 2)
			{
				Console.WriteLine("Christmas Eve Eve");
			}
			else
			{
				Console.WriteLine("Christmas Eve Eve Eve");
			}

			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)
int a[200010];
int main(){
    int k, n;
    cin >> k >> n;
    int max_d = 0;
    rep(i,0,n){
        cin >> a[i];
    }
    max_d = k-a[n-1]+a[0];
    rep(i,1,n) max_d = max(max_d, a[i] - a[i-1]);
    cout << k - max_d << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>

#define MAX_LEN_S (10)

int main(int argc, char *argv[]) {
  int i, e = 0;
  char s[MAX_LEN_S + 2], buf[MAX_LEN_S];
  fgets(s, MAX_LEN_S + 2, stdin);

  for (i = 0; s[i] != '\n'; i++) {
    if (s[i] == '0' || s[i] == '1') {
      buf[e++] = s[i];
    } else { // 'B'
      if (e != 0) {  // empty
        e--;
      } 
    }
  }
  buf[e] = '\0';
  printf("%s\n", buf);
  
  return 0;
}


Measured memory_bytes: 128
import math

n = int(input())

###商及び余りをsとすると、n=m*s+s=s(m+1)、ただし0<s<m
sum_fav = 0
for s in range(1,int(math.sqrt(n))+1):
  if n%s == 0:
    m = n//s-1
    if s < m:
      #print(m)
      sum_fav += m
    else:
      break
  
print(sum_fav)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll ncr[3001][3001];
const int MOD = 1e9 + 7;

ll choose(int n, int r)
{
	if(r==0) return 1;
	if(n<r) return 0;
	if(ncr[n][r]!=-1) return ncr[n][r];
	ncr[n][r]=(choose(n-1,r-1)+choose(n-1,r))%MOD;
	return ncr[n][r];
}

ll dp[3001][3001];
ll modinv[3001];
ll fact[3001];

ll modpow(ll a, ll b)
{
	ll r = 1;
	while(b)
	{
		if(b&1) r=(r*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return r;
}

ll inv(ll a)
{
	return modpow(a,MOD-2);
}

int pre[3001];
int countone(int l, int r)
{
	if(l==0) return pre[r];
	return pre[r]-pre[l-1];
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(ncr,-1,sizeof(ncr));
	for(int i = 1; i <= 3000; i++) modinv[i] = inv(i);
	fact[0]=1;
	for(int i = 1; i <= 3000; i++) fact[i]=(fact[i-1]*i)%MOD;
	int n, m; cin>>n>>m;
	string s; cin >> s;
	for(int i = 0; i < n; i++)
	{
		if(s[i]=='1') pre[i]=1;
		if(i>0) pre[i]+=pre[i-1];
	}
	vector<ii> vec;
	for(int i = 0; i < m; i++)
	{
		int l, r; cin>>l>>r;
		l--; r--;
		vec.pb(mp(l,r));
	}	
	vector<ii> move;
	sort(vec.begin(),vec.end());
	int cur = -1;
	for(int i = 0; i < m; i++)
	{
		if(vec[i].se>cur)
		{
			move.pb(vec[i]);
			cur=vec[i].se;
		}
	}
	move.pb(mp(n,n));
	m = move.size();
	//dp[0][countone(move[0].fi,move[0].se)] = choose(move[0].se-move[0].fi+1, countone(move[0].fi,move[0].se));
	for(int i = 0; i <= n; i++)
	{
		int l = move[0].fi;
		int mid = min(move[1].fi-1, move[0].se);
		int r = move[0].se;
		int cnt = countone(l,r);
		//i is [mid+1,r]
		if(i>cnt) break;
		if(i>r-mid) break;
		dp[0][i] = choose(mid-l+1,cnt-i);
		//cerr<<0<<' '<<i<<' '<<dp[0][i]<<'\n';
	}
	for(int i = 1; i < m - 1; i++)
	{
		int l = move[i].fi;
		int mid = min(move[i+1].fi-1, move[i].se);
		int r = move[i].se;
		int cnt = countone(l,r);
		if(move[i].fi>move[i-1].se)
		{
			ll an = 0;
			for(int j = 0; j <= n; j++)
			{
				an=(an+dp[i-1][j])%MOD;
			}
			for(int j = 0; j <= r-mid; j++)
			{
				if(j>cnt) break;
				dp[i][j] = (an*choose(mid-l+1,cnt-j))%MOD;
			}
		}
		else
		{
			cnt = countone(move[i-1].se+1,r);
			//this is the number of ones in the later part
			//Naive way
			for(int x = 0; x <= r-mid; x++)
			{
				for(int j = n; j >= max(0,x - cnt); j--)
				{
					dp[i][x] = (dp[i][x]+(dp[i-1][j]*choose(mid-l+1,j+cnt-x))%MOD)%MOD;
				}
			}
			/*
			for(int j = n; j >= max(0,r-mid - cnt); j--)
			{
				
				dp[i][x] = (dp[i][x]+(dp[i-1][j]*choose(mid-l+1,j+cnt-x))%MOD)%MOD;
			}
			for(int x = r-mid; x >= 0; x--)
			{
				
			}
			*/
		}
		/*
		for(int j = 0; j <= n; j++)
		{
			cerr<<i<<' '<<j<<' '<<dp[i][j]<<'\n';
		}
		*/
	}
	ll ans = dp[m-2][0];
	cout<<ans<<'\n';
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    int ans = 0;
    for (int i = 0; i < N-2; i++) {
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') {
            ans++; 
        }
    }
    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 256