akhauriyash/Code-Regression huggingface dataset:
import math 
n=int(input())
s=math.factorial(n)
mod=10**9+7
i=2
cnt=0
ans=1
while s!=1:
	if s%i==0:
		cnt+=1
		s//=i
	else:
		ans*=(cnt+1)
		cnt=0
		i+=1
print(ans*(cnt+1)%mod)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int H,W;
  	cin >> H >> W;
  	vector<vector<char>> data(H+2, vector<char>(W+2));
 	for(int i = 0;i<H+2;i++){
    	for(int j = 0;j<W+2;j++){
        	data.at(i).at(j) = '#';
        }
    }
  	for(int i = 0;i< H;i++){
    	for(int j = 0;j<W;j++){
        	cin >> data.at(i+1).at(j+1);
        }
    }
  	for(int i = 0;i<H+2;i++){
    	for(int j = 0;j<W+2;j++){
        	cout << data.at(i).at(j);
        }
      	cout << endl;
    }
}


Measured memory_bytes: 256
import java.util.*
import kotlin.math.absoluteValue

fun main() {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val ls = (1..n).map { sc.nextInt() }
    val result = calc(n, ls)

    println(result.toString())
}

fun calc(n: Int, ls: List<Int>): Int {
    var cnt = 0
    ls.forEachIndexed { aindex, a ->
        ls.forEachIndexed { bindex, b ->
            ls.forEachIndexed { cindex, c ->
                if((b - c).absoluteValue < a && a < b + c && aindex != bindex && bindex != cindex && aindex != cindex && a < b && b < c) cnt++
            }
        }
    }
    return cnt
}


Measured memory_bytes: 39960
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>

using namespace std;

int main() {
	int N;
	cin >> N;
	map<string, int> mp;

	string s;
	string pres;
	cin >> pres;
	++mp[pres];
	for (int i = 1; i < N; ++i) {
		cin >> s;
		if (pres.back() != s[0] || mp[s] != 0) {
			cout << "No" << endl;
			return 0;
		}
		++mp[s];
		pres = s;
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
// Last Change: 06/13/2019 18:36:31.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  vector<ll> ipt(3);
  for (auto &&e : ipt) {
    cin >> e;
  }

  sort(ipt.begin(), ipt.end());

  int cnt = 0;
  for (auto &&e : ipt) {
    cout << e;
    if (cnt != 2) {
      cout << ' ';
    }
    ++cnt;
  }
  cout << endl;

  //NS::LoopUntilZeroInpput();
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
typedef short ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
#define INF (30000)
ll gcd (ll a,ll b) {
	if(b == 0) {
		return a;
	}
	return gcd(b,a % b);
}

ll n,ma,mb,a[100],b[100],c[100];
ll dp[2][2500][2500];

int main(){

	cin >> n;

	cin >> ma >> mb;

	REP(i,n) {
		cin >> a[i] >> b[i] >> c[i];
	}

	REP(k,2){
		REP(i,1001) {
			REP(j,1001) {
				dp[k][i][j] = INF;
			}
		}
	}
	dp[0][0][0] = 0;

	REP(i,n) {
		REP(k,1001) {
			REP(l,1001) {
				dp[(i + 1) & 1][k + a[i]][l + b[i]] = min(dp[(i + 1) & 1][k + a[i]][l + b[i]],(short)(dp[i & 1][k][l] + c[i]));
				dp[(i + 1) & 1][k][l] = min(dp[(i + 1) & 1][k][l],dp[i & 1][k][l]);
			}
		}
		REP(k,1001) {
			REP(l,1001) {
				dp[i & 1][k][l] = INF;
			}
		}
	}
	
	ll ans = INF;
	FOR(i,1,1001) {
		FOR(j,1,1001) {
			ll g = gcd(i,j);

			if(i / g == ma && j / g == mb) {
				ans = min(ans,dp[n & 1][i][j]);
			}
		}
	}
	if(ans < INF) {
		cout << ans << endl;
	}else {
		cout << -1 << endl;
	}
	return 0;
}



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

// 最大公約数
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

  ll ans = 0;
  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++) {
        ans += gcd(gcd(a, b), c);
      }
    }
  }

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

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

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long ret = 0;
            ret += x[1];
            int[] a = new int[] { x[0],x[3],x[4] }; long aret = 0;
            aret += a[0] / 2 * 2; aret += a[1] / 2 * 2; aret += a[2] / 2 * 2;
            int[] b = new int[] { x[0] - 1,x[3] - 1,x[4] - 1 }; long bret = 0;
            bret += b[0] / 2 * 2; bret += b[1] / 2 * 2; bret += b[2] / 2 * 2;
            Console.WriteLine(ret + Math.Max(aret,b.Min() >= 0 ? bret + 3 : 0));
        }
    }
}

