akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
  int count = 0, n, m, c, b[20] = {0}, souce[20] = {0};
  scanf("%d %d %d", &n, &m, &c);getchar();
  for(int i = 0; i < m; i++){
    scanf("%d", &b[i]);getchar();
  }
  for(int i = 0; i < n; i++){
    int num = 0;
    for(int j = 0; j < m; j++){
      scanf("%d", &souce[j]);getchar();
      num += souce[j] * b[j];
    }
    num += c;
    if(num > 0){
      count++;
    }
  }
  printf("%d\n", count);
  return 0;
}
    

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
         
        int a=stdIn.nextInt();
        int b=stdIn.nextInt();
         
        System.out.print(a*b+" ");
        System.out.println(2*(a+b));
         
 
    }
 
}

Measured memory_bytes: 17160
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
    val (A,B)=readLine()!!.split(" ").map {it.toInt()}
    println(when{
      A==B -> "Draw"
      A==1 -> "Alice"
      B==1 -> "Bob"
      A>B->"Alice"
      else-> "Bob"
    })
  }
}


Measured memory_bytes: 29916
use std::io;
use std::str::FromStr;

fn main(){
    let stdin = io::stdin();
    let mut buf = String::new();

    loop {
        let _ = stdin.read_line(&mut buf);
        let vec : Vec<usize> = buf.split_whitespace().map( |x| usize::from_str(x).unwrap() ).collect();
        buf.clear();
        let (h, w) = (vec[0], vec[1]);

        if h == 0 && w == 0 {
            break;
        }

        let ht = "#".repeat(w);
        let md = format!("#{}#\n", ".".repeat(w-2));
        println!("{0}\n{1}{0}\n", ht, md.repeat(h-2));
    }
}



Measured memory_bytes: 5024
a = list()
a[0:2] = map(int, input().split())
a[3:5] = map(int, input().split())
a[6:8] = map(int, input().split())
n = int(input())
for i in range(n):
    b = int(input())
    if b in a:
        a[a.index(b)] = 0
for i, j, k in ((0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6), (1, 4, 7), (2, 5, 8), (0, 4, 8), (2, 4, 6)):
    if a[i] == a[j] == a[k] == 0:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 9208
# Integer Cards

cards = []
rewrite_source = []

N, M = gets.chomp.split(" ").map(&:to_i)

cards = gets.chomp.split(" ").map(&:to_i)

for i in 0...M do
  bnum, cnum = gets.chomp.split(" ").map(&:to_i)
  rewrite_source[i] = [bnum, cnum]
end

cards.sort!

rewrite_source.sort_by!{|a| a[1]}.reverse!

check = 0

j = 0
i = 0

while i < M
#for i in 0...M
  if N < rewrite_source[i][0] + check then
    while j < N
      if cards[j] <= rewrite_source[i][1] then
        cards[j] = rewrite_source[i][1]
      else
        break
      end
      j += 1
    end
  else
    while j < rewrite_source[i][0] + check
      if cards[j] <= rewrite_source[i][1] then
        cards[j] = rewrite_source[i][1]
      else
        break
      end
      j += 1
    end
  end
  check = j
  i += 1
end

answer = 0

cards.each{|a|
  answer += a
}

puts answer


Measured memory_bytes: 21576
#include<bits/stdc++.h>
using namespace std;
int a,b,k,cnt=0;

int main()
{
	cin>>a>>b>>k;
	for(int i=a;i>=1;i--)
	{
		if(a%i!=0) continue;
		if(b%i==0) cnt++;
		if(cnt==k)
		{
			cout<<i<<endl;
			break;
		}
	}
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long A,B,C,K;
  cin >> A >> B >> C >> K;
  
  if(K<=A){
    cout << K << endl;
  }
  else if(K<=(A+B)){
    cout << A << endl;
  }
  else {
    cout << 2*A+B-K << endl;
  }
}


Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout << (x ? "Yes" : "No") << endl;
#define out(s) cout << s << endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(), s.end()
void vout(vi v)
{
    for (int i = 0; i < v.size(); i++)
        cout << v.at(i) << endl;
}
long long int gcd(long long int x, long long int y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

int main()
{
    lli k, ans = 0;
    cin >> k;
    rep(i, k) rep(j, k) rep(l, k)
    {
        ans += gcd(i+1, gcd(j+1, l+1));
    }
    out(ans);
}

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

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pqb             priority_queue<ll>
#define pqs             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mx 3000
ll n,m;
char gd[mx][mx];
ll solve(ll n,ll m){
   ll dp[n+1][m+1];
    dp[n][m]=1;
   for(int i=n;i>=1;i--){
        for(int j=m;j>=1;j--){
                if(i==n&& j==m)continue;
             if(gd[i][j]=='#')
                dp[i][j]=0;
              else  dp[i][j]=(((i==n)?0:dp[i+1][j])+((j==m)?0:dp[i][j+1]))%mod;

        }
   }
  /* for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){
    cout<<dp[i][j]<<" ";}cout<<endl;
   }*/
   return dp[1][1];
}
int main()
{
    FIO;
    ll c,d,e,f=0,sum=0,ans,ck,k,p,q,r,t,add=0,w,x,y,z;
    cin>>n>>m;

    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)
        {cin>>gd[i][j];}
   ck= solve(n,m);
    cout<<ck<<endl;

    return 0;
}



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

