akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>p;
struct edge { int to, cost; };
std::vector<int>G[100000];
std::vector<int>I[100000];

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = false;
bool f = false;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int main() {
	ll n, ans = 0;
	std::cin >> n;
	std::string s, t;
	s = std::to_string(n);
	t = s;
	for (int i = 0;i < s.size()-1;i++) {
		if (flag) {
			if (s[i + 1] - '0' != 9) {
				int a = s[i] - '0' - 1;
				s[i] = a + '0';
				s[i + 1] = '9';
			}
			else s[i + 1] = '9';
		}
		else s[i + 1] = '9';
		if (s < t)flag = false;
	}
	for (int i = 0;i < s.size();i++) {
		ans += s[i] - '0';
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define MOD(x) ((x)>=mod?(x)-mod:(x))
using namespace std;
const int maxn=500010, inf=1e9, mod=1e9+7;
struct poi{int x, v;}q[maxn];
int n;
int l[maxn], r[maxn], f[maxn], pos[maxn];

bool operator < (poi a, poi b){return a.x<b.x;}

inline bool cmp(int a, int b){return q[a].v<q[b].v;}

int main()
{
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d%d", &q[i].x, &q[i].v);
	sort(q+1, q+1+n); for(int i=1;i<=n;i++) pos[i]=i;
	sort(pos+1, pos+1+n, cmp);
	for(int i=1;i<=n;i++) l[pos[i]]=r[pos[i]]=i;
	for(int i=2;i<=n;i++) r[i]=max(r[i], r[i-1]);
	for(int i=n-1;i;i--) l[i]=min(l[i], l[i+1]);
	f[0]=1;
	for(int i=1, j=0, ans=1;i<=n;i++)
	{
		while(j<l[i]-1) ans=MOD(ans-f[j]+mod), j++;
		f[r[i]]=MOD(f[r[i]]+ans);
		ans=MOD(ans+ans);
	}
	printf("%d\n", f[n]);
}

Measured memory_bytes: 9344
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int m,d;
	cin>>m>>d;
	int ans=0;
	int db[105][105];
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=d;j++)
		{
			if(j/10!=0)
			{
				int g,s;
				g=j%10;
				s=j/10;
				if(g>=2&&s>=2&&g*s==i)
				ans++;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
using vc = vector<char>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int n;
  cin >> n;
  vl a(n);
  long sum = 0;
  rep(i,n){
    cin >> a.at(i);
    sum += a.at(i);
  }
  long sub = 0;
  RNG(i,1,n,2){
    sub += a.at(i);
  }
  vl d(n);
  d.at(0) = sum - sub*2;
  REP(i,1,n){
    d.at(i) = 2*a.at(i-1) - d.at(i-1);
  }
  rep(i,n) cout << d.at(i) << " ";
  cout << endl;
}

Measured memory_bytes: 2944
a,b,c = 0,0,0
for i in input():
    if i == 'a':
        a = 1
    if i == 'b':
        b = 1
    if i == 'c':
        c = 1

if a == 1 and b == 1 and c == 1 :
    print("Yes")
else :
    print("No")

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
    int n, x, l, i;
    cin >> n >> x;
    int bnc[n];
    bnc[0]=0;

    int pulos=1;
    for(i=1;i<=n;i++){
        cin >> bnc[i];
        bnc[i]+=bnc[i-1];
        if(bnc[i]<=x){
            pulos++;
        }
    }
    cout << pulos << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define memset(v, h) memset((v), h, sizeof(v))
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using P = pair<ll, ll>;
const int INF = 1001001001;

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

struct node
{
    public: ll x;
    public: ll y;

    node(ll xx, ll yy)
    {
        x = xx;
        y = yy;
    }
};

ll comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v[n][r];
}

ll digit(ll num)
{
    if(num < 10)
    {
        return 1;
    }

    ll d = 1;
    ll k = 10;
    while(num >= k)
    {
        d++;
        k *= 10;
    }

    return d;
}

ll digitNum(ll num, ll count)
{
    ll a = (num % (ll) pow((double) 10, (double) count));
    return a / pow(10, count - 1);
}

bool less_abs(int lhs, int rhs) {
    if(lhs < 0)
    {
        lhs *= -1;
    }
    if(rhs < 0)
    {
        rhs *= -1;
    }

    return lhs < rhs;
}

bool IsTrueBit(int bit, int index)
{
    return (bit & (1 << index));
}

int main(){
    int n;
    cin >> n;

    vector<pair<int, int>> onest[n];

    rep(i, n)
    {
        int a;
        cin >> a;
        rep(j, a)
        {
            int x,y;
            cin >> x >> y;
            onest[i].push_back(pair<int, int>(x, y));
        }
    }

    int max = 0;
    rep(i, 1 << n)
    {
        bool isMatch = false;
        rep(j, n)
        {
            if(!IsTrueBit(i, j)) continue;

            vector<pair<int, int>> p = onest[j];
            if(p.size() == 0)
            {
                isMatch = true;
            }
            for(int k = 0; k < p.size(); ++k)
            {
                bool isOnest = IsTrueBit(i, p[k].first-1);
                isMatch = (isOnest && p[k].second == 1) || (!isOnest && p[k].second == 0);

                if(!isMatch)
                {
                    break;
                }
            }

            if(!isMatch)
            {
                break;
            }
        }

        if(isMatch)
        {
            int count = 0;
            rep(j, n)
            {
                if(IsTrueBit(i, j)) ++count;
            }

            if(count > max)
            {
                max = count;
            }
        }
    }

    cout << max << endl;
    return 0;
}

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

#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

#define QUEUE_SIZE 0x10000
typedef int Item;
Item queue[QUEUE_SIZE];
size_t queue_in = 0;
size_t queue_out = 0;
int queue_is_full = 0;

size_t inc_queue_index(size_t index)
{
  return (index + 1) % QUEUE_SIZE;
}

void queue_push(const Item* item)
{
  if(queue_is_full) {
    fputs("Queue is full.\n", stderr);
    exit(1);
  }
  memcpy(&queue[queue_in], item, sizeof(Item));
  queue_in = inc_queue_index(queue_in);
  queue_is_full = queue_in == queue_out;
}

void queue_pop(Item* result)
{
  if(queue_in == queue_out && !queue_is_full) {
    fputs("Queue is empty.\n", stderr);
    exit(1);
  }
  memcpy(result, &queue[queue_out], sizeof(Item));
  queue_out = inc_queue_index(queue_out);
  queue_is_full = 0;
}

void clear_queue()
{
  queue_in = 0;
  queue_out = 0;
  queue_is_full = 0;
}

int main()
{
  int num_people, days, rest_chocolate;
  scanf("%d%d%d", &num_people, &days, &rest_chocolate);

  long long total_chocolate = rest_chocolate;
  for(int i = 0; i < num_people; i++) {
    int a;
    scanf("%d", &a);
    total_chocolate += ((days-1) / a) + 1;
  }
  printf("%lld\n", total_chocolate);
  return 0;
}


Measured memory_bytes: 128
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
def gcds(ls):
  ret = 0
  for i in ls:
    ret = gcd(ret,i)
  return ret
def flg(ls):
  if (sum(ls)-len(ls))%2:
    ret = 1
  else:
    ret = 2
  return ret
if n%2 == 0:
  if sum(a)%2:
    print("First")
  else:
    print("Second")
else:
  cnt = 0
  while flg(a)%2 == 0:
    odd = 0
    oddidx = -1
    even = 0
    for i,x in enumerate(a):
      if x%2:
        odd += 1
        oddidx = i
      else:
        even += 1
    if odd == 1 and a[oddidx] > 1:
      a[oddidx] -= 1
      g = gcds(a)
      for i in range(n):
        a[i] //= g
      cnt += 1
    else:
      break
  if (flg(a)+cnt)%2 == 1:
    print("First")
  else:
    print("Second")

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

using namespace std;


struct Dsu {
    int n;
    vector<int> p;
    vector<int> r;
    
    Dsu(int _n) { n = _n; p.resize(n); r.resize(n); init(); }
    inline void init() {
        for (int i = 0; i < n; i++) {
            p[i] = i;
            r[i] = 1;
        }
    }
    inline int find(int x) {
        return p[x] == x ? x: p[x] = find(p[x]);
    }
    inline bool join(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (r[x] < r[y]) swap(x, y);
        p[y] = x; r[x] += r[y];
        return true;
    }
    inline bool check(int x, int y) {
        return find(x) == find(y);
    }
};

struct Node {
    int x, y, id;
    Node(): x(0), y(0), id(-1) {}
    Node(int _x, int _y, int _id) : x(_x), y(_y), id(_id) {}
};
const int N = 100005; 
set<int> X[N], Y[N];

void solve() {
    int n; cin >> n;
    vector<Node> a(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        a[i] = {x, y, i};
    }
    Dsu d(n);
    sort(a.begin(), a.end(), [&](auto& u, auto& v){
            return u.x < v.x;
            });
    int i = 0;
    while (i < n) {
        int j = i+1;
        while (j < n && a[j].x == a[i].x) {
            d.join(a[i].id, a[j].id);
            j++;
        }
        i = j;
    }
    sort(a.begin(), a.end(), [&](auto& u, auto& v){
            return u.y < v.y;
            });
    i = 0;
    while (i < n) {
        int j = i+1;
        while (j < n && a[j].y == a[i].y) {
            d.join(a[i].id, a[j].id);
            j++;
        }
        i = j;
    }
    sort(a.begin(), a.end(), [&](auto& u, auto& v){
            return u.id < v.id;
            });
    for (int i = 0; i < n; i++) {
        int k = d.find(i);
        X[k].insert(a[i].x);
        Y[k].insert(a[i].y);
    }
    long long res = 0;
    for (int k = 0; k < n; k++) {
        int szx = X[k].size();
        int szy = Y[k].size();
        if (szx > 1 && szy > 1) {
            res += 1ll*szx*szy - d.r[k];
        }
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 16256
#include<iostream>
using namespace std;
int main() {
    int n, a[200000];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    long long res = 0;
    int acc = 0;
    for (int s = 0, e = 0; e < n;) {
        while ((acc & a[e]) == 0) {
            acc |= a[e];
            ++e;
            res += (e - s);
            if (e == n) break;
        }
        while ((acc & a[e]) != 0) {
            acc -= a[s];
            ++s;
            if (s == e) break;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <numeric>
#include <functional>
#include <deque>
using namespace std;
// using LL = long long; //冗長なので略すと便利ちゃん

int main(void) {

	int N;
	cin >> N;

	deque<int> S;
	int temp;
	for (int i = 0; i < N; i++) {
		cin >> temp;
		S.push_back(temp);
	}

	if (N % 2 != 0) S.push_front(-1);

	deque<int> ans;
	while (!S.empty()) {

		ans.push_back(S.front());
		S.pop_front();
		ans.push_front(S.front());
		S.pop_front();

	}

	if (N % 2 != 0) {
		ans.erase(ans.begin() + (N + 1) / 2);
	}

	for (int i = 0; i < N; i++) {
		cout << ans[i] << " ";
	}
	

	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  map<ll,ll> mp;
  ll sum = 0;
  REP(i,n) {
    ll a;
    cin>>a;
    ++mp[a];
    sum += a;
  }
  ll q;
  cin>>q;
  REP(i,q) {
    ll b,c;
    cin>>b>>c;
    ll cnt = mp[b];
    mp.erase(b);
    mp[c] += cnt;
    sum -= cnt * b;
    sum += cnt * c;
    cout<<sum<<"\n";
  }
  return 0;
}


Measured memory_bytes: 7536
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<cstring>
//#include<unordered_map>
using namespace std;
#define ll long long 
#define dd cout<<endl
#define lll __int128
const int mod=1e9+7;
const int inf=1e9+7;

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
		
	ll int n;
	cin>>n;
	
	cout<<n*n*n<<endl;
	
		
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int) n; i++)
#define repb(i, n) for (int i = (int) n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int) m; i < (int) n; i++)
#define repsb(i, m, n) for (int i = (int) m; i >= (int) n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define pb(a) push_back(a)
#define ll long long int
const ll LLINF = 1e18 + 10;
int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };
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; }
//vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));
using namespace std;
int main(int argc, char const * argv[]){
    int n, k,ans,t;
    cin >> k >> n;
    vector<int> v(n+1,-1);
    rep(i,n) cin>>v[i];
    v[n]=v[0]+k;
    ans=0;

    rep(i,n) ans = max(ans, v[i+1]-v[i]);

    cout<<k-ans<<endl;

    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(N);
  REP(i,N) cin >> A[i];

  int ret = INF;
  for(int bound: A) {
    vector<int> tmp;
    multiset<int> ms;
    REP(i,N + 1) {
      if(i == N || A[i] < bound) {
        sort(ALL(tmp));
        REP(j, tmp.size() - K + 1) ms.insert(tmp[j]);
        tmp.clear();
      }else{
        tmp.push_back(A[i]);
      }
    }
    if(ms.size() < Q) continue;
    auto itr = ms.begin();
    REP(i,Q - 1) itr++;
    ret = min(ret, *itr - bound);
  }
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 512
//config = {stdin: 'tmp', newline: '\r\n'}; // win
config = {stdin: '/dev/stdin', newline: '\n'}; // linux

line = require('fs').readFileSync(config.stdin, 'ascii')
       .split(config.newline)
       .map(function (line) { return line.split(' '); });
line = line.slice(1, parseInt(line[0], 10) + 1);

function compare(dice1, dice2) {
  var d1 = dice1.sorted, d2 = dice2.sorted;
  for (var i in d1)
    if (d1[i] !== d2[i]) return d1[i] - d2[i];
  return 0;
}

line = line.map(function(dice) {
  var sorted = [].concat(dice);
  sorted.sort();
  return {
    raw: dice,
    sorted: sorted
  };
});
line.sort(compare);

group = [];
g = [];
for (i in line) {
  if (g.length === 0) {
    g.push(line[i]);
  } else if (compare(line[i], g[0]) === 0) {
    g.push(line[i]);
  } else {
    group.push(g);
    g = [line[i]];
  }
}
group.push(g);

dice_pos = {
  1: [0, 0, 0.5], 2: [0, -0.5, 0], 3: [0.5, 0, 0],
  4: [-0.5, 0, 0], 5: [0, 0.5, 0], 6: [0, 0, -0.5] };

function find(dice1, dice2, i) {
  return dice2.indexOf(dice1[i - 1]);
}

function sub(x, y) {
  return [x[0] - y[0], x[1] - y[1], x[2] - y[2]];
}

function get_vector_by_index(dice1, dice2, i, j) {
  var pi = find(dice1, dice2, i), pj = find(dice1, dice2, j);
  if (pi === -1 || pj === -1) return null;
  return sub(dice_pos[pi + 1], dice_pos[pj + 1]);
}

function equal(dice1, dice2) {
  var d1 = dice1.raw;
  var d2 = dice2.raw;
  var v16 = get_vector_by_index(d1, d2, 6, 1);
  var v25 = get_vector_by_index(d1, d2, 5, 2);
  var v34 = get_vector_by_index(d1, d2, 4, 3);
  var outer;

  if (v16 === null || v25 === null || v34 === null) return false;
  
  outer = [ v16[1] * v25[2] - v16[2] * v25[1],
            v16[2] * v25[0] - v16[0] * v25[2],
            v16[0] * v25[1] - v16[1] * v25[0] ];

  return (outer[0] === -v34[0] && outer[1] === -v34[1] && outer[2] == -v34[2]);
}

res = group.map(function (group) {
  for (var i = 0; i < group.length; i++)
    for (var j = i + 1; j < group.length; j++)
      if (equal(group[i], group[j])) return false;
  return true;
});

res = res.reduce(function (p, c) { return p && c; }, true);

console.log(res ? "Yes" : "No");

Measured memory_bytes: 17240
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  ll sum = 0;
  for (auto c : s) {
    int i = c - '0';
    sum += i;
  }
  string ans;
  ans = (sum % 9 == 0) ? "Yes" : "No";
  cout << ans << endl;
}

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

#define llint long long int

using namespace std;

int main(){
    int A, B, C, D;

    cin >> A >> B >> C >> D;

    while(true){
        C -= B;

        if(C <= 0){
            break;
        }
        A -= D;

        if(A <= 0){
            break;
        }
    }
    if(C <= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, D; cin >> N >> D; 
	int X[12][12] = {}; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j < D; j++){
			cin >> X[i][j]; 
		}
	}
	vector<int> Dis = {}; 
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			int tmp = 0; 
			for(int d = 0; d < D; d++){
				tmp += (X[i][d] - X[j][d]) * (X[i][d] - X[j][d]); 
			}
			Dis.push_back(tmp); 
		}
	}
	int count = 0; 
	for(int i = 0; i < Dis.size(); i++){
		for(int s = 0; s < 200; s++){
			if(Dis.at(i) == s * s) count ++; 
		}
	}
	cout << count << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    ll n,m,x;
    cin>>n>>m>>x;
    ll c[20],a[20][20];
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    bool ok=false;
    ll ans=INF;
    for(int bit=0;bit<(1<<n);bit++){
        ll b[20]={};
        ll nowans=0;
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                nowans+=c[i];
                for(int j=0;j<m;j++){
                    b[j]+=a[i][j];
                }
            }
        }
        bool nowok=true;
        for(int i=0;i<m;i++){
            if(b[i]<x) nowok=false;
        }
        if(nowok){
            ans=min(ans,nowans);
            ok=true;
        }
    }
    if(ok) cout<<ans<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main()
{
     char s[27];
     int i,j,size;

     for(i=0;i<27;i++)
     {
          scanf("%c",&s[i]);

          if(s[i]=='\n')
          {
               size=i;
               break;
          }
     }
     
     for(i=0;i<size;i++)
     {
          for(j=0;j<size;j++)
          {
               if(i!=j){
                    if(s[i]==s[j]){
                         printf("no\n");
                         return 0;
                    }
               }
          }
     }

     printf("yes\n");
     return 0;
     
}