Measured memory_bytes: 13396
# for #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict

def main():
	# for t in range(int(input())):
	n = int(input())
	l = [int(j) for j in input().split()]
	dp = dict()
	dp[0,0] = 0
	dp[2,1] = max(l[0], l[1])
	dp[1,1] = l[0]
	dp[2,2] = -1e14
	dp[1, 0] = 0
	for i in range(3,n+1):
		for j in [(i//2), (i+1)//2]:
			# print(i, j)
			# if (i+j)%2==1:
			dp[i, j] = dp[i-2, j-1]+l[i-1]
			if i>=2*j:
				dp[i, j] = max(dp[i-2, j-1]+l[i-1], dp[i-1, j])				
				
			# else:
			# dp[i, j] = dp[i-2, j-1]+l[i-1]

			# if dp[i, j]
	print(dp[n, (n)//2])
		


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = "x" in file.mode or "r" not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b"\n") + (not b)
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode("ascii"))
		self.read = lambda: self.buffer.read().decode("ascii")
		self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
	main()

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

int n;cin>>n;
  ll a=0;
  for(int i=1;i<(n+1);i++){
    if(i%5!=0&&i%3!=0){a=a+i;}
  }
cout<<a<<endl;
}



Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;

const int N=1e5+20;

int n,u,v,a,b,dp[2][N],ans;
vector <int> adj[N];

void dfs(int node,int parent,int idx,int depth=0)
{
	dp[idx][node]=depth;
	for(auto child:adj[node])
		if(child!=parent)
			dfs(child,node,idx,depth+1);
}

int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for(int i=0;i<n-1;i++)
	{
		scanf("%d%d",&u,&v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	dfs(a,0,0),dfs(b,0,1);
	for(int i=1;i<=n;i++)
		if(dp[0][i]<=dp[1][i])
			ans=max(ans,dp[1][i]-1);
	printf("%d",ans);
}

Measured memory_bytes: 11648
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		// 整数の入力
		String a = sc.next();

		if (a.endsWith("s")) {
			System.out.println(a + "es");
		} else {
			System.out.println(a + "s");
		}


	}
}

Measured memory_bytes: 38412
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int X,A;cin>>X>>A;
  
  if(X>=A){
    cout<<10<<endl;
  }
  else{
    cout<<0<<endl;
  }
}


Measured memory_bytes: 3592
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
C = list(map(int, input().split()))

res = -10**10

for i in range(N):
    j = i
    total = 0
    loop_values = []

    while True:
        j = P[j] - 1
        loop_values.append(C[j])
        total += C[j]
        if j == i:
            break
    
    loop_length = len(loop_values)
    point_sum = 0

    for j in range(loop_length):
        point_sum += loop_values[j]
        result_cand = point_sum

        if j+1 > K:
            break

        if total > 0:
            loop_num = (K - j - 1) // loop_length
            result_cand += total * loop_num
        
        if res < result_cand:
            res = result_cand

print(res)

Measured memory_bytes: 81040
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if (a+b>c+d) cout << "Left" << endl;
  else if (a+b==c+d) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(lambda x:int(x)-1,input().split()))

ans=-1
l=[-1]*n
now=0
i=1
result=[0]
while i<=k:
    now=a[now]
    if l[now]!=-1:
        
        length=i-l[now]
        d=(k-i)%length+l[now]
        ans=l.index(d)
        break
    l[now]=i
    i+=1
    
if ans!=-1:
    print(ans+1)
