akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict
N = int(input())
MOD = 10**9+7
dp = [0]*(N+1)
dp[0] = 1
dic = defaultdict(int)
p = -1
for i in range(N):
  c = int(input())
  if c==p:
    dp[i+1] = dp[i]
    continue
  dic[c] += dp[i]
  dp[i+1] = dic[c]%MOD
  p = c
#  print(dp)

print(dp[-1]%MOD)

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

int main(){
    int s;
    cin >> s;
    int now = s;
    vector<int> num(1000005);
    num[s]++;
    for(int i = 2; ; i++){
        if(now % 2 == 0) now /= 2;
        else now = now*3 + 1;
        if(num[now] == 1){
            cout << i << endl;
            return 0;
        }
        num[now]++;
    }
}

Measured memory_bytes: 7216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

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

	int n,k,sk=0;
	cin >> n >> k;
	FOR(i,0,k){
		int x;
		cin >> x;
		sk += (1<<(x+1));
	}
	FOR(i,0,(1<<n)){
		vector<int> p;
		int ok = sk;
		FOR(j,0,n){
			if(i&(1<<j)){
				p.push_back(j);
				if(sk&(1<<(j+1)))ok-=(1<<(j+1));
			}
		}
		if(ok)continue;
		cout << i << ":";
		FOR(j,0,p.size()){
			cout << " " << p[j];
		}
		cout << endl;
	}
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

const ll inf=1e18;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    ll n;
    cin>>n;
    ll ans=1,v=0,zero=0;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        if(x==0) zero=1;
        double tmp=1e18/(double)x;
        //cout<<setprecision(14)<<ans<<" "<<tmp<<endl;
        if((double)ans>tmp || v){
            v=1;
            continue;
        }
        ans*=x;
        if(ans>inf) v=1;
    }
    if(zero) cout<<0<<endl;
    else if(v) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}


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

using namespace std;
typedef long long int ll;
int main() 
{
 ll h,w;
 cin>>h>>w;
 ll k=h*w;
 if(h==1 || w==1)
 {
     cout<<"1";
 }
 else if(k%2==0)
 {
     cout<<k/2;
 }
 else
 {ll g=k/2+1;
     cout<<g;
 }


return 0;    
}

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

