akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

using i64 = long long;
using u64 = unsigned long long;

const int mod = (int)1e9+7;

void __print() {cerr << "]\n";}

template<typename T, typename... V>
void __print(T t, V... v)
{ cerr << t; if(sizeof...(v)) cerr << ", "; __print(v...);}

#define dbg(x...) cerr << "[" << #x << "] = ["; __print(x);


int n, q;
vector<int> adj[210000];
i64 incr_val[210000];
int visited[210000];
i64 ans[210000];

void dfs(int u, i64 par_val)
{
    if(visited[u]) return;
    visited[u] = true;
    i64 val = par_val + incr_val[u];
    ans[u] = val;
    for(int to : adj[u]) {
        dfs(to, val);
    }
}

int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 0; i < n-1; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    while(q--) {
        int x;
        i64 y;
        scanf("%d%lld", &x, &y);
        incr_val[x] += y;
    }
    dfs(1, 0);
    for(int i = 1; i <= n; i++) printf("%lld ", ans[i]);
    puts("");
}


Measured memory_bytes: 25096
//g++ -std=c++17 -Wall t.cpp -o test -g -O2
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl '\n'
#define teto(a, b) (a+b-1)/(b)
 
const int MAX = 10000;
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-6;
const ld PI = acos(-1.0);

using namespace std;

// End - Template //

int main()
{sws;

    ll q, a, b, opt;
    ll B=0;
    multiset<ll> l, r;
    ll suml=0, sumr=0;
    cin >> q;
    while(q--){
        cin >> opt;
        if(opt==1){
            cin >> a >> b;
            B+=b;

            // cout << "ok\n";

            if(l.empty()){
                l.insert(a);
                suml+=a;
            }else if(a>=*(--(l.end()))){
                r.insert(a);
                sumr+=a;
            }else{
                l.insert(a);
                suml+=a;
            }
            while(!((int)l.size()==(int)r.size() or (int)l.size()==(int)r.size()+1)){
                // cout << "sz = " << l.size() << " " << r.size() << endl;
                if((int)l.size()>(int)r.size()+1){
                    auto it = l.end();
                    --it;
                    r.insert(*it);
                    sumr+=*it;
                    suml-=*it;
                    l.erase(it);
                }else if((int)r.size()>(int)l.size()){
                    auto it = r.begin();
                    l.insert(*it);
                    suml+=*it;
                    sumr-=*it;
                    r.erase(it);
                }
            }
        }else{
            auto it = l.end();
            --it;
            ll val1 = *it;

            ll ans = B;
            ans += (ll)l.size()*val1 - suml;
            ans += sumr - (ll)r.size()*val1;

            cout << val1 << " " << ans << endl;


        }

    }



    return 0;
}



Measured memory_bytes: 12888
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ret = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if a * 500 + b * 100 + c * 50 == X:
                ret += 1
print(ret) 

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