else:
    print(now+1)

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	int n;
	cin>>n;
	vl a(n),b(n),c(n);//cin>>a>>b>>c;
	ll dp[n][3];
	repi(i,n){
	cin>>a[i]>>b[i]>>c[i];
	 dp[i][0]=dp[i][1]=dp[i][2]=0;
	 }
	dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];
	for(int i=1;i<n;++i){
		dp[i][0]=a[i]+Max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=b[i]+Max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=c[i]+Max(dp[i-1][1],dp[i-1][0]);
	}
	db(Max(Max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]));
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a == b) {
			System.out.println(c);
		} else if (a == c) {
			System.out.println(b);
		} else {
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 35704
_n = gets.strip.to_i
a = gets.strip.split.map(&:to_i).sort.reverse

sum_even = 0
sum_odd = 0
a.each_with_index do |n, i|
  if i.even? 
    sum_even += n
  else
    sum_odd += n
  end
end
  
puts sum_even - sum_odd


Measured memory_bytes: 1916
#include <iostream>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <string>
#include <cctype>
#include <string.h>
#include <ctime>  
using namespace std;

int mark[100001],a[100001];

int main()
{
	int x,c,n,i,j,k,y,z;
	cin>>n;
	for (i=1;i<=n;i++) cin>>a[i];
	
	x=1;
	c=0;
	while (x!=2)
	{
		c++;
		x=a[x];
		if (mark[x]) break;	
		mark[x]=1;
	}
	
	if (x==2) 
		cout<<c<<endl;
	else 
		cout<<"-1"<<endl;
	
	return 0;
}


Measured memory_bytes: 1024
$A, $B, $C, $X, $Y = gets.split.map(&:to_i)
$ans = 0

def solve()
    a = [$A,2*$C].min
    b = [$B,2*$C].min
    diff = ($X-$Y).abs
    diff_val = $X > $Y ? a*diff : b*diff

    $ans = [a*$X + b*$Y, 2*$C*([$X,$Y].min) + diff_val].min
end

solve
puts $ans


Measured memory_bytes: 1788
N = int(input())

ans = N*(N+1)*0.5

fizz = int(N/3)
buzz = int(N/5)
fizzbuzz = int(N/15)

fizzsum = 3*0.5*fizz*(fizz+1)
buzzsum = 5*0.5*buzz*(buzz+1)
fizzbuzzsum = 15*0.5*fizzbuzz*(fizzbuzz+1)

ans = ans - fizzsum - buzzsum + fizzbuzzsum

print(int(ans))

Measured memory_bytes: 9128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int max_status = 1;
	for(int i = 0; i < n; i++) {
		max_status *= 2;
	}
	vector<int> cost(max_status, -1);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		vector<bool> kc(n, false);
		for(int j = 0; j < b; j++) {
			int c;
			cin >> c;
			c--;
			kc[c] = true;
		}
		int cur = 0;
		for(int i = 0; i < n; i++) {
			cur *= 2;
			if (kc[i]) {
				cur++;
			}
		}
		if (cost[cur] == -1) {
			cost[cur] = a;
		} else if (cost[cur] >= a) {
			cost[cur] = a;
		}
	}
	int zero_start = 0;
	int one_start = 0;
	int one_end =  max_status;
	for (int i = n - 1; i >= 0; i--) {
		one_start |= (1 << i);
		for (int j = zero_start; j < one_start; j++) {
			for (int k = one_start; k < one_end; k++) {
				if(cost[j] == -1) continue;
				if(cost[k] == -1) continue;
				int next_key = j | k;
				int next_cost = cost[j] + cost[k];
				if (cost[next_key] == -1) {
					cost[next_key] = next_cost;
				} else {
					if (cost[next_key] > next_cost) {
						cost[next_key] = next_cost;
					}
				}

			}
		}
		zero_start = one_start;
	}
	
	cout << cost[max_status - 1] << endl;

	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, k;
  cin >> n >> k;
  int left = 0, right = 0, mid;
  vector<int> x(n);
  arep(i, x) cin >> i, chmax(right, i);
  sort(all(x));
  ++right;

  auto f = [&](int now) {
    int cnt = 0;
    rep(i, 0, n) cnt += ((x[i] - 1) / now);
    return cnt <= k;
  };

  while (right - left > 1) {
    mid = (left + right) / 2;
    if (f(mid))
      right = mid;
    else
      left = mid;
  }

  cout << right << '\n';
  return 0;
}

Measured memory_bytes: 4716
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int e;
    while (cin>>e) {
        if (e==0) {
            break;
        } else {
            int min=1000000;
            int z_size=cbrt(e);
            int y_size=sqrt(e);
            for (int z=0;z<=z_size+1;z++) {
                for (int y=0;y<=y_size;y++) {
                    int x=e-(z*z*z+y*y);
                    if (x>=0&&x+y+z<min) {
                        min=x+y+z;
                    }
                }
            }
            cout<<min<<endl;
        }
    }
}


