akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll N;
ll A[101010];
ll mina[101010];
ll T;
ll maxdiff;

int main() {
  cin >> N >> T;
  mina[0] = inf;
  repe(i, 1, N) {
    cin >> A[i];
    mina[i] = min(mina[i - 1], A[i]);
    chmax(maxdiff, A[i] - mina[i]);
  }

  ll cnt = 0;
  repe(i, 1, N) {
    if (A[i] - mina[i] == maxdiff) {
      ++cnt;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 5132
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            var N = int.Parse(str[0]);
            var X = int.Parse(str[1]);
            var T = int.Parse(str[2]);
            var a = N/ X;
            if(N%X != 0)
            {
                a++;
            }
            Console.WriteLine(a*T);
        }
    }
}


Measured memory_bytes: 27312
N=int(input())
A=[]
for l in range(N):
  array = list(map(int, input().split()))
  A.append(array)
import math
import itertools as ir
x=0
y=1
#街u,vの距離
def distance(u,v):
  distance = math.sqrt( (A[u][x]-A[v][x])**2 + (A[u][y]-A[v][y])**2 )
  return distance
#街リストの生成（街0からN-1）
city_list=[]
for i in range(N):
  city_list.append(i)
#街のまわり方の並べ方
permutations=list(ir.permutations(city_list))
#距離の計算(一パターンを組み合わせ分だけ）
sum_distance=0
for j in range(math.factorial(N)):
  for k in range(N-1):
    sum_distance+=distance(permutations[j][k],permutations[j][k+1])
result=sum_distance/math.factorial(N)
print(result)
    

Measured memory_bytes: 8052
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define sz size()
#define vec vector<int>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int( str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str,size_t first_itr,bool isFirst) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFirst) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, int now) {
	/*if (depth == n)return !now;
	for (int i = 0; i < k; i++) {
		if (dfs(depth + 1, now ^ t[depth][i]))return true;
	}
	/**/
	return false;
}


