akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n, m;cin>>n>>m;
  vector<int> arr(n);
  map<int, int> num;
  rep(i, n)cin>>arr[i];
  sort(arr.begin(), arr.end());
  int pre=-1;
  rep(i, n){
    int s=arr[i]/2, t=2;
    if(pre==s)continue;
    map<int, int> mp;
    while(s>=t*t){
      if(s%t==0){
        s/=t;
        mp[t]++;
      }else{
        t++;
      }
    }
    mp[s]++;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
      num[itr->first]=max(num[itr->first], itr->second);
    }
    pre=arr[i]/2;
  }
  ll ans=1LL;
  for(auto itr=num.begin();itr!=num.end();itr++){
    rep(i, itr->second){
      ans*=ll(itr->first);
      if(m<ans){cout<<0<<endl;return 0;}
    }
  }
  rep(i, n){
  	if((ans/(arr[i]/2))%2LL==0LL){cout<<0<<endl;return 0;}
  }
  cout<<(m/ans-1)/2+1<<endl;
  return 0;
}



Measured memory_bytes: 3584
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	H, W, K := sc.nextInt(), sc.nextInt(), sc.nextInt()
	S := make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = sc.nextStr()
	}
	ans := INF
	for bit := 0; bit < 1<<uint(H-1); bit++ {
		group := 0
		id := make([]int, H)
		for i := 0; i < H; i++ {
			id[i] = group
			if 1<<uint(i)&bit > 0 {
				group++
			}
		}
		group++
		G := make([][]int, group)
		for i := 0; i < group; i++ {
			G[i] = make([]int, W)
		}
		for i := 0; i < W; i++ {
			for j := 0; j < H; j++ {
				if S[j][i] == '1' {
					G[id[j]][i]++
				}
			}
		}
		ok := true
		for i := 0; i < group; i++ {
			for j := 0; j < W; j++ {
				if G[i][j] > K {
					ok = false
				}
			}
		}
		if !ok {
			continue
		}
		now := make([]int, group)
		total := group - 1
		for i := 0; i < W; i++ {
			ok := true
			for j := 0; j < group; j++ {
				now[j] += G[j][i]
				if now[j] > K {
					ok = false
				}
			}
			if !ok {
				total++
				now = make([]int, group)
				for j := 0; j < group; j++ {
					now[j] += G[j][i]
				}
			}
		}
		ans = min(ans, total)
	}

	fmt.Fprintln(wtr, ans)
}


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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int N, A, B;
    cin >> N >> A >> B;

    int x = N / (A + B);
    int ans = x * A;
    int remain = N - (A + B) * x;
    if(remain >= A) { ans += A; }
    else { ans += remain; }

    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int INF = 1 << 22;
int main(){
  int n, m;
  while(true){
    cin >> n >> m;
    if(n == 0 && m == 0){
      break;
    }
    int cost[m+1][m+1], time[m+1][m+1];
    for(int i = 0; i < m+1; ++i){
      for(int j = 0; j < m+1; ++j){
        cost[i][j] = time[i][j] = INF;
      }
    }
    for(int i = 0; i < n; ++i){
      int a, b, c, t;
      cin >> a >> b >> c >> t;
      cost[a][b] = cost[b][a] = c;
      time[a][b] = time[b][a] = t;
    }
    // Warshall-Floyd
    for(int k = 0; k < m+1; ++k){
      for(int i = 1; i < m+1; ++i){
        for(int j = 1; j < m+1; ++j){
          cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
          time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
        }
      }
    }
    int q_num;
    cin >> q_num;
    for(int i = 0; i < q_num; ++i){
      int p, q, r;
      cin >> p >> q >> r;
      if(r == 0){
        cout << cost[p][q] << endl;
      }
      else{
        cout << time[p][q] << endl;
      }
    }
  }    
  return 0;
}

Measured memory_bytes: 1236
N,K,*A = $<.read.split.map(&:to_i)
A.unshift 1
B = [-1]+[nil]*N
at = 0
while 0
	(p at; exit) if B[at] == K

	nx = A[at]

	if B[nx] # B[nx] <= B[at]
		l = B[at]-B[nx]+1
		B[nx] = B[nx]+(K-B[nx])/l*l
	else
		B[nx] = B[at]+1
	end

	at = nx
end


Measured memory_bytes: 32784
package main