Measured memory_bytes: 3204
import java.util.Scanner;

public class Main{
    public static void swap(int[] A, int a, int b){
        int s = A[a];
        A[a] = A[b];
        A[b] = s;
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt = 0;
        int[] a = new int[n];
        /*input*/
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        /*sort*/
        for(int i=0; i<n-1; i++){
            int min = i;
            for(int j=i+1; j<n; j++) {
                if(a[j]<a[min]) min=j;
            }
            if(i != min){
                swap(a, i, min);
                cnt++;
            }

        }
        /*output*/
        for(int i=0; i<n-1; i++) System.out.printf("%d ", a[i]);
        System.out.println(a[n-1]);
        System.out.println(cnt);
    }
}



Measured memory_bytes: 26692
#include <bits/stdc++.h>
#define ll long long

using namespace std;
ll findlcm(ll arr[], ll n,ll m) 
{ 
   
   ll ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++){ 
        ans = (((arr[i] * ans)) / 
                (__gcd(arr[i], ans)));
        if(ans>2*m)return 0;          
    }
    return ans; 
} 
int main() {
    
   ll n,m;cin>>n>>m;
   ll a[n];
   for(ll i=0;i<n;i++)cin>>a[i];
   set<ll>s;
   for(ll i=0;i<n;i++){ll c=0;
       ll x=a[i];
       while(x%2==0){x/=2;c++;}
       s.insert(c);
       
   }
   ll l=findlcm(a,n,m);
  // cout<<l<<endl;
  if(!l)cout<<0<<endl;
   else if(s.size()>1){cout<<0<<endl;}
   else cout<<(2*m+l)/(2*l);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,s1;
  cin>>s>>s1;
  int ans = 1001;
  for(int i =0;i+s1.length()-1<s.length();i++)
  {
    int c = 0;
    for(int j =0;j<s1.length();j++)
    {
     if(s[i+j] != s1[j])
       c++;
    }
    ans = min(c,ans);
  }
    cout<<ans;
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
using namespace std;

template<typename Type> class RangeMin {
private:
	int size_;
	std::vector<Type> dat;
public:
	RangeMin() : size_(0), dat(std::vector<Type>()) {};
	RangeMin(int size__) {
		for (size_ = 1; size_ < size__; ) size_ <<= 1;
		dat.resize(size_ << 1, std::numeric_limits<Type>::max());
	}
	template<class T>
	RangeMin(T begin_, T end_) {
		int n = end_ - begin_;
		for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max());
		for (int i = 0; i < n; i++) dat[i + size_] = *(begin_ + i);
		for (int i = size_ - 1; i > 0; i--) dat[i] = std::min(dat[i << 1], dat[(i << 1) + 1]);
	}
	inline unsigned size() { return size_; }
	inline void update(int i, Type x) {
		i += size_; dat[i] = x;
		while (i > 1) {
			i >>= 1;
			dat[i] = std::min(dat[i << 1], dat[i << 1 | 1]);
		}
	}
	inline Type query(int l, int r) {
		Type ret = std::numeric_limits<Type>::max();
		l += size_; r += size_;
		while (l != r) {
			if (l & 1) ret = std::min(ret, dat[l++]); l >>= 1;
			if (r & 1) ret = std::min(ret, dat[--r]); r >>= 1;
		}
		return ret;
	}
};