Measured memory_bytes: 128
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
template<typename T> using vec = std::vector<T>;
template<typename T> using withi = std::pair<T, int>;
using ll = long long;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=withi<T>)vec<U>zipi(const vec<T>&x,int s=0){int N=x.size();vec<U>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

int imos[20200];

signed main() {
  int N = in(), M = in(), T = in();
  rep(i, N) {
    int t = in();
    imos[t - M] += 1;
    imos[t + M] -= 1;
  }
  int d = 0;
  int ans = 0;
  rep(t, 0, T) {
    d += imos[t];
    if (d == 0) ans++;
  }
  pr(ans);
  return 0;
}

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

#define int long long 
#define dou  double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int i,j,ans=0,n;
	cin >> n;
	for(j=1;j<=n;j++)
	{
		for(i=j;i<=n;i+=j)
			ans+=i;
	}
	cout << ans << endl;
}

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

	solve();
}


Measured memory_bytes: 3688
N,A,B,C = map(int, input().split())
l =[int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur,a,b,c):
  if cur == N:
    return abs(a-A)+abs(b-B)+abs(c-C) - 30 if min(a,b,c) else INF
  ret0 = dfs(cur+1,a,b,c)
  ret1 = dfs(cur+1,a+l[cur],b,c) + 10
  ret2 = dfs(cur+1,a,b+l[cur],c) + 10
  ret3 = dfs(cur+1,a,b,c+l[cur]) + 10
  return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define see(x) cout<<#x<<" : "<<(x)<<endl;
