akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define MAX_LENGTH 2000001

int n, A[MAX_LENGTH], B[MAX_LENGTH], C[10001];

void CountingSort(int k){
    for (int ix = 0; ix < k; ix++)
        C[ix] = 0;
    for (int jx = 0; jx < n; jx++)
        C[A[jx]]++;
    for (int ix = 0; ix < k; ix++)
        C[ix+1] += C[ix];
    for (int jx = n-1 ; jx >= 0; jx--){
        B[C[A[jx]]-1] = A[jx];
        C[A[jx]]--;
    }
}
          
int main(){
    int k = -1;
    scanf("%d\n",&n);
    for (int ix = 0; ix < n; ix++){
        scanf("%d",&A[ix]);
        if ( k < A[ix]) k = A[ix];
    }
    CountingSort(k);
    for (int ix = 0; ix < n; ix++){
        if (ix != n-1) printf("%d ",B[ix]);
        else printf("%d\n",B[ix]);
    }    
    return 0;
}


Measured memory_bytes: 17324
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    vector<int> a(n);
    rep(i,n-1) cin >> a[i];
    ans += a[0];
    rep(i,n-1){
        ans += min(a[i],a[i+1]);
    }
    ans += a[n-2];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

int main() {
  string s;
  cin >> s;
  long long k;
  cin >> k;
  long long n = s.size();
  bool allSame = true;
  int start = 0;
  vector<int> v; 
  for(int i=0;i<n-1;i++) {
    if(s[i] != s[i+1]) {
      allSame = false;
      v.emplace_back(i+1-start);
      start = i + 1;
    }
  }
  v.emplace_back(n - start);
  long long ans = 0;
  if(s[0] == s[n-1]) {
    if(allSame) ans = n * k / 2;
    else {
      rep(i, v.size()) {
        if(i == 0 || i == v.size() - 1) continue;
        else ans += v[i] / 2;
      }
      ans *= k;
      ans += (v.front() + v.back()) / 2 * (k - 1);
      ans += v.front() / 2 + v.back() / 2;
    }
  }
  else {
    rep(i, v.size()) ans += v[i] / 2;
    ans *= k;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
mod = 10**9+7
n = int(input())
inf = 10**20
fish = {}
rish = {}
att = 0
raw = []
raz = []
def lon(a,b,p):
  return p*10**40 + a*10**20 + b
def rev(z):
  p,a,b = z//(10**40),(z//(10**20))%(10**20),z%(10**20)
  return lon(b,a,1-p)
for _ in range(n):
  a,b = map(int,input().split())
  r = 1
  if a*b == 0:
    if a == b == 0:
      att += 1
    elif a == 0:
      raw.append(lon(0,1,1))
      raz.append(lon(1,0,0))
      fish[lon(0,1,1)] = [0,0]
      fish[lon(1,0,0)] = [0,0]
    else:
      raw.append(lon(1,0,0))
      raz.append(lon(0,1,1))
      fish[lon(1,0,0)] = [0,0]
      fish[lon(0,1,1)] = [0,0]
    continue
  if a*b < 0:
    r = 0
  a = abs(a)
  b = abs(b)
  big = int(a)
  sml = int(b)
  while sml != 0:
    big,sml = sml,big%sml
  a //= big
  b //= big
  raw.append(lon(a,b,r))
  raz.append(lon(b,a,1-r))
  fish[lon(a,b,r)] = [0,0]
  fish[lon(b,a,1-r)] = [0,0]
for x in raw:
  fish[x][0] += 1
for x in raz:
  fish[x][1] += 1
double = [1]
for _ in range(3*10**5):
  double.append(double[-1]*2%mod)
ans = 1
#print(fish)
for x in fish:
  re = rev(x)
  #print(x,fish[x][0],fish[x][1])
  #print(re)
  ans *= double[fish[x][0]] + double[fish[x][1]] - 1
  ans %= mod
  fish[x] = [0,0]
  fish[re] = [0,0]
ans -= 1
ans += att
ans %= mod
print(ans)

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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



void solve(long long N, std::vector<long long> a) {
    long long x = 0;
    for( auto i : a ){
        x ^= i;
    }
    for( auto j : a ){
        cout << (j^x) << " ";
    }
    cout << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(a));
  return 0;
}


Measured memory_bytes: 4840
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let (a,b,c) = {
        let t = read_vec::<i64>();
        (t[0],t[1],t[2])
    };
    let ans = if a == b {
        c
    } else if a == c {
        b
    } else {
        a
    };
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

int main()
{
  string S, T;
  ll temp,ans;
  cin >> S >> T;
  ans = T.size();

  rep(i,(S.size()-T.size()+1))
  {
    temp = 0;
    rep(j,T.size())
    {
      if (T[j]!=S[j+i])
      {
        temp++;
      }
    }
    ans = min(ans, temp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600
from itertools import product as prd

n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]


c = n - m + 1
ans = [list(map(lambda l: l[j:j+m], a[i:i+m])) == b for i, j in prd(range(c), range(c))]
print("Yes" if any(ans) else "No")


Measured memory_bytes: 3064
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;


// ここからコード

// 頂点１からの距離を記録
int v[25];

// 辺の長さ
int edge[25][25];

int N;
int ans;

// 出力用のベクター
vector<int> output;

// DFS
int dfs(int crt){
    // 子がないノードを判別するためのflag
    int flag = 1;
    for (int i = 1; i <= N; i++){
        if (edge[crt][i] && v[i] == -1){
            flag = 0;
            v[i] = v[crt] + edge[crt][i];
            ans += edge[crt][i] * 2;
            if (dfs(i)){ 
                ans -= edge[crt][i] * 2;
                v[i] = -1;
            }
        }
    }
    // ここでflag = 1がreturnされていれば子がない
    return flag;
}


int main(){
    cin.tie(0);
    
    while (1){
        // init
        memset(v, -1, sizeof(v));
        memset(edge, 0, sizeof(edge));
        ans = 0;

        // input
        cin >> N;
        if (N == 0) break;
        for (int i = 0; i < N-1; i++){
            int a, b, t;
            cin >> a >> b >> t;
            edge[a][b] = t;
            edge[b][a] = t;
        }

        // dfs
        v[1] = 0;
        dfs(1);

        // calc ans
        int ma = 0;
        for (int i = 1; i <= N; i++){
            ma = max(v[i], ma);
        }
        ans -= ma;
        output.push_back(ans);
    }

    //output
    for (int i = 0; i < output.size(); i++){
        cout << output[i] <<endl;
    }
    return 0;
} 



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

# import numpy as np

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

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


# ===CODE===

def main():
    n = ni()
    a = [na() for _ in range(n)]

    dp = [[0 for _ in range(3)] for __ in range(n + 1)]
    dp[0] = 0, 0, 0

    for i in range(n):
        for j in range(3):
            for k in range(1, 3):
                idx = (j + k) % 3
                dp[i + 1][idx] = max(dp[i + 1][idx], dp[i][j] + a[i][idx])

    print(max(dp[n]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 105060
class Factorial():
    def __init__(self,n,mod):
        self.mod = mod
        self.factorial = [0 for _ in range(n+1)]
        self.inv = [0 for _ in range(n+1)]
        self.factorial[0] = 1
        self.inv[0] = 1
        for i in range(n):
            self.factorial[i+1] = self.factorial[i]*(i+1)%mod
        self.inv[n] = pow(self.factorial[n],mod-2,mod)
        for i in range(n)[::-1]:
            self.inv[i] = self.inv[i+1]*(i+1)%mod
    def comb(self,m,k): #組み合わせ 0<=k<=m<=n 重複組み合わせはcomb(m+k-1,k)
        return self.factorial[m]*self.inv[k]*self.inv[m-k]%self.mod

from collections import deque

MOD = 1000000007

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

F = Factorial(N*M,MOD)

print(F.comb(N*M-2,K-2)*(N+M)*N*M*(N*M-1)//6%MOD)

Measured memory_bytes: 54096
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using llGraph = vector<vl>;
using vb = vector<bool>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

template<typename T>
bool CompareBySecond(pair<T, T> a, pair<T, T> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

template<typename T>
bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
  if (a.first * b.first < 0) {
    return a.first < b.first;
  }
  if (a.first == 0) {
    if (a.second >= 0) {
      return true;
    }
    return a.first < b.first;
  }
  if (b.first == 0) {
    if (b.second >= 0) {
      return false;
    }
    return a.first < b.first;
  }
  return a.second * b.first < a.first * b.second;
}

template<typename T>
T GCD(T a, T b) {
  T c = a % b;
  while (c != 0) { a = b; b = c; c = a % b; }
  return b;
}


/* -------- <templates end> -------- */


struct gluttony {
  ll score, time, food;
  bool operator<(const gluttony &another) const {
    return score < another.score;
  }
};

void solve() {
  int n; ll k; cin >> n >> k;
  vl time(n), food(n);
  rep(i,n) cin >> time[i];
  rep(i,n) cin >> food[i];
  sort(RALL(time));
  sort(ALL(food));

  vector<gluttony> G(n);
  rep(i,n) {
    G[i].time = time[i];
    G[i].food = food[i];
    G[i].score = time[i] * food[i];
  }
  sort(RALL(G));

  ll good = 1e12+1, bad = -1;

  while (good - bad > 1) {
    ll score = (good + bad) / 2;
    ll cnt = 0;
    rep(i,n) {
      if (G[i].score <= score) break;
      ll tmp = score / G[i].food;
      cnt += G[i].time - tmp;
    }
    if (cnt <= k) good = score;
    else bad = score;
  }

  cout << good << endl;
}


/* -------- <programs end> -------- */


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


Measured memory_bytes: 8064
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<iterator>
#include<math.h>
#include<cstring>
using namespace std;
void lets_play()

{
   int n,m;
   cin>>n>>m;

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








int main()
{
        lets_play();

}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+23;

int main(){
	int n;
	cin>>n;
	vector<int> a(n+5);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	ll now=1000;
	for(int i=1,j;i<=n;i++){
		j=i;
		while(a[j]<=a[j+1]&&j<=n) j++;
		// printf("%d %d\n",i,j);
		if(a[j]>a[i]){
			now=(now%a[i])+now/a[i]*a[j];
			i=j;
		}
	}
	cout<<now;
}

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

int main(void){
    int N;
    string ans = "ABC";
    scanf("%d", &N);
    
    // implements
    if(N >= 1000){
       ans = "ABD";
    }
    
    // output
    printf("%s\n", ans.c_str());
}

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

int main() {

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    vector<long long> arr(3);
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr.begin(), arr.end());
    long long ans = arr[0] * arr[1];

    if(arr[2] & 1) //odd
    	cout<<ans;
    else 
    	cout<<0;
	return 0;		
}


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

using namespace std;

#define LL long long
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

LL fact[2000002];
const LL mod=1e9+7;

LL BigMod(LL val,LL pow)
{
    LL res = 1;
    val = val % mod;
    while(pow > 0)
    {
        if(pow & 1)res = (res*val) % mod;
        pow = pow >> 1;
        val = (val*val) % mod;
    }
    return res;
}

LL nCr(LL n,LL r)
{
    if(n < r)return 0;
    return fact[n]*BigMod(fact[r]*fact[n-r],mod-2)%mod;
}

int main()
{
    FAST();
    string s;
    fact[0]=1;
    LL i,k,l,ans=0;
    cin >> k >> s;
    l=(LL)s.size();
    for(i=1;i<=k+l;i++)fact[i]=(fact[i-1]*i)%mod;
    for(i=0;i<=k;i++)
    {
        ans+=nCr(k+l-i-1,l-1)*(BigMod(26,i)*BigMod(25,k-i)%mod)%mod;
        if(ans >= mod)ans-=mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 19832
#include<bits/stdc++.h>
#include<string>
#include<cctype> 
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
  long long n;
  cin >> n; 
  long long a[n];
  long long i,j;
  for(i=0;i<n;i++){  
    cin >> a[i];
  }  
  if(n==1){
    cout<< a[0] << endl;
  }else if(n%2==1){
    for(j=n-1;j>=0;j-=2){
      cout << a[j] << ' ';
    }
    for(i=1;i<n-3;i+=2){
      cout << a[i] << ' ';
    }
    cout << a[n-2] << endl;  
  }else{
    for(j=n-1;j>0;j-=2){
      cout << a[j] << ' ';
    }
    for(i=0;i<n-3;i+=2){
      cout << a[i] <<' ';
    }
    cout << a[n-2] << endl;
  }
    
  return 0;
} 


Measured memory_bytes: 3712
#include <algorithm>
#include <iostream>

int main(int argc, char *argv[]) {
  int n, q;
  std::cin >> n;
  long long a[1001];
  for (int i = 0; i < n; ++i)
    std::cin >> a[i];
  std::cin >> q;
  for (int i = 0; i < q; ++i) {
    int b, e, t;
    std::cin >> b >> e >> t;
    std::swap_ranges(a + b, a + e, a + t);
  }
  for (int i = 0; i < n; ++i) {
    if(i>0)
      std::cout << " ";
    std::cout << a[i];
  }
  std::cout << std::endl;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo 1e18
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vs vector<string>



using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=1e2+10,mod=1e9+7;
ll n , m ;
Matrix G;
vll d,vis;
void bfs(int s){
    d.assign(n+1,oo);
    vis.assign(n+1,0);
    queue<int> q;
    q.push(s);
    d[s]=0;
    while(!q.empty()){
        auto p = q.front();
        q.pop();
        for(auto v:G[p]){
            if(!vis[v]){
                vis[v]=1;
                q.push(v);
                d[v]=p;
            }
        }
    }
}

int main ()
{
    FASTIO
    cin >> n >> m ;
    G.assign(n+1,vll());
    while(m--){
        ll u , v;
        cin >> u >> v;
        G[v].pb(u);
        G[u].pb(v);
    }
    bfs(1);
    vll ans;
    for(int i=2;i<=n;i++){
        if(d[i]!=oo)ans.pb(d[i]);
    }
    if(ans.si<n-1)return cout << "No" << endl,0;
    cout << "Yes" << endl;
    for(auto x:ans)cout << x << endl ;

    return 0;
}
/**

*/


Measured memory_bytes: 14508
def examA():
    X, A, B = LI()
    if (B-A)<=0:
        ans = "delicious"
    elif (B-A)<=X:
        ans = "safe"
    else:
        ans = "dangerous"
    print(ans)


import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 38256
#include <iostream>

int main(void) {
    int n;
    std::cin >> n;
    int a = 0, b = 0, c = 0, d = 0;
    std::string str;
    for (int i = 0; i < n; i++) {
        std::cin >> str;
        if (str == "AC") {
            a++;
        } else if (str == "WA") {
            b++;
        } else if (str == "TLE") {
            c++;
        } else {
            d++;
        }
    }
    std::cout << "AC x " << a << std::endl;
    std::cout << "WA x " << b << std::endl;
    std::cout << "TLE x " << c << std::endl;
    std::cout << "RE x " << d << std::endl;

    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;


int main() {
   int n,a,b;
   cin >> n >> a >> b;
   cout << min(n*a,b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include <algorithm>
#include<string>
using namespace std;

int main() {
        int N;
        long long int Y;

        cin >> N >> Y;

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

        cout << "-1 -1 -1"<< endl;
        return 0;
}


Measured memory_bytes: 256
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=5e6+10;
	ll fac[M],facinv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
	}
	
	const int N=1e6+10;
	int x[N];
	void main()
	{PRE();
		int n=qread(),K=qread();
		int now=1,mx=K;while(mx-1<n) mx*=K,now++;write(now);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"\n---------------------Zory-------------------\nTime: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 80256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

n = 60
cnt = [[0, 0] for _ in range(n)]

for x in A:
	x = "{:b}".format(x).zfill(n)
	for i in range(n):
		cnt[i][int(x[-(i+1)])] += 1

ans = 0

for i in range(n):
	bit_sum = ((cnt[i][0]*cnt[i][1])%mod) * pow(2, i, mod) % mod
	ans = (ans+bit_sum)%mod

print(ans)


Measured memory_bytes: 132368
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 500010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define ull unsigned long long
#define mp make_pair
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
int n, m;

int main() {
	io(); cin >> n >> m;
	if (n == m) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
import copy

N,M,Q =  map(int, input().split())
dataList = []

for i in range(Q) :
    a,b,c,d = map(int, input().split())
    dataList.append([a,b,c,d])
ans = 0
    
def dfs(A) :
    global ans
    if(len(A) == N+1) :
#         print(A)
        now = 0
        for i in range(Q):
            if(A[dataList[i][1]] - A[dataList[i][0]] == dataList[i][2]) :
                now += dataList[i][3]
        ans = max(ans,now)
        return 0

    A.append(A[-1])
    while(A[-1] <= M) :
        dfs(copy.copy(A))
        A[-1]+=1
        
        



dfs([1])
print(ans)

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


int main() {
  int N;
  cin >> N;
  int A[210];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int e=1;
  int res=0;
  while(e==1){
    for(int i=0;i<N;i++){
      if(A[i]%2==1){
        e=0;
      }
    }
    if(e==0){
      break;
    }
    res++;
    for(int i=0;i<N;i++){
      A[i]/=2;
    }
  }
  cout << res;
  
}


Measured memory_bytes: 256
let powers =
    let rec powers_sub b k =
        if k > 1000 then []
        else k :: powers_sub b (k * b)
    in
    let rec loop b =
        if b > 1000 then []
        else (powers_sub b (b * b)) @ loop (b + 1)
    in
    1 :: loop 2

let () =
    let x = read_int () in
    List.filter ((>=) x) powers
    |> List.fold_left max 1
    |> string_of_int
    |> print_endline


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200005;

int n;
string s;
int white[N], black[N];

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == '.') white[i]++;
        else black[i]++;
        if (i) {
            white[i] += white[i - 1];
            black[i] += black[i - 1];
        }
    }

    int ans = min(white[n - 1], black[n - 1]);
    for (int i = 0; i < n; i++) {
        int change = black[i] + white[n - 1] - white[i];
        ans = min(ans, change);
    }
    cout << ans << "\n";
    return 0;
}


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

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

    int N, M;
    cin >> N >> M;

    int front = M / 2;
    int back = M - front;

    int a = 1;
    int b = 1 + 2 * front;

    int c = b + 1;
    int d = c + 2 * back - 1;

    for(int i = 0; i < front; i++) {
        cout << a << " " << b << endl;
        a++;
        b--;
    }

    for(int i = 0; i < back; i++) {
        cout << c << " " << d << endl;
        c++;
        d--;
    }
}

Measured memory_bytes: 3616
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,*A = map(int, read().split())

    A.sort()
    table = [0] * (A[-1] + 1)
    n = len(table)

    for a in A:
        if table[a] > 1:
            continue

        if table[a] == 0:
            for i in range(2*a, n, a):
                table[i] = 2
        
        table[a] += 1

    ans = 0
    for a in A:
        if table[a] == 1:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32344
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n - h + 1) * (n - w + 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef long double ld;
ll mx=INT_MIN;
ll mn=INT_MAX;
ll MOD=1e9+7;
ll INF = 1e18;
const int maxs=2e5+10;
const int lg=22;

void code_idhr_h(){
    ll N; cin>>N;
    ll A[N+1]; int flg=0;  
    for(ll i=1; i<=N; i++){
        cin>>A[i];
        if(A[i]==0) flg=1;
    }
    if(flg){
        cout<<0;
        return;
    }
    ll ans=1;
    for(ll i=1; i<=N; i++){
        if(A[i]>(INF/ans)){
            flg=1;
            break;
        }
        ans*=A[i];
    }
    if(flg) cout<<"-1";
    else cout<<ans;
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        code_idhr_h();
    }
    return 0;
}

Measured memory_bytes: 4408
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (n, m) = read!(usize, usize);

    // ある1つのマスAに着目すると、そのマスが接している8つのマスのうち何個にカードが存在しているかによって、マスAのカードがひっくり返される回数が確定する
    // 例えば接しているマス8つともカードがある場合は、マスAは9回ひっくり返されるので、最終的にウラになる
    // このようにして、マスAが接しているマス8のうちカードがあるマスの個数をNとすると
    // Nが奇数のときマスAの最終状態はオモテ
    // Nが偶数のときマスAの最終状態はウラ
    // となる。
    // したがって今回求める値は、「周囲を偶数個のカードマスで囲まれているマスの個数」

    // n <= m としても一般性を失わない
    let (n, m) = if n <= m { (n, m) } else { (m, n) };

    if n == 1 && m == 1 {
        println!("1");
        return;
    }
    if n == 1 {
        println!("{}", m - 2);
        return;
    }
    if n == 2 {
        println!("0");
        return;
    }
    // n >= 3 のとき
    // 両端の行および列は必ず奇数個のカードマスに囲まれているのでオモテになる
    // したがって内部のみ考えればいいが、内部は絶対に8つのカードマスに囲まれているので、ウラになる
    println!("{}", (n - 2) * (m - 2));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

struct mint {
    const int mod = 1e9 + 7;
    long long x;
    
    mint (long long x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    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;
    }
};

long long mod_pow(long long x, long long n, long long mod = 1e9 + 7) {
    long long ans = 1;
    while(n > 0) {
        if ((n % 2) == 0) {
            x = (x * x) % mod;
            n >>= 1;
        }
        else {
            ans = (ans * x) % mod;
            n--;
        }
    }
    return ans;
}

mint combination(ll n, ll r) {
    mint bs = 1, bb = 1;
    rep(i, r) {
        bs *= n - i;
        bb *= i + 1;
    }
    return bs / bb;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, a, b;
    cin >> n >> a >> b;
    mint ans = mod_pow(2, n) - 1;
    ans -= combination(n, a);
    ans -= combination(n, b);
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ABC144_C
{
    class Program
    {
        static void Main(string[] args) {
            long n = long.Parse(Console.ReadLine());

            long intAns = -1;

            long ansRow = 0;
            long ansColumn = 0;

            for (int i = 1; i <= Math.Sqrt(n); i++) {
                if (n % i != 0) continue;

                long kariAns = 0;
                long kariRow = i - 1;
                long kariColumn = n / i - 1;

                kariAns = kariRow + kariColumn;

                if (kariAns < intAns || intAns == -1) {
                    intAns = kariAns;
                }
            }

            Console.WriteLine(intAns);
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int n;
    cin>>n;
	int a[n];
	map<int,int> mp;
	ll total=0;
	rep(i,0,n){
		cin>>a[i];
		mp[a[i]]++;
		total+=(mp[a[i]]-1);
	}
	rep(i,0,n){
		ll ans=total-(mp[a[i]]-1);
		cout<<ans<<endl;
	}
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 8320
#include <cstdio>
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b&&a!=c){
		puts("Yes");
		return 0;
	}
	if(a==c&&a!=b){
		puts("Yes");
		return 0;
	}
	if(b==c&&a!=b){
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

std::string s;
int main()
{
    bool ans = true;
    std::cin >> s;
    ans = (s.at(0) == 'A');
    if (ans) {

        int num = 0;
        for (int i = 2; i < s.length() - 1; i++) {
            if (s.at(i) == 'C') {
                num += 1;
                //        std::cout << i << "c num " << std::endl;
                if (num >= 2) {
                    ans = false;
                    break;
                }
                continue;
            }
            if (num >= 2 || std::isupper(s.at(i))) {
                ans = false;
                //       std::cout << " upper" << i << std::endl;
                break;
            }
            if (i == s.length() - 2 && num == 0) {
                ans = false;
                //      std::cout << " last" << std::endl;
                break;
            }
        }
        ans = (ans && !std::isupper(s.at(s.length() - 1)) ? true : false);
        ans = (ans && !std::isupper(s.at(1)) ? true : false);
    }
    std::cout << (ans ? "AC" : "WA") << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, q;
    cin >> n >> q;
    int h = n, w = n;
    ll res = (n - 2) * (n - 2);
    vector<int> r(n, n - 2), c(n, n - 2);
    while (q--) {
        int a, b;
        cin >> a >> b;
        if (a == 1) {
            if (b < w) {
                res -= h - 2;
                r[b] = 0;
                for (int i = b + 1; i < w; i++) {
                    r[i] = h - 2;
                }
                w = b;
            } else {
                res -= r[b];
                r[b] = 0;
            }
        } else {
            if (b < h) {
                res -= w - 2;
                c[b] = 0;
                for (int i = b + 1; i < h; i++) {
                    c[i] = w - 2;
                }
                h = b;
            } else {
                res -= c[b];
                c[b] = 0;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 4716
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int lli;
const lli mod = 998244353;
 

int main(){
	lli x;
	cin >> x;
	cout << x/500*1000 +(x%500)/5*5 << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_vec<T: FromStr>(n: usize) -> Vec<T> {
    return (0..n).map(|_| read()).collect();
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let ai: Vec<usize> = read_vec(m);

    let sum = ai.into_iter().sum();

    if n >= sum {
        println!("{}", n - sum);
    } else {
        println!("{}", -1);
    }    
}


Measured memory_bytes: 2164
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Guess The Number
            Console.WriteLine(CreateNumber());
        }

        static int CreateNumber()
        {
            var line = ReadLine();
            int N = line[0];
            int M = line[1];

            var number = new SortedDictionary<int, int>();

            for (int i = 0; i < M; i++)
            {
                line = ReadLine();
                int s = line[0];
                int c = line[1];

                if (N > 1 && s == 1 && c == 0)
                {
                    return -1;
                }

                if (number.ContainsKey(s))
                {
                    if (number[s] != c)
                    {
                        return -1;
                    }
                }
                else
                {
                    number.Add(s, c);
                }                
            }

            for(int i = 1; i <= N; i++)
            {
                if (!number.ContainsKey(i))
                {
                    if (i == 1 && N == 1)
                    {
                        number.Add(i, 0);
                    }
                    else if (i == 1)
                    {
                        number.Add(i, 1);
                    }
                    else
                    {
                        number.Add(i, 0);
                    }
                }
            }

            string ans = "";

            foreach(var n in number.Values)
            {
                ans += n;
            }

            return int.Parse(ans);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

#define int long long

#define rep(i,s,n) for(int i = (s);i<(n);i++)
#define repe(i,s,n) for(int i = (s);i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
const ll MOD=1000000007,INF=1e18;

int n,p,x,cnt0,cnt1;
int a[100010];

signed main(){
    cin>>n>>p;
    bool can=true;
    rep(i,0,n){
        cin>>x;
        if(x%2)can=false;
        
    }
    int ans;
    if(can)ans=(p==0?pow(2,n):0);
    else ans=pow(2,n-1);
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, A[212345];

int main() {

	cin >> N;
	rep(i, N)
		cin >> A[i];

	map<ll, ll> c;

	ll ans = 0;

	rep(i, N) {
		ans += c[i - A[i]];
		c[A[i] + i]++;
	}

	cout << ans << endl;

	return 0;
}


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

int main()
{
    int d;
    cin >> d;
    int c[26];
    for(int i = 0; i < 26; i++) cin >> c[i];
    int s[400][26];
    for(int i = 0; i < d; i++){
        for(int j = 0; j < 26; j++) cin >> s[i][j];
    }
    int last[26];
    for(int i = 0; i < 26; i++) last[i] = -1;
    for(int i = 0; i < d; i++){
        int l = 0;
        for(int j = 0; j < 26; j++){
            if(s[i][j] - (i - last[j]) * c[j] > s[i][l] - (i - last[l]) * c[l]) l = j;
        }
        last[l] = i;
        cout << l + 1 << endl;
    }
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define mk make_pair
#define endl '\n'

int main()
{
    IOS;
    int n,m;
    cin>>n>>m;
    vector<vector<int>> graph(n+1);
    for (int i = 0; i < m; i++)
    {
        int x,y;
        cin>>x>>y;
        graph[x].eb(y);
        graph[y].eb(x);

    }
    queue<int> q;
    q.push(1);
    vector<int> visited(n+1,0);
    vector<int> parent(n+1,0);
    parent[1]=1;
    visited[1]=1;
    while(!q.empty())
    {
        int temp=q.front();
        q.pop();
        for (auto &&i : graph[temp])
        {
            if(visited[i])
            {
                continue;
            }
            parent[i]=temp;
            visited[i]=1;
            q.push(i);
        }
    }
    bool flag=true;
    for (int i = 2; i < n+1; i++)
    {
        if(visited[i]==0)
        {
            flag=false;
        }
        /* code */
    }
    if(!flag)
    {
        cout<<"No";
        return 0;
    }
    cout<<"Yes"<<endl;
    for (int i = 2; i < n+1; i++)
    {
        cout<<parent[i]<<endl;
        /* code */
    }
    
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000


int main(){

	int H,W,N;
	cin>>H>>W>>N;
	
	vector<int> a(N);
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	
	vector<vector<int>> ans(H,vector<int>(W));
	
	int y = 0;
	int x = 0;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<a[i];j++){
			ans[y][x]=i+1;
			if(y%2==0){
				x++;
				if(x==W){
					x--;
					y++;
				}
			}
			else{
				x--;
				if(x==-1){
					x++;
					y++;
				}
			}
		}
	}
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(j!=0)cout<<' ';
			cout<<ans[i][j];
		}
		cout<<endl;
	}
	
    return 0;
}



Measured memory_bytes: 384
a,b,n = map(int,input().split())

if b > n:
    mod_ab = a%b
    #answer = 1/b (A*x - mod(x*mod(a,b),b)
    answer = (a*n)//b
else:
    x=b-1
    tmp_max=(a*x-(a*x)%b)
    answer=int(tmp_max/b)

print(answer)

Measured memory_bytes: 9160
n, m, l = (int(x) for x in input().split())
A = [[int(j) for j in input().split()] for i in range(n)]
B = [[int(j) for j in input().split()] for i in range(m)]
C = [[0 for j in range(l)] for i in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for i in range(n):
    for j in range(l):
        if j == (l - 1): print(C[i][j])
        else: print(C[i][j], end = " ")


Measured memory_bytes: 7056
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int ans = 0;
    if(((k % 2) == 0) || ((k % 5) == 0)) {
      ans = -1;
    } else {
      int t = (7 % k);
      if(t == 0) {
        ans = 1;
      } else {
        for(int i = 2; i <= k; i++) {
          t = ((10 * t + 7) % k);
          if(t == 0) {
            ans = i;
            break;
          }
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35792
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] c = new char[H][W];
		for(int i=0; i<H; i++)
			c[i] = sc.next().toCharArray();
	
		int ans = 0;
		
		for(int i=0; i<W-1; i++) {
			int[][] dp = new int[H+1][H+1];
			for(int j=0; j<H+1; j++)
				Arrays.fill(dp[j], Integer.MAX_VALUE);
			int[][] match = new int[H+1][H+1];
			
			dp[0][0] = 0;
			for(int j=0; j<=H; j++) {
				for(int k=0; k<=H; k++) {
					if(j<H) {
						if(k>0)
							match[j+1][k] = match[j][k-1] + (c[j][i]==c[k-1][i+1] ? 1 : 0);
						dp[j+1][k] = Math.min(dp[j+1][k], dp[j][k] + match[j+1][k]);
					}
					if(k<H) {
						if(j>0)
							match[j][k+1] = match[j-1][k] + (c[j-1][i]==c[k][i+1] ? 1 : 0);
						dp[j][k+1] = Math.min(dp[j][k+1], dp[j][k] + match[j][k+1]);
					}
				}
			}
			ans += dp[H][H];
		}
		
		System.out.println(ans);
		sc.close();
	}
}



Measured memory_bytes: 77724