akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = [int(i) for i in input().split()]

ans = 0
for C in range(1, n):
    f = 0
    for k in range([int(((n - 1) / C + 1) / 2), int((n - 1) / C)][(n - 1) % C != 0]):
        f += a[k * C] + a[(n - 1) - k * C]
        ans = max(ans, f)
print(ans)

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

int main() {
	int n;
	cin >>n;
	int house[4][3][10] = {};
	for(int i=0; i<4; i++){
		for(int j=0; j<3; j++){
			for(int k=0; k<10; k++){
				house[i][j][k]=0;
			}
		}
	}
	for(int i=0; i<n; i++){
		int b,f,r,v;
		cin>>b>>f>>r>>v;
		house[b-1][f-1][r-1] += v;
	}
	for(int i=0; i<4; i++){
		for(int j=0; j<3; j++){
			for(int k=0; k<10; k++){
				cout<<" "<<house[i][j][k];
			}
			cout << endl;
		}
		if(i!=3) cout<<"####################"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <numeric>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define itr(i, x) for(auto i = (x).begin(); i != (x).end(); i++)
#define ritr(i, x) for(auto i = (x).rbegin(); i != (x).rend(); i++)
#define INF 1010101010
#define MOD 1000000007
#define LL long long
using Coord = pair<int, int>;

int main() {
    string s;
    cin >> s;
    char c1, c2;
    c1 = c2 = '0';
    rep(i, s.size()) {
        if (s[i] == c1) {
            cout << i - 1 << ' ' << i + 1 << endl;
            return 0;
        }
        if (s[i] == c2) {
            cout << i << ' ' << i + 1 << endl;
            return 0;
        }
        c1 = c2;
        c2 = s[i];
    }
    cout << "-1 -1" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define hell  1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb   push_back


int main()
{
	ios;
	ll n,x=0;
	cin>>n;
	ll a[n+10];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		x^=a[i];
	}
	for(ll i=0;i<n;i++)
	{
		cout<<(x^a[i])<<' ';
	}
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;

int main(){
    int K,X;
    cin >> K >> X;

    rep(i,2*(K-1)+1){
        cout << X-(K-1)+i <<" "; 
    }





    
    cout <<endl;
    return 0;
    

}

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

using namespace std;

template <class T>
struct Triple {
	T a, b, c;

	Triple() : a(0), b(0), c(0) {

	}

	Triple(const T & a, const T & b, const T & c) : a(a), b(b), c(c) {
		
	}
	
	bool operator < (const Triple & rhs) const {
		return a + b < rhs.a + rhs.b;
	}
};

vector<Triple<int> > ans;

bool answer(const int & N, const int & K) {
	if (N < K * 2 - 1)
		return false;

	for (int i = 0; i < N; i++)
		ans.emplace_back(K + i, K + N * 2 - i - 1, 0);
	int x = K - 1;
	int y = (x + 1) / 2, z = x / 2;
	for (int i = 0; i < y; i++)
		swap(ans[i].b, ans[y * 2 - i - 1].b);
	for (int i = 0; i < z; i++)
		swap(ans[y * 2 + i].b, ans[y * 2 + z * 2 - i].b);
	sort(ans.begin(), ans.end());
	for (int i = 0; i < N; i++)
		ans[i].c = K + N * 2 + i;
	return true;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	int N, K;
	
	cin >> N >> K;

	if (answer(N, K)) {
		for (const auto & t : ans)
			cout << t.a << ' ' << t.b << ' ' << t.c << '\n';
	} else
		cout << "-1" << '\n';

	return 0;
}

Measured memory_bytes: 3572
n = int(input().strip())
res = []
for i in range(1, n + 1):
    res.append(input().strip().split() + [i])
    res[-1][1] = int(res[-1][1])
    
res.sort(key=lambda s: (s[0], -s[1]))
for i in res:
    print(i[-1])

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

int main()
{
	int X, Y;
	cin >> X >> Y;

	if (Y % 2 == 0 && X * 2 <= Y && Y <= X * 4)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int PARENT[100002] = {0};
int RANK[100002] = {0};

void init(int L){
	if(L<1) return;
	for(int i=0; i<L; i++){
		PARENT[i]=i;
		RANK[i]=0;
	}
}

int root(int x){
	if(x<0) return -1;
	if(PARENT[x]==x){
		return x;
	}
	else{
		PARENT[x] = root(PARENT[x]);
		return PARENT[x];
	}
}

int same(int x, int y){
	if(x==y) return 1;
	if(root(x)==root(y)){
		return 1;
	}
	else{
		return 0;
	}
}

void combine(int x, int y){
	if(x==y) return;

	int a = root(x);
	int b = root(y);
	if(a==b) return;

	if(RANK[x]<RANK[y]){
		PARENT[b] = a;
	}
	else{
		PARENT[a] = b;
		if(RANK[x]==RANK[y]) RANK[x] += RANK[y];
	}
}


int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	init(N);
	for(int i=0; i<M; i++){
		int X, Y, Z;
		cin >> X >> Y >> Z;
		combine(X-1, Y-1);
	}
	map<int, int> mp;
	LL ans = 0;
	for(int i=0; i<N; i++){
		int u = root(i);
		if(mp.count(u) == 0){
			ans++;
			mp[u] = 1;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 9208
total_cost = 0
max_cost = 0
n,m = gets.split.map(&:to_i)
m.times do |i|
    a,b = gets.split.map(&:to_i)
    if a < n then
        cost = n - a
        total_cost += cost
        max_cost = cost if max_cost < cost
    end
end
puts total_cost - max_cost


Measured memory_bytes: 6860
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


mod = 1000000007
inf = float('INF')


def A():
    a = II()
    b = a//2
    p = b/a
    if a % 2:
        print(1-p)
    else:
        print(p)

    return

# B


def B():
    N, K = map(int, input().split())
    h = LI()
    count = 0

    for i in h:
        if i >= K:
            count += 1
        else:
            continue
    print(count)
    return

# C


def C():
    N = II()
    A = LI()
    J = [0] * N
    for i, n in enumerate(A):
        J[n-1] = i+1
    for s in J:
        print(s, end=" ")

    return

# D


def D():
    A, B = map(int, input().split())
    g = gcd(A, B)
    go = g
    myset = set([1])
    sq = int(sqrt(g)) + 2

    for i in range(2, sq):
        while g % i == 0:
            g /= i
            myset.add(i)
        if g == 1:
            break
        if i == sq - 1:
            myset.add(go)

    print(len(myset))

    return

# E


def E():
    return

# F


def F():
    return


# Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 39152
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
main(){
	int a;
	while(~getI(a)) printf("%lld\n",a+a*a+a*a*a);
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long H, long long W, std::vector<std::vector<std::string>> S){
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            if(S[i][j] == "snuke"){
                cout << (char)('A'+j) << i+1 << endl;
                return;
            }
        }
    }
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::vector<std::string>> S(H, std::vector<std::string>(W));
    for(int i = 0 ; i < H ; i++){
        for(int j = 0 ; j < W ; j++){
            std::cin >> S[i][j];
        }
    }
    solve(H, W, std::move(S));
    return 0;
}


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

vector<long long>v;

long long dp[1000007];
int main ()
{
    long long x,n;
    cin>>n;

    while(n--) cin>>x,v.push_back(x);

    dp[1]=abs(v[1]-v[0]);
    for(long long i=2;i<v.size();i++)
    {
        dp[i] = min(dp[i-1] + abs(v[i]-v[i-1]), dp[i-2]+ abs(v[i]-v[i-2]));
    }

    cout<<dp[v.size()-1]<<endl;

}


Measured memory_bytes: 1908
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define puts(s) cout<<(s)<<endl
#define inf (1000000007)
#define nil -1

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	string ans = "Yes";
	map<char, char> s_map;
	for (int i = 0; i < n; i++)
	{
		if (s_map.find(s[i]) == s_map.end()) {
			s_map[s[i]] = t[i];
		}
		else {
			if (s_map[s[i]]!=t[i]) {
				ans = "No";
			}
		}
		s_map[s[i]] = t[i];
	}
	map<char, char> t_map;
	for (int i = 0; i < n; i++)
	{
		if (t_map.find(t[i]) == t_map.end()) {
			t_map[t[i]] = s[i];
		}
		else {
			if (t_map[t[i]] != s[i]) {
				ans = "No";
			}
		}
		t_map[t[i]] = s[i];
	}
	puts(ans);

	/*
	int n = 3;
	int m = 3;
	vi A = {1,2,3};
	vvi dp(n+1,vi(m+1));
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j <=m; j++)
		{
			for (int k = 0; k <=min(j,A[i-1]); k++)
			{
				dp[i][j] += dp[i-1][j-k];
			}
		}
	}
	puts(dp[n][m]);
	*/
}


Measured memory_bytes: 776
#include <iostream>
using namespace std;
int main(void){
    int n,A[100],count = 0,tmp,minj;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> A[i];
    }
    for (int i = 0; i <= n-1; i++){
        minj = i;
        for (int j = i; j <= n-1; j++){
            if (A[j] < A[minj]){
                minj = j;
            }
        }
        if (A[i] != A[minj]){
            count += 1;
        }
        tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;
    }
    for (int i = 0; i < n; i++){
        cout << A[i];
        if (i != n - 1){
            cout << " ";
        }
    }
    cout << endl;
    cout << count << endl;
}


Measured memory_bytes: 3096
from fractions import gcd

A, B, K = map(int, input().split())

largest_divisor = gcd(A, B)
divisors = []
for d in range(1, largest_divisor):
    if A % d == 0 and B % d == 0:
        divisors.append(d)
divisors.append(largest_divisor)
print(divisors[-K])

Measured memory_bytes: 5304
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


class UnionFind
{
public:
  UnionFind(int n)
  {
    parent=vector<int>(n,-1);
  }
  int root(int a)
  {
    if(parent[a]<0)return a;
    return parent[a]=root(parent[a]);
  }
  int size(int a)
  {
    return -parent[root(a)];
  }
  bool connect(int a,int b)
  {
    int A=root(a);
    int B=root(b);
    if(A==B)return false;
    if(size(A)>size(B))swap(A,B);
    parent[B]+=parent[A];
    parent[A]=B;
    return true;
  }
private:
  vector<int> parent;

};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>x(n),y(n);
  ll id=0;
  unordered_map<ll,ll>ma;//x:even
  rep(i,n){
    cin>>x[i]>>y[i];
    ma[x[i]*2]=id++;
    ma[y[i]*2+1]=id++;
  }
  UnionFind uf(id);
  rep(i,n){
    uf.connect(ma[x[i]*2],ma[y[i]*2+1]);
  }
  vector<vector<ll>>rec(id,vector<ll>(2));
  rep(i,id){
    rec[uf.root(i)][i%2]++;
  }
  ll res=0;
  rep(i,id){
    res+=rec[i][0]*rec[i][1];
    //cout<<rec[i][0]<<" "<<rec[i][1]<<endl;
  }
  cout<<res-n<<endl;



  return 0;

}


Measured memory_bytes: 17828
import fractions
n, m = map(int,input().split())
s = list(map(str,input()))
t = list(map(str,input()))
k = 0
q = fractions.gcd(n, m)
l = n * m // q #lcm(n, m)
p = int(l/n * l/m / fractions.gcd(l/n, l/m)) #lcm(l/n, l/m)
for i in range(0, int(l/p)):
  if s[i * p//(l//n)] != t[i * p//(l//m)]:
    print('-1')
    break
  else:
    k = k + 1

if k == l/p:
  print(l)

Measured memory_bytes: 6960
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

happy = sum(B)

for j in range(N-1):
    if A[j+1] - A[j] == 1:
        happy +=  C[A[j]-1]

print(happy)


Measured memory_bytes: 9032
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){ 
  vector<int> dishes(5); for(int i = 0; i < 5; i++){ cin >> dishes[i];}
int min_ans = 1e3; 
  sort(dishes.begin(),dishes.end());

  do{
    int sum = 0;
    for(int i = 0; i < 5;i++){
      int res = sum % 10; if(res != 0){sum += 10 - res;}
        sum += dishes[i];}
    
    min_ans = min(min_ans,sum);
    
  }while(next_permutation(dishes.begin(),dishes.end()));
    
    cout << min_ans << endl;
  
  return 0;
}
    
  


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# input
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    if a[i] % 6 == 0:
        pass
    elif a[i] % 10 == 0:
        pass
    elif a[i] % 2 > 0:
        pass
    else:
        print('DENIED')
        exit()
print('APPROVED')

Measured memory_bytes: 3060
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String x,r;int[]a={0,3,6,9,12,15,19,22},b={3,3,3,3,3,4,3,4},k={46,44,33,63,32};for(int t=s.nextInt(),c,i,p;t-->0;System.out.println(r))for(x=s.next(),r="",i=c=0;i<x.length()-1;)if((p=x.charAt(i++))==x.charAt(i))c++;else{if(p>48)r+=(char)(p<50?k[c%5]:97+(a[p-=50]+c%b[p]));c=0;}}}