int main() {
	int n; cin >> n;
	str s,tmp1,tmp2; cin >> s;
	if (n % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}
	tmp1 = split(s, n / 2, true);
	tmp2 = split(s, n / 2, false);
	if (tmp1 == tmp2)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,a;
    cin>>x>>a;
    if(x<a) cout<<0<<endl;
    else  cout<<10<<endl;
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  int cnt = 0;
  rep(i,H) {
    rep(j,W) {
      char x;
      cin >> x;
      if(x=='#') cnt++;
    }
  }
  cout << (cnt==H+W-1? "Possible" : "Impossible") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>


struct Point{
  double x;
  double y;
};

void kohho(int n, struct Point a, struct Point b)
{
  struct Point s,t,u;
  double k = M_PI*60.0 / 180.0;
  
  if(n==0)return;

  s.x = ( 2.0 * a.x + 1.0*b.x)/3.0;
  s.y = ( 2.0 * a.y + 1.0*b.y)/3.0;
  t.x = ( 1.0 * a.x + 2.0*b.x)/3.0;
  t.y = ( 1.0 * a.y + 2.0*b.y)/3.0;
  u.x = ( t.x - s.x )*cos(k)-(t.y-s.y)*sin(k)+s.x;
  u.y = ( t.x - s.x )*sin(k)+(t.y-s.y)*cos(k)+s.y;

  kohho(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  kohho(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  kohho(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  kohho(n-1,t,b);
}

int main()
{
  struct Point a,b;
  int n;

  scanf("%d",&n);
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;


  printf("%.8f %.8f\n",a.x,a.y);
  kohho(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}

  



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

long long int sum=0;

long long int search(int v,int pre,vector<vector<pair<int,int>>> &edge){
  long long int res=0;
  for(int i=0;i<edge[v].size();i++){
    int to=edge[v][i].first;
    if(to==pre) continue;
    if(edge[to].size()==1) continue;
    long long int costing=edge[v][i].second+search(to,v,edge);
    res=max(res,costing);
  }
  return res;
}


long long int solve(int v,vector<vector<pair<int,int>>>& edge){
  long long int lost_cost=search(v,v,edge);
  long long int cost=0;
  for(int i=0;i<edge.size();i++){
    for(int j=0;j<edge[i].size();j++){
      int to=edge[i][j].first;
      if(to!=v && edge[to].size()==1) continue;
      if(i!=v && edge[i].size()==1) continue;
      cost+=edge[i][j].second;
    }
  }
  cost/=2;
  //  cout<<"#"<<v<<" "<<cost<<endl;  
  return sum+2*cost-lost_cost;
}

int main(){
  int n;
  while(cin>>n,n){
    vector<vector<pair<int,int>>> edge(n);
    sum=0;
    vector<int> pp(n);
    vector<int> dd(n);
    for(int i=1;i<n;i++) cin>>pp[i];
    for(int i=1;i<n;i++) cin>>dd[i];
    for(int i=1;i<n;i++){
      int p,d;
      p=pp[i];
      d=dd[i];
      p--;
      edge[i].push_back({p,d});
      edge[p].push_back({i,d});
      sum+=d;
    }
    long long int res=sum*3;
    for(int i=0;i<n;i++){
      res=min(res,solve(i,edge));
    }
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>
#include<stdlib.h>
int fun(int ,int ,int ,int );
int fun(int a,int b,int c,int X)
{
    int i,j,ans=0;
    for(i=0;i<=a;i++)
    {
        for(j=0;j<=b;j++)
        {
            if((X-i*500-j*100>=0)&&(X-i*500-j*100<=c*50))
            {
                ans++;
            }
        }
    }
    return ans;
}
int main()
{
    int a,b,c,X;
    scanf("%d%d%d%d",&a,&b,&c,&X);
    printf("%d\n",fun(a,b,c,X));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

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

	vector<pair<int, int>> factor;

	int root_n = sqrt(n);
	int a = n;

	for (int i = 2; i <= a; i++) {
		if (n == 1) break;
		if (i == root_n + 1 && factor.empty()) break;
		int count = 0;
		while (n % i == 0) {
			n /= i;
			count++;
		}
		if (count) factor.push_back(make_pair(i, count));
	}

	cout << a << ":";

	if (factor.empty()) cout << " " << a;

	while (!factor.empty()) {
		pair<int, int> fa;
		fa = *(factor.begin());
		factor.erase(factor.begin());
		for (int i = 0; i < fa.second; i++) {
			cout << " " << fa.first;
		}
	}

	cout << endl;

	return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;

int main(int argc, char** argv) {
	int X; scanf("%d", &X);
	if(X <= 599) puts("8");
	else if(X <= 799) puts("7");
	else if(X <= 999) puts("6");
	else if(X <= 1199) puts("5");
	else if(X <= 1399) puts("4");
	else if(X <= 1599) puts("3");
	else if(X <= 1799) puts("2");
	else puts("1");
	
	return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    rep (i, n) {
        cin >> a[i];
        sum += a[i];
    }
    sum /= 2;
    for (int i = 0; i < n; i += 2) {
        sum -= a[i];
    }
    vector<ll> ans(n);
    ans[0] = -sum;
    cout << ans[0] * 2;
    rep (i, 1, n) {
        cout << " ";
        ans[i] = a[i-1] - ans[i-1];
        cout << ans[i] * 2;
    }
    cout << endl;
}

Measured memory_bytes: 2944
#include<iostream>
using namespace std;
int main()
{
    int n;
    int i,j;
    int c[600],s[600],f[600];
    int t;
    while(cin>>n)
    {
        for(i=1;i<=n-1;i++)
        cin>>c[i]>>s[i]>>f[i];
        for(i=1;i<=n-1;i++)
        {   
            t=0;
            t+=s[i];
            for(j=i;j<=n-1;j++)
        {
            t+=c[j];
            if(j<n-1)
            {
                if(t<s[j+1])t=s[j+1];
            if(t>=s[j+1]&&t%f[j+1]!=0)
            t+=f[j+1]-t%f[j+1];
            }
           
                                
                                
        }
        cout<<t<<endl;
        }
        cout<<0<<endl;
        
    }


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *p, const void *q) {
    return *(long *)p - *(long *)q;
}

int main(int argc, char const *argv[]) {
    long N, A[200000], temp, mean, ans = 0;
    scanf("%ld", &N);
    for (int i = 0; i < N; i++) {
        scanf("%ld", &temp);
        temp -= i + 1;
        A[i] = temp;
    }
    qsort(A, N, sizeof(long), cmp);
    mean = A[N / 2];
    for (int i = 0; i < N; i++) {
        ans += abs(A[i] - mean);
    }
    printf("%ld", ans);
    return 0;
}

Measured memory_bytes: 3324
# Mまでの素数全列挙(エラトステネスの篩)
def primes(M):
    is_prime = [-1 for _ in range(M+1)]
    for m in range(2, M+1):
        if is_prime[m] == -1:
            is_prime[m] = 1
            l = 2
            while m*l <= M:
                is_prime[m*l] = 0
                l += 1
    primes = []
    for p in range(2, M+1):
        if is_prime[p] == 1:
            primes.append(p)
    return primes

N = int(input())

P = primes(55555)
A = []
for p in P:
    if p%5 == 2:
        A.append(p)
    if len(A) == N: break
print(' '.join([str(a) for a in A]))

Measured memory_bytes: 3864
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		int[] b=new int[n];
		for (int i=0;i<n;i++){
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		}
		long c=0;
		for (int i=n-1;i>=0;i--){
			int d=(int)(((long)a[i]+c)%(long)b[i]);
			if(d!=0){
				c+=(long)(b[i]-d);
			}
		}
		System.out.println(c);
	}
}
	


Measured memory_bytes: 48896
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  map<pii, int> cnt;
  rep(i, 1, N + 1) {
    string s = to_string(i);
    cnt[pii(s.front() - '0', s.back() - '0')]++;
  }
  int ans = 0;
  rep(i, 0, 10) {
    rep(j, i + 1, 10) {
      int x = cnt[pii(i, j)];
      int y = cnt[pii(j, i)];
      ans += x * y * 2;
    }
    int x = cnt[pii(i, i)];
    ans += x * x;
  }
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

int main()
{
    ll N, M;
    scanf("%lld %lld", &N, &M);

    vector<ll> H(N);
    for (ll i = 0; i < N; i++)
        scanf("%lld", &(H[i]));

    vector<vector<ll>> pass(N, vector<ll>());
    for (ll i = 0; i < M; i++)
    {
        ll A, B;
        scanf("%lld %lld", &A, &B);
        pass[A - 1].push_back(B - 1);
        pass[B - 1].push_back(A - 1);
    }

    vector<ll> pm(N, -1);
    for (ll i = 0; i < N; i++)
    {
        if (pm[i] != -1)
            continue;

        bool res = true;
        for (auto to : pass[i])
        {
            if (H[to] >= H[i])
            {
                res = false;
            }
            if (H[to] <= H[i])
            {
                pm[to] = false;
            }
        }

        pm[i] = res;
    }

    ll ans = 0;
    for (ll i = 0; i < N; i++)
    {
        if (pm[i] == 1)
            ans++;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 10632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;

public class Main
{
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
		int K = Integer.parseInt(BR.readLine()), Count = 0; Queue<Long> Numbers = new LinkedList<>(), nextNumbers = new LinkedList<>(); HashSet<Long> previousLunLun = new HashSet<>();
		if (K < 9)
		{
			System.out.println(K);
		}
		else
		{
			nextNumbers.add(1l); nextNumbers.add(2l); nextNumbers.add(3l); nextNumbers.add(4l); nextNumbers.add(5l); nextNumbers.add(6l); nextNumbers.add(7l); nextNumbers.add(8l); nextNumbers.add(9l);
			while (Count != K)
			{
				for (Long N : nextNumbers)
				{
					Numbers.add(N);
					previousLunLun.add(N);
				}
				nextNumbers.clear();
				for (Long N : Numbers)
				{
					Count++;
					if (Count == K)
					{
						System.out.println(N);
						break;
					}
					if (N % 10 != 0 && !previousLunLun.contains(10 * N + N % 10 - 1))
					{
						nextNumbers.add(10 * N + N % 10 - 1);
						previousLunLun.add(10 * N + N % 10 - 1);
					}
					if (!previousLunLun.contains(10 * N + N % 10))
					{
						nextNumbers.add(10 * N + N % 10);
						previousLunLun.add(10 * N + N % 10);
					}
					if (N % 10 != 9 && !previousLunLun.contains(10 * N + N % 10 + 1))
					{
						nextNumbers.add(10 * N + N % 10 + 1);
						previousLunLun.add(10 * N + N % 10 + 1);
					}
				}
				Numbers.clear();
			}
		}
	}
}


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

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);

    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int t;
            cin >> t;
            t--;
            a[t]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == 0)
            ans++;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse

#endif

struct Ans
{
	ll hash;
	ll count;
	Ans(ll h, ll c)
	{
		hash = h;
		count = c;
	}
};

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

	vector<ll> vs(n);
	rep(i, 0, n)
	{
		string s; cin >> s;
		sort(all(s));
		vs[i] = hash<string>()(s);
	}

	vector<Ans> ans;
	ans.push_back(Ans(-1, 0));
	sort(all(vs));
	rep(i, 1, n)
	{
		if (vs[i - 1] == vs[i])
		{
			if (ans.back().hash == vs[i - 1])
				ans.back().count++;
			else
				ans.push_back(Ans(vs[i-1], 2));
		}
	}

	ll sum = 0;
	for (const auto& e : ans)
		sum += ((e.count * e.count - e.count) / 2);

	cout << sum;
	return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);

    rep(i, m)
    {
        cin >> p.at(i) >> s.at(i);
    }

    map<int, int> mapWA;
    map<int, string> mapOR;

    int countAC = 0;
    int countWA = 0;

    rep(i, m)
    {
        int num = p.at(i);
        string str = s.at(i);

        // mapOR == ACで何もしない
        if (mapOR[num] != "AC")
        {
            if (str == "AC")
            {
                countAC += 1;
                countWA += mapWA[num];
                // 最後にmapORを更新
                mapOR[num] = "AC";
            }
            else if (str == "WA")
            {
                mapWA[num] += 1;
            }
        }
    }
    cout << countAC << " " << countWA << endl;
}


Measured memory_bytes: 21760
// Template begins
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <deque> 
#include <queue> 
#include <string.h>
#include <string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<b;i++)
#define all(v) (v).begin(),(v).end()
#define sort0(v) sort(all(v))
#define lbb(a,b,arr,x) lower_bound(arr+a,arr+b+1,x)-arr
#define ubb(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-arr
#define freq(a,b,arr,x) upper_bound(arr+a,arr+b+1,x)-lower_bound(arr+a,arr+b+1,x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define ss second
#define ff first
#define pb push_back
#define pf push_front
#define mp make_pair
#define printp(x) cout << x.ff << " " << x.ss << endl

const ll mod=998244353;
#define inf 9999999999999
#define MAXN   100001 
  
// stores smallest prime factor for every number 
ll inv(ll i){if(i==1) return 1;return (mod-((mod/i)*inv(mod%i))%mod)%mod;}
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b,b%a);}
inline void fastio(){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
// Template ends
const int MN = 2e5+7;
ll h,w,ch,cw,dh,dw;
char grid[1001][1001];
bool legal(int x, int y) {
    if (x<0||y<0||x>=w||y>=h || grid[x][y]=='#') return false;
    return true;
}
int main(){
    fastio();
    cin>>h>>w>>ch>>cw>>dh>>dw;
    ch--; cw--; dh--; dw--;
    ll dist[w][h];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>grid[j][i];
            dist[j][i]=1e9;
        }
    }
    //ll dist[h][w];
    dist[cw][ch]=0;
    deque <ll> sx;
    deque <ll> sy;
    int dy[4]={0,0,-1,1};
    int dx[4]={-1,1,0,0};
    sx.push_back(cw); sy.push_back(ch);
    while(sx.size()>0){
        ll curX=sx.front(); ll curY=sy.front(); sx.pop_front(); sy.pop_front();
			for (int d=0; d<4; d++) {
				int nx=curX+dx[d], ny=curY+dy[d];
				if (!legal(nx, ny)) continue;
				if (dist[nx][ny]>dist[curX][curY]) {
					dist[nx][ny]=dist[curX][curY];
					sx.push_front(nx);
					sy.push_front(ny);
				}
			}
			for (int i=curX-2; i<=curX+2; i++) {
				for (int y=curY-2; y<=curY+2; y++) {
					if (!legal(i, y)) continue;
					if (dist[i][y]>dist[curX][curY]+1) {
						dist[i][y]=dist[curX][curY]+1;
						sx.push_back(i);
						sy.push_back(y);
					}
				}
			}
		}
    if(dist[dw][dh]>1e7){
        cout<<-1<<endl;
    }else{
        cout<<dist[dw][dh]<<endl;
    }
    
    return 0;
}

 