import (
	"fmt"
)

func compare(a, b []int) bool {
	if len(a) != len(b) {
		return false
	}
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func main() {
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	for i := range h {
		fmt.Scan(&h[i])
	}

	cnt := 0
	g := make([]int, n)
	for !compare(g, h) {
		w := false
		for i := 0; i < n; i++ {
			if g[i] != h[i] {
				if !w {
					cnt++
					w = true
				}
				g[i]++
			} else {
				w = false
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long int ll;
typedef pair<int, ll> P;

//--------------
//#define DEBUG
//--------------

#ifdef DEBUG
	#define debugprint(x) cout<<x<<" "
	#define debugendl cout<<endl
	#define debug(x) x
#else
	#define debugprint(x)
	#define debugendl
	#define debug(x)
#endif

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	zahyo operator*(int t){
		zahyo temp;
		temp.x=this->x*t;
		temp.y=this->y*t;
		return temp;
	}
	zahyo operator%(int t){
		zahyo temp(this->x%t,this->y%t);
		return temp;
	}
	zahyo operator/(int t){
		zahyo temp(this->x/t,this->y/t);
		return temp;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};

bool IsInBoard(int x,int maxx, int y,int maxy){
	if(x>=0 and x<maxx and y>=0 and y<maxy){
		return true;
	}
	else{
		return false;
	}
}

int main(){
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		string x,y;
		cin>>x>>y;
		int dp[1001][1001]={};
		for(int j=1;j<=x.size();j++){
			for(int k=1;k<=y.size();k++){
				int same=0;
				if(x[j-1]==y[k-1]){
					same=1;
				}
				dp[j][k]=max(dp[j-1][k-1]+same,max(dp[j-1][k],dp[j][k-1]));
			}
		}
		cout<<dp[x.size()][y.size()]<<endl;
	}

}



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

int main(){
  string s, t;
  int n, num=0;
  cin >> t >> n;
  for(int i=0; i<n; i++){
    cin >> s;
    for(int j=0; j<t.length(); j++){
      s += s[j];
     }
    for(int j=0; j<s.length()-t.length(); j++){
      int k=0;
      for(k=0; k<t.length(); k++){
	if(s[j+k] != t[k]){
	  k=-2; break;
	}
      }
      if(k!=-2){
	num++; break;
      }
    }
  }
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	vector<vector<int>> ans(500, vector<int>(500, 1));
	vector<int> pr;
	for (int i = 2; i <= 20000; i++) {
		bool flag = true;
		for (int j = 2; j*j <= i; j++) {
			if (i%j == 0) flag = false;
		}
		if (flag) pr.pb(i);
	}
	int idx = 0;
	for (int i = 0; i < 1000; i += 2) {
		for (int j = 0; j < 500; j++) {
			int k = i - j;
			if (0 <= k && k < 500) ans[j][k] *= pr[idx];
		}
		idx++;
	}
	for (int i = 0; i < 1000; i += 2) {
		for (int j = 0; j < 500; j++) {
			int k = -i + j + 500;
			if (0 <= k && k < 500) ans[j][k] *= pr[idx];
		}
		idx++;
	}
	rep(i, 500) {
		rep(j, 500) {
			if (i % 2 != j % 2) {
				if (i != 0) ans[i][j] = lcm(ans[i][j], ans[i - 1][j]);
				if (i != 499) ans[i][j] = lcm(ans[i][j], ans[i + 1][j]);
				if (j != 0) ans[i][j] = lcm(ans[i][j], ans[i][j - 1]);
				if (j != 499) ans[i][j] = lcm(ans[i][j], ans[i][j + 1]);
				ans[i][j]++;
			}
		}
	}
	int n;
	cin >> n;
	rep(i, n) {
		rep(j, n) {
			cout << ans[i][j] << ' ';
		}
		cout << endl;
	}
}

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

int main() {
  int A, B, K;
  cin >> K >> A >> B;
  
  if (A % K == 0){
    cout << "OK" << endl;
  }
  else if ((B - A) + (A % K) >= K){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

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

    int N, M; cin >> N >> M;
    vl data;
    ll ans = 0;
    F0R(i, N) {
        ll X; cin >> X; data.pb(X); ans += X;
    }

    vpl queries;
    F0R(i, M) {
        ll B, C; cin >> B >> C;
        queries.pb(mp(-1 * C, B));
    }
    sort(all(queries));
    int index = 0;
    sort(all(data));
    F0R(i, N) {
        if (index == M) goto done;
        if (-1 * queries[index].f <= data[i]) goto done;
        queries[index].s--;
        ans += -1 * queries[index].f - data[i];
        if (queries[index].s == 0) index++;
    }

    done:;
    cout << ans << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int i = 0;
		while(i < N) {
			a[i] = sc.nextInt();
			i++;
		}

		Arrays.sort(a);
		boolean result = true;
		for(i = 1;i < N;i++) {
			if(a[i] == a[i-1]) {
				result = false;
				break;
			}
		}

		if(result == true) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}

}

Measured memory_bytes: 85628
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int n,m;
        scanf("%d%d",&n,&m);
        if(n == 0 && m == 0) break;
        int a[1001] = {0};
        for(int i = 1; i <= n; i++){
            scanf("%d",&a[i]);
        }
        sort(a+1,a+n+1);
        reverse(a+1,a+n+1);
        int sum = 0;
        for(int i = 1; i <= n; i++){
            if(i % m == 0)continue;
            sum += a[i];
        }
        printf("%d\n",sum);
    }

    return 0;
}

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

using ll = long long;
#define REP(i,n) for(int i=0; i<(int)(n); i++)

ll modpow(ll a, ll b, ll p){
    ll r = 1;
    while(b){
        if(b&1)r=r*a%p;
        a=a*a%p;
        b>>=1;
    }
    return r;
}

int n, p;
char s[252521];

ll sum[252521];
ll cnt[12525];

int main(){
    scanf("%d%d", &n, &p);
    scanf("%s", s);
    if(p==2 || p==5){
        ll ans = 0;
        REP(i,n){
            int v = s[i] - '0';
            if(v % p == 0){
                ans += i+1;
            }
        }
        printf("%lld\n", ans);
        return 0;
    }
    sum[0] = 0;
    REP(i,n){
        sum[i+1] = (sum[i] * 10 + (s[i] - '0')) % p;
    }
    // s[l,r) mod p == sum[r] - sum[l] * pow(10, r-l) mod p == 0
    // sum[r] == sum[l] * pow(10, r-l)                  (mod p)
    // sum[r] * pow(10, -r) == sum[l] * pow(10, -l)     (mod p)
    REP(i,n+1){
        sum[i] = sum[i] * modpow(modpow(10, i, p), p-2, p) % p;
    }
    ll ans = 0;
    REP(r,n+1){
        ans += cnt[sum[r]];
        cnt[sum[r]] += 1;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
using namespace std;


int main(){
    int N;
    cin >> N;
    int A[110];
    for(int i = 0; i < N; i++) cin >> A[i];
  
    sort(A, A + N, greater<int>());
    int sumA = 0;
    int sumB = 0;
    if(N%2 == 0){
        for(int i = 0; i < N/2 ;i++){
            sumA += A[2*i];
            sumB += A[2*i+1];
        }
        cout << sumA - sumB << endl;
    }
    else{
        for(int i = 0; i < N/2 ;i++){
            sumA += A[2*i];
            sumB += A[2*i+1];
        }
        sumA += A[N-1];
        cout << sumA - sumB << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
	int a=1;
	bool f=true;
	while(a!=3){
		char b=getchar();
		if(f){
			putchar(b);
			f=false;
		}
		if(b==' '){
			b=getchar();
			putchar(b);
			a++;
		}
	}
	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    string s;
    cin >> s;
    string t;
    rep(i, s.size())
    {
        if (s[i] == '0' || s[i] == '1')
            t += s[i];
        else
        {
            if (t != "")
                t.erase(t.size() - 1);
        }
    }
    OP(t);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;
#define MX 100009

int mp[MX][29];

int main(){
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int m=t.size();
  rep(i,MX)rep(j,29)mp[i][j]=-1;
  for(int i=n-1;i>=0;i--){
    rep(j,26){
      mp[i][j]=mp[i+1][j];
    }
    mp[i][s[i]-'a']=i;
  }
  ll ans=0;
  int p=-1;
  rep(i,m){
    int x=mp[p+1][t[i]-'a'];
    int nxt=mp[0][t[i]-'a'];
    if(p<x){
      ans+=x-p;
      p=x;
    }
    else{
      if(nxt==-1){
        ans=-1;
        break;
      }
      ans+=n-p+nxt;
      p=nxt;
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 11904
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define dl double
#define mod 1000000007
#define sz 100005
#define szz 150

using namespace std;

int main()
{
    ll a,b,c;
    
    scanf("%lld %lld %lld",&a,&b,&c);
    
    if(a==b)
        printf("%lld\n",c);
    
    else if(a==c)
        printf("%lld\n",b);
    
    else if(b==c)
        printf("%lld\n",a);

    return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	double N, i, j, k;

	cin >> N;

	for (i = 1.0; i <= 3500.0; i += 1.0) {
		for (j = 1.0; j <= 3500.0; j += 1.0) {
			if (4 * i * j - N * i - N * j >= 1.0) {
				k = (N * i * j) / (4 * i * j - N * i - N * j);
				if (ceil(k) == floor(k)) {
					cout << int(i) << ' ' << int(j) << ' ' << int(k) << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}

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

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

    int len = (int)s.length();
    long long cur = 0;
    int pos;
    for (int bit = 0; bit < (1 << (len - 1)); bit++) {
        pos = 0;
        for (int i = 1; i < len; i++) {
            if (bit & (1 << (i - 1))) {
                cur += stoll(s.substr(pos, (i - pos)));
                pos = i; 
            }
        }
        cur += stoll(s.substr(pos));
    }

    cout << cur << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int a, b;cin >> a >> b;
  cout << a*b << " " << 2*(a + b) << endl;
}


Measured memory_bytes: 3076
// date: 22/08/20 17:20:42 // 
#include <bits/stdc++.h>
using namespace std;

#define iterall(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <bool> vb;
typedef vector <double> vd;
typedef vector <ll> vll;
typedef vector <vector <int>> vvi;
typedef vector <vector <long long>> vvll;
typedef vector <vd> vvd;
typedef vector <long long> vll;
typedef pair <int, int> pii;
typedef pair<ll , ll> pll;
typedef vector <pair <int, int>> vpii;
typedef vector <pll> vpll;

const ll INF = 1e9+5;
const double EPS = 1e-9;


int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    double res = ceil((double)n/x);
    res = res*t;

    cout << (ll)res << endl;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys

from functools import reduce

import math

def is_prime(n):
    if n % 2 == 0 and n > 2: 
        return False
    for i in range(3, int(math.sqrt(n)) + 1, 2):
        if n % i == 0:
            return False
    return True

def sieve(n):
    n=int(n)
    # Create a boolean array "prime[0..n]" and initialize 
    # all entries it as true. A value in prime[i] will 
    # finally be false if i is Not a prime, else true. 
    prime = [True for i in range(n + 1)] 
    p = 2
    while (p * p <= n): 
          
        # If prime[p] is not changed, then it is a prime 
        if (prime[p] == True): 
              
            # Update all multiples of p 
            for i in range(p * 2, n + 1, p): 
                prime[i] = False
        p += 1
    prime[0]= False
    prime[1]= False

    return [i for i, p in enumerate(prime) if p]

def inthroot(x,n):
    "calculate floor(x**(1/n))"
    return math.floor(x**(1/n))

def is_a_power(n):
    "return (a,b) if n=a**b otherwise throw ValueError"
    for b in sieve( math.log2(n) +1 ):
        if b == 0:
            raise ValueError
            
        a = inthroot(n,b)
        if a**b == n:
            return a,b
    raise ValueError
    


def smooth_factorization(n):
    "return (p,e) where p is prime and n = p**e if such value exists, otherwise throw ValueError"
    e=1
    p=n
    while True:
        try:
            p,n = is_a_power(p)
            e = e*n
        except ValueError:
            break
    if is_prime(p): 
        return p,e


def factors(n):
    return set(
        reduce(
            list.__add__,
            ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0),
        )
    )
        
def solve(N: int):
    count = 0
    picked_z = set([])

    while True:
        zs = list(factors(N))
        zs.remove(1)

        for _ in range(len(zs)):
                    
            z = min(zs)
            i = zs.index(z)

            is_prime_power = smooth_factorization(z)
            if is_prime_power and z not in picked_z:
                picked_z.add(z)
                N = N / z
                count += 1
                del zs[i]
                break

            del zs[i]

        if len(zs) == 0:
            break

    print(count)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()


Measured memory_bytes: 69852
fun main(args: Array<String>) {
  val st = readLine()!!.split(" ")
  val ab = readLine()!!.split(" ").map { it.toInt() }
  val u = readLine()!!
  if (st[0] == u) {
    print("${ab[0] - 1} ${ab[1]}")
  } else {
    print("${ab[0]} ${ab[1] - 1}")
  }
}

Measured memory_bytes: 37868
n, k = map(int, input().split())
mod = 10 ** 9 + 7


def comb(n, k, p):
    from math import factorial

    if n < 0 or k < 0 or n < k:
        return 0
    if n == 0 or k == 0:
        return 1
    a = factorial(n) % p
    b = factorial(k) % p
    c = factorial(n - k) % p
    return (a * power_func(b, p - 2, p) * power_func(c, p - 2, p)) % p


def power_func(a, b, p):
    if b == 0:
        return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, p)
        return d * d % p
    if b % 2 == 1:
        return (a * power_func(a, b - 1, p)) % p


for i in range(1, k + 1):
    print(comb(n - k + 1, i, mod) * comb(k - 1, i - 1, mod) % mod)


Measured memory_bytes: 3444
x,y = gets.split(" ").map(&:to_i);
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if (a.include?(x) && a.include?(y)) || (b.include?(x) && b.include?(y))||(c.include?(x) && c.include?(y))
    puts 'Yes'
else
    puts 'No'
end

Measured memory_bytes: 1788
n=int(input())
d=dict()
for i in range(n):
  a=input()
  if a not in d:
    d[a]=1
  else:
    d[a]+=1
m=int(input())
for i in range(m):
  a=input()
  if a not in d:
    d[a]=-1
  else:
    d[a]-=1
dl=sorted(d.items(),key=lambda x:x[1],reverse=True)
print(max(dl[0][1],0))

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

ifstream fin("darb.in");
ofstream fout("darb.out");
int minCost[100001], v[100001];

int main() {
    int n, k;

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

    minCost[1] = 0;
    for (int i = 2; i <= n; i++) {
        int minCurrent = INT_MAX;
        for (int j = 1; j <= k && i - j; j++)
            minCurrent = min(minCurrent, minCost[i - j] + abs(v[i] - v[i - j]));
        minCost[i] = minCurrent;
    }

    cout << minCost[n] << " ";

    return 0;
}

Measured memory_bytes: 4420
use warnings;
    use Data::Dumper;
    
    sub GetInputData{
    
        my @array_data;
    
        my $line = <STDIN>;
    
        chomp($line);
    
        while($line ne ""){
    
           push(@array_data,$line);
    
           $line = <STDIN>;
    
           chomp($line);
    
    }
    
        return @array_data;
    
    }
    
    sub GetSpaceInputData{
    
        my @array_temp=GetInputData();
    
        my @array_buf;
    
        foreach(@array_temp){
    
            #戻りは配列スペース区切りを分解
            # myを先頭につける必要あり
            my @array_work=split(" ",$_);

            # print "@array_work";
    
            # リファレンスを配列に代入
            push(@array_buf,\@array_work);
        }
    
        return @array_buf;
    
    }
    
    my @arr_result = GetSpaceInputData();

    my $x = $arr_result[0][0];
    my $y = $arr_result[0][1];
   
    print $x + $y / 2;

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
struct union_find
{
	vector<int> par;
	union_find(int n) 
	{
		REP(i, n) par.push_back(i);
	}
	int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }
	void unite(int x, int y)
	{
		x = find(x); y = find(y);
		if (x == y) return;
		par[y] = x;
		if (find(x) != find(y)) par[find(y)] = x;
	}
	int count()
	{
		int cnt = 0;
		REP(i, par.size()) if (par[i] == i) cnt++;
		return cnt;
	}
	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};

int main()
{
	int n, w, h;
	cin >> n >> w >> h;
	vector<vi> x(h), y(w);
	union_find uf(n);
	REP(i, n)
	{
		int a, b; cin >> b >> a;
		a--; b--;
		x[a].push_back(i), y[b].push_back(i);
	}
	REP(i, h)REP(j, x[i].size() - 1) uf.unite(x[i][j], x[i][j + 1]);
	REP(i, w)REP(j, y[i].size() - 1) uf.unite(y[i][j], y[i][j + 1]);
	ll cnt = uf.count();
	ll ans = n - cnt;
	if (cnt > 1)
	{
		ans += cnt;
		ans += cnt - 1;
		if (x[0].size() || x[h - 1].size() || y[0].size() || y[w - 1].size()) ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9764
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5;
#define yi first
#define er second
typedef pair<int,int> node;
node a[yuzu|10];

bool cmp(node a,node b){
return a.er<b.er;
}

int main(){
int i,j,n=read(),m=read();
for (i=1;i<=m;++i) a[i].yi=read(),a[i].second=read();
sort(a+1,a+m+1,cmp);
int now=-1,llx=0;
for (i=1;i<=m;++i){
  if (now<a[i].yi){
    now=a[i].er-1,++llx;
    }
  }write(llx);
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

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

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<ll> A(N);
  rep(i,N) std::cin >> A[i];

  rep(i,N) {
    if ( A[i] == 0 ) {
      std::cout << 0 << std::endl;
      return 0;
    }
  }

  ll ans = 1;
  const ll th = 1e18;
  rep(i,N) {
    if ( th/ans < A[i] ) {
      std::cout << -1 << std::endl;
      return 0;
    }
    ans *= A[i];
    if ( ans > th ) {
      std::cout << -1 << std::endl;
      return 0;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}



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

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  
  if(N % X == 0) {
    cout << N / X * T << endl;
  } else {
    cout << (N / X + 1) * T << endl;
  }
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int a[maxn], b[maxn];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = n; i >= 1; i--) {
		int sum = 0;
		for (int j = 1; j * i <= n; j++) {
			sum += b[i * j];
		}
		if (sum % 2 != a[i]) {
			ans++; 
			b[i] = 1;
		}
	}
	cout << ans <<endl;
	for (int i = 1; i <= n; i++) {
		if (b[i]) {
			cout << i << " ";
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int e;
    cin >> e;
    if (a.empty() || a.back() != e) a.push_back(e);
  }
  n = a.size();
  map<int, int> m;
  vector<int> v(n, n);
  for (int i = n - 1; i >= 0; i--) {
    if (m.count(a[i])) {
      v[i] = m[a[i]];
    }
    m[a[i]] = i;
  }
  vector<ll> dp(n + 1);
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    dp[i + 1] += dp[i];
    dp[i + 1] %= mod;
    dp[v[i]] += dp[i];
    dp[v[i]] %= mod;
  }
  cout << dp[n - 1] << endl;
}


Measured memory_bytes: 12788
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    stack<char>s;
    int k=(n-1)%26;
    s.push('a'+k);
    n--;
    n=n/26;
    while(n)
    {
        k=(n-1)%26;
        s.push('a'+k);
        n--;
        n=n/26;
    }
    while(!s.empty())
    {
        cout<<s.top();
        s.pop();
    }
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define INPUT(X) cin >> X
#define OUTPUT(X) cout << X << endl
#define REPEAT(i,n) for(int i=0;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
const ll MOD = 1e9+7;

inline ll Upstair(ll n){
	ll rt;
	if(n==1) return 1;
	return n*Upstair(n-1);
}



int main(void) {


	int N;
	vector<int> v;
	INPUT(N);
	REPEAT(i,N){
		int a;
		INPUT(a);		
		v.push_back(a);
	}
	SORT(v);
	double ans = 0.0;
	REPEAT(i,N-1) {
		if( i == 0 ){
			ans = (v[i]+v[i+1])/2.0;
		}else{
			ans = (ans+v[i+1])/2.0;
		}
	}
	

	OUTPUT(ans);
		
}

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

using namespace std;

typedef long long ll;

ll n, s, ans = 1e18;

inline void check(ll i){
	ll x = n, y = 0;
	while(x){
		y += x % i;
		x /= i;
	}
	if(y == s) ans = min(ans, i);
}

int main(){
	scanf("%lld%lld", &n, &s);
	if(n == s) ans = n + 1;//debug:特判n=s的情况 
	for(int i = 2;1ll * i * i <= n;i++) check(i);
	//xb+y=n,x+y=s -> x(b-1)=n-s
	for(ll i = 1;i * i <= n - s;i++){
		if((n - s) % i) continue;
		if((i + 1) * (i + 1) > n) check(i + 1);
		check((n - s) / i + 1);
	}
	printf("%lld", ans == 1e18 ? -1 : ans);
}

Measured memory_bytes: 3768
CONST_DIVSOR = 998244353
N = int(input())
Ds = list(map(int, input().strip().split()))
counter = [0] * (max(Ds)+1)
for D in Ds:
    counter[D] += 1
ans = 1
if counter[0] != 1 or Ds[0] != 0:
    print(0)
else:
    for i in range(1,max(Ds)+1):
        ans *= (counter[i-1] ** counter[i])
        ans %= CONST_DIVSOR
    print(ans)


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

int main() {
   int a,b;
   cin >> a >> b;
   cout << a/b << " " << a%b << " " << flush; 
   cout << fixed << setprecision(5) << (double)a/(double)b << endl;
   return 0;
}


Measured memory_bytes: 3292
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(s:#));
    s.chars()
        .enumerate()
        .filter(|&(i, _)| i % 2 == 0)
        .map(|(_, x)| x)
        .collect::<String>()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "atcoder" => "acdr",
    test2: "aaaa" => "aa",
    test3: "z" => "z",
    test4: "fukuokayamaguchi" => "fkoaaauh",
}


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

using namespace std;

int main() {
  int n, a, c[8] = {}, p = 0, ans;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a >= 3200)
      p++;
    else
      c[a / 400] = 1;
  }
  ans = count(c, c + 8, 1);
  printf("%d %d\n", max(1, ans), ans + p);
  return 0;
}


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

int main() {
    while (true) {
        int n;
        cin >> n;
        
        if (n==0) {
            break;
        }
        
        int m[n], a[n], b[n];
        vector<int> vals;
        
        for (int i=0; i<n; i++) {
            cin >> m[i] >> a[i] >> b[i];
            vals.push_back(a[i]);
            vals.push_back(b[i]);
        }
        
        sort(vals.begin(), vals.end());
        vals.erase(unique(vals.begin(), vals.end()), vals.end());
        
        int imos[vals.size()];
        
        for (int i=0; i<vals.size(); i++) {
            imos[i] = 0;
        }
        
        for (int i=0; i<n; i++) {
            int s_idx = lower_bound(vals.begin(), vals.end(), a[i])-vals.begin();
            int t_idx = lower_bound(vals.begin(), vals.end(), b[i])-vals.begin();
            imos[s_idx] += m[i];
            imos[t_idx] -= m[i];
        }
        
        for (int i=1; i<vals.size(); i++) {
            imos[i] += imos[i-1];
        }
        
        bool flag = true;
        
        for (int i=0; i<vals.size(); i++) {
            if (imos[i]>150) {
                cout << "NG" << endl;
                flag = false;
                break;
            }
        }
        
        if (flag) {
            cout << "OK" << endl;
        }
    }
}


Measured memory_bytes: 3144
// 3_abc139_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#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 SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int cnt = 0;
    int ans = 0;
    int h;
    cin >> h;
    rep(i, n - 1){
        int a;
        cin >> a;
        if(h >= a) cnt++;
        else{
            ans = max(ans, cnt);
            cnt = 0;
        }
        h = a;
    }
    ans = max(ans, cnt);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
int main() {
    ll n;
    cin >> n;
    ll a[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    bool uritai = false;
    ll now = 1;
    ll shojikin = 1000;
    ll shojikabu = 0;
    ll ret = 1000;
    while (now <= n) {
        if (uritai) {
            if ((now < n) && (a[now] < a[now + 1])) {
                now++;
                continue;
            }
            else {
                shojikin += shojikabu * a[now];
                shojikabu = 0;
                uritai = false;
                if (ret < shojikin) {
                    ret = shojikin;
                }
            }
        }
        else {
            //安く買いたい
            if ((now == n) || (a[now] > a[now + 1])) {
                now++;
                continue;
            }
            else {
                shojikabu = shojikin / a[now];
                shojikin %= a[now];
                uritai = true;
            }
        }
        now++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
const int maxd = 2e5+10;
vector<int> mp[50];
char a[maxd],b[maxd];
int now,ed;
int find(int now,int v)
{
	int ans = ed,l = 0,r = mp[v].size()-1;

	//printf("	%d %d %d\n",l,r,v);
	while(l<=r)
	{
		int mid = (l+r) >> 1;
		if(mp[v][mid] >= now) ans = mid, r = mid-1;
		else l = mid + 1;
		
	}
	if(ans == ed) return ans;
	return mp[v][ans];
}
int main()
{
	// freopen("a.in","r",stdin);
	// freopen("k.out","w",stdout);
	scanf("%s%s",a+1,b+1);
	for(int i=1;a[i];i++) 
	{
		mp[a[i]-'a'].push_back(i);
		//printf("%d %d %lu\n",a[i]-'a',i,mp[a[i]-'a'].size());
	}
	now = 1,ed = strlen(a+1)+1;
	long long ans = 0ll;
	for(int i=1;b[i];i++)
	{
		int r = find(now,b[i]-'a');
		//printf("%d\n",r);
		if( r == ed )
		{
			ans += 1ll * ed-1;
			now = 1;
			r = find(now,b[i]-'a');
			if( r == ed)
			{
				printf("-1");
				return 0;
			}
		}
		now = r+1;
	}
	printf("%lld", 1ll * ans + now-1);
	return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
typedef pair<int,int> P;
#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--)
int n,m;
vector<int> G[300000];
bool used[300000];
int main(){
    scanf("%d%d",&n,&m);
    REP(i,m){
        int a,b;
        scanf("%d%d",&a,&b);
        a--;b--;
        G[b].pb(a);G[a].pb(b);
    }
    used[0] = true;
    queue<P> que;
    REP(i,G[0].size()){
        que.push(P(G[0][i],1));
        used[G[0][i]] = true;
    }
    while(!que.empty()){
        P p = que.front();
        que.pop();
        if(p.second >= 2){
            break;
        }
        REP(i,G[p.first].size()){
            if(!used[G[p.first][i]]){
                used[G[p.first][i]] = true;
                que.push(P(G[p.first][i],p.second + 1));
            }
        }
        if(used[n - 1]){
            printf("POSSIBLE\n");
            return 0;
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}



Measured memory_bytes: 15344
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ll long long
using namespace std;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
int a[110];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=inf;
	for(int i=1;i<n;i++){
		int r1=0,r2=0;
		for(int j=1;j<=i;j++){
			r1+=a[j];
		}
		for(int j=i+1;j<=n;j++){
			r2+=a[j];
		}
		ans=min(ans,abs(r1-r2));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
ans_list = []

while True:
    num = input()
    if num == "0":
        break
    n = len(num)
    sum_of_digits = 0
    for i in range(n):
        sum_of_digits += int(num[i])
    ans_list.append(sum_of_digits)

for ans in ans_list:
    print(ans)



Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int sum = 700;
    int cnt=0;
    for(int i=0; i<3; i++){
        if(s.at(i)=='o'){
            cnt++;
        }
    }
    sum += 100*cnt;
    cout << sum << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,l,min1=mod,ans,ans2;
int32_t main(){
CODE_START;
cin>>n;
cin>>l;
for(ll i=1;i<=n;i++)
ans=ans+l+i-1;
ll min1=mod,x=0;
for(ll i=1;i<=n;i++){
        ans2=0;
    for(ll j=1;j<=n;j++)
    if(i!=j)
    ans2=ans2+j+l-1;
    if(abs(ans-ans2)<min1){
        min1=abs(ans-ans2);
        x=ans2;
    }
}
cout<<x;
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define rep(i, n) for(int i = 0; i < n; i++)
const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
  ll N, X, M;
  cin >> N >> X >> M;
  if(N <= M) {
    ll ans = X;
    rep(i, N - 1) {
      X = X * X % M;
      ans += X;
    }
    cout << ans << endl;
  }
  else {
    set<ll> check;
    check.insert(X);
    ll A = X;
    ll right = 1;
    rep(i, M) {
      A = A * A % M;
      right++;
      if(check.count(A)) {
        break;
      }
      check.insert(A);;
    }
    ll left = 1;
    ll B = X;
    rep(i, M) {
      if(B == A) {
        break;
      }
      B = B * B % M;
      left++;
    }
    ll ans = 0;
    ll keep = X;
    rep(i, left - 1) {
      ans += keep;
      keep = keep * keep % M;
    }
    ll roopsum = 0;
    rep(i, right - left) {
      roopsum += keep;
      keep = keep * keep % M;
    }
    ans += roopsum * ((N - left + 1) / (right - left));
    rep(i, (N - left + 1) % (right - left)) {
      ans += keep;
      keep = keep * keep % M;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 5912