akhauriyash/Code-Regression huggingface dataset:
k = int(input())

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


ans = 0
for i in range(1,k+1):
    for j in range(i,k+1):
        for h in range(j,k+1):
            if i == j and i == h:
                ans += gcd(i,j,h)
            elif (i == j and j !=h) or (j == h and h != i) or (i == h and h != j):
                ans += 3*gcd(i,j,h)
            else:
                ans += 6*gcd(i,j,h)


print(ans)



Measured memory_bytes: 9628
def main():
    N, P = map( int ,input().split())
    S = [ int(s) for s in list(input())][::-1]
    if P == 2 or P == 5:
        ans = 0
        for i in range(N):
            if S[i]%P == 0:
                ans += N-i
        print(ans)
        return
    L = [0]*P
    L[0] = 1
    t = 0
    s = 1
    for i in range(N):
        t = (S[i]*s+t)%P
        L[t] += 1
        s *= 10
        s %= P
    ans = 0
    for l in L:
        ans += l*(l-1)//2
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 6436
#include <bits/stdc++.h>
using namespace std;
int main()	{
	int n,m;
	cin>>n>>m;
	int ans=(n-1)*(m-1);
	if(ans<0)	{
		cout<<"0\n";
	}
	else	{
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int sum(vector<int> A){
    int s = 0;
    for(int x : A) s += x;
    return s;
}
 
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);
    int vote = sum(A) / (4 * M);
    if(sum(A) % (4 * M) != 0) vote ++;
    int count = 0;
    for(int x : A){
        if(x >= vote) count ++;
    }
    
    if(count < M) cout << "No" << endl;
    else cout << "Yes" << endl;
 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define long long int
int main()
{
    int n;
    cin>>n;
    vector<int> v;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
    }

    int sum=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            sum+=(v[i]*v[j]);
            //cout<<v[i]<<endl;
        }
    }
    cout<<sum<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(1100000);
vector<ll> ifac(1100000);

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

int main()
{
    ios::sync_with_stdio(false);
    ll X, Y;
    cin >> X >> Y;
    if ((X+Y)%3 != 0){
        cout << 0 << endl;
        return 0;
    } 
    ll m = (X+Y)/3;
    ll a = X - m;
    ll b = Y - m;
    if (a < 0 || b < 0){
        cout << 0 << endl;
        return 0;
    }

    //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<1100000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

    ll ans = 0;
    ans = comb(a+b,a) % M;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17408
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	ll N=in();
	if(N==1){
		out(1);
		return 0;
	}
	vector<pair<int,int>> P(N);
	REP(i,N){
		P[i].first=in();
		P[i].second=in();
	}
	
	map<pair<int,int>,int> M;
	REP(i,N){
		REP(j,N){
			if(i==j) continue;
			M[make_pair((P[i].first-P[j].first),(P[i].second-P[j].second))]++;
		}
	}
	priority_queue<ll> Q;
	for(auto& x:M) Q.push(x.second);

	out(N-Q.top());
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int x,y;cin>>x>>y;
    long long int v=x,ans=1;
    while(v<=y)
    {
        v=2*v;
        ans++;
    }
    ans--;
    if(ans==0)ans++;
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3612
# equeue

from collections import deque
import heapq


def main():
    N, K = map(int, input().split())
    V = list(map(int, input().split()))
    res = 0
    for pull in range(K+1):
        push = K - pull
        if push < 0 or push > N:
            continue
        for left_push in range(push+1):
            tmp_que = deque(V)
            tmp_heap = []
            heapq.heapify(tmp_heap)
            right_push = push - left_push
            for _ in range(left_push):
                heapq.heappush(tmp_heap, tmp_que.popleft())
            for _ in range(right_push):
                heapq.heappush(tmp_heap, tmp_que.pop())

            tmp_res = sum(tmp_que)
            for i in range(min(push, pull)):
                x = heapq.heappop(tmp_heap)
                if x >= 0:
                    heapq.heappush(tmp_heap,x)
                    break


            res = max(res, sum(tmp_heap))
    print(res)
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	string a,b;
	cin>>a>>b;
	if(a.length()>b.length())
	 cout<<"GREATER";
	else
    {
         if(b.length()>a.length())
          cout<<"LESS";
         else
         {
            int i,c=0;
            for(i=0;i<a.length();i++)
            {
                if(a[i]>b[i])
                {
                    c=1;
                    break;
                }
                if(b[i]>a[i])
                {
                     c=2;
                     break;
                }
            }
             if(c==0)
              cout<<"EQUAL";
            else
            {
                 if(c==1)
                  cout<<"GREATER";
                 else
                  cout<<"LESS";
            }
         }
    }
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a[55],b[55];
int n,m;
int work(int i,int j){
	for(int k = 0;k<m;k++){
		for(int l = 0;l<m;l++){
			if(a[i+k][j+l]!=b[k][l]) return 0;
		}
	}
	return 1;
}
int main(){
	cin>>n>>m;
	for(int i = 0;i<n;i++) cin >> a[i];
	for(int i = 0;i<m;i++) cin >> b[i];
	for(int i = 0;i+m<=n;i++)
	for(int j = 0;j+m<=n;j++)
	if(work(i,j)){cout<<"Yes"<<endl;return 0;}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	int x[100]={0},y[100]={0};
	int n;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x[i]);
	} 
	for(int i=0;i<n;i++)
	{
		scanf("%d",&y[i]);
	}
	double dis1=0,dis2=0,dis3=0;
	double sum=0.000000,sum1=0.000000;
	for(int i=0;i<n;i++)
	{
		dis1=dis1+fabs(x[i]-y[i]);
		sum=sum+pow(fabs(x[i]-y[i]),2);
		dis2=sqrt(sum);
		sum1=sum1+pow(fabs(x[i]-y[i]),3);
		dis3=pow(sum1,1.0/3.0);
	}	
	double max=0;
	double abs[100];
	for(int i=0;i<n;i++)
	{
		abs[i]=fabs(x[i]-y[i]);
		if(abs[i]>max){max=abs[i];}
	}
	printf("%lf\n",dis1);
	printf("%lf\n",dis2);
	printf("%lf\n",dis3);
	printf("%lf\n",max);
}

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

