akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using o_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) find_by_order(i)
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);


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

Measured memory_bytes: 3664
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
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; }
map<int,int> mp;
ll dp[10][10];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
vector<int> a(n);
int cnt=0;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++){
    if(a[i]==i+1){
        if(i+1<n&&a[i+1])swap(a[i],a[i+1]);
        cnt++;
    }
}
cout<<cnt<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
    long long N, A, B, x, y, z, a, b;
    scanf("%lld%lld%lld", &N, &A, &B);
    if ((A-B)%2==0) {
        x=(A-B)/2;
        if (x<0) x=-x;
        printf("%lld", x);
    }
    else {
        y=A-1;
        z=N-B;
        a=y;
        b=1;
        if (z<y) {
            a=z;
            b=2;
        }
        if (b==1) {
            x=y+1;
            A=1;
            B-=y+1;
        }
        else {
            x=z+1;
            A+=z+1;
            B=N;
        }
        // printf("%lld ", x);
        x+=(B-A)/2;
        printf("%lld", x);
        // printf("\n%lld %lld %lld %lld %lld", b, y, z, A, B);
    }
    return 0;
}


Measured memory_bytes: 128
s = input()
t = input()
n,m = len(s),len(t)
dp = [[0]*(m+1) for _ in range(n+1)]
for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j]+1
        else:
            dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])
res = ''
while n and m:
    if dp[n][m] == dp[n-1][m]:
        n -= 1
    elif dp[n][m] == dp[n][m-1]:
        m -= 1
    else:
        res = s[n-1]+res
        n -= 1
        m -= 1
print(res)


Measured memory_bytes: 112220
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long K = sc.nextLong();
    long res = N-K;
    long answer=0;
    if(N>=K){
      answer+=(res/K+1)*(res/K+1)*(res/K+1);
      if(K%2==0){
        long res_2 = N-K/2;
        answer+=(res_2/K+1)*(res_2/K+1)*(res_2/K+1);
      }
      System.out.println(answer);
    }else{
      if(K%2==0&&2*N>=K){
        answer++;
      }
      System.out.println(answer);
    }
  }
}


Measured memory_bytes: 23508
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
A = list2d(N, M, 0)
for i in range(N):
    for j, a in enumerate(LIST()):
        # データの持ち方を変える
        A[i][a-1] = j

k = 0
valid = [1] * M
ans = INF
while k < M:
    cnt = [0] * M
    for i in range(N):
        mn = INF
        idx = -1
        for j in range(M):
            if valid[j] and A[i][j] < mn:
                mn = A[i][j]
                idx = j
        # 一番順位が高いスポーツにカウント追加
        cnt[idx] += 1
    mx = max(cnt)
    ans = min(ans, mx)
    for i in range(M):
        # 票が最も集まったものは次から選ばないようにする
        if cnt[i] == mx:
            valid[i] = 0
            k += 1
print(ans)


Measured memory_bytes: 46172
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
  int u, minv;
  // 重み、親、色
  int d[MAX], p[MAX], color[MAX];

  for (int i = 0; i < n; i++) {
    d[i] = INFTY;
    p[i] = -1;
    color[i]  = WHITE;
  }

  d[0] = 0;

  while (1) {
    minv = INFTY;
    u = -1;
    for (int i = 0; i < n; i++) {
      if (color[i] != BLACK && d[i] < minv) {
        minv = d[i];
        u = i;
      }
    }

    if (u == -1) break;

    color[u] = BLACK;

    for (int v = 0; v < n; v++) {
      if (color[v] != BLACK && M[u][v] != INFTY) {
        if (d[v] > M[u][v]) {
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }

  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += d[i];
  }

  return sum;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int e;
      cin >> e;
      M[i][j] = (e == -1) ? INFTY : e;
    }
  }
  cout << prim() << endl;
};



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
#define fi cin
#define fo cout 
#define repi(i,a,n) for(i=a;i<n;i++)
#define repie(i,a,n) for(i=a;i<=n;i++)
#define repd(i,a,n) for(i=n;i>a;i--)
#define repde(i,a,n) for(i=n;i>=a;i--) 
#define pb(n) push_back(n)
#define ff first
#define ss second
#define dfo if(0) cout
#define mod 1000000007
#define mem(x) memset(x,0,sizeof(x))