long long N, X[1 << 18], V[1 << 18], DA[1 << 18], DB[1 << 18], L[1 << 18], R[1 << 18], P[1 << 18], mod = 1000000007;
long long dp[1 << 18], dpr[1 << 18];
vector<pair<long long, long long>> L1, L2;
RangeMin<int> Pmin, Pmax;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> V[i];
		L1.push_back(make_pair(X[i], i));
		L2.push_back(make_pair(V[i], i));
	}
	sort(L1.begin(), L1.end()); L1.erase(unique(L1.begin(), L1.end()), L1.end());
	sort(L2.begin(), L2.end()); L2.erase(unique(L2.begin(), L2.end()), L2.end());

	for (int i = 0; i < L1.size(); i++) DA[L1[i].second] = i + 1;
	for (int i = 0; i < L2.size(); i++) DB[L2[i].second] = i + 1;

	Pmin = RangeMin<int>(N + 2);
	Pmax = RangeMin<int>(N + 2);
	for (int i = 1; i <= N; i++) {
		Pmin.update(DB[i], DA[i]);
		Pmax.update(DB[i], -DA[i]);
	}
	for (int i = 1; i <= N; i++) {
		int LL = Pmin.query(DB[i], N + 1);
		int RR = -Pmax.query(1, DB[i] + 1);
		L[i] = LL; R[i] = RR; P[R[i] + 1] = max(P[R[i] + 1], L[i]); // P[i]: i に黒を追加するときに、前の黒は P[i] かそれ以降
	}
	for (int i = 1; i <= N + 1; i++) P[i] = max(P[i], P[i - 1]);

	dp[0] = 1; dpr[0] = 1;
	for (int i = 1; i <= N + 1; i++) {
		long long T1 = dpr[i - 1]; if (P[i] >= 1) T1 -= dpr[P[i] - 1]; T1 += mod; T1 %= mod;
		dp[i] = T1; dpr[i] = dpr[i - 1] + dp[i]; dpr[i] %= mod;
	}
	cout << dp[N + 1] << endl;
	return 0;
}

Measured memory_bytes: 30300
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    string ans = "";
    rep(i, s.size()){
        if(s[i] == 'B'){
            if(ans != "") ans = ans.substr(0, (int)ans.size() - 1);
        }else{
            ans += s[i];
        }
    }
    cout << ans << endl;
}

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

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

fn main() {
    let a:i64 = read();
    let v:i64 = read();
    let b:i64 = read();
    let w:i64 = read();
    let t:i64 = read();

    if v - w > 0 {
        let s = (a-b).abs();
        let d = (v-w)*t;
        if s <= d {
            println!("YES");
        }else{
            println!("NO");
        }
    }else{
        println!("NO");
    }

}


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

using namespace std;