#define ya cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define ff first
#define sc second
typedef long long ll;
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    //freopen("test.txt","r",stdin);
    ll n,ind=0,i,j,ans=0,ev=0,od=0;
    cin>>n;
    vector<ll>v(n);
    for(auto &ii:v)cin>>ii;
    ll l[n+2];
    ll r[n+2];
    l[0]=r[n+1]=0;
    for(i=1;i<=n;i++)
    {
        l[i]=__gcd(l[i-1],v[i-1]);
    }
    for(i=n-1;i>=0;i--)
    {
        r[i+1]=__gcd(r[i+2],v[i]);
    }
    ans=1;
    for(i=1;i<=n;i++)
    {
        ans=max(__gcd(l[i-1],r[i+1]),ans);
    }
    cout<<ans<<endl;
    return 0;
}



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

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

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

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


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll l,r;
	cin>>l>>r;
	if(r-l>=2018){
		puta(0);
		return 0;
	}
	l%=2019, r%=2019;
	if(l>=r){
		puta(0);
		return 0;
	}
	ll ans=LINF;
	range(i,l,r)range(j,i+1,r+1){
		chmin(ans,i*j%2019);
	}
	puta(ans);
	return 0;
}

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

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
        int n, m;
        cin >> n >> m;
        if( n==m)
            cout << "Yes\n";
        else
            cout << "No\n";

    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



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

