akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=1e9+7;
const ll ms=2e5+5;
const ll inf=1e17;



ll ar[ms];

ll modpow(ll a,ll b)
{
    ll r=1;
    while(b)
    {
        if(b&1)
        {
            r=(r*a)%modo;
        }
        a=(a*a)%modo;
        b>>=1;
    }
    return r;
}

int main()
{
    idfc;



    int n,k;
    cin>>n>>k;
    int i,j;

    for(i=k;i>=1;i--)
    {
        ar[i]=0;
        ar[i]=modpow(k/i,n);
        for(j=2*i;j<=k;j+=i)
        {
            ar[i]=(ar[i]+modo-ar[j])%modo;
        }
    }

    ll ans=0;
    ll x;
    for(i=1;i<=k;i++)
    {
        x=(ar[i]*i)%modo;
        ans=(ans+x)%modo;
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 4392
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque

def run():
    N,M = map(int, sysread().split())
    A, B = [],[]
    for i in range(N):
        A.append(input())
    for i in range(M):
        B.append(input())
    # extract candidates
    b = B[0]
    collection = []
    for i in range(N-M+1):
        a = A[i]
        for j in range(N-M+1):
            for k in range(M):
                if a[j+k] != b[k]:break
            collection.append((i,j))

    for start in collection:
        i, j = start
        breaked = False
        for x in range(M):
            if A[i+x][j:j+M] != B[x]:
                breaked = True
                break
        if not breaked:
            print("Yes")
            return None
    print("No")




if __name__ == "__main__":
    run()

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

int main()
{
    string s;
    cin>>s;
    string res = "";
    int i,ss=s.size();
    //cout<<ss<<endl;
    for(i=0;i<ss-1;i++)
    res += s[i];
    res+=s[i];
    if(s[i] == 's')
    res += "es";
    else
    res+="s";
    cout<<res;
    return 0;
}

Measured memory_bytes: 3628
//! Oos Karim Rokhsat
#include<bits/stdc++.h>
using namespace std;

typedef double                      ld;
typedef long long                   ll;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<string , string>       pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define sep                         ' '
#define endl                        '\n'
#define file_io                     freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(x)                    cerr << "$$$ " << x << '\n';
#define error2(x,y)                 cerr << "#F : " << x << "      #S : " << y << '\n';
#define kill(x)                     return cout << x << endl , 0;
#define pb                          push_back

const ll MXN = 1e3 + 10;
const ll MXM = 50 + 10;
const ll MX5 = 2e5 + 10;
const ll MX6 = 1e6 + 10;
const ll LOG = 20;
const ll INF = 8e18;
const ld eps = 1e-9;
const ll MOD = 1e9 + 7; //998244353;

ll power(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));
}
ll bmm(ll a,ll b){
    return (a%b==0 ? b : bmm(b,a%b));
}
string base2(ll n){
    string a="";while(n>=2){a+=(char)(n%2+'0');n/=2;}a+=(char)(n+'0');reverse(all(a));return a;
}

ll n, m;

int main(){
    fast_io
    //file_io
    cin >> n >> m;
    if(n > m) swap(n, m);
    if(n == 1){
        if(m == 2){
            cout << 3;
        }
        else
            cout << 2;
    }
    else {
        cout << 1;
    }




    return 0;
}

//! N.N


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e6 + 5;
const ll base = 313;
const ll base1 = 113;
const ll mod = 1e9 + 7;
ll n, t, pr[N], nx[N], T, k, b[N], c[N], sum= 0, m, tong, ans, pw1[N], pw[N];
struct dang
{
    ll l, r, pos;
};
dang a[N];
string s;

void sol()
{
    cin >> s;
    for(int i = 0; i < s.length(); i ++)
        {
            if(s[i] == 'R')++n;
            else n = 0;
            m = max(n, m);
        }
    cout << m;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    sol();
}


Measured memory_bytes: 3648
from math import gcd

def solve():
    n = int(input())
    c = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            a = gcd(i, j)
            for k in range(1, n+1):
                c += gcd(a, k)

    return c

print(solve())

Measured memory_bytes: 9188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから

void solve(){
  char a,b;
  cin>>a>>b;
  if(a=='D'){
    if(b=='H')cout<<'D';
    else cout<<'H';
  }
  else cout<<b;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from bisect import bisect_left, bisect_right
def resolve():
    n, m = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(n)]
    AB.sort()
    X = [0] * (n + 1)
    X[0] = AB[0][1]
    for i in range(n - 1):
        X[i + 1] = AB[i][1] ^ AB[i + 1][1]
    X[n] = AB[n - 1][1]

    E = [[] for _ in range(n + 1)]
    for i in range(m):
        u, v = map(int, input().split())
        l = bisect_left(AB, [u, 0])
        r = bisect_right(AB, [v, 1])
        E[l].append((r, i + 1))
        E[r].append((l, i + 1))

    ans = []
    used = [False] * (n + 1)
    def dfs(v):
        used[v] = True
        res = X[v]
        for nv, i in E[v]:
            if used[nv]:
                continue
            r = dfs(nv)
            if r:
                ans.append(i)
            res ^= r
        return res

    for v in range(n + 1):
        if used[v]:
            continue
        if dfs(v):
            print(-1)
            return

    print(len(ans))
    if ans:
        print(*sorted(ans))
resolve()

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

int main()
{
	int n;
    cin>> n;
   	int arr[n];
    for(int i=0;i<n;i++)cin>> arr[i];
    vector<int>dp(n,0);
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++){
        dp[i]=min( dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+ abs( arr[i] -arr[i-2])  );
    }
    cout<<dp[n-1]<<endl;
        
    return 0;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	int n; cin >> n;
	vi a(n);
	bool even=true;
	rep(i,n){
		cin >> a[i];
		if(a[i]<0){
			even = !even;
			a[i] *= -1;
		}
	}
	SORT(a);
	ll ans = 0;
	rep(i,n) ans += a[i];
	if(even) cout << ans << endl;
	else cout << ans-2*a[0] << endl;

}




Measured memory_bytes: 640
import sys
input = lambda: sys.stdin.readline().rstrip()

K, N = map(int, input().split())

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

max_dist = 0
for i in range(N-1):
    max_dist = max(max_dist, A[i+1]-A[i])

max_dist = max(max_dist, A[0]-(A[-1]-K))

print(K-max_dist)

Measured memory_bytes: 72076
/*
    Vora Mahammadasim
*/

#include<bits/stdc++.h>
#include<stdio.h>
#define int long long
#define pb emplace_back
#define Mod 1000000007
#define all(a) a.begin(),a.end()
#define ps(a) partial_sum(all(a),a.begin())
using namespace std;
signed main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    int q = n%1000;
    if(q) cout<<1000-q;
    else cout<<0;
}


Measured memory_bytes: 3628
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int n , a , b ;

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

	cin >> n >> a >> b ;

	cout << ((a - b) % 2 ? "Borys" : "Alice") << '\n' ;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> num(n+1);
  rep(i, n+1) num[i] = i;
  ll ng = 0, ok = n;
  while(abs(ng-ok) > 1) {
    ll mid = (ng+ok)/2;
    if(n <= mid*(mid+1)/2) ok=mid;
    else ng=mid;
  }
  for(ll i = 1; i <= ok; ++i) {
    if(ok*(ok+1)/2 - n == i) continue;
    cout << i << endl;
  }
}


Measured memory_bytes: 81316
#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;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	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=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e5+10;
int a[maxn];
int main(){
	int n=read();
	REP(i,1,n) a[i]=read()-i;
	sort(a+1,a+n+1);
	ll ans=0;
	int Mid=a[(1+n)>>1];
	REP(i,1,n) ans+=abs(a[i]-Mid);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1024
def calc(N):
    max_num_cake = N / 4
    max_num_donut = N / 7
    for i in range(max_num_cake + 1):
        for j in range(max_num_donut + 1):
            if 4 * i + 7 * j == N:
                return True
    return False

N = input()
if calc(N):
    print 'Yes'
else:
    print 'No'



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int n, w=0, r=0, mi, tmp=0;
	string s;

	cin>> n >> s;

	rep(i, n){
		if(s[i]=='W') w++;
		else r++;
	}

	mi=min(w, r);

	rep(i, r) {
		if (s[i]=='W') tmp++;
	}

	cout<< min(mi, tmp) << endl;
 
	return 0;
}