int main()
{
	int n;
	cin>>n;
	
	int cnt=0;
	
	int a;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(i%2 && a%2)
		{
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  int cnt = 0;
  while (A >= B || B >= C) {
    if (A >= B) {
      B *= 2, ++cnt;
    }
    if (B >= C) {
      C *= 2, ++cnt;
    }
  }

  if (cnt <= K) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
#include <stdio.h>
int main(){
  int N;
  int R, G, B;
  scanf("%d%d%d%d", &R, &G, &B, &N);
  int r, g;
  long ans=0;
  for(r=0; r<=N/R; r++){
    for(g=0; g<=N/G; g++){
      int n = N-r*R-g*G;
      if(n>=0 && n%B==0) ans++;
    }
  }
  printf("%ld\n", ans);
}


Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = 0;
  for (int i = 0; i <= 100; i++) {
    if (a <= i && c <= i && i <= b && i <= d) {
      ans++;
    }
  }
  cout << max(0LL, ans - 1) << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <stack>

using namespace std;

int main()
{
	stack<int> s;
	string x;
	int a, b;

	
	while (cin >> x) {
		if (x[0] == '+') {
			a=s.top(); s.pop();
			b = s.top(); s.pop();
			 s.push(a + b);
		}
		else if (x[0] == '-') {
			a = s.top(); s.pop();
			b = s.top(); s.pop();
			s.push(b - a);
		}
		else if (x[0] == '*') {
			a = s.top(); s.pop();
			b = s.top(); s.pop();
			s.push(a * b);
		}
		else {
			s.push(atoi( x.c_str() ));
		}
		
	}

	cout << s.top() << endl;
	return 0;
}




Measured memory_bytes: 3148
#include <bits/stdc++.h>
#include <string>
#include <string.h>
using namespace std;
int main ()
{
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	s1[0]=toupper(s1[0]);
	s2[0]=toupper(s2[0]);
	s3[0]=toupper(s3[0]);
	cout<<s1[0]<<s2[0]<<s3[0]<<endl;
}

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

typedef long long ll;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char a;
    cin >> a;
    if(isupper(a)){
        cout << "A" << endl;
    }else{
        cout << "a" << endl;
    }
}


Measured memory_bytes: 3652
#include<cstdio>
#include<queue>
#include<utility>
#include<algorithm>
using namespace std;
int n,two[30],a[300000],ans[300000],f;
pair<int,int> p[300000][2];
priority_queue<pair<int,int> > q;
int main(){
    two[0]=1;
    for(int i=1;i<30;i++){
        two[i]=2*two[i-1];
    }
    scanf("%d",&n);
    for(int i=0;i<two[n];i++){
        scanf("%d",&a[i]);
    }
    p[0][0].first=a[0];
    p[0][0].second=0;
    p[0][1].first=0;
    p[0][1].second=0;
    ans[0]=-1;
    for(int i=1;i<two[n];i++){
        q.push(make_pair(a[i],i));
        q.push(make_pair(a[0],0));
        for(int j=0;j<30;j++){
            if(i&two[j]){
                q.push(p[i^two[j]][0]);
                q.push(p[i^two[j]][1]);
            }
        }
        f=0;
        p[i][0]=q.top();
        q.pop();
        while(!q.empty()){
            if(f==0&&q.top()!=p[i][0]){
                f=1;
                p[i][1]=q.top();
            }
            q.pop();
        }
        ans[i]=p[i][0].first+p[i][1].first;
        ans[i]=max(ans[i],ans[i-1]);
    }
    for(int i=1;i<two[n];i++){
        printf("%d\n",ans[i]);
    }
}

Measured memory_bytes: 9344
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath> 
#include <cctype>

using namespace std;

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

    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        string s1 = s.substr(0, i);
        string s2 = s.substr(i, N - i);
        int count = 0;
        for (int ch = 'a'; ch <= 'z'; ch++) {
            int n1 = s1.find(ch);
            int n2 = s2.find(ch);
            if (n1 != string::npos && n2 != string::npos) {
                count++;
            }
        }
        ans = max(ans, count);
    }

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

Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,a[100005],b[100005],ans,x=1,y=1;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",a+i),b[i]=a[i];
    sort(b+1,b+n+1);
    n=(n+1)/2;
    for(int i=1;i<=n;++i)a[i]=a[i*2-1],b[i]=b[i*2-1];
    sort(a+1,a+n+1);
    ans=n;
    while(x<=n&&y<=n){
        if(a[x]==b[y]){
            ++x,++y,--ans;
            continue;
        }
        if(a[x]<b[y])++x;
        else ++y;
    }
    printf("%d\n",ans);
    //system("pause");
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include<string.h>
#include <math.h>
#include <stack>
#define ll long long
using namespace std;
typedef struct Node {
	int cnt, num;
	bool operator < (const Node &o)const {
		return num < o.num;
	}
};
int a[100010];
Node b[100010];
int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	for (int i = 0; i < m; i++)
		scanf("%d %d", &b[i].cnt, &b[i].num);
	sort(a, a + n);
	sort(b, b + m);
	int point = m-1;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		if (point == -1) {
			sum += a[i];
			continue;
		}
		if (b[point].cnt == 0) {
			point--;
			i--;
			continue;
		}
		if (a[i] >= b[point].num) {
			point--;
			sum += a[i];
		}
		else {
			a[i] = b[point].num;
			b[point].cnt--;
			sum += a[i];
		}
	}
	printf("%lld\n", sum);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, const vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int n, m;
int dp[9][1 << 9];

