akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

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

int main()
{
    int n; cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    ll r[n],l[n];
    r[0] = a[0];
    l[n-1] = a[n-1];
    for(int i = 1; i < n; i++) r[i] = gcd(a[i],r[i-1]);
    for(int i = n-2; i >= 0; i--) l[i] = gcd(l[i+1],a[i]);
    ll ans = 0;
    rep(i,n){
        if(i == 0) ans = max(ans,l[1]);
        else if(i == n-1) ans = max(ans,r[n-2]);
        else ans = max(ans,gcd(r[i-1],l[i+1]));
        //cout << l[i] << endl;
    }
    cout << ans << endl;
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string a, b, c; cin >> a >> b >> c;
    cout << "A" << b[0] << "C" << endl;
}

Measured memory_bytes: 3644
x,k,d=map(int,input().split())
if x<0:
    x*=(-1)
z=x//d
ans_p=x-z*d
ans_n=-(ans_p-d)
if k<z:
    ans=x-k*d
elif k==z:
    ans=ans_p
else:
    num=k-z
    if num%2==1:
        ans=ans_n
    else:
        ans=ans_p
print(ans)

Measured memory_bytes: 61936
import math

a, b = map(int, input().split())

min = int(math.ceil(a / 0.08))
max = min
while math.floor(max * 0.08) == a:
    max += 1

for i in range(min, max):
    if math.floor(i * 0.1) == b:
        print(i)
        break
else:
    print(-1)


Measured memory_bytes: 3060
H = []
W = []
for _ in range(300):
  _h, _w = map(int, input().split())
  if _h == 0 and _w == 0:
    break
  else:
    H.append(_h)
    W.append(_w)

for i in range(len(H)):
  for _ in range(H[i]):
    dash = ""
    for _ in range(W[i]):
      dash = dash + "#"
    print(dash)
  print('')



Measured memory_bytes: 5628
// Sakhiya07 - Yagnik Sakhiya

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

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>

#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 200005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
string s;
ll dp[N];
vector<ll> v;
ll solve1(ll id)
{
    if(id==0)    return 0;
    ll ans = dp[id];
    if(ans!=-1)   return ans;
    ans = 1e9;
    for(auto X:v)
    {
        if(X<=id)
        {
            ans = min(ans,1+solve1(id-X));
        }
    } 
    return dp[id] = ans;
}
void solve()
{
    ll n;
    cin >> n;
    v.pb(1);
    ll temp = 6;
    while(temp<=n)
    {
        v.pb(temp);
        temp *= 6;
    }
    temp = 9;
    while(temp<=n)
    {
        v.pb(temp);
        temp *= 9;
    }
    sort(all(v));
    memset(dp,-1,sizeof(dp));
    ll ans = solve1(n);
    cout<<ans;
}

int main()
{
    FAST;
    ll t = 1;
  //  cin >> t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
using pp=pair<ll,pair<ll,ll>>;
#define MAX 1000000
#define MOD 998244353
#define INF 1000000000000000000

int main(){
  int N,M;
  cin>>N>>M;
  vector<ll> a(N),b(M);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  for(int i=0;i<M;i++){
    cin>>b[i];
  }

  vector<ll> c=convolution<MOD>(a,b);
  for(int i=0;i<N+M-1;i++){
    cout<<c[i]<<" ";
  }
  cout<<endl;

}


Measured memory_bytes: 27244
#include <bits/stdc++.h>
#define ll long long

#define TASKNAME ""

using namespace std;

const int INF = 1e9 + 7;
const int MAXN = 1e6 + 7;
const double EPS = 1e-8;

int main() {
    #ifdef MY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(TASKNAME".in", "r", stdin);
        //freopen(TASKNAME".out", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // MY
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int r = 0;
    ll res = 0;
    ll sum = 0;
    for (int l = 0; l < n; l++) {
        while (r < n && (sum ^ a[r]) == sum + a[r]) {
            sum += a[r];
            r++;
        }
        sum -= a[l];
        res += r - l;
    }
    cout << res;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
int n;

int main(){
	IOS
	cin >> n;
	bool berak=false;
	while(n--){
		int x;
		cin >> x;
		if(x%2==0){
			if(x%3!=0 and x%5!=0){
				berak=true;
			}
		}
	}
	if(berak){
		cout << "DENIED" << '\n';
	}
	else{
		cout << "APPROVED" << '\n';
	}
}

Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 1e5 + 5;
const int mod = 1e9 + 7; 
using namespace std;

int n, m, k, ans, f[N], stk[N], top; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int fpow(int x, int y)
{
	int res = 1;
	for( ; y; y >>= 1, x = 1ll * x * x % mod)
		if(y & 1) res = 1ll * res * x % mod;
	return res; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin);
#endif
	n = read <int> (), m = read <int> (), k = (n + 1) / 2; 
	for(int i = 1; i * i <= n; i++)
		if(n % i == 0)
		{
			stk[++top] = i; 
			if(i * i != n) stk[++top] = n / i; 
		}
	sort(stk + 1, stk + top + 1); 
	for(int x, i = 1; i <= top; i++) x = (stk[i] + 1) / 2, f[i] = fpow(m, x); 
	for(int i = 1; i <= top; i++)
		for(int j = i + 1; j <= top; j++)
			if(stk[j] % stk[i] == 0) f[j] = (f[j] - f[i] + mod) % mod; 
	for(int i = 1; i <= top; i++)
	{
		if(stk[i] & 1) ans = (1ll * f[i] * stk[i] + ans) % mod;
		else ans = (1ll * f[i] * (stk[i] / 2) + ans) % mod; 
	}
	printf("%d\n", ans); 
	return 0; 
}

Measured memory_bytes: 3236
#include<stdio.h>
#define N 100000
#define Q 50000

int A[N],n;

int search(int k){
  int l,r,m;

  l=0;r=n;

  while(l<r){
    m=(l+r)/2;
    if(k==A[m])return 1;
    if(k>A[m])l=m+1;
    else if(k<A[m])r=m;
  }
  return 0;
}

main(){
  int i,q,k;
  int c=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(search(k))c++;
  }

  printf("%d\n",c);

  return 0;

}



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

