akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define MAXN 15
#define INF 0x3F3F3F3F
int v[MAXN][MAXN], n, m, x, y, z;
int c[1 << MAXN][MAXN], f[1 << MAXN][MAXN];
int main(){
	scanf("%d%d", &n, &m);
	for(int i = 0;i < m;i++){
		scanf("%d%d%d", &x, &y, &z);
		x--;y--;
		v[x][y] = v[y][x] = z;
	}
	for(int d = 0;d < (1 << n);d++){
		for(int i = 0;i < n;i++){
			f[d][i] = INF;
			for(int j = 0;j < n;j++)if((d >> j) & 1)c[d][i] += v[i][j];
		}
	}
	f[1][0] = 0;
	for(int d = 0;d < (1 << n);d++){
		for(int i = 0;i < n;i++){
			if(((d >> i) & 1) && f[d][i] != INF){
				for(int j = 0;j < n;j++){
					if(!((d >> j) & 1) && v[i][j]){
						f[d | (1 << j)][j] = std::min(
							f[d | (1 << j)][j],
							f[d][i] + c[d][j] - v[i][j]
						);
					}
				}
				register int next = d ^ (1 << i), st = ((1 << n) - 1) ^ d, sum;
				for(int j = st;j > 0;j = (j - 1) & st){
					sum = 0;
					for(int l = 0;l < n;l++)if((j >> l) & 1)sum += c[next][l];
					f[d | j][i] = std::min(f[d | j][i], f[d][i] + sum);
				}
			}
		}
	}
	printf("%d\n", f[(1 << n) - 1][n - 1]);
	return 0;
}