Measured memory_bytes: 12000
/*
 * Bad Move
 * Code be weshen zyk :'(
 */
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/STACK:1024000000,1024000000")

#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

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

#define S second
#define F first
#define pb push_back

using ii = pair<int, int>;
using ll = long long;
using db = long double;

const int N = 1e5 + 5, K = 205, MOD = 998244353;
const ll MX = 1e15;
const int blkSz = 320;
int n;
vector<ll> L, R;
int main() {
//#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//#endif

	cin >> n;
	for (int i = 0, l, r; i < n; i++) {
		cin >> l >> r;
		L.pb(l);
		R.pb(r);
	}
	L.pb(0), R.pb(0);

	sort(L.rbegin(), L.rend());
	sort(R.begin(), R.end());
	ll ans = 0;

	for(int i = 0; i < n && 2 * (L[i] - R[i]) >= 0; i++){
		ans += 2 * (L[i] - R[i]);
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,x,y,z,l,n,m,a,r,f;
  long long min,max,sum;
  //vector<vector<int>> A(n, vector<int>(m, 0));
  vector<int> B(26, 0);
  string s,g;
cin >> s >> g;
  s+=s;
  s+=s;
  if(s.find(g) != string::npos)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3212
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
dt=1000000
ans=-1
th=0
for i in range(n):
  th=abs(a-t+h[i]*0.006)
  if th<dt:
    ans=i+1
    dt=th
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

// *** フェルマーの小定理を用いたCombination計算(modの構造体と一緒に使う) *** //
struct combination {
    vector<mint> fact, ifact;
    combination(int n) :fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};
int main()
{
    /*int x; cin >> x;
    if (x == 0)cout << 1 << endl;
    else cout << 0 << endl;
    */

    /*ll a, b, c, d; cin >> a >> b >> c >> d;
    ll ans = a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    cout << ans << endl;
    */

    /*ll n; cin >> n;
    ll ans = 1;
    if (n == 1) cout << 0 << endl;
    else if (n == 2) cout << 2 << endl;
    else {
        n -= 2;
        rep(i, n) {
            ans *= 10;
            ans %= mod;
        }
        ans *= (n + 1);
        ans %= mod;
        ans *= (n + 2);
        ans %= mod;
    }
    cout << ans << endl;
    */

    int s; cin >> s;
    if (s <= 2) {
        cout << 0 << endl;
        return 0;
    }
    int rp = s / 3;
    mint ans = 1;
    for (int i = 2; i <= rp; ++i) {
        ll res = s - ll(3) * i;
        combination c(res + i - 1);
        mint a = c(res + i - 1, i - 1);
        ans += a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
let N = Int(readLine()!)!
let H = readLine()!.characters.split(" ").map{Int(String($0))!}
var ans = 0
var l = 0
while l < N {
    var r = l
    while r+1 < N && H[r] >= H[r+1] {
        r += 1
    }
    ans = max(ans, r-l)
    l = r+1
}
print(ans)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
    int n;cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=a[i]*a[j];
        }
    }
    cout<<ans<<endl;
}

 
    

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $N, $X);
$NN = 2 * $N - 1;