int main() {
  int h, w;
  cin >> h >> w;
  vector<int> delRow(h, 0), delCol(w, 0);
  vector<vector<char>> data(h, vector<char>(w));
  char BLACK = '#';

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> data.at(i).at(j);
    }
  }

  for (int i= 0; i < h; i++) {
    bool sameRow = true;
    for (int j = 0; j < w; j++) {
      if (
        data.at(i).at(j) == BLACK ||
        j > 0 && data.at(i).at(j-1) != data.at(i).at(j)
      ) {
        sameRow = false;
        break;
      }
    }
    if (sameRow) delRow.at(i) = 1;
  }

  for (int i= 0; i < w; i++) {
    bool sameColumn = true;
    for (int j = 0; j < h; j++) {
      if (
        data.at(j).at(i) == BLACK ||
        j > 0 && data.at(j-1).at(i) != data.at(j).at(i)
      ) {
        sameColumn = false;
        break;
      }
    }
    if (sameColumn) delCol.at(i) = 1;
  }

  for (int i = 0; i < h; i++) {
    if (delRow.at(i) == 1) continue;
    for (int j = 0; j < w; j++) {
      if (delCol.at(j) == 1) continue;
      cout << data.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import sys

use_clipboard=True

def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if sys.platform =='ios':
	if use_clipboard:
		ic=input_clipboard()
		input = lambda : ic.__next__()
	else:
		sys.stdin=open('inputFile.txt')


	
#+++++

x, y = map(int, input().split())
ret = x if x % y != 0 else -1
print(ret)

Measured memory_bytes: 38256
#include <iostream>
#include <cstring>
#include <queue>

using namespace std;

#define fst first
#define scd second
#define mp make_pair
#define rep(i,x) for(int i=0;i<(int)x;++i)
#define rep1(i,x) for(int i=1;i<=(int)x;++i)

class P {
public:
    int x, y;
    P (int x0,int y0) {
        x=x0,y=y0;
    };
};

int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};

int d[53][53];
int memo[53][53][53][53];
bool used[53][53][53][53];

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

    int X, Y;
    while (cin >> X >> Y, X || Y) {
        memset(memo, 0, sizeof(memo));
        memset(used, false, sizeof(used));

        int tx, ty; cin >> tx >> ty;
        int kx, ky; cin >> kx >> ky;
        fill(d[0], d[Y+2], 1);
        rep1(i, Y) rep1(j, X) cin >> d[i][j];

        queue<pair<P, P> > q;

        q.push(mp(P(tx, ty), P(kx, ky)));
        memo[ty][tx][ky][kx] = 0;
        used[ty][tx][ky][kx] = true;

        int ans = -1;

        while (q.size()) {
            pair<P, P> r = q.front(); q.pop();
            P f = r.fst, s = r.scd;

            if (memo[f.y][f.x][s.y][s.x] >= 100) break;

            if (f.x == s.x && f.y == s.y) {
                ans = memo[f.y][f.x][s.y][s.x];
                break;
            }

            rep(i, 4) {
                int nfx = f.x + dx[i], nfy = f.y + dy[i];
                int nsx = s.x - dx[i], nsy = s.y - dy[i];
                if (d[nfy][nfx] == 1) nfx = f.x, nfy = f.y;
                if (d[nsy][nsx] == 1) nsx = s.x, nsy = s.y;
                if (!used[nfy][nfx][nsy][nsx]) {
                    used[nfy][nfx][nsy][nsx] = true;
                    memo[nfy][nfx][nsy][nsx] = memo[f.y][f.x][s.y][s.x] + 1;
                    q.push(mp(P(nfx, nfy), P(nsx, nsy)));
                }
            }
        }

        if (ans == -1) cout << "NA" << endl;
        else cout << ans << endl;
    }
}

