akhauriyash/Code-Regression huggingface dataset:
/*
h3110_fr13nd,
 
AUTHOR : @sam_jn
*/
 
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<pair<int, int>, null_type, less_equal<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define NN 1000002
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot(a, n) for(int i = 0; i < n; i++) cout << a[i] << " ";
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int prime[NN];
int find(int i);  
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}
void init();
int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[8] = {-1, 1, 0, 0, 1, -1, 1, -1};
//----------------------------------SOLUTION-BELOW-------------------------------------------// 

void solve(){
    ll a;
    cin >> a;
    cout << a + a*a + a*a*a;
}
int main(){


                                                            // #ifndef ONLINE_JUDGE    
                                                            // freopen("/home/samyak/Desktop/CP/input.txt", "r", stdin);
                                                            // freopen("/home/samyak/Desktop/CP/output2.txt", "w", stdout);
                                                            // #else
                                                            // // online submission
                                                            // #endif
// 

    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}
 
 
//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;    
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)  
{  
    if (baap[i] != i)  
        baap[i] = find(baap[i]);  
  
    return baap[i];  
}
 
bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}
void init(){
  for(ll i = 2; i < NN; i++){
      if(prime[i]) continue;
      for(ll j = 2*i; j < NN; j += i)
          prime[j] = i;
  }
}

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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=3e5+10;
struct Interval{int l,r,len;}itv[MAXN];
int n,m,res,bit[MAXN];

bool cmp(Interval a,Interval b)
{return a.len<b.len;}
void Update(int k,int x)
{while(k<=m) bit[k]+=x,k+=k&(-k);}
int Query(int k)
{int ret=0;while(k) ret+=bit[k],k-=k&(-k);return ret;}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&itv[i].l,&itv[i].r),itv[i].len=itv[i].r-itv[i].l+1;
	sort(itv+1,itv+n+1,cmp);
	
	int k=1;
	for(int i=1;i<=m;i++)
	{
		while(itv[k].len<=i&&k<=n)
			Update(itv[k].l,1),Update(itv[k].r+1,-1),k++;
		res=n-k+1;
		for(int j=i;j<=m;j+=i)
			res+=Query(j);
		printf("%d\n",res);
	}
	return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9