Measured memory_bytes: 12120
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string str;
  cin>>str;
  if(str=="Sunny")
     cout<<"Cloudy"<<endl;
  else if(str=="Cloudy")
     cout<<"Rainy"<<endl;
  else
    cout<<"Sunny"<<endl;
  return 0;
}

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

const int V = 101010;
vector<int> to[2*V];
vector<int> cnt;
bool visited[2*V];

void dfs(int v){
    if(visited[v]) return;
    visited[v] = true;
    cnt[v/V]++;
    for(int u : to[v]) dfs(u);
}

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

	int n;
	cin >> n;

	rep(i, n) {
        int x, y;
        cin >> x >> y;
        y += V;

        to[x].push_back(y);
        to[y].push_back(x);
    }

    ll ans = 0;
    for(int i = 0; i < 2 * V; i++){
        if(visited[i]) continue;
        cnt = vector<int>(2);
        dfs(i);
        ans += (ll) cnt[0] * cnt[1];
    }

    cout << ans - n << endl;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
int main(){
 int X,A ,B;
 cin >> X >> A >> B;
 if(A >= B) cout << "delicious" << endl;
 else if(A + X  >=   B) cout <<"safe" << endl;
 else cout <<"dangerous " << endl;
  
 return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    """Function."""
    a, b, c = map(int, input().split())

    if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
        print(0)
    else:
        print(min([a*b, a*c, b*c]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
int H;
int W;
int a;
int i;
int c;

scanf("%d %d",&H,&W);

while(1){
  for(i=1;i<=H;i++){
    for(c=1;c<=W;c++){
      printf("#");}
    printf("\n");}
  scanf("%d %d",&H,&W);
  printf("\n");
  if(H==0 && W==0){
  break;}
}
return 0;
}


Measured memory_bytes: 2044
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

string S;
int num[100010];
int num2[100010];

signed main(){
	cin>>S;
	int cnt=0;
	bool flag=false;
	int pos=0;
	REP(i,S.size()){
		if(0<i&&S[i-1]=='R'&&S[i]=='L'){
			flag=true;
			pos=i;
			cnt=0;
			num[i]=1;
		}
		else if(flag==true){
			if(S[i]=='L'){
				cnt++;
				if(cnt%2==1){
					num[pos-1]++;
				}
				else{
					num[pos]++;
				}
			}
			else{
				flag=false;
			}
		}
	}
	flag=false;
	pos=0;
	cnt=0;
	for(int i=S.size()-1;0<=i;i--){
		if(i<S.size()-1&&S[i]=='R'&&S[i+1]=='L'){
			flag=true;
			pos=i;
			cnt=0;
			num[i]++;
		}
		else if(flag==true){
			if(S[i]=='R'){
				cnt++;
				if(cnt%2==1){
					num[pos+1]++;
				}
				else{
					num[pos]++;
				}
			}
			else{
				flag=false;
			}
		}
	}
	REP(i,S.size()){
		cout<<num[i];
		if(i!=S.size()-1){
			cout<<" ";
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 1408
import math
datas =input()
list = datas.split(" ")
list = [int(i) for i in list]
a = list[0]
b = list[1]
x = list[2]
x_ = x/a
if x > a**2*b/2:
    x__ = a*b - x_
    h = 2*x__/a
    d = math.atan(h/a)
    print(math.degrees(d))
else:
    h = 2*x_/b
    d = math.atan(h/b)
    print(math.degrees(math.pi/2-d))
    

Measured memory_bytes: 3188
#include <string.h>
#include <stdio.h>
int main()
{
   char str[100],str1[100],str3[200];
   scanf("%s",str);
   str3[0]='\0';
   scanf("%s",str1);
   strcat(str3,str1);
   strcat(str3,str);
   printf("%s",str3);
}


Measured memory_bytes: 128
n,k = map(int, input().split())
ans = 0
abl = [ tuple(map(int, input().split())) for _ in range(n) ]

kset = set()
kset.add(k)
for i in range(30):
    if k&(1<<i) == 0: continue
    v = 0
    for j in range(i):
        v += pow(2,j)
    for j in range(i+1,30):
        if k&(1<<j) > 0:
            v += pow(2,j)
    kset.add(v)

kl = list(kset)
ans = 0
for ki in kl:
    v = 0
    for a,b in abl:
        if a > k: continue
        for i in range(30):
            if a&(1<<i) > 0 and ki&(1<<i) == 0:
                break
        else:
            v += b
    ans = max(ans, v)

print(ans)


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))

void solve() {
  int n;
  ll k;
  cin >> n >> k;
  vl a(n);
  rep(i, n) cin >> a[i];
  int m = 40;
  // while (!((k >> (m - 1)) & 1)) m--;
  dump(n, k, m, a);
  vi c(m);
  rep(i, m) rep(j, n) {
    int x = (int)((a[j] >> i) & 1);
    if (x) c[i]++;
  }
  dump(c);
  vvl dp(100005, vl(2, -1)); // [i][less]
  dp[0][0] = 0;
  rep(i, m) rep(less, 2) rep(d, 2) {
    int j = m - i - 1;
    int x = (int)((k >> j) & 1);
    int nless = less;
    if (less == 0 && x < d) continue;
    if (less == 0 && x > d) nless = 1;
    ll val;
    if (less == 0 && x == 0) val = c[j] * (ll)(1ll << j);
    else if (d == 0) val = c[j] * (ll)(1ll << j);
    else val = (n - c[j]) * (ll)(1ll << j);
    if (dp[i][less] >= 0) {
      dp[i + 1][nless] = max(dp[i + 1][nless], dp[i][less] + val);
      dump(i, j, d, x, less, nless, c[j], val, dp[i], dp[i+1]);
    }
  }
#if 0
  rep(i, m) rep(less, 2) {
    int j = m - i - 1;
    int x = (int)((k >> j) & 1);
    ll mask = 1ll << j;
    int nless = less;
    if (less == 0 && x < d) continue;
    if (less == 0 && x > d) nless = 1;
    if (dp[i][less] >= 0) {
      //これは、すでに X < Kなる場合が存在する時
      //この時、この桁については1でも0でも構わない
      if (less)
        maxs(dp[i + 1][1], dp[i][less] + mask * max(c[j], n - c[j]));
      else if (x == 0) {
        maxs(dp[i + 1][0], dp[i][less] + mask * c[j]);
      } else {
        maxs(dp[i + 1][1], dp[i][less] + mask * c[j]);
        maxs(dp[i + 1][0], dp[i][less] + mask * (n - c[j]));
      }
    }
    dump(i, j, x, dp[i], dp[i+1]);
  }
#endif
  // rep(i, m) {
  //   int j = m - i - 1;
  //   int x = (int)((k >> j) & 1);
  //   ll mask = 1ll << j;
  //   if (dp[i][1] >= 0) {
  //     //これは、すでに X < Kなる場合が存在する時
  //     //この時、この桁については1でも0でも構わない
  //     maxs(dp[i + 1][1], dp[i][1] + mask * max(c[j], n - c[j]));
  //   }
  //   if (dp[i][0] >= 0) {
  //     if (x == 0) {
  //       maxs(dp[i + 1][0], dp[i][0] + mask * c[j]);
  //     } else {
  //       maxs(dp[i + 1][1], dp[i][0] + mask * c[j]);
  //       maxs(dp[i + 1][0], dp[i][0] + mask * (n - c[j]));
  //     }
  //   }
  //   dump(i, j, x, dp[i], dp[i+1]);
  // }
  dump(dp[m][0], dp[m][1]);
  ll ans = max(dp[m][0], dp[m][1]);
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		ll num = (ll)i * (i + 1) / 2;
		if (num >= N) {
			for (int j = i; j > 0; j--) {
				if (j <= N) {
					cout << j << endl;
					N -= j;
				}
			}
			return 0;
		}
	}
}


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

int main(void)
{
	string s;
  	cin >> s;
    int A, Z;
  	for(int i = 0; i < s.size(); i++){
    	if(s[i] == 'A'){
        	A = i;
          	break;
        }
    }
  	for(int i = 0; i < s.size(); i++){
    	if(s[i] == 'Z'){
        	Z = i;
        }
    }
  	cout << Z - A + 1 << endl;
  	return 0;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll X, N;
    cin >> X >> N;
    vll p(N);
    rep(i, N) cin >> p[i];
    ll md = 101;
    ll m = -1;
    REP(i, 0, 102){
        if(find(all(p), i)==p.end()){
            ll d = abs(i-X);
            if(d<md){
                md = d;
                m = i;
            }
        }
    }
    cout << m << endl;
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<string.h>
int main()
{
    char first[20],second[20],count=0;
    gets(first);
    gets(second);
    int a=strlen(first);
    int b=strlen(second);
    if(a<b)
    {
        for(int i=0;i<a;i++)
        {
            if(first[i]!=second[i])
            {
                printf("No\n");
                count++;break;
            }
        }
        if(count==0)
        {
            printf("Yes\n");
        }
    }
    return 0;
}


Measured memory_bytes: 1488
#include<bits/stdc++.h>
using namespace std;
int d[100010];
int a[100010];
int sum[100010];
int n,k;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		scanf("%1d",&d[i]);
		a[i]=(d[i]^d[i-1]);
	}
	sum[0]=0;
	for(int i=1;i<=n;i++)
		sum[i]=sum[i-1]+a[i];
	int b=0;
	int res=0;
	for(int i=1;i<=n;i++){
		b^=a[i];
		int tmp=upper_bound(sum,sum+n+1,k*2-(!b)+sum[i])-sum;
		res=max(res,tmp-i);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1408
S = input()
N = len(S)

import math
M = math.floor((N-3)/2)

a = 0

for i in range(M):
  if S[i] != S[i+M+2]:
    a = 1
    
for j in range(M):
  if S[j] != S[N-j-1]:
    a = 1
    
if a == 0:
  print('Yes')
  
else:
  print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<string.h>
using namespace std;
int main() 
{
  string s,t;
  cin >> s >> t;
  
  int l = s.length();
  
  for(int i = 0;i<=l; i++){
    if(s[i] != t[i]){
      cout << "No";
      break;
    }
    else if (i == l - 1){
	  cout << "Yes";
      break;
    }
  }
}


Measured memory_bytes: 3584
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n+1];
		for(int i=0; i<n; i++){
			a[i] = sc.nextInt();
		}
      	int sum = 0;
      	int x = n;
      	for(int i=0; i<n; i++){
          sum += Math.abs(a[i]-a[x]);
          x = i;
        }
      	sum += Math.abs(a[n-1]-a[n]);
      	x = n;
      	for(int i=0; i<n; i++){
      	  int ans = sum;
      	  ans += Math.abs(a[x] - a[i+1]) - Math.abs(a[i] - a[x]) - Math.abs(a[i+1] - a[i]);
      	  System.out.println(ans);
      	  x = i;
    	}
	}
}