int main() {
    string n;
    cin >> n;
    if((n[0]==n[1] && n[1]==n[2])||(n[1]==n[2]&&n[2]==n[3]))
    {
        cout  << "Yes" << endl;
    }else{
        cout  << "No" << endl;
    }

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

template <typename T>
vector<T> divisor(T n) {
  vector<T> ret;
  for (T i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  return ret;
}

int main(void) {
  int n, m;
  cin >> n >> m;
  auto div = divisor(m);
  sort(all(div), greater<int>());
  allrep (d, div) {
    if (m / d >= n) {
      cout << d << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
from functools import reduce
n = int(input())
p = list(map(int, input().split()))
add_0 = int(reduce(lambda x, y: x+y, p)/n)
add_1 = add_0+1
res_0 = res_1 = 0
for digit in p:
    res_0 = res_0 + (digit-add_0)**2
    res_1 = res_1 + (digit-add_1)**2
print(min(res_0,res_1))

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

using namespace std;

long long p[20020];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long long h, n, a, b, m;
	cin >> h >> n;
	for(long long i = 1; i <= h + 10005; ++i) p[i] = 1000000009;
	for(long long i = 0; i < n; ++i){
		cin >> a >> b;
		for(long long j = a; j < h + 10005; ++j) p[j] = min(p[j], p[j - a] + b);
	}
	m = 1000000009;
	for(long long i = h; i < h + 10005; ++i) m = min(m, p[i]);
	cout << m;

	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


long long GCD(long long x, long long y) {
    return y ? GCD(y, x%y) : x;
}


long long A, B;
int main() {
    while (cin >> A >> B) {
        long long G = GCD(A, B);
        auto pf = prime_factorize(G);
        cout << pf.size() + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 200100;

bool done[d5];
int ans[d5],sum[d5];
vector<int> adj[d5];

void dfs(int root,int extra){
    done[root]=true;
    ans[root]=sum[root]+extra;
    for(auto u:adj[root]){
        if(!done[u]){
            dfs(u,extra+sum[root]);
        }
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,u,v,q,x,p;
    cin>>n>>q;
    for(int i=1;i<n;i++){
        cin>>u>>v;
        u--;
        v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i=0;i<q;i++){
        cin>>x>>p;
        sum[x-1]+=p;
    }
    dfs(0,0);
    for(int i=0;i<n;i++){
        cout<<ans[i]<<' ';
    }
    cout<<endl;
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }


int main() {
  lint n; cin >> n;
  vector<lint> a(n); for(lint i=0;i<n;i++) { cin >> a[i]; }

  map<lint,lint> mp;
  for(lint i=0;i<n;i++) { mp[a[i]]++; }

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

  if(a[n-1] == 0) { cout << "Yes\n"; return 0; } // all zero
  if(n%3 != 0) { cout << "No\n"; return 0; }
  if(mp.size() > 3) { cout << "No\n"; return 0; }

  if(mp.size() == 2) {
    if(mp[0] == n/3 && mp[a[n/3]] == n/3*2) { cout << "Yes\n"; return 0; }
  } else if(mp.size() == 3) {
    if(mp[a[0]] == n/3 && mp[a[n/3]] == n/3 && mp[a[n/3*2]] == n/3) {
      if((a[0] ^ a[n/3] ^ a[n/3*2]) == 0) {
        // cout << a[0] << a[n/3] << a[n/3*2];
        cout << "Yes\n"; return 0;
      }
    }
  }

  cout << "No\n";
  return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>


int main() {
	std::string s;

	std::cin >> s;

	int max = 0;

	for (size_t i = 0; i < s.length(); i++)
	{
		int count = 0;
		for (size_t j = i; j < s.length(); j++)
		{
			if (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T') {
				count++;
			}
			else {
				break;
			}
		}
		max = std::max(max, count);
	}

	std::cout << max << std::endl;

	return 0;
}

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

long solve(int* weights, int* values, int n, int W, int index, long** dp){
    if(index==n-1){
        if(W>=weights[index]){
            return values[index];
        }else{
            return 0;
        }
    }
    if(index>=n){
        return 0;
    }
    if(W<=0){
        return 0;
    }
    if(dp[index][W]!=-1){
        return dp[index][W];
    }

    //without including this weight
    long ans1=solve(weights, values, n, W, index+1, dp);

    //including this weight
    long ans2=0;
    if(W-weights[index]>=0)
        ans2=values[index]+solve(weights, values, n, W-weights[index], index+1, dp);

    long res=max(ans1, ans2);
    dp[index][W]=res;
    return res;
}

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

    int W;
    cin>>W;

    int* weights=new int[n];
    int* values=new int[n];

    for(int i=0; i<n; i++){
        cin>>weights[i];
        cin>>values[i];
    }

    long** dp=new long*[n+1];
    for(int i=0; i<=n; i++){
        dp[i]=new long[W+1];
    }
    for(int i=0; i<=n; i++){
        for(int j=0; j<=W; j++){
            dp[i][j]=-1;
        }
    }

    long maxprofit=solve(weights, values, n, W, 0, dp);
    cout<<maxprofit<<endl;


}

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

//flag を用いてバブルソート
int bubbleSort(int A[], int N){
  int sw = 0;
  bool flag = 1;
  for (int i = 0; flag; i++){
    flag = 0;
    for (int j = N-1; j >= i+1; j--){
      if (A[j] < A[j-1]){
        //隣接要素を交換する
        swap(A[j], A[j-1]);
        flag = 1;
        sw++;
      }
    }
  }
  return sw;
}

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

  sw = bubbleSort(A, N);

  for (int i = 0; i < N; i++){
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

const int MAX = 1e5 + 5;
const ll INF = 9223372036854775807;
const int MOD = 1e9 + 7;

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

    vector<P> D;
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        D.emplace_back(x, y);
    }

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

    ll ans = INF;

    rep(i, N)rep(j, N) {
        int y1 = min(D[i].second, D[j].second);
        int y2 = max(D[i].second, D[j].second);

        int r = 0, cnt = 0;
        rep(l, N) {
            while(r < N && cnt < K) {
                if (y1 <= D[r].second && D[r].second <= y2) cnt++;
                r++;
            }

            if (cnt == K) ans = min(ans, (ll)(D[r-1].first - D[l].first) * (y2 - y1));
            
            if (l == r) r++;
            else if (y1 <= D[l].second && D[l].second <= y2) cnt--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mx = 100005;
vector<int> adj[mx];
vector<int> radj[mx];
vector<int> sorted;
vector<bool> visited(mx);


void dfs(int v, int p)
{
	if (visited[v])
	{
		return;
	}
	visited[v] = true;
	for (int a : adj[v])
	{
		if (a != p)
		{
			dfs(a, v);
		}
	}
	sorted.push_back(v);
}
int main()
{
	int n,m;
	cin >> n >> m;
	for (int q = 0; q < m; q++)
	{
		int a,b;
		cin >> a >> b;
		adj[a].push_back(b);
		radj[b].push_back(a);
	}
	for (int q = 1; q <= n; q++)
	{
		if (!visited[q])
		{
			dfs(q, -1);
		}
	}
	reverse(sorted.begin(), sorted.end());
	int dp[n];
	int best = 0;
	for (int q = 0; q < n; q++)
	{
		dp[sorted[q]] = 0;
		for (int a : radj[sorted[q]])
		{
			dp[sorted[q]] = max(dp[sorted[q]], dp[a]+1);
		}
		best = max(best, dp[sorted[q]]);
	}
	cout << best << "\n";
	return 0;
}


Measured memory_bytes: 13824
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

static int color[100010];
static int length[100010];
static vector<int> graph[100010];


int splat(int ver,int len,int col){
	int i;

	if(len<=length[ver]) return 0;
	if(color[ver]==0) color[ver]=col;

	length[ver]=len;

	if(len>0){
		for(i=0;i<graph[ver].size();i++){
			splat(graph[ver][i],len-1,col);
		}
	}

	return 0;
}

int main(void)
{
	//変数の宣言
	int n,m,q;
	static int a[100010];
	static int b[100010];
	static int v[100010];
	static int d[100010];
	static int c[100010];
//	vector<int> graph[100010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;
	int ok,ng;
	int r;


	//データの読み込み


	scanf("%d %d",&n,&m);
//	scanf_s("%d %d",&n,&m);

	for(i=0;i<m;i++){
		scanf("%d %d",&a[i],&b[i]);
//		scanf_s("%d %d",&a[i],&b[i]);
		graph[a[i]].push_back(b[i]);
		graph[b[i]].push_back(a[i]);
	}

	scanf("%d",&q);
//	scanf_s("%d",&q);

	for(i=0;i<q;i++){
		scanf("%d %d %d",&v[i],&d[i],&c[i]);
//		scanf_s("%d %d %d",&v[i],&d[i],&c[i]);
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	for(i=1;i<=n;i++){
		color[i]=0;
		length[i]=-1;
	}

	for(i=q-1;i>=0;i--){
		splat(v[i],d[i],c[i]);
/*		for(j=1;j<=n;j++){
			printf("%d ",color[j]);
		}
		printf("\n");*/
	}
	

	//	printf("計算部分終了\n");

	//出力

	for(i=1;i<=n;i++){
		printf("%d\n",color[i]);
	}



	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 9208
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

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

		ArrayList<Double> standardDeviationList = new ArrayList<Double>();

		int inputCount;
		while (EndDecision(inputCount = sc.nextInt())) {
			int[] scores = new int[inputCount];
			for (int i = 0; i < inputCount; i++) {
				scores[i] = sc.nextInt();
			}
			standardDeviationList.add(StandardDeviationCalculation(scores));
		}

		for (double value : standardDeviationList) {
			System.out.println(value);
		}

	}

	private static double StandardDeviationCalculation(int[] scores) {
		double sum = 0;
		double standardDeviation = 0;
		for (int i : scores)
			sum += i;
		for (int i : scores)
			standardDeviation += Math.pow((sum / scores.length) - i, 2);
		standardDeviation = Math.sqrt(standardDeviation / scores.length);

		return standardDeviation;
	}

	private static boolean EndDecision(int i) {
		if (i == 0) {
			return false;
		} else {
			return true;
		}
	}

}



Measured memory_bytes: 31740
import java.util.*;
import java.io.*;
 
public class Main {
  public static void main(String[] args) throws Exception{
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    new Solution(n);
  }
}

class Solution {
  public Solution(int n) {
    boolean res = false;
    while(n > 0) {
      if(n % 10 == 7) res = true;
      n /= 10;
    }
    if(res) System.out.println("Yes");
    else System.out.println("No");
  }
}



class FastScanner {
  private final InputStream in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  public FastScanner(InputStream source) {
    in = source;
  }

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) return buffer[ptr++];
    else return -1;
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public long nextLong() {
    if (!hasNext()) throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public int nextInt() {
    long nl = nextLong();
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
      throw new NumberFormatException();
    return (int) nl;
  }

  public double nextDouble() {
    return Double.parseDouble(next());
  }
}

Measured memory_bytes: 25460
line = input()
n, x = [int(i) for i in line.split()]
line = input()
l = [int(j) for j in line.split()]
if n>1:
    coord=0
    s=2
    for k in range(len(l)-1):
        if l[k] + l[k+1] + coord <= x :
            s+=1
        coord = coord+l[k]

    print(s)
else:
    print("2")       


Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string num, sub;
    int m, h;
    while(cin >> num){
    if(num == "-") break;
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> h;
        sub = num.substr(0, h);
        num = num.erase(0, h);
        num += sub;
    }
    cout << num << endl;
    }
    return 0;
    
}



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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

ll calc(vector<int> v) {
    ll s = 0;
    fori(i, 1, v.size()) {
        s += abs(v[i] - v[i - 1]);
    }
    return s;
}

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n);
    fori(i, 0, n) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    /*
    vector<int> p(n);
    iota(p.begin(), p.end(), 0);
    ll best = 0;
    vector<int> krai;
    do {
        vector<int> tmp;
        fori(i, 0, n) {
            tmp.push_back(v[p[i]]);
        }
        ll now = calc(tmp);
        if(now > best) {
            best = now;
            krai = tmp;
        }
    } while(next_permutation(p.begin(), p.end()));
    debug(best);
    for(auto &each : krai) debug(each);
    */
    ll ans = 0;
    vector<int> a(n);
    a[0] = v[n / 2];
    int l = 0, r = n - 1;
    fori(i, 1, n) {
        if(i & 1) {
            a[i] = v[r--];    
        }
        else {
            a[i] = v[l++];
        }
    }
    ans = calc(a);
    a[0] = v[n / 2];
    l = 0, r = n - 1;
    fori(i, 1, n) {
        if(i & 1) {
            a[i] = v[l++];    
        }
        else {
            a[i] = v[r--];
        }
    }
    ans = max(ans, calc(a));
    if(n % 2 == 0) {
        vector<int> b(n);
        l = 0, r = n - 1;
        b[0] = v[n / 2 - 1];
        fori(i, 1, n) {
            if(i & 1) {
                b[i] = v[l++];
            }
            else {
                b[i] = v[r--];
            }
        }
        ans = max(ans, calc(b));
        l = 0, r = n - 1;
        b[0] = v[n / 2 - 1];
        fori(i, 1, n) {
            if(i & 1) {
                b[i] = v[r--];
            }
            else {
                b[i] = v[l++];
            }
        }
        ans = max(ans, calc(b));
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1784
module Direction
  TURN_LEFT = 0
  TURN_RIGHT = 1
  BASE = TURN_RIGHT
end

class Edge
  def initialize length
    @length = length
    @next_edge = nil
    @next_direction = nil
    @prev_edge = nil
    @prev_direction = nil
  end

  def eql? edge
    return false unless @length == edge.length
    return true if @next_edge.nil? and edge.next_edge.nil?
    return false if @next_edge.nil? or edge.next_edge.nil?
    return false unless @next_direction == edge.next_direction
    return @next_edge.eql?(edge.next_edge)
  end

  def reverse_eql? edge
    return false unless @length == edge.length
    return true if @next_edge.nil? and edge.prev_edge.nil?
    return false if @next_edge.nil? or edge.prev_edge.nil?
    return false unless @next_direction == edge.prev_direction
    return @next_edge.reverse_eql?(edge.prev_edge)
  end

  attr_accessor :length, :next_edge, :next_direction, :prev_edge, :prev_direction
end

def main
  loop do
    n = gets.chomp.to_i
    break if n == 0

    polygonal_lines = []
    (n+1).times do
      line = []
      m = gets.chomp.to_i
      prev_x,prev_y = gets.chomp.split(' ').map(&:to_i)
      prev_prev_x = nil
      prev_prev_y = nil
      prev_edge = nil
      (m-1).times do
        x,y = gets.chomp.split(' ').map(&:to_i)

        length = get_length(prev_x, prev_y, x, y)
        edge = Edge.new(length)

        unless line.empty?
          prev_edge.next_direction = get_direction(x, y, prev_x, prev_y, prev_prev_x, prev_prev_y)
          edge.prev_direction = prev_edge.next_direction ^ Direction::BASE
          prev_edge.next_edge = edge
          edge.prev_edge = prev_edge
        end
        line << edge

        prev_edge = edge
        prev_prev_x = prev_x
        prev_prev_y = prev_y
        prev_x = x
        prev_y = y
      end
      polygonal_lines << line
    end

    target = polygonal_lines.shift
    polygonal_lines.each_with_index do |p_line, i|
      puts i + 1 if target[0].eql?(p_line[0]) or target[0].reverse_eql?(p_line[-1])
    end
    puts '+++++'
  end
end

def get_direction x, y, prev_x, prev_y, prev_prev_x, prev_prev_y
  case
  when x > prev_x
    case
    when prev_y > prev_prev_y; Direction::TURN_RIGHT
    when prev_y < prev_prev_y; Direction::TURN_LEFT
    end
  when x < prev_x
    case
    when prev_y > prev_prev_y; Direction::TURN_LEFT
    when prev_y < prev_prev_y; Direction::TURN_RIGHT
    end
  when y > prev_y
    case
    when prev_x > prev_prev_x; Direction::TURN_LEFT
    when prev_x < prev_prev_x; Direction::TURN_RIGHT
    end
  when y < prev_y
    case
    when prev_x > prev_prev_x; Direction::TURN_RIGHT
    when prev_x < prev_prev_x; Direction::TURN_LEFT
    end
  end
end

def get_length prev_x, prev_y, next_x, next_y
  unless next_x == prev_x
    if (next_x <=> prev_x) > 0
      return (next_x - prev_x).abs + 1
    else
      return (prev_x - next_x).abs + 1
    end
  else
    if (next_y <=> prev_y) > 0
      return (next_y - prev_y).abs + 1
    else
      return (prev_y - next_y).abs + 1
    end
  end
end

main

Measured memory_bytes: 6088
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

int dp[200010];

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;

        ans = max(ans, dp[v] = dp[v - 1] + 1);
    }
    cout << n - ans << '\n';
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  int num = 643;

  vector<int>a(5);
  for (auto it = a.begin(); it != a.end(); ++it) cin >> *it;

  vector<int> v(a.size());
  for (int i = 0; i < a.size(); ++i) {
    v[i] = i;
  }

  do {
    int tmp = 0;
    for (int i = 0; i < v.size(); ++i) {
      tmp += a[v[i]];
      if (i != 4 && tmp % 10 != 0) {
        tmp += 10 - (tmp % 10);
      }
    }
    num = min(tmp, num);
  } while(next_permutation(v.begin(), v.end()));

  cout << num << endl;
  
  return 0;
}


Measured memory_bytes: 256
N=int(input())
AB=[list(map(int,input().split())) for i in range(N)][::-1]
count=0
for i in range(N):
    AB[i][0]+=count
    if AB[i][0]%AB[i][1]!=0:
        count+=AB[i][1]-(AB[i][0]%AB[i][1])
print(count)

Measured memory_bytes: 32160
#include<iostream>
#include<vector>
using namespace std;
vector<vector<int> > g,rg;
vector<int> vs,used,cmp;

void dfs(int v){
    used[v] = 1;
    for(int i = 0; i < g[v].size(); i++){
        if(!used[g[v][i]])dfs(g[v][i]);
    }
    vs.push_back(v);
}

void rdfs(int v, int k){
    used[v] = 1;
    cmp[v] = k;
    for(int i = 0; i < rg[v].size(); i++){
        if(!used[rg[v][i]])rdfs(rg[v][i],k);
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    g = rg = vector<vector<int> >(n);
    used = cmp = vector<int>(n,0);
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        rg[b].push_back(a);
    }
    for(int v = 0; v < n; v++){
        if(!used[v])dfs(v);
    }
    used = vector<int>(n,0);
    int k = 0;
    for(int i = vs.size()-1; i >= 0; i--){
        if(!used[vs[i]])rdfs(vs[i],k++);
    }
    for(int i = 0; i < n; i++){
        int num = cmp[i];
        vector<int> ans;
        for(int j = 0; j < n; j++){
            if(cmp[j] == num)ans.push_back(j);
        }
        for(int j = 0; j < ans.size(); j++){
            if(j)cout << " ";
            cout << ans[j]+1;
        }
        cout << endl;
    }
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a));
#define size_of(a) (int)a.size()

typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;

const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
const Double EPS = 1e-9;

string S;

bool parse(int left, int right) {
	if (left > right) return true;
	if (S[left] != 'm' || S[right] != 'w') return false;
	
	int mcnt = 0, ecnt = 0;	
	int epos = -1;
	
	for_(i,left,right) {
		if (S[i] == 'm') mcnt++;
		if (S[i] == 'e') ecnt++;
		
		if (mcnt == ecnt) {
			epos = i;
			if (!parse(left + 1, epos - 1)) return false;
			if (!parse(epos + 1, right - 1)) return false;
			return true;
		}
	}
	
	return false;
}

void solve() {
	if (parse(0, size_of(S) - 1)) cout << "Cat" << endl;
	else cout << "Rabbit" << endl;
}

int main() {
	cin >> S;
	solve();
	return 0;
}

Measured memory_bytes: 1188
program sum
    implicit none
    integer(8) i,n,m,q,a(10),d(50,4),score1,flag
    read(*,*) n,m,q
    do i = 1, q
        read(*,*) d(i,1),d(i,2),d(i,3),d(i,4)
    end do

    do i = 1, n
        a(i)=1
    end do
    
    score1=0
    flag=n
    do while ( flag>0 )
        call routine(a,d,n,m,q,score1,flag)
    end do
    write(*,*) score1
end program sum

subroutine routine(a,d,n,m,q,score1,flag)
    implicit none
    integer(8) :: a(10), d(50,4), n, m, q, j, score, score1, flag

    score=0
    if ( flag==n ) then
        do while (a(n)<=m)
            ! do j = 1, n
            !     write(*,fmt='(I4)',advance='no') a(j)
            ! end do
            ! write(*,*)
            do j = 1, q
                if ( a(d(j,2))-a(d(j,1))==d(j,3) ) then
                    score=score+d(j,4)
                end if
            end do
            if ( score>score1 ) then
                score1=score
            end if
            ! write(*,*) score
            score=0
            a(n)=a(n)+1
        end do
        flag=flag-1
    else if ( a(flag)<m ) then
        a(flag)=a(flag)+1
        do j = flag+1, n
            a(j)=a(flag)            
        end do
        flag=n
    else
        flag=flag-1
    end if
end subroutine routine

Measured memory_bytes: 2864
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    
    int ans;
    if (k <= a)
        ans = k;
    else if (k <= a + b)
        ans = a;
    else
        ans = a - (k - (a + b));
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(d);
	cout << "Christmas ";
	while(d != 25)	cout << "Eve ", d++;
	cout << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
data=[0]*n
for i in a:
  data[i-1]+=1
data.sort()
m=n-k
if data.count(0)>=m:
  print(0)
else:
  ans=0
  res=data.count(0)
  while res<m:
    ans+=data[res]
    res+=1
  print(ans)

Measured memory_bytes: 32108
#include<stdio.h>

int main(){
  
  int S[10000], T[500], n, q, i, j, cnt = 0;
  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i = 0; i < q; i++) scanf("%d",&T[i]);
  
  for(i = 0; i < q; i++)
    for(j = 0; j < n; j++)  
      if(T[i] == S[j]) {
        cnt++;
        break;
      }
  
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  pair<string,int> p[N];
  REP(i,N){
    string s;
    int t;
    cin>>s>>t;
    p[i]=make_pair(s,t);
  }
  string X;
  cin>>X;
  bool f=false;
  lint ans=0;
  REP(i,N){
    if(f)ans+=p[i].second;
    if(p[i].first==X)f=true;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>

#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>

#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;

template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

class DisjointSet {
public:
  vint v;
  DisjointSet(int n) : v(n, -1) {}

  int root(int n) { return v[n] == -1 ? n : (v[n] = root(v[n])); }
  void unite(int a, int b) {
    int ra = root(a), rb = root(b);
    if (ra != rb) v[ra] = rb;
  }
};

int main() {
  int n, m;
  while (cin >> n >> m) {
    DisjointSet ds(n);
    REP(i,m) {
      int s, d, c;
      cin >> s >> d >> c;
      s--; d--;
      ds.unite(s, d);
    }
    // pp(ds.v);
    cout << count(ALL(ds.v), -1) << endl;
  }
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,s[120],count;;
	while(true){
		cin>>n;
		if(n==0)
			break;
		count=0;
		for(int i=0;i<n;i++){
			cin>>s[i];
			count+=s[i];
		}
		for(int i=0;i<n-1;i++){
			for(int j=n-1;j>i;j--){
				if(s[j]<s[j-1]){
					int tmp=s[j];
					s[j]=s[j-1];
					s[j-1]=tmp;
				}
			}
		}
		count-=s[0];
		count-=s[n-1];
		cout<<count/(n-2)<<endl;
	}
    return 0;
}
 

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

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF*INF;
const int MAX = 100010;
const long double PI = acos(-1.);
const double EPS = 1e-6;
LL mod = 1000LL*1000*1000 + 7;

VI g[100*1000+7];
int u[100*1000+7];
int dfs(int v,int v2)
{
	if(v==v2)
		return 1;
	u[v] = 1;
	FOR(i,0,SZ(g[v]))
		if(!u[g[v][i]])
			return dfs(g[v][i],v2);
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0); double startClock = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	int n,m;
	cin >> n >> m;
	FOR(i,0,m)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		g[a].PB(b);
		g[b].PB(a);
	}
	bool isok = 1;
	int cnt4 = 0;
	int cnt6 = 0;
	FOR(i,0,n)
	{
		if(SZ(g[i])%2)
			isok = 0;
		if(SZ(g[i])>=6)
			cnt6++;
		if(SZ(g[i])==4)
			cnt4++;
	}
	if(isok)
	{
		if(cnt6>0 ||cnt4>2)
			cout << "Yes";
		else
		{
			if(cnt4==2)
			{
				VI v;
				FOR(i,0,n)
					if(SZ(g[i])==4)
						v.PB(i);
				int res = dfs(v[0],v[1]);
				u[v[0]]=0;
				res+=dfs(v[0],v[1]);
				u[v[0]]=0;
				res+=dfs(v[0],v[1]);
				u[v[0]]=0;
				res+=dfs(v[0],v[1]);
				if(res==4)
					cout << "No";
				else
					cout << "Yes";
			}
			else
			{
				cout << "No";
			}
		}
	}
	else
		cout << "No";









	cerr << endl << (clock() - startClock)/CLOCKS_PER_SEC << endl;return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <map>
#include <algorithm>  
#include <cmath>
#include <iomanip>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll ans=n*(n+1);
    ans=ans/2;
    ll last=n/3;
    ll red=last*(last+1);
    red=(red*3)/2;
    ans-=red;
    last=n/5;
    red=last*(last+1);
    red=(red*5)/2;
    ans-=red;
    last=n/15;
    red=last*(last+1);
    red=(red*15)/2;
    ans+=red;
    cout<<ans<<endl;
}

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

/*ll fact(ll n)
{
  ll f=1,i;
  for(i=1;i<=n;i++)
  {
    f=f*i;
  }
  return f;
}*/
//#define FOR(i,0,n) for(int i=0;i<n;i++)
int main() {
  // your code goes here
 /* int t;
  cin>>t;
  while (t--)
  {*/
    
 ios_base::sync_with_stdio(false); 
    cin.tie(NULL);cout.tie(NULL);
    
 
    ll n,m,z,k;cin>>n>>m;
    z=n*(n-1)/2;
    k=m*(m-1)/2;
    cout<<z+k;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  vector<int> a(N);
  cin >> N;
  for(int i=0; i<N; i++) cin >>a.at(i);
  int count =0;
  
  for(int i=0; i<N; i++){
    if(a.at(i) % 2 !=0 && i % 2==0) count++;
  }
 cout << count << endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ss second
#define ff first
vector<vector<ll>> dp;ll it=0,f=0;
ll vsum=100000,wmax=1e9+1;

ll knapsack(ll v,ll i,ll wi[],ll vi[],ll n)
{
    if(v<=0)
    return 0;
    if(i==n)
    return wmax;
    if(dp[i][v]!=-1)
    return dp[i][v];
    dp[i][v]=min(knapsack(v,i+1,wi,vi,n),wi[i]+knapsack(v-vi[i],i+1,wi,vi,n));
    return dp[i][v];
}
int main() 
{
    ll n,i,j,k,x,y,w,flag=0;
    cin>>n>>w;
    ll wi[n],vi[n];
    for(i=0;i<n;i++)
    {
        cin>>wi[i]>>vi[i];
    }
    dp.resize(n+1);
    for(i=0;i<n+1;i++)
    dp[i].resize(100001);
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=100001;j++)
        {
            dp[i][j]=-1;
        }
    }
    for(i=vsum;i>=0;i--)
    {
        ll ans=knapsack(i,0,wi,vi,n);
        if(ans<=w)
        {
            cout<<i;
            break;
        }
    }//cout<<knapsack(9,0,wi,vi,n);
    return 0;
}


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

using namespace std;
mt19937_64 rng(58);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double theta1, theta2;
    theta1 = M_PI / 6.0 * (h + m / 60.0);
    theta2 = M_PI / 30.0 * m;
    double theta = min(2 * M_PI - abs(theta1 - theta2), abs(theta1 - theta2));
    // cout << theta << ", " << cos(theta / M_PI * 360.0) << endl;
    // cout << cos(M_PI_2) << endl;
    cout.precision(19);
    double c = sqrt(a * a + b * b - 2 * a * b * cos(theta));
    cout << c << endl;

}

Measured memory_bytes: 4208
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int[]a=new int[3];
        for(int i=0;i<3;i++){
            a[i]=sc.nextInt();
        }
        int K=sc.nextInt();
        Arrays.sort(a);
        int kk=1;
        for(int i=0;i<K;i++){
            kk=kk*2;
        }
        a[2]=a[2]*kk;
        System.out.println(a[0]+a[1]+a[2]);


        
}
        
        
    }


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define pb push_back
#define fs first
#define sc second
#define MOD 1000000007
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    vi A(n);
    rep(i,0,n) cin >> A[i];
    int cnt = 0;
    rep(i,1,n-1){
        vector<int> tmp(3);
        tmp[0] = A[i-1];
        tmp[1] = A[i];
        tmp[2] = A[i+1];
        sort(tmp.begin(), tmp.end());
        if(A[i] == tmp[1]) cnt++;
    }
    cout << cnt << endl;
}


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