const int M = 10000001;
ll a[M];
int main() {
    int N;
    cin >> N;
    fill(a, a + M, 1);
    for (ll i = 2; i < M; i++) {
        for (ll j = 1; i * j < M; j++) {
            a[i * j]++;
        }
    }
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        ans += i * a[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 81760
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args) throws Exception {
		FastScanner sc = new FastScanner();
		long N = sc.nextLong();
		long K = sc.nextLong();
		long res = 0;
		if(K == 0) {
			System.out.println(N*N); return;
		}
		for(long b = K+1; b <= N; b++) {
			res += (N/b) * (b-K);
			res += Math.max(0, (N%b)-K+1);
		}
		System.out.println(res);
	}
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
 
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
 
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
 
		public int nextInt() {
			return Integer.parseInt(next());
		}
 
		public long nextLong() {
			return Long.parseLong(next());
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
 
	}
}

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

using namespace std;

typedef long long llint;
const long long MOD = 1e9 + 7;

int N;
llint A[101010];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  vector<llint> x(N + 1), y(N + 1), z(N + 1);
  for (int i = 0; i < N; i++) {
    x[i + 1] = x[i], y[i + 1] = y[i], z[i + 1] = z[i];
    if (x[i] == A[i]) {
      x[i + 1]++;
    } else if (y[i] == A[i]) {
      y[i + 1]++;
    } else if (z[i] == A[i]) {
      z[i + 1]++;
    }
  }

  llint ans = 1;
  for (int i = 0; i < N; i++) {
    llint t = 0;
    if (x[i] == A[i]) {
      t++;
    }
    if (y[i] == A[i]) {
      t++;
    }
    if (z[i] == A[i]) {
      t++;
    }
    ans *= t, ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sint(a) scanf("%d",&a)
#define sint2(a,b) scanf("%d %d",&a,&b)
#define sll(a) scanf("%lld",&a)
#define sll2(a,b) scanf("%lld %lld",&a,&b)
#define mem(a,i) memset(a,i,sizeof(a))

ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
ll a[100000005];
ll s=0;
ll isp[100000004];
int main()
{
    ll k,b;
    sll2(k,b);
    ll c=gcd(k,b);
    mem(a,1);
    ll sum=0;
    for(ll i=2; i*i<=c+1; i++)
    {
        if(c%i==0)
        {
            sum++;
            while(c%i==0)
                c/=i;
        }
    }
    if(c!=1)
        sum++;
    printf("%lld\n",sum+1);
    return 0;
}


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

int main(void){
    ll N;
    cin >> N;
    ll cnt = 0;
    if(N % 2 == 1){
        printf("0");
    }
    else{
        N = N / 2;
        while (N >= 5){
            cnt += N/5;
            N = N/5;
        }
        printf("%lld", cnt);
    }
}


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

map<long long, int> prime_factor(long long n){
    map<long long, int> ret;
    for(long long i=2; i*i<=n; i++){
        while(n%i==0){
            ret[i]++;
            n /= i;
        }
    }
    if(n!=1) ret[n] = 1;
    return ret;
}

int main(){
    long long N;
    cin >> N;
    long long i;
    vector<long long> nijou;
    for(i=1; i<=1000000; i++){
        nijou.push_back((i*(i+1))/2);
    }
    long long counta;
    long long ans=0;
    for(auto p : prime_factor(N)){
        counta=1;
        while(p.second--){
            counta++;
        }
        i = lower_bound(nijou.begin(),nijou.end(),counta)-nijou.begin();
        ans += i;
    }
    cout << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 11656
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Collections;

class Main {
    public static void main(String[] args) throws IOException {
    	 Scanner sc = new Scanner(System.in);
    	 int i=0;
    	 ArrayList<Integer> list = new ArrayList<Integer>();
    	 
         while(sc.hasNextInt()) {
        	 int num = sc.nextInt();
        	 list.add(num);
        	 i++;
        	 // 入力データは10個らしいので。
        	 if(i>9){
        		 break;
        	 }
         }
    	if (sc.ioException() != null) {
    	    throw sc.ioException();
    	}
    	
    	Collections.sort(list);
    	System.out.println(list.get(9));
        System.out.println(list.get(8));
        System.out.println(list.get(7));
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>

using namespace std;


int main() {

    int N, M;
    cin >> N >> M;
    map<int, int> m;
    for (int i = 0; i < N; i++) {
        int K;
        cin >> K;
        for (int k = 0; k < K; k++) {
            int A;
            cin >> A;
            m[A] += 1;
        }
    }

    int result = 0;

    for (auto kv:m) {
        if (kv.second == N) {
            result += 1;
        }
    }

    cout << result << "\n";

    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i + 100*j + 50*k == x:
        cnt += 1
 
print(cnt)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

uint64_t counter[200'000];
vector<int> child[200'000];
bool isVisited[200'000];

void dfs(int root, uint64_t a)
{
    isVisited[root] = true;
    counter[root] += a;

    for (const int &c : child[root])
    {
        if (!isVisited[c])
        {
            dfs(c, counter[root]);
        }
    }
}

int main()
{
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        child[a].push_back(b);
        child[b].push_back(a);
    }

    fill(counter, counter + n, 0);
    fill(isVisited, isVisited + n, false);

    for (int i = 0; i < q; i++)
    {
        int p;
        uint64_t x;
        cin >> p >> x;
        p--;
        counter[p] += x;
    }

    dfs(0, 0);

    for (int i = 0; i < n; i++)
    {
        cout << counter[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 21376
import heapq
import math

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(lambda x: x * (-1), a))

heapq.heapify(b)
for i in range(m):
    h = heapq.heappop(b)
    heapq.heappush(b, math.ceil(h / 2))

c = list(map(lambda x: x * (-1), b))

print(sum(c))


Measured memory_bytes: 15300
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const ll INF = 1E+18;


int main(){
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    set<int> s;
    int m = 0;
    rrep(i, n) {
        if (i!=n-1) {
            chmax(m, *s.rbegin()-a[i]);
        }
        s.insert(a[i]);
    }
    map<ll, ll> mp;
    vector<ll> sum(n+1);
    vector<ll> rsum(n+1);
    rep(i, n) {
        sum[i+1] = sum[i] + mp[a[i]-m];
        mp[a[i]]++;
        //debug(sum[i+1]);
    }
    mp.clear();
    rrep(i, n) {
        rsum[i] = rsum[i+1] + mp[a[i]+m];
        mp[a[i]]++;
        //debug(rsum[i]);
    }
    ll ans = INF;
    rep(i, n+1) {
        chmin(ans, sum[i]+rsum[i]);
    }
    ans++;
    
    cout << sum[n] << endl;
    return 0;
}


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

int main() {
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<LL> a(X), b(Y), c(Z);
  for (int i = 0; i < X; i ++) cin >> a[i];
  for (int i = 0; i < Y; i ++) cin >> b[i];
  for (int i = 0; i < Z; i ++) cin >> c[i];

  vector<LL> ab;
  for (int i = 0; i < X; i ++) {
    for (int j = 0; j < Y; j ++) {
      ab.push_back(a[i] + b[j]);
    }
  }
  sort(ab.begin(), ab.end());
  reverse(ab.begin(), ab.end());

  vector<LL> abc;
  for (int i = 0; i < min(K, (int)ab.size()); i ++) {
    for (int j = 0; j < Z; j ++) {
      abc.push_back(ab[i] + c[j]);
    }
  }
  sort(abc.begin(), abc.end());
  reverse(abc.begin(), abc.end());

  for (int i = 0; i < K; i ++) {
    cout << abc[i] << endl;
  }
}

Measured memory_bytes: 43240
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class Type>struct is_vector : std::false_type {};
	template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
	template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
		if (v.empty())return out;
		constexpr bool is_vector_v = is_vector<T>::value;
		if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
		else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
		return out;
	}
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	inline void putn() {}
	template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

	void solve() {
		IOS;
		ll n;
		cin >> n;
		vector<ll> a(n), b(n), c(n);
		REP(i, n) {
			cin >> a[i];
		}
		REP(i, n) {
			cin >> b[i];
		}
		REP(i, n) {
			cin >> c[i];
		}
		sort(all(a));
		sort(all(b));
		sort(all(c));
		ll res = 0;
		REP(i, n) {
			ll ok1 = -1, ng1 = n;
			while (abs(ng1 - ok1) > 1) {
				ll mid = (ok1 + ng1) / 2;
				if (a[mid] < b[i]) {
					ok1 = mid;
				} else {
					ng1 = mid;
				}
			}
			ll ok2 = n, ng2 = -1;
			while (abs(ng2 - ok2) > 1) {
				ll mid = (ok2 + ng2) / 2;
				if (c[mid] > b[i]) {
					ok2 = mid;
				} else {
					ng2 = mid;
				}
			}
			res += (ok1 + 1) * (n - ok2);	
		}
		put(res);
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}


Measured memory_bytes: 2560
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

N = int(input())
ans = [INF]*26

for i in range(N):
	S = list(input())
	alpha_count = [0]*26
	for s in S:
		ind = atoz.index(s)
		alpha_count[ind] += 1

	for j in range(26):
		ans[j] = min(ans[j],alpha_count[j])

ans_str = ''
for i,num in enumerate(ans):
	for j in range(num):
		ans_str = ans_str + atoz[i]

print(ans_str)

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

#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
#define DEBUG(x) cerr << #x << " = " << x << endl

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> inline T tabs(T a) { return (a > 0) ? a : -a; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

const int N = 100005;
int a[N];

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);
	
	int n, L;

	cin >> n >> L;
	REPU(i, 0, n) {
		cin >> a[i];
	}
	int ind = -1;
	REPU(i, 1, n) {
		if (a[i] + a[i - 1] >= L) {
			ind = i; break;
		}
	}
	if (ind == -1) {
		puts("Impossible"); return 0;
	}
	puts("Possible");
	REPU(i, 1, ind) {
		printf("%d\n", i);
	}
	REPD(i, n - 1, ind) {
		printf("%d\n", i);
	}
	printf("%d\n", ind);
	
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
struct Cell
{
	int x,y;
};
int val[1005][1005];
queue<Cell> q;
int x[4]={-1,0,0,1};
int y[4]={0,-1,1,0};
int h,w;
bool safe(int i,int j)
{
	if(i>=1&&i<=h&&j>=1&&j<=w)
		return true;
	else
		return false;
}
void bfs()
{
	int i,j,u,v;
	while(!q.empty())
	{
		//cout<<q.size()<<endl;
		Cell temp=q.front();
		q.pop();
		i=temp.x;j=temp.y;
		for(int k=0;k<=3;k++)
		{
			u=i+x[k];
			v=j+y[k];
			if(safe(u,v))
			{
				if(val[u][v]==-1)
				{
					val[u][v]=val[i][j]+1;
					Cell temp1;
					temp1.x=u;temp1.y=v;
					q.push(temp1);
				}
			}
		}
	}
}
int main()
{
	int i,j,max1=-1;string s;
	cin>>h>>w;
	memset(val,-1,sizeof(val));
	for(i=1;i<=h;i++)
	{
		cin>>s;
		for(j=1;j<=w;j++)
		{
			if(s[j-1]=='#')
			{
				Cell temp;
				temp.x=i;temp.y=j;
				q.push(temp);
				val[i][j]=0;
			}
		}
	}
	bfs();
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
			max1=max(max1,val[i][j]);
	}
	cout<<max1<<endl;
}


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

const int maxn = 50 + 5;
int N;
double mem[maxn];

double solve()
{
	sort(mem, mem+N);
	for(int i = 0; i < N-1; i++)
	{
		mem[i+1] = (mem[i]+mem[i+1])/2;
	}
	return mem[N-1];
}

int main()
{
	cin >> N;
	for(int i = 0; i < N; i++) cin >> mem[i];
	printf("%lf\n", solve());
}

Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int a,b;
	cin>>a>>b;
	cout<<lcm(a,b);
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}







Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define int long long
const int MOD = 1e9 + 7;
using namespace std;
void solve() {
    int d,t,s;
    cin>>d>>t>>s;
    if(((double)d/s)<=t) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";

}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

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

		switch (str1 + str2){
			case("HH"):System.out.println("H"); break;
			case("DH"):System.out.println("D"); break;
			case("HD"):System.out.println("D"); break;
			case("DD"):System.out.println("H"); break;
		}

	}
}

Measured memory_bytes: 21712
/*  -*- coding: utf-8 -*-
 *
 * 2781.cc: Help the Princess!
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 200;
const int MAX_W = 200;
const int INF = 1 << 30;

const int dxs[] = { 1, 0, -1, 0 }, dys[] = { 0, -1, 0, 1 };

/* typedef */

typedef pair<int,int> pii;
typedef queue<pii> qpii;

/* global variables */

char flds[MAX_H][MAX_W + 4];
int dists[MAX_H][MAX_W];

/* subroutines */

bool bfs(qpii &q, int gx, int gy, int h, int w) {
  while (! q.empty()) {
    pii u = q.front(); q.pop();
    int &ux = u.first, &uy = u.second;
    if (ux == gx && uy == gy) return true;

    int vd = dists[uy][ux] + 1;
    
    for (int di = 0; di < 4; di++) {
      int vx = ux + dxs[di], vy = uy + dys[di];
      if (vx >= 0 && vx < w && vy >= 0 && vy < h &&
	  flds[vy][vx] == '.' && dists[vy][vx] > vd) {
	dists[vy][vx] = vd;
	q.push(pii(vx, vy));
      }
    }
  }

  return false;
}

/* main */

int main() {
  int h, w;
  scanf("%d%d", &h, &w);

  int px, py, gx, gy;
  qpii q;

  for (int y = 0; y < h; y++) {
    scanf("%s", flds[y]);
    fill(dists[y], dists[y] + w, INF);
    for (int x = 0; x < w; x++)
      switch (flds[y][x]) {
      case '@': px = x, py = y, flds[y][x] = '.'; break;
      case '%': gx = x, gy = y, flds[y][x] = '.'; break;
      case '$': q.push(pii(x, y)), dists[y][x] = 0, flds[y][x] = '.'; break;
      }
  }

  bfs(q, -1, -1, h, w);
  //for (int y = 0; y < h; y++) {
  //for (int x = 0; x < w; x++) printf("%d ", dists[y][x]);
  //putchar('\n');
  //}

  dists[py][px] = 0;
  q.push(pii(px, py));
  bool ok = bfs(q, gx, gy, h, w);
  if (ok) puts("Yes");
  else puts("No");
  return 0;
}



Measured memory_bytes: 3484
#include <iostream>
using namespace std;
typedef long long ll;
ll n,m;
ll ans;
inline void dfs(ll x,ll y){
	if(x%y==0){
		ans+=x*2-y;
		return ;
	}
	else{
		ans+=(x-x%y)*2;
		dfs(y,x%y);
	}
}
main(){
	cin>>n>>m;
	ans=n;
	n-=m;
	dfs(max(n,m),min(n,m));
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)
l = [0 for i in range(n)]
cou = 0
for i in range(n):
  k = s[i]
  if k=="B":
    l[i] += 1+l[i-1]
  else:
    l[i] += l[i-1]
    cou += l[i]
#  print(l)
print(cou)

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

int main() {
  int n;
  cin >> n;
  queue<int> q[n+1];
  for ( int i = 1; i <= n; i++ ) {
    for ( int k = 1; k < n; k++ ) {
      int en;
      cin >> en;
      q[i].push(en);
    }
  }

  queue<int> today, tomorrow;
  for ( int i = 1; i <= n; i++ ) { today.push(i); }

  vector<vector<bool>> done(n+1, vector<bool>(n+1, false));
  int day = 0;
  int game_num = 0;
  
  while ( !today.empty() ) {
    day++;
    // 今日の試合チェック
    while ( !today.empty() ) {
      int team1 = today.front(); today.pop();
      int team2 = q[team1].front();
      done[team1][team2] = true;

      if ( done[team1][team2] == done[team2][team1] ) {
        q[team1].pop();
        q[team2].pop();
        game_num++;
        if ( !q[team1].empty() ) { tomorrow.push(team1); }
        if ( !q[team2].empty() ) { tomorrow.push(team2); }
      }
    }
    // 明日の試合のセット
    while ( !tomorrow.empty() ) {
      today.push(tomorrow.front());
      tomorrow.pop();
    }
  }

  if ( game_num != n*(n-1)/2 ) { day = -1; }
  cout << day << endl;
  return 0;
}


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

int n,W;
vector<ll>w,v;

ll knapsack()
{
  vector<vector<ll>>dp(n,vector<ll>(W+1));
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<=W;j++)
    {
      if(j==0)
        dp[i][j]=0;
      else if(i==0)
      {
        if(w[i]<=j)
        {
          dp[i][j]=v[i];
        }
        else 
          dp[i][j]=0;
      }
      else
      {
        if(w[i]<=j)
        {
          dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
        }
        else
          dp[i][j]=dp[i-1][j];
      }
    }
  }
  return dp[n-1][W];
}
int main()
{
  cin>>n>>W;
  w=vector<ll>(n);
  v=vector<ll>(n);
  for(int i=0;i<n;i++)
    cin>>w[i]>>v[i];
  cout<<knapsack()<<endl;
}

Measured memory_bytes: 79488
/*
    アリナ・グレイはかわいい
*/

#include<bits/stdc++.h>
using namespace std;
#define itn int
#define endl "\n"

int main(void){
    int n;
    cin >> n;
    long long int a[n],num[n];
    for(int i = 0;i < n;i++)cin >> a[i];
    
    num[0] = a[0];
    for(int i = 1;i < n;i++)num[i] = num[i-1] + a[i];
    
    long long int sum = abs(num[0] - (num[n-1] - num[0]));
    for(int i = 1;i < n-1;i++)sum = min(sum,abs(num[i]-(num[n-1]-num[i])));
    
    cout << sum << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 0x3f3f3f3f;
const int MAX_N = 1006;

int N;
int a[MAX_N][MAX_N];
queue<int> g[MAX_N];
int step[MAX_N];

void solve()
{
	for(int i=1;i<=N;++i)for(int j=1;j<=N-1;++j)g[i].push(a[i][j]);
	queue<int> que;
	for(int i=1;i<=N;++i)que.push(i);
	int day = 0;
	int M = N*(N-1)/2;
	while(!que.empty()){
		queue<int> nex;
		while(!que.empty()){
			int host = que.front(); que.pop(); //current host playing
			if(g[host].empty()) continue; // done with its matches
			int away = g[host].front();
			if(step[host]<=day&&step[away]<=day&&!g[away].empty()&&g[away].front()==host){
				step[host]=step[away]=day+1;
				nex.push(host);
				nex.push(away);
				M--;
				g[host].pop(), g[away].pop();
			}
		}
		day++;
		if(M==0) break;
		swap(que, nex);
	}
	if(M) cout << -1;
	else cout << day;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N;
	for(int i=1;i<=N;++i){
		for(int j=1;j<=N-1;++j){
			cin >> a[i][j];
		}
	}
	solve();
	return 0;
}

Measured memory_bytes: 8704
#include<cstdio>
using namespace std;
int main()
{
    char c[4];
    for(int i=0;i<4;i++)    scanf("%c",&c[i]);
    if(c[0]==c[1]&&c[1]==c[2]||c[1]==c[2]&&c[2]==c[3])
         printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

using namespace std;

constexpr int MOD = 1000000007;

using Long = long long;
template<typename T>
using V = vector<T>;
template<typename T>
using Vv = V<V<T>>;
using Vb = V<bool>;
using Vvb = V<Vb>;
using Vi = V<int>;
using Vvi = V<Vi>;
using Vl = V<Long>;
using Vvl = V<Vl>;
using Vd = V<double>;
using Vvd = V<Vd>;
using Vs = V<string>;

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

template <typename First, typename Second>
istream& operator>>(istream& is, pair<First, Second>& v) {
    for (auto& x : v) {
        is >> v.first >> v.second;
    }
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for (const auto& x : v) {
        os << x << ' ';
    }
    return os;
}

// *** SOLUTION BEGIN ***

Long f(vector<int>& a, vector<int>& b) {
    int n = a.size();
    Vi used;

    for (int maxK = 50; maxK > 0; maxK--) {
        int mat[51][51];
        for (int i = 0; i <= 50; ++i) {
            for (int j = 0; j <= 50; ++j) {
                mat[i][j] = i == j ? 0 : 51;
            }
        }
        for (int s = 1; s <= 50; ++s) {
            for (int d = s - 1; d >= 0; --d) {
                for (int k : used) {
                    mat[s][d] = min(mat[s][d], mat[s % k][d]);
                }
                for (int k = 1; k <= maxK; ++k) {
                    mat[s][d] = min(mat[s][d], max(k, mat[s % k][d]));
                }
            }
        }
        int k = 0;
        for (int i = 0; i < n; ++i) {
            if (a[i] != b[i]) {
                k = max(k, mat[a[i]][b[i]]);
            }
        }
        if (k == 51) {
            return -1;
        }
        if (k > 0) {
            used.push_back(k);
        }
    }
    Long ans = 0;
    for (int k : used) {
        ans += 1ll << k;
    }
    return ans;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    cin >> a >> b;
    cout << f(a, b);
}

// *** SOLUTION END ***

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


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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N,M,K;
    cin>>N>>M>>K;
    vector<ll> A(N),B(M);
    REP(i,N) cin>>A[i];
    REP(i,M) cin>>B[i];
    vector<ll> sum_A(N+1,0),sum_B(M+1,0);
    REP(i,N){
        sum_A[i+1]=sum_A[i]+A[i];
    }

    REP(i,M){
        sum_B[i+1]=sum_B[i]+B[i];
    }

    ll ans=0;
    REP(i,N+1){
        ll time=K-sum_A[i];
        if(time<0) break;
        ll b=0;
        auto itr=upper_bound(sum_B.begin(),sum_B.end(),K-sum_A[i]);
        if(itr!=sum_B.begin()){
            itr--;
            b=itr-sum_B.begin();
        }
        ans=max(ans,i+b);
    }
    cout<<ans<<endl;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	long long ans = 1;
	for(int i = 0; i < n; i++) {
		long long t;
		cin >> t;
		ans = t / __gcd(t, ans) * ans;
	}
	cout << ans << endl;
	return 0;	
}


Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N,R = map(int,input().split())

    if N >= 10:
        res = R
    else:
        res = R + 100 * (10 - N)

    print(res)



main()


Measured memory_bytes: 2940
n = int(input())
#a, b = map(int, input().split())
bl = list(map(int, input().split()))
#al=[list(input()) for i in range(n)]

al = [0]*n
al[-1] = bl[-1]
for i in range(n-2, -1, -1):
    if bl[i] < al[i+1]:
        al[i+1] = bl[i]
    al[i] = bl[i]
print(sum(al))


Measured memory_bytes: 9120
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int64_t w,h;
  cin>>w>>h;

  std::vector<std::pair<int64_t,int>> vec;
  for(int i=0;i<w;i++){
    int p;
    cin>>p;
    vec.push_back(std::make_pair(p,0));
  }
  for(int i=0;i<h;i++){
    int q;
    cin>>q;
    vec.push_back(std::make_pair(q,1));
  }
  std::sort(vec.begin(), vec.end());
  int64_t result=0;
  int r=0,c=0;
  for(auto v:vec){
    if(v.second==0){
      c++;
      result+=std::max(0l,v.first*(h+1-r));
    }else{
      r++;
      result+=std::max(0l,v.first*(w+1-c));
    }
  }

  cout<<result<<endl;





  return 0;
}

Measured memory_bytes: 6512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            double[] V = ReadDoubles();
            Console.WriteLine(V[0] / V[1]);
        }
    }
}