int main()
{
	long long n, i;
	long long ans = 1e12;
	cin >> n;
	for(i=1; i<=(int)sqrt(n); i++) {
		if(n%i == 0) {
			long long temp = (i-1) + (n/i-1);
			ans = min(ans, temp);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    int ans=0,l=0,r=a.size()-1;
    while(l<r){
        if(a[l]!=a[r]) ans++;
        l++,r--;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll p=1e9+7;
ll n,k,i,mn,mx,ans;
int main(){
	scanf("%lld%lld",&n,&k);
	for(i=k;i<=n+1;i++){
		mn=i*(i-1)/2;
		mx=(n+n-i+1)*i/2;
		ans+=mx-mn+1;
		ans%=p;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 3824
#include<stdio.h>
int main(){
  double r,l;
  int k,i;
  int dr[4]={0};
  int dl[4]={0};
  while(scanf("%lf %lf",&l,&r)!=EOF){
    if     (l<0.2)k=3;
    else if(l<0.6)k=2;
    else if(l<1.1)k=1;
    else          k=0;
    dl[k]++;
    if     (r<0.2)k=3;
    else if(r<0.6)k=2;
    else if(r<1.1)k=1;
    else          k=0;
    dr[k]++;
  }
  for(i=0;i<4;i++){
    printf("%d %d\n",dl[i],dr[i]);
  }
  return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll solve(ll top, ll x){
  if(top == -1)
    return 0;
  else{
    if((top+1)%x == 0)
      return (top+1)/x;
    else
      return (top+1)/x+1;
  }
  }

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

  ll a,b,x;
  cin >> a >> b >> x;

  ll ans = solve(b, x) - solve(a-1, x);

  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
using ll = long long;

int main() {
  int N, M, K;
  cin >> N >> M >> K;
  vector<ll> A(N + 1), B(M + 1);
  rep(i, N) {
    int a;
    cin >> a;
    A[i + 1] = a + A[i];
  }
  rep(i, M) {
    int b;
    cin >> b;
    B[i + 1] = b + B[i];
  }

  int ans = 0, j = M;
  rep(i, N + 1) {
    if (A[i] > K) break;
    while (B[j] > K - A[i]) {
      j--;
    }
    ans = max(ans, i + j);
  }

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


Measured memory_bytes: 6388
mod = 10**9+7
k = int(input())
s = input()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, len(s)+k+5):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(len(s), len(s)+k+1):
  ans += pow(25, i-len(s), mod)*pow(26, k+len(s)-i, mod)*cmb(i-1, len(s)-1, mod)
  ans %= mod
  
print(ans)

Measured memory_bytes: 227204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ret = 0;
            int point = 1;
            for (int i = 0; i < N; i++)
            {
                if (r[i] == point)
                {
                    point++;
                }
                else
                {
                    ret++;
                }
            }

            if (ret == N)
            {
                Console.WriteLine(-1);
            }
            else
            {
                Console.WriteLine(ret);
            }
            
        }
    }
}

Measured memory_bytes: 31708
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

#define REP(i,m,M) for(int i=m; i<M; i++)
#define REPR(i,M,m) for(int i=M; i>m; i—-)
#define REPLL(i,m,M) for(ll i=m; i<M; i++)
#define REPLLR(i,M,m) for(ll i=M; i>m; i—-)
#define ALL(v) v.begin(),v.end()

string minStr[5];
bool bEnd[5];
bool bEndPrev[5];
int K;
string s;

void insert(string s)
{
    for (int k=0; k<K; k++) {
        if (s==minStr[k]) {
            bEnd[k] = true;
            break;
        }
        else if (s<minStr[k]) {
            for (int l=K-1; l>=k+1; --l) {
                minStr[l] = minStr[l-1];
                bEnd[l] = bEnd[l-1];
            }
            minStr[k] = s;
            bEnd[k] = true;
            break;
        }
    }
}

int main(int argc, const char * argv[]) {
    cin >> s >> K;
    string sTmp = "";
    sTmp += ('z'+1);
    for (int k=0; k<K; ++k) {
        minStr[k] = sTmp;
        bEnd[k] = false;
    }
    
    int L = (int) s.size();
    for (int l=0; l<L; ++l) {
        for(int k=0; k<K; ++k){
            bEndPrev[k] = bEnd[k];
            bEnd[k] = false;
        }
        sTmp = "";
        sTmp += s[l];
        string sTmp2[5];
        for (int k=0; k<K; ++k){
            sTmp2[k] = minStr[k];
            if(bEndPrev[k]) sTmp2[k] += s[l];
            else sTmp2[k] = '}';
        }
        insert(sTmp);
        for (int k=0; k<K; ++k) insert(sTmp2[k]);
        
        for (int k=0; k<K; ++k) cerr << minStr[k] << endl;
        cerr << endl;
    }
    
    cout << minStr[K-1] << endl;

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  long long int l[90];
  l[0] = 2;
  l[1] = 1;
  for(int i = 2; i <= n; i++){
    l[i] = l[i-1] + l[i-2];
  }
  cout << l[n] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int N = 10;

int main() {
  vector<int> ms(N);
  REP(i, N) scanf("%d", &ms[i]);
  SORT(ms);
  printf("%d\n%d\n%d\n", ms[N - 1], ms[N - 2], ms[N - 3]);
  return 0;
}

Measured memory_bytes: 3272
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int pn = 0;
int primes[16000000];
int eulnums[16000000];

void eulerprime(int n) {
    fill(eulnums, eulnums + n + 1, 0);
    for (int i = 2; i <= n; i++) {
        if (eulnums[i] == 0) {
            eulnums[i] = i;
            primes[pn] = i;
            pn++;
        }

        for (int j = 0; i * primes[j] <= n; j++) {
            eulnums[i * primes[j]] = primes[j];
            if (i % primes[j] == 0) {
                break;
            }
        }
    }
}

int primepow[16000000];
vector<ll> ansnum;
ll diff;
ll N, S;

ll digsum(ll b, ll n) {
    if (n < b) {
        return n;
    } else {
        return digsum(b, n / b) + n % b;
    }
}

void solve(ll now, ll n) {
    if (n == -1) {
        //cout << "a" << endl;
        solve(now, 0);
        solve(now * diff, 0);
    } else {
        if (n < pn - 1) {
            ll next = n + 1;
            for (int i = n + 1; i < pn - 1; i++) {
                if (primepow[i] != 0) {
                    break;
                } else {
                    next++;
                }
            }
            ll tmp = now;
            for (int i = 0; i <= primepow[n]; i++) {
                //cout << n << endl;
                solve(tmp, next);
                tmp *= primes[n];
            }
        } else {
            ll tmp = now;
            for (int i = 0; i <= primepow[n]; i++) {
                if (digsum(tmp + 1, N) == S) {
                    ansnum.push_back(tmp + 1);
                }
                tmp *= primes[n];
                //cout << tmp << endl;
            }
        }
    }
}

int main() {
    cin >> N;
    cin >> S;
    if (N < S) {
        cout << -1 << endl;
        return 0;
    } else if (N == S) {
        cout << N + 1 << endl;
        return 0;
    }
    diff = N - S;
    eulerprime(1e6);
    //cout << pn << endl;
    fill(primepow, primepow + pn + 10, 0);
    for (int i = 0; i < pn; i++) {
        while (diff % primes[i] == 0) {
            primepow[i]++;
            diff /= primes[i];
        }
    }
    solve(1, -1);
    sort(ansnum.begin(), ansnum.end());
    if (ansnum.size() == 0) {
        cout << -1 << endl;
    } else {
        cout << ansnum[0] << endl;
    }
}


Measured memory_bytes: 8952
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define pop(v) (v).back(); (v).pop_back()
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

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

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

    char in[2][3];
    cin>>in[0]>>in[1];
    YES(in[0][0]==in[1][2]&&in[0][1]==in[1][1]&&in[0][2]==in[1][0]);
}

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

using namespace std;

int main(){
  	cin.tie(0);
    cout.tie(0);
  	ios_base::sync_with_stdio(0);
 	int x;
    cin >> x;
  	if(x <= 0)
      cout << "1";
  	else if( x > 0)
      cout << "0";
  
}

Measured memory_bytes: 3604
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long s = sc.nextLong();
        long[] a = new long[n];
        if (s < Math.pow(10, 9)) {
            Arrays.fill(a, s + 1);
        } else {
            Arrays.fill(a, 1);
        }
        for (int i = 0; i < n; i++) {
            if (i >= k) {
                break;
            }
            a[i] = s;
        }

        StringJoiner sj = new StringJoiner(" ");
        for (int i = 0; i < n; i++) {
            sj.add(String.valueOf(a[i]));
        }
        System.out.println(sj.toString());
    }

}


Measured memory_bytes: 39316
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val a = sc.nextInt()
    val b = sc.nextInt()
    var sa = ""
    var sb = ""
    repeat(a) { sb += b }
    repeat(b) { sa += a }

    println(if (sa < sb) sa else sb)
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}





Measured memory_bytes: 29356
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  int d,i,j,k;
  cin >> d;
  double a[1000]={},b[1000]={};
  for(i=0;i<d;i++) cin >> a[i];
  for(i=0;i<d;i++) cin >> b[i];
  double o1=0,o2=0,o3=0,oe=0;
  for(i=0;i<d;i++){
    o1+=fabs(a[i]-b[i]);
    o2+=fabs(a[i]-b[i])*fabs(a[i]-b[i]);
    o3+=fabs(a[i]-b[i])*fabs(a[i]-b[i])*fabs(a[i]-b[i]);
    oe=max(oe,fabs(a[i]-b[i]));
  }
  printf("%.6f\n",o1);
  printf("%.6f\n",sqrt(o2));
  printf("%.6f\n",pow(o3,1.0/3.0));
  printf("%.6f\n",oe);
  return 0;
}