using namespace std;
typedef long long ll;

int main(){
  string S;
  ll Q;
  cin >> S;
  cin >> Q;
  vector<char> s;
  for(ll i=0;i<S.length();i++){
    s.push_back(S[i]);
  }
  ll T[Q];
  vector<ll> q(Q);
  vector<char> p(Q); 
  for(ll i=0;i<Q;i++){
    cin >> T[i];
    if(T[i]==1){
      q[i]=0;
    }else{
      cin >> q[i] >> p[i];
    }
  }
  bool flag = true;
  for(ll i=0;i<Q;i++){
    if(T[i]==1){
      flag = !flag;
    }else{
      if(flag){
	if(q[i]==2){
	  s.push_back(p[i]);
	}else{
	  s.insert(s.begin(),p[i]);
	}
      }else{
	if(q[i]==2){
	  s.insert(s.begin(),p[i]);
	}else{
	  s.push_back(p[i]);
	}	
      }
    }
  }
  if(flag){
    for(ll i=0;i<s.size();i++){
      cout << s[i];
    }
  }else{
    for(ll i=s.size()-1;i>=0;i--){
      cout << s[i];
    }
  }
  cout << endl;
}


Measured memory_bytes: 6864
#include<stdio.h>

int main(){
  int A,B;
  int ans;
  scanf("%d%d",&A,&B);
  if(A > B){
    ans = A*2-1;
  }
  else if(A < B){
    ans = B*2-1;
  }
  else{
    ans = A*2;
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

//ユークリッドの互除法
unsigned gcd(unsigned a, unsigned b)
{
    if (a < b)
    {
        gcd(b, a);
    }

    unsigned r;

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

    return b;
}

int main()
{
    unsigned long long int a, b, c, d, e;

    cin >> a >> b >> c >> d;

    e = c * d / gcd(c, d);
    a--;

    cout << b - (b / c + b / d - b / e) - (a - (a / c + a / d - a / e));

    return 0;
}

Measured memory_bytes: 256
d, n = gets.split.map(&:to_i)

if d.zero?
  puts n == 100 ? 101 : n
elsif d == 1
  puts n == 100 ? 10100 : n.to_s + '00'
else
  puts n == 100 ? 1010000 : n.to_s + '0000'
end

Measured memory_bytes: 1916
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,m;
Vi a;
ll cal(ll n){
	switch(n){
		case 1:
			return 2;
			break;
		case 2:
		case 3:
		case 5:
			return 5;
			break;
		case 4:
			return 4;
			break;
		case 6:
			return 6;
			break;
		case 7:
			return 3;
			break;
		case 8:
			return 7;
			break;
		case 9:
			return 6;
			break;
		default:
			return 0;
			break;
	}
}

vector<string> dp;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>n>>m;
	a.resize(m);
	rep(i,m){
		cin>>a[i];
	}
	dp.resize(n+10,"-1");
	dp[0]="";
	rep(i,n){
		if(dp[i]=="-1")continue;
		rep(j,a.size()){
			ll tmp = i+cal(a[j]);
			string fig = dp[i]+(char)('0'+a[j]);
			string now = dp[tmp];
			if(now=="-1" || now.size()<fig.size()){
				dp[tmp] = fig;
			}else if(now.size()>fig.size()){

			}else{
				chmax(dp[tmp],fig);
			}
		}
	}
	print(dp[n]);
	return 0;
}

Measured memory_bytes: 43776