Measured memory_bytes: 3756
import math
N = int(input())
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]
S = [P, Q]
p = [0]*N
q = [0]*N

for i in range(N):
    for j in range(i):
        if P[i] > P[j]:
            p[i] += 1    
        if Q[i] > Q[j]:
            q[i] += 1

ans_p = 0
ans_q = 0

for i in range(N):
    ans_p += math.factorial(N-1-i) * (P[i]-1-p[i])
    ans_q += math.factorial(N-1-i) * (Q[i]-1-q[i])

print(abs(ans_p - ans_q))

Measured memory_bytes: 9204
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
constexpr ll mod[2] = {1000000007,998244353};
ll a[200010],b[200010];
struct rolling_hash{
	ll z = 100;
	vector<ll> v,w[2],ex[2];
	rolling_hash(vector<ll> &s){
		int i,j,n = s.size();
		for(i=0;i<n;i++){
			v.push_back(s[i] + 1);
		}
		w[0].assign(n + 1,0),w[1].assign(n + 1,0);
		ex[0].assign(n + 1,0),ex[1].assign(n + 1,0);
		ex[0][0] = 1,ex[1][0] = 1;
		for(i=0;i<n;i++){
			for(j=0;j<2;j++){
				w[j][i + 1] = (w[j][i]*z + v[i])%mod[j];
				ex[j][i + 1] = ex[j][i]*z%mod[j];
			}
		}
	}
	inline pll get(int l, int r){//[l,r)
		ll x = (w[0][r] - ex[0][r - l]*w[0][l]%mod[0] + mod[0])%mod[0];
		ll y = (w[1][r] - ex[1][r - l]*w[1][l]%mod[1] + mod[1])%mod[1];
		return {x,y};
	}
};

vector<ll> c,d;
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	for(i=0;i<n;i++){
		cin >> b[i];
	}
	for(i=0;i<n;i++){
		c.push_back((a[i]^a[(i + 1)%n]));
		d.push_back((b[i]^b[(i + 1)%n]));
	}
	rolling_hash rh1(c); rolling_hash rh2(d);
	for(i=0;i<n;i++){
		if(rh1.get(i,n)==rh2.get(0,n - i) && rh1.get(0,i)==rh2.get(n - i,n)){
			cout << i << " " << (a[i]^b[0]) << endl;
		}
	}
}

Measured memory_bytes: 25444
#include <stdio.h>
const int N = 15;
int main(void)
{
	
	int a[N] = {0};
	int i, j, box, n;
	for(i = 0; i < 10; i++)
	{
		scanf("%d", &a[i]);
	}
	for(i = 0; i < 10; i++)
	{
		for(j = i; j < 10; j++)
		{
			if(a[i] < a[j])
			{
				box = a[j];
				a[j] = a[i];
				a[i] = box;
			}
		}
	}
	for(i = 0; i < 3; i++)
	{
		printf("%d\n", a[i]);
	}
	return 0;
}


Measured memory_bytes: 2748
#include<bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pii pair<int,int>
using namespace std;
int main()
{
    fast;
   
    ll a,b;
    cin>>a>>b;
    cout<<a*b;
}