Measured memory_bytes: 3368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, X, ans=0,D=0;
  cin >> N >> X;
  
  while(D <= X){
    int L;
    cin >> L;
    D += L;
    ans++;
    if(ans == N+1) {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    

int main() {    

    int p, q, r;
    cin >> p >> q >> r;
    vector<int> a {(p + q), (p + r), (q + r) };
    int rtn = *min_element(a.begin(), a.end());
    cout << rtn << endl;
    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
const int64_t INF = 1e15;
const int64_t cut_off = 8*1e14;

int main(){
    int N;
    int64_t A[100010];
    char op[100010];
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>A[i];
        if(i!=N){
            cin>>op[i];
        }
    }
    int64_t dp[3][100010]={};
    for(int i=0;i<100010;i++){
        for(int j=0;j<3;j++){
            dp[j][i]=INF;
        }
    }
    dp[0][1]=A[1];
    for(int i=1;i<=N-1;i++){
        if(op[i]=='-'){
            if(dp[1][i]<cut_off){
                if(dp[2][i]<cut_off){
                    dp[2][i+1]=max(dp[2][i],dp[1][i])+A[i+1];
                }else{
                    dp[2][i+1]=dp[1][i]+A[i+1];
                }
            }
            dp[0][i+1]=dp[0][i]-A[i+1];
            dp[1][i+1]=dp[0][i]-A[i+1];
        }else{
            dp[0][i+1]=dp[0][i]+A[i+1];
            dp[1][i+1]=dp[1][i]-A[i+1];
            dp[2][i+1]=dp[2][i]+A[i+1];
        }
    }
    int64_t res = -INF;
    for(int i=0;i<3;i++){
        if(dp[i][N]<cut_off){
            res = max(res,dp[i][N]);
        }
    }
    cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 3456
n = int(input())
a = input().split()

minus = 0


A = [int(element) for element in a]

A_abs = [abs(element) for  element in A]

for a_num in A:
    if a_num < 0:
        minus = minus + 1


if minus % 2 == 0:
    result = sum(A_abs)

else:
    result = sum(A_abs) - 2*min(A_abs)

print(result)


Measured memory_bytes: 18380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<pii>>;
const int MOD = 1e9 + 7;

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

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

    vector<vector<int>> cnt(N + 3, vector<int>(N + 3));
    for (int i = 0; i < M; ++i) {
        int l, r;
        cin >> l >> r;
        cnt[l][r]++;
    }

    for (int i = 0; i <= N; ++i)
        for (int j = 0; j <= N; ++j)
            cnt[i + 1][j + 1] += cnt[i + 1][j] + cnt[i][j + 1] - cnt[i][j];

    for (int i = 0; i < Q; ++i) {
        int p, q, ans = 0;
        cin >> p >> q;
        p--;
        cout << cnt[q][q] - cnt[q][p] - cnt[p][q] + cnt[p][p] << '\n';
    }

    return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	int N, M;
	while (cin >> N >> M, N || M) {
		vector<int> masu, sai;
		REP(i, 0, N) {
			int a;
			cin >> a;
			masu.push_back(a);
		}
		REP(j, 0, M) {
			int b;
			cin >> b;
			sai.push_back(b);
		}

		int now = 0;
		int cnt = 0;
		REP(j, 0, M) {
			if (now >= N - 1) break;

			cnt++;
			int next = now + sai[j];
			if (next >= N - 1) break;
			
			now += (sai[j] + masu[next]);
		}

		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
import sys
read = sys.stdin.read
from itertools import permutations
def main():
    def warshall_floyd(d):
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j])
        return d
 
    n, m, r = map(int, input().split())
    rs = tuple(map(int, input().split()))
    d = [[10**9] * n for _ in range(n)]
    m = map(int, read().split())
    mmm = zip(m, m, m)
    for s, t, dis in mmm:
        s -= 1
        t -= 1
        d[t][s] = d[s][t] = dis
    for j1 in range(n):
        d[j1][j1] = 0
    res = warshall_floyd(d)
    rsp = tuple(permutations(rs))
    result = float('inf')
    for rspe in rsp:
        res_t = 0
        for i1 in range(r - 1):
            res_t += res[rspe[i1]-1][rspe[i1+1]-1]
        result = min(result, res_t)
    print(result)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 80940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
 
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
 
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n, q;
  cin >> n >> q;
  vector<vector<int>> graph(n, vector<int>{});
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    graph[b - 1].push_back(a - 1);
    graph[a - 1].push_back(b - 1);
  }
  vector<long long> point(n);
 
  rep(i, q) {
    int p, x;
    cin >> p >> x;
    point[p - 1] += x;
  }
 
  vector<bool> seen(n, false);
  queue<int> que;
  que.push(0);
  seen[0] = true;
 
  while (!que.empty()) {
    int curr = que.front();
    que.pop();
    long long curr_point = point[curr];
    for (auto &next : graph[curr]) {
      if (!seen[next]) {
        point[next] += curr_point;
        que.push(next);
        seen[next] = true;
      }
    }
  }
  print(point);
}

Measured memory_bytes: 16372
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> w(26,1);
  int n;
  cin >>n;
  for(int i=0;i<n;i++){
    char W;
    cin >> W;
    w.at(W-'a')++;
  }
  long long ans = 1;
  for(int i:w){
    ans *=i;
    if(ans > 100000009){
      ans %= 1000000007;
    }
  }
  cout << (ans -1)%1000000007;
  
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define endl ('\n')
//#define MOD 1000000007LL
#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[](auto f,auto... args){return f(f,args...);};

int main(){
    string s,t;
    cin>>s>>t;
    t.pop_back();
    if(s==t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3640