akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int c[10][10] , r , reach;
bool visit[10];

void dfs(int x){
    visit[x]=true;
    if(x == 1){
        reach=min(reach,r);
    } else {
        for(int i=0;i<=9;i++){
            if(visit[i] == false){
                r+=c[x][i];
                dfs(i);
                r-=c[x][i];
            }
        }
    }
    visit[x]=false;
}

signed main(){
    int h , w , num[10]={} , a , ans=0;
    cin>>h>>w;
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            cin>>c[i][j];
        }
    }
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a;
            if(a>=0){
                num[a]++;
            }
        }
    }
    
    for(int i=0;i<=9;i++){
        if(num[i]>0 && i != 1){
            reach=c[i][1] , r=0;
            dfs(i);
            ans+=reach*num[i];
        }
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 256
#!/usr/bin/env python
import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    input = sys.stdin.readline
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())
    #ps = list(map(int, input().split()))

    N = int(input())


    print(N ** 3)




if __name__ == '__main__':
    main()


Measured memory_bytes: 9768
N=int(input())
D,X=map(int,input().split())
A=[]
for i in range(N):
  A.append(int(input()))
ans=0
count=0
for i in range(N):
  while count*A[i]+1<=D:
    if count*A[i]+1<=D:
      ans+=+1
      count+=1
  count=0
print(ans+X)

Measured memory_bytes: 3064
n = int(input())
hs = [int(x) for x in input().split()]

for i in range(1, n):
  if hs[i-1] < hs[i]:
    hs[i] = hs[i] -1

for i in range(1, n):
  if hs[i-1] > hs[i]:
    print("No")
    break
else:
  print("Yes")