Measured memory_bytes: 59608
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n;
  cin>>n;

  vector<Pll> A;
  vector<ll> num(n, 0);
  rep(i,n){
    ll a;cin>>a;
    A.push_back({a, -i});
  }
  A.push_back({0, -LINF});

  sort(all(A));
  reverse(all(A));

  ll kosu = A[0].first;
  ll id = -A[0].second;
  reps(i,n){
    //cout<<i<<" "<<id<<endl;
    ll sa = kosu - A[i].first;
    num[id] += sa * i;
    kosu = A[i].first;
    chmin(id, -A[i].second);
  }

  rep(i,n){
    cout<<num[i]<<endl;
  }

  return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

ll a[200010], cnt=0;
bool vis[100010];
vector<ll>g[100010];
void dfs(ll rt)
{
    vis[rt]=1;
    int f=0;
    for(auto x: g[rt])
    {
        if(a[x]>=a[rt]) f=1;
    }
    if(!f) cnt++;
}

int main()
{
   ll t,n,i,j,k,l,r,mn=0, mx=0,m,u,v;

   sl2(n,m);
   for(int i=1; i<=n; i++)
    sl(a[i]);

   for(int i=0; i<m; i++)
   {
       sl2(u,v);
       g[u].pb(v);
       g[v].pb(u);
   }

   for(int i=1; i<=n; i++)
   {
       if(vis[i]==0)
       {
           if(g[i].sz==0) cnt++, vis[i]=1;
           else dfs(i);
       }
   }
   cout<<cnt;

}



