akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

const ll MOD = 1000000007;

struct mint {
    ll x;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    mint operator-() const {
        return mint(-x);
    }
    mint &operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t / 2);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

ostream &operator<<(ostream &os, const mint &a) {
    return os << a.x;
}

int main() {
    int N;
    cin >> N;
    int zero = 0;
    map<pair<ll,ll>,pair<int,int>> mp;

    rep(i, N) {
        ll x, y;
        cin >> x >> y;
        if (x == 0 && y == 0) {
            ++zero;
            continue;
        }
        ll g = gcd(x, y);
        x /= g;
        y /= g;
        if (y < 0) x = -x, y = -y;
        if (y == 0 && x < 0) x = -x, y = -y;
        bool rot90 = (x<=0);
        if (rot90) {
            ll tmp = x;
            x=y;y=-tmp;
        }
        if(rot90) mp[{x,y}].first++;
        else mp[{x,y}].second++;
    }

    mint ans     = 1;
    for(auto [f,se]:mp){
        int s = se.first;
        int t = se.second;
        mint now = 1;
        now += mint(2).pow(s)-1;
        now += mint(2).pow(t)-1;
        ans*=now;
    }
    ans -=1;
    ans+=zero;
    cout << ans << endl;
}

Measured memory_bytes: 15912
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	v := nextInt(sc)
	h := nextInt(sc)

	area := v * h
	perimeter := v + h + v + h

	fmt.Println(area, perimeter)
}

func nextInt(sc *bufio.Scanner) int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}



Measured memory_bytes: 1060
data Group = A | B | C deriving (Eq)

main:: IO ()
main = do
    [x,y] <- (map read . words) <$> getLine
    putStrLn $ if solve (x,y) then "Yes" else "No"

-- |
solve :: (Int,Int) -> Bool
solve (x,y) = grouping x == grouping y

grouping :: Int -> Group
grouping x
  | x `elem` [4,6,9,11] = A
  | x == 2              = B
  | otherwise           = C


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n; cin >> n;
  vector<int> a(5); REP (i, 5) cin >> a[i];
  int mi = 1e18;
  int idx = -1;
  REP (i, 5) if (chmin(mi, a[i])) idx = i;
  cout << (n + a[idx] - 1) / a[idx] + 4 << endl;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int ans = -10e9;
