akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

#define N_MAX 10000005

using namespace std;

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

const ll mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1LL << 60;



struct edge {ll from,to,cost;};


ll fac[N_MAX];

void init()
{
    fac[0] = 1;
    fac[1] = 1;
    for(int i = 2; i < N_MAX; i++){
        fac[i] = ((fac[i-1] * i) % mod);
    }
}

ll pow(ll n, ll p)
{
    if(p == 0){
        return 1;
    }else if(p % 2 == 0){
        return (pow(n,p/2) * pow(n,p/2) % mod);
    }else{
        return (n * pow(n,p-1) % mod);
    }
}

ll com(ll n, ll k)
{
    return (fac[n] * (pow(fac[k],mod-2) * pow(fac[n-k],mod-2) % mod)) % mod;
}


int main()
{
    ll x,y;
    cin >> x >> y;
    ll ans = 0;;
    ll s,t;
    if((x + y) % 3 == 0){
        ll n = (x + y) / 3;
        for(ll i = 0; i <= n; i++){
            s = i;
            t = n-i;
            if(s < 0 || t < 0) continue;
            if(2 * s + t == x){
                init();
                ans = com(n,s);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple<int, int> ti2;
typedef tuple<int, int, int> ti3;
typedef tuple<int, int, int, int> ti4;
typedef tuple<ll, ll> tl2;
typedef tuple<ll, ll, ll> tl3;
typedef tuple<ll, ll, ll, ll> tl4;
typedef vector<int> vi;
typedef vector<ti2> vti2;
typedef vector<ti3> vti3;
typedef vector<ti4> vti4;
typedef vector<ll> vl;
typedef vector<tl2> vtl2;
typedef vector<tl3> vtl3;
typedef vector<tl4> vtl4;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vti2> vvti2;
typedef vector<vti3> vvti3;
typedef vector<vti4> vvti4;
typedef vector<vl> vvl;
typedef vector<vtl2> vvtl2;
typedef vector<vtl3> vvtl3;
typedef vector<vtl4> vvtl4;
typedef vector<vs> vvs;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; i++)
#define FORD(i, a, b) for (int i = (a), i##_len = (b); i > i##_len; i--)
#define FORR(t, a) for (auto t : a)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORT(a, func) sort(ALL(a), [](const auto& x, const auto& y) func)
#define GET(i, j) get<j>(i)
#define MT(x, ...) make_tuple(x, __VA_ARGS__)
#define PRINT(i) cout << i << endl
#define PRINT2(i, j) cout << i << " " << j << endl
#define PRINT3(i, j, k) cout << i << " " << j << " " << k << endl
#define PRINT4(i, j, k, l) \
    cout << i << " " << j << " " << k << " " << l << endl
#define PRINTL(a)                                       \
    for (const auto& d9aw : a) { cout << d9aw << " "; } \
    cout << endl

//演算子オーバーロード
bool operator<(const ti2 x, const ti2 y) {
    if (GET(x, 0) != GET(y, 0))
        return GET(x, 0) < GET(y, 0);
    else
        return GET(x, 1) < GET(y, 1);
}
bool operator>(const ti2 x, const ti2 y) {
    if (GET(x, 0) != GET(y, 0))
        return GET(x, 0) > GET(y, 0);
    else
        return GET(x, 1) > GET(y, 1);
}

int main() {
    int n;
    cin >> n;
    PRINT(n * n * n);
}


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

int main(){
  int a, b;
  cin >> a >> b;
  int ans = 0;
  rep(i,2){
    if(a>=b){
      ans += a;
      a--;
    }
    else{
      ans += b;
      b--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
inp = list(map(int,input().split()))
x=inp[0]
y=inp[1]
flag=1
if (4*x-y)<0 or (4*x-y)%2==1:
  print ('No')
  flag=0
if (2*x>y or (y-2*x)%2==1) and flag==1:
  print ('No')
  flag=0
if flag==1:
  print ('Yes')

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N,C;
ll p [401] [401];
ll dp [401] [401];
const ll MOD = 1e9 + 7;

long long pow_mod(long long x,long long y,long long i = MOD - 2)
{
	while(i){
		if(i & 1){
			(x *= y) %= MOD;
		}
		(y *= y) %= MOD;
		i >>= 1;
	}

	return x;
}

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

	cin >> N >> C;
	vector<int> A(N),B(N);
	FOR(i,0,N){
		cin >> A [i];
	}
	FOR(i,0,N){
		cin >> B [i];
	}

	for(int i = 0;i <= 400;i++){
		for(int j = 1;j <= 400;j++){
			(p [i] [j] = p [i] [j - 1] + pow_mod(1,j,i)) %= MOD;
		}
	}

	dp [0] [0] = 1;
	FOR(i,0,N){
		for(int j = 0;j <= C;j++){
			if(dp [i] [j] == 0) continue;
			for(int k = j;k <= C;k++){
				(dp [i + 1] [k] += dp [i] [j] * (p [k - j] [B [i]] - p [k - j] [A [i] - 1])) %= MOD;
				(dp [i + 1] [k] += MOD) %= MOD;
			}
		}
	}

	cout << dp [N] [C] << endl;

	return 0;
}


Measured memory_bytes: 2816
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            long lN = long.Parse(Console.ReadLine().Trim());

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            long lOut = 1L;
            for (long i = 1; i <= lN; i++)
            {
                lOut *= i;                              // 階乗
                lOut %= 1000000007L;
            }

            //出力
            Console.WriteLine("{0}", lOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, K;
int sqrtN;
int dp0[100000];
int dp[100000];
int sdp[100000];
int dp2[100000];
const int mod = 1000000007;

signed main() {
    cin >> N >> K;
    sqrtN = (int) sqrt(N);
    for (int i = 1; i <= sqrtN; ++i) {
        dp[i] = 1;
    }
    for (int i = 1; i <= sqrtN; ++i) {
        dp[i + sqrtN] = N / (sqrtN - i + 1) - max(sqrtN, N / (sqrtN - i + 2));
    }
    for (int i = 1; i <= sqrtN * 2; ++i) {
        dp0[i] = dp[i];
    }
    for (int i = 1; i <= 2 * sqrtN; ++i)sdp[i] = sdp[i - 1] + dp[i];
    for (int t = 1; t <= K - 1; ++t) {
        for (int i = 1; i <= 2 * sqrtN; ++i) {
            dp2[i] = sdp[2 * sqrtN - i + 1];
            if (i > sqrtN)dp2[i] *= dp0[i];
            dp2[i] %= mod;
        }
        swap(dp, dp2);
        for (int i = 1; i <= 2 * sqrtN; ++i)sdp[i] = (sdp[i - 1] + dp[i]) % mod;
    }

    int ans = sdp[2 * sqrtN];
    ans %= mod;
    ans += mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}
//1,2,...,√N:
//√N,...,N:

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

int main() {
	int n, ans;
  	cin >> n;
    if(n < 105) {
    	ans = 0;
    } else if(n < 135) {
      	ans = 1;
    } else if(n < 165) {
      	ans = 2;
    } else if(n < 189) {
        ans = 3;
    } else if(n < 195) {
      	ans = 4;
    } else {
      	ans = 5;
    }
  	cout << ans << '\n';
}

Measured memory_bytes: 764
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = int(input())
AA = inpl()

ans = 0
R = 0
xorsum = AA[0]
plussum = AA[0]
for L in range(N):
    while xorsum == plussum and R < N:
        R += 1
        if R >= N:
            break
        xorsum ^= AA[R]
        plussum += AA[R]
    #print(L,R)
    ans += (R-L)
    xorsum ^= AA[L]
    plussum -= AA[L]


print(ans)


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

main(){

long long n,p,q,k,x,t,i,j,l,m;
  while(cin>>n>>m>>i>>j)
{
 cout<<max(n*i,max(m*i,max(n*j,m*j)));

  } return 0;

}


Measured memory_bytes: 3500
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) std::cout << (j ? s1 : s2) << endl;
# define YES(j) std::cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

int main()
{
    string a,b ;cin >> a >> b ;

    if(a.size()>b.size()) p("GREATER")
    else if(a.size()<b.size()) p("LESS")
    else if(a==b) p("EQUAL")
    else if(a>b) p("GREATER")
    else p("LESS")
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    double d = 0.0;
    double t = 0.0;
    double s = 0.0;
    scanf("%lf %lf %lf", &d, &t, &s);
    double less = d / s;
    if(less <= t){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1692
n=gets.chomp.split("").map(&:to_s)
max=0

for i in 0..n.length-1
    for j in 0..n.length-1
        v=n[i..j]
        count=0
        (v.length).times.each do
            #p v
            vv=v.pop
         
            if vv=="G" || vv=="A" || vv=="C" || vv=="T"
                count+=1
            else
            count=0
              break
            end
           
         end
        #p count
        max=[max,count].max
    end
end
p max

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

int main(){
  int n;

  while(cin>>n){
    int dec[100002];
    int inc[100002];

    for(int i=0;i<100002;i++){
      dec[i] = 0;
      inc[i] = 0;
    }

    for(int i=0;i<n;i++){
      int a,b;
      cin>>a>>b;
      inc[a]++;
      dec[b]++;
    }

    int now = 0;
    int ans = 0;

    for(int i=0;i<100002;i++){
      now += inc[i];
      if(now + 1 >= i) ans = max(ans, i);
      now -= dec[i];
    }

    cout<<ans-1<<endl;
  }
}

Measured memory_bytes: 1608
#include <cstdio>
#include <stdio.h>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
    char c[3][3];

    for(int i = 0; i < 3; i ++) {
        scanf(" %c %c %c", &c[i][0], &c[i][1], &c[i][2]);
    }

    printf("%c%c%c\n", c[0][0], c[1][1], c[2][2]);
    return 0;
}

Measured memory_bytes: 128
from itertools import product
S = input().strip()
k = len(S)-1
cnt = 0
for x in product((0,1),repeat=k):
    A = []
    cur = 0
    for i in range(k):
        if x[i]==1:
            A.append(int(S[cur:i+1]))
            cur = i+1
    A.append(int(S[cur:k+1]))
    cnt += sum(A)
print(cnt)

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

using namespace std;

int main()
{
    string s; cin >> s;

    bool ans = false;
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) ans = true;
    if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) ans = true;
    if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) ans = true;

    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
using namespace std;
int main(){
	int n,h,w,s=0;
	cin>>n>>h>>w;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		if(a>=h && b>=w)
			s++;
	}
	cout<<s;
	return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int N,X;
    
    cin >> N >>X;
    vector<int> L(N);
    vector<int> D(N);
    
    for (int i=0; i<N; i++){
        cin >> L[i];
        //cout << i<< ":"<<L[i]<<endl;
    }
    D[0]=0;
    int j=0;
    while(X>=D[j]){
        D[j+1] = D[j] + L[j];
        if (j==N){j++; break;}
            else j++;
        }
    
    cout <<j<<endl;
    return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    string S;
    cin >> S;
    print(S.substr(0,3));

    

}

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

Measured memory_bytes: 3616
using System;

public class cal
{
	public static void Main()
	{
		string target_str;
		
		while ((target_str = Console.ReadLine()) != null)
		{
			int answer = 0;
			int target = 0;
			target = int.Parse(target_str);

			for (int a = 0; a < 10; a++)
			{
				for (int b = 0; b < 10; b++)
				{
					for (int c = 0; c < 10; c++)
					{
						for (int d = 0; d < 10; d++)
						{
							if (a + b + c + d == target)
							{
								answer++;
							}
						}
					}
				}
			}
			Console.WriteLine(answer);
		}

	}
}

Measured memory_bytes: 9012
var
 n,a,b,i:longint;
begin
 read(a,b); n:=1;
 for i:=a to b do
  if i=0 then begin writeln('Zero'); halt; end
   else if i<0 then n:=-n;
 if n=1 then writeln('Positive')
  else writeln('Negative');
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
int gcd(int a, int b) {  
    if (!b)  
        return a;  
    return gcd(b, a%b);  
}  
 
int main(){
  int A, B, K, c, i;
  cin >> A >> B >> K;
  
  c = gcd(A, B);
  
  for (i = c; i >= 1; i--){
    if(c%i == 0){
      K--;
    }
    if(K == 0){
      break;
    }
  }
  
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

const int N = 1e5+5;

int n, minval=1e9, ans=0;
int a[N];
bool checkpos=0, checkneg=0;
multiset<int> pos, neg;

int32_t main()
{
	IOS;
	cin >> n;
	int ctzero = 0;
	for(int i = 1;i <= n; i++)
	{
		cin >> a[i];
		minval = min(abs(a[i]), minval);
		checkpos |= (a[i] > 0);
		checkneg |= (a[i] < 0);
		ans += abs(a[i]);
		if(a[i] > 0)
			pos.insert(a[i]);
		else if(a[i] < 0)
			neg.insert(a[i]);
		else
			ctzero++;
	}
	while(ctzero > 0)
	{
		if(pos.size() < neg.size())
			pos.insert(0);
		else
			neg.insert(0);
		ctzero--;
	}
	if(pos.size() && neg.size())
	{
		cout << ans << endl;
		int n = *neg.begin();
		neg.erase(neg.begin());
		while(pos.size() > 1)
		{
			cout << n << " " << *pos.begin() << endl;
			n -= *pos.begin();
			pos.erase(pos.begin());
		}
		neg.insert(n);
		int p = *pos.begin();
		while(neg.size() > 0)
		{
			cout << p << " " << *neg.begin() << endl;
			p -= *neg.begin();
			neg.erase(neg.begin());
		}
	}
	else
	{
		cout << ans - 2 * minval << endl;
		if(pos.size())
		{
			int least = *pos.begin();
			pos.erase(pos.find(least));
			while(pos.size() > 1)
			{
				cout << least << " " << *pos.begin() << endl;
				least -= *pos.begin();
				pos.erase(pos.begin());
			}
			cout << *pos.begin() << " " << least << endl;
		}
		else
		{
			int mx = *neg.rbegin();
			neg.erase(neg.find(mx));
			while(neg.size() > 0)
			{
				cout << mx << " " << *neg.begin() << endl;
				mx -= *neg.begin();
				neg.erase(neg.begin());
			}
		}
	}
	return 0;
}

Measured memory_bytes: 7040
use std::error::Error;
use std::io::{self, BufRead};

fn run() -> Result<String, Box<Error>> {
    let stdin = io::stdin();
    let mut stdin = stdin.lock().lines();

    let (n, l) = {
        let s = stdin.next().unwrap()?;
        let mut it = s.split_whitespace().map(|s| s.parse::<usize>());
        (it.next().unwrap()?, it.next().unwrap()?)
    };

    let mut ss = stdin.take(n).collect::<Result<Vec<String>, _>>()?;
    ss.sort();

    Ok(ss.into_iter().collect())
}

fn main() {
    println!("{}", run().unwrap());
}


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

int main(void){
    string s;
    while(true){
        cin >> s;
        if(s == "0"){
            break;
        }
        int d = 0;
        for(int i = 0;i < s.size(); i++){
            int n = s[i] - 48;
            d += n;
        }
        cout << d << endl;
    }
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
struct data{int a,t,g,c;};

int A,T,G,C,N,M,mod=1e9+7;
string s[100],str,tmp;
vector<string> t[100];
int dp[51][51][51][51];
bool flg[51][51][51][51];
map<string,int> mp;
vector<int> V;

int calc(string &str){
  int res=0;
  for(int i=1;i+1<(int)str.size();i++){
    if(str[i]=='A')res+=(1<<0);
    if(str[i]=='T')res+=(1<<1);
    if(str[i]=='G')res+=(1<<2);
    if(str[i]=='C')res+=(1<<3);
  }
  return res;
}

void dfs(int id){
  if(A+T+G+C<(int)V.size())return;
  for(int i=0;i<(int)t[id].size();i++){
    if(t[id][i][0]=='[')V.push_back(calc(t[id][i]));
    else dfs(mp[t[id][i]]);
  }
}

int solve(){
  dfs(0);
  if(A+T+G+C!=(int)V.size())return 0;
  
  queue< data > Q;
  dp[0][0][0][0]=1;
  flg[0][0][0][0]=true;
  Q.push((data){0,0,0,0});
  
  while(!Q.empty()){
    data d=Q.front();Q.pop();
    int p=d.a+d.t+d.g+d.c;
    for(int i=0;i<4;i++){
      if(V[p]>>i&1){
        int na=d.a;
        int nt=d.t;
        int ng=d.g;
        int nc=d.c;
        if(i==0)na++;
        if(i==1)nt++;
        if(i==2)ng++;
        if(i==3)nc++;
        if(A<na||T<nt||G<ng||C<nc)continue;
        dp[na][nt][ng][nc]+=dp[d.a][d.t][d.g][d.c];
        if(dp[na][nt][ng][nc]>=mod)dp[na][nt][ng][nc]-=mod;
        if(!flg[na][nt][ng][nc]){
          flg[na][nt][ng][nc]=true;
          Q.push((data){na,nt,ng,nc});
        }
      }
    }
  }
  return dp[A][T][G][C];
}

int main(){
  cin>>A>>T>>G>>C>>N;
  cin.ignore();
  for(int i=0;i<N;i++){
    getline(cin,str);
    stringstream ss(str);
    ss>>s[i];
    mp[s[i]]=i;
    while(ss>>tmp){
      if(tmp[0]!='[')tmp+=':';
      t[i].push_back(tmp);
    }
  }
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 35572
import java.math.BigDecimal

fun main(args: Array<String>) {
    val n = readLine()!!

    println(
            readLine()!!.split(Regex("\\s+")).map { it.toInt() }
                    .groupBy { it }
                    .mapValues { it.value.size }
                    .filterValues { it >= 2 }
                    .toList().sortedByDescending { it.first }
                    .let { l ->
                        val p1 = l.getOrElse(0, { i -> 0 to 0 })
                        val p2 = l.getOrElse(1, { i -> 0 to 0 })

                        val e1 = BigDecimal(p1.first)
                        val e2 = BigDecimal(p2.first)
                        
                        e1 * (if (p1.second >= 4) e1 else e2)
                    }
    )
}


Measured memory_bytes: 81240
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
        ans+=i;
    }
    cout<<ans;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    int M, D;
    cin >> M >> D;
    int cnt = 0;
    for (int m = 1; m <= M; ++m){
        for (int d = 1; d <= D; ++d){
            int d10 = d / 10;
            int d1 = d % 10;
            if (d1 >= 2 && d10 >= 2){
                if (d1 * d10 == m){
                    cnt += 1;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
x,n=map(int,input().split())
datap=[int(i) for i in input().split()]

for i in range(x-n-1,x+1,1):
    if i in datap:
        pass
    else:
        ansm=i

for j in range(x+n+1,x-1,-1):
    if j in datap:
        pass
    else:
        ansp=j

if x-ansm>ansp-x:
    print(ansp)
else:
    print(ansm)

Measured memory_bytes: 9048
#include<bits/stdc++.h>
#include<iomanip>
#include<cstring>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define MOD 1000000007


double dp[3000][3000];
double rec(vector<double>& arr, int i, int x)
{
	if (x == 0)
		return 1;
	if (i == 0)
		return 0;

	if (dp[i][x] > -0.9)
		return dp[i][x];

	dp[i][x] = ((arr[i] * rec(arr, i - 1, x - 1)) + ((1 - arr[i]) * rec(arr, i - 1, x)));
	return dp[i][x];
}


int main()
{



	int n;
	cin >> n;
	vector<double> arr(n + 1);

	for (int i = 1; i <= n; i++)
		cin >> arr[i];

	memset(dp, -1, sizeof(dp));
	double x = rec(arr, n, ((n + 1) / 2));
	cout << setprecision(10) << x << endl;
}





Measured memory_bytes: 70784
N = int(input())
S_1 = input()
S_2 = input()
ans = 1
i = 0
while True:
    if i >= N:
        break
    if i == 0:
        if S_1[i] == S_2[i]:
            ans *= 3
            i += 1
        else:
            ans *= 6
            i += 2
    else:
        if S_1[i-1] == S_2[i-1] and S_1[i] == S_2[i]:
            ans *= 2
            i += 1
        elif S_1[i-1] != S_2[i-1] and S_1[i] == S_2[i]:
            ans *= 1
            i += 1
        elif S_1[i-1] == S_2[i-1] and S_1[i] != S_2[i]:
            ans *= 2
            i += 2
        elif S_1[i-1] != S_2[i-1] and S_1[i] != S_2[i]:
            ans *= 3
            i += 2
    ans = ans % 1000000007
print(ans)


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

int main(){
    int house[5][4][11];
    
    //reset for house
    for(int a=0; a<5; a+=1){
        for(int i=0; i<4; i+=1){
            for(int j=0; j<11 ;j+=1){
                house[a][i][j] = 0;
            }
        }
    }
    
    int c,b,f,r,v;
    
    cin >> c;
    for(int n=1; n<=c; n+=1){
        cin >> b >> f >> r >> v;
        house[b][f][r] += v;
    }
    
    for(int a=1; a<5; a+=1){
        for(int i=1; i<4; i+=1){
            for(int j=1; j<11; j+=1){
                cout << " " << house[a][i][j];
            }
            cout << endl;
        }
        if(a==4) break;
        cout << "####################" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3076
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;
        int n; cin >> n;
        int m = n*800;
        cout<<m - (n/15)*200<<endl;



return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	const int INF = 1e9;
	int n,k;
	std::cin >> n >> k;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	std::map<int,int> map;
	rep(i,n) map[a[i]]++;
	int unique_count = map.size();
	std::vector<int> count;
	for(auto x:map) count.emplace_back(x.second);
	std::sort(all(count));
	int sum = 0;
	rep(i,unique_count-k) sum+=count[i];
	print(sum);
}


Measured memory_bytes: 16500
#include <bits/stdc++.h>
const int INF=1e9,MOD=INF+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int A,B,T;cin>>A>>B>>T;
  cout<<T/A*B<<endl;
}


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

typedef long long ll;
typedef struct pair<int,int> P;
int p[1001]={};
int x[1001]={};
int y[1001]={};

vector<int> v[1001];


int main() {
	int n;
	cin>>n;
	int r,l;
	int t=0;
	for(int i=0;i<n;++i){
		cin>>l>>r;
		t+=r-l+1;
	}
	cout<<t<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

bool fourcard(int h[5]) {
	if ((h[0] == h[1] && h[0] == h[2] && h[0] == h[3]) ||
		(h[4] == h[1] && h[4] == h[2] && h[4] == h[3]) )
		return true;
	return false;
}

bool fullhouse(int h[5]) {
	if ((h[0] == h[1] && h[0] == h[2] && h[3] == h[4]) ||
		(h[0] == h[1] && h[4] == h[2] && h[4] == h[3]) )
		return true;
	return false;
}

bool straight(int h[5]) {
	if (h[0] == 1 && h[1] != 2) {
		for (int i = 1; i < 5; i++)
			if (h[i] != i + 9)
				return false;
	}
	else {
		for (int i = 0; i < 4; i++)
			if (h[i] + 1 != h[i+1])
				return false;
	}
	return true;
}

bool threecard(int h[5]) {
	for (int i = 0; i < 3; i++)
		if (h[i] == h[i+1] && h[i] == h[i+2])
			return true;
	return false;
}

int pairs(int h[5]) {
	int ret = 0;
	for (int i = 0; i < 4; i++)
		if (h[i] == h[i+1]) {
			ret++;
			i++;
		}
	return ret;
}

int main() {
	int h[5];
	while (scanf("%d,%d,%d,%d,%d", &h[0], &h[1], &h[2], &h[3], &h[4]) != EOF) {
		sort(h, h + 5);
//		for (int i = 0; i < 5; i++)
//			printf("%d ", h[i]);
//		printf("\n");
		if (fourcard(h)) printf("four card\n");
		else if (fullhouse(h)) printf("full house\n");
		else if (straight(h)) printf("straight\n");
		else if (threecard(h)) printf("three card\n");
		else {
			int n = pairs(h);
			switch (n) {
				case 1: printf("one pair\n"); break;
				case 2: printf("two pair\n"); break;
				default: printf("null\n"); break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<queue>
#include<set>
#include<vector>
#include<cmath>
#include<ctime>
#include<locale>
using namespace std;
long a[10001],s[100];
long n;
struct xxx
{
    long n;
    long s;
};
queue<long> q;
void xx(long k,long s)
{
    a[s]=1;
    xx(k+1,s);
}
int main()
{
    memset(a,0,sizeof(a));
    cin>>n;
    for(long i=0;i<n;i++)
    {
        scanf("%d",&s[i]);
    }
    q.push(0);
    a[0]=1;
    for(long i=0;i<n;i++)
    {
        long k=q.size();
        for(long j=0;j<k;j++)
        {
            long d;
            d=q.front();
            //cout<<d<<endl;
            q.pop();
            if(a[d+s[i]]==0)
            {
                a[d+s[i]]=1;
                q.push(d+s[i]);
                q.push(d);
            }
        }
    }
    //cout<<"\\\\"<<endl;
    //for(long i=0;i<1000;i++)cout<<a[i]<<' ';cout<<endl;cout<<a[9999]<<endl;
    for(long i=10000;i>=0;i--)if(a[i]==1&&i%10!=0){cout<<i;return 0;}
    cout<<0;
    return 0;
}


Measured memory_bytes: 384
N = int(input())
words_set = set()
words_list = []
OK = True
for _ in range(N):
    s = input()
    words_list.append(s)
    words_set.add(s)
# print(words_list)
# print(words_set)
last_word = words_list[0][-1]
# print(last_word)
for i in range(1, N):
    if last_word == words_list[i][0]:
        last_word = words_list[i][-1]
    else:
        OK = False
        break

if OK and len(words_list) == len(words_set):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){

	int i;
	int x1 = 0, x2 = 0;
	char S[3];

	for(i = 0; i < 3; i++){
		scanf("%s", &S[i]);
		if(S[i] == 'A')
			x1++;
		if(S[i] == 'B')
			x2++;
	}
	if((x1 == 3) ||(x2 == 3))
		printf("No");
	else
	  printf("Yes");

  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();

		if(k >= a + b) {
			System.out.println(0 + " " + 0);
			System.exit(0);
		}

		if(a - k < 0) {
			k = k - a;
			a = 0;
		}else {
			a = a - k;
			k = 0;
		}

		if(k != 0) {
			b = b - k;
			k = 0;
		}
		System.out.println(a + " " + b);
		sc.close();
	}
}


Measured memory_bytes: 21844
import math


def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False
    return pow(2, q - 1, q) == 1


def main(n):
    if is_prime(n):
        return n - 1
    else:
        sqrt = int(math.sqrt(n))
        for i in range(sqrt, 1, -1):
            div, mod = divmod(n, i)
            if mod == 0:
                return i + div - 2


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


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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}

void solve()
{
    string s;
    cin >> s;
    ll a= 0, e = s.size()-1, ans = 0;
    while(a <= e) {
        if(s[a]!=s[e]){
            ans++;
        }
        a++;
        e--;
    }
    cout << ans << "\n";
}

int main()
{
    FAST_IO;
    #ifndef ONLINE_JUDGE 
      // OC;
    #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    int N,X[101];
    int max=-1,min=101,Smin=1000000000,S;
    scanf("%d",&N);
    for (int i=0; i<N; i++) {
        scanf("%d",&X[i]);
        if(X[i]>max){
            max=X[i];
        }
        if(min>X[i]){
            min=X[i];
        }
    }
    for (int i=min; i<=max; i++) {
        S=0;
        for (int j=0 ; j<N ; j++) {
            S+=(X[j]-i)*(X[j]-i);
        }
        if(S<Smin){
            Smin=S;
        }
    }
    printf("%d\n",Smin);
    return 0;
}


Measured memory_bytes: 128
import sys
import re
import math
import collections
import decimal
import bisect
import itertools

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
# MOD = 10 ** 9 + 7

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()
    d = na()

    d.sort()
    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            l = bisect.bisect_left(d, d[i] + d[j])
            ans+=l-j-1
    print(ans)


if __name__ == '__main__':
    main()


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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v)
{
    for (auto& e : v) {
        is >> e;
    }
    return is;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;


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

    while (true) {
        int N, M;
        cin >> N >> M;
        if (N == 0 and M == 0) {
            break;
        }
        vector<ll> h(N);
        vector<ll> w(M);

        vector<ll> ver(N + 1, 0);
        vector<ll> hor(M + 1, 0);
        for (int i = 0; i < N; i++) {
            cin >> h[i];
            ver[i + 1] += ver[i] + h[i];
        }
        for (int i = 0; i < M; i++) {
            cin >> w[i];
            hor[i + 1] += hor[i] + w[i];
        }
        map<ll, ll> h_mp;
        for (int i = 0; i <= N; i++) {
            for (int j = i + 1; j <= N; j++) {
                h_mp[ver[j] - ver[i]]++;
            }
        }
        map<ll, ll> w_mp;
        for (int i = 0; i <= M; i++) {
            for (int j = i + 1; j <= M; j++) {
                w_mp[hor[j] - hor[i]]++;
            }
        }

        ll sum = 0;
        for (const auto& p : h_mp) {
            const ll e = p.first;
            const ll n = p.second;
            if (w_mp.find(e) != w_mp.end()) {
                sum += n * w_mp[e];
            }
        }
        cout << sum << endl;
    }


    return 0;
}

Measured memory_bytes: 38892
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	int n,m;
	cin >> n >> m;
	vector<ll> x(n),y(n);
	for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
	ll res = -1;
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) 
	for(int u = 0; u < n; u++) for(int v = 0; v < n; v++) {
		int K = 0;
		ll xmin = min(x[u],x[i]);
		ll xmax = max(x[u],x[i]);
		ll ymin = min(y[v],y[j]);
		ll ymax = max(y[v],y[j]);
		// cout << x[i] << " " << x[j] << " " << y[i] << " " << y[j] << endl;
		for(int k = 0; k < n; k++) {
			if(x[k]<xmin||x[k]>xmax|| y[k]<ymin|| y[k]>ymax) {
				// cout << xmin << " " << xmax << " " << x[k] << endl;
				// cout << ymin << " " << ymax << " " << y[k] << endl;
				// cout << endl;
				// ;
			}
			else K++;
		}
		ll tmp = (xmax-xmin) * (ymax-ymin);
		// cout << tmp << " " << K << endl;
		if(K>=m && (res<0 || tmp < res)) {
			res = tmp;
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fo(i,n) for(i=0;i<n;i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);


int main()
{
	IOS
     ll t,r,d,a,i,j;
  cin>>r>>d>>a;
  for(i=1;i<=10;i++)
  {
     a=r*a-d;
    cout<<a<<endl;
  }
}

Measured memory_bytes: 256
fun main() {
  val n = readInt()
  val a = readInts().map { it.toDouble() }.sorted()
  println(a.reduce { s, elm -> (s + elm) / 2 })
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readStrings() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 39012
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
struct Edge{
    ll to;
    ll cost;
    Edge(ll to, ll cost) : to(to), cost(cost) {};
};
int main(){
    int V, E, r;
    cin >> V >> E >> r;
    vector<vector<Edge>> graph(V);
    for(int i = 0; i < E; i++){
        int a, b, c;
        cin >> a >> b >> c;
        graph[a].emplace_back(b, c);
    }
    vector<ll> dis(V, INF);
    dis[r] = 0;
    for(int i = 1; i < V; i++){
        for(int j = 0; j < V; j++){
            for(auto k : graph[j]){
                dis[k.to] = min(dis[k.to], dis[j] + k.cost);
            }
        }
    }
    vector<ll> ans = dis;
    for(int j = 0; j < V; j++){
         for(auto k : graph[j]){
            ans[k.to] = min(dis[k.to], dis[j] + k.cost);
        }
    }
    /*for(int i = 0; i < V; i++) cout << dis[i] << " ";
    for(int i = 0; i < V; i++) cout << ans[i] << " ";*/
    for(int i = 0; i < V; i++){
        if(ans[i] != dis[i] && ans[i] <= 1e9 && dis[i] <= 1e9) {cout << "NEGATIVE CYCLE" << "\n"; return 0;}
    }
    for(int i = 0; i < V; i++){
        if(ans[i] > 1e9){cout << "INF" << "\n";}
        else cout << ans[i] << "\n";
    }
}


Measured memory_bytes: 3208
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())
    d = defaultdict(int)
    for i in range(N):
        s = list(input())
        d["".join(sorted(s))] += 1

    ans = 0
    for k, v in d.items():
        ans += v * (v - 1) // 2

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18692
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (((i+1) % 2 == 1) && (vec.at(i) % 2 == 1)) ans++;
  }
  cout << ans;
  
}


Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;

int main(){
  int n, bld, flr, rm, ppl, room[4][3][10] = {};
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> bld >> flr >> rm >> ppl;
    room[bld - 1][flr - 1][rm - 1] += ppl;
    room[bld - 1][flr - 1][rm - 1] = max(room[bld - 1][flr - 1][rm - 1], 0);
    room[bld - 1][flr - 1][rm - 1] = min(room[bld - 1][flr - 1][rm - 1], 9);
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << ' ' << room[i][j][k];
      }
      cout << endl;
    }
    if (i != 3) {
      cout << "####################" << endl;
    }
  }
}

Measured memory_bytes: 3080
import math
#A,B,C,D = map(int,input().split())
N = int(input())
d = []
for i in range(N):
    temp = int(input())
    d.append(temp)
d = sorted(d)
d.reverse()

ans = 1
temp = d[0]
for i in range(1,len(d)):
    if d[i] < temp:
        ans += 1
        temp = d[i]

print(ans)

Measured memory_bytes: 3064
(function main() {
  const n = Number(require('fs').readFileSync('/dev/stdin', 'utf8'));

  const cache = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144];
  const fib = function fib(n) {
    if (cache[n]) return cache[n];
    return cache[n] = fib(n - 1) + fib(n - 2);
  };
  console.log(fib(n));
})();



Measured memory_bytes: 15128
n = int(input())
room = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for _ in range(n):
    b,f,r,v = map(int,input().split())
    room[b-1][f-1][r-1] += v

for c in range(4):
    for d in range(3):
        print('',*room[c][d])
    if c != 3:
        print('#' *20)



Measured memory_bytes: 5624
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
     
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
 
        int N = Integer.parseInt(sc.next());
 
        char[] cline = new char[10];
        String key = "";
        long tmpCount = 0;
        long count = 0;
        
        Map<String, Integer> map = new HashMap<>();

        for (int i = 0; i < N; i++) {
            tmpCount = 0;

            cline = sc.next().toCharArray();
            Arrays.sort(cline);
            key = String.valueOf(cline);
            tmpCount = map.getOrDefault(key, 0);

            count += tmpCount;

            map.put(key, (int) (tmpCount + 1));
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 51860
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }

void test_case() {
	int n;
	scanf("%d", &n);
	vector<long long> a(n);
	for(int i = 0; i < n; ++i) {
		scanf("%lld", &a[i]);
	}
	char s[n+1];
	scanf("%s", s);
	assert((int) strlen(s) == n);
	vector<long long> base;
	for(int i = n - 1; i >= 0; --i) {
		// if(a[i] == 0) {
			// continue;
		// }
		long long x = a[i];
		for(long long b : base) {
			x = min(x, x^b);
		}
		if(x == 0) {
			continue;
		}
		if(s[i] == '0') {
			base.push_back(x);
		}
		else {
			puts("1");
			return;
		}
	}
	puts("0");
}

int main() {
	int T;
	scanf("%d", &T);
	while(T--) {
		test_case();
	}
}


Measured memory_bytes: 3680
#include <stdio.h>

int main()
{
    int A,B;
    int X,Y,Z;
    int temp;

    scanf("%d %d\n",&A,&B);

    X=2*A-1;
    Y=A+B;
    Z=2*B-1;

    temp=X;

    if(temp<=Y){
        temp=Y;
    }
    if(temp<=Z){
        temp=Z;
    }

    printf("%d\n",temp);

    return 0;
}

Measured memory_bytes: 128
import itertools
import sys
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def get_lcm(num):
    return reduce(lambda x,y:(x * y) // fractions.gcd(x, y), num, 1)

def main():
    N,M = map(int,input().split())
    half_A = list(map(lambda x:int(x)//2,input().split()))

    lcm = get_lcm(half_A)

    if lcm > M:
        print(0)
        exit()

    for a in half_A:
        if (lcm // a) % 2 == 0:
            print(0)
            exit()

    # print(math.ceil(M/(2*lcm)))
    print((M//lcm + 1) // 2)


if __name__ == "__main__":
  main()


Measured memory_bytes: 24968
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

//0 = 羊, 1 = 狼

int main(){
  int N;
  string s;
  cin >> N >> s;
  int a[N]={0,0},b[N]={0,1},c[N]={1,0},d[N]={1,1};
  FOR(i,2,N){
    if(s[i-1] == 'o'){
      a[i] = a[i-2] ^ a[i-1];
      b[i] = b[i-2] ^ b[i-1];
      c[i] = c[i-2] ^ c[i-1];
      d[i] = d[i-2] ^ d[i-1];
    }
    else{
      a[i] = a[i-2] ^ a[i-1] ^ 1;
      b[i] = b[i-2] ^ b[i-1] ^ 1;
      c[i] = c[i-2] ^ c[i-1] ^ 1;
      d[i] = d[i-2] ^ d[i-1] ^ 1;
    }
  }
  bool a1=0,a2=0,b1=0,b2=0,c1=0,c2=0,d1=0,d2=0;
  if(s[N-1] == 'o'){
    if(a[0] == a[N-2] ^ a[N-1])a1 = 1;
    if(b[0] == b[N-2] ^ b[N-1])b1 = 1;
    if(c[0] == c[N-2] ^ c[N-1])c1 = 1;
    if(d[0] == d[N-2] ^ d[N-1])d1 = 1;
  }
  else{
    if(a[0] == a[N-2] ^ a[N-1] ^ 1)a1 = 1;
    if(b[0] == b[N-2] ^ b[N-1] ^ 1)b1 = 1;
    if(c[0] == c[N-2] ^ c[N-1] ^ 1)c1 = 1;
    if(d[0] == d[N-2] ^ d[N-1] ^ 1)d1 = 1;
  }
  if(s[0] == 'o'){
    if(a[1] == a[N-1] ^ a[0])a2 = 1;
    if(b[1] == b[N-1] ^ b[0])b2 = 1;
    if(c[1] == c[N-1] ^ c[0])c2 = 1;
    if(d[1] == d[N-1] ^ d[0])d2 = 1;
  }
  else{
    if(a[1] == a[N-1] ^ a[0] ^ 1)a2 = 1;
    if(b[1] == b[N-1] ^ b[0] ^ 1)b2 = 1;
    if(c[1] == c[N-1] ^ c[0] ^ 1)c2 = 1;
    if(d[1] == d[N-1] ^ d[0] ^ 1)d2 = 1;
  }
  if(a1 && a2){
    FOR(i,0,N)cout << (a[i] ? 'W' : 'S');cout << endl;
    return 0;
  }
  if(b1 && b2){
    FOR(i,0,N)cout << (b[i] ? 'W' : 'S');cout << endl;
    return 0;
  }
  if(c1 && c2){
    FOR(i,0,N)cout << (c[i] ? 'W' : 'S');cout << endl;
    return 0;
  }
  if(d1 && d2){
    FOR(i,0,N)cout << (d[i] ? 'W' : 'S');cout << endl;
    return 0;
  }
  cout << -1 << endl;
}


Measured memory_bytes: 2176