int n;
int p[10000] = {0};
vector<int>prime;
void find_prime(){
	for(int i=2;i<=100;i++){
		int pr = 1;
		for (int j=2;j*j<=i;j++){
			if (i%j == 0){
				pr = 0;
				break;
			}
		}
		if (pr)prime.push_back(i);
	}
}
			
int main(){
	scanf("%d", &n);
	find_prime();
	for (int i=0;i<prime.size();i++){
		int temp = n;
		while(temp>1){
			p[i] += temp/prime[i];
			temp/=prime[i];
		}
	}
	int c2=0, c4=0, c14=0, c24=0, c74=0;
	//find case pangkat 74
	for (int i=0;i<=100;i++){
		if (p[i] >= 74){
			c74++;
		}
		if (p[i] >= 24){
			c24++;
		}
		if (p[i] >= 14){
			c14++;
		}
		if (p[i] >= 4){
			c4++;
		}
		if (p[i] >= 2){
			c2++;
		}
	}
	int total = c74 + (c24 * (c2-1)) + max(0, (c14 * (c4-1))) + (c4 * (c4-1) / 2 * (c2-2));
	printf("%d\n", total);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cctype>

using namespace std;

int n2d(const char *s) {
    int res=0;
    char c;
    int last=1;

    while(c=*s++) {
        int w;
        switch(c) {
            case 'm':
                w = 1000;
                break;
            case 'c':
                w = 100;
                break;
            case 'x':
                w = 10;
                break;
            case 'i':
                w = 1;
                break;
            default:
                last = c-'0';
                continue;
        }
        res += w*last;
        last = 1;
    }

    return res;
}

string d2n(int d) {
    stringstream ss;
    if(d/1000) { 
        if(d/1000-1) ss << d/1000;
        ss << 'm';
        d %= 1000;
    }
    if(d/100) {
        if(d/100-1) ss << d/100;
        ss << 'c';
        d %= 100;
    }
    if(d/10) {
        if(d/10-1) ss << d/10;
        ss << 'x';
        d %= 10;
    }
    if(d) { 
        if(d-1) ss << d/1;
        ss << 'i';
    }

    return ss.str();
}

int main(void) {
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++) {
        char a[100], b[100];
        scanf("%s%s",a,b);
        printf("%s\n", d2n(n2d(a)+n2d(b)).c_str());
    }
    return 0;
}