int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N){
    cin >> a[i];
  }
  int cnt = 0;
  REP(i, N-1){
    if(a[i] == a[i+1]){
      cnt++;
      a[i+1] = -1;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#scipy.sparse import csr_matrix
#scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
    N,x,*a=map(int,read().split())
    t=0
    ans=0
    for i in range(N-1):
        now=max(0,a[i]-t)
        t=max(0,now+a[i+1]-x)
        ans+=t
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 12496
n = int(input())
s = [input() for i in range(n)]
lst = []
for i in range(ord("a"),ord("z")+1):
    m = 0
    for j in range(n):
        cnt = 0
        for k in range(len(s[j])):
            if i == ord(s[j][k]):
                cnt += 1
        if j == 0:
            m = cnt
        else:
            m = min(m, cnt)
    lst.append(m)

ans = ""
for i in range(26):
    ans += chr(ord("a")+i)*lst[i]

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
using namespace std;

typedef long long llong;
// -2.1e-9 <= int <= 2.1e9

int main()
{
    size_t N; cin >> N;
    vector<int> A(N, 0);

    bool judge = true;
    for (size_t i=0; i<N; i++) {
        cin >> A[i];
        if ((A[i] % 2) == 0) {
            if ( ((A[i] % 3) != 0) && ((A[i] % 5) != 0) ){
                judge = false;
                break;
            }
        }
    }

    if (judge == true) {
        cout << "APPROVED" << endl;
    }
    else {
        cout << "DENIED" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long n;
  cin>>n;
  if(n % 4 == 0 ||n % 7 == 0)
  {
    cout<<"Yes";
    return 0;
  }
  while(n % 7 != 0 &&n > 0)
  {
    n-=4;
  }
  if(n % 7 == 0)
  {
    cout<<"Yes";
  }else
  {
    cout<<"No";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 1000;
char s[maxn + 1];
int cnt[256];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> s;
    for(int i = 0; s[i]; i += 1) cnt[s[i]] = 1;
    cout << ((cnt['N'] ^ cnt['S']) + (cnt['W'] ^ cnt['E']) ? "No" : "Yes");
    return 0;
}

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


using namespace std;


int main() {

	int H, W, xkey, ykey;
	cin >> H >> W;
	vector<string> S(H);

	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}

	int i = 0;

	while (i != S.size()) {
		xkey = 0;
		for (int j = 0; j < S[0].size(); j ++) {
			if (S[i][j] == '.') {
				xkey++;
			}
		}
		if (xkey == S[0].size()) {
			S.erase(S.begin() + i);
		}
		else {
			i++;
		}
	}
	
	int j = 0;

	while (j != S[0].size()) {
		ykey = 0;
		for (int i = 0; i < S.size(); i++) {
			if (S[i][j] == '.') {
				ykey++;
			}
		}
		if (ykey == S.size()) {
			for (int i = 0; i < S.size(); i++) {
				S[i].erase(j, 1);
			}
		}
		else {
			j++;
		}
	}


	for (int i = 0; i < S.size(); i++) {
		cout << S[i] << "\n";
	}


	return 0;
}


Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=3005;
const int mod=1e9+7;

string a,b;
int dp[N][N];
int rec(int i,int j){
    if(i==a.size() or j==b.size()) return 0;
    int &cache=dp[i][j];
    if(cache!=-1) return cache;
    if(a[i]==b[j]) return cache=1+rec(i+1,j+1);
    return cache=max(rec(i+1,j),rec(i,j+1));
}
void path(int i,int j){
    if(i==a.size() or j==b.size()) return;
    int ans=dp[i][j];
    if(a[i]==b[j]){
        cout<<a[i];
        return path(i+1,j+1);
    }
    else{
        if(ans==dp[i+1][j]) return path(i+1,j);
        return path(i,j+1);
    }
}
signed main(){
    FastIO;
    cin>>a>>b;
    memset(dp,-1,sizeof dp);
    rec(0,0);
    path(0,0);
    return 0;
}


Measured memory_bytes: 35968
#include <stdio.h>
#define H 500001

int n;

int maxHeapify(int A[], int i){
    int l, r, largest, temp;
    l = 2*i;
    r = 2*i + 1;
    if(l<=n && A[l]>A[i])    largest = l;
    else    largest = i;
    if(r<=n && A[r]>A[largest]) largest = r;
    if(largest!=i){
        temp = A[i];
        A[i] = A[largest];
        A[largest] = temp;
        maxHeapify(A, largest);
    }
    
}

int buildMaxHeap(int A[]){
    int i;
    for(i=n/2; i>0; i--)    maxHeapify(A, i);
}

int main(){
    int i, A[H];
    scanf("%d",&n);
    for(i=0; i<n; i++)  scanf("%d",&A[i+1]);
    
    buildMaxHeap(A);
    
    for(i=0; i<n; i++)
    printf(" %d",A[i+1]);
    printf("\n");
    
    return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
ll arr[3];
int main(){
	memset(arr,0,sizeof(arr));
	ll n,a,b;
	cin>>n>>a>>b;
	for(int i=0;i<n;i++){
		int m;
		cin>>m;
		if(m<=a)
			arr[0]++;
		else if(m>=a+1&&m<=b)
			arr[1]++;
		else if(m>=b+1)
			arr[2]++;
	}
	sort(arr,arr+3);
	printf("%lld",arr[0]);
} 

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

#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
const mint inv9 = mint(1)/9; // 9の逆元
// モノイドの構成
struct S{ // モノイドの型
	mint x, w;
	S(mint x=0, mint w=1): x(x), w(w) {}
};
S op(S a, S b){ return S(a.x*b.w + b.x, a.w*b.w); } // ・:S*S->S 関数
S e(){ return S(); } // 単位元
using F = int; // 写像の型
S mapping(F f, S x){ // f(x) 関数
	if(f == 0) return x;
	return S((x.w-1)*inv9 * f, x.w);
}
F composition(F f, F g){ // f・g 関数
	if(f == 0) return g;
	return f;
}
F id(){ return 0; }
// (1) lazy_segtree<S, op, e, F, mapping, composition, id> seg(int n);
using LZ_SegT = lazy_segtree<S, op, e, F, mapping, composition, id>;

int main(){
	int N, Q; cin>>N>>Q;
	LZ_SegT lz(N); // init
	// void seg.set(int p, S x) : a[p] = x
	rep(i, N) lz.set(i, S(1, 10)); // a[0,N) = S
	rep(q, Q){
		int l, r; F d; cin>>l>>r>>d;
		// (2) void seg.apply(int l, int r, F f) : i:[l,r) -> a[i] = f(a[i])
		lz.apply(l-1, r, d); // [l-1,r) の範囲を d で更新
		// S seg.prod(int l, int r) : op(a[l], ..., a[r - 1])
		S ans = lz.prod(0, N); // op を [0,N) の範囲で実行して取得
		cout<< ans.x.val() <<endl;
	}
}


Measured memory_bytes: 9908
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <math.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<1||a>9||b<1||b>9){
        cout<<-1<<endl;
        return 0;
    }else{
        cout<<a*b<<endl;
        return 0;
    }
}


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

typedef long long ll;

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

    for(int i=0;;i++){
        int h,w; 
        cin >> h >> w;
        if(h==0 && w==0) break;
        for(int j=0;j<h;j++){
            for(int k=0;k<w;k++){
                if(j==0 || j==h-1) cout << '#';
                else if(k==0 || k==w-1) cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3176
N = int(input())
s = input()
t = input()

if s == t:
    print(N)
    exit()

res = 0
for i in range(N):
    if s[i:] == t[:N-i]:
        res = i
        break

if res == 0:
    print(len(s + t))
else:
    ans = s[:res] + t
    print(len(ans))

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

int memo[500][500];

bool check(string str, int start)
{
	bool flag = false;

	if (str.empty() == true) {
		flag = true;
	}
	else {
		if (memo[start][str.size()] == 1) {
			return true;
		}
		else if (memo[start][str.size()] == 0) {
			return false;
		}
		else {
			if (str.front() == 'm'&&str.back() == 'w') {
				for (int i = 0; i < str.size(); i++) {
					if (str[i] == 'e') {
						if (check(str.substr(1, i - 1), start + 1) && check(str.substr(i + 1, str.size() - i - 2), start + i + 1)) {
							flag = true;
							break;
						}
					}
				}
			}
		}
	}

	if (flag == true) {
		memo[start][str.size()] = 1;
	}
	else {
		memo[start][str.size()] = 0;
	}

	return flag;
}

int main()
{
	for (int i = 0; i < 500; i++) {
		for (int j = 0; j < 500; j++) {
			memo[i][j] = -1;
		}
	}

	string S;
	cin >> S;

	bool flag = check(S, 0);

	if (flag == true) {
		cout << "Cat" << endl;
	}
	else {
		cout << "Rabbit" << endl;
	}

	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<ll, char> pc; 

const ll Mod = 10889;
const ll Delta = 10889;
const int Maxn = 3e3 + 10;
const int Maxm = 1e3 + 10;
const ll Inf = 1e16;

bool d[10];

bool check(ll x){
	while(x){
		if(d[x % 10]) return false;
		x /= 10;
	}
	return true;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
	ll n;
	cin >> n;
	ll k;
	cin >> k;
	ll v;
	for(int i = 1; i <= k; i++){
		cin >> v;
		d[v] = true;
	}
	for(int i = n; i <= 1000000; i++){
		if(check(i)) return cout << i, 0;
	}
	return 0;
}



Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

vector<ll>v;
void rec(ll i){
    if(i>4e10) return;
    v.pb(i);
    if(i%10) rec(10*i+(i%10-1+10)%10);
    rec(10*i+i%10);
    if(i%10<9) rec(10*i+(i%10+1)%10);
}
signed main(){
    FastIO;
    int k;
    cin>>k;
    rep(i,1,9) rec(i);
    sort(all(v));
    cout<<v[k-1];
    return 0;
}


Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,c=0;
	cin>>n;
	unordered_map<int,int> m;
	for (int i=1;i<n;i++)
		{
			cin>>c;
			m[c]++;
		}
			
	for(auto j=1;j<=n;j++)
		{
			cout<<m[j]<<"\n";
		}
}

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

#define fr(i,n) for(i=0;i<n;i++)
#define frs(i,a,n) for(i=a;i<n;i++)
#define frv(i,n) for(i=n-1;i>=0;i--)

#define ne cout<<"\n";
#define cas(i) cout<<"Case #"<<i<<": "

#define vpi vector <pair <int,int> >
#define vpin(v,a,b) v.push_back(make_pair(a,b))
#define vsort(v) sort(v.begin(),v.end());

int dis(int a, int b)
{
    if(a-b<0) return b-a;
    return a-b;
}
long long me(char a[5])
{
    long long n=0,r=1;
    int i, siz=strlen(a);
    frv(i,siz)
    {
        if(a[i]>='0'&&a[i]<='9')
        {
            n+=(a[i]-'0')*r;
            r*=10;
        }
    }
    return n;
}
int main()
{
    long long a,B,ans;
    char dn[5];
    dn[0]='0';
    dn[1]='.';
    dn[2]='0';
    dn[3]='0';
    dn[4]='\0';
    double b;
    cin>>a;
    cin>>dn;
    B = me(dn);
//    b*=100.0;
//    B = floor(b);
    if(a==0||B==0) ans=0;
    else{
    ans = (B*a)/100;
    }
    cout<<ans<<"\n";

//    cout<<fixed<<setprecision(0)<<a*b<<"\n";
    return 0;
}




Measured memory_bytes: 3680
#include <cstdio>

using namespace std;
 
int main() {
	int n;
	int i, j, k, m;
	int counter;
	
	while (scanf("%d", &n) != EOF) {
	    counter = 0;
	    
	    for (i = 0; i < 10; i++) {
	        for (j = 0; j < 10; j++) {
	            for (k = 0; k < 10; k++) {
	                for (m = 0; m < 10; m++) {
	                    if ((i + j + k + m) == n) counter++;
	                }
	            }
	        }
	    }
	    
	    printf("%d\n", counter);
	}
	
	return 0;
}

Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
dpr=[0]*n
dpb=[0]*n
dpg=[0]*n
if a[0]!=0:
    print(0)
    exit()
dpr[0]=1
x=1
for i in range(1,n):
    r,b,g=dpr[i-1],dpb[i-1],dpg[i-1]
    c=0
    now=a[i]
    if now==r:
        c+=1
    if now==b:
        c+=1
    if now==g:
        c+=1
    x*=c
    if now==r:
        dpr[i]=dpr[i-1]+1
        dpb[i]=dpb[i-1]
        dpg[i]=dpg[i-1]
    elif now==b:
        dpr[i]=dpr[i-1]
        dpb[i]=dpb[i-1]+1
        dpg[i]=dpg[i-1]
    elif now==g:
        dpr[i]=dpr[i-1]
        dpb[i]=dpb[i-1]
        dpg[i]=dpg[i-1]+1
    else:
        print(0)
        exit()
print(x*3%mod)


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

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

    map <string, int> m;

    while(n--){
        string s;
        cin >> s;
        m[s]++;
    }

    cout << "AC x " << m["AC"] << "\n";
    cout << "WA x " << m["WA"] << "\n";
    cout << "TLE x " << m["TLE"] << "\n";
    cout << "RE x " << m["RE"] << "\n";

    return 0;
}


Measured memory_bytes: 3632
ABK=input().split()
A=int(ABK[0])
B=int(ABK[1])
K=int(ABK[2])
if A >= K:
    A=A-K
else:
    K=K-A
    A=0
    if B >= K:
        B=B-K
    else:
        B=0
print(str(A)+' '+str(B))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  string s;
  ll k;
  cin >> s >> k;
  if(s[0]!='1'){
    cout << s[0] << endl;
    return 0;
  }
  int n = s.size();
  ll pos = -1;
  rep(i,n){
    if(s[i]=='1'){
      pos = i;
    } else {
      break;
    }
  }
  if(pos+1>=k){
    cout << s[0] << endl;
    return 0;
  } else {
    cout << s[pos+1] << endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

const int MAX_N = 1 << 17;

int n, dat[2 * MAX_N - 1];

void init(int n_) {
    n = 1;
    while(n < n_) n *= 2;
    rep(i, 2 * n - 1) dat[i] = INT_MAX;
}

void update(int k, int a) {
    k += n - 1;
    dat[k] = a;
    while(k > 0) {
        k = (k - 1) / 2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
}

int query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return INT_MAX;
    if(a <= l && r <= b) return dat[k];
    else {
        int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
}


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, q;
    cin >> N >> q;
    init(N);
    rep(i, q) {
        int c, x, y;
        cin >> c >> x >> y;
        if(c == 0) update(x, y);
        else cout << query(x, y + 1, 0, 0, n) << endl;
        //rep(i, 2 * n - 1) cout << dat[i] << " ";
        //cout << endl;
    }

    return 0;
}



Measured memory_bytes: 4168
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i <= (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = long long;


int main() {

	int k, s;
	cin >> k >> s;
	int ans = 0;
	rep(i, k) {
		for (int j = 0; j <= k; j++) {
			if (s - i - j <= k&&s-i-j>=0) { ans++; }
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:31:41 2020

@author: Kanaru Sato
"""

n = int(input())

count = 0
for i in range(1,n+1):
    if 1<=i and i<=9:
        count += 1
    elif 100 <= i and i <= 999:
        count += 1
    elif 10000 <= i and i <= 99999:
        count += 1

print(count)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#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 <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;

using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する

void solve(int n) {
    int min_v = 114514;
    int max_v = 0;
    int sum = 0;
    rep(i,0,n){
        int tmp;
        cin >> tmp;
        sum += tmp;
        min_v = min(tmp,min_v);
        max_v = max(tmp,max_v);
    }
    sum -= min_v + max_v;
    cout << sum / (n-2) << endl;
}

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

    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        else solve(n);
    }


    return 0;
}




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

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

struct Edge{
	int src,dst,weight;
	Edge(){}
	Edge(int s,int d,int w):src(s),dst(d),weight(w){}
};

bool operator<(const Edge& lhs,const Edge& rhs)
{
	return lhs.weight<rhs.weight;
}

bool operator>(const Edge& lhs,const Edge& rhs)
{
	return lhs.weight>rhs.weight;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

struct UnionFind{
	vi data;
	UnionFind(int size):data(size,-1){}
	int Find(int n){
		return data[n]<0?n:(data[n]=Find(data[n]));
	}
	void Union(int n1,int n2){
		int d1=Find(n1);
		int d2=Find(n2);
		if(d1!=d2){
			if(-data[d1]<-data[d2])
				swap(d1,d2);
			data[d1]+=data[d2];
			data[d2]=d1;
		}
	}
	int Size(int n){
		return -data[Find(n)];
	}
};

int Kruskal(Graph& g,Edges& e)
{
	e.clear();
	
	UnionFind uf(g.size());
	multiset<Edge> s;
	rep(i,g.size())
		rep(j,g[i].size())
			s.insert(g[i][j]);
	
	int res=0;
	foreach(i,s){
		if(uf.Find(i->src)!=uf.Find(i->dst)){
			uf.Union(i->src,i->dst);
			res+=i->weight;
			e.push_back(*i);
		}
	}
	
	return res;
}

int Prim(Graph& g,Edges& tree,int root=0)
{
	tree.clear();
	
	int size=g.size();
	vector<int> visited(size);
	
	priority_queue<Edge,vector<Edge>,greater<Edge> > pq;
	pq.push(Edge(-1,root,0));
	int res=0;
	while(!pq.empty()){
		Edge e=pq.top();
		pq.pop();
		if(visited[e.dst])
			continue;
		if(e.src!=-1)
			tree.push_back(e);
		visited[e.dst]=1;
		res+=e.weight;
		rep(i,g[e.dst].size()){
			Edge cand=g[e.dst][i];
			if(!visited[cand.dst])
				pq.push(cand);
		}
	}
	return res;
}

int main()
{
	for(int n,m;cin>>n>>m,n;){
		Graph g(n);
		rep(i,m){
			int src,dst,weight;
			scanf("%d,%d,%d",&src,&dst,&weight);
			g[src].push_back(Edge(src,dst,weight/100-1));
			g[dst].push_back(Edge(dst,src,weight/100-1));
		}
		Edges e;
		int sum=Kruskal(g,e);
		//int sum=Prim(g,e);
		cout<<sum<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
import math
a, b, c, d = map(int, input().split())
e = c*d//math.gcd(c,d)
def ko(a,b,c):
  x = b//c-a//c
  if a%c==0:
    x+=1
  return(x)
print(b-a+1-ko(a,b,c)-ko(a,b,d)+ko(a,b,e))

Measured memory_bytes: 9192
#pragma GCC optimize("Ofast")
#include <stdio.h>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[20];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    int res = arr1[ch[0] - '0'][ch[7] - '0'];
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            res = '4' - ch[2];
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            res = ch[2] - '0';
        }
        else
            res = arr1[ch[0] - '0'][ch[6] - '0'];
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            res = 22888;
        }
        else if (ch[0] == '9') {
            res = 25436;
        }
    }
    puti(res);
    fputc('\n', stdout);
    return 0;
}

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

using namespace std;
typedef long long LL;
const int Max_Num=2e5+10;
const LL INF=2e18;
vector<LL> p, n, pr, nr;
LL ns, ps;

LL count_negative(LL x){
	int i=0, j=0;
	LL res=0;
	while(i<ns){
		for(int k=j; k<ps; k++){
			if(n[i]*p[k]<=x){
				res+=ps-k;
				i++, j=k;
				break;
			}
			if(k==ps-1) i=ns;
		}
	}
	return res;
}

LL count_positive(LL x){
	int i=0, j=0;
	LL res=0;
	while(i<ns){
		for(int k=j; k<ns; k++){
			if(nr[i]*n[k]<=x){
				res+=ns-k;
				if(i+k<=ns-1) res--;
				i++, j=k;
				break;
			}
			if(k==ns-1) i=ns;
		}
	}
	i=0, j=0;
	while(i<ps){
		for(int k=j; k<ps; k++){
			if(p[i]*pr[k]<=x){
				res+=ps-k;
				if(i+k<=ps-1) res--;
				i++, j=k;
				break;
			}
			if(k==ps-1) i=ps;
		}
	}
	return res/2;
}

bool is_valid(LL x, LL key, char c){
	LL res;
	if(c=='n') res=count_negative(x);
	if(c=='p') res=count_positive(x);
	if(res>=key) return true;
	else return false;
}

LL binary_search(LL key, char c){
	LL left=-INF, right=INF;
	while(right-left > 1){
		LL x=left+(right-left)/2;
		if(is_valid(x,key,c)) right=x;
		else left=x;
	}
	return right;
}

int main(){
	LL N;
	LL K;
	cin >> N >> K;
	rep(i,N){
		LL a;
		cin >> a;
		if(a<0) n.emplace_back(a);
		if(a>0) p.emplace_back(a);
	}
	sort(n.begin(),n.end());
	sort(p.begin(),p.end());
	ns=n.size(), ps=p.size();
	rep(i,ns) nr.emplace_back(n[ns-1-i]);
	rep(i,ps) pr.emplace_back(p[ps-1-i]);
	LL nega=ns*ps, posi=ns*(ns-1)/2+ps*(ps-1)/2;
	LL zero=N*(N-1)/2-nega-posi;
	LL ans=0;
	if(nega>=K){
		ans=binary_search(K,'n');
	}
	else if(nega+zero>=K) ans=0;
	else{
		ans=binary_search(K-nega-zero,'p');
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  cout << n*n*n << endl;
  return 0;
}


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

int main(){
    string s,t;
    cin >> s;
    int l=s.length();
    bool ans=true;
    int i=0;
    while(1){
        if(s.at(l-1)=='r' && s.at(l-3)=='m'){
            t+="remaerd";
            l-=7;
        }
        else if(s.at(l-1)=='m'){
            t+="maerd";
            l-=5;
        }
        else if(s.at(l-1)=='r' && s.at(l-3)=='s'){
            t+="resare";
            l-=6;
        }
        else if(s.at(l-1)=='e'){
            t+="esare";
            l-=5;
        }
        i++;
        if(l==0 || i>100000) break;
    }
    reverse(t.begin(),t.end());
    if(t==s) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3732
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	for(;;){
		int sum = 0;
		int ace = 0;
		bool finish = false;
		do{
			int a;
			scanf("%d", &a);
			if(a == 0){
				finish = true;
				break;
			}
			if(a == 1)
				++ace;
			else
				sum += min(a, 10);
			
		}while(getchar() == ' ');
		
		if(finish)
			break;
		
		int best = 0;
		rep(i, ace+1){
			int now = sum + i + (ace-i) * 11;
			if(now > 21)
				now = 0;
			best = max(best, now);
		}
		
		printf("%d\n", best);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main()
{
    int n , t ;
    cin>>n>>t ;
    int ans = 10005 ;
    for(int i = 0 ; i < n ; ++i)
    {
        int x , y ;
        cin>>x>>y ;
        if(y <= t)
            ans = min(ans , x) ;
    }
    if(ans == 10005)
        cout<<"TLE\n";
    else
        cout<<ans<<"\n";
    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if((s=="hi")||(s=="hihi")||(s=="hihihi")||(s=="hihihihi")||(s=="hihihihihi"))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL N; cin >> N;
    LL P; cin >> P;

    auto pfac = prime_factorize(P);
    LL ans = 1;
    for(auto p : pfac)
    {
        if(p.second / N != 0)
        {
            REP(j,p.second/N) ans *= p.first;

        }
    }
    cout << ans << endl;


}

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

constexpr int MOD = 1000000007;
 // constexpr int MOD = 998244353;

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  auto cs = [&](auto V) {
    int n = V.size() + 1;
    vector<long> R(n);
    for (int i = 1; i < n; i++) {
      R.at(i) = R.at(i - 1) + V.at(i - 1);
    }
    return R;
  };

  auto R = cs(A);
  long ans = 0;
  for (int i = 0; i < N; i++) {
    long tmp = R.at(N) - R.at(i + 1);
    tmp %= MOD;
    tmp *= A.at(i);
    tmp %= MOD;
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 6348
n = int(input())

li = []

for i in range(0,(n//2)*2):
  if i+1 < n-i:
    li.append([i+1,n-i-n%2])
  else:
    break
if n%2 == 1:
  li.append([n])
if len(li) > 2:
  li.append(li[0])

count = 0
for i in range(1,len(li)):
  for j in li[i-1]:
    for k in li[i]:
      count += 1
print(count)
for i in range(1,len(li)):
  for j in li[i-1]:
    for k in li[i]:
      print(j,k)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
 
using namespace std;
 
int main(){
 
  int n;
  cin>>n;
  
  vector<vector<int>> input(n,vector<int>(2,0));
  for(int i=0;i<n;i++){
  	cin>>input[i][0]>>input[i][1];
  }
  
  
  for(int i=0;i<n-2;i++){
  	if(input[i][0]==input[i][1]&&
      input[i+1][0]==input[i+1][1]&&
      input[i+2][0]==input[i+2][1])
    {
    	cout<<"Yes";
      	return 0;
    }
  }
  
  cout<<"No";
 
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  
  if(a.at(0)==a.at(1) || a.at(1)==a.at(2) || a.at(2)==a.at(3)){
      cout << "Bad" << endl;
  }
  else{
      cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

template <typename T>
T lcm(T x,T y){
    return x*y/gcd(x,y);
}

int main(){
    double r=in,pi=3.1415926535;
    out(r*2.0*pi);
}

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

using namespace std;

typedef long long ll;

double getTime() { 
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

const ll MOD = 1e9 + 7;

ll bigmod(ll a, ll b) {
  ll res = 1LL;
  while(b) {
    if(b & 1) res = (res * a) % MOD;
    b >>= 1LL;
    a = (a * a) % MOD;
  }
  return res;
}

const ll N = 1e6 + 6;

vector <ll> prime; 
bool used[N];

int main() {
  for(int i = 2; i < N; i++) {
    if(!used[i]) {
      prime.push_back(i);
      for(int j = i + i; j < N; j += i) {
        used[j] = 1;
      }
    }
  }
  int n; scanf("%d", &n);
  vector <ll> a(n);
  map <ll, ll> mp;
  for(int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    ll cur = a[i];
    for(int j = 0; j < prime.size() and prime[j] * prime[j] <= cur; j++) {
      ll p = prime[j];
      ll cnt = 0;
      while(cur % p == 0) {
        cur /= p;
        cnt++;
      }
      if(mp.count(p) == 0) mp[p] = cnt;
      else mp[p] = max(mp[p], cnt);
    }
    if(cur > 1) {
      if(mp.count(cur) == 0) mp[cur] = 1LL;
      else mp[cur] = max(mp[cur], 1LL);
    }
  }
  ll big = 1LL;
  for(auto x : mp) {
    big = (big * bigmod(x.first, x.second)) % MOD;
  }
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    ans = (ans + bigmod(a[i], MOD - 2) * big % MOD) % MOD;
  }
  print(ans);
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  ll N,K;
  cin>>N>>K;
  ll a[N];
  rep(i,N){
    cin>>a[i];
  }
  sort(a,a+N);
  ll ans=0;
  rep(i,K){
    ans+=a[i];
  }
  cout<<ans;
}


Measured memory_bytes: 3628
import math

div1 = 3
div2 = 673

L, R = map(int, input().split())

if R - L >= 2019:
    print(0)
    exit()

min_v = 2018

for i in range(L, R):
    for j in range(i + 1, R + 1):
        v = i * j % 2019
        if v == 0:
            print(v)
            exit()
        min_v = min(min_v, v)

print(min_v)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
 
#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i = a ; i < (int)n ; i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define mp make_pair
#define eps 1e-14
#define INF 1e9
#define m0(x) memset(x, 0, sizeof(x))
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
 
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};
 
signed main(){
  int n;
  string s1, s2, ans;
  
  int l, r;
  cin >> n;
  cin >> s1;
  l = r = 0;
  ans = "";
  int a = 0, b = 0;
  rep(i, s1.size()){
    if(s1[i] == '(') l++;
    else r++;
    
    if(b > l - r) b = l-r;
  }
  
  rep(i, abs(b)){
    ans += "(";
  }
  ans += s1;  
  rep(i, l-r+abs(b)){
    ans += ")";
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf ll(1e18)
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
ll power(ll a,ll n,ll m) ;
ll power(ll a,ll n,ll m)
{  if(n==0)
   return 1 ;
   ll x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
double PI=3.14159265357 ;
int32_t main()
{ ll n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,temp;
  ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
   cin>>k>>n ;
   map<ll,ll> p ;
   ll arr[n] ;
   for(i=0;i<n;i++)
   {
       cin>>arr[i] ;
       p[arr[i]]++ ;
   }
   for(i=0;i<=200;i++)
   {
       if(p.find(k-i)==p.end())
       {cout<<k-i ;
         return 0 ; }
          if(p.find(k+i)==p.end())
       {cout<<k+i ;
         return 0 ; }
   } return 0; }


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>

#define rep(i,m,n) for(unsigned long long int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<long long int> v;
vector<long long int> w;

int main() {
	ll X;
	cin >> X;
	ll ans = 0;
	ll mom = 100;
	while (mom < X) {
		++ans;
		mom *= 1.01;
	}
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

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

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

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 64;
const int N = (int)2e5 + 7;
const int MAXN = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)2e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e18;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

bool ok[MAXN];
int n, cnt[MAXN];

void solve() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		cnt[x]++;
	}
	fill(ok, ok + MAXN, true);
	for (int i = 0; i < MAXN; i++) {
		if (cnt[i] == 0)
			continue;
		if (cnt[i] > 1)
			ok[i] = false;
		for (int j = 2 * i; j < MAXN; j += i)
			ok[j] = false;
	}
	int ans = 0;
	for (int i = 0; i < MAXN; i++)
		ans += (cnt[i] > 0) && ok[i];
	cout << ans;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}
	
#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 8504
#include <utility>
#include <bitset>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <ios>
#include <iomanip>
#include <sstream>
#include <climits>
#include <cmath>

using namespace std;

#ifdef USE_LOG
#define LOG(str)  cout << str << endl
#define DMP(var)  cout << #var << " = " << var << endl
#else
#define LOG(...)
#define DMP(...)
#endif

#define FOR(v, b, e)   for (int v = (b); v < (e); ++v)
#define RFOR(v, b, e)  for (int v = (e) - 1; (b) <= v; --v)
#define REP(v, n)      FOR(v, 0, n)
#define RREP(v, n)     RFOR(v, 0, n)

#define ALL(c)         (c).begin(), (c).end()

typedef long long           ll;
typedef unsigned long long  ull;

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

	int N, A;
	cin >> N;
	cin >> A;

	if ((N % 500) <= A) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

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

    string A,B,C;
    cin >> A >> B >> C;
    if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0]){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }  
}

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

//const int MAX_N = 100;

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

	if(s.size()%2==0)
		s=s.substr(0, s.size()-2);
	else
		s=s.substr(0, s.size()-1);

	while(1){
		int half=s.size()/2;
		if(s.substr(0,half)==s.substr(half,half)){
			break;
		}

		s=s.substr(0,half*2-2);
	}

	cout<<s.size()<<endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>

using namespace std;
typedef long long ll;

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


    ll ans=0;
    ll anss =0;
    ll count=0;
    ll i,j;
  
    ll K;
    vector<ll> a;

    ll Q,N;
    string S;
    cin>>N>>K;
    ll flag=0;
    ll t1=0;
    ll t2=0;

    if(N>9||K>9){
        cout << -1<< endl;

    }else{
    cout <<N*K << endl;
    }
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  string s;
  cin >> s;

  int ans = 0, cnt = 0;
  REP(i, 0, s.length()){
      if (s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T')
        cnt++;
      else
        cnt = 0;
      ans = max(ans, cnt);
  }
  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0;i <n;i++)
#define RFOR(i, n) for(int i = n;i >= 0;i--)
#define REP(i, m, n) for(int i = m;i < n;i++)
#define RREP(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
 
using namespace std;
int main(int argc, char const *argv[]) 
{
 int a,b;
 cin >>a>>b;
if(a*b%2 == 0)
{
  cout<<"No"<<endl;
}
else
{
  cout<<"Yes"<<endl;
}

 
return 0;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int a[110][110],b[110];
	int i,j;
	for(i=0;i<n;++i){
		for(j=0;j<m;++j){
			scanf("%d",&a[i][j]);
		}
	}
	
	for(i=0;i<m;i++){
		scanf("%d",&b[i]);
	}
	
	int ans[110];
	
	for(i=0;i<n;i++){
		for(ans[i]=0,j=0;j<m;++j){
			ans[i]+=a[i][j]*b[j];
		}
		printf("%d\n",ans[i]);
	}
	return 0;
}
		


Measured memory_bytes: 2112