int main() {
    int n;
    cin >> n;
    vector<vector<int>> P(n, vector<int>(11)), F(n, vector<int>(10));
    rep(i, n) rep(j, 10) cin >> F[i][j];
    rep(i, n) rep(j, 11) cin >> P[i][j];
    //cout << ans << endl;
    for(int i = 1; i < 1 << 10; i++) {
        int ansi = 0;
        rep(shop, n) {
            int cnt = 0;
            rep(j, 10) {
                //cout << time + day*2 << endl;
                if(i & (1 << j)) {
                    if(F[shop][j]) cnt += 1;
                }
            }
            //if(i == 32) cout << "cnt: " << cnt << " benefit:" << P[shop][cnt] <<endl;
            ansi += P[shop][cnt];
        }

        //cout << " ansi: " << ansi << " i: " << i << endl;
        //cout << endl;
        ans = max(ans, ansi);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
def modelAnswer(S:list) -> int:
   l = [0 for i in range(len(S)+1)]
   for n,s in enumerate(S):
      if(s == "<"):
         l[n+1] = l[n] + 1
   for n,s in enumerate(S[::-1]):
      if(s == ">"):
         tmp = l[len(S) - n] + 1
         if (tmp > l[len(S) - n - 1]):
            l[len(S) -n - 1] = tmp
   return sum(l)
def main():
   S = list(input())
   print(modelAnswer(S[:]))
if __name__ == '__main__':
   main()

Measured memory_bytes: 35292
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  vll a(n);
  rep(i, n){
    cin >> a[i];
  }
  int ans = 0;
  rep(i, n)repr(j, i+1, n)repr(k, j+1, n){
    int tmp = 1;
    tmp &= a[i]!=a[j];
    tmp &= a[k]!=a[j];
    tmp &= a[i]!=a[k];
    tmp &= a[i]+a[j]>a[k];
    tmp &= a[k]+a[j]>a[i];
    tmp &= a[i]+a[k]>a[j];
    ans += tmp;
  }
  print(ans);
}


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

using namespace std;
int cnt=0;
int main()
{
	int n;
	cin>>n;
	vector<int>v;
	for(int i=1;i<=n;i+=2)
	{
		int ans=0;
		for(int j=1;j<=n;j++)
		{
			if(i%j==0)
			ans++;
		}
		v.push_back(ans);
	}
	for(int i=0;i<v.size();i++)
	{
		if(v[i]==8)
		cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
  long answer = 0;
	string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
	long n = long.Parse(input[0]);
	long m = long.Parse(input[1]);
  long[] a = new long[m];
  long[] b = new long[m];
  long[] c = new long[m];
  long[] distance = new long[n];//最短距離
  bool[] negative = new bool[n];//負のループ

    for(long i = 0; i < n; i++)
    {
      distance[i] = long.MaxValue;
    }
    
    for(long i = 0; i < m; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);//１行ごとに受け取る
      a[i] = nums[0]-1;
      b[i] = nums[1]-1;
      c[i] = -nums[2];//最短距離を調べるために正負逆転
      //Console.WriteLine( a[i]+" "+b[i]+ " "+c[i]);
    }
    distance[0] = 0;

    for(long i = 0; i < n-1; i++)//全頂点について、最短距離の更新
    {
      for(long j = 0; j < m; j++)
      {
        if(distance[a[j]] == long.MaxValue) continue;

        distance[b[j]] = Math.Min(distance[b[j]], distance[a[j]] + c[j]);
        //Console.WriteLine(a[j] + " "+b[j]+" " +distance[b[j]]);
      }
    }

    answer = distance[n-1];

    for(long i = 0; i < n; i++)
    {
      for(long j = 0; j < m; j++)
      {
        if(distance[a[j]] == long.MaxValue) continue;

        if(distance[b[j]] > distance[a[j]] + c[j])//最短距離の更新をしたのに最短がまだ含まれる
        {
          distance[b[j]] = distance[a[j]] + c[j];
          negative[b[j]] = true;
        }

        if(negative[a[j]] == true)//先が負のループならば
        {
        negative[b[j]] = true;//後も負のループ
        }
        
      }
    }

    if(negative[n-1]) Console.WriteLine("inf");
    else Console.WriteLine(-answer);

	}
}

Measured memory_bytes: 11220
import java.util.*

data class Score(val midterm: Int, val final: Int, val makeup: Int) {

    val doesTakeMidtermAndFinal = this.midterm != -1 && this.final != -1

    fun getPerformance(): String {
        val total = this.midterm + this.final
        return when {
            !doesTakeMidtermAndFinal -> "F"
            total >= 80 -> "A"
            total >= 65 -> "B"
            total >= 50 -> "C"
            total >= 30 -> if (this.makeup >= 50) "C" else "D"
            else -> "F"
        }
    }
}

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val scores = mutableListOf<Score>()
    while (true) {
        val midterm = scanner.nextInt()
        val final = scanner.nextInt()
        val makeup = scanner.nextInt()
        if (midterm == -1 && final == -1 && makeup == -1) {
            break
        }
        scores.add(Score(midterm, final, makeup))
    }
    scores.forEach {
        println(it.getPerformance())
    }
}


Measured memory_bytes: 25640
#include <iostream>

using namespace std;