int solve(int v, int vis, const Graph& g)
{
	if (dp[v][vis] >= 0) return dp[v][vis];
	if (vis == (1 << n) - 1) return 1;
	int res = 0;
	for (auto e : g[v])
	{
		int u = e.to;
		if ((vis >> u) & 1) continue;
		res += solve(u, vis | (1 << u), g);
	}
	return dp[v][vis] = res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	cin >> n >> m;
	Graph g(n);
	REP(i, m)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		add_edge(g, a, b, 0);
		add_edge(g, b, a, 0);
	}
	MS(dp, -1);
	cout << solve(0, 1, g) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(all(a));
  sort(all(b));
  sort(all(c));

  ll ans = 0;
  rep(i, n)
  {
    auto itr1 = lower_bound(all(a), b[i]);
    ll d1;
    if (itr1 == a.begin())
    {
      continue;
    }
    else
    {
      itr1--;
      d1 = distance(a.begin(), itr1);
    }
    auto itr2 = upper_bound(all(c), b[i]);
    ll d2 = distance(itr2, c.end());
    ans += (d1 + 1) * d2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, x;
	bool valid = true;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> x;
		if (x % 2 == 0) {
			if ((x % 3 != 0) && (x % 5 != 0)) valid = false;
		}
	}
	if (valid) cout << "APPROVED\n";
	else cout << "DENIED\n";
	return 0;
}



Measured memory_bytes: 256
//Binary Search Tree 1
#include <stdio.h>
#include <stdlib.h>
struct node{
  int key;
  struct node *left,*right,*parent;
};
typedef struct node Node;
Node *rootnode;
Node *NIL;
void Insert(int );
void Preorder(Node *);
void Inorder(Node *);



int main(void){
  int n,i,key;
  char command[6];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",command);
    if(command[0]=='i'){
      scanf("%d",&key);
      Insert(key);
    }
    else if(command[0]=='p'){
      Inorder(rootnode);
      printf("\n");
      Preorder(rootnode);
      printf("\n");
    }
  }

  return 0;
}
void Insert(int key){
  Node *parent=rootnode;
  Node *z;
  Node *y=NIL;
  z=(Node *)malloc(sizeof(Node));
  z->key=key;
  z->left=NIL;
  z->right=NIL;

  while(parent!=NIL){
    y=parent;
    if(key > parent->key)
      parent=parent->right;
    else
      parent=parent->left;
  }
  if(y==NIL)rootnode=z;
  z->parent=y;
  if(y!=NIL){
    if(key > y->key)
      y->right=z;
    else
      y->left=z;
  }
}

void Preorder(Node *node){
  printf(" %d",node->key);
  if(node->left!=NIL)
    Preorder(node->left);
  if(node->right!=NIL)
    Preorder(node->right);
}

void Inorder(Node *node){
  if(node->left!=NIL)
    Inorder(node->left);
  printf(" %d",node->key);
  if(node->right!=NIL)
    Inorder(node->right);
}



Measured memory_bytes: 25148
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]

k = i()
lunlun_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
tmp_list = lunlun_list
tmp_tmp_list = []
cnt = 9
def lunlun(y):
    x = y[-1]
    if x == "0":
        tmp_tmp_list.append(y + "0")
        tmp_tmp_list.append(y + "1")
        return 2
    elif x == "9":
        tmp_tmp_list.append(y + "8")
        tmp_tmp_list.append(y + "9")
        return 2
    else:
        x = int(x)
        tmp_tmp_list.append(y + str(x - 1))
        tmp_tmp_list.append(y + str(x))
        tmp_tmp_list.append(y + str(x + 1))
        return 3

while len(lunlun_list) < k:
    for tmp in tmp_list:
        cnt += lunlun(str(tmp))
        if cnt >= k:
            break
    tmp_list = tmp_tmp_list
    lunlun_list += tmp_list
    tmp_tmp_list = []

lunlun_list = [int(i) for i in lunlun_list]
lunlun_list.sort()

print(lunlun_list[k - 1])

Measured memory_bytes: 84696
def main():

    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    dup = 0
    prev = 0
    for i in range(N):
        if A[i] == prev:
            dup += 1
        prev = A[i]
    if dup % 2 == 0:
        return N-dup
    else:
        return N-dup-1


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 52788
s = str(input())
an = ["-" for i in range(len(s))]
ans = 0
ch = ["A","G","T","C"]
for i in range(len(s)):
    if s[i] in ch:
        an[i] = "1"
    else:
        an[i] = "0"
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        if an[i:j] == ['1' for i in range(len(an[i:j]))]:
            ans = max(ans,len(an[i:j]))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

//--global--//

int n;
int maxDep = 0;
int aaa[3] = {7, 5, 3};

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