Measured memory_bytes: 40048
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n;
ll ans;
vll a;
ll ST[4*MAX],A[MAX],dp[MAX];
ll vis[MAX];
void build(ll node,ll lo,ll hi){
	if(lo == hi){
		ST[node] = lo;
		return;
	}
	ll mid = (lo+hi)>>1;
	build(node<<1,lo,mid);
	build(node<<1|1,mid+1,hi);
	ST[node]=(A[ST[node<<1]]>A[ST[node<<1|1]])?ST[node<<1]:ST[node<<1|1];
}

void update(ll node,ll lo,ll hi,ll x,ll y){
	if(lo == hi){
		ST[node]=lo;
		A[lo]+=y;
		return;
	}
	ll mid = (lo+hi)>>1;
	if(lo<=x and mid>=x){
		update(node<<1,lo,mid,x,y);
	}
	else{
		update(node<<1|1,mid+1,hi,x,y);
	}
	ST[node]=(A[ST[node<<1]]>A[ST[node<<1|1]])?ST[node<<1]:ST[node<<1|1];
}

ll query(ll node,ll lo,ll hi,ll l,ll r){
	if(lo>r or hi<l){
		return -1;
	}
	else if(l<=lo and hi<=r){
		return ST[node];
	}
	ll mid = (lo+hi)>>1LL;
	ll p1 = query(node<<1,lo,mid,l,r);
	ll p2 = query(node<<1|1,mid+1,hi,l,r);
	if(p1 == -1)return p2;
	if(p2 == -1)return p1;
	return (A[p1]>A[p2])?p1:p2;
}
int main(){FAST;
multiset<ll>f;
cin>>n;
ll x;
cin>>x;
f.insert(x);
for(ll i=1;i<n;i++){
	cin>>x;
	auto it = f.lower_bound(x);
	if(it == f.begin()){
		f.insert(x);
	}
	else{
		it--;
		f.erase(it);
		f.insert(x);
	}
}
cout<<f.size();
return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=1e9;
const double PI=acos(-1);


ll binary_power(ll a, ll n) {
    if (n==0) return 1;
    ll k=binary_power(a,n/2);
    if (n%2==0) return (k*k)%MOD;
    else return (((k*k)%MOD)*a)%MOD;
}


int main() {
    ios_base::sync_with_stdio(false); 

    ll m,k;
    cin >> m >> k;
    ll p=pow(2,m);
    if (k==0) {
        rep(i,p) cout << i << ' ' << i << ' ';
        cout << endl;
    } else if (m==1 && k==1) {
        cout << -1 << endl;
    } else if (k<=p-1) {
        rep(i,k) cout << i << ' ';
        cout << k << ' ';
        invrep(i,k) cout << i << ' ';
        repr(i,k+1,p) cout << i << ' ';
        cout << k << ' ';
        invrepr(i,k+1,p) cout << i << ' ';
        cout << endl;
    } else cout << -1 << endl;

    return 0;
}


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


int main() {

	int N;
	cin >> N;

	for (int i = 1; i <=9; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			if (i*j == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}

	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
typedef long long ll;
int x,n,y,a,b,c,cnt[maxn]; 
struct node {
	int v,c;
	bool operator < (const node &rhs) const {
		return v > rhs.v;
	}
}p[maxn];
int main() {
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	for (int i = 1; i <= a; i++) {
		scanf("%d",&p[i].v);
		p[i].c = 1;
	}
	for (int i = 1; i <= b; i++) {
		scanf("%d",&p[a + i].v);
		p[a + i].c = 2;
	}
	for (int i = 1; i <= c; i++) {
		scanf("%d",&p[a + b + i].v);
		p[a + b + i].c = 0;
	}
	sort(p + 1,p + a + b + c + 1);
	int cx = 0,cy = 0,tot = 0;
	ll ans = 0;
	for (int i = 1; i <= a + b + c && tot < x + y; i++) {
		if (p[i].c == 1 && cx < x) {
			ans += p[i].v;
			cx++;
			tot++;
		} else if (p[i].c == 2 && cy < y) {
			ans += p[i].v;
			cy++;
			tot++;
		} else if (p[i].c == 0) {
			ans += p[i].v;
			tot++;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
n, y = map(int, input().split())

for i in range(n + 1):
    for j in range(n - i + 1):
        if(((10000 * i) + (5000 * j) + (1000 * (n - i - j))) == y):
            print(i, " ", j, " ", (n - i - j))
            exit()

print(-1, " ", -1, " ", -1)
5


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

class union_find{
public:
  int n;
  int *par, *rank;

  union_find(int n){
    this-> n = n;
    par = new int[n];
    rank = new int[n];
    init();
  }
  
  int find(int x){
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }

  void unite(int x, int y){
    x = find(x);
    y = find(y);

    if(x == y) return;

    if(rank[x] < rank[y]){
      par[x] = y;
    }else{
      par[y] = x;
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }

  void print(){
    cout << "---------------" << endl;
    for(int i=0; i<n; i++){
      cout << "par " << i << " : " << par[i] << endl;
    }
    cout << "---------------" << endl;
  }

private:
  void init(){
    for(int i=0; i<n; i++){
      par[i] = i;
      rank[i] = 1;
    }
  }
};

int main(){
  int n, q; cin >> n >> q;
  union_find uf(n);

  for(int i=0; i<q; i++){
    int o, x, y; cin >> o >> x >> y;
    if(o == 0){
      uf.unite(x, y);
    }
    if(o == 1){
      bool t = uf.same(x, y);
      cout << (t? 1: 0) << endl;
    }
  }
  
  /* uf.print(); */

  return 0; 
}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  
  if(s[0] > s[2]) swap(s[0], s[2]);
  if(s[0] > s[1]) swap(s[0], s[1]);
  if(s[1] > s[2]) swap(s[1], s[2]);
  
  
  if(s == "abc") cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97
#define rep(i,n) for(int i=1;i<=n;i++)
typedef long long  ll;
typedef long double  ld;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)

int ilog(ll n,ll k){
int cnt=0;
for(int i=1;i<=n;i*=k){
cnt++;
}cnt--;
return cnt;
}
int main() {cerr<<ilog(1,2);
  int x;
  cin>>x;
  int ma=-1;
  for(int i=2;i<32;i++){ma=max(ma,(int)pow(i,ilog(x,i)));}
  if(x==10)cout<<9<<endl;else cout<<ma<<endl;}

Measured memory_bytes: 384
import sys

lines = []
for line in sys.stdin:
   lines.append(line)
    
if len(lines) != 2:
   print("No")
elif len(lines[0])+1 != len(lines[1]):
   print("No")
elif (lines[0][:-1] != lines[1][:-2]):
   print("No")
else:
   print("Yes")


Measured memory_bytes: 9016
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,m,i,j,x,s=0;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>x;
        s+=x;
    }
    if(n>=s)
        cout<<n-s<<endl;
    else
        cout<<"-1"<<endl;

}


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

int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  int t=0;
  for(int i=0;i<n-2;i++){
   if((p[i]<p[i+1] && p[i+1]<p[i+2]) || (p[i]>p[i+1] && p[i+1]>p[i+2])){
     t++;
   }
    
  }
  cout<<t<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

const int maxn = 1e5+5;
int n,ans[maxn];
char ch[maxn];

bool check()
{
    if(!ans[n])
    {
        if(ch[n] == 'o' && ans[n-1] != ans[1]) return 0;
        if(ch[n] == 'x' && ans[n-1] == ans[1]) return 0;
    }
    else
    {
        if(ch[n] == 'x' && ans[n-1] != ans[1]) return 0;
        if(ch[n] == 'o' && ans[n-1] == ans[1]) return 0;
    }
    if(!ans[1])
    {
        if(ch[1] == 'o' && ans[n] != ans[2]) return 0;
        if(ch[1] == 'x' && ans[n] == ans[2]) return 0;
    }
    else
    {
        if(ch[1] == 'x' && ans[n] != ans[2]) return 0;
        if(ch[1] == 'o' && ans[n] == ans[2]) return 0;
    }
    return 1;
}

int main()
{
    scanf("%d%s",&n,ch+1);
    for(int i = 0 ; i < 4 ; i ++)
    {
        ans[1] = i&1;
        ans[2] = (i>>1)&1;
        for(int j = 3 ; j <= n ; j ++)
        {
            if(!ans[j-1])
            {
                if(ch[j-1] == 'o') ans[j] = ans[j-2];
                else ans[j] = ans[j-2]^1;
            }
            else
            {
                if(ch[j-1] == 'x') ans[j] = ans[j-2];
                else ans[j] = ans[j-2]^1;
            }
        }
        if(check())
        {
            for(int j = 1 ; j <= n ; j ++)
            {
                if(!ans[j]) printf("S");
                else printf("W");
            }
            printf("\n");
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}


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

#define int long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define ps(x, y) fixed << setprecision(y) << x
#define rep(i, begin, end) for (int i = begin; i < end; i++)
#define all(p) p.begin(), p.end()
#define sz(x) (int)x.size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = (int)(1e9 + 7);
const int inf = (int)(1e18);
void run()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int power(int a, int n)
{
    if (n == 0)
    {
        return 1;
    }
    a %= mod;
    int ans = power(a, n / 2);
    ans *= ans;
    ans %= mod;
    if (n & 1)
    {
        ans *= a;
    }
    ans %= mod;
    return ans;
}
void solution()
{
    int n;
    cin >> n;
    int ans = power(10, n) - 2 * power(9, n) + power(8, n);
    ans = (ans + 3 * mod) % mod;
    cout << ans << endl;
    return;
}
int32_t main()
{
    run();
    int t;
    t = 1;
    while (t--)
    {
        solution();
    }
    return 0;
}

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

#define ll long long

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    int n;
    cin >> n;
    string tmp;
    set<string> A;
    while(n--) {
        cin >> tmp;
        A.insert(tmp);
    }
    cout << A.size() << "\n";
    return 0;
}


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

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

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<P> input(n);
    for(int i = 0; i < n; ++i){
        int x, l;
        cin >> x >> l;
        input[i] = P(x + l, x - l);
    }
    sort(input.begin(), input.end());
    int ans = 0, t = -INF * 2;
    for(int i = 0; i < n; ++i){
        int st = input[i].second, ed = input[i].first;
        if(st < t)  continue;
        ++ans;
        t = ed;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
let input = require('fs').readFileSync('/dev/stdin', 'utf8')
// let input = require('fs').readFileSync('./sample_c.txt', 'utf8')
.split(/\n| /)
.slice(0 ,-1)
.map(item => parseInt(item))


const [N] = input



let count = 0



for(let A=1; A*A<N; A++){
    for(let B=A; A*B < N; B++){
        if(A===B)count += 1
        else count += 2
    }
}
console.log(count)

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

int main()
{
  double v;
  while (cin >> v) {
    double t = v / 9.8;
    double y = 4.9 * t * t;

    int ans = 1;
    while (5*ans-5 < y)
      ++ans;

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

Measured memory_bytes: 0
// "static void main" must be defined in a public class.
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        int[] sign = new int[4];
        for(int i = 0; i < Math.pow(4,2); i++){
            for(int j = 0; j < 4; j++){
                if((i>>j & 1) == 1){sign[j] = 1;}
                else{sign[j] = -1;}
            }
            int ans = sign[0] * (str.charAt(0)-'0') + 
                sign[1] * (str.charAt(1)-'0') + 
                sign[2] * (str.charAt(2)-'0') + 
                sign[3] * (str.charAt(3)-'0');
            if(ans == 7){
                String head = new String();
                if(str.charAt(0)-'0' != 0){
                    head = cv(sign[0]) == "+"?"":"-";
                }
                System.out.println(head+(str.charAt(0)-'0')
                                  +cv(sign[1])+(str.charAt(1)-'0')
                                  +cv(sign[2])+(str.charAt(2)-'0')
                                  +cv(sign[3])+(str.charAt(3)-'0') +"=7");
                break;
            }
        }
        
    }
    private static String cv(int a){
            if(a == 1){return "+";}
            else{return "-";}
        }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

#define NMAX 105
#define WMAX 10005
#define DIAGONAL 1
#define TOP 0

struct Item{
    int value, weight;
};

int N,W;
Item items[NMAX+1];
int C[NMAX+1][WMAX+1], G[NMAX+1][WMAX+1];

void compute(int &maxValue, vector<int> &selection){
    for(int w=0;w<=W;w++){
        C[0][w] = 0;
        G[0][w] = DIAGONAL;
    }
    
    for(int i=1;i<=N;i++) C[i][0] = 0;
    
    for(int i = 1;i<=N;i++){
        for(int w=1;w<=W;w++){
            C[i][w] = C[i-1][w];
            G[i][w] = TOP;
            if(items[i].weight>w) continue;
            if(items[i].value+C[i-1][w-items[i].weight]>C[i-1][w]){
                C[i][w] = items[i].value + C[i-1][w-items[i].weight];
                G[i][w] = DIAGONAL;
            }
        }
    }
    
    maxValue = C[N][W];
    selection.clear();
    for(int i=N,w=W;i>=1;i--){
        if(G[i][w]==DIAGONAL){
            selection.push_back(i);
            w-=items[i].weight;
        }
    }
    
    reverse(selection.begin(),selection.end());
}

void input(){
    cin >> N >> W;
    for(int i=1;i<=N;i++){
        cin >> items[i].value >> items[i].weight;
    }
}


int main(){
    int maxValue;
    vector<int> selection;
    input();
    compute(maxValue,selection);
    
    cout << maxValue << endl;
    
    return 0;
}



Measured memory_bytes: 11068
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;
int main()
{
    int n;
    cin>>n;
    cout<<pow(n,3)<<endl;
}


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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, A, B;
    cin >> N >> A >> B;

    int ans = 0;
    for(int i = 1; i <= N; i++){
        int num = i;
        int sum = 0;
        while(num/10 != 0){
            sum += num%10;
            num /= 10;
        }
        sum += num;
        if(A <= sum && sum <= B) ans+=i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main(){

  int n, l, aji, sa;
  aji = 0;
  sa = MAX;
  cin >> n >> l;
  rep(i, n){
    aji += l + i;
    sa = min (abs(l + i), sa);
  }
  if(aji < 0)sa *= -1;
  cout << aji - sa << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

template<class T> class rollinghash {
	const ull mask30 = (1LL << 30) - 1;
	const ull mask31 = (1LL << 31) - 1;
	const ull mod61 = (1LL << 61) - 1;
	vector<ull> base;
	vector<vector<ull>> hashvalue, basepower;
	int length;
	ull multiply(ull a, ull b) {
		ull au = a >> 31; ull ad = a & mask31;
		ull bu = b >> 31; ull bd = b & mask31;
		ull mid = ad * bu + au * bd;
		ull midu = mid >> 30; ull midd = mid & mask30;
		return au * bu * 2 + midu + (midd << 31) + ad * bd;
	}
	ull modulo(ull a) {
		ull au = a >> 61; ull ad = a & mod61;
		ull res = au + ad; if (res >= mod61) res -= mod61;
		return res;
	}
public:
	rollinghash(T s) {
		length = s.size();
		base = { 200003 };
		hashvalue = vector<vector<ull>>(length + 1, vector<ull>(1));
		for (int j = 0; j < 1; j++) {
			for (int i = 0; i < length; i++) {
				hashvalue[i + 1][j] = modulo(multiply(hashvalue[i][j], base[j]) + s[i]);
			}
		}
		basepower = vector<vector<ull>>(length + 1, vector<ull>(1));
		for (int j = 0; j < 1; j++) {
			basepower[0][j] = 1;
			for (int i = 1; i <= length; i++) {
				basepower[i][j] = modulo(multiply(basepower[i - 1][j], base[j]));
			}
		}
	}
	ull hash(ll l, ll r, ll i) {
		assert(l < r && 0 <= l && l < length && 0 < r && r <= length);
		return modulo(hashvalue[r][i] + mod61 * 3 - multiply(hashvalue[l][i], basepower[r - l][i]));
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	string s;
	cin >> s;
	rollinghash<string> rol(s);
	int ans = 0;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			int ok = 0, ng = j - i + 1;
			while (ng - ok > 1) {
				int mid = (ok + ng) / 2;
				bool flag = true;
				rep(k, 1) {
					if (j + mid > n || rol.hash(i, i + mid, k) != rol.hash(j, j + mid, k)) flag = false;
				}
				if (flag) ok = mid;
				else ng = mid;
			}
			chmax(ans, ok);
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int N;
  long long K;
  cin >> N >> K;
  vector<pair<int,int>> ab(N);
  for(int i=0;i<N;i++)  cin >> ab.at(i).first >> ab.at(i).second;

  sort(ab.begin(),ab.end());
  long long count=0;
  int x;
  for(int i=0;i<N;i++){
    if(count>=K) break;
    count+=(long long)ab.at(i).second;
    x=i;
  }
  cout << ab.at(x).first << endl;

  return 0;
}


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

using namespace std;
using ll = long long;

const int M = 320;

int k;
ll mod;

ll C[M][M];

ll fdp[M][M], gdp[M][M];
bool fus[M][M], gus[M][M];

ll f(int t, int c);
ll g(int t, int c);

ll f(int t, int c) {
    if (c == 0) return 1;
    if (t == k) return 0;
    if (fus[t][c]) return fdp[t][c];
    fus[t][c] = true;
    ll ans = 0;
    for (int i = 1; i <= c; i++) {
        ans += g(t+1, i-1) * f(t, c-i) % mod * C[c-1][i-1];
        ans %= mod;
    }
    return fdp[t][c] = ans;
}

ll g(int t, int c) {
    if (t == k+1) return 0;
    if (gus[t][c]) return gdp[t][c];
    gus[t][c] = true;
    return gdp[t][c] = (f(t, c) + g(t+1, c)) % mod;
}

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

    C[0][0] = 1;
    for (int i = 1; i < M; i++) {
        C[i][0] = C[i-1][0];
        for (int j = 1; j < M; j++) {
            C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod;
        }
    }
    cout << f(0, n) << endl;
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <string>
int main(){
  char cf[2] = {'C','F'};
  std::string input;
  std::cin >> input;
  int i=0,j=0;
  for(i-0;i<input.size();i++){
    if(input[i]==cf[j]){
      j++;
      if(j==2){
        std::cout << "Yes" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


int main(){
    int n;
    cin >> n;
    int ans = 0;
    if(n%1000 != 0){
        ans = 1000 - n%1000;
    }
    cout << ans <<endl;
}



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




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

    string s, t = "keyence", ans = "NO";
    cin >> s;
    int n = s.size();

    rep(i,8){
        bool a = true;
        rep(j,7){
            if(i<=j)if(t[j]!=s[n-7+j])
                    a = false;
            if(i>j)if(t[j]!=s[j])
                    a=false;
        }
        if(a)
            ans = "YES";
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
	string S1,S2,S3,R;
	int H,W,x;
	cin>>H>>W>>S1>>S2;
	for(int j=0;j<W;j++){
		if(S1[j]!='#'){
			if(j!=W-1&&S1[j+1]=='#')
				x++;
			if(j!=0&&S1[j-1]=='#')
				x++;
			if(S2[j]=='#')
				x++;
			if(j!=W-1&&S2[j+1]=='#')
				x++;
			if(j!=0&&S2[j-1]=='#')
				x++;
			cout<< x ;
			x=0;
		}
		else
			cout<< "#" ;
	}
	cout << endl;
  	if(H>2){
      for(int i=1;i<H-1;i++){
          cin>>S3;
          for(int j=0;j<W;j++){
              if(S2[j]!='#'){
                  if(S1[j]=='#')
                      x++;
                  if(j!=W-1&&S1[j+1]=='#')
                      x++;
                  if(j!=0&&S1[j-1]=='#')
                      x++;
                  if(j!=W-1&&S2[j+1]=='#')
                      x++;
                  if(j!=0&&S2[j-1]=='#')
                      x++;
                  if(S3[j]=='#')
                      x++;
                  if(j!=W-1&&S3[j+1]=='#')
                      x++;
                  if(j!=0&&S3[j-1]=='#')
                      x++;
                  cout<< x;
                  x=0;
              }
              else
                  cout<< "#" ;
          }
          cout << endl;
          S1=S2;
          S2=S3;
      }
    }
  	if(H>1){
      for(int j=0;j<W;j++){
          if(S2[j]!='#'){
              if(j!=W-1&&S2[j+1]=='#')
                  x++;
              if(j!=0&&S2[j-1]=='#')
                  x++;
              if(S1[j]=='#')
                  x++;
              if(j!=W-1&&S1[j+1]=='#')
                  x++;
              if(j!=0&&S1[j-1]=='#')
                  x++;
              cout<< x;
              x=0;
          }
          else
              cout << "#";
      }
    }
	cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x, y;
	scanf("%d %d", &x, &y);
	int ans = 0;
	if (x <= 3)
		ans += 100000 * (4 - x);
	if (y <= 3)
		ans += 100000 * (4 - y);
	if (x == y && x == 1)
		ans += 400000;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=[0]*M
y=[0]*M
c=[0]*M
for i in range(M):
    x[i],y[i],c[i]=map(int,input().split())

a_m=min(a)
b_m=min(b)

ans=(a_m+b_m)
tem=0

for i in range(M):
    aa=x[i]-1
    bb=y[i]-1
    hikaku=a[aa]+b[bb]-c[i]
    ans=min(ans,hikaku)


print(ans)

Measured memory_bytes: 68716
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()

const int mod = 1000000007;
int binpow(int a, int b, int mod)
{
    int ans = 1;
    a = a % mod;
    b = b % mod;
    if (b == 0)
        return 1;
    while (b)
    {
        if (b & 1)
            ans = ((ans % mod) * (a % mod)) % mod;
        a = ((a % mod) * (a % mod)) % mod;
        b >>= 1;
    }
    return ans % mod;
}

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int ct = 0;
        for (int i = 1; i < n; ++i)
        {
        outer:;
            for (int j = i; j < n; ++j)
            {
                int val = i * j;
                if (val >= n)
                {
                    i++;
                    goto outer;
                }
                else
                {
                    if (i == j)
                        ct++;
                    else
                    {
                        ct += 2;
                    }
                }
            }
        }
        cout << ct << "\n";
    }
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
typedef pair<ll, ll> LP;
 
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1)%MOD;
}
 
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return m%MOD*COM(m-1,n)%MOD*modinv(m-n,MOD)%MOD;
}
 
int main()
{
  double n,t,a,h[1200],ans;
  ll m;
  ans=1000000;
  cin >> n >> t >> a;
  rep(i,n)cin >> h[i];
  rep(i,n)ans=min(ans,abs(t-h[i]*0.006-a));
  rep(i,n)if(ans==abs(t-h[i]*0.006-a))m=i+1;
  printf("%lld",m);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  int k;
  cin >> k;
  rep(i, s.size()-1){
    char now = s.at(i);
    if(now == 'a') continue;
    // cerr  << 'z' - now << endl;
    if('z' - now + 1 <= k){
      s.at(i) = 'a';
      k -= 'z' - now + 1;
    }
    if(k == 0) break;
  }
  int c = s.back() - 'a';
  c += k;
  c %= 26;
  s.back() = 'a' + c;
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>

int main(int argc, char *argv[])
{
    int n;
    int ans = 0;

    std::vector<std::vector<std::pair<int,int>>> xy;

    // input
    std::cin >> n;
    xy.resize(n);

    // input each person's testimony
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        xy[i].resize(a);
        for (int j = 0; j < a; j++) {
            int x, y;
            std::cin >> x >> y;
            x--;
            xy[i][j].first = x;
            xy[i][j].second = y;
        }
    }

    // check
    for (int i = 0; i < std::pow(2, n); i++) {
        int feasible = true;
        std::vector<bool> t(n, false);

        // bitmapの展開
        for (int j = 0; j < n; j++) {
            if (((i>>j) & 0x01) == 1) {
                t[j] = true;
            }
        }

        for (int j = 0; j < n; j++) {
            if (t[j]) {
                for (int k = 0; k < xy[j].size(); k++) {
                    const int x = xy[j][k].first;
                    const int y = xy[j][k].second;
                    if (t[x] != y) {
                        feasible = false;
                        break;
                    }
                }
            }
            if (!feasible) {
                break;
            }
        }

        if (!feasible) {
            continue;
        }

        int count = 0;
        for (int j = 0; j < n; j++) {
            if (t[j]) {
                count++;
            }
        }
        ans = std::max(ans, count);
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
// #include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i,k,n) for(ll i=k; i<(ll)(n); i++)
#define Q 1000000007


struct UnionFind {
    vector<ll> par; //par[a]=b: aの親がb

    UnionFind(ll N) : par(N) { //初めは全て根として初期化
        rep(i,0,N) par[i] = i;
    }

    ll root(ll x) { //xの属する根を求める
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { //xとyの木を併合
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return; //根が同じときはそのまま
        par[rx] = ry;
    }

    bool same(ll x, ll y) { //x,y の属する木が同じならtrue
        return root(x) == root(y);
    }
};


int main(){
    ll n,m; cin >> n >> m;
    UnionFind tree(n);
    vector<ll> p(n);
    rep(i,0,n) {
        cin >> p[i];
        --p[i];
    }
    vector<ll> x(m),y(m);
    rep(i,0,m) {
        cin >> x[i] >> y[i];
        --x[i]; --y[i];
        tree.unite(x[i],y[i]);
    }

    ll ans = 0;
    rep(i,0,n) {
        if(i == p[i]) ans++;
        else if(tree.same(i,p[i])) {
            // cout << i << "," << p[i] << endl;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6376
#include<bits/stdc++.h>
using namespace std;
#define maxn 10010
typedef long long ll;
typedef long double ld;
const ll inF=1e18;
int a,b;
int main(){
    ios_base::sync_with_stdio(0);
    cin>>a>>b;
    if (a<=b) cout <<"unsafe"<< endl;
    else cout <<"safe"<< endl;
}


Measured memory_bytes: 3652
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e5+69, INF=2e9+6969;

ll q,n,a,b,c;
map <ll,ll> m;
ll s=0;
int main()
{
	cin >> n;
	for(int i=0;i<n;++i)
	{
		cin >> a;
		m[a]++;
		s+=a;
	}
	cin >>q;
	for(int i=0;i<q;++i)
	{
		cin >> b >> c;
		ll cur = m[b];
		m[b]=0;
		m[c]+=cur;
		s-=b*cur;
		s+=c*cur;
		cout << s << "\n";
	}
	return 0;
}


Measured memory_bytes: 9388
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll d[mm];
int main()
{
   ll n,m,i,j,t,a,b,c,p,k,kk; 
     ll s=0;
     string s1,s2;
     cin>>s1>>s2;
     for(i=0;i<s1.size();i++)
     {
     	if(s1[i]!=s2[i])
     	s++;
	 }
	 cout<<s<<endl;
	 
} 

Measured memory_bytes: 3852