int main()
{
    int x;
    cin >> x;
    if(x >= 400 && x <= 599)
    {
        cout << 8;
    }
    else
    {
        if(x >= 600 && x <= 799)
        {
            cout << 7;
        }
        else
        {
            if(x >= 800 && x <= 999)
            {
                cout << 6;
            }
            else
            {
                if(x >= 1000 && x <= 1199)
                {
                    cout << 5;
                }
                else
                {
                    if(x >= 1200 && x <= 1399)
                    {
                        cout << 4;
                    }
                    else
                    {
                        if(x >= 1400 && x <= 1599)
                        {
                            cout << 3;
                        }
                        else
                        {
                            if(x >= 1600 && x <= 1799)
                            {
                                cout << 2;
                            }
                            else
                            {
                                if(x >= 1800 && x <= 1999)
                                {
                                    cout << 1;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3668
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define test ll t; cin>>t; while(t--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
#define max 1000005
bool prime[max];
/*ull sieve()
{
	memset(prime,true,sizeof(prime));
	for(ull p=2;p*p<max;p++)
	{
		if(prime[p]==true){
			for(ull i=2*p;i<max;i+=p)
			{
				prime[i]=false;
			}
		}
	}
	prime[0]=0;
	prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int i,j,k;
	vector<int>r;
	vector<int>g;
	vector<int>hel;
	map<int ,char>b;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='R')
			r.pb(i);
		else if(s[i]=='G')
			g.pb(i);
		else{
			hel.pb(i);
			b[i]='B';
		}
	}
	int tot=r.size()*g.size()*hel.size();
	sort(g.begin(),g.end());
	sort(r.begin(),r.end());
	sort(hel.begin(),hel.end());
//	cout<<tot<<endl;
	for(int i=0;i<r.size();i++)
	{
		for(int j=0;j<g.size();j++)
		{
			int dist=(r[i]+g[j]);
			if(dist%2==0 && b[dist/2]=='B')	//B is middle
				tot--;
			if(b[2*r[i]-g[j]]=='B')	//R is middle
				tot--;
			if(b[2*g[j]-r[i]]=='B')	//G is middle 
				tot--;
			
		}
	}
	cout<<tot<<endl;
}













Measured memory_bytes: 4304
n = int(input())
a = [0] * 5
for i in range(5):
    a[i] = int(input())
ans = [[0,0] for i in range(5)]
ans[0] = [0,(n + a[0] -1)//a[0]]
for i in range(1,5):
    if a[i] < a[i - 1]:
        ans[i] = [ans[i-1][0]+1, max(ans[i-1][0]+1 + (n + a[i] -1 )//a[i],ans[i-1][1] + 1)]
    else:
        ans[i] = [ans[i-1][0]+1,ans[i-1][1] + 1]
print(ans[4][1])

Measured memory_bytes: 3064
import sys

N = int(input())
P = map(int, input().split())

Kcost = [min(row, N - 1 - row, clm, N - 1 - clm) for row in range(N) for clm in range(N)]

Sitting = [1] * (N * N)
Kcount = 0


def Kcheck(qsn, cdsn):
    if Kcost[cdsn] > Kcost[qsn] + Sitting[qsn]:
        Kcost[cdsn] = Kcost[qsn] + Sitting[qsn]
        queue.append(cdsn)


for sn in P:
    csn = sn - 1
    Kcount += Kcost[csn]
    Sitting[csn] = 0
    queue = [csn]

    while queue:
        qsn = queue.pop()
        div, mod = divmod(qsn, N)
        if mod: Kcheck(qsn, qsn - 1)
        if mod != N - 1: Kcheck(qsn, qsn + 1)
        if div: Kcheck(qsn, qsn - N)
        if div != N - 1: Kcheck(qsn, qsn + N)

print(Kcount)

sys.exit()


Measured memory_bytes: 137604
#include <bits/stdc++.h>
using namespace std;
vector<int> g[200001];
int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    int n;
    cin >> n;
    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    long long ans = 0;
    for(int i=1;i<=n;i++) ans += i*1ll*(n-i+1);
    for(int u=1;u<=n;u++){
        for(int j=0;j<g[u].size();j++){
            int v = g[u][j];
            if(u < v){
                int L = u, R = v;
                ans -= L*1ll*(n-R+1);
            }
        }
    }
    printf("%lld\n", ans);
}

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

int main(void)
{
	int n;
	int d[3] = {125,140,160};

	while(cin >> n, n >= 0){
		int mon = 1150;
		n -= 10;

		for(int i = 0; i < 10 && n > 0; i++,n--){
			mon += d[0];
		}
		for(int i = 0; i < 10 && n > 0; i++,n--){
			mon += d[1];
		}
		for(int i = 0; n > 0; i++,n--){
			mon += d[2];
		}

		cout << 4280 - mon << endl;
	}


	return 0;
}

Measured memory_bytes: 1156
import bisect

N = int(input())
d = list(map(int, input().split()))
D_MAX = max(d)
d_sort = sorted(d)

k_min = 10 ** 6
k_max = -1
center = N // 2
count = 0
for i in range(1, D_MAX + 1):
    if bisect.bisect_left(d_sort, i) == center:
        count += 1
print(count)




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

struct fast_input{
  #if local
    static constexpr int input_max = 1e2;
  #else
    static constexpr int input_max = 1e7;
  #endif
  char buf[input_max];
  char* itr;
  fast_input(){fread(buf,1,input_max,stdin);itr=buf;}
  constexpr inline bool isdigit(char* ptr)const noexcept{
    return '0' <= *ptr and *ptr <= '9';
  }
  constexpr inline uint32_t operator()(){
    while(!isdigit(itr))itr++;
    uint32_t num{};
    while(isdigit(itr)){
      num *= 10;
      num += *itr-'0';
      itr++;
    }
    return num;
  }
  template<class T = int64_t>
  T get(){
    while(!isdigit(itr) and *itr!='-')itr++;
    bool negative = *itr=='-';
    if(negative)itr++;
    T num{};
    while(isdigit(itr)){
      num *= 10;
      num += *itr-'0';
      itr++;
    }
    return negative?-num:num;
  }
}in;

int main(){
  using namespace std;
  int64_t a = in.get();
  int64_t b = in.get();
  int64_t n = in.get();
  auto f = [&](int64_t x){return a*x/b-a*(x/b);};
  cout<< f(min(b-1,n)) <<endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 52
#define mod 998244353
ll n,q,i,k,t,arr[sz],brr[sz],crr[sz],a,b,c,d,m,x,y,l,r,z,dp[sz][sz][sz],drr[sz];
void dpdp(ll node,ll val,vector<ll> v)
{
    if(node==n)
    {
        x=0;
        for(ll j=1;j<=q;j++)
        {
            if(v[brr[j]-1]-v[arr[j]-1]==crr[j])
                x+=drr[j];
        }
        if(x>=t)
            t=x;
            v.clear();
        return;
    }
    for(ll j=val;j<=m;j++)
    {
        v.push_back(j);
        dpdp(node+1,j,v);
        v.pop_back();
    }
     return;
}
int main()
{
    scanf("%lld %lld %lld",&n,&m,&q);
    vector<ll>v;
   for(i=1;i<=q;i++)
    scanf("%lld %lld %lld %lld",&arr[i],&brr[i],&crr[i],&drr[i]);
   for(i=1;i<=m;i++)
   {
       v.push_back(i);
       dpdp(1,i,v);
   }
   printf("%lld\n",t);
    return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  string s, t; cin >> s >> t;
  int m = s.size();

  VV lc(26, V());
  rep(i, m) {
    int x = s[i] - 'a';
    lc[x].push_back(i);
  }

  int i = -1;
  ll cnt = 0;
  for (auto c : t) {
    int x = c - 'a';
    if (lc[x].size() == 0) {
      cout << -1 << "\n";
      return 0;
    }
    auto it = lower_bound(all(lc[x]), i+1);
    if (it == lc[x].end()) {
      i = lc[x][0];
      ++cnt;
    }
    else i = *it;
  }

  ll ans = cnt * m + i + 1;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 4088
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;
 use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;

procedure main is
   N: Integer;
   M: Integer;
begin
   get(N);
   get(M);
   put(N * (N - 1) / 2 + M * (M - 1) / 2, 0);
end main;

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,mod=1e9+7;
ll n,k,ans[N];
ll qpow(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=ans*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    n=3;
    scanf("%lld",&k);
    ll res=0;
    for(int i=k;i>=1;i--)
    {
        ans[i]=(ans[i]+qpow(k/i,n))%mod;
        res=(res+ans[i]*i)%mod;
        for(int j=1;j*j<=i;j++)
            if(i%j==0)
            {
                if(j!=i)
                    ans[j]=(ans[j]-ans[i])%mod;
                if(i/j!=j&&i/j!=i)
                    ans[i/j]=(ans[i/j]-ans[i])%mod;
            }
    }
    res=(res+mod)%mod;
    printf("%lld\n",res);
}


Measured memory_bytes: 3832
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)
    {
        for(int i=0;i<a;i++)
        {
            cout<<b;
        }
    }
    else if(a<b)
    {
        for(int i=0;i<b;i++)
        {
            cout<<a;
        }
    }
    else
    {
        for(int i=0;i<a;i++)
        {
            cout<<a;
        }
    }
    return 0;
}


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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> D1(N), D2(N);
    rep(i, N) cin >> D1[i] >> D2[i];
    rep(i, N - 2) {
        if (D1[i] == D2[i] && D1[i + 1] == D2[i + 1] && D1[i + 2] == D2[i + 2]) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

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

int main() {
  int N, D;
  cin >> N >> D;
  
  int A = 0;
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    A += D * 2 + 1;
    count++;
    if (A >= N) {
      break;
    }
  }
  cout << count << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
	int N;
	cin >> N;
	int num = (N + 1) / 2;
	double ans = (double)num / N;
	cout << fixed << setprecision(15) << ans << endl;
}



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

int PN_Detector(int n){
	for(int i=2; i*i<=n; i++){
		if(n%i==0){
			return 0;
		}
	}
	return 1;
}

int main(int argc, char const *argv[])
{
	int counter = 0;
	// Input the total number of elements
	int N;
	scanf("%d", &N);
	// Input elements in the list
	int A[N];
	for(int i=0; i<N; i++){
		scanf("%d", &A[i]);
	}
	// Count the number of prime number in the list
	for(int i=0; i<N; i++){
		if(PN_Detector(A[i])==1) counter++;
	}
	printf("%d\n", counter);
	return 0;
}


Measured memory_bytes: 2000
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, t;
    cin >> n;
    std::map<int, int> a;
    while(cin >> t){
        a[t-1]++;
        //cout << t<<' '<<a[t] <<endl;
        
    }
     for(int i = 0; i < n; i ++){
         cout << a[i]<<endl;
        
        
     }    
    
    
}


Measured memory_bytes: 12976
#include <iostream>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

int left_to_right(string s) {
    int n = s[0]-'0';
    for (int i=0; i<(int)s.length()/2; i++) {
        int right = s[2*i+2]-'0';
        if (s[2*i+1] == '+') {
            n += right;
        }
        else {
            n *= right;
        }
    }
    return n;
}

int multiplication_first(string s) {
    vector<int> terms;
    terms.push_back(s[0]-'0');
    for (int i=0; i<(int)s.length()/2; i++) {
        int right = s[2*i+2]-'0';
        if (s[2*i+1] == '+') {
            terms.push_back(right);
        }
        else {
            terms[terms.size()-1] *= right;
        }
    }
    return accumulate(terms.begin(), terms.end(), 0);
}

int main() {
    string s;
    int n;
    cin >> s >> n;
    if (left_to_right(s) == n) {
        if (multiplication_first(s) == n) {
            cout << "U" << endl;
        }
        else {
            cout << "L" << endl;
        }
    }
    else {
        if (multiplication_first(s) == n) {
            cout << "M" << endl;
        }
        else {
            cout << "I" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

/* 二項係数 C(n,k) mod p を計算 */
const int MOD = 1000003;
const int MAX = 2010000;
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;
}

ll modpow(ll a , ll b, ll m){
  if (b == 0) return 1;
  ll ret;
  if (b%2 == 0){
    ll  t = modpow(a, b/2, m)%m;
    ret = t*t %m;
  }else{
    ll t = modpow(a, (b-1)/2,m)%m;
    ret = a*t %m * t % m;
  }
  ret %= m;
  return ret;
}

int main(){
  COMinit();
  ll Q; cin >> Q;
  REP(i,Q){
    ll x,d,n; cin >> x >> d >> n;
    if(d==0){
      cout << modpow(x,n,MOD) << endl;
      continue;
    }

    //d>0
    if(n>=MOD){
      cout << 0 << endl;
      continue;
    }

    ll t = (x*inv[d])%MOD;
    ll ans = ((modpow(d,n,MOD) * fac[t+n-1] ) % MOD) * finv[t-1] %MOD;
    cout << ans << endl; 
  }
}

Measured memory_bytes: 48000
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    

    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i=2;i*i <= n;i++){
        ll tmp = n;
        if(tmp%i == 1){
            ans++;
            if(tmp / i != i){
               ans++;
            }
        }else{
            while(tmp%i == 0){
                tmp /= i;
            }
            if(tmp%i == 1){
                ans++;
            }
        }
    }
    if(n > 2) {
        cout << ans + 2 << endl;
    }else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e5+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) x.rbegin(),x.rend()
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define            bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int a , b , k;

void go()
{
     cin >> k >> a >> b;

     fo(i,a,b+1) 
     {
          if( i%k == 0 )
          {
               cout << "OK\n";
               return;
          }
     }
     cout << "NG\n";
}

int32_t main()
{
     FAST;     
     int t=1; 
     // cin>>t;
     test(t) go();
}

 

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

int main(int argc, const char * argv[]) {
    vector<int> se{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    };
    int k; cin >> k;
    cout << se[k-1] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string S,T,a;
  cin >> S;
  cin >> T;
  for(int c = 0; c < N; c++){
    a += S.substr(c,1);
    a += T.substr(c,1);
  }
  cout << a << endl;

}
  

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 X;
	cin >> X;
	cout << (X==7 ? "YES" : X==5 ? "YES" : X==3 ? "YES" : "NO") << endl;
	return 0;
}


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

vector<int> Spath, Tpath;

struct circle {
  int x, y, r;
  vector<int> e;
};

vector<circle> S, T;

bool asc(const circle& a, const circle& b) {
  return a.r < b.r;
}

double dist(int x0, int y0, int x1, int y1) {
  return sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1));
}

bool include(circle a, circle b) {//a???b??????????????????
  if(dist(a.x, a.y, b.x, b.y)+b.r < a.r)
    return true;
  else
    return false;
}

bool intersect(circle a, circle b) {
  if(dist(a.x, a.y, b.x, b.y) <= a.r + b.r)
    return true;
  else
    return false;
}

void S_search(int x) {
  if(Spath[x] < 0) {
    if(S[x].e.size() > 0) {
      int m = -1;
      for(int i = 0; i < S[x].e.size(); i++) {
	if(Spath[S[x].e[i]] > 0) {//already search
	  if(m < Spath[S[x].e[i]]) m = Spath[S[x].e[i]];
	}
	else {//not yet search
	  S_search(S[x].e[i]);
	  if(m < Spath[S[x].e[i]]) m = Spath[S[x].e[i]];
	}
      }
      Spath[x] = m+1;
    }
    else
      Spath[x] = 1;
  }
}

void T_search(int x) {
  if(Tpath[x] < 0) {
    if(T[x].e.size() > 0) {
      int m = -1;
      for(int i = 0; i < T[x].e.size(); i++) {
	if(Tpath[T[x].e[i]] > 0) {//already search
	  if(m < Tpath[T[x].e[i]]) m = Tpath[T[x].e[i]];
	}
	else {//not yet search
	  T_search(S[x].e[i]);
	  if(m < Tpath[T[x].e[i]]) m = Tpath[T[x].e[i]];
	}
      }
      Tpath[x] = m+1; 
    }
    else {
      Tpath[x] = 1;
    }
  }
}
    

int main() {
  while(true) {
    int n, xt, yt, xs, ys, x, y, r;
    cin >> n;
    if(n == 0) break;
    cin >> xs >> ys >> xt >> yt;
    for(int i = 0; i < n; i++) {
      cin >> x >> y >> r;
      double ds, dt;
      ds = dist(x, y, xs, ys);
      dt = dist(x, y, xt, yt);
      if((ds > r) && (dt < r)) {//??´???????????????
	circle tmp;
	tmp.x = x; tmp.y = y; tmp.r = r;
	T.push_back(tmp);
      }
      else if((ds < r) && (dt > r)) {//?????????????????????
	circle tmp;
	tmp.x = x; tmp.y = y; tmp.r = r;
	S.push_back(tmp);
      }
    }
    if(S.size() > 0) sort(S.begin(), S.end(), asc);
    if(T.size() > 0) sort(T.begin(), T.end(), asc);	       
    for(int i = 0; i < S.size(); i++) {
      for(int j = 0; j < S.size(); j++) {
	if(include(S[i], S[j])) S[i].e.push_back(j);
      }
      Spath.push_back(-1);
    }
    for(int i = 0; i < T.size(); i++) {
      for(int j = 0; j < T.size(); j++) {
	if(include(T[i], T[j])) T[i].e.push_back(j);
      }
      Tpath.push_back(-1);
    }
    for(int i = 0; i < S.size(); i++) {
      S_search(i);
    }
    for(int i = 0; i < T.size(); i++) {
      T_search(i);
    }
    int maxS = 0, maxT = 0, maxST = 0;
    if(S.size() > 0) maxS = *max_element(Spath.begin(), Spath.end());
    if(T.size() > 0) maxT = *max_element(Tpath.begin(), Tpath.end());
    for(int i = 0; i < S.size(); i++) {
      for(int j = 0; j < T.size(); j++) {
	if(!intersect(S[i], T[j])){
	  if(maxST < Spath[i]+Tpath[j]) maxST = Spath[i]+Tpath[j];
	}
      }
    }
    cout << max({maxS, maxT, maxST}) << endl;
    S.clear();
    T.clear();
    Spath.clear();
    Tpath.clear();
  }
  return 0;
}
	  

Measured memory_bytes: 5548
N, M, K = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i)
B = gets.chomp.split(" ").map(&:to_i)

tt = 0
ia = 0
ib = 0
A.each do |a|
  break if tt + a > K
  tt += a
  ia += 1
end
B.each do |b|
  break if tt + b > K
  tt += b
  ib += 1
end

max_n = ia + ib
while ia > 0
  ia -= 1
  tt -= A[ia]
  loop do
    break if !B[ib] || tt + B[ib] > K
    tt += B[ib]
    ib += 1
  end
  max_n = ia + ib if max_n < ia + ib
end
puts max_n


Measured memory_bytes: 49372
a, b, k = map(int, input().split())

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        b = b + (a / 2)
        a = a / 2
    else:
        if b % 2 == 1:
            b -= 1
        a = a + (b / 2)
        b = b / 2
print(int(a), int(b))

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

#define int long long
typedef pair <string, string> pii;

map <pii, int> M;

int32_t main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int mask = 0; mask < (1 << n); mask++) {
		string t = "";
		string q = "";
		for (int i = 0; i < n; i++){
			if (mask & (1 << i))
				t += s[i];
			else
				q += s[i];
		}
		M[pii(t, q)] ++;
	}
	int ans = 0;
	for (int mask = 0; mask < (1 << n); mask++) {
		string t = "", q = "";
		for (int i = n - 1; i >= 0; i --) {
			if (mask & (1 << i))
				t += s[i + n];
			else
				q += s[i + n];
		}
		ans += M[pii(t, q)];
	}
	cout << ans;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    string s;
    int x;
    cin>>s>>x;
    int n =s.length();
    for (int i=0; i<n; i+=x) {
	cout<<s[i];
    }
    cout<<endl;
    
    return 0;
}


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

const int maxn = 2e5 + 5;
int num[maxn];

map<ll,ll>cnt;

int main(){
	int n; cin >> n;
	for(int i = 1; i < n; i++){
		int t; cin >> t;
		cnt[t]++;
	}

	for(int i = 1; i <= n; i++) cout << cnt[i] << endl;

}


Measured memory_bytes: 16132
#include<stdio.h>

int main(){
  int x,y,d,n;
  scanf("%d%d",&x,&y);
  if(x<y){
    n=y;
    y=x;
    x=n;
  }
  while((x%y)!=0){
    
    d=x%y;
    x=y;
    y=d;
  }
  printf("%d\n",y);
  return 0;
}



Measured memory_bytes: 2072
#include <iostream>
using namespace std;
int main(void){
    int n, m, s[10][10], k[10], p[10], c=0, w;
    bool b;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> k[i];
        for(int j=0;j<k[i];j++){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    for(int i=0;i<m;i++){
        cin >> p[i];
    }
    
    for(int i=0;i<(1<<n);i++){
        b = true;
        for(int j=0;j<m;j++){
            w = 0;
            for(int l=0;l<k[j];l++){
                if(((i>>s[j][l])&1)==1)w++;
            }
            if(w%2!=p[j]){
                b = false;
                break;
            }
        }
        if(b)c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
template<class T> inline int Digit_L(T n){
  int res=0;
  while(n){
    res++;
    n /= 10;
  }
  return res;
}
template<class T> inline T pow2_L(T a){
  return a*a;
}
template<class T, class S> inline T pow_L(T a, S b){
  T res=1;
  res = 1;
  while(b){
    if(b&1){
      res *= a;
    }
    b >>= 1;
    a *= a;
  }
  return res;
}
int main(){
  int A, B, i;
  rd(A);
  rd(B);
  A = A * (pow_L(10,Digit_L(B))) + B;
  for(i=0;i<(500);i++){
    if(pow2_L(i)==A){
      wt_L("Yes");
      wt_L('\n');
      return 0;
    }
  }
  wt_L("No");
  wt_L('\n');
  return 0;
}
// cLay varsion 20190827-1

// --- original code ---
// {
//   int A, B;
//   rd(A,B);
//   A = A * (10 ** Digit(B)) + B;
//   rep(i,500) if(i**2==A) wt("Yes"), return 0;
//   wt("No");
// }


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

struct RollingHash{
    static const int B1=1007,B2=2009;
    static const int mod1=1000000007,mod2=1000000009;
    vector<long long> hash1,hash2,po1,po2;
    RollingHash(const vector<long long> &vs){init(vs);}
    RollingHash(const string &S){
        vector<long long> vs;
        for (char c:S) vs.emplace_back(c);
        init(vs);
    }
    void init(vector<long long> vs){
        int n=vs.size();
        hash1.assign(n+1,0);
        hash2.assign(n+1,0);
        po1.assign(n+1,1);
        po2.assign(n+1,1);
        for (int i=0;i<n;++i){
            hash1[i+1]=(hash1[i]*B1+vs[i])%mod1;
            hash2[i+1]=(hash2[i]*B2+vs[i])%mod2;
            po1[i+1]=po1[i]*B1%mod1;
            po2[i+1]=po2[i]*B2%mod2;
        }
    }
    inline pair<long long,long long> get(int l,int r) const{
        long long res1=hash1[r]+mod1-hash1[l]*po1[r-l]%mod1
                ,res2=hash2[r]+mod2-hash2[l]*po2[r-l]%mod2;
        return {res1>=mod1?res1-mod1:res1,res2>=mod2?res2-mod2:res2};
    }
    inline int LCP(int a,int b) const{
        int len=min((int)hash1.size()-a,(int)hash1.size()-b);
        int lb=0,ub=len;
        while(ub-lb>1){
            int mid=(lb+ub)>>1;
            (get(a,a+mid)==get(b,b+mid)?lb:ub)=mid;
        }
        return lb;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; string S; cin >> N >> S;
    RollingHash rh(S);
    int ans=0;
    for (int i=0;i<N;++i){
        for (int j=i+1;j<N;++j){
            int lcp=rh.LCP(i,j);
            ans=max(ans,min(lcp,j-i));
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
struct Edge{
    ll from, to, cost;
    Edge(){from=0, to=0, cost=0;}
    Edge(ll u, ll v, ll c){from=u, to=v, cost=c;}
};
ostream& operator<<(ostream &s, Edge e){
    s<<"<"<< e.from << ", " <<e.to<<", " <<e.cost<< " >";
    return s;
}

struct Graph{
    ll V;
    ll E;
    vector<Edge> Edges;
    vector<vector<Edge>> NeigborList;
    vector<ll> dist;
    vector<int> used;
    Graph(ll n){
        V = n;
        NeigborList.resize(n);
        dist.resize(n, INF);
        used.resize(n, 0);
    }
    void dijkstra(ll s);
    bool bellmanFord(ll s){
        bool hasNegativeLoop = false;
        dist[s] = 0;
        for(ll t=0; t<V; t++){
            bool update = false;
            for(auto e: Edges){
                if(dist[e.from]==INF) continue;
                if(dist[e.to]>dist[e.from]+e.cost){
                    dist[e.to] = dist[e.from] + e.cost;
                    update = true;
                }
            }
            if(!update) break;
            else if(t==V-1) hasNegativeLoop = true;
        }
        return hasNegativeLoop;
    }
};
signed main(){
    ll N, M, s;
    cin>>N>>M>>s;
    Graph g(N);
    REP(i, M){
        ll u, v, c;
        cin>>u>>v>>c;
        g.Edges.emplace_back(Edge(u, v, c));
    }
    bool res = g.bellmanFord(s);
    if(res) cout << "NEGATIVE CYCLE" << endl;
    else {
        REP(i, N){
            if(g.dist[i]==INF) cout << "INF" <<endl;
            else cout << g.dist[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3184
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        double H = scanner.nextDouble();
        int N = scanner.nextInt();
        int sum = 0;
        
        for(int i=0; i<N; i++){
            
            int A = scanner.nextInt();
            sum += A;
            
        }
        if(sum>=H){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    }
}


Measured memory_bytes: 47104
s = list(input())

S = []
for i in range(len(s)):
    if s[i] == "0":
        S += s[i]
    elif s[i] == "1":
        S += s[i]
    elif len(S) == 0:
        pass
    else:
        del S[-1]
print("".join(S))


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var np = Array.ConvertAll(ReadLine().Split(' '), long.Parse);
        if (np[0] == 1) { WriteLine(np[1]);return; }
        var max = 0;
        for(var i = 1; np[1] >= Pow(i, np[0]); i++)
        {
            if (np[1] % (long)Pow(i, np[0]) == 0) max = i;
        }
        WriteLine(max);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 13140