Measured memory_bytes: 3656
class Facts:

  def __init__(self, mod=10**9+7, n_max=1):
    self.mod     = mod
    self.n_max   = n_max
    self.fact    = [1, 1]
    self.inv     = [0, 1]
    self.factinv = [1, 1]
    if 1 < n_max:
      self.setup_table(n_max)

  def cmb(self, n, r):
    if r < 0 or n < r:
      return 0
    if self.n_max < n:
      self.setup_table(n)
    return self.fact[n] * (self.factinv[r] * self.factinv[n-r] % self.mod) % self.mod

  def setup_table(self, t):
    for i in range(self.n_max+1,t+1):
      self.fact.append( self.fact[-1] * i % self.mod )
      self.inv.append( -self.inv[mod % i] * (self.mod // i) % self.mod )
      self.factinv.append( self.factinv[-1] * self.inv[-1] % self.mod )
    self.n_max = t

# ABC167 E 2020/5/11
mod = 998244353

n, m, k = map(int, input().split())

ans = 0
f = Facts(mod)
t = m * pow(m-1, n-1-k, mod)

for i in range(k,-1,-1):
  ans += f.cmb(n-1,i) * t % mod
  t = t * (m-1) % mod

print(ans % mod)


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

int main() {
    int x, y, sum = 0;
    cin >> x >> y;
    if(x == 3) sum += 100000;
    if(x == 2) sum += 200000;
    if(x == 1) sum += 300000;
    if(y == 3) sum += 100000;
    if(y == 2) sum += 200000;
    if(y == 1) sum += 300000;
    if(x == 1 && y == 1) sum += 400000;

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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 void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); if (n == 0) cout << endl; REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int h, w, k;
    cin >> h >> w >> k;
    REP(i, h + 1) REP(j, w + 1) {
        int b = i * j + (h - i) * (w - j);
        if (k == b or k == h * w - b) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}


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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using i64 = long long int;

using P = pair<i64, i64>;

int main(){
    i64 n;
    cin >> n;
    vector<P> a(n);
    rep(i, n){
        i64 na;
        cin >> na;
        a[i] = P(na, i + 1);
    }
    sort(a.begin(), a.end());
    rep(i, n) cout << a[i].second << endl;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;



int main()
{
  string s,t;cin>>s>>t;
  int ans=0;
  if(s[0]==t[0])ans++;
  if(s[1]==t[1])ans++;
  if(s[2]==t[2])ans++;
  cout<<ans<<endl;
  return 0;
}


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

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main()
{
	int N, M, K;
	cin >> N >> M >> K;
	UnionFind uf( N );
	vector<vector<int>> g( N );
	for( int i = 0; i < M; i++ ) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		uf.unionSet( a, b );
		g[a].push_back( b );
		g[b].push_back( a );
	}
	vector<int> ans( N );
	for( int i = 0; i < N; i++ ) {
		ans[i] = (uf.size( i ) - 1) - g[i].size();
	}
	for( int i = 0; i < K; i++ ) {
		int c, d;
		cin >> c >> d;
		c--;
		d--;
		if( uf.findSet( c, d ) ) {
			ans[c]--;
			ans[d]--;
		}
	}

	for( int i = 0; i < N; i++ ) {
		if( i ) cout << " ";
		cout << ans[i];
	}
	cout << endl;
}


Measured memory_bytes: 7416
#include <stdio.h>

int main(void)
{
	int n, i;
  int h[30];
  int ans = 0;
  int max = 0;
	
	scanf("%d", &n);
  
  for (i = 0; i < n; i++){
    scanf("%d ", &h[i]);
    if ((i == 0)||((h[i-1] <= h[i])&&(max <= h[i]))){
      ans++;
    }
    if (max < h[i]){
      max = h[i];
    }
  }
	
	printf("%d", ans);
	
	return 0;
	
}

Measured memory_bytes: 128
c[2];i;m;main(j,s)char*s;{gets(s);for(gets(s);s[++i];m=fmax(__builtin_popcount(*c&c[1]),m))for(*c=c[1]=j=0;s[j];)c[j<i]|=1<<s[j++]-97;printf("%d",m);}


Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))

res = 0
sums = sum(A)
for i in range(len(A)):
  sums = sums - A[i]
  a = A[i]
  res += ((a * sums) % (10 ** 9 + 7))
print(res % (10 ** 9 + 7))