Measured memory_bytes: 1244
#include<stdio.h>

int main(void)
{
   int n,i;

   scanf("%d",&n);
   for(i=9;i>0;i--)
      if((n%i==0)&&(n/i<10)){
         printf("Yes\n");
         return 0;}
   printf("No\n");
   return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <algorithm>
#include <string>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, a, b) for(int i = a; i < b; i++)

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> jobs(N);
    rep(i, N) {
        pair<int, int> job;
        cin >> job.first;
        cin >> job.second;
        jobs[i] = job;
    }

    sort(jobs.begin(), jobs.end(), [](pair<int, int> a, pair<int, int> b) {
        return a.second < b.second;
    });

    int sum_time = 0;

    rep(i, N) {
        sum_time += jobs.at(i).first;
        if (sum_time > jobs.at(i).second) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x(x % mod) {}

    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 >> 1);
        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;
    }
};

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(100005);

mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n, k);
    res *= comb.fact[k];
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<int> a(N + 1);
    vector<int> cnt(N + 1);
    rep(i, N + 1) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    vector<int> b;
    rep(i, N + 1) if (cnt[a[i]] == 2) b.push_back(i);
    int d = b[1] - b[0];

    for (int k = 1; k <= N + 1; k++) {
        ll ans = (comb(N + 1, k).x - comb(N - d, k - 1).x + mod) % mod;
        cout << ans << endl;
    }
}