Measured memory_bytes: 11220
# coding: utf-8
# Your code here!
# Your code here!
import collections
n=int(input())
e=[]
o=[]
a=input().split(" ")
for i in range(n):
    if(i%2==0):
        e.append(a[i])
    else:
        o.append(a[i])
#print(e,o)
e_c=collections.Counter(e)
e_m=e_c.most_common()
e1=e_m[0][1]

o_c=collections.Counter(o)
o_m=o_c.most_common()
o1=o_m[0][1]

ans=n-(e1+o1)
if(o_m[0][0]==e_m[0][0]):
    if(len(o_m)<2):
        o2=0
    if(len(e_m)<2):
        e2=0
    else:
        e2=e_m[1][1]
        o2=o_m[1][1]
    ans_list=[n-(o1+e2),n-(e1+o2)]
    ans=min(ans_list)
print(ans)

Measured memory_bytes: 26604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> o_tree;

const int N=2e5+5;
ll ans[N];

ll cal(ll x)
{
   ll res = 0;
   ll xx=x;
   // cout<<"called "<<x<<"\n";
   while (x > 0)
   {
      if(ans[x]!=-1)
      {
         return res+ans[x];
      }
      // cout<<x<<"\n";
      ll no = __builtin_popcountll(x);
      x %= no;
      
      res++;
   }

   return res;
}