Measured memory_bytes: 14396
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ql(){
	ll f=0;int fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
int main()
{
	int n=qi(),x=qi(),t=qi();
	int tmp=n/x+(n%x!=0);
	printf("%d\n",tmp*t);
	return 0;
}

Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807;
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
		int n, p, a;
		int x = 0;

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

		for (int i = 0; i < n; i++) {
			scanf("%d", &a);
			if (a % 2 == 1) {
				x++;
			}
		}

		printf("%ld\n", (p == 1 && x == 0) ? 0L : x == 0 ? 1L << n : 1L << (n - 1));






#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <stack>

using namespace std;
typedef long long ll;

#define _SI(arr) (sizeof(arr)/sizeof(arr[0])

int main() {
	string s;
	char s1[6];
	cin >> s;

	s.erase(s.begin(), s.begin() + 5);

	cout << "2018/" << s << endl;
}

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

using namespace std;

using int64 = long long;

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

  int a, b;
  cin >> a >> b;
  int ans = max(max(a + b, a - b), a * b);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

class UnionFind {
  vector<int> par, rank, potential;
public:
  UnionFind(int n) {
    par.resize(n, -1);
    rank.resize(n, 0);
    potential.resize(n, 0);
  }
  int root(int x) {
    if (par[x] < 0)
      return x;
    int r = root(par[x]);
    potential[x] += potential[par[x]];
    return par[x] = r;
  }
  int size(int x) {
    return -par[root(x)];
  }
  int weight(int x) {
    root(x);
    return potential[x];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y, int w = 0) {
    w += weight(x);
    w -= weight(y);
    x = root(x);
    y = root(y);
    if (x == y) {
      return false;
    }
    if (rank[x] < rank[y]) {
      swap(x, y);
      w = -w;
    }
    if (rank[x] == rank[y])
      rank[x]++;
    par[x] += par[y];
    par[y] = x;
    potential[y] = w;
    return true;
  }
  int diff(int x, int y) {
    return weight(y) - weight(x);
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    --a[i], --b[i];
  }
  int ans = 0;
  rep(i, m) {
    UnionFind uf(n);
    rep(j, m) {
      if (j != i)
        uf.unite(a[j], b[j]);
    }
    if (uf.size(0) < n)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())

# Nの因数を昇順で返す関数。1含む
def factor(n):
    f = []
    for i in range(1, int(n**0.5) + 1):
        if n%i == 0:
            f.append(i)
            if i != n//i:
                f.append(n//i)
    return f

ans = 0
for x in factor(N):
    m = (N//x) - 1
    if x < m:
        ans += m

print(ans)

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

using ll = long long;
static const ll MOD = 998244353;

// Segment-Tree
struct SegmentTree {
  int n;
  vector<int> dat;
  
  SegmentTree(int _n) {
    init(_n);
  }
  
  void init(int _n) {
    n = 1;
    while (n < _n) n *= 2;
    dat.assign(2 * n - 1, -1);
  }
  
  // i番目の値をxに変更
  void update(int i, int x) {
    i += n - 1; // 葉のノード
    dat[i] = x;
    while (i > 0) { // 更新
      i = (i - 1) / 2;
      dat[i] = max(dat[2 * i + 1], dat[2 * i + 2]);
    }
  }
  
  // [a, b)の最大値
  // k:ノードの番号 [l, r)がkに対応づいている
  // query(a, b, 0, 0, n)と呼ぶ
  int query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    if (r <= a || b <= l) return -1;
    if (a <= l && r <= b) return dat[k];
    else {
      int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
      int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
      return max(vl, vr);
    }
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<pair<int, int>> x(n);
  for (int i = 0; i < n; i++) cin >> x.at(i).first >> x.at(i).second;
  
  sort(x.begin(), x.end());
  
  SegmentTree st(n);
  for (int i = 0; i < n; i++) st.update(i, i);
  for (int i = n - 2; i >= 0; i--) {
    int keep = x.at(i).first + x.at(i).second;
    int l = i, r = n;
    while (r - l > 1) {
      int mid = (l + r) / 2;
      if (x.at(mid).first < keep) l = mid;
      else r = mid;
    }
    st.update(i, st.query(i, r));
  }
  
  vector<ll> dp(n);
  dp[n - 1] = 2;
  for (int i = n - 2; i >= 0; i--) {
    if (st.query(i, i + 1) + 1 < n) dp[i] = dp[i + 1] + dp[st.query(i, i + 1) + 1];
    else dp[i] = dp[i + 1] + 1;
    dp[i] %= MOD;
  }
  
  cout << dp[0] << '\n';
}

Measured memory_bytes: 8476
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	ll n, a, b;
	cin >> n >> a >> b;
	if ((b-a)%2 == 0) cout << (b-a)/2 << endl;
	else cout << min(a-1, n-b) + 1 + (b-a-1)/2 << endl;
 	return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long i=0;i<(long)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=1e10+7;

int main(void){
    long n,k,m;
    cin>>n>>k;
    m=k*pow(k-1,n-1);
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
A=list(input())
B=list(input())
C=list(input())
t='a'
d=1#ずっとまわすつもり。
while d==1:
    if t=='a':
        t=A.pop(0)
    elif t=='b':
        t=B.pop(0)
    elif t=='c':
        t=C.pop(0)
    if t=='a' and A==[]:
        print('A')
        break
    elif t=='b' and B==[]:
        print('B')
        break
    elif t=='c' and C==[]:
        print('C')
        break

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

using ll = long long;

using namespace std;
#define int ll

//0 -> a-1
#define rep(i, a) for (int i = 0; (i) < (int)(a); (i)++)
//a -> b-1
#define reps(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
//a-1 -> 0
#define rrep(i, a) for (int i = (int)a - 1; (i) >= 0; (i)--)
//a-1 -> b
#define rreps(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
//next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
(v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v) \
	sort(all(v)); \
	(v).erase(unique(all(v)), v.end())
#define CIN(type, x) \
	type x;          \
	cin >> x
#define YES(f) if ((f)) {cout << "YES" << endl;} else {cout << "NO" << endl;}
#define Yes(f) if ((f)) {cout << "Yes" << endl;} else {cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
//b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
//c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)
#define RS resize
#define CINV(v, N)             \
	do                         \
	{                          \
		v.RS(N);               \
		rep(i, N) cin >> v[i]; \
	} while (0);

#define RCINV(v, N)             \
	do                          \
	{                           \
		v.RS(N);                \
		rrep(i, N) cin >> v[i]; \
	} while (0);
#define MOD 1000000007

template <class T>
inline T GET()
{
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	int N;
	string s;
	cin >> N >> s;
	int a=0, b=0;
	rep(i, N) {
		a += s[i] == 'R';
		b += s[i] == 'B';
	}
	Yes(a > b);
}

void solve()
{
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n, i, j, a[100] = {0}, max = 0, list[100];

	while(scanf("%d", &n) != EOF){
		a[n - 1]++;
	}

	for (i = 0; i < 100; i++){
		if(max < a[i]){
			max = a[i];
			j = 0;
			list[j] = i + 1;
		} else if(max == a[i]){
			list[++j] = i + 1;
		}
	}

	for (i = 0; i <= j; i++){
		printf("%d\n", list[i]);
	}


	return 0;
}


Measured memory_bytes: 2028
#include <cstdio> 

bool f[100001];
int c[100002];
int N,L,R;
int main ()
{
	for(int i=2;i<=100000;i++)if(!f[i])for(int j=i+i;j<=100000;j+=i) f[j]=true;
	for(int i=3;i<=100000;i+=2)if(!f[i]&&!f[(i+1)/2])c[i]++;
  	for(int i=3;i<=100000;i++)c[i]+=c[i-1];
	scanf("%d",&N);
	while(N--)
	{
      scanf("%d%d",&L,&R);
      printf("%d\n",c[R]-c[L-1]);
	}
 }

Measured memory_bytes: 1024
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy

res1 = 'R' * x + 'U' * y
res2 = 'L' * x + 'D' * y
res3 = 'D' + 'R' + res1 + 'U' + 'L'
res4 = 'U' + 'L' + res2 + 'D' + 'R'

res = res1 + res2 + res3 + res4

print(res)

Measured memory_bytes: 3060
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;

    auto dp = new long[][](N, N);
    dp[0][] = 1;

    foreach (i; 1..N) {
        if (S[i-1] == '>') {
            long s = dp[i-1][N-i];
            foreach_reverse (j; 0..N-i) {
                (dp[i][j] += s) %= MOD;
                (s += dp[i-1][j]) %= MOD;
            }
        } else {
            long s = dp[i-1][0];
            foreach (j; 0..N-i) {
                (dp[i][j] += s) %= MOD;
                (s += dp[i-1][j+1]) %= MOD;
            }
        }
    }

    long ans = 0;
    foreach (j; 0..N)
        (ans += dp[N-1][j]) %= MOD;
    ans.writeln;
}


Measured memory_bytes: 74492
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long n;
  long long ans = LLONG_MAX;
  cin >> n;
 
  for(long long i = 1; i*i <= n; i++){
    if(n % i == 0){
      long long a = i;
      long long b = n/i;
      ans = min(ans, a+b-2);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
s = [int(x) for x in input().split()]
a =0
if s[0] == s[1]and s[0] != s[2] or s[1] == s[2] and s[0] != s[2] or s[0] == s[2] and s[1] != s[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <string>
#include <cmath>
//#include <vector>
//#include <time.h>
#include <queue>
//#include <stack>
//#include <map>
//#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
int a[10000];
int main()
{
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    sum/=n;
    int ans1=0,ans2=0,ans3=0;
    for(int i=1;i<=n;i++)
    {
        ans1+=(sum-a[i])*(sum-a[i]);
        ans2+=(sum+1-a[i])*(sum+1-a[i]);
        ans3+=(sum-1-a[i])*(sum-1-a[i]);
    }
    cout<<min(ans1,min(ans2,ans3));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
   int x;
   cin >> x;
   if(x == 3 || x == 5 || x == 7){
      cout << "YES" << endl;
   }
   else{
      cout << "NO" << endl;
   }

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 10000007
using namespace std;
int n,m,q; 
vector<vector<long long int>> abcd;
int long long nmax;
void dfs(vector<int> A,int head,int value) {
	if(head == n) {
    	long long int total = 0;
      	for(int k = 0;k < q;k++) {
        	if(A[abcd[k][1] - 1] - A[abcd[k][0] - 1] == abcd[k][2]) total += abcd[k][3];
        }
      	if(total > nmax) nmax = total;
    }
  	else {
    	for(int i = value;i <= m;i++) {
          	A[head] = i;
        	dfs(A,head + 1,i);
        }
    }
}

int main() {
  	cin >> n >> m >> q;
  	nmax = 0;
  	for(int i = 0;i < q;i++) {
      	long long int a,b,c,d;
      	cin >> a >> b >> c >> d;
      	abcd.push_back({a,b,c,d});
    }
   
   	vector<int> A(n,1);

    dfs(A,0,1);	
  
    cout << nmax << "\n";
  	return 0;
}

Measured memory_bytes: 3632
#! /usr/bin/python3
""" Increment Decrement """

N = int(input())
S = input()
x = 0
test = False


def answer(ori_x, s):
    """ 文字列 s から i 回目の計算結果のリストを作り、その中の最大値を返す。"""
    temp_x = ori_x
    l = [ori_x]

    for I_or_D in s:
        if I_or_D == 'I':
            temp_x += 1
        elif I_or_D == 'D':
            temp_x -= 1
        else:
            print('error')
            break
        l.append(temp_x)

    if test:
        print('l =', l)

    return max(l)


def main():
    ''' 関数に値を適用 '''
    print(answer(x, S))


if __name__ == '__main__':
    main()


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

string title[102], author[102], dt[102];

int main() {
  int n;

  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      cin >> title[i] >> author[i] >> dt[i];
    }
    int q;
    cin >> q;
    for (int QUERY = 1; QUERY <= q; QUERY++) {
      if (QUERY != 1) {
        cout << endl;
      }
      string qt, qa, qd_from, qd_to;
      cin >> qt >> qa >> qd_from >> qd_to;
      for (int i = 0; i < n; i++) {
        if ((qt == "*" || title[i].find(qt) != string::npos) &&
            (qa == "*" || author[i].find(qa) != string::npos) &&
            (qd_from == "*" || qd_from <= dt[i]) &&
            (qd_to == "*" || qd_to >= dt[i])) {
          cout << title[i] << endl;
        }
      }
    }
  }
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iomanip>
using namespace std;

int main() {
    int d[6],u = 1, f = 2, r = 3, t;
    char move;
    for (int i = 0; i < 6; i++) {
        cin >> d[i];
    }
    while (cin >> move) {
        switch (move) {
            case 'N':t = u; u = f; f = 7 - t; break;
            case 'S':t = f; f = u; u = 7 - t; break;
            case 'E':t = r; r = u; u = 7 - t; break;
            case 'W':t = u; u = r; r = 7 - t; break;
            default: cout << "error" << endl; break;
        }
        // printf("u:%d f:%d r:%d\n", u, f, r);
    }
    cout << d[u-1] << endl;
    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int x;
	cin >> x;
	int i = 0, wei = 0;
	while(wei < x)
	{
		wei += i;
		i ++;
	}
	cout << i - 1;
 
	return 0;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define eb emplace_back
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,m;cin >> n >> m;
	vector<int> ar[n];
	int h[n];
	for(int i=0;i<n;i++) cin >> h[i];
	for(int i=0;i<m;i++){
		int a,b;cin >> a >> b;
		a--,b--;
		ar[a].eb(b);ar[b].eb(a);
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		bool valid = true;
		for(auto it : ar[i]){
			if(h[it] >= h[i]){
				valid = false;
				break;
			}
		}
		ans += valid;
	}
	cout << ans << '\n';
	return 0;
}


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

int main() {
  int N;
  int sum = 0;
  string str;
  cin >> N >> str;
  for(int i = 0; i < N; i++){
    if(i == N-2){
      break;
    }else if(str.at(i) == 'A' && str.at(i+1) == 'B' && str.at(i+2) == 'C'){
      sum++;
    }  
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
package main
 
import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func main() {
  if sc.Scan() {
    s := strings.Split(sc.Text(), " ")
    a, _ := strconv.Atoi(s[0])
    b, _ := strconv.Atoi(s[1])
    k, _ := strconv.Atoi(s[2])

    j := 0
    z := 0
    for i := 100; i >= 1; i-- {
      if (a % i == 0) && (b % i == 0) {
        j++
        if j == k {
          z = i
          break
        }
      }
    }
    fmt.Printf("%d", z)
  }
}

Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <iostream>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define tii tuple<int,int,int>
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}
int main(){
    int a =in();
    int b=in();
    if(a<10&&b<10)cout<<a*b<<endl;
    else cout<<-1<<endl;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
template <typename T> using vec = vector<T>;
typedef vec<int> vi;
typedef vec<ll> vl;


template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

int n;
int a[20],b[21],c[21];

int main()
{
  cin >> n;

  forn(i,n) cin >> a[i];
  forn1(i,n) cin >> b[i];
  forn1(i,n-1) cin >> c[i];

  int ans = 0;
  forn(i,n) {
    ans += b[a[i]];
    if (i < n-1 && a[i]+1 == a[i+1]) ans+= c[a[i]];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int tax(int rate, int price)
{
    return static_cast<int>(price * (100 + rate) / 100);
}

int main()
{
    int x, y, s = 0;

    while (std::cin >> x >> y >> s && s > 0) {
        int max;
        for (int i = 1; i < s; i++) {
            for (int j = i; j < s; j++) {
                if (tax(x, i) + tax(x, j) == s) {
                    if (tax(y, i) + tax(y, j) > max) {
                        max = tax(y, i) + tax(y, j);
                    }
                }
            }
        }
        std::cout << max << '\n';
        max = 0;
    }
    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;



int main() {

    int x,n;
    cin>>x>>n;
    set<int> s;
    rep(i,n){
        int a;
        cin>>a;
        s.insert(a);
    }
    int ans=INF;
    for(int i=-2;i<200;i++){
        if(s.count(i))continue;
        if(abs(x-i)<abs(x-ans)){
            ans=i;
        }
    }
    fin(ans);
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int n;
char a[1000009];
int arr[1009];
int main()
{
    memset(arr,0,sizeof(arr));
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        arr[a[i]]++;
    }
    if(arr['G']&&arr['W']&&arr['P']&&arr['Y'])cout<<"Four";
    else cout<<"Three";
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int ans = 0;

        for(int i=0; i<3; i++){
            if(s.substring(i,i+1).equals("1")){
                ans += 1;
            }
        }
        System.out.println(ans);
    } 
}

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

/*
 * kが奇数の場合：条件を満たす３数はすべてkの倍数である
 * kが偶数の場合：条件を満たす３数はすべてkの倍数かすべてkの剰余がk/2となる数である
 */

int n;
int k;

long oddK() {
	int num = n / k;
	return (long)pow((double)num, 3);
}

long evenK() {
	int num1 = n / k;
	int num2;
	if (n % k < k / 2) num2 = n / k;
	else num2 = (n / k) + 1;

	return (long)pow((double)num1, 3) + (long)pow((double)num2, 3);
}

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

	cin >> n >> k;

	long result;
	if (k % 2 == 1) result = oddK();
	else result = evenK();

	cout << result << "\n";
	return 0;
}

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

using namespace std;

string s, t;

int main() {
  cin >> s >> t;
  cout << t << s;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vector<ll> A(n);
  vector<pair<ll, int>> B(m);
  rep(i, n) cin >> A[i];
  rep(i, m) cin >> B[i].second >> B[i].first;
  sort(all(A));
  sort(all(B), greater<pair<ll, int>>());
  int j = 0;
  rep(i, n) {
    if(j >= m) break;
    if(A[i] >= B[j].first) break;
    A[i] = B[j].first;
    B[j].second--;
    if(B[j].second == 0) j++;
  }
  cout << accumulate(all(A), 0LL) << "\n";
  return 0;
}


Measured memory_bytes: 5588
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

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



int main() {
	int i = 0, j = 0,k,m=0;
	vector<int>n(0);
	string s;
	cin >> s;
	k = s.length();
	vector<char>w(k);
	rep(i,k) {
		w.at(i) = s[i];
	}
	rep(i, k) {
		rep(j, k) {
			if (w.at(i) == w.at(j) ){
				m++;
			}
		}
		n.push_back(m);
		m = 0;
	}
	rep(i, n.size()) {
		if (n.at(i) % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main(){
    int min,a,b,n,A[100],count;
    count = 0;
    cin >> n;
    for(int i = 0; i < n; i ++){
        cin >> A[i];
    }
    for(int i = 0; i < n; i++){
        min = i;
        for(int j = i + 1; j < n; j ++){
            if(A[min] > A[j]) min = j;
            
        }
        a = A[min];
        b = A[i];
        A[min] = b;
        A[i] = a;
        if(min != i) count++;
        
    }
    for(int i = 0; i < n; i++){
        if(i != 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3104
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

template <typename NodeType, typename FuncType>
struct SegmentTree {
    int length;
    vector<NodeType> node;
    NodeType identity;
    FuncType func;
    
    SegmentTree(int length_, NodeType identity_, FuncType func_) : identity(identity_), func(func_) {
        length = 1;
        while (length < length_) length <<= 1;
        node.resize(length << 1, identity);
    }
    
    void change(int idx, NodeType val) {
        idx += length;
        node[idx] = val;
        while (idx >>= 1) node[idx] = func(node[(idx << 1) | 0], node[(idx << 1) | 1]);
    }
    
    NodeType query(int l, int r) {
        l += length; r += length;
        NodeType vl = identity, vr = identity;
        while (l < r) {
            if (l & 1) vl = func(vl, node[l++]);
            if (r & 1) vr = func(node[--r], vr);
            l >>= 1; r >>= 1;
        }
        return func(vl, vr);
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    
    auto f = [](ll x, ll y) {return min(x, y);};
    SegmentTree<ll, decltype(f)> RmQ(n, (1LL << 31) - 1, f);
    rep(i, q) {
        int com, x, y;
        cin >> com >> x >> y;
        if (!com) RmQ.change(x, y);
        else cout << RmQ.query(x, y + 1) << "\n";
    }
    
    return 0;
}



Measured memory_bytes: 4956
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue> 
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
#define db double
#define int LL
using namespace std;
const int N   = 2e5+233;
//const int mod = ;
const int INF =numeric_limits<int >::max();

#define rep(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}

void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
#define GG return printf("-1"),0
int n,a[N],ans;
signed main()
{
	read(n);
	rep(i,1,n) 
	{
		read(a[i]);
		if (a[i]-a[i-1]>1) GG;
	}
	if (a[1]!=0) GG;
	for (int i=1;i<=n;)
	{
		if (i==n ) break;
		int l=i,r=i+1;
		while (a[r]!=0&&r<=n) ++r;--r;
		//if (r>n)  i=n+1;
		//else i=r+1;
		i=r+1;
		for (int j=r;j>=l;)
		{
			int pos=j;
			while (a[pos]-a[pos-1]==1&&pos>=l) --pos;
			ans+=a[j];
			j=pos-1;
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
X, N = map(int, input().split(' '))
if N > 0:
    p = list(map(int, input().split(' ')))
else:
    print(X)
    exit(0)

if X not in p:
    print(X)
    exit(0)

i = 1
while(True):
    if X - i not in p:
        print(X - i)
        exit(0)
    if X + i not in p:
        print(X + i)
        exit(0)
    i += 1

Measured memory_bytes: 9140
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll INF=1e18;
int main()
{
	int n;
	cin>>n;
	ll a[20000];
	for(int i=0; i<n; i++) cin>>a[i];
	ll p10=1;
	int ans=0;
	for(int i=0; i<=16; i++){
		ll dp[2][20001][10];
		for(int j=0; j<=n; j++){
			for(int k=0; k<10; k++){
				dp[0][j][k]=INF; dp[1][j][k]=-1;
			}
		}
		dp[0][0][0]=0;
		dp[1][0][0]=0;
		for(int j=0; j<n; j++){
			for(int k=0; k<10; k++){
                dp[0][j+1][k]=min(dp[0][j+1][k], dp[0][j][k]);
				dp[1][j+1][k]=max(dp[1][j+1][k], dp[1][j][k]);
				if(dp[1][j][k]==-1) continue;
				ll a0=p10*k+dp[0][j][k]+a[j];
				ll a1=p10*k+dp[1][j][k]+a[j];
				dp[0][j+1][a0/p10%10]=min(a0%p10, dp[0][j+1][a0/p10%10]);
				dp[1][j+1][a0/p10%10]=max(a0%p10, dp[1][j+1][a0/p10%10]);
				dp[0][j+1][a1/p10%10]=min(a1%p10, dp[0][j+1][a1/p10%10]);
				dp[1][j+1][a1/p10%10]=max(a1%p10, dp[1][j+1][a1/p10%10]);
			}
		}
		for(int k=9; k>=0; k--){
			if(dp[1][n][k]>=0){
				ans+=k;
				break;
			}
		}
		p10*=10;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main()
{
    long n;
    cin >> n;
    long max = 0;

    map<string, int> st{};
    for (int i = 0; i < n; ++i) {
        string tmp;
        cin >> tmp;
        st[tmp]++;
        if (max < st[tmp]) max = st[tmp];
    }
    for (const auto& e: st) {
        if (e.second == max) cout << e.first << endl;
    }
    return 0;
}


Measured memory_bytes: 25728
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp
//ƒxƒ‹ƒ}ƒ“ƒtƒH[ƒh–@
#include<iostream>
#define MAX_V 100000
#define MAX_E 500000
#define INF 1e9
using namespace std;
struct edge {
	int from, to, cost;
};
edge es[MAX_E];
int d[MAX_V];
int V;
int E;



bool find_negative_loop(int s)
{
	d[s] = 0;
	int count = 0;
	while (true)
	{
		bool update = false;
		count++;
		for (int i = 0; i < E; i++)
		{

			if (d[es[i].from] != INF && d[es[i].to] > d[es[i].from] + es[i].cost)
			{
				if (count == V)
				{
					return true;
				}
				d[es[i].to] = d[es[i].from] + es[i].cost;
				update = true;
			}
		}
		if (update == false)
		{
			break;
		}


	}
	return false;
}

int main()
{

	int r;
	cin >> V >> E >> r;
	for (int i = 0; i < MAX_V; i++)
	{
		d[i] = INF;
	}
	for (int i = 0; i < E; i++)
	{
		cin >> es[i].from >> es[i].to >> es[i].cost;
	}
	if (find_negative_loop(r))
	{
		cout << "NEGATIVE CYCLE" << endl;
	}
	else
	{
		for (int i = 0; i < V; i++)
		{
			if (d[i] == INF)
			{
				cout << "INF" << endl;
			}
			else
			{
				cout << d[i] << endl;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 9204
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll A, B, C;

int main() {
	cin >> A >> B >> C;
	if ((10 * B + C) % 4 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}


int digit(int n){
    int cnt = 0;
    while(n>0){
        cnt++;
        n /=10;
    }
    return cnt;
}
int main()
{
    int a,b; cin >> a >> b;
    

    int d = digit(b);
    int x = a*pow(10,d) + b;
    
    bool ans = false;
    
    rep(i,1000){
        if(x == i*i) ans = true;
    }
    
    cout << yn(ans) << endl;
}



Measured memory_bytes: 256
S = input()
N = len(S)
def f(s):
    n = len(s)
    for i in range((n-1)//2+1):
        if s[i] != s[n-i-1]:
            return False
    return True

if f(S) and f(S[:(N-1)//2]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
package main
import "fmt"
import "strconv"
import "strings"

func strToInt(s string) int {
    i, err := strconv.Atoi(s)
    if err != nil{
        fmt.Println(err)
    }
    return i
}

func main(){
    // Your code here!
    var a, b string
    fmt.Scan(&a, &b)
    s := strings.Repeat(a, strToInt(b))
    t := strings.Repeat(b, strToInt(a))
    
    if s < t{
        fmt.Println(s)
    }else{
        fmt.Println(t)
    }
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <memory>
#include <algorithm>
#include <cstring>

#define ll long long

using namespace std;

ll gcd(ll a, ll b)
{
    for (;;)
    {
        if (a == 0) return b;
        b %= a;
        if (b == 0) return a;
        a %= b;
    }
}

ll div(ll a, ll b, ll c) {
    ll start = a + (a % c == 0 ? 0 : c - a % c);
    ll len = (b - start + 1);
    if (len <= 0)
        return 0;
    return len / c + (len % c ? 1 : 0);
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (b < c && b < d) {
        cout << b - a + 1;
        return 0;
    }
    if (c == 1 || d == 1) {
        cout << 0;
        return 0;
    } else if (c == d) {
        cout << (b - a + 1) - div(a, b, c);
        return 0;
    }
    cout << (b - a + 1) - div(a, b, c) + div(a, b, (c / gcd(c, d) * d)) - div(a, b, d);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ll  long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define MAX_N 100000
using namespace std;
// int dx[4] = {1,-1,0,0};
// int dy[4] = {0,0,1,-1};
ll dp[401][401];
ll prefixSum[401];
ll get(vector<ll>&arr, ll i, ll j){
    if(i>=j)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    ll ans = LLONG_MAX; 
    for(int k=i+1;k<=j;k++){
        ll temp = get(arr,i,k-1)+get(arr,k,j);
        ll sum = prefixSum[j];
        if(i-1>=0)
            sum-=prefixSum[i-1];
        ans = min(ans,temp+sum);
    }
    return dp[i][j] = ans;
}

void preprocess(vector<ll>&arr, ll n){
    prefixSum[0]=arr[0];
    repA(i,1,n-1)
    prefixSum[i]=prefixSum[i-1]+arr[i];
}

void solve(){

    ll n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    vector<ll>arr(n);

    rep(i,n)
    cin>>arr[i];
    preprocess(arr,n);
    ll ans = get(arr,0,arr.size()-1);
    db1(ans);   

}
int main(){ 

int t=1;
//cin>>t;
while(t--){
 solve();
}
  return 0; 
}


Measured memory_bytes: 1536
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy


def Partition(A,p,r):
    x = A[r][1]
    i = p - 1
    for j in range(p,r):
        if A[j][1] <= x:
            i = i + 1
            tmp = A[i]
            A[i] = A[j]
            A[j] = tmp
    tmp2 = A[i+1]
    A[i+1] = A[r]
    A[r] = tmp2
    return i + 1

def QuickSort(A,p,r):
    if p<r:
        q = Partition(A,p,r)
        QuickSort(A,p,q-1)
        QuickSort(A,q+1,r)

if __name__ == "__main__":
    n = int(input())
    card = []
    for i in range(n):
        key,val = input().split()
        card.append([key,int(val)])
    card2 = copy.copy(card)
    card2.sort(key= lambda x:x[1])
    QuickSort(card,0,n-1)
    if card2 == card:
        print("Stable")
    else:
        print("Not stable")
    for i in range(n):
        print(card[i][0],card[i][1])


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

/*bool palin(string s , int start , int end){
    
    int j = end-1;

    for(int i = start ; i < (start + end)/2 ; i++){
        if(s[i] == s[j]){
            
            j--;
            
        }
        else{
            
            return false;
        }
    }
    return true;
}*/
int main(){
  
  int L;
  cin >> L;

  double side = (double)L/3;

  

  double ans = side * side * side ;

  cout<< fixed << setprecision(12) << ans;


  
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count =0;
		
		for (int i =0; i< N; i++) {
			long a = sc.nextLong();
			while (a%2 ==0) {
				a /= 2;
				count++;
			}
		}
		System.out.println(count);
		
	}
}


Measured memory_bytes: 36012
#include <bits/stdc++.h>
using namespace std;
int main() {
	double num;
	while(cin>>num,num>=0){
	    string str;
		for(int i=7;i>-5;i--){
			str+=int(num/pow(2,i))+'0';
			if(num/pow(2,i)>=1)num-=pow(2,i);
			if(i==0)str+='.';
		}
		if(num/pow(2,-5)>0||num/pow(2,9)>=1)cout<<"NA"<<endl;
		else cout<<str<<endl;
	}
}

Measured memory_bytes: 1264
n,k,c=map(int,input().split());s=input();
l=[];r=[];i=0;j=n-1
while 0<=i<=n-1:
  if s[i]=="o":l+=i,;i+=c+1
  else:i+=1
while 0<=j<=n-1:
  if s[j]=="o":r+=j,;j-=c+1
  else:j-=1
a=list(set(l)&set(r))
if len(a)>k:exit()
for q in sorted(a):print(q+1)

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

void solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    int maxi = a[0];
    if (n == 1)
    {
        cout << "0\n";
        return;
    }
    long long int ans = 0;
    for (int i = 1; i < n; i++)
    {
        if (a[i] < maxi)
        {
            ans += maxi - a[i];
        }
        else if (a[i] > maxi)
            maxi = a[i];
    }
    cout << ans << "\n";

}

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

    return 0;
}


Measured memory_bytes: 3988