Measured memory_bytes: 3584
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int n,m;
vector<pi> G[100010];
int dp[100010];
int used[100010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>n>>m;
	int a,b;
	rep(i,m){
		cin>>a>>b;
		a--,b--;
		G[b].pb(mp(a,i+1));
	}
	int M=0;
	rep(i,n){
		rep(j,sz(G[i])){
			dp[i]=max(dp[i],dp[G[i][j].fir]+1);
		}
		M=max(M,dp[i]);
	}
	vi v,w,ans;
	rep(i,n)if(dp[i]==M)v.pb(i);
	while(dp[v[0]]){
		//rep(i,sz(v))cout<<v[i]<<" ";cout<<endl;
		w.clear();
		rep(i,sz(v)){
			rep(j,sz(G[v[i]])){
				if(!used[G[v[i]][j].fir] && dp[G[v[i]][j].fir] == dp[v[i]]-1){
					w.pb(G[v[i]][j].fir);
					used[G[v[i]][j].fir]=1;
				}
			}
		}
		if(sz(v)==1 && sz(w)==1){
			rep(i,sz(G[v[0]])){
				if(dp[G[v[0]][i].fir] == dp[v[0]]-1){
					ans.pb(G[v[0]][i].sec);
				}
			}
		}
		v=w;
	}
	sort(ans.begin(),ans.end());
	if(sz(ans)==0)cout<<-1<<endl;
	else rep(i,sz(ans))cout<<ans[i]<<endl;
}

Measured memory_bytes: 7848
#include <bits/stdc++.h>
using namespace std;
#define xfor(i, a, b) for (int i = a; i < b; i++)
#define ifor(i, a, b) for (int i = a; i <= b; i++)
#define rxfor(i, b, a) for (int i = b; i > a; i--)
#define rifor(i, b, a) for (int i = b; i >= a; i--)
#define foreach(v, c)                                                          \
  for (typeof((c).begin()) v = (c).begin(); v != (c).end(); ++v)
#define all(a) a.begin(), a.end()
#define in(a, b) ((b).find(a) != (b).end())
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;