long long power(long long x, long long y, long long p)
{
long long res = 1;


x = x % p;


while (y > 0)
{
if (y & 1)
res = (res*x) % p;


y = y>>1;
x = (x*x) % p;
}
return res;
}

void solve()
{
   ll i;
   memset(ans,-1,sizeof(ans));
   ans[0]=0;
   //    cout<<cal(1)<<"\n";
   ll n;
   cin>>n;
   string s;
   cin>>s;
   ll no0=0,no1=0;
   for(i=0;i<n;i++)
   {
      no0+=(s[i]=='0');
      no1+=(s[i]=='1');
   }
   // cout<<no0<<" "<<no1<<"\n";

   for (i = 1; i < N; i++)
   {
      ll no = cal(i);
      ans[i]=no;
   }

   ll noo1=0,noo2=0;
   
   for(i=0;i<n;i++)
   {
      if(s[i]=='1'){
      ll no = power(2ll,n-1-i,no1+1);
      noo1+=no;
      noo1%=(no1+1);
      }
   }

   if(no1>1)
   {
      for(i=0;i<n;i++)
      {
         if(s[i]=='1'){
         ll no = power(2ll,n-1-i,no1-1);
         noo2+=no;
         noo2%=(no1-1);
         }
      }
   }
   // cout<<noo1<<" "<<noo2<<"\n";

   for(i=0;i<n;i++)
   {
      if(s[i]=='0')
      {
         ll noo=no1+1;
         ll tans = noo1;
         tans+=(power(2ll,n-1-i,noo));
         tans%=noo;
         // cout<<tans<<" -- ";
         cout<<ans[tans]+1<<"\n";
         continue;
      }
      else{
         ll noo=no1-1;
         if(noo==0)
         {
            cout<<0<<"\n";
            continue;
         }
         ll tans = noo2;
         tans-=power(2ll,n-1-i,noo);
         tans%=noo;
         tans+=noo;
         tans%=noo;
         cout<<ans[tans]+1<<"\n";
         continue;

      }
   }
}

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

   if (fopen("input.txt", "r"))
   {
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
   }
   cout << setprecision(20);

   ll t = 1;

   // cin>>t;

   while (t--)
   {
      solve();
   }

   return 0;
}