Measured memory_bytes: 31536
<?php
/*
    Problem URL : http://abc046.contest.atcoder.jp/tasks/abc046_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

fscanf(STDIN, "%d %d", $N, $K);

$ans = 1;

for ($i = 0; $i < $N; $i++) {
    $ans *= $K - ($i !== 0);
}

echo $ans . PHP_EOL;

Measured memory_bytes: 2812
#include <iostream>
#include<string>
using namespace std;
int main(void){
	string s;
    
    cin >> s;
 	
	if (s == "Sunny"){
        cout<<"Cloudy"<<endl;
    } else if(s == "Cloudy"){
        cout<<"Rainy"<<endl;
    }else{
        cout<<"Sunny"<<endl;
    }
	
	return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
N,M=map(int,input().split())

L=[[]for i in range(N+1)]

I=[0 for i in range(N+1)]
for i in range(N+M-1):
    a,b=map(int,input().split())
    L[a].append(b)
    I[b]+=1
    
#print(L)
#print(I)
P=[-1 for i in range(N+1)]
S=-1
for i in range(1,N+1):
    if I[i]==0:
        P[i]=0
        S=i
        break

B=[]
cnt=0
for i in L[S]:
    if I[i]==1:
        B.append(i)
        P[i]=S
    else:
        I[i]-=1

for i in range(10**6):
    if cnt==len(B):
        break
    for j in L[B[cnt]]:
        if I[j]==1:
            B.append(j)
            P[j]=B[cnt]
        else:
            I[j]-=1
    cnt+=1
for i in range(1,N+1):
    print(P[i])

Measured memory_bytes: 61616
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int lli;
typedef pair<int,int> pii;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

map<int,int> memo;

int DFS(int n){
	auto it=memo.find(n);
	if(it!=memo.end()) return it->second;
	int a=n/3;
	int b=(n-a)/2;
	int c=n-a-b;
	return memo[n]=max(DFS(a),max(DFS(b),DFS(c)))+1;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	memo[0]=memo[1]=0;
	memo[2]=memo[3]=1;
	int N;
	cin >> N;
	cout << DFS(N) << endl;
	return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] ary = new int[n];
		int check = 1;
		for(int i = 0; i < n; i++){
			if(check == sc.nextInt()){
				check++;
			}
		}
		System.out.println(check == 1 ? -1 : n - check + 1);
	}
}


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

using namespace std;

typedef long long ll;

const int MAXN = 205;

int T,n;

ll base[64];
ll a[MAXN];

char s[MAXN];

void insert(ll v)
{
	for (int i = 62;i >= 0;i--)
		if (v >> i & 1)
		{
			if (!base[i])
			{
				base[i] = v;
				return;
			}
			v ^= base[i];
		}
}

bool ok(ll v)
{
	for (int i = 62;i >= 0;i--)
		if (v >> i & 1)
		{
			if (!base[i])
				return 0;
			v ^= base[i];
		}
	return 1;
}

int main()
{
	scanf("%d",&T);
	while (T--)
	{
		scanf("%d",&n);
		for (int i = 1;i <= n;i++)
			scanf("%lld",&a[i]);
		scanf("%s",s + 1);
		memset(base,0,sizeof(base));
		int flag = 0;
		for (int i = n;i >= 1;i--)
			if (s[i] == '0')
				insert(a[i]);
			else if (!ok(a[i]))
			{
				flag = 1;
				break;
			}
		printf("%d\n",flag);
	}
	return 0;
}


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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 1e5 + 2, M = 15;

int A[N], C[M + 1], DP[1 << M], XO[1 << M];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	for (int mask = 1; mask < (1 << M); mask++) XO[mask] = XO[mask - (mask & -mask)] ^ (__builtin_ctz(mask) + 1);
	for (int mask = 1; mask < (1 << M); mask++) for (int sub = mask; sub > 0; sub = (sub - 1) & mask) if (XO[sub] == 0) DP[mask] = max(DP[mask], DP[mask ^ sub] + 1);

	int n; cin >> n;
	for (int i = 1; i < n; i++) {
		int v, u, x; cin >> v >> u >> x;
		A[v] ^= x, A[u] ^= x;
	}
	for (int i = 0; i < n; i++) C[A[i]]++;
	int x = 0, cnt = C[0];
	for (int i = 1; i <= M; i++) {
		cnt += C[i] >> 1;
		if (C[i] & 1) x ^= (1 << (i - 1));
	}
	cout << n - (cnt + DP[x]) << endl;

	return 0;
}


Measured memory_bytes: 1024
import scala.io.StdIn._
import scala.math._

object Main extends App with StdInHelper {
  val Array(x, n) = readInts
  val ps = readInts

  var finish = false

  var i = 0
  while (!finish) {
    if (!ps.contains(x - i)) {
      println(x - i)
      finish = true
    } else if (!ps.contains(x + i)) {
      println(x + i)
      finish = true
    }
    i += 1
  }
}

trait StdInHelper {
  def readStrings = {
    val l = readLine
    if (l == "") Array.empty[String]
    else l.split(" ")
  }
  def readInts = readStrings.map(_.toInt)
  def readLongs = readStrings.map(_.toLong)
  def readDoubles = readStrings.map(_.toDouble)
  def readBigInts = readStrings.map(BigInt.apply(_))
  def readBigDecimals = readStrings.map(BigDecimal.apply(_))
}


Measured memory_bytes: 54872
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        k: isize,
        x: isize
    };

    let l = x - k + 1;
    let r = x + k - 1;
    let res = (l..=r).join(" ");
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


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

int main(){
    int N; cin >> N;
    string ans;
    switch (N)
    {
    case 25:
        ans = "Christmas";
        break;
    
    case 24:
        ans = "Christmas Eve";
        break;
    
    case 23:
        ans = "Christmas Eve Eve";
        break;
    
    case 22:
        ans = "Christmas Eve Eve Eve";
        break;
    
    default:
        break;
    }
    cout  << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N = 1e3 + 5;
string grid[N];
int mod = 1e9 + 7;
ll mem[N][N];
int n, m;
ll DP(int i = 0, int j = 0){
    if(i == n-1 && j == m-1)
        return 1;
    ll &ret = mem[i][j];
    if(~ret)
        return ret;
    return ret = ((i+1<n && grid[i+1][j]=='.'?DP(i+1, j)%mod:0) +
            (j+1 < m && grid[i][j+1]=='.'?DP(i, j+1)%mod:0)) %mod;
}



int main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false), cin.tie(0);
#endif
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    memset(mem, -1, sizeof(mem));
    cin>>n>>m;
    for(int i=0; i<n; i++)
        cin>>grid[i];
    cout<<DP()<<'\n';

}










Measured memory_bytes: 12756
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);
    
    int n;
    cin >> n;
    int m;
    cin >> m;
    vector<int> A(m);
    vector<int> B(m);
    vector<int> C(m);

    const long long INF = 1LL << 50;
    vector<vector<long long>> dis(n, vector<long long>(n, INF));
    for (int i = 0; i < m; ++i) {
        cin >> A[i] >> B[i] >> C[i];
        --A[i], --B[i];
        dis[A[i]][B[i]] = C[i];
        dis[B[i]][A[i]] = C[i];
    }
    for (int i = 0; i < n; ++i) {
        dis[i][i] = 0;
    }

    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }


    int res = 0;
    for (int i = 0; i < m; ++i) {
        int u = A[i], v = B[i];
        bool ok = false;
        for (int s = 0; s < n && !ok; ++s) {
            for (int t = 0; t < n; ++t) {
                if (dis[s][u] + C[i] + dis[v][t] == dis[s][t]) {
                    ok = true;
                    break;
                }
            }
        }
        if (!ok) {
            ++res;
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  string s;
  cin >> s;
  bool alpha[3];
  int ans = 0;
  rep(i,3)alpha[i] = false;
  rep(i,3){
    if(s[i] == 'a')alpha[0] =true;
    else if(s[i] == 'b')alpha[1] =true;
    else if(s[i] == 'c')alpha[2] = true;
  }
  rep(i,3)if(alpha[i] == true)ans++;
  cout << (ans == 3?"Yes":"No") << endl;

}


Measured memory_bytes: 256
n = int(input())
h_s = [int(v) for v in input().split()]

ans = 'Yes'
for i in range(n - 2, -1, -1):
  if h_s[i] > h_s[i + 1]:
    if h_s[i] - 1 == h_s[i + 1]:
      h_s[i] -= 1
    else:
      ans = 'No'
      break
      
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e5+100,inf=(ll)1e15;
ll seg[2][N*4];
void upd(ll nod,ll l,ll r,ll L,ll R,ll id,ll val){
    if (l>=R || L>=r) return ;
    if (l>=L && r<=R){
        seg[id][nod]=val;
        return ;
    }
    ll mid=(r+l)/2;
    upd(nod*2,l,mid,L,R,id,val);
    upd(nod*2+1,mid,r,L,R,id,val);
    seg[id][nod]=min(seg[id][nod*2],seg[id][nod*2+1]);
    return ;
}
ll get(ll nod,ll l,ll r,ll L,ll R,ll id){
    if (l>=R || L>=r) return inf;
    if (l>=L && r<=R){
        return seg[id][nod];
    }
    ll mid=(r+l)/2;
    return min(get(nod*2,l,mid,L,R,id),get(nod*2+1,mid,r,L,R,id));
}
ll a[N];
int32_t main(){
    ll n,q,a,b;
    cin >> n >> q >> a >> b;
    memset(seg,63,sizeof seg);
    ll lazy=0;
    upd(1,1,N,b,b+1,1,b);
    upd(1,1,N,b,b+1,0,-b);
    while(q--){
        ll x;
        cin >> x;
        ll z=min(get(1,1,N,1,x+1,0)+x,get(1,1,N,x,N,1)-x)+lazy;
        lazy+=abs(a-x);
        z-=lazy;
        upd(1,1,N,a,a+1,1,z+a);
        upd(1,1,N,a,a+1,0,z-a);
        a=x;
    }
    ll mi=inf;
    for (int i=1;i<=n;i++){
        ll t=get(1,1,N,i,i+1,1)-i;
        t+=lazy;
        mi=min(mi,t);
    }
    cout << mi << endl;
}


Measured memory_bytes: 16152
# Aizu Problem 0074: Videotape
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    t, m, s = [int(_) for _ in input().split()]
    if t == m == s == -1:
        break
    secs_left = 7200 - 3600 * t - 60 * m - s
    for secs in [secs_left, 3 * secs_left]:
        h = secs // 3600
        secs %= 3600
        m = secs // 60
        s = secs % 60
        print("%02d:%02d:%02d" % (h, m, s))

Measured memory_bytes: 7840
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> A(pow(10, 5) + 5, vector<int>());
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        a--;
        A[a].push_back(b);
    }

    ll ans = 0;
    priority_queue<ll> pq;
    for (int i = 0; i < M; i++) {
        if (A[i].size() != 0) {
            for (auto a : A[i]) {
                pq.push(a);
            }
        }
        if (!pq.empty())
            ans += pq.top(), pq.pop();
    }

    cout << ans << endl;
}

Measured memory_bytes: 5632
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	int a, b, c; cin >> a >> b >> c;
	if (a >= b && a >= c) {
		cout << a * 10 + b + c << endl;
	}
	else if (b >= c && b >= a) {
		cout << b * 10 + a + c << endl;
	}
	else cout << c * 10 + a + b << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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; }
const ll MOD = 1e9 + 7;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -MOD * MOD;
const long double pi = 3.141592653589793;
int main() {
	int n, m;
	cin >> n >> m;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	VV G(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<bool> good(n, true);
	rep(i, n) {
		for (auto c : G[i]) {
			if (a[i] <= a[c]) good[i] = false;
		}
	}
	int ans = 0;
	rep(i, n) {
		if (good[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

long long lcm(long long A, long long B){
  long long  C;
  while(A%B!=0){
    C=B;
    B=A%B;
    A=C;
  }
  return B;
}

int main() {
long long Q,W;
  cin>>Q>>W;
  
  long long X;
  X=lcm(Q,W);
  long long Y;
  Y=Q*W/X;
 // cout<<Q*W<<endl;
  cout<<Y<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)

int N,M;
vector<pii>power;

int main(){
    scanf("%d%d",&N,&M);
    power.resize(M);
    rep(i,M)scanf("%d%d",&power[i].fi,&power[i].se);
    sort(all(power));

    int right=0,cur=0;
    int cnt=0;
    while(true){
        if(right==N){
            printf("%d\n",cnt);
            return 0;
        }

        int use=-1;
        while(cur<power.size()&&power[cur].fi<=right+1){
            if(use<power[cur].se)use=power[cur].se;
            cur++;
        }
        if(use==-1)break;
        right=use;
        cnt++;
    }
    puts("Impossible");
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll a(n);
    rep(i,n) cin>>a[i];
    ll sum=0;
    ll pm=0,mp=0;
    rep(i,n){
        sum+=a[i];
        ll goal=(i&1)?1:-1;
        if (goal*sum>0) continue;
        mp += abs(goal-sum);
        sum += goal-sum;
    }
    sum=0;
    rep(i,n){
        sum+=a[i];
        ll goal=(i&1)?-1:1;
        if (goal*sum>0) continue;
        pm += abs(goal-sum);
        sum += goal-sum;
    }
    cout<<min(mp,pm)<<"\n";
    return 0;
}


Measured memory_bytes: 1024
def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())


mod = 10**9 + 7


def main():
    n, a, b = I()
    s = input()
    yn = []
    for i in range(n):
        if s[i] == 'a':
            if a + b > 0:
                print('Yes')
                if a > 0:
                    a -= 1
                else:
                    b -= 1
            else:
                print('No')
        elif s[i] == 'b':
            if a + b > 0 and b > 0:
                print('Yes')
            else:
                print('No')
            if b > 0:
                b -= 1
        else:
            print('No')


if __name__ == '__main__':
    main()


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;


set<int> aset[26];
int main()
{
    int n;cin >> n;
    string s;cin >> s;
    int q;cin >> q;
    rep(i,n)
    {
        aset[s[i]-'a'].insert(i);
    }
    
    vector<int> ans;
    rep(i,q)
    {
        int type;cin >> type;
        if(type == 1)
        {
            int index;cin >> index;
            index--;
            char c;cin >> c;
            aset[s[index]-'a'].erase(index);
            s[index] = c;
            aset[s[index]-'a'].insert(index);
        }
        if(type == 2)
        {
            int l,r;cin >> l >> r;
            l--;r--;
            int tans = 0;
            rep(j,26)
            {
                if(aset[j].size()==0)continue;
                auto itr = aset[j].lower_bound(l);
                if(itr != aset[j].end())
                {
                    int temp = *itr;
                    if (temp <= r)
                    {
                        tans++;
                    }
                }
                
            }
            ans.push_back(tans);
        }
    }
    for (auto &&i : ans)
    {
        cout << i << endl;
    }
    
}

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

using namespace std;

using ll = long long;

constexpr ll inf = 1e18;

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

  int n;
  cin >> n;

  vector<ll> a(n), pref(n + 1);
  vector<vector<ll>> dp(n, vector<ll>(n, inf));
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    pref[i + 1] = pref[i] + a[i];
    dp[i][i] = 0;
  }

  for (int len = 2; len <= n; ++len) {
    for (int i = n - len; i >= 0; --i) {
      int r = i + len - 1;
      for (int k = i; k < r; ++k) {
        dp[i][r] = min(dp[i][r], dp[i][k] + dp[k + 1][r] + pref[r + 1] - pref[i]);
      }
    }
  }

  cout << dp[0][n - 1] << '\n';

  return 0;
}


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

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

s=sum(A)
for i in range(2,n,2):
    s-=2*A[i-1]
    ans=str(s)+' '
for j in range(n-1):
    s=2*A[j]-s
    ans+=str(s)+' '

print(ans)

Measured memory_bytes: 14028
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long
 
#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)
 
#define sl          cout<<' '
#define ps          printf(" ")
 
#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))
 
#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())
 
#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound
 
#define ALL(V)  V.begin(),V.end()
 
#define MX1     100000LL
#define MX2     1000000LL
#define Inf     1000000000000000LL
#define mod		1000000007LL
using namespace std;
 
lli Power(lli a,lli b)
{
    lli result=1;
 
    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }
 
        b=b>>1;
        a=(a*a)%mod;
    }
 
 return result;
}
 
int main()
{
    //opt;
 
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
 
    int N,i,Q;
    scanf("%d %d",&N,&Q);
 
    while(Q--)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        
        if(N==1)
        {
            printf("%d\n",min(a,b));
            continue;
        }
 
        --a,--b;
 
        while(a != b)
        {
            if(a>b)
            {
                a=(a-1)/N;
            }
            else
            {
                b=(b-1)/N;
            }
        }
 
        printf("%d\n",a+1);
    }
 
 
 
 
 
 
 
 return 0;
}

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

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i]--;
  }
  int p = 0, ans = -1;
  rep(i, n) {
    if (a[i] == p) {
      ++p;
      ans = n-p;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024