int main() {
  int n, m;
  cin >> n >> m;
  int x;
  int sum = 0;
  xfor(i, 0, m) {
    cin >> x;
    sum += x;
    if (sum > n) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << n - sum << endl;
}


Measured memory_bytes: 3592
n = int(input())
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

ans = 0
for i in range(n)[-1::-1]:
    val = B[i] - (A[i] + ans)%B[i]
    if val == B[i]:
        continue
    ans += val
    
print(ans)

Measured memory_bytes: 85300
using System;
using System.Text;

namespace ITP1_6_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var n = Convert.ToInt32(input[0]);
            var m = Convert.ToInt32(input[1]);
            var mat = new Matrix_NxM(n, m);
            var vec = new VectorM(m);

            for(int i = 0; i < n; i++)
            {
                input = Console.ReadLine().Split(' ');

                for (int j = 0; j < m; j++)
                {
                    mat[i, j] = Convert.ToInt32(input[j]);
                }
            }
            for(int i = 0; i < m; i++)
            {
                vec[i] = Convert.ToInt32( Console.ReadLine() );
            }

            Console.WriteLine(mat.Multiply(vec).ToString());
        }
    }

    public class Matrix_NxM
    {
        public int this[int n,int m] { get { return Values[n,m]; } set { Values[n,m] = value; } }
        public int[,] Values { get; protected set; }

        public Matrix_NxM(int dimN, int dimM)
        {
            Values = new int[dimN, dimM];
        }

        public VectorM Multiply(VectorM vec)
        {
            int dimN = Values.GetLength(0);
            int dimM = Values.GetLength(1);

            VectorM newVec = new VectorM(dimN);

            for (int i = 0; i < dimN; i++)
            {
                for(int j = 0; j < dimM; j++)
                {
                    newVec[i] += this[i, j] * vec[j];
                }
            }

            return newVec;
            
        }
    }

    public class VectorM
    {
        public int this[int index] { get { return Values[index]; } set { Values[index] = value; } }
        public int[] Values { get; protected set; }

        public VectorM(int dim)
        {
            Values = new int[dim];
        }

        public override string ToString()
        {
            var sb = new StringBuilder();
            foreach (var val in Values) sb.AppendLine(val.ToString());
            return sb.ToString().TrimEnd('\r', '\n');
        }
    }

}

Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
// Euclidean Algorithm
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}
int ctoi(char c) {if (c >= '0' && c <= '9') {return c - '0';}return 0;}


int main(){
  ll N, M; cin >> N >> M;
  ll ans = 0;
  if(N>=2 && M>=2) ans = (N-2)*(M-2);
  else if(N == 1 && M >= 2) ans = M-2;
  else if(M == 1 && N >= 2) ans = N-2;
  else if(N == 1 && M == 1) ans = 1;
  cout << ans << endl;
  return 0;
}

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