Measured memory_bytes: 10308
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int K, N;
    scan(K, N);
    auto a = readln.split.to!(int[]);

    long ans = infl;

    foreach (i ; 0 .. N) {
        long v;
        if (i < N - 1) {
            v = K - (a[i + 1] - a[i]);
        }
        else {
            v = K - (a[0] - a[N - 1] + K);
        }
        chmin(ans, v);
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 11348
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X, Y = MAP()
print(X + Y//2)

Measured memory_bytes: 5140
#include <stdio.h>

int binarySearch(int);

int S[100000];
int n;

int main(){

  int q,key,count=0,flag=0,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&key);
      flag = binarySearch(key);
    if(S[flag] == key){
      count++;
    }
  }
  
  printf("%d\n",count);

  return 0;
}


int binarySearch(int key){
  int left = 0;
  int right = n;
  int mid = 0;
  
  
  while(left<right){
    mid = (left + right)/2;
    if(S[mid] == key)return mid;
    else if(key < S[mid])right = mid;
    else left = mid + 1;
  }
  return 0;
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((a+d-1)/d >= ((c+b-1)/b)){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		Main app = new Main();
		String string;
		
		while((string = reader.readLine()) != null){
			String[] source = string.split(",");
			double[] p = app.map(source);
			
			if(app.check(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]) < 0.0 ||
			   app.check(p[4], p[5], p[6], p[7], p[0], p[1], p[2], p[3]) < 0.0)
				System.out.println("NO");
			else
				System.out.println("YES");
		}
		
		reader.close();
	}
	
	public double[] map(String[] source){
		double[] hoge = new double[8];
		for(int i = 0; i < 8; i++) hoge[i] = Double.parseDouble(source[i]);
		return hoge;
	}
	
	public double check(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4){
		return ((x1 - x2) * (y3 - y1) + (y1 - y2) * (x1 - x3)) * ((x1 - x2) * (y4 - y1) + (y1 - y2) * (x1 - x4));
	}
	
}