int main()
{
    int k = 38;
    int n = (k - 1) * (k - 1) + k;
    cout << n << " " << k << endl;
    for(int i = 0; i < k; i++){
        cout << 1;
        for(int j = 0; j < k - 1; j++) cout << " " << i * (k - 1) + j + 2;
        cout << endl;
    }
    int p[50];
    for(int i = 0; i < k - 1; i++) p[i] = 0;
    for(int i = 0; i < k - 1; i++){
        for(int j = 0; j < k - 1; j++){
            cout << i + 2;
            for(int l = 0; l < k - 1; l++) cout << " " << (l + 1) * (k - 1) + ((j + p[l]) % (k - 1)) + 2;
            cout << endl;
        }
        for(int j = 0; j < k - 1; j++) p[j] = (p[j] + j) % (k - 1);
    }
}


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

int main() {
  int i = 0;
  while(true) {
    i++;
    int a;
    cin >> a;
    if(a != 0) {
      cout << "Case " << i << ": " << a << endl;
    }else{
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3052
T=int(input())
for t in range(T):
    N,A,B,C,D=map(int,input().split())
    memo=dict()

    def dist(n):
        if n==0:
            return 0
        if n==1:
            return D
        if n in memo:
            return memo[n]

        ret = min(
            D*n,
            D*abs(n-(n//5)*5)+C+dist(n//5),
            D*abs(n-(n+4)//5*5)+C+dist((n+4)//5),
            D*abs(n-n//3*3)+B+dist(n//3),
            D*abs(n-(n+2)//3*3)+B+dist((n+2)//3),
            D*abs(n-n//2*2)+A+dist(n//2),
            D*abs(n-(n+1)//2*2)+A+dist((n+1)//2)
        )
        memo[n]=ret
        return ret
    print(dist(N)) 

Measured memory_bytes: 10856
function main() {
  var N = input[0];
  var A = input[1].split(' ').map(function (x) {
    return parseInt(x, 10);
  });
  var v;
  for (var i = 0; i < N; i++) {
    v = A[i];
    for (var j = i - 1; j >= 0; j--) {
      if (A[j] > v) {
        A[j + 1] = A[j];
      } else {
        break;
      }
    }
    A[j + 1] = v;
    console.log(A.join(' '));
  }
}

var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  input.pop();
  main();
});

Measured memory_bytes: 16732
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int waru2(int num, int count) {
    if (num == 0) {
        return count;
    } else {
        if (num % 2 == 0) {
            count++;
            waru2(num/2, count);
        } else {
            return count;
        }
    }
}
int main() {
    int N, res, count;
    cin >> N ;
    count = res = 0;
    for (int i = N; i >= 1; i--) {
        int tmp = 0;
        tmp = waru2(i,0);
        if (tmp > count) {
            res = i;
            count = tmp;
        }
    }
    if (N == 1) {
        res = 1;
    }

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    '''ユークリッド互除法を使った最大公約数の求め方'''
    while b != 0:
        a, b = b, a % b
    return(a)


def lcm(a, b):
    '''最小公倍数の求め方'''
    return a * b // gcd(a, b)


A, B, C, D = list(map(int, input().split()))

lcmCD = lcm(C, D)

divB = (B // C) + (B // D) - (B // lcmCD)
divA_1 = ((A - 1) // C) + ((A - 1) // D) - ((A - 1) // lcmCD)
print((B - A) - (divB - divA_1) + 1)


Measured memory_bytes: 3064
"use strict";
function calc(n, N) {
    const qt = Math.floor(N / n);
    return (Math.floor((n + qt * n) * qt / 2));
}
function main(input) {
    const N = parseInt(input.replace("\n", ""));
    console.log(calc(1, N) - calc(3, N) - calc(5, N) + calc(15, N));
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29688
n = int(input())
h = [int(i) for i in input().split()]
h[0] -= 1

def is_stairs(h):
	for i in range(n - 1):
		if h[i + 1] > h[i]:
			h[i + 1] -= 1
		elif h[i + 1] < h[i]:
			return False
	return True
	
print('Yes' if is_stairs(h) else 'No')

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

#define ll long long
#define F first
#define S second

const int mod = 1000000007;
const int M = 100005;

int main() {
	int T = 1;
	// cin>>T;
	while(T--)
	{
		int n;	cin>>n;
	
		vector<int> A(n);
		vector<int> B(n);
		vector<int> C(n);
		
		for(int i=0; i<n; i++)	cin>>A[i]>>B[i]>>C[i];
		
		vector<vector<int> > dp(3, vector<int> (n));
		
		dp[0][0] = A[0];
		dp[1][0] = B[0];
		dp[2][0] = C[0];
		
		for(int i=1; i<n; i++)
		{
			dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + A[i];
			dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + B[i];
			dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + C[i];
		}
		
		cout<<max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1]);
	}
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,m;cin>>n>>m;
    map<int,int> mp;
    vector<bool> AC(n,false);
    ll res1=0,res2=0;
    rep(i,m){
        int p;string s;cin>>p>>s;
        p--;
        if(s=="AC"){
            AC[p]=true;
        }else{
            if(AC[p])continue;
            mp[p]++;
        }
    }
    rep(i,n){
        if(AC[i]){
            res1++;
            res2+=mp[i];
        }
    }
    cout<<res1<<" "<<res2<<endl;
}

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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF (1<<28)
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define floot10 cout<<fixed<<setprecision(10);
#define int long long

typedef struct{
	int num;
	int right;
	int left;
	void dosetss(){
		num=-1;
		right=-1;
		left=-1;
	};
} nod2;

nod2 t[500000];
int used=1;
void Preorder(int now){
	cout<<" "<<t[now].num;
	if(t[now].left!=-1)Preorder(t[now].left);
	if(t[now].right!=-1)Preorder(t[now].right);
	return;
}
void Inorder(int now){
	if(t[now].left!=-1)Inorder(t[now].left);
	cout<<" "<<t[now].num;
	if(t[now].right!=-1)Inorder(t[now].right);
	return;
}

void insert(int now,int num){
	if(t[now].num==-1) t[now].num=num;
	else{
		if(t[now].num<num){
			if(t[now].right==-1){
				t[now].right=used;
				t[used].dosetss();
				used++;
			}
			insert(t[now].right,num);
		}
		else{
			if(t[now].left==-1){
				t[now].left=used;
				t[used].dosetss();
				used++;
			}
			insert(t[now].left,num);
		}
	}
	return;
}

string find(int now,int num){
	if(now==-1) return "no";
	if(t[now].num==num) return "yes";
	else{
		if(t[now].num>num) return find(t[now].left,num);
		else return find(t[now].right,num);
	}
}

signed main(){
	int n;
	cin>>n;
	t[0].dosetss();
	lp(i,n){
		string s;
		cin>>s;
		if(s[0]=='i'){
			int num;
			cin>>num;
			insert(0,num);
		}
		else if(s[0]=='f'){
			int num;
			cin>>num;
			cout<<find(0,num)<<endl;
		}
		else{
			Inorder(0);
			cout<<endl;
			Preorder(0);
			cout<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 12584
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{min, max};

fn main() {
    input!{
        n: i64,
        a: i64,
        b: i64
    }
    println!("{} {}", min(a, b), max(0, a + b - n));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
    fast;
    string s;
    cin>>s;
    lli i,count=0;;
    fr(i,s.length())
    {
        if(s[i]=='?')
            s[i]='D';
    }
    cout<<s;
    /*fr(i,s.length()-1)
    {
        if(s[i]=='P'&&s[i+1]=='D')
            count++;
        if(s[i]=='D')
            count++;
    }
    cout<<count;*/
    
    return 0;
}

Measured memory_bytes: 3784
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
    int w,n,i,box;
    int a[31],b[31],num[31];
    scanf("%d%d",&w,&n);
    for(i=1;i<=w;i++)
        num[i]=i;
    for(i=1;i<=n;i++)
    {
        scanf("%d,%d",&a[i],&b[i]);
        box=num[a[i]];
        num[a[i]]=num[b[i]];
        num[b[i]]=box;
    }
    for(i=1;i<=w;i++)
        printf("%d\n",num[i]);
    return 0;
}

Measured memory_bytes: 596
a = input()
b = input()
c = input()
al, bl, cl = [], [], []
for i in range(len(a)):
	al.append(a[i])

for i in range(len(b)):
	bl.append(b[i])

for i in range(len(c)):
	cl.append(c[i])

hand = 'a'
while True:
	if hand == 'a':
		if len(al) == 0:
			print("A")
			break
		cast = al[0]
		al.pop(0)
	elif hand == 'b':
		if len(bl) == 0:
			print("B")
			break
		cast = bl[0]
		bl.pop(0)
	elif hand == "c":
		if len(cl) == 0:
			print("C")
			break
		cast = cl[0]
		cl.pop(0)
	hand = cast


Measured memory_bytes: 3064
object Main extends App {
  def buildChessboard(w: Int, h: Int): String = {
    val chess = "#." * (w + h);
    (0 until h).map(x => chess.slice(x, x + w)).mkString("\n")
  }

  scala.io.Source.stdin.getLines.toList.init
    .map(_.split(" ").map(_.toInt))
    .map(x => buildChessboard(x(1), x(0)))
    .map(x => println(x + "\n"))
}

Measured memory_bytes: 44940
#include <stdio.h>

int main(void)
{
	int n, c;
	int i;
	int sum, tmp;
	
	scanf("%d %d", &n, &c);
	
	for (i = sum = 0; i < c; i++){
		scanf(" %d", &tmp);
		sum += tmp;
	}
	
	if (sum <= n){
		puts("1");
	}
	else {
		printf("%d\n", ((sum % (n + 1)) == 0)? sum / (n + 1) : (sum / (n + 1)) + 1);
	}
	
	return (0);
}



Measured memory_bytes: 2052
s=input()
a = 0
b = 0
c = 0
for i in range(3):
    if s[i] == 'a':
        a = a + 1
    elif s[i] == 'b':
        b = b + 1
    elif s[i] == 'c':
        c = c + 1
if a == 1 and b == 1 and c == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  long long a = n;
  long long b = m;
  if (abs(n-m) <= 1){
  if (n == m) {
    for (int i = n; i > 1; i--) {
      a = a*(i-1)%1000000007;
    }
    cout << a*a%1000000007*2%1000000007 << endl;
  }
  else {
    for (int i = n; i > 1; i--) {
      a = a*(i-1)%1000000007;
    }
    for (int i = m; i > 1; i--) {
      b = b*(i-1)%1000000007;
    }
    cout << a*b%1000000007 << endl;
  }
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3604
import sys
import collections
import itertools

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

N, K = nm()
V = nl()
assert len(V) == N
INF = 10 ** 9


def solve():
    ans = 0
    for i in range(K + 1):
        if i > N:
            break
        for j in range(K + 1 - i):
            if i + j > N:
                break
            v = V[:i] + V[N - j :]
            v.sort()
            s = sum(v)
            k = 0
            while k < K - i - j:
                if k >= len(v):
                    break
                if v[k] >= 0:
                    break
                s -= v[k]
                k += 1
            if ans < s:
                ans = s
                # print(f"> ans={ans} i={i}, j={j}, k={k}", file=sys.stderr)
    return ans


print(solve())


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int d = sc.nextInt();

		switch(d) {
		case 22:
			System.out.println("Christmas Eve Eve Eve");
			break;
		case 23:
			System.out.println("Christmas Eve Eve");
			break;
		case 24:
			System.out.println("Christmas Eve");
			break;
		case 25:
			System.out.println("Christmas");
			break;
		}

	}

}


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

using namespace std;
using namespace std::chrono;

#define rep(i,a,b) for(int i = a;i<(b);++i)
#define trav(a,v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

ll big = 1000000007ll;
ll big2 = 1000000009ll;
ll n,m,T,k,q,x;

ll F[200001] = {0};
vector<vector<ll> > C(200001, vector<ll>());

int main()
{
   // freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d,e;

    cin >> n >> m;
    for(ll c1 = 0; c1 < m; c1++){
        cin >> a >> b;
        a--;
        b--;
        C[a].push_back(b);
        C[b].push_back(a);
    }

    queue<ll> Q;
    Q.push(0);
    F[0] = 1;
    while(!Q.empty()){
        a = Q.front();
        Q.pop();
        for(ll c1 = 0; c1 < sz(C[a]); c1++){
            b = C[a][c1];
            if(F[b] == 0){
                F[b] = F[a]+1;
                Q.push(b);
            }
        }
    }

    if(F[n-1] == 3){
        cout << "POSSIBLE\n";
    }
    else{
        cout << "IMPOSSIBLE\n";
    }


    return 0;
}


Measured memory_bytes: 15208
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n;
  scanf("%d",&n);

  //偶数の個数
  int e=n/2;

  //奇数の個数
  int o=(n+1)/2;

  printf("%d\n",e*o);

  return 0;
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    char c;
    cin>>c;
    if(c>=65 && c<=90) cout<<"A\n";
    else cout<<"a\n";
 }

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int x, t;

int main() {
	cin >> x >> t;
	cout << max(0, x - t) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double btc2yen(double btc){
    double yen;
    yen = btc*380000;
    return yen;
}
int main(){
    double Otoshidama=0;
    int N;
    double X;
    int i;
    char U[4];
    scanf("%d", &N);
    for(i=0; i<N; i++){
        scanf("%lf %s", &X, U);
        if(U[0]=='J'){
            Otoshidama += X;
        }else{
            Otoshidama += btc2yen(X);
        }
    }
    printf("%lf", Otoshidama);
    return 0;
}

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

int main(){
    int n, q,flag=0,count=0,ans;
    int l,r;
    cin >> n >> q;
    char s[n-1];
    vector<int> cnt;
    scanf("%s", s);
    for ( int i = 0; i < n; i++ ){
        if(s[i] == 'A') flag = 1;
        else if(s[i] == 'C'){
            if(flag == 1) count++;
            flag = 0;
        }else flag = 0;
        cnt.push_back(count);
    }

    for( int i=0; i<q; i++ ){
        scanf("%d %d", &l, &r);
        ans = cnt[r-1] - cnt[l-1];
        cout << ans << endl;
    }
  
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
//#define mp make_pair
#define pb push_back
#define tp make_tuple
#define srt(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr(a) printf("%lld\n",a)
#define r0 return 0
using namespace std;

int main()
{
    ll n,m,i,j,k,t,x,y,d;

    cin>>n>>m>>d;

    k=0;

    for(i=n;i<=m;i++){

        if(i%d==0)k++;
    }

    cout<<k<<endl;

}



Measured memory_bytes: 3632
n = (int)(input())
alp = [10000 for i in range(0 , 90)] # initialize to infinity
for i in range(0 , n):
	s = input()
	now = [0 for i in range(29)]
	for i in s:
		now[ord(i)-ord('a')]+=1 # counting letters
	for i in range(0  ,27):
		alp[i]=min(alp[i], now[i])# consider minimum frequency of every letter occuring in the string
res = ""
for i in range(0 , 26):
	if alp[i]>=1:
		res = res+"".join(([(chr(i+ord('a')))]*alp[i])) # very complex
print(res)

Measured memory_bytes: 65480
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; j < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int A,B;
  cin >> A >> B;
  int ans = 0;
  if(A > B) {
    ans += A;
    A--;
  } else {
    ans += B;
    B--;
  }
  if(A > B) {
    ans += A;
    A--;
  } else {
    ans += B;
    B--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val n: Int = io.StdIn.readInt()
  val preorder: Array[Int] = io.StdIn.readLine().split(" ").map(_.toInt)
  val inorder: Vector[Int] = io.StdIn.readLine().split(" ").map(_.toInt).toVector
  val postorder = in2post(inorder)
  println(postorder.mkString(" "))

  def in2post(l: Vector[Int]): Vector[Int] =
    if (l.length < 2) l
    else {
      val p: Int = l.indices.minBy(i => preorder.indexOf(l(i)))
      val left: Vector[Int] = l.take(p)
      val right: Vector[Int] = l.drop(p+1)
      in2post(left) ++ in2post(right) ++ Vector(l(p))
    }
}


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

void Insertion_Sort(int A[], int n) {
  for (int i = 1; i < n; i++) {
    int v = A[i];
    int j = i - 1;

    while (j >= 0 && A[j] > v) {
      A[j+1] = A[j];
      j = j - 1;
      A[j+1] = v;
    }

    for (int k = 0; k < n; k++) {
    cout << A[k];
    if (k != n - 1) cout << " ";
    }

    cout << endl;
  }

}

int main() {
  int n, A[100];

  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];

  for (int i = 0; i < n; i++) {
    if (i != n -1) cout << A[i] << " ";
    else cout << A[i];
  }

  cout << endl;

  Insertion_Sort(A, n);

  return 0;
}



Measured memory_bytes: 3068
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    X, N = [int(x) for x in input().split()]
    P = [int(x) for x in input().split()]

    sa = float("inf")

    ans = 0
    for i in range(-100, 102):
        if i in P:
            continue

        satmp = sa
        sa = min(sa, abs(i - X))
        if sa != satmp:
            ans = i

    print(ans)

    
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
/*
 * test.cpp
 *
 *
 *      Author: Fireworks
 */

#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<cmath>
#include<bitset>
#include<set>
#include<iomanip>
#include<fstream>
#include<bitset>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<list>
#include<sstream>

using namespace std;

typedef pair<int,int> ii;
typedef pair<int,long long> il;
typedef pair<long long,long long> ll;
typedef pair<ll,int> lli;
typedef pair<long long,int> li;
typedef pair<double,double> dd;
typedef pair<ii,int> iii;
typedef pair<int,ii> iii2;
typedef pair<double,int> di;
typedef pair<ii,ii> iiii;
long long mod = 1000000007LL;
long long base = 37;
long long large = 1000000000000000000LL;


int r,c,n;

bool onBondary(int x,int y){
	return x==0||x==r||y==0||y==c;
}

int label(int x,int y){
	if(x==0) return y;
	if(y==c) return x+y;
	if(x==r) return r+c+c-y;
	return r+c+c+r-x;
}
int main(){
	cin>>r>>c>>n;
	vector<ii> e;
	for(int i=0;i<n;i++){
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		if(onBondary(x1,y1)&&(onBondary(x2,y2))){
			e.push_back(ii(label(x1,y1),i));
			e.push_back(ii(label(x2,y2),i));
		}
	}
	sort(e.begin(),e.end());
	vector<int> st;
	for(int i=0;i<(int)e.size();i++){
		int t = e[i].second;
		if(st.empty()||st.back()!=t){
			st.push_back(t);
		}else{
			st.pop_back();
		}
	}
	if(st.empty()){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}



	/*int totalcase;
	int testcase=0;
	cin>>totalcase;
	ofstream out;
	out.open("result.txt");

	while(totalcase--){
		testcase++;
		out<<"Case #"<<testcase<<": ";
		cout<<testcase<<": "<<endl;

		//GOGOGO


		//END
	}
	out.close();*/

	return 0;
}


Measured memory_bytes: 2672
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

ll MOD = 1000000007;

int main() {
	ll n;
	cin >> n;
	vector <ll> a(n);
	for (ll i = 0; i < n; i++)
		cin >> a[i];
	vector <ll> power_of_two(64);
	power_of_two[0] = 1;
	for (ll i = 1; i < 64; i++)
		power_of_two[i] = power_of_two[i - 1] * 2;
	vector <vector <bool>> bin(n);
	for (ll i = 0; i < n; i++)
		bin[i].resize(64);
	for (ll i = 0; i < n; i++) {
		ll x = a[i];
		ll cnt = 0;
		while (x > 0) {
			bin[i][cnt] = x % 2;
			cnt++;
			x /= 2;
		}
	}
	ll ans = 0;
	for (ll i = 0; i < 64; i++) {
		ll ans_for_bit = 0;
		vector <ll> zero(n), unit(n);
		zero[0] = 1 - bin[0][i];
		unit[0] = bin[0][i];
		for (ll j = 1; j < n; j++) {
			zero[j] = zero[j - 1] + (1 - bin[j][i]);
			unit[j] = unit[j - 1] + bin[j][i];
		}
		for (ll j = 1; j < n; j++)
			ans_for_bit = (ans_for_bit + bin[j][i] * zero[j - 1] + (1 - bin[j][i]) * unit[j - 1]) % MOD;
		ans = (ans + (ans_for_bit * (power_of_two[i] % MOD)) % MOD) % MOD;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 28424
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long N = inputLongArray[0];
            long L = inputLongArray[1];
            long[] delicious = new long[N];
            for (long j= 0; j < N; j++)
            {
                delicious[j] = L + (j+1) - 1;
            }

            long sum = delicious.Sum();
            if (L < 0)
            {
                for(long z = 0; z < N; z++)
                {
                    if (delicious[z] == 0)
                    {
                        Console.WriteLine(sum);
                        return;
                    }

                }
                    sum -= delicious[N-1];
            }
            else
            {
                sum -= delicious[0];
            }
            Console.WriteLine(sum);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


Measured memory_bytes: 13396
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    ll add = 0;
    for(int i = N-1; 0 <= i; i--){
        if( (A[i]+add)%B[i] != 0 ) add += B[i] - (A[i]+add)%B[i];
    }

    cout << add << endl;

    return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n; cin >> n;
    vector<int> memo{0, 0, 0};
    ll res = 1;
    rep(i, n){
        int a; cin >> a;
        int cnt = 0;
        rep(i, 3)if(memo[i] == a) cnt++;
        if(cnt == 0){res = 0; break;}
        res = res * cnt % MOD;
        rep(i, 3)if(memo[i] == a){memo[i]++; break;}
    }
    cout << res << ln; 
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[200050];
  long long int b=0;
   cin>>a;
  for(int i=0;i<strlen(a);i++)
    b+=a[i]-'0';
  if(b%9) cout<<"No";
  else cout<<"Yes";
     return 0;
} 

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#include <atcoder/math>
using namespace std;
using namespace atcoder;
int main(){
  int T;
  cin >> T;
  for (int i = 0; i < T; i++){
    int N, M, A, B;
    cin >> N >> M >> A >> B;
    cout << floor_sum(N, M, A, B) << endl;
  }
}

Measured memory_bytes: 3572
w, h, n = map(int,input().split())
a_1 = 0
a_2 = w
a_3 = 0
a_4 = h
for i in range(n):
    x, y, a = map(int,input().split())
    if a == 1:
        a_1 = max(a_1,x)
    elif a == 2:
        a_2 = min(a_2,x)
    elif a == 3:
        a_3 = max(a_3,y)
    else:
        a_4 = min(a_4,y)

if a_1 > a_2:
    print(0)
elif a_3 > a_4:
    print(0)
else:
    print((a_2-a_1)*(a_4-a_3))
    


Measured memory_bytes: 3064
def f( n ):
    if( n % 2 == 0 ): return n/2
    else: return 3*n + 1

s = int(input())
a = [s]

i = 1
flag = True

while flag:
    i += 1
    ins = f(a[-1])
    for j in range(len(a)):
        if a[j] == ins:
            flag = False
            break
    a.append(ins)

print( i )

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	ll ans=0LL;
	cin >>n;
	string c;
	V a(n);
	rep(i,n){
		cin>>a[i];
		ans^=a[i];
	}

	cout<<solve(!ans)<<endl;
}
/*
a b c =0
  b c d =0
    c d e =0
      d e a
        e a b

b = e
a=d -> a d =0
*/

Measured memory_bytes: 4052
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,x,m; cin>>n>>x>>m;
    if(n==1)  { cout<<x<<endl; return 0; }
    ll arr[m+4];
    ll sum=0;
    sum+=x;
    map<ll,ll> mp;
    arr[1]=x;
    mp[x]=1;
    for(int i=2;i<=n;i++)
    {
        ll val=arr[i-1]*arr[i-1];
        val%=m;
        if(mp.count(val))
        {
            ll j=mp[val];
            ll no=i-j;
            ll fck=0;
            for(int k=j;k<=i-1;k++){
                fck+=arr[k];
            }
            ll left=n-i+1;
            ll f=left/no;
            f=(f*fck);
            sum+=f;
            left=left%no;
            int cnt=0;
            for(int k=j;k<=i-1;k++){
                if(cnt==left) break;
                sum+=arr[k];
                cnt++;
            }
            cout<<sum<<endl;
            return 0;
        }
        else {
            
            mp[val]=i;
            arr[i]=val;
        }
        // cout<<arr[i]<<endl;
        sum+=arr[i];
        if(i==n) { cout<<sum<<endl; return 0;  } 
    }
}

Measured memory_bytes: 7160
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    string A, B, C;
    cin >> A >> B >> C;

    if(A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

bool eql(V<> l, V<> r) {
  for (auto&& e : l) e -= l.back();
  for (auto&& e : r) e -= r.back();
  return l == r;
}
struct S {
  int m;
  V<> x, y;
  bool operator==(S r) const {
    for (int i = 0; i < 4; ++i) {
      if (eql(x, r.x) and eql(y, r.y)) return true;
      for (int j = 0; j < r.m; ++j) {
        tie(r.x[j], r.y[j]) = make_pair(-r.y[j], r.x[j]);
      }
    }
    reverse(begin(r.x), end(r.x));
    reverse(begin(r.y), end(r.y));
    for (int i = 0; i < 4; ++i) {
      if (eql(x, r.x) and eql(y, r.y)) return true;
      for (int j = 0; j < r.m; ++j) {
        tie(r.x[j], r.y[j]) = make_pair(-r.y[j], r.x[j]);
      }
    }
    return false;
  }
  friend istream& operator>>(istream& i, S& s) {
    cin >> s.m;
    s.x.resize(s.m), s.y.resize(s.m);
    for (int i = 0; i < s.m; ++i) cin >> s.x[i] >> s.y[i];
    return i;
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int n; cin >> n;
    if (!n) break;
    V<S> a(n + 1); for (auto&& e : a) cin >> e;
    for (int i = 1; i <= n; ++i) if (a[i] == a[0]) {
      cout << i << '\n';
    }
    cout << "+++++" << '\n';
  }
}


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

const int N = 3000 + 20;
int a[N];
vector<int> adj[N];

bool dfs(int u, int par) {
    bool res = false;
    for (auto v: adj[u])
        if (v ^ par)
            if (a[v] < a[u] && !dfs(v, u))
                res = true;
    return res;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, u, v;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 1; i < n; i++) {
        cin >> u >> v;
        adj[--u].push_back(--v);
        adj[v].push_back(u);
    }
    for (int i = 0; i < n; i++)
        if (dfs(i, -1))
            cout << i + 1 << " ";
    cout << "\n";
    return 0;
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 998244353;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int a[100006], b[100006];
P sa[100006];

int par[200006], siz[200006];
void init(int n) {
	rep(i, n) {
		par[i] = i;
		siz[i] = 1;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x); y = find(y);
	if (x == y)return;
	if (siz[x] < siz[y])swap(x, y);
	par[y] = x;
	siz[x] += siz[y];
}

signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i]; rep(i, n)cin >> b[i];

	vector<P>V,V2;

	rep(i, n)V.push_back(P(b[i], a[i]));
	sort(V.begin(), V.end());
	rep(i, n) {
		a[i] = V[i].second;
		b[i] = V[i].first;
	}

	rep(i, n)sa[i] = P(a[i],i); 
	sort(sa, sa + n);
	
	init(n);
	rep(i, n) {
		if (sa[i].first > b[i]) {
			puts("No"); return 0;
		}
		unite(sa[i].second, i);
	}
	set<int>S;
	rep(i, n)S.insert(find(i));
	if (S.size() >= 2) {
		puts("Yes"); return 0;
	}

	rep(i, n - 1) {
		if (b[i] >= sa[i+1].first) {
			puts("Yes"); return 0;
		}
	}
	puts("No");
}


Measured memory_bytes: 7408
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <bitset>
typedef unsigned long long int ll;
const ll INF = 876543210987654321;
const int MOD = 1000000007;
#define REP(i,n) for(int i=0;i<n;++i)
using namespace std;
//vector<vector<int>>(h, vector<int>(w, f));
 
 
int main() {
	string s;
	cin >> s;
	ll a[256] = {};
	ll n = s.size();
	for(int i = 0;s[i] ; ++i )a[s[i]-'a']++;
	ll ans = n*(n - 1) / 2;
	for (int i = 0; i < 26; ++i) {
		if (a[i] > 1)ans -= a[i] * (a[i] - 1) / 2;
 
	}
	cout << ans+1 << endl;
	int aa;
	cin >> aa;
	return 0;
 
}

Measured memory_bytes: 640