Measured memory_bytes: 3968
#include <stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(i*j == n){
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int>P;
vector<vector<P> >v(155);	
vector<vector<vector<int> > >dp(155);
int F(int n1,int k1,int n2,int k2)
{
	P p=v[n1][k1],q=v[n2][k2];
	return (p.first+q.first)*abs(p.second-q.second);
}
int main()
{
	int n,m,k,x,d,i,j,l;
	while(scanf("%d%d",&n,&m),n)
	{
		for(i=0;i<155;++i)v[i].clear(),dp[i].clear();
		for(i=0;i<n;++i)
		{
			scanf("%d",&k);
			dp[i].resize(k);
			for(j=0;j<k;++j)
			{
				scanf("%d%d",&x,&d);
				v[i].push_back(P(d,x));
				dp[i][j].resize(m+1);
				fill(dp[i][j].begin(),dp[i][j].end(),INT_MAX/4);
			}
		}
		for(i=0;i<v[0].size();++i)
			dp[0][i][m]=0;
		if(m)
			for(i=0;i<v[1].size();++i)
				dp[1][i][m-1]=0;
		for(i=0;i<n;++i)
		{
			for(j=0;j<dp[i].size();++j)
			{
				for(l=0;l<dp[i+1].size();++l)
				{
					for(k=0;k<=m;++k)
					{
						int&r=dp[i+1][l][k];
						r=min(r,dp[i][j][k]+F(i,j,i+1,l));
					}
				}
				for(l=0;l<dp[i+2].size();++l)
				{
					for(k=1;k<=m;++k)
					{
						int&r=dp[i+2][l][k-1];
						r=min(r,dp[i][j][k]+F(i,j,i+2,l));
					}
				}
			}
		}
		int res=INT_MAX;
		for(j=0;j<dp[n-1].size();++j)
			for(k=0;k<=m;++k)
				res=min(res,dp[n-1][j][k]);
		for(j=0;j<dp[n-2].size();++j)
			for(k=1;k<=m;++k)
				res=min(res,dp[n-2][j][k]);
	printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 1336
#include<bits/stdc++.h>
using namespace std;
int ans[200005];
int a[200005];
int n;
int main()
{
	int j=0, cnt;
	cin >> n;
	for (int i=1;i<=n;i++)
		cin >> a[i];
	for (int i=n;i>=1;i--){
		cnt=0;
		for (int j=i;j<=n/i*i;j+=i)
			if (ans[j]) cnt++;
		if (cnt%2!=a[i])
			ans[i]=1;
	}
	cnt=0;
	for (int i=1;i<=n;i++)
		if (ans[i]) cnt++;
	cout << cnt << endl;
	for (int i=1;i<=n;i++)
		if (ans[i]) cout << i << " ";
	return 0;
}

Measured memory_bytes: 2432
#def main(S, b):

if __name__ == '__main__':
    N = int(input())

    A = list(map(int, input().split()))

    ans = "APPROVED"
    for a in A:
        if (a % 2 == 0):
            if a % 3 == 0 or a % 5 == 0:
                continue
            else:
                ans = "DENIED"
                break
    print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 300002, M = 998244353;
ll n,a,b,k,fact[N],revFact[N],inv[N];

ll choose(int x, int y){
    return fact[x] * revFact[y] % M * revFact[x-y] % M;
}

int main(){
    fact[0] = revFact[0] = 1;
    lp(i,1,N-1){
        fact[i] = fact[i-1] * i % M;
        if(i == 1) inv[i] = 1;
        else inv[i] = inv[M % i] * (M - M / i) % M;
        revFact[i] = revFact[i-1] * inv[i] % M;
    }

    cin >>n >>a >>b >>k;
    ll ans = 0;
    lp(i,0,n) if(k >= i * a and (k - i * a) % b == 0){
        ll x = i, y = (k - i * a) / b;
        if(y <= n)
            ans = (ans + choose(n, x) * choose(n, y) % M) % M;
    }
    cout <<ans;
}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define uni(v) v.erase(unique(v.begin(), v.end()), v.end())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (ll) a / __gcd(a, b) * b
#define what_is(x) cerr << #x << " is " << x << endl;

using namespace std;

const int M = 998244353;

void write();
template <typename T, typename... Args>
void write(T x, Args... args);

const int N = 2e5 + 1;
vi par(N, -1);

int root(int u) { return par[u] < 0 ? u : par[u] = root(par[u]); }
int merge(int u, int v) {
    u = root(u), v = root(v);
    if (u == v) return u;
    if (u > v) swap(u, v);
    par[u] += par[v];
    return par[v] = u;
}

void solve() {
    int n;
    cin >> n;
    vector<ii> a(n);
    vi nxt(n);
    for (int i = 0; i < n; ++i) cin >> a[i].fi >> a[i].se;
    sort(all(a));

    stack<int> in;
    for (int i = n; i--;) {
        int x = upper_bound(all(a), ii{a[i].fi + a[i].se, 0}) - a.begin() - 1;

        if (i == x) {
            nxt[i] = i + 1;
            in.push(i);
            continue;
        }

        while (!in.empty()) {
            int f = in.top();

            if (f > x) break;

            in.pop();
            merge(i, f);
        }
        nxt[i] = i - par[i];
        in.push(i);
    }

    vi dp(n + 1, 1);
    for (int i = n; i--;) dp[i] = (dp[nxt[i]] + dp[i + 1]) % M;
    cout << dp[0] << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

void write() { cout << "\n"; }
template <typename T, typename... Args>
void write(T x, Args... args) {
    cout << x << ' ';
    write(args...);
}

Measured memory_bytes: 4608
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    string s, t; cin >> s >> t;
    cout << t + s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  
  int n;
  scanf("%d",&n);
  int a[n];
  int i;
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  
  int flag=0;
  
  for(i=0;i<n;i++)
  {
   if(a[i]%2==0)
   {
     if( ( a[i]%3 == 0) || (a[i]%5==0) )
     {
      
       
     }
     else 
     {
       flag=1;
       printf("DENIED");
       break;
     }
     
   }
    
  }
  
  if(flag==0)
  {
    printf("APPROVED");
  }

  
 return 0;
  
}

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

#define ll long long
ll sumOfFactors(int n)
{
	ll ans = 0;
	for(int i=1;i<=n;i++)
	{
		ll firstFactor = i;
		ll lastFactor = (n/i)*i;
		ll totalFactors = (lastFactor - firstFactor)/i + 1;
		ll totContribution = ((totalFactors)*(totalFactors+1))/2;
		ans += totContribution*i;
	}
	return ans;
}

int main()
{
	int n;
	cin >> n;
	cout << sumOfFactors(n) << endl;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define repp(i,a,b) for(int i = a ; i < b ; i++)
#define rep(i,n) repp(i,0,n)
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) reppr(i,n,0)
#define ff first
#define ss second
#define all(n) n.begin(),n.end()
#define SORT(a) sort(all(a));
#define REVERSE(a) reverse(all(a));

int powmod(int x,int y) 
{ 
    if (y == 0) return 1; 
    int p = powmod(x, y/2) % mod; 
    p = (p * p) % mod;   
    return (y%2 == 0) ? p : (x * p) % mod; 
}
 
int inverse(int a) 
{ 
   return powmod(a,mod-2); 
}

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--) solve();
}