Measured memory_bytes: 23976
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#define INF 1e9
#define MOD 1000000007
#define ll long long
using namespace std;
typedef unsigned long long ull;
typedef pair<int, int> pr;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='2'){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
n,a,b,c,d = map(int, input().split())

a = a-1
b = b-1
c = c-1
d = d-1

s = input()
s += '##'

def check(x,y):
    while x<y:
        if s[x+1]=='.':
            x += 1
        elif s[x+1]=='#':
            if s[x+2]=='#':
                return False
            x += 2
    if x==y:
        return True
    else:
        return False


def overtake(x,y):
    while x<n and y<n and x<y:
        if s[x+1] == '.' and y-x!=1:
            x += 1
        elif s[x+2] == '.' and y-x!=2:
            x += 2
        elif s[y+1] == '.':
            y += 1
        elif s[y+2] == '.':
            y += 2
        else:
            return None, None
    if y<x:
        return x,y
    else:
        return None,None
            
            
            

if c<d:
    if check(b,d) and check(a,c):
        print('Yes')
    else:
        print('No')
else:
    a, b = overtake(a,b)
    if a is None:
        print('No')
    elif check(b,d) and check(a,c):
        print('Yes')
    else:
        print('No')
    


Measured memory_bytes: 3700
n,x = list(map(int,input().split(' ')))
a = list(map(int,input().split(' ')))

#a_sort = sorted(a, reverse=True)
a_sort = sorted(a)
#print(a_sort)
manzoku =0
flag = 0
for n,i in enumerate(a_sort):
    if x>=i:
      x-=i
      #print(x)
      manzoku+=1
#      print(x,i)
    elif x<i:
      flag =1
      
    

if  flag:
    print(manzoku)
elif flag==0 and(x>0) and (manzoku>0):
    print((manzoku)-1)
else:
    print(manzoku)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
        using namespace std;
        int main(){
    		int n,ans=0,ten=10;
			cin>>n;
			for(;;){
				if(n>=ten){
					ans+=ten-ten/10;
				}
				else if(n>=ten/10){
					cout<<ans+(n/(ten/10)-1)*(ten/10)+n%(ten/10)+1<<endl;
					break;
				}
				else{
					cout<<ans<<endl;
					break;
				}
				ten*=100;
			}
    		return(0);
        }

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N;
    scanf("%d",&N);
    char po[100],pu[100];
    scanf("%s",po);
    scanf("%s",pu);
    long long int ans;
    int back;
    for(int i=0;i<N;i++){
        if(i==0){
            if(po[0]==pu[0]){ans=3;back=0;}
            else {
                ans=6;
                i++;
                back=1;
            }
        }
        else {
            if(po[i]==pu[i]){
                if(back==0)ans*=2;
                back=0;
            }
            else {
                if(back==0)ans*=2;
                else ans*=3;
                back=1;
                i++;
            }
        }
        ans%=1000000007;
    }
    printf("%lld",ans);
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

 
int main(){
  int n, m;
  cin >> n >> m;
  int a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  vector<int> s(n+1);
  s[0] = 0;
  for(int i=0; i<n; i++){
    s[i+1] = (s[i]+a[i])%m;
  }
  map<int, int> mp;
  ll ans = 0;
  for(int i=0; i<=n; i++){
    ans += mp[s[i]];
    mp[s[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3968