Measured memory_bytes: 5296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  


int main(){
  ll a, b, n;   cin >> a >> b >> n;
  ll x = min(n, b-1);
  cout << a*x/b-a*(x/b) << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <numeric>
#include<algorithm>
#include <cmath>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(){
    int x, y;
    cin >> x >> y;
    if(y%2 == 1) cout << "No" << endl;
    else if( y>=2*x && y<=4*x) cout << "Yes"<<endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3608
N = int(input())
originalN = 0 +N
if N == 2:
  print(1)
  exit()
ans = 0
primenum = [2]
count = [0 for _ in range(int(N**0.5)+2)]
for k in range(3, len(count), 2):
  if count[k] == 0:
    primenum.append(k)
    for j in range(k, len(count), k):
      count[j] = 1
    
def factorization(n):
  lis = []
  k = 0
  while primenum[k] <= n:
    if n%primenum[k] == 0:
      c = 0 
      while n%primenum[k] == 0:
        n //= primenum[k]
        c += 1
      lis.append([primenum[k], c])
    else:
      k += 1
      if k > len(primenum)-1:
        break
  if n > 1:
    lis.append([n, 1])
  return lis

list1 = factorization(N-1)
#print(factorization(N-1))
ans1 = 1
for k in range(len(list1)):
  ans1*= list1[k][1]+1
ans1 -= 1
ans += ans1

#print(ans1)

def operation(K):
  N = originalN
  while N%K == 0:
    N //= K
  if N%K == 1:
    return True
  else:
    return False

list2 = factorization(N)
#print(list2)
factorlist = [1]

for l in range(len(list2)):
  list3 = []
  for j in range(list2[l][1]):
    for k in range(len(factorlist)):
      list3.append(factorlist[k]*list2[l][0]**(j+1))
  factorlist += list3

factorlist = factorlist[1:-1]
#print(factorlist)
ans2 = 1
for item in factorlist:
  if operation(item):
    #print(item)
    ans2 +=1


ans += ans2
#print(ans2)

print(ans)

Measured memory_bytes: 20132
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int a,b,c,d;
    long long int sum1,sum2;

    while(scanf("%d%d%d%d",&a,&b,&c,&d) != EOF)
    {
        sum1 = a * b;
        sum2 = c * d;
        if(sum1 > sum2)
            printf("%lld\n",sum1);
        else printf("%lld\n",sum2);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll a, b, k;
    cin >> a >> b >> k;

    ll cnt = 0;
    for(ll i = 100; i >= 1; i--) {
        if(a%i == 0 && b%i == 0) {
            cnt++;
        }
        if(cnt == k) {
            out(i);
            re0;
        }
    }
    
    re0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      a = l[i]
      b = l[j]
      c = l[k]
      if a == b or b == c or c == a:
        continue
      if l[i] + l[j] > l[k]:
        ans += 1
print(ans)

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;
typedef long long ll;



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

    int cnt = 0;
    int ans = 0;
    vector<int> C1(26);
    vector<int> C2(26);
    for(int i=0; i<N; i++){
        for(int j=0; j<i; j++){
            for(int k=i; k<N; k++){
                if(C1[S[j]-'a'] != 1 && C2[S[k]-'a'] != 1 && S[j]==S[k]) cnt++;
                C2[S[k]-'a'] = 1;

            }
            C1[S[j]-'a'] = 1;
            C2.clear();
            C2.resize(26);
        }
        ans = max(ans, cnt);
        cnt = 0;
        C1.clear();
        C1.resize(26);
    }

    cout << ans << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1, ll y1, ll x2, ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll x;
	cin >> x;
	f(i, 0, C)
	{
		char flag = 'N';
		f(j, -i-1, i + 2)
		{
			if (power(i, 5) - power(j, 5) == x)
			{
				cout << i << " " << j;
				flag = 'Y';
				break;
			}
		}
		if (flag == 'Y')
			break;
	}
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <bitset>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

////const long long MOD = 1000000007;
//
void solve(long long N, std::vector<unsigned long long> A){
    ll cnt=0;
    unsigned long long mask=1;
    
    ll ans=0;
    rep(i,61){
        rep(j,N){
            if(A[j]&mask)cnt++;
        }
        ans+=((((cnt*(N-cnt))%MOD)*(mask%MOD))%MOD);
        ans%=MOD;
        cnt=0;
        mask<<=1;
    }
    op(ans)
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<unsigned long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
//const int MAX_N = 1000 + 10;
//char s[MAX_N];
int has[ 4 ];
int main() {
	string s; cin >> s;
	// map< char, int > mp;
	// mp[ ]
	for( int i = 0; i < s.size(); ++i ){
		if( s[ i ] == 'N' ) has[ 0 ] = 1;
		else if( s[ i ] == 'W' ) has[ 2 ] = 1;
		else if( s[ i ] == 'E' ) has[ 1 ] = 1;
		else has[ 3 ] = 1;
	}
	for( int i = 0; i < 4; ++i )
		if( has[ i ] and not has[ 3 - i ] ){
			cout << "No" << endl;
			return 0;
		}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256