if ($X <= 1 || $X >= $NN) {
	echo 'No' . PHP_EOL;
	exit;
}
echo 'Yes' . PHP_EOL;
if ($N === 2) {
	echo implode(PHP_EOL, [1, 2, 3]) . PHP_EOL;
	exit;
} else 
$result = [];
if ($X > $N) {
	$result[$N - 1] = 1;
	$result[$N    ] = $X;
	$result[$N + 1] = $NN;
	$result[$N + 2] = 2;
} else {
	$result[$N - 1] = $NN;
	$result[$N    ] = $X;
	$result[$N + 1] = 1;
	$result[$N + 2] = $NN-1;
}
$num = [];
for ($i = 1; $i <= $NN; $i++) {
	$num[$i] = $i;
}
foreach ($result as $v) {
	unset($num[$v]);
}
$idx = 1;
foreach ($num as $v) {
	while (isset($result[$idx])) {
		echo $result[$idx++] . PHP_EOL;
	}
	echo $v . PHP_EOL;
	$idx++;
}
if ($idx < $NN) {
	while (isset($result[$idx])) {
		echo $result[$idx++] . PHP_EOL;
	}
}

Measured memory_bytes: 33784
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int x[5];
	REP(i, 5) { cin >> x[i]; }
	REP(i, 5) {
		if (x[i] == 0) {
			cout << i + 1 << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3636
//abc140_d.cpp
//Sun Dec 22 17:33:45 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,k;
	cin >> n >> k;
	string s;
	cin >> s;

	int ans = 0;
	int rlcount = 0;
	int rlcounthashi = 0;
	for (int i=0;i<s.length();i++){
		if (i>0 && s[i]==s[i-1]){
			ans++;
		}
	}

	cout << min(ans+k*2,n-1) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

constexpr long long inv(long long x, long long m) {
  return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x;
}

const int M = 1e9 + 7, N = 1e6 + 5;
int f[N];

int main() {
  f[0] = 1;
  for (int i = 1; i <= int(1e6); ++i) f[i] = 1LL * f[i - 1] * i % M;
  int x, y;
  cin >> x >> y;
  LL ans = 0;
  for (int i = 0; i <= x; ++i) {
    int dx = x - i, dy = y - 2 * i;
    if (dy < 0 || bool(dx & 1)) continue;
    if (dy * 2 != dx) continue;
    int j = dy;
    ans += 1LL * f[i + j] * inv(f[i], M) % M * inv(f[j], M) % M; 
    ans %= M;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4096
#include <stdio.h>

int main(void){
  int H,W;
  int i,j;
  while(1)
    {
      scanf("%d %d",&H,&W);
      if (H == 0 && W == 0)break;
      for(j = 0; j < H;j++)
        {
          for (i = 0; i < W; i++)
            {
              if((i+j)%2 == 0)printf("#");
              else printf(".");
            }
          printf("\n");
        }
      printf("\n");
    }
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

const string KEY = "keyence";
string s;
int p;

int main() {
	cin >> s;
	for (int i = 0; i != 8; ++i) {
		string k;
		for (int j = 0; j != i; ++j) {
			k += s[j];
		}
		for (int j = s.size() - (7 - i); j != s.size(); ++j) {
			k += s[j];
		}
		if (k == KEY) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    int N; cin >> N;
    if (N == 1) {
        cout << "Hello World" << endl;
    } else {
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int *> P;
typedef pair<long long,int>PP;
typedef long long ll;
int main(){
  int n,k,c;
  cin>>n>>k>>c;
  if(n*c<=k){
    cout<<c<<endl;
  }else{
    int a=0;
    for(int i=n;i<=k;i+=n){
      a++;
    }
    cout<<a<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
<?php
list($a,$b,$x) = explode(" ",trim(fgets(STDIN)));
$q = $b % $x;
if($a == $b){
echo $q == 0? 1:0;
}else{
$r = $a % $x;
$ans = ($b - $q - $a + $r) / $x;
echo $r == 0? $ans + 1:$ans;
}

Measured memory_bytes: 3700
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    # 言い直して、同じ文字が連続している区間が何個あるかを求めよ
    n = int(input())
    s = input()
    res = 0
    i = 0
    while i < n:
        j = i
        #print(i)
        while True:
            if j < n:
                if s[j] == s[i]:
                    j += 1
                else:
                    break
            else:
                break
        i = j
        res += 1
    print(res)

if __name__ == '__main__':
  main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + (ll)b) % mod
#define MUL(a, b) a = (a * (ll)b) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rer(i, a, b) for(int i = a - 1; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<int, pi> ppi;
typedef vector<ll> vec;

const int MAX_N = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 27;

void Debug() {cout << '\n'; }

template<class FIRST, class... REST> 
void Debug(FIRST arg, REST... rest) { cout << arg << " "; Debug(rest...); }

template<class T>
ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";
	if(!v.empty()) {
		rep(i, 0, (int)v.size() - 1) out << v[i] << ", ";
		out << v.back();
	}
	out << "]";
  return out;
}

template<class S, class T>
ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";
	return out;
}

///g++ -g3 -std=c++0x -DLOCAL -Wall -ftrapv -D_GLIBCXX_DEBUG -Wl,-stack,268435456 -o
///g++ -O2 -std=c++0x -DLOCAL -Wall -Wl,-stack,268435456 -o

////////////////////////////////////////////////////////////////////////

int N;
ll A, B;
ll D[MAX_N];

bool C(ll m) {
	ll res = 0;
	rep(i, 0, N) {
		ll a = D[i] - m * B;
		if(a > 0) res += (a + A - B - 1) / (A - B);
		//if(m == 8e8) debug(i, res);
	}
	if(res <= m) return true;
	else return false;
}

void solve() {
	cin >> N >> A >> B;
	rep(i, 0, N) {
		cin >> D[i];
	}
	ll lv = -1, rv = 1e10;
	while(rv - lv > 1) {
		ll m = (lv + rv) / 2;
		//debug(lv, m, rv);
		if(C(m)) rv = m;
		else lv = m;
	}
	cout << rv << '\n';
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);	
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

#define NIL -1

struct node {
	int p, l, r;
};

node T[100000];

int getdepth(int u) {
	int ans = 0;
	while (T[u].p != NIL) {
		ans++;
		u = T[u].p;
	}
	return ans;
}

void printchildren(int u) {
	cout << "[";
	int c = T[u].l;
	while (c != NIL) {
		if (T[c].r != NIL)
			cout << c << ", ";
		else
			cout << c;
		c = T[c].r;
	}
	cout << "]" << endl;
}

void initnode(int n) {
	for (int i = 0; i < n; i++) {
		T[i] = { NIL, NIL, NIL };
	}
}

void regnode(int id, int k, int c[]) {
	for (int j = 0; j < k; j++) {
		if (j == 0)
			T[id].l = c[0];
		if (j < k - 1)
			T[c[j]].r = c[j + 1];
		T[c[j]].p = id;
	}
}

string gettype(int id) {
	if (T[id].p == NIL)
		return "root";
	else if (T[id].l == NIL)
		return "leaf";
	else
		return "internal node";
}

int main() {
	int n;
	cin >> n;
	initnode(n);
	for (int i = 0; i < n; i++) {
		int id, k;
		cin >> id >> k;
		int c[k];
		for (int j = 0; j < k; j++) {
			cin >> c[j];
		}
		regnode(id, k, c);
	}
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << T[i].p << ", depth = "
				<< getdepth(i) << ", " << gettype(i) << ", ";
		printchildren(i);
	}
	return 0;
}



Measured memory_bytes: 4700
#include <bits/stdc++.h>
using namespace std;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define ull				unsigned long long
const double PI = 2 * acos(0.0);
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 1e6 + 5;

int main() {
	run();
	int n;
	cin >> n;
	vi v(n);
	int fr = 0, sec = 0;
	multiset<int, greater<int>> ms;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		ms.insert(v[i]);

	}
	auto it = ms.begin();
	it++;
	fr = *ms.begin();
	sec = *(it);
	for (int i = 0; i < n; i++) {
		if (v[i] == fr)
			cout << sec << endl;
		else
			cout << fr << endl;
	}
}


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

using namespace std;

typedef long long ll;

string s, t;

void GetLCM(ll sourceA, ll sourceB, ll &dstgcd, ll &dstlcm)
{
	ll lcm;
	ll a, b, r;
	ll temp;

	a = sourceA;
	b = sourceB;

	if (a < b)
	{
		temp = a;
		a = b;
		b = temp;
	}

	r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}

	lcm = sourceA *	sourceB / b;

	dstgcd = b;
	dstlcm = lcm;

}

int main()
{
	ll n, k;
	
	ll lcm, gcd;
	
	ll lltmp;
	
	cin >> n >> k;
	cin >> s >> t;

	if (n < k)
	{
		lltmp = n;
		n = k;
		k = lltmp;
		
		s.swap(t);
	}
				
	GetLCM(n, k, gcd, lcm);

	for (ll i = 0; i < gcd; i++)
	{
		if (s[(n / gcd)*i] != t[(k / gcd)*i])
		{
			cout << "-1";
			return 0;
		}
	}

	cout << lcm;
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define lli long long int
#define floop(a,b,c) for(lli a=b;a<c;a++)
#define bloop(a,b,c) for(lli a=b;a>=c;a--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vt vector
#define MAX 1000000007
using namespace std;
lli t,n;
lli i,j;
int main(){
        cin>>n;
        lli a[n]; floop(i,0,n) cin>>a[i];
        lli cost[n]={0}; cost[1]=abs(a[1]-a[0]);
        floop(i,2,n){
            cost[i]=min(cost[i-1]+(abs(a[i]-a[i-1])),cost[i-2]+(abs(a[i]-a[i-2])));
        }
        cout<<cost[n-1];
        return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

bool is_prime(int x) {
    if (x == 1) return false;
    else if (x == 2) return true;
    else if (x % 2 == 0) return false;
    else {
        for (int i = 3; i*i <= x; i += 2) {
            if (x % i == 0) return false;
        }
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<int> ans;
    rep(i, 2, 55555) {
        if (is_prime(i) && i % 5 == 1) {
            ans.push_back(i);
            if ((int)ans.size() == n) {
                break;
            }
        }
    }
    rep(i, 0, n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*; 
import java.io.*;

class Main {

  public static String StringPeriods(String str) {
    boolean flag = false;
    String ans = "";
    for(int i=0;i<str.length();i++){
      String temp = str;
      String substr = str.substring(0,i);
      temp = temp.replaceAll(substr, "");
      if(temp.equals("")) {
    	  flag = true;
    	  ans = substr;
    	  break;
      }
    }
    if(flag) {
    	str = ans;
    }else {
    	str = "-1";
    }
    // code goes here  
    return str;
  }

  public static void main (String[] args) {  
    // keep this function call here     
    Scanner sc = new Scanner(System.in);
   int N=sc.nextInt();
   Map<Integer,Integer> map = new HashMap<Integer,Integer>();
   int[] A= new int[N];
   for(int i=0;i<N;i++) {
	   A[i]=sc.nextInt();
	   if(!map.containsKey(A[i])) {
		   map.put(A[i],1);
	   }else {
		   map.put(A[i],map.get(A[i])+1);
	   }
   }
   long anstemp = 0;
   for(Integer key:map.keySet()) {
	   long v = map.get(key);
	   anstemp+=(v*(v-1)/2);
	}
   for(int i=0;i<N;i++) {
	   long ans = anstemp;
	   long v = map.get(A[i]);
	   ans -= (v*(v-1)/2);
	   ans += ((v-1)*(v-2)/2);
	   System.out.println(ans);
   }
   
  }
}

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

int main() {
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  
  double a = H * 30.0;
  double b = M * 5.5;
  double c;
  
  if (a > b) {
    c = a - b;
  }
  else {
    c = b - a;
  }
  
  if (c > 360-c) {
    c = 360 - c;
  }
  
#include <math.h>
#include <stdio.h>

  double deg = c;   
  double pi,unit,deg_c;
  
  pi     = 2.0 * asin(1.0);            /* πの値 */
  unit   = pi / 180.0;    
  deg_c  = deg * unit;
  
  double x = sqrt(A*A + B*B - 2*A*B*cos(deg_c));
  
  cout << fixed << setprecision(15) << x << endl;
}

Measured memory_bytes: 4092
#include<cstdio>
using namespace std;
int main()
{
	int n,i,x,flg;
	scanf("%d",&n);
	flg=0;
	for(i=1;i<=9;i++){
		x=n/i;
		if(n%i==0)	flg=1;
		if(flg==1){
			if(x>9)	flg=0;
		}
	}
	if(flg==1)		printf("Yes\n");
	else	printf("No\n");
	return 0;
}	

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

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int> V(N);
	for (auto& e: V) scanf("%d", &e);
	int sum{};
	for (auto& e: V)
	{
		int C;
		scanf("%d", &C);
		e -= C;
		if (e > 0) sum += e;
	}
	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
  int plen,cnum,width,cspace;
  while(cin >> plen >> cnum >> width >> cspace && plen){
    vector<string> column;
    vector<string> words;
    string s;
    int len=0;
    getline(cin,s);
    while(true){
      getline(cin,s);
      if(s=="?")break;
      len+=s.length();
      words.push_back(s);
    }
    if(len==0){
      cout <<"?"<<endl;
      continue;
    }
    for(int i = 0; i < (int)words.size(); ++i){
      if((int)words[i].length()<width){
	column.push_back(words[i]);
      }else{
	string t = words[i];
	while((int)t.length()>=width){
	  column.push_back(t.substr(0,width));
	  t.erase(t.begin(),t.begin()+width);
	}
	if(t.length()>0){
	  column.push_back(t);
	}
      }
    }
    while((column.size()%(plen*cnum))!=0){
      column.push_back("");
    }
    int now_page=1;
    bool broke=false;
    for(int i = 0; i < (int)column.size(); ++i){
      if(i>0&&(i%plen)==0){
	i=plen*cnum*now_page;
	cout<<"#"<<endl;
	if(i>=(int)column.size()){
	  broke=true;
	  break;
	}
	++now_page;
      }

      int now_print = i;
      for(int j = 0; j < cnum; ++j){
	cout << column[now_print];
	for(int k = 0; k < width-(int)column[now_print].length(); ++k){
	  cout<<'.';
	}
	if(j<cnum-1){
	  for(int k = 0; k < cspace; ++k){
	    cout <<'.';
	  }
	}
	now_print += plen;
      }
      cout << endl;
    }
    if(!broke)cout<<"#"<<endl;
    cout << "?" << endl;
  }
  return 0;
}

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

int main() {
  int k;
  cin >> k;
  cout << (k / 2) * ((k + 1) / 2) << endl;
  return 0;
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
int n,k, A[202020];

void solve() {
  cin>>n>>k;
  rep(i,1,n)A[i]=read();
  sort(A+1,A+n+1);
  ll sum=0;
  rep(i,1,k)sum+=A[i];
  cout<<sum<<endl;
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>
#include<atcoder/all>
using namespace atcoder;

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl

using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}
long long myPow(int x,int n){
    int res=1;
    int cur=x;
    while(n>0){
        if(n&1){
            res*=cur;
        }
        n/=2;cur*=cur;
    }
    return res;
}
lint solve(lint n){
//lint n;cin>>n;
  map<lint,int> prime;
  lint bbuf=n*2;
  for(int i=2;i*i<=n*2;++i){
    while(bbuf%i==0){
      bbuf/=i;
      prime[i]+=1;
    }
  }
  if(bbuf>1)prime[bbuf]+=1;
  vector<pair<lint,int>> primes;
  for(auto& val:prime){
    primes.push_back({val.first,val.second});
  }
  lint num=primes.size();
  lint res=inf;
  for(lint bit=0;bit<(1<<num);++bit){
    lint a=1;lint b=1;
    for(int i=0;i<num;++i){
      if(bit&(1<<i)){
        a*=myPow(primes[i].first,primes[i].second);
      }
      else{
        b*=myPow(primes[i].first,primes[i].second);
      }
    }
    vector<lint> r(2),m(2);
    r[0]=0;m[0]=a;
    r[1]=b-1;m[1]=b;
    auto p=crt(r,m);
    if(p.first==0)continue;
    res=min(res,p.first);
  }
  return res;
}
signed main(){
    map<lint,int> memo;
    for(int i=1;i<=10000;++i){
        if(memo.find(i*(i+1)/2)==memo.end())memo[i*(i+1)/2]=i;
    }
    lint n;cin>>n;
    lint res;
    if(memo.find(n)==memo.end())res=solve(n);
    else res=memo[n];
    for(auto& val:memo){
      lint buf=solve(val.second);
      if(val.first!=buf&&false){
        debug(val.first);
        debug(val.second);
        debug(buf);
      }
    }
    cout<<res<<"\n";
}


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

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int64_t INF{};
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  int V{};
  for(int i = 0; i < N; ++i)
  {
    cin >> w[i] >> v[i];
    V += v[i];
    INF += w[i];
  }
  vector<int64_t> dp(V + 1, INF);
  dp[0] = 0;
  for(int i = 0; i < N; ++i)
  {
    for(int j = V; j >= v[i]; --j)
    {
      dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
    }
  }
  
  int res{};
  
  for(int i = 0; i <= V; ++i)
  {
    if(dp[i] <= W)
    {
      res = max(res, i);
    }
  }
  
  cout << res << "\n";
  
  return 0;
}

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

using namespace std;

int main(){
  int n, a, b, sum=0;
  cin >> n >> a >> b;
  for(int i=1;i<=n;i++){
    int mod, tmp_sum=0, t=i;
    while(t!=0){
      mod=t%10;
      tmp_sum+=mod;
      t/=10;
    }
    if((a<=tmp_sum)&&(tmp_sum<=b))sum+=i;
  }
  cout << sum << endl;
  

}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
def min_sum(N):
  dp=[0]*(N)
  for i in range(N):
    if i==0 or i==1:
      dp[0]=0
      dp[1]=abs(H[1]-H[0])
    else:
      dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
    
  return dp[N-1]

print(min_sum(N))

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

using namespace std;

int N;
int A[100];
int B[100];

int main(){
    cin >> N;
    for(int i=0;i<N-1;i++){
        cin >> B[i];
    }
    int m = B[0] + B[N-2];
    for(int i=1;i<N-1;i++){
        m += min(B[i],B[i-1]);
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define x first
#define y second
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;

typedef pair<int, int> pii;

int n, a, b, c, d, q, ans;

int main() {
	INIT
	cin >> a >> b >> c >> d;
	cout << int((a - c) * (b - d));

	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/agc035/tasks/agc035_a
//A - XOR Circle
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N; cin>>N;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    ll ans=an[0];
    FOR(i,1,N){
        ans ^= an[i];
    }
    cout<<(ans==0?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

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



int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	int p[114514];
	cin >> n;
	REP(i, n){
		cin >> p[i]; p[i]--;
	}
	int cnt = 0;
	REP(i, n){
		if(p[i] == i){
			if((i == 0 || p[i+1] == i+1) && i != n-1){
				cnt++;
				swap(p[i], p[i+1]);
			}else{
				cnt++;
				swap(p[i], p[i-1]);
			}
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 640
x, y = map(int, input().split())
if x * y > 0:
    if x < y:
        print(y-x)
    else:
        print(x-y+2)
elif x * y < 0:
    print(abs(abs(y)-abs(x)) + 1)
elif x==0:
    if y > 0:
        print(y)
    else:
        print(abs(y)+1)
else:
    if x > 0:
        print(x+1)
    else:
        print(abs(x))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000009
const long long INF = 1LL<<60;

int main() {
    int n;
    cin>>n;
    vector<ll> t(n),a(n);
    rep(i,n) cin>>t[i]>>a[i];
    ll pret=t[0];
    ll prea=a[0];
    for(int i=1;i<n;i++){
        if(pret<=t[i] && prea<=a[i]){
            pret=t[i];
            prea=a[i];
        }
        else if(pret>t[i] && prea>a[i]){
            ll tmp1=(t[i]+pret-1)/t[i];
            ll tmp2=(a[i]+prea-1)/a[i];
            ll tmp=max(tmp1,tmp2);
            pret=tmp*t[i];
            prea=tmp*a[i];
        }
        else if(pret>t[i]){
            ll tmp=(t[i]+pret-1)/t[i]; 
            pret=tmp*t[i];
            prea=tmp*a[i];
        }
        else if(prea>a[i]){
            ll tmp=(a[i]+prea-1)/a[i];
            pret=tmp*t[i];
            prea=tmp*a[i];
        }
        //cout<<pret<<" "<<prea<<endl;
    }

    ll ans=pret+prea;
    cout<<ans<<endl;

}

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

int main(){
  int A,B,C,count;
  cin >> A >> B;
  while(A <= B){
    if(A/10000 == A%10){
      C = A%10000/10;
      if(C/100 == C%10){
        count++;
      }
    }
    A++;
  }
  cout << count;
      
}  
 

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

#define rep(i,n) for(int i=0;i<n;i++)
#define clear(v) memset(v,0,sizeof(v))
#define ALL(v) (v).begin(),(v).end()


int main(){
	int n;
	while (cin >> n, n){
		rep(i, n){
			int p[3]; rep(i, 3) cin >> p[i];
			double ave = (p[0] + p[1] + p[2]) / 3.0;
			char ans;
			if (p[0] == 100 || p[1] == 100 || p[2] == 100){
				ans = 'A';
			} else if ((p[0]+p[1])/2.0>=90){
				ans = 'A';
			} else if (ave >= 80){
				ans = 'A';
			} else if (ave >= 70){
				ans = 'B';
			} else if (ave >= 50 && (p[0] >= 80 || p[1] >= 80)){
				ans = 'B';
			} else{
				ans = 'C';
			}
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 1152