int rec(int dep, int val, int used){
    if(maxDep == dep){
        if(val <= n && (used == 7)){
            //cout << val << endl;
            return 1;
        }
        else{
            return 0;
        }
    }
    int res = 0;
    int tmp = val;
    rep(i, 3){
        val *= 10;
        val += aaa[i];
        //cout << val << ", " << used << endl;
        res += rec(dep+1, val, used | 1 << i);
        val = tmp;
    }
    if(val <= n && (used == 7)){
        //cout << val << endl;
        res++;
    }
    return res;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//
    
    cin >> n;
    int tmp = n;
    while(tmp > 0){
        tmp /= 10;
        maxDep++;
    }

    cout << rec(0, 0, 0) << endl;
    
    return 0;
}


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

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	std::string S;
	std::cin >> S;
	std::vector<int> num;
	num.push_back(0);
	S = '1' + S;
	for (unsigned int i{1}; i < S.size(); i++)
	{
		if (S[i] == S[i - 1]) num.back()++;
		else num.push_back(1);
	}
	if (S.back() == '0') num.push_back(0);
	if (2 * (unsigned int)K + 1 >= num.size())
	{
		printf("%d\n", N);
		return 0;
	}
	int sum{}, max{};
	for (int i{}; i < 2 * K + 1; i++)
		sum += num[i];
	max = sum;
	for (int i{}; i + 2 * K + 1 < (int)num.size(); i += 2)
	{
		sum -= num[i] + num[i + 1];
		sum += num[i + 2 * K + 1] + num[i + 2 * K + 2];
		max = std::max(sum, max);
	}
	printf("%d\n", max);

	return 0;
}

Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int A,B,C,D,E,F; cin >> A >> B >> C >> D >> E >>F;

    double ma = 0;
    int water = 0, sugar = 0;
    int mawa = 0, masu = 0;
    for (int i = 0; i < (ll)ceil(F/((double)A * 100)); i++) {
        for (int j = 0; j < (ll)ceil(F/((double)B * 100)); j++) {
            if (i + j == 0) continue;
            water = i * A * 100 + j * B * 100; 
            if (water > F) break;
            for (int k = 0; water + k * C < F; k++) {
                for (int l = 0; ; l++) {
                    sugar = k * C + l * D;
                    if (water * E < sugar * 100) break;
                    if (water + sugar > F) break;
                    if (water * E == 100 * sugar) {
                        mawa = water;
                        masu = sugar;
                        goto END;
                    }
                    double c = 100 * (double)sugar / (water + sugar);
                    if (ma <= c) {
                        ma = c;
                        mawa = water;
                        masu = sugar;
                    }
                }
            }
        }
    }
END:
    cout << mawa + masu << " " << masu << endl;
}

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

int main()
{
	double x1,y1,x2,y2;
	double ans=0,x=0,y=0;

	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	if(x1>x2) x=x1-x2;
	else if(x1<x2) x=x2-x1;
	
	if(y1>y2) y=y1-y2;
	else if(y1<y2) y=y2-y1;

	ans = (x*x)+(y*y);
	ans = sqrt(ans);
	printf("%.8lf\n",ans);

	return 0;
}

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (l, r, d) = [int(e) for e in lines[0].split(' ')]

    return (l, r, d)


def solve(l, r, d):

    cnt = 0    
    for i in range(l, r+1):
        if i % d == 0:
            cnt = cnt + 1

    return cnt
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 62080
#include <bits/stdc++.h>
const long long mod=1e9+7;
#define ll long long
using namespace std;
int lim=0;