void solve()
{
	int n;
	cin >> n;
	repp(i,1,n+1)
	{
		int ans = 0;
		for(int j = 1 ; j*j <= i ; j++)
		{
			for(int k = 1 ; k*k <= i ; k++)
			{
				int lol = i - j*j - k*k - j*k;
				if(lol<=0) break; 
				int b = j + k , c = -lol;
				int hell = sqrt(b*b-4*c);
				int cnt1 = (-b + hell)/2 , cnt2 = (-b-hell)/2;
				if(cnt1>0 && cnt1*(cnt1+b)==lol)
					ans++;
				if(cnt2>0 && cnt2*(cnt2+b)==lol)
				 	ans++;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3552
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, m; cin >> n >> m;
	vector<int> s(m);
	vector<char> c(m);
	rep(i, m)
	{
		cin >> s[i] >> c[i];
		--s[i];
	}
	for (int i = 0; i < pow(10, n); ++i)
	{
		string can = to_string(i);
		if (can.size() != n)continue;
		bool ok = true;
		rep(j, m)
		{
			if (can[s[j]] != c[j])ok = false;
		}
		if (ok)
		{
			cout << can << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

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

a=n//100
b=(n-a*100)//10
c=n%10

if a==1:
    a=9
elif a==9:
    a=1
    
if b==1:
    b=9
elif b==9:
    b=1
    
if c==1:
    c=9
elif c==9:
    c=1
    
print(a*100+b*10+c)


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
int main()
{
	
	int t,i,h,len,k,m,top=0;
	int stack[99999];//栈
	char a[99999];//算式
	char j;
	scanf("%[^\n]",a);
	len=strlen(a);
	for(i=0;i<=len-1;i++)
	{
		t=a[i];
		if(t==32)
			continue;
		if(t==43)
		{
			h=stack[top-1]+stack[top];
			top--;
			stack[top]=h;
		}
		if(t==45)
		{
			h=stack[top-1]-stack[top];
			top--;
			stack[top]=h;
		}
		if(t==42)
		{
			h=stack[top-1]*stack[top];
			top--;
			stack[top]=h;
		}
		if(t>=48 && t<=57)
		{
			h=0;
			k=i;
			j=a[k];
			while(j!=' ')
			{
				m=j;
				m-=48;
				h=h*10+m;
				a[k]=' ';
				k++;
				j=a[k];
			}
			top++;
			stack[top]=h;
		}
	}
	if(top!=1)
		printf("Error\n");
	else
		printf("%d\n",stack[1]);
	return 0;
}


Measured memory_bytes: 2148
function Main(input) {
	const inputs = input.split(" ");
	
	const product = inputs.reduce((a, b) => a * b);
	const isEven = product % 2 === 0;
	console.log(isEven ? "Even" : "Odd");
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

  ll h, n;
  cin >> h >> n;
  ll ans = 0;
  for (int i = 0; i < n; i++)
  {
    int num;
    cin >> num;
    ans += num;
  }
  if(ans >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    int N;
    cin >> N;
    vector<int> T(N);
    int sum = 0;

    rep(i, N){
        cin >> T[i];
        sum += T[i];
    } 
    int M;
    cin >> M;
    rep(i, M){
        int P, X;
        int ans = 0;
        cin >> P >> X;
        ans = sum - T[P-1] + X;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define N 41
#define D 14
using namespace std;
typedef pair<int,int> P;
int d,x,p,y,ans;
int dp[N][D];
string s;
vector<P> v;
 
int main(){
  cin>>d;
    cin>>x;
  for(int i=0;i<x;i++){
    cin>>s>>p;
    if(s=="D")v.push_back(P(1,p));
  }
  cin>>y;
  for(int i=0;i<y;i++){
    cin>>s>>p;
    if(s=="DD")v.push_back(P(2,p));
  }
  memset(dp,-1,sizeof(dp));
  dp[0][0]=ans=0;
  for(int i=0;i<(int)v.size();i++){
    int cost=v[i].first,point=v[i].second;
    for(int j=0;j<=d;j++){
      if(dp[i][j]<0)continue;
      if(j+cost<=d)dp[i+1][j+cost]=max(dp[i+1][j+cost],dp[i][j]+point);
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    }
  }
  for(int i=0;i<=d;i++)ans=max(ans,dp[v.size()][i]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1216
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===

def main():
    h, w, n = ns()
    y, x = ns()
    s = list(input())
    t = list(input())

    su, sd, sl, sr = 0, 0, 0, 0
    tu, td, tl, tr = 0, 0, 0, 0

    yes = True

    for si, ti in zip(s, t):
        if si == "U":
            su += 1
        elif si == "D":
            sd += 1
        elif si == "L":
            sl += 1
        else:
            sr += 1

        if y - (su - td) < 1:
            yes = False
        if y + sd - tu > h:
            yes = False
        if x - (sl - tr) < 1:
            yes = False
        if x + sr - tl > w:
            yes = False

        if ti == "U":
            tu = min(tu + 1, y - 1 + sd)
        elif ti == "D":
            td = min(td + 1, h - y + su)
        elif ti == "L":
            tl = min(tl + 1, x - 1 + sr)
        else:
            tr = min(tr + 1, w - x + sl)

    print("YES" if yes else "NO")


if __name__ == '__main__':
    main()


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

int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  
  if (op == '+') {
    cout << A + B << endl;
  }
  if (op == '-') {
    cout << A - B << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,ll> P;
typedef vector<P> vip;

void solve(){
    int n;cin>>n;
    int ans=0;
    int l,r;
    fol(i,n){
        cin >> l >>r;
        ans+=r-l+1;
    }
    cout << ans <<endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int n;
    int m;
    int l;
 
   int ans;
  
  vector<int> v;  
  
   cin >> n >> m >> l;
  
   int a = n + m;
   int b = m + l;
   int c = n + l;
  
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
   
  int min = *min_element(v.begin(), v.end());
  
  
   cout << min << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x)*(x))
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
typedef long long ll;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
using namespace std;
int main(void){
#ifdef ljxtt
freopen("data.in", "r", stdin);
#endif
    double r;
    cin >> r;
    printf("%.2f\n", 2 * pi * r);
    return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<int,int>
#define pli pair<int,int>
#define pint pair<int,int>
#define pid pair<int,double>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
#define SIZE 200010
#define MOD 1000000007
#define BIG 999999937


int main()
{
	
	/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif*/
    
    ll n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n-1;i++)
    {
    	sum+=i;
	}
	cout<<sum;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define upb upper_bound
#define lwb lower_bound
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = (a - b); if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = (a + b); if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);


	string s;
	cin>>s;
	ll ans=0;
	for(int i=0;i<s.size();i++){
		ans+=s[i]-'0';
	}
	if(ans%9) cout<<"No";
	else cout<<"Yes";

    return 0;
}


Measured memory_bytes: 3776
#include <iostream>

constexpr std::uint64_t gcd(const std::uint64_t a, const std::uint64_t b) {
  return b == 0 ? a : gcd(b, a % b);
}

template <typename T> constexpr T div_floor(T lhs, T rhs);
template <typename T> constexpr T div_ceil(T lhs, T rhs);

template <typename T> constexpr T div_floor(const T lhs, const T rhs) {
  return
    lhs >= 0 && rhs >= 0 ?
      lhs / rhs :
    lhs < 0 && rhs >= 0 ?
      -div_ceil<T>(-lhs, rhs) :
    lhs >= 0 && rhs < 0 ?
      -div_ceil<T>(lhs, -rhs) :
      div_floor<T>(-lhs, -rhs);
}

template <typename T> constexpr T div_ceil(const T lhs, const T rhs) {
  return
    lhs >= 0 && rhs >= 0 ?
      (lhs - 1 + rhs) / rhs :
    lhs < 0 && rhs >= 0 ?
      -div_floor<T>(-lhs, rhs) :
    lhs >= 0 && rhs < 0 ?
      -div_floor<T>(lhs, -rhs) :
      div_ceil<T>(-lhs, -rhs);
}

int main() {
  std::int32_t t;
  std::int64_t a, b, c, d;
  std::cin >> t;
  while (std::cin >> a >> b >> c >> d) {
    const std::int64_t gcd_b_d = gcd(b, d);
    std::cout << (a < b || b > d || a - div_floor<std::int64_t>(a - (c + 1), gcd_b_d) * gcd_b_d - b < 0 ? "No" : "Yes") << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
typedef long long ll;
 
int main()
{
int h,w;
cin>>h>>w;
char a[h][w];
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        cin>>a[i][j];
    }
}

ll dp[h+1][w+1];
for(int i=0;i<=h;i++){
    for(int j=0;j<=w;j++){
        dp[i][j]=0;
    }
}
dp[1][1]=1;
for(ll i=1;i<=h;i++){
  //  cout<<"r\n";
    for(ll j=1;j<=w;j++){
     //   cout<<dp[i][j]<<" ";
        if(i==1 && j==1){
            dp[i][j]=1;
        }
        
        else if(a[i-1][j-1]=='#'){
            dp[i][j]=0;
        }
        else{
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007;
        }
        
    }
}
cout<<dp[h][w]%1000000007<<endl;
    return 0;
}

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

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    int max_a = max({A,B,C});
    int ans = (max_a - A) + (max_a -B)+(max_a-C);
    if(ans%2==0){cout << ans/2<<endl;}
    else{cout << (ans+1)/2+1<<endl;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


double sol (double a, double b, double c,double xq, double yq) {
    return printf("%lf %lf\n",xq-2*a*(a*xq+b*yq+c)/(a*a+b*b),yq-2*b*(a*xq+b*yq+c)/(a*a+b*b));
}

int main(){
    double x1,y1,x2,y2,qx,qy;
    while (scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&qx,&qy)!=EOF) {
        sol(y2-y1,-1*(x2-x1),x2*y1-x1*y2,qx,qy);
    }
    return 0;
}

Measured memory_bytes: 3120
n=int(input())
count=[[0 for i in range(10)]for i in range (10)]
ans=0
for i in range(1,(n+1)):
    s=str(i)
    h=int(s[0])
    t=int(s[len(s)-1])
    count[h][t]+=1
for i in range(len(count)):
    for j in range(len(count)):
        ans+=count[i][j]*count[j][i]
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll a[100000];
ll dp[100000];
ll maque[100000];
ll nex[100000];
int main(){
	int n,m, k; cin >> n >> m >> k;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		dp[i] = a[i];
	}
	Rep1(j,2, k) {
		int s = 0;
		int t = 0;
		rep(i, n) {
			if (dp[i] == -1)continue;
			if (t > s) {
				nex[i] = j * a[i] + dp[maque[s]];
			}
			else {
				nex[i] = -1;
			}
			while (t - 1 >= s && dp[i] > dp[maque[t - 1]]) {
				t--;
			}
			maque[t] = i; t++;
			if (i >= m) {
				if (maque[s] == i - m) {
					s++;
				}
			}
		}
		rep(i, n) {
			dp[i] = nex[i];
		}
	}
	ll out = 0;
	rep(i, n) {
		out = max(out, dp[i]);
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 2944
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    sieve_len = A[-1] + 1
    sieve = [0] * sieve_len

    count = 0
    for ix, a in enumerate(A):
        if sieve[a] == 0:
            if ix == len(A) - 1 or a != A[ix+1]:
                count += 1
        else:
            continue
        intermediate_a = a
        while intermediate_a < sieve_len:
            sieve[intermediate_a] += 1
            intermediate_a += a
    print(count)



if __name__ == '__main__':
    main()


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;

bool cmp(pair<pair<string,ll>,ll> a,pair<pair<string,ll>,ll> b) {
	return ((a.fi.fi<b.fi.fi) || (a.fi.fi==b.fi.fi && a.fi.se>b.fi.se));
}

void solve(){
	ll n,l;
	cin>>n>>l;
	vector<string> A(n);
	for(int i=0;i<n;i++) cin>>A[i];
	sort(all(A));
	for(auto i:A)cout<<i;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


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

int main() {
    int N, Y;
    cin >> N >> Y;

    for (int i=0; i<=N; i++) {
        for (int j=0; j<=N-i; j++) {
            for (int k=0; k<=N-i-j; k++) {
                if (10000*i + 5000*j + 1000*k == Y && i+j+k == N) {
                    cout << i << " " << j << " " << k << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef pair<int, pair < int, int > > PP;
typedef long long ll;
typedef pair<ll, ll>P;
ll inf = -1;
ll mod = pow(10, 9) + 7;

int main() {
	int n,t;cin>>n>>t;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	reverse(a.begin(),a.end());
	int I=0,J=1,K=0;
	vector<int>cnt[100010];
	int len=1;
	cnt[0].push_back(a[0]);
	while(J<n){
		if(a[I]>a[J]){
			cnt[K].push_back(a[J]);
		}
		else{
			K++;len++;
			cnt[K].push_back(a[J]);
			I=J;
		}
		J++;
	}
	for(int i=0;i<len;i++){
		sort(cnt[i].begin(),cnt[i].end());
	}
	int b=0,e=len-1;
	vector<int>s;
	for(int i=b;i<=e;i++){
		if(cnt[i].size()>=2){
			s.push_back(cnt[i][cnt[i].size()-1]-cnt[i][0]);
		}
	}
	sort(s.begin(),s.end(),greater<int>());
	int ans=0;
	for(int i=0;i<s.size();i++){
		if(s[i]==s[0]){
			ans++;
		}
		else{
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4864
N = int(input())
s = input()

s_flag = [1 if s[i]=='o' else -1 for i in range(N)]

def find_pattern(init_t_flag):
    for i in range(2, len(s_flag)):
        init_t_flag.append(init_t_flag[i-2]*init_t_flag[i-1]*s_flag[i-1])
    first_t_flag = init_t_flag[-2] * init_t_flag[-1] * s_flag[-1]
    second_t_flag = init_t_flag[-1] * init_t_flag[0] * s_flag[0]
    if init_t_flag[0] == first_t_flag and init_t_flag[1] == second_t_flag:
        return init_t_flag
    else:
        return -1

def output_result():
    res_SS = find_pattern([1,1])
    if res_SS != -1:
        res = ['S' if res_SS[i]==1 else 'W' for i in range(N)]
        return("".join(res))

    res_SW = find_pattern([1, -1])
    if res_SW != -1:
        res = ['S' if res_SW[i]==1 else 'W' for i in range(N)]
        return("".join(res))

    res_WS = find_pattern([-1,1])
    if res_WS != -1:
        res = ['S' if res_WS[i]==1 else 'W' for i in range(N)]
        return("".join(res))

    res_WW = find_pattern([-1, -1])
    if res_WW != -1:
        res = ['S' if res_WW[i]==1 else 'W' for i in range(N)]
        return("".join(res))

    return(-1)

print(output_result())

Measured memory_bytes: 5740
import java.io.IOException;
import java.math.BigInteger;
import java.util.Scanner;

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

		double x = 0.0;
		double y = 0.0;
		int angleDeg = 90;
		while(in.hasNext()) {
			String s = in.next();
			String[] lr = s.split(",");
			int d = Integer.parseInt(lr[0]);
			int a = Integer.parseInt(lr[1]);

			// go to d[m]
			x += d * Math.cos(Math.toRadians(angleDeg));
			y += d * Math.sin(Math.toRadians(angleDeg));

			// rotate a human
			angleDeg -= a;

			if(d==0 && a == 0) {
				break;
			}
		}
		System.out.println((int)x);
		System.out.println((int)y);
	}

}

Measured memory_bytes: 25640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B; cin >> A >> B;
  if(A <= 8 && B <= 8){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int max(int a, int b) { return (a > b) ? a : b; }

int main() {
    int i, j;
    int n, m, a[1001];
    while (1) {
        scanf("%d %d", &n, &m);

        if (n == 0 && m == 0) { break; }

        int ans = -1;

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

        for (i = 0; i < n; i++) {
            for (j = 0; j < n; j++) {
                if (i == j) { continue; }
                if (a[i] + a[j] <= m) { ans = max(ans, a[i] + a[j]); }
            }
        }
        if (ans == -1) { puts("NONE"); }
        else { printf("%d\n", ans); }
    }
    return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 2333
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
char a[N][N]; int f[N][N],g[N][N],s[N],l[N],r[N];
int main()
{	int n,m,ans=0; cin>>n>>m; ans=max(n,m);
	for(rint i=1;i<=n;i++) scanf("%s",a[i]+1);
	for(rint i=1;i<n;i++)
	for(rint j=m;j>=1;j--)
	if(a[i][j]==a[i+1][j]) g[i][j]=g[i][j+1]+1,f[i][j]=0;
	else f[i][j]=f[i][j+1]+1,g[i][j]=0;
	for(rint j=1;j<=m;j++)
	{	int top=0;
		for(rint i=1;i<=n;i++)
		{	while(top&&max(f[s[top]][j],g[s[top]][j])>max(f[i][j],g[i][j]))
			r[s[top]]=i,top--;
			l[i]=s[top]+1; s[++top]=i;
		}
		while(top) r[s[top--]]=n;
		for(rint i=1;i<=n;i++) ans=max(ans,max(f[i][j],g[i][j])*(r[i]-l[i]+1));
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 45312
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	vector<vector<int>> a(h, vector<int>(w));
	rep(i,h)rep(j,w) cin >> a[i][j];
	vector<pair<P, P>> ans;
	rep(i,h){
		if(i%2 == 0){
			rep(j,w){
				if(j+1 < w){
					if(a[i][j]%2 == 1){
						a[i][j]--;
						a[i][j+1]++;
						ans.push_back(make_pair(P(i+1,j+1), P(i+1,j+2)));
					}
				}
				else{
					if(a[i][j]%2 == 1 && i+1 < h){
						a[i][j]--;
						a[i+1][j]++;
						ans.push_back(make_pair(P(i+1,j+1), P(i+2,j+1)));
					}
				}
			}
		}
		else{
			for(int j = w-1; j >= 0; --j){
				if(j-1 >= 0){
					if(a[i][j]%2 == 1){
						a[i][j]--;
						a[i][j-1]++;
						ans.push_back(make_pair(P(i+1,j+1), P(i+1,j)));
					}
				}
				else{
					if(a[i][j]%2 == 1 && i+1 < h){
						a[i][j]--;
						a[i+1][j]++;
						ans.push_back(make_pair(P(i+1,j+1), P(i+2,j+1)));
					}
				}
			}
		}
	}
	cout << ans.size() << endl;
	for(auto p : ans){
		cout << p.first.first << " " << p.first.second << " " << p.second.first << " " << p.second.second << endl;
	}
	return 0;
}

Measured memory_bytes: 5236
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int a=s.size();
	cout<<s[0]<<(a-2)<<s[a-1];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

int main() {
  long long n, a, b;
  cin >> n >> a >> b;

  long long set_count = a + b;
  if (set_count == 0) {
    cout << 0 << endl;
    return 0;
  }
  long long div = n / set_count;
  long long mod = n % set_count;

  long long ans = 0;
  if (div == 0) {
    ans = min(a, mod);
  } else {
    ans = div * a;
    if (mod != 0) ans += min(a, mod);
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

int main() {
    int n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll LCM = lcm(n, m);
    map<ll, char> mp;
    int count = 0;
    for (ll i = 0; i < LCM; i += LCM / n) {
        mp[i] = s[count];
        count++;
    }
    count = 0;
    for (ll i = 0; i < LCM; i += LCM / m) {
        if (mp[i] != false && mp[i] != t[count]) {
            puts("-1");
            return 0;
        }
        count++;
    }
    cout << LCM << endl;
    return 0;
}

Measured memory_bytes: 10880
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//INT_MAXなど
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/

signed main(){
  ll N;
  cin >> N;

  vector<int> d(N);
  for (int i = 0; i < N; i++)
    cin >> d[i];

  sort(d.begin(), d.end());
  int mid = d.size() / 2;
  if (d[mid - 1] == d[mid]) {
    cout << "0" << endl;
  } else {
    cout << d[mid] - d[mid - 1] << endl;
  }

  return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long x, k, d;
    cin >> x >> k >> d;
    long long r = x % d, p = abs(x)/d;
    if(p > k){
        if(x > 0){
            cout << abs(x - k * d);
        }
        else{
            cout << abs(x + k * d);
        }
        return 0;
    }
    if((k - p) % 2 == 0){
        cout << abs(r);
        return 0;
    }
    else{
        if(r < 0){
            cout << abs(r + d);
            return 0;
        }
        else{
            cout << abs(r - d);
            return 0;
        }
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll N; cin >> N;
    ll a[100005];
    map<ll,ll> mp;
    ll s = 0;

    for (int i = 0;i < N;i++){
        cin >> a[i];
        mp[a[i]]++;
        s ^= a[i];
    }

    if(s == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 5760
#![allow(clippy::many_single_char_names)]
#[allow(unused_imports)]
use proconio::{
    input,
    marker::{Chars, Usize1},
};

fn main() {
    input!(s: Chars);
    println!(
        "{}",
        if s.iter().map(|&c| ((c as u8 - b'0') as u32)).sum::<u32>() % 9 == 0 {
            "Yes"
        } else {
            "No"
        }
    );
}


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

int main(){
    ll A,B;
    cin >> A >> B;
    ll m;
    m = max(A,B);
    for(ll k=0;k<=m;k++){
        ll a = abs(A-k);
        ll b = abs(B-k);
        if(a==b){
            cout << k << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include "stdlib.h"
using namespace std;

/*int main() {
  int change(int n, int b);
  char operand(int n);
  int N; cin >> N;
  int A = N / 1000;
  int B = (N / 100) % 10;
  int C = (N / 10) % 10;
  int D = N % 10;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        if (A + change(B, i) + change(C, j) + change(D, k) == 7) {
          cout << A << operand(i) << B << operand(j) << C << operand(k) << D <<"=7" << endl;
          return 0;
        }
      }
    }
  }
}

int change(int n, int b) {
  if (b)
    return n;
  else
    return -n;
}

char operand(int n) {
  if (n == 1)
    return '+';
  else
    return '-';
}*/

int main() {
  int N; cin >> N;
  int num[4] = {N/1000, (N/100)%10, (N/10)%10, N%10};
  char opr[2] = {'-', '+'};
  int sc;
  for (int i = 0; i < (1 << 3); i++) {
    sc = num[0];
    for (int j = 0; j < 3; j++) {
      if (1 & (i >> j)) { //iのj番目が1ならば
        sc += num[j+1];
      } else {
        sc -= num[j+1];
      }
    }
    if (sc == 7) {
      cout << num[0];
      for (int j = 0; j < 3; j++) {
        //cout << '(' << (1 & (i >> j)) << ')';
        cout << opr[1 & (i >> j)] << num[j+1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


void solve(ll N = 0){
  // ll N; cin >>N;
  stack<char> sta;
  while (N >= 26){
    ll n = N % 26;
  }
  while (N > 0){
    int n = N % 26;
    n = (n + 26 - 1) % 26;
    char c = 'a' + n;
    sta.push(c);
    N /= 26;
  }

  {
    char c = 'a' + N;
    sta.push(c);
  }
  while (!sta.empty()){
    char c = sta.top();
    sta.pop();
    cout <<c;
  }
  cout <<endl;
}

void solve2(ll N, int digit){
  N--;
  stack<char> sta;
  for (int i=0; i<digit; i++){
    ll n = N % 26;
    char c = 'a' + n;
    sta.push(c);
    N /= 26;
  }
  while (!sta.empty()){
    char c = sta.top();
    sta.pop();
    cout <<c;
  }
  cout <<endl;
}

int main() {
  ll N; cin >>N;
  int digit = 1;
  ll check = 26;
  while (N > check){
    digit++;
    N -= check;
    check *= 26;
  }
  solve2(N, digit);
  // for (int i=1; i<=300; i++){
  //   cout <<i <<": ";
  //   solve(i);
  // }
}

/*
a 0
b 1
c 2

y 24
z 25
aa 26
ab 27
ac 28

ay 50
az 51
ba 52
bb 53
bc 54

by 76
bz 77
ca 78

ya 26*25

za 26*26 = 


*/

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string ans = "No";
  for (int i=1;i<10;i++){
    for (int j=1;j<10;j++){
      if (i*j == n) ans = "Yes";
    }
  }
  cout << ans << endl;
}

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

int main()
{
	int n, d, x;
	cin >> n >> d >> x;

	vector<vector<int>>p(d);
	for (int i = 0; i < d; i++) {
		p[i].resize(n);
		for (int j = 0; j < n; j++) {
			cin >> p[i][j];
		}
	}

	for (int i = 0; i < d-1; i++) {
		vector<int>DP(1000001);
		for (int k = 0; k <= x; k++) {
			for (int j = 0; j < n; j++) {
				DP[k + p[i][j]] = max(DP[k + p[i][j]], DP[k] + p[i+1][j]);
			}
		}

		int next_x=x;
		for (int k = 0; k <= x; k++) {
			DP[k] = DP[k] + x - k;
			next_x = max(DP[k], next_x);
		}
		x = next_x;
	}

	cout << x << endl;

    return 0;
}

Measured memory_bytes: 6992
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=27;
char s[maxn],s1[maxn];
int p[26];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	if(n<26){
		REP(i,1,n) p[(int)s[i]-'a']=1;
		printf("%s",s+1);
		REP(i,0,25) if(!p[i]){
			putchar(i+'a');
			putchar('\n');
			return 0;
		}
	}
	bool flag=1;
	DREP(i,25,0) if(s[n-i]!=i+'a'){
		flag=0;
		break;
	}
	if(flag){
		printf("-1\n");
		return 0;
	}
	REP(i,1,n) s1[i]=s[i];
	next_permutation(s+1,s+n+1);
	REP(i,1,n){
		putchar(s[i]);
		if(s[i]!=s1[i]) return 0;
	}
	return 0;
}

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

#define N 36

typedef struct pp{
  char name;
  int value;
}CARD;


int n;
CARD data[N],data1[N];


void BubbleSort(CARD* ,int);
void SelectionSort(CARD* ,int);
int isStable(CARD*,CARD*,int);


int main(){
  int i,j,m;
  char t;

  scanf("%d",&n);

  scanf(" %c",&data[0].name);
  scanf("%d",&data[0].value);
  data1[0]=data[0];
  for(j=1;j<n;j++){
    scanf(" %c",&data[j].name);
    scanf("%d",&data[j].value);
    data1[j]=data[j];
  }

  
  BubbleSort(data,n);

  SelectionSort(data1,n);

  m=isStable(data,data1,n);

  printf("%c%d",data[0].name,data[0].value);
  for(j=1;j<n;j++) printf(" %c%d",data[j].name,data[j].value);
  printf("\nStable\n");

  printf("%c%d",data1[0].name,data1[0].value);
  for(j=1;j<n;j++) printf(" %c%d",data1[j].name,data1[j].value);
  if(m==0) printf("\nNot stable\n");
  else printf("\nStable\n");

  return 0;
  
  
}

void BubbleSort(CARD *B,int n){
  int i,j;
  CARD temp;
  
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(B[j].value<B[j-1].value){
	temp=B[j];
	B[j]=B[j-1];
	B[j-1]=temp;
      }
    }
  }

  return;
}

void SelectionSort(CARD *S,int n){
  int i,j,min;
  CARD temp;

  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(S[j].value<S[min].value) min=j;
    }
    temp=S[i];
    S[i]=S[min];
    S[min]=temp;
  }

  return;
}

int isStable(CARD *in,CARD *out,int n){
  int i,j,a=0,b=0;

  for(i=0;i<n;i++){
    if(strcmp(&in[i].name,&out[i].name)==0) a++;
  }
  for(i=0;i<n;i++){
    if(in[i].value==out[i].value) b++;
  }
  

  if(a==b) return 1;

  else return 0;
}



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

int main() {
	int D, N;
	cin >> D >> N;

	int output;
	output = pow(100, D) * N;
	if (output == pow(100, 1)) {
		output = pow(100, 1) + 1;
	} else if (output == pow(100, 2)) {
		output = 10100;
	} else if (output == pow(100, 3)) {
		output = 1010000;
	}

	printf("%d", output);

	return 0;
}


Measured memory_bytes: 256