int main()
{
	ios_base::sync_with_stdio(0);
	fi.tie(0);
	fo.tie(0);

	ll i,j,k,t,tc,n;

	fi>>n;
	ll a[n];

	ll maxi=0,r=0;

	repi(i,0,n)
	{
		fi>>a[i];
		maxi=max(maxi,a[i]);
	}
	k=maxi/2;

	for(i=0;i<n;++i)
	{
		if(abs(k-r) > abs(k-a[i]))r=a[i];
	}	
	fo<<maxi<<" "<<r<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>

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

int main() {
	long long int n;
	cin >> n;
	vector< vector<long long int> > g(n);
	long long int a, b;
	for (long long int i = 0; i < n-1; i++) {
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<long long int> aa(n, -1);
	vector<long long int> bb(n, -1);
	queue<P> q;
	q.push(P(1, 0));
	aa[0] = 0;
	long long int al, bl;
	al = bl = -1;
	while (!q.empty()) {
		P p = q.front();
		q.pop();
		//cout << p.first << ' ' << p.second << endl;
		for (long long int j = 0; j < g[p.second].size(); j++) {
			//cout << g[p.second][j] << endl;
			if (g[p.second][j] == n - 1) {
				al = p.first;
			} else if (aa[g[p.second][j]] == -1) {
				aa[g[p.second][j]] = p.first;
				q.push(P(p.first + 1, g[p.second][j]));
			} 
		}
	}
	q.push(P(1, n - 1));
	bb[n - 1] = 0;
	while (!q.empty()) {
		P p = q.front();
		q.pop();
		//cout << p.first << ' ' << p.second << endl;
		for (long long int j = 0; j < g[p.second].size(); j++) {
			//cout << g[p.second][j] << endl;
			if (g[p.second][j] == 0) {
				bl = p.first;
			}
			else if (bb[g[p.second][j]] == -1) {
				bb[g[p.second][j]] = p.first;
				q.push(P(p.first + 1, g[p.second][j]));
			}
		}
	}
	long long int a2, b2, c2, d2;
	a2 = b2 = c2 = d2 = 0;
	for (long long int i = 0; i < n; i++) {
		//cout << bb[i] << ' ';
		if (aa[i] > 0 && bb[i] > 0) {
			if (aa[i] <= bb[i]) {
				c2++;
			}
			else {
				d2++;
			}
		}
		else if (aa[i] > 0) {
			a2++;
		}
		else if (bb[i] > 0) {
			b2++;
		}
	}
	//cout << a2 << ' ' << b2 << ' ' << c2 << endl;
	if (a2 + c2 > b2 + d2) {
		cout << "Fennec" << endl;
	}
	else {
		cout << "Snuke" << endl;
	}
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
 
#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
 
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-
 
 
 
ll n,m,k,x,y,r;
ll dp[9999999][2];
ll a;ll aa[9900000];ll mp[990000];
 
 
int main()
{
   
   set<ll>v;  
ll ans=0;
 ll mx=0;
cin>>n;cout<<(n*n)*3;
  

  
   }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll k,n=50;
    cin>>k;
    ll arr[50];
    FOR(i, 0, 50) {
    	arr[i] = i + k / n;
    }
    k %= n;
    int ind = 0;
    while(k--) {
    	arr[ind] += n;
    	FOR(i, 0, 50) {
    		if(i == ind) continue;
    		arr[i]--;
    	}
    	ind++;
    }
    cout<<50<<endl;
    FOR(i, 0, 50) {
    	cout<<arr[i]<<" ";
    }

    return 0;
}

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

int main() {
    int64_t N, M, a, ans = 0;
    cin >> N >> M;
    priority_queue<int> s;
    for (int i = 0; i < N; i++) {
        cin >> a;
        s.push(a);
    }
    for (int i = 0; i < M; i++) {
        a = s.top();
        a /= 2;
        s.pop();
        s.push(a);
    }
    for (int i = 0; i < N; i++) {
        ans += s.top();
        s.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <utility>
using namespace std;


typedef long long LL;
typedef pair<LL, LL> P;

const LL BASE = 1000000007;


// Borrowed from: https://qiita.com/drken/items/0c88a37eec520f82b788
LL gcd(LL a, LL b) {
	if (!b) return a;
	else return gcd(b, a % b);
}


LL pow2(LL M) {
	if (M == 0) return 1LL;
	
	LL a = M / 2;
	LL b = pow2(a);
	b = (b * b) % BASE;
	if (M % 2) b = (b * 2) % BASE;
	
	return b;
}


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

	vector<LL> A(N), B(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i] >> B[i];

	int zeros = 0;

	map<P, P> d;
	for (int i = 0; i < N; ++i) {
		auto iw = make_pair(A[i], B[i]);

		if (!iw.first && !iw.second) {
			++zeros;
			continue;
		}

		if (!iw.first) {
			d[make_pair(1LL, 0)].second++;
		} else if (!iw.second) {
			d[make_pair(1LL, 0)].first++;
		} else {
			LL c = gcd(abs(iw.first), abs(iw.second));
			iw.first /= c;
			iw.second /= c;

			if (iw.first < 0) {
				iw.first *= -1;
				iw.second *= -1;
			}

			if (iw.second > 0) d[iw].first++;
			else d[make_pair(-iw.second, iw.first)].second++;
		}
	}

	LL ans = 1;
	for (auto const kv : d) {
		LL ans0 = (pow2(kv.second.first) + pow2(kv.second.second) - 1) % BASE;
		ans = (ans * ans0) % BASE;
	}
	ans = (ans - 1 + zeros) % BASE;
	if (ans < 0) ans = ans + BASE;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 21344
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
//#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define PB push_back
#define MP make_pair
#define INF 1073741824
#define inf 1152921504606846976
#define pi 3.14159265358979323846
//#pragma comment(linker,"/STACK:10240000,10240000")
//mt19937 rand_(time(0));
const int N=3e5+7,M=2e6;
const long long mod=1e9+7;
inline int read(){int ret=0;char ch=getchar();bool f=1;for(;!isdigit(ch);ch=getchar()) f^=!(ch^'-');for(;isdigit(ch);ch=getchar()) ret=(ret<<1)+(ret<<3)+ch-48;return f?ret:-ret;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll ksm(ll a,ll b,ll mod){int ans=1;while(b){if(b&1) ans=(ans*a)%mod;a=(a*a)%mod;b>>=1;}return ans;}
ll inv2(ll a,ll mod){return ksm(a,mod-2,mod);}//逆元
int head[N],NEXT[M],ver[M],tot;void link(int u,int v){ver[++tot]=v;NEXT[tot]=head[u];head[u]=tot;}
int dp[N],indeg[N];
void dfs(int x){
    for(int i=head[x];i;i=NEXT[i]){
        int y=ver[i];
        if(dp[y]) dp[x]=max(dp[y]+1,dp[x]);
        else {
            dfs(y);
            dp[x]=max(dp[y]+1,dp[x]);
        }
    }
}
int main(){
    //freopen("1.txt","r",stdin);
    //ios::sync_with_stdio(false);
    int n,m;
    int u,v;
    tot=0;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d",&u,&v);
        link(u,v);
        indeg[v]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(indeg[i]) continue;
        dfs(i);
        ans=max(ans,dp[i]);
    }
    printf("%d\n",ans);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}




Measured memory_bytes: 12288
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 
int main(){
    int n ;
    cin >> n;
    map<int, int> mp ;
    rep(i, n){
        int a ;
        cin >> a; 
        if(mp.count(a)){
            cout << "NO" << endl ;
            return 0 ;
        }
        else {
            mp[a] = 1 ;
        }
    }
    cout << "YES" << endl ;
} 

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    int ans = 0;
    rep2(i,1, N + 1)  {
        if (i % 2) {
            int cnt = 0;
            for (int j = 1; j * j <= i; j++) {
                if (i % j == 0) {
                    cnt ++;
                    if (j != i / j) {
                        cnt++;
                    }
                }
            }
            if (cnt == 8) {
                ans ++;
            }
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  long a, b, c=0, d=0, e, f, g, h, n;
  cin >> a >> b;
  while(1){
    if(a>0){
      a=a-b;
      c++;
    }
    else break;
  }
  co(c);
  
  return 0;
}


Measured memory_bytes: 256
import itertools
N,M = map(int,input().split())
switch = [list(map(int,input().split())) for m in range(M)]
p = list(map(int,input().split()))
S = list(itertools.product([0,1], repeat=N))
ans = 0
for s in S:
    s_ok = 0
    for m in range(M):
        count = 0
        for i in range(1, switch[m][0]+1):
            if s[switch[m][i]-1] == 1:
                count += 1
        if count%2 == p[m]:
            s_ok += 1
        else:
            break
    if s_ok == M:
        ans += 1
print(ans)



Measured memory_bytes: 3188
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
ll n,m;
vector<ll> g[101010];
ll col[101010];

bool dfs(ll v,ll c){
  col[v]=c;
  for(ll nv : g[v]){
    if(col[nv]!=-1){
      if(col[nv]!=1-c)return false;
    }else{
      if(!dfs(nv,1-c))return false;
    }
  }
  return true;
}

int main(){
  cin>>n>>m;
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  memset(col,-1,sizeof(col));
  if(dfs(0,0)){
    ll c0=0,c1=0;
    rep(i,n){
      if(col[i]==0)c0++;
      else c1++;
    }
    cout<<c1*c0-m<<endl;
  }else{
    cout<<n*(n-1)/2-m<<endl;
  }
  return 0;
}


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

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

  vector<char> A(N);
  for (int i = 0; i < N; i++) {
    char C;
    cin >> C;
    A.at(i) = C;
  }

  vector<int> B(N);
  for (int i = 1; i < N; i++) {
    if (A.at(i - 1) == 'A' && A.at(i) == 'C') B.at(i)++;
    B.at(i) += B.at(i - 1);
  }

  for (int i = 0; i < Q; i++) {
    int L, R;
    cin >> L >> R;
    cout << B.at(R - 1) - B.at(L - 1) << endl;
  }
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for(int i = 0;i <= n-3;i++){
    if(s[i] =='A' && s[i+1] =='B' && s[i+2] =='C'){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	ll h, w; cin >> h >> w;
	ll ans = 1e9;
	for (ll i = 1; i < h; ++i) {
		ans = min(ans, max(i*w, (h - i + 1) / 2 * w) - min(i*w, (h - i) / 2 * w));
		ans = min(ans, max(i*w, (w + 1) / 2 * (h - i)) - min(i*w, w / 2 * (h - i)));
	}
	for (ll i = 1; i < w; ++i) {
		ans = min(ans, max(i*h, (w - i + 1) / 2 * h) - min(i*h, (w - i) / 2 * h));
		ans = min(ans, max(i*h, (h + 1) / 2 * (w - i)) - min(i*h, h / 2 * (w - i)));
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
	int a, mini=10, sum=0;
	rep(i, 5) {
		cin >> a;
		if (a % 10 != 0) {
			mini = min(mini, a % 10);
			a = (a / 10 + 1) * 10;
		}
		sum += a;
	}
	cout << sum + mini - 10 << endl;
	


	return 0;
}



Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
if c > 0:
  if b > 0:
    ret = b * d
  else:
    ret = b * c
elif c <= 0 and d > 0:
  if a > 0:
    ret = b*d
  elif a <= 0 and b > 0:
    ret = max(a * c, b * d)
  else:
    ret = a * c
else:
  if a > 0:
    ret = a * d
  else:
    ret = a * c
print(ret)

Measured memory_bytes: 9196
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const double PI = 3.1415926535897932384626433832795;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  --x;
  --y;
  vector<int> ans(n);
  rep(i, n) {
    int start = i;
    vector<int> dist(n, INF);
    queue<P> q;
    auto push = [&](int v, int d) {
      // cout << v << endl;
      if (d < dist[v]) {
        q.push(P(v, d));
        dist[v] = d;
      }
    };
    push(start, 0);

    while (!q.empty()) {
      P p = q.front(); q.pop();
      int v = p.first;
      int d = p.second;
      if (v - 1 >= 0) push(v - 1, d + 1);
      if (v + 1 < n) push(v + 1, d + 1);
      if (v == x) push(y, d + 1);
      if (v == y) push(x, d + 1);
    }

    rep(i, n) ans[dist[i]]++;
  }
  for (int i = 1; i <= n - 1; ++i) {
    cout << ans[i] / 2 << endl;
  }

}

Measured memory_bytes: 256
#include<stdio.h>
#define N 500000
#define INFTY 1000000000

void merge(int *,int,int,int);
void mergesort(int *,int,int);

int cnt = 0;

int main () {

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

  mergesort(a,0,n);

    for(i=0;i<n;i++){
    if(i != n-1)
      printf("%d ",a[i]);
    else if(i == n-1)
      printf("%d\n",a[i]);
  }
  printf("%d\n",cnt);

return 0;
}

void mergesort(int *A,int left,int right){
  int mid;
  if (left+1 < right){
  mid = (left + right) / 2;
  mergesort(A,left,mid);
  mergesort(A,mid,right);
  merge(A,left,mid,right);
  }
}

void merge (int *A,int left,int mid,int right){
  int i,j,k,n1,n2,L[N],R[N];
  n1 = mid - left;
  n2 = right - mid;

  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
    A[k] = L[i];
    i=i+1;
    }
    else{
    A[k] = R[j];
    j=j+1;
    }
  }
}

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

int main(){
	
	char str[100];
	scanf("%s",str); getchar();
	int len= strlen(str);
	int x=len-1;
	int count = 0;
	for(int i=0; i<len-1; i++){
		if(str[i]==str[x]){
			count++;
		}
		x--;
	}
	if(count==len-1){
		printf("Yes");
	}
	else printf("No");
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    FAST
    int n;
    cin>>n;
    string s;
    cin>>s;
    int len=s.length();
    if(len & 1)cout<<"No";
    else{
        if(s.substr(0,len/2)==s.substr(len/2,len/2))
         cout<<"Yes";
         else
         cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		String[] strs;
		int x;
		int y;
		int w;
		while(true){
			str = br.readLine();
			strs = str.split(" ");
			x = Integer.parseInt(strs[0]);
			y = Integer.parseInt(strs[1]);
			if(x == 0 && y == 0){
				break;
			}else if(x > y){
				w = y;
				y = x;
				x = w;
			}//if
			System.out.println(x + " " + y);
		}//while
	}
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    string s;
    cin >> s;
    reverse(all(s));
    if(s=="0") return 0;
    vector<int> count(11,0);
    int now=0,ans=0;
    count[0]++;
    for(int i=0;i<s.length();i++){
      now=(now+(s[i]-'0')*(i%2?-1:1)+11)%11;
      // cout << now << endl;
      if(s[i]!='0') ans+=count[now];
      count[now]++;
      // for(int i=0;i<11;i++){
      //   cout << count[i]<<" ";
      // }
      // cout << endl;
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3288
#include<stdio.h>
int main(){
  int i=1, sum5=0;
  for( i ; i <= 5 ; i++){
    int seiseki=0;
    scanf("%d",&seiseki);
    if(seiseki < 40){
      seiseki=40;
      }
    sum5 += seiseki;
  }
  printf("%d\n",sum5/5);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,T;
    cin>>n>>T;
    vector<ll> t(n);
    rep(i,n) cin>>t[i];

    ll ans=T;
    for(int i=1;i<n;i++){
        ans+=min(T,t[i]-t[i-1]); 
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1000000000000
typedef long long ll;

int main()
{
  ll n, ans = INF, sum = 0;
  cin >> n;

  vector<int> x(n);
  REP(i,n){
    cin >> x[i];
  }
  FOR(i, 1, 100)
  {
    REP(j, n)
    {
      sum += (x[j] - i) * (x[j] - i);
    }
    if (sum < ans)
    {
      ans = sum;
    }
    sum = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        long A = cin.nextInt();
        long B = cin.nextInt();
        long K = cin.nextLong();

        setFact(N + 1);

        long ans = 0;
        for (long a = 0; a <= N; a++)
        {
            long b = (K - (a * A)) / B;
            if (b < 0 || b > N) continue;
            if (a * A + b * B != K) continue;
            

            long tmp = getC(N, (int)a) * getC(N, (int)b);
            ans += tmp % mod;
            ans %= mod;
        }

        Console.WriteLine(ans);
    }

    long mod = 998244353;
    long powmod(long a, long p)
    {
        long ans = 1;
        long mul = a;
        for (; p > 0; p >>= 1, mul = (mul * mul) % mod)
        {
            if ((p & 1) == 1) ans = (ans * mul) % mod;
        }
        return ans;
    }


    long[] fact; //階乗
    long[] revFact; //階乗の逆元
    void setFact(int N)
    {
        fact = new long[N];
        revFact = new long[N];
        fact[0] = 1;
        for (int i = 1; i < N; i++)
        {
            fact[i] = fact[i - 1] * i;
            fact[i] %= mod;
        }
        revFact[N - 1] = powmod(fact[N - 1], mod - 2);
        for (int i = N - 2; i >= 0; i--)
        {
            revFact[i] = revFact[i + 1] * (i + 1);
            revFact[i] %= mod;
        }
    }


    long getC(int a, int b)
    {
        return (((fact[a] * revFact[b]) % mod) * revFact[a - b]) % mod;
    }

}






class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 15584
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<string>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	ll N;
	cin >> N;
	ll t[N + 100], x[N + 100], y[N + 100];
	for (ll i = 1; i <= N; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}
  	t[0]=0,x[0]=0,y[0]=0;
	string ans = "Yes";
	for (ll i = 0; i < N; i++) {
		ll m = t[i + 1] - t[i];
		ll n = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		if (m % 2 != n % 2 || m < n)
			ans = "No";
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////
LL gcd(LL a, LL b) {
	return (b > 0) ? gcd(b, a % b) : a;
}

void solve() {
	LL A, B;
	cin >> A >> B;
	vector<LL> C;
	set<LL> ans;

	for (int i = 2; i <= 1000000; ++i) {
		if ((A % i) == 0 && (B % i) == 0) {
			A /= i;
			B /= i;
			C.push_back(i);
			ans.insert(i);
		}
		while ((A % i) == 0 && (B % i) == 0) {
			A /= i;
			B /= i;
		}
	}
	
	
	LL res = gcd(A, B);
	if (res != 1) {
		C.push_back(res);
		ans.insert(res);
	}
	
	
	cout << ans.size()+1 << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int n, m; cin >> n >> m;

    if(n == m){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#6
#入力
N=int(input())

#処理
import math as m
t=0
for i in range(m.ceil(N/4),m.floor(N*3/4)+1):
    #print(i)
    if 4*i==N:
        continue
    for j in range(m.ceil(N*i/(4*i-N)),m.floor(2*N*i/(4*i-N))+1):
        #print(j)
        if 4*i*j-N*i-N*j==0:
            continue
        k=int((N*i*j)/(4*i*j-N*i-N*j))
        #print(k)
        if 4*i*j*k==N*(i*j+i*k+j*k):
            h=i
            n=j
            t=1
            break
    if t==1:
        break

print(h,n,k)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, k; cin >> n >> k;
    bitset<10> bad;
    for (int i = 0; i < k; i++) {
        int x; cin >> x;
        bad[x] = 1;
    }
    while (true) {
        int y = n;
        bool ok = true;
        while (y > 0) {
            if (bad[y % 10]) {
                ok = false;
            }
            y /= 10;
        }
        if (ok) {
            cout << n << "\n";
            return 0;
        }
        n++;
    }
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

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

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

  int N;
  cin >> N;

  double ans;
  if(N%2==1){
    ans = double(N+1)/double(2*N);
  }else{
    ans = 0.5;
  }

  std::cout<<std::fixed<<std::setprecision(10);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);
#define int long long int
using namespace std;
const int MAXN = 100, MOD = 1e9 + 7;
int n, k, base[MAXN][MAXN];
struct matrix
{
     int n, m;
     int mx[MAXN][MAXN];
     matrix(int n = 0, int m = 0)  : n(n), m(m)
     {
          memset(mx, 0, sizeof(mx));
     }
     matrix operator * (matrix a)  const
     {
          matrix ans(n, a.m);
          for(int i = 0; i < n; i++)
               for(int j = 0; j < a.m; j++)
                    for(int k = 0; k < m; k++)
                    {
                         ans.mx[i][j] += mx[i][k] * a.mx[k][j];
                         ans.mx[i][j] %= MOD;
                    }     
          return ans;
     }
};
main()
{
     fastio;
     cin >> n >> k;
     for(int i = 0; i < n; i++)
          for(int j = 0; j < n; j++)
               cin >> base[i][j];
     matrix b(n, n);
     for(int i = 0; i < n; i++){
          for(int j = 0; j < n; j++){
               b.mx[i][j] = base[i][j];
          }
     }
     matrix ans(n, n);
     for(int i = 0; i < n; i++){
          ans.mx[i][i] = 1;
     }
     for(int i = 62; i >= 0; i--){
          ans = ans * ans;
          if(k & 1LL << i) ans = ans*b; 
     }
     int resp = 0;
     for(int i = 0; i < n; i++){
          for(int j = 0; j < n; j++){
               ans.mx[i][j] %= MOD;
               resp += ans.mx[i][j];
               resp %= MOD;
          }
     }
     cout << resp << endl;
}

Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) ((x).begin()),((x).end())
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimization ("unroll-loops")
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using pii = pair<int, int>;
using ppp = pair<int , pii>;
int valid = 0;
string str;
int orig[30303];
int32_t main()
{
	int n;
	cin >> n;
	cin >> str;
	for (int i = 0; i < n; i++)
	{
		orig[i] = str[i]-'0';
	}
	for (int i = 0; i < 1000; i++)
	{
		int a = i/100;
		int b = (i/10)%10;
		int c = i%10;
		int ck = 0;
		for (int pos = 0; pos < n; pos++)
		{
			if (ck == 0 && (orig[pos] == a))
				ck = 1;
			else if (ck == 1 && (orig[pos] == b))
				ck = 2;
			else if (ck == 2 && (orig[pos] == c))
				ck = 3;
			else continue;
		}
		if (ck == 3) valid++;
	}
	cout << valid << '\n';
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;


int main() {
	
	int a, b;
	cin >> a >> b;
	if (a > 8 || b > 8) cout << ":(" << endl;
	else cout << "Yay!" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTPAIR(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define PRINTSET(x) for (auto it = x.begin(); it != x.end(); it++) { std::cout << *it << ' '; } std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;
using namespace std;


int main()
{
	io;
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);  
    #endif

    int n,x;
    cin >> n;
    vector<int> occ(n+1);
    for (int i = 0; i < n- 1; ++i ){
        cin >> x;
        occ[x-1]++;
    }
    for (int i = 0; i < n; ++i) {
        cout << occ[i] << '\n';
    }

    #ifndef ONLINE_JUDGE   
    //std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


Measured memory_bytes: 3992
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
list<long long int> Prime(int M) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= M; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

long long int N, M, K, Q, W, H;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	cin >> N >> K;
	ans = K;
	for (int i = 0; i < N - 1; i++)ans *= K - 1;
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

llint solve(vllint a) {
	if (a.size() == 0)return 0;
	int mn = 200001;
	int mni;
	rep(i, a.size()) {
		if (mn > a[i]) {
			mn = a[i];
			mni = i;
		}
	}
	vllint b, c;
	rep(j, mni) {
		b.push_back(a[j]);
	}
	for (int j = mni + 1;j < a.size();j++) {
		c.push_back(a[j]);
	}
	return mn*(a.size() - mni)*(mni + 1) + solve(b) + solve(c);
}

int main() {
	int x, y;
	cin >> x >> y;
	if (0 <= x) {
		if (0 < y) {
			if (x < y) {
				cout << y - x << endl;
			}
			else {
				cout << x - y + 2 << endl;
			}
		}
		else {
			cout << 1 + abs(abs(y) - x) << endl;
		}
	}
	else {
		if (0 < y) {
			cout << min(y - x, abs(abs(x) - y) + 1) << endl;
		}
		else {
			if (x < y) {
				cout << y - x << endl;
			}
			else {
				cout << x - y + 2 << endl;
			}
		}
	}
	return 0;
}

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  string S; cin >> S;
  string ans = S;
  if(S.size() == 1){
    if(S[0] == 's'){
      ans += "es";
    } else { 
      ans += "s";
    }
  } else {
    if(S[S.size()-1] == 's'){
      ans += "es";
    } else {
      ans += "s";
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3652
use std::collections::BTreeSet;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let mut set = BTreeSet::new();
    for _ in 0..3 {
        let a: usize = sc.read();
        set.insert(a);
    }
    if set.len() == 2 {
        println!("Yes");
    } else {
        println!("No");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352