/*ll power(ll n)
{
    if(n==0) return 0%mod;
    if(n==1) return 1%mod;
    return ((power(n-1)%mod) + (power(n-2)%mod ))%mod;
}
int main()
{
    ll n;cin>>n;
    cout<<power(n%mod)%mod;
}*/
ll pw(ll x,ll n)
{
    ll res=1;
    while(n)
    {
        if(n&1) res=res*x*1ll%mod;
        x=x*x*1ll%mod;
        n/=2;
    }return res;
}
int main()
{
    int i,n,s=0;scanf("%d",&n);
    char a[n],t;
    scanf("%s",a);
    t=a[0];
    for(i=0;i<n;i++)
    {
        if(a[i]==t) s=s;
        else
        {
            s++;
            t=a[i];
        }
    }printf("%d",s+1);
}
// C++ program to find sum of two large numbers.
/*#include<bits/stdc++.h>
using namespace std;

// Function for finding sum of larger numbers
string findSum(string str1, string str2)
{
    // Before proceeding further, make sure length
    // of str2 is larger.
    if (str1.length() > str2.length())
        swap(str1, str2);

    // Take an empty string for storing result
    string str = "";

    // Calculate length of both string
    int n1 = str1.length(), n2 = str2.length();

    // Reverse both of strings
    reverse(str1.begin(), str1.end());
    reverse(str2.begin(), str2.end());

    int carry = 0;
    for (int i=0; i<n1; i++)
    {
        // Do school mathematics, compute sum of
        // current digits and carry
        int sum = ((str1[i]-'0')+(str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');

        // Calculate carry for next step
        carry = sum/10;
    }

    // Add remaining digits of larger number
    for (int i=n1; i<n2; i++)
    {
        int sum = ((str2[i]-'0')+carry);
        str.push_back(sum%10 + '0');
        carry = sum/10;
    }

    // Add remaining carry
    if (carry)
        str.push_back(carry+'0');

    // reverse resultant string
    reverse(str.begin(), str.end());

    return str;
}

// Driver code
int main()
{
    string str1 ,str2 ;
    cin>>str1>>str2;
    cout << findSum(str1, str2);
    return 0;
}
*/
// CPP program to find (a^b) % MOD where a and
// b may be very large and represented as strings.




Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> tree(n);
  for(int i = 0;i < n;i++)cin >> tree[i];
  sort(tree.begin(),tree.end());
  int res = 0;
  res = INT_MAX;
  for(int i = 0;i <= n - k;i++){
    res = min(res,tree[i + k - 1] - tree[i]);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define lp(i,n) for(int i=0;i<(n);i++)
#define lps(i,j,n) for(int i=j;i<n;i++)

#define fordebug int hoge;cin>>hoge;

#define DEKAI 1000000007
#define floot10 cout<<fixed<<setprecision(15)
#define all(v) v.begin(),v.end()
double PI = acos(-1);

signed main(){
  int n,m;
  cin>>n>>m;

  //mの約数を探す
  vector<int> yakusuu;
  for(int i=1;i*i<=m;i++){
    if(m%i==0){
      //割り切れるなら、iとm/iが約数
      yakusuu.push_back(i);
      yakusuu.push_back(m/i);
    }
  }
  //ソートする(小さい順になる)
  sort(yakusuu.begin(),yakusuu.end());
  
  // m/n以下の中で一番大きいのを探す。
  // x*n<=m
  int ans=1;
  for(int i=0;i<yakusuu.size();i++){
    if(yakusuu[i]*n<=m)ans=yakusuu[i];
    else break;
  }
  cout<<ans<<endl;
  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  char c;
  REP(i,3){
    cin >> c;
    if(c=='1')cout << 9;
    else if(c=='9')cout << 1;
    else cout << c;
  }
  cout << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
//#define M   1000000007 // 1e9 + 7
#define MAXN 300100
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
	
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}

int A[] = {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};

int32_t main(){
	fastio;
	
	int k;
	cin>>k;
	cout<<A[k-1]<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

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

//想定解答との絶対誤差または相対誤差が 10−6以下の場合+1以上だしておく。適当に15とかでもおｋ．
//cout << fixed << setprecision(15);

int main() {
    string s;
    int k;
    cin >> k;
    //vector<vector<int>> data(3, vector<int>(4));
    //初期値0
    //vector<int> data(i, 0);
    int x[] = { 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};
    cout << x[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase >= 0;testcase++){
    int3(m, nin, nax); if(!(m|nax|nin))break;
    int p[m]; scn(m, p);

    int res = 0, resi;
    nin--; nax--;
    for(i = nin;i <= nax;++i){
      if(res <= p[i] - p[i + 1]){ res = p[i] - p[i + 1]; resi = i + 1; }
    }
    pri(resi);


//*/

//*/ break;
  }
  return 0;
}

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

int main()
{
  int n;cin>>n;
  string s;cin>>s;
  int i,j;
  int q;cin>>q;
  vector<set<int>> sets(26);
  for(i=0;i<n;i++)
  {
    sets.at(s.at(i)-'a').insert(i);
  }
  for(i=0;i<q;i++)
  {
    int num;cin>>num;
    if(num==1)
    {
      int ind;
      char c;
      cin>>ind>>c;
      for(j=0;j<26;j++)sets.at(j).erase(ind-1);
      sets.at(c-'a').insert(ind-1);
    }
    else if(num==2)
    {
      int l,r;cin>>l>>r;
      int kind=0;
      for(j=0;j<26;j++)
      {
        auto it=sets.at(j).lower_bound(l-1);
        if(it!=sets.at(j).end()&&*it<=r-1)kind++;
      }
      cout<<kind<<endl;
    }
  }
}


Measured memory_bytes: 24196
import sys
sys.setrecursionlimit(10 ** 6)

def main():
    S = input()
    T = input()
    pair1 = {}
    pair2 = {}
    for i in range(len(S)):
        if S[i] not in pair1.keys():
            pair1[S[i]] = T[i]
        else:
            if pair1[S[i]] != T[i]:
                print('No')
                return
        if T[i] not in pair2.keys():
            pair2[T[i]] = S[i]
        else:
            if pair2[T[i]] != S[i]:
                print('No')
                return
        
    print('Yes')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3632
//vansh
#include <stdio.h>
 int main(void){
 int a, b, c;

 scanf("%d%d%d", &a, &b, &c);

 int ispoor = 0;
 if (a == b && b != c) ispoor = 1;
 if (b == c && c != a) ispoor = 1;
 if (c == a && a != b) ispoor = 1;

 if (ispoor) {
 puts("Yes");
 } else {
 puts("No");
 }

 return 0;
}

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

using ll = long long int;
using vi = vector<int>;
using vii = vector<vi>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  int n, shurui = 0;
  map<int, int> DATA;
  scanf("%d", &n);
  REP(i, n){
    int tmp;
    scanf("%d",&tmp);
    if(DATA[tmp] == 0){
      shurui++;
      DATA[tmp] = 1;
    }
  }
  if((n - shurui) % 2 == 1){
    shurui--;
  }
  cout << shurui << "\n";
  return 0;
}

Measured memory_bytes: 4992
use proconio::input;
use num_rational::Rational64;

fn main() {
    input! {
        a: i64,
        b: String,
    }

    let b_arr: Vec<_> = b.split('.').collect();
    let b_int: i64 = b_arr[0].parse().unwrap();
    let b_int: Rational64 = b_int.into();
    let b_dec_l = b_arr[1].len();
    let b_dec_num: i64 = b_arr[1].parse().unwrap();
    let b_dec = Rational64::new(b_dec_num, 10i64.pow(b_dec_l as u32));
    let b = b_int + b_dec;
    let a: Rational64 = a.into();
    let ans = (a * b).floor();
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 177, task a, 2020/08/30
//ms,
/*
*/

struct UnionFind{
  //各頂点の親のid。親がいないなら、子の頂点数に-1をかけた値。このvectorで木を表現。
  vector<int> r;

  //コンストラクタ
  UnionFind(int N){
    r = vector<int>(N, -1);
  }

  //入力：頂点ラベル。出力：最上位の親id。入力自身でもありうる。ついでにグラフの縮約も。
  int root(int v){
    if(r[v]<0) return v;
    else{
      r[v]=root(r[v]);
      return r[v];
    }
  }

  //入力：二つの頂点ラベル。出力：併合可否。(もともと同じ集合ならfalse)。
  //入力の頂点についてはグラフの縮約をする。さらにそれぞれの頂点の集合を併合する。
  bool unite(int x, int y){
    x=root(x);
    y=root(y);
    //すでに同所属
    if(x==y) return false;

    //異所属の場合、併合。小さい方を大きい方に入れる(これは大事)
    if(abs(r[x]) < abs(r[y]) ) swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }

  int size(int x){
    return -r[root(x)];
  }
};

int main(void){
  int N, M;
  int ans=1;

  cin >>N >>M;
  UnionFind friends(N);
  for(int i=0;i<M;i++){
    int a, b;
    cin >>a >>b;
    friends.unite(a-1, b-1);
  }

  for(int i=0;i<N;i++){
    ans = max(ans, friends.size(i));
  }

  cout <<ans<<endl;
  return 0;
}
/*
幅優先探索だけじゃなくて、ユニオンファインド木もやるよー。
ユニオンファインド木はグループわけを表現できます。
所属判定も当然できます。超高速で、logNよりさらに速いです(適切な実装のもと)。
グループの大きさも返せます。
*/


Measured memory_bytes: 4056
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int max = a[0];
	for (int i = 1; i < 3; ++i)
	{
		a[0] += a[i];
		if (a[i] > max)max = a[i];
	}


	cout << a[0]-max << "\n";

	return 0;
}


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

using namespace std;

#define For(i,a,b) for(int i = a ; i <= b ; ++ i)
#define int long long

const int N = 5002 , mod = 1e9 + 7;

int n , f[N][N];
string s;

int cal(int a ,int b){
	if(b == 0) return 1;
	int res = cal(a,b/2);
	res = (res * res) % mod;
	if(b%2) res = (res * a) % mod;
	return res;
}
signed main(){
	cin >> n >> s;
	int len = s.length();
	int sum = 1;
	For(i,1,len) sum = (sum * 2) % mod;
	f[0][0] = 1;
	For(i,1,n){
		For(j,0,n){
			if( j == 0) f[i][j] = ( f[i - 1][j] + f[i - 1][j + 1] ) % mod;
			else f[i][j] = (f[i - 1][j - 1] * 2 + f[i - 1][j + 1]) % mod;		
		}
	}
	int ans = f[n][len] * cal(sum , mod - 2) % mod;
	cout << ans;	
}	

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

int b[2525][2525], s[4334][4334];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, x, y;
	char c;
	cin>>n>>k;
	int l=k<<1;
	REP(i, n){
		cin>>x>>y>>c;
		if(c=='W'){
			y+=k;
		}
		++b[x%l][y%l];
	}
	int m=l<<1;
	REP(i, m){
		REP(j, m){
			s[i+1][j+1]=s[i+1][j]+b[i%l][j%l];
		}
	}
	REP(j, m){
		REP(i, m){
			s[i+1][j+1]+=s[i][j+1];
		}
	}
	int ans=0;
	REP(i, l){
		REP(j, l){
			int cnt1=s[i+k][j+k]-s[i][j+k]-s[i+k][j]+s[i][j];
			int cnt2=s[i+l][j+l]-s[i+k][j+l]-s[i+l][j+k]+s[i+k][j+k];
			CHMAX(ans, cnt1+cnt2);
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 92416
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int gcd(int a, int b) {
  int d=a;
  if (b!=0) {
    d=gcd(b,a%b);
  }
  return d;
}

int main() {
  ll A,B,C,D;
  cin >> A >> B >> C >> D;
  ll m=B/C-(A-1)/C;
  ll n=B/D-(A-1)/D;
  ll mn=B/(C*D/gcd(C,D))-(A-1)/(C*D/gcd(C,D));
  cout << B-A+1-(m+n-mn) << endl;
}

Measured memory_bytes: 3576
#include <stdio.h>
int main(){
    long n;
    long a[10000];
    int i;
    long total = 0;
    long min, max;
    scanf("%ld", &n);
    for(i=0;i<n;i++){
        scanf("%ld", &a[i]);
        total += a[i];
    }
    min = max = a[0];
    for(i=0; i<n; i++){
        if(max < a[i]){
            max = a[i];
        }else if(min > a[i]){
            min = a[i];
        }
    }
    printf("%ld %ld %ld\n", min, max, total);
    return 0;
}


Measured memory_bytes: 2092
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, p;
int ans = 1;
vector<int> pr;
int32_t main() {
	cin >> n >> p;
	int x = p ;
	for(int i = 2; i * i <= x; i++) {
		if(x % i == 0) {
			pr.push_back(i);
			while (x % i == 0) x /= i ;
		}
	}
	if (x > 1) 
		pr.push_back(x);
	for(int i = 0; i < pr.size(); i++) {
		int tmp = pr[i];
		int res = 0;
		int nn = p;
		while(nn % tmp == 0) {
			nn /= tmp;
			res++;
		}
		int x = floor(res / n);
		for(int j = 0; j < x; j++)
			ans *= tmp;
	}
	cout << ans;
}

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

using ll = long long;

int n, s;

const ll kMod = 998244353ll;
const ll kInv = 499122177ll;

ll base = 1;

ll memo[3005][3005];
int arr[3005];

ll rek(int x, int rem) {
	if (rem < 0) return 0;
	if (x == n) {
		if (rem == 0) return base;
		return 0;
	}
	ll &res = memo[x][rem];
	if (res != -1) return res;
	res = rek(x + 1, rem);
	// take
	res += rek(x + 1, rem - arr[x]) * kInv % kMod;
	res %= kMod;
	return res;
}

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

	cin >> n >> s;

	for (int i = 0; i < n; ++i) {
		base *= 2;
		base %= kMod;
	}

	memset(memo, -1, sizeof(memo));

	for (int i = 0; i < n; ++i) cin >> arr[i];


	cout << rek(0, s) << '\n';


	return 0;
}

Measured memory_bytes: 74384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int K, A, B;

int main() {
  INCANT;
  cin >> K >> A >> B;
  bool flag = false;
  for (int i=A; i<=B; i++) {
    if (i%K==0) flag = true;
  }
  string ans = flag?"OK":"NG";
  cout << ans << "\n";
  return 0;
}

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

int main(){
	int n, i, j;
	int cards [4] [13] = {0};
	char suit; //?????????
	int num;
	
	cin >> n;
	
	for(i = 0; i < n; i++){
		cin >> suit >> num;
		
		if(suit == 'S'){
			cards[0][num - 1]++;
		}else if(suit == 'H'){
			cards[1][num - 1]++;
		}else if(suit == 'C'){
			cards[2][num - 1]++;
		}else{
			cards[3][num - 1]++;
		}
	}
		
	for(i = 0; i < 4; i++){
		for(j = 0; j < 13; j++){
			if(cards[i][j] == 0){
				if(i == 0){
					cout << 'S' << " " << j + 1 << endl;
				}else if(i == 1){
					cout << 'H' << " " << j + 1 << endl;
				}else if(i == 2){
					cout << 'C' << " " << j + 1 << endl;
				}else{
					cout << 'D' << " " << j + 1 << endl;
				}
			}
		}
	}

	
    return 0;
}

Measured memory_bytes: 3080
N=int(input())
A=list(map(int,input().split()))
ans = sum(A)

for i in range(N):
  S=sum(A[:i])
#  print(A[0:i])
  T=sum(A[i:])
#  print(A[i:N])
  ans = min(ans,abs(S-T))

print(ans) 

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1e+9 + 7;
// constexpr int mod = 998244353;

template<typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;      // モノイドに対して二項演算を行う関数オブジェクト
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
        sz = 1;
        while(sz < n)   sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x){
        seg[k + sz] = x;
    }

    void build(){
        for(int k = sz - 1; k > 0; --k){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    void update(int k, const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    Monoid query(int a, int b){
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
            if(a & 1)   L = f(L, seg[a++]);
            if(b & 1)   R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const{
        return seg[k + sz];
    }
};

vector<vector<P>> input;

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

    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    for(int i = 0; i < A; ++i)  cin >> a[i];
    for(int i = 0; i < B; ++i)  cin >> b[i];
    input.resize(A);
    for(int i = 0; i < M; ++i){
        int x, y, c;
        cin >> x >> y >> c;
        --x, --y;
        input[x].push_back(P(y, c));
    }

    SegmentTree<int> seg(B, [](int u, int v){return min(u, v);}, INF);
    for(int i = 0; i < B; ++i)  seg.update(i, b[i]);
    int res = 1e+7;
    for(int i = 0; i < A; ++i){
        int sz = input[i].size();
        if(sz == 0){
            int foo = a[i] + seg.query(0, B);
            chmin(res, foo);
        }
        else{
            for(int j = 0; j < sz; ++j){
                int y = input[i][j].first, c = input[i][j].second;
                int foo = a[i] + seg.query(0, y);
                chmin(res, foo);
                foo = a[i] + seg.query(y + 1, B);
                chmin(res, foo);
                foo = a[i] + seg[y] - c;
                chmin(res, foo);
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

int main(){
	int n;
	cin>>n;
	char a[n];
	int x=0;
	int k=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]=='I'){
			x++;
			}
		else{
			x--;
			}
		if(k<x){
			k=x;
			}
		}
	cout<<k<<endl;
	}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n, m, l;
	cin >> n >> m >> l;
	int matrixA[100][100] = { 0 }, matrixB[100][100] = { 0 };
	long matrixC[100][100] = { 0 };
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> matrixA[i][j];

	for (int i = 0; i < m; i++)
		for (int j = 0; j < l; j++)
			cin >> matrixB[i][j];

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < l; j++)
		{
			for(int k = 0;k < m;k++)
			{
				matrixC[i][j] += matrixA[i][k] * matrixB[k][j];
			}
			if (j != l - 1)
				cout << matrixC[i][j] << " ";
			else
				cout << matrixC[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3264
#include  <iostream>
#include  <vector>
#include  <string>

using namespace std;
typedef long long ll;
const ll aa = static_cast <ll> (1e9 + 7);

int main()
{
	string s;
	cin >> s;
	int cnt = s.size();
	vector < vector<ll> > dp(cnt + 1, vector <ll>(13, 0));
	
	dp[0][0] = 1;  //最上位桁0として初期化
	for (int i = 0; i < cnt; i++) {
		int c;
		if (s[i] != '?') c = s[i] - '0';
		else  c = -1;

		for (int k = 0; k < 10; k++) {
			if (c != -1 && c != k)  continue;
			for (int j = 0; j < 13; j++) {
				dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
			}
		}
		for (int p = 0; p < 13; p++)  dp[i + 1][p] %= aa;
	}
	cout << dp[cnt][5] << endl;
}

Measured memory_bytes: 13696