int main(){ 
  int D,N;
  cin >> D >> N;
  if(N==100){
    if(D==0) cout << 101 << endl;
    else if(D==1) cout << 10100 << endl;
    else cout << 1010000 << endl;
  }
  else{
    if(D==0) cout << N << endl;
    else if(D==1) cout << N*100 << endl;
    else cout << N*10000 << endl;
  }
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    K = int(input())
    A, B = map(int, input().split())
    if A % K == 0:
        print("OK")
    elif B // K == A // K:
        print("NG")
    else:
        print("OK")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9104
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

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

    int N;
    bool flag = false;
    cin >> N;
    for (int i = 0; i < N; i++) {
        char a;
        cin >> a;
        if (a == 'Y') flag = true;
    }

    if (flag) {
        cout << "Four" << endl;
    } else {
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque

def gcd(a, b):
    """最大公約数"""
    a, b = (a, b) if a >= b else (b, a)
    if b == 0:
        return a
    return gcd(b, a % b)


def prime_factorization(x):
    """素因数分解"""
    import math
    re = []
    i = 2
    while x != 1:
        if x % i == 0:
            re.append(i)
            x //= i
        else:
            i += 1
            if i > math.sqrt(x):
                re.append(x)
                break
    return re


# from decorator import stop_watch
#
#
# @stop_watch
def solve(A, B):
    div = gcd(A, B)
    print(len(set(prime_factorization(div))) + 1)


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    A, B = map(int, input().split())
    # As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    # print(prime_factorization(A))
    # print(prime_factorization(B))
    solve(A, B)


Measured memory_bytes: 9152
n=int(input())
a=list(map(int,input().split()))
cnt=0
maxi=0
for i in range(n-1):
    if a[i]>=a[i+1]:
        cnt+=1
        i+=1
    else:
        maxi=max(maxi,cnt)
        i+=1
        cnt=0
maxi=max(maxi,cnt)
print(maxi)

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

int N;
long long W, weights[100], values[100];

long long dp[101][100001] = {0};

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

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

    for (int i = 0; i < N; ++i) {
        for (int w = 0; w <= W; ++w) {

            if (w - weights[i] >= 0) {
                dp[i + 1][w] = max(dp[i + 1][w], dp[i][w - weights[i]] + values[i]);
            }

            dp[i + 1][w] = max(dp[i + 1][w], dp[i][w]);
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 78336
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


void solve()
{
	int k ;
	cin >>k ;
	int ans = inf ;
	for(int i = 1; i*i <= k ; ++i){
		if(k%i) continue ;
		ans = min(ans , i + k/i - 2);
	}
	cout << ans << endl ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

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

#define ll long long

using namespace std;

ll extgcd(ll a, ll b, ll &x, ll &y){
    ll d=a;
    if(b != 0){
        d = extgcd(b,a%b,y,x);
        y -= (a/b)*x;
    }else{
        x=1;
        y=0;
    }
    return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (x%m+m)%m;
}

int main(){
    int n;
    cin >> n;
    ll m1 = 999979, m2 = 999961;
    ll t1=0,t2=0;
    int op,y;
    for(int i=0;i<n;i++){
        cin >> op >> y;
        if(op == 1){
            t1 = (t1+y)%m1;
            t2 = (t2+y)%m2;
        }else if(op == 2){
            t1 = (t1-y%m1+m1)%m1;
            t2 = (t2-y%m2+m2)%m2;
        }else if(op == 3){
            t1 = (t1*y)%m1;
            t2 = (t2*y)%m2;
        }else{
            t1 = (t1*mod_inverse(y,m1))%m1;
            t2 = (t2*mod_inverse(y,m2))%m2;
        }
    }
    ll a,b;
    extgcd(m1,m2,a,b);
    ll res = (m1*t2*a+m2*t1*b)%((ll)m1*m2);
    if(res >= (1ll<<31)){
        res -= (ll)m1 * m2;
    }
    cout << res << endl;
}

Measured memory_bytes: 844
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int64_t mod(int64_t val, int64_t m){
    int64_t res = val%m;
    if(res<0) res+=m;
    return res;
}

int main(){
    int64_t k;
    int n,rev,loop; cin >> n >> k;
    vi a(n);
    for(int ix=0;ix<n;ix++){ cin >> a.at(ix); a.at(ix)--; }
    
    int cnt=0;
    map<int,int> ss; int pos = 0; ss[pos] = 0;
    while(true){
        pos = a.at(pos);
        cnt++;
        if(!ss.count(pos)) ss[pos] = cnt;
        else{
            loop = cnt - ss.at(pos);
            break;
        }
    }
    int tale = cnt-loop;
    if(k < tale){
      rev=k; pos=0;
      for(int ix=0;ix<rev;ix++) pos=a.at(pos);
    }
    else{
      rev = mod((k%loop) - ((int64_t)tale%loop),loop);
      for(int ix=0;ix<rev;ix++){
        pos = a.at(pos);
      }
    }
    cout << pos+1 << endl;
}


Measured memory_bytes: 13064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A,B,C,D;
  	cin>>A>>B>>C>>D;
  if(A+B>C+D){
    cout<<"Left"<<endl;
     }
  else if(A+B==C+D){
  	cout<<"Balanced"<<endl;
  }
  else{
  	cout<<"Right"<<endl;
  }
}

Measured memory_bytes: 256
let n, t = Scanf.scanf " %d %d" @@ fun a b -> a, b
let cts = Array.to_list @@ Array.init n @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a, b
let _ = match List.filter (fun (_, t0) -> t0 <= t) cts |> List.sort compare with
  | [] -> print_endline "TLE"
  | (c, _) :: _ -> Printf.printf "%d\n" c

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

#define endl "\n"
using namespace std;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	vector<int> arr;
	int n,aux;
	cin >> n;
	while(n--){
		cin >> aux;
		arr.push_back(aux);
	}
	int cont=0, max=0,actual=arr[arr.size()-1];
	for(int i=arr.size()-2;i>=0;i--){
		if(arr[i]>=arr[i+1]){
			cont++;
		}else{
			max=(max>cont)?max:cont;
			cont=0;
		}
	}
	max=(max>cont)?max:cont;
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 892
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <sstream>
#include <list>
//#include <array>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <iterator>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}

int is_palindrome(string &s) {
    int len = s.length();
    int ret = 0;
    for (int i = 0; i < len / 2; i++) {
        if (s[i] != s[len - i - 1]) 
            ret++;
    }
    return ret;
}

int main(void) {
    FAST_IO;
    
    string s;
    cin >> s;
    cout << is_palindrome(s) << endl;
    
    return 0;
}

Measured memory_bytes: 256