akhauriyash/Code-Regression huggingface dataset:
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = CInt(ReadLine())
        Dim dic As New Dictionary(Of String, Boolean)

        For i As Integer = 0 To N - 1
            Dim S As String = NextString()
            dic(S) = True
        Next

        WriteLine(New String() {"Three", "Four"}(B2I(dic.Count = 4)))
    End Sub

    Function B2I(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 22224
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

t = 1000000007
ans = 1


def Fib(n):
    a, b = 1, 2
    if n == 0:
        return 1
    elif n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n - 2):
            a, b = b, a + b
        return b


if m == 0:
    ans = Fib(n)
elif m == 1:
    ans = ans * Fib(a[0] - 1) * Fib(n - a[0] - 1)
else:
    for i in range(m):
        # 最初の段
        if i == 0:
            ans = ans * Fib(a[i] - 1)
        # 二段壊れは0
        elif a[i] - a[i - 1] == 1:
            ans = 0
            break
        # 最後の段
        elif i == m - 1:
            ans = ans * Fib(a[i] - a[i - 1] - 2)
            if a[i] != n - 1:
                ans = ans * Fib(n - a[i] - 1)
            break
        # 壊れ段の間
        else:
            ans = ans * Fib(a[i] - a[i - 1] - 2)

print(ans % t)


Measured memory_bytes: 7080
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>c(N);
	vector<int>s(N);
	vector<int>f(N);
	for (int i = 1; i < N; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}
	for (int i = 1; i < N; i++) {
		int t = s[i] + c[i];
		for (int j = i + 1; j < N; j++) {
			if (t < s[j]) {
				t = s[j];
			}
			if (t % f[j]) {
				t += f[j];
				t /= f[j];
				t *= f[j];
			}
			t += c[j];
		}
		cout << t << endl;
	}
	cout << 0 << endl;
	return 0;
}

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

class Program
{
    static void Main()
    {
        new Program().Solve();
    }
    private int N,M,R;
    private int[]r;
    private int[,]dist;
    private long Anser=long.MaxValue;
    private void Scan()
    {
        string[] l=Console.ReadLine().Split(' ');
        N=int.Parse(l[0]);
        M=int.Parse(l[1]);
        R=int.Parse(l[2]);
        l=Console.ReadLine().Split(' ');
        r=new int[R];
        for(int i=0;i<R;i++)
        {
            r[i]=int.Parse(l[i])-1;
        }
        dist=new int[N,N];
        for(int i=0;i<N;i++)for(int j=0;j<N;j++)dist[i,j]=(int)1e9;
        for(int i=0;i<M;i++)
        {
            l=Console.ReadLine().Split(' ');
            int a=int.Parse(l[0])-1;
            int b=int.Parse(l[1])-1;
            int c=int.Parse(l[2]);
            dist[a,b]=c;
            dist[b,a]=c;
        }
        for(int k=0;k<N;k++)for(int i=0;i<N;i++)for(int j=0;j<N;j++)dist[i,j]=Math.Min(dist[i,j],dist[i,k]+dist[k,j]);
    }
    
    private void Calc(int[]root,int index,long sum)
    {
        if(index==R)
        {
            Anser=Math.Min(Anser,sum);
            return;
        }
        foreach(int rr in r)
        {
            bool f=false;
            for(int i=0;i<index;i++)
            {
                if(root[i]==rr)
                {
                    f=true;
                    break;
                }
            }
            if(f)continue;
            root[index]=rr;
            long next=0;
            if(index>0)
            {
                next=sum+dist[root[index-1],rr];
            }
            Calc(root,index+1,next);
        }
    }
    
    public void Solve()
    {
        Scan();
        Calc(new int[R],0,0);
        Console.WriteLine(Anser);
        
    }
}

Measured memory_bytes: 15272
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
//#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define INF (int)1e15
#define MOD 1000000007
//#define N 12
#define sz 1000*1000

 int main(){

     int n; cin>>n;
   char x;
     set<char>ani;
     for(int i=0;i<n;i++)  {
       cin>>x;
       ani.insert(x); }

       if(ani.size() == 3 ) cout<<"Three"<<endl;
       else if(ani.size() == 4)
            cout<<"Four"<<endl;


  return 0;
 }


Measured memory_bytes: 3612
// Test.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string str;
    bool flg = true;
    cin >> str;

    int lim = str.size() / 2;
    int n = str.size();

    for (int i = 0; i < lim; i++) {
        n--;
        if (str[i] != str[n]) {
            flg = false;
            goto end;
        }
    }
    lim = str.size() / 2 / 2;
    n = str.size()/2;
    for (int i = 0; i < lim; i++)
    {
        n--;
        if (str[i] != str[n]) {
            flg = false;
            goto end;
        }
    }
    lim = str.size();
    n = str.size();
    for (int i = str.size() / 2 + 1; i < lim; i++)
    {
        n--;
        if (str[i] != str[n]) {
            flg = false;
            goto end;
        }
    }

end:;
    if (flg) { cout << "Yes"; }
    else{ cout << "No"; }
}



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

int main() {
    ll N, T;
    cin >> N >> T;
    struct Dish {
        ll A, B;
    };
    vector<Dish> dishes(N);
    for (ll i = 0; i < N; i++) {
        cin >> dishes[i].A >> dishes[i].B;
    }
    sort(dishes.begin(), dishes.end(), [](const Dish& lhs, const Dish& rhs) {
        return (lhs.B == rhs.B ? lhs.A > rhs.A : lhs.B < rhs.B);
    });

    //dp[i][j] := i番目までを使って時刻jでの最良値
    vector<vector<ll>> dp(N + 1, vector<ll>(T, 0));
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < T; j++) {
            //iを食べない
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

            if (j + dishes[i].A < T) {
                //iを食べる
                dp[i + 1][j + dishes[i].A] = max(dp[i + 1][j + dishes[i].A], dp[i][j] + dishes[i].B);
            }
        }
    }

    ll ans = 0;
    ll remained_time = T - 1;
    ll tmp = 0;
    for (ll i = N - 1; i >= 0; i--) {
        //i番目のものをラストに注文
        ans = max(ans, dp[i][remained_time] + dishes[i].B + tmp);

        //i番目のものを先頭で注文
        remained_time -= dishes[i].A;
        tmp += dishes[i].B;
        if (remained_time < 0) {
            break;
        }
    }

    cout << ans << endl;
}

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

const int MOD = (int)1e9+7;

int bi_search_left(vector<char> &t,vector<char> &d,string s,int left,int right){
	if(left>right)	return left;
	int mid=left+(right-left)/2;
	int now=mid;
	for(int i=0;i<t.size();i++){
		if(now<0 || now>=s.size())	break;
		if(s.at(now)==t.at(i)){
			if(d.at(i)=='L')	now--;
			else if(d.at(i)=='R')	now++;
		}
	}
	if(now<0)	return bi_search_left(t,d,s,mid+1,right);
	else	return bi_search_left(t,d,s,left,mid-1);
}

int bi_search_right(vector<char> &t,vector<char> &d,string s,int left,int right){
	if(left>right)	return left;
	int mid=left+(right-left)/2;
	int now=mid;
	for(int i=0;i<t.size();i++){
		if(now<0 || now>=s.size())	break;
		if(s.at(now)==t.at(i)){
			if(d.at(i)=='L')	now--;
			else if(d.at(i)=='R')	now++;
		}
	}
	if(now>=s.size())	return bi_search_right(t,d,s,left,mid-1);
	else	return bi_search_right(t,d,s,mid+1,right);
}

int main(){
	int N,Q;
	string s;
	cin >> N >> Q >> s;
	vector<char> t(Q);
	vector<char> d(Q);
	for(int i=0;i<Q;i++)	cin >> t.at(i) >> d.at(i);

	int left=bi_search_left(t,d,s,0,N-1);
	int right=bi_search_right(t,d,s,0,N-1);
	//cout << "left:" << left << "  right:" << right << endl;
	cout << max(0,right-left) << endl;

	return 0;
}


Measured memory_bytes: 4740
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    string s; cin >> s;
    int count = 0;
    for (const char ch : s)
    {
        if (count == 0 && ch == 'C') ++count;
        if (count == 1 && ch == 'F') ++count;
    }
    cout << (count == 2 ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void chmax (long long &a, long long b) {
    if (a < b) a = b;
}

int main() {
    int n, w;
    cin >> n >> w;
    vector<int> wei(n), val(n);
    for (int i=0; i<n; ++i) cin >> wei[i] >> val[i];
    vector<vector<long long>> dp(n+1, vector<long long>(w+10));
    for (int i=0; i<n; ++i) {
        for (int j=0; j<=w; ++j) {
            if (j >= wei[i]) {
                chmax(dp[i+1][j], dp[i][j-wei[i]] + val[i]);
            }
            chmax(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[n][w] << endl;
}

Measured memory_bytes: 80256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    int a = stdin.nextInt();
    int b = stdin.nextInt();
    int c = stdin.nextInt();

    if (a < b && b < c) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

}

Measured memory_bytes: 17160
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[300000];
    for(int i=0;i<n;++i){
        cin>>a[i];
        a[i]-=i+1;
    }
    sort(a,a+n);
    long long int x = 0;
    for(int i=0;n-1-i>i;++i){
        x+=a[n-1-i]-a[i];
    }
    cout<<x<<endl;
    return 0;
}


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

int main(){
    int n,x,maxv=-2000000000,minv;
    cin >> n;
    cin >> minv;
    for(int i=1;i<n;i++){
        cin >> x;
        maxv = max(maxv,x-minv);
        minv = min(minv,x);
    }
    
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3108
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int):
    print(180*(N-2))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
// selection sort alg
// input integer elements, output sorted elements and number of change operations
#include<iostream>
void SelectionSort(int*,int);
int main(){
  int N;
  std::cin >> N;
  int A[N];
  for(int i=0; i<N; i++) std::cin >> A[i];
  SelectionSort(A,N);
  return 0;
}
void SelectionSort(int *S, int N){
  int cnt=0,tmp;
  for(int i=0,min; i<N-1; i++){
    min = i;
    for(int j=i; j<N; j++) if(S[j] < S[min]) min = j;
    if(S[i] != S[min]) tmp = S[i], S[i] = S[min], S[min] = tmp, cnt++;
  }
  for(int i=0; i<N; i++) std::cout << S[i] << (i < N-1 ? " " : "\n");
  std::cout << cnt << "\n";
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll n;cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<vector<ll> >dp(n+1,vector<ll>(n+1,-1));
    vector<pll>p(n);
    rep(i,n){
        p[i]=mp(a[i],i);
    }
    sort(rall(p));
    dp[0][0]=0;
    rep(i,n){
        rep(j,n){
            if(dp[i][j]<0)continue;
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]+p[i].first*abs(n-1-(i-j)-p[i].second));
            dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+p[i].first*abs(p[i].second-j));
        }
    }
    ll ans=0;
    rep(i,n+1){
        ans=max(ans,dp[n][i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 34668
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int main()
{
	int n,m,dp[maxn],w[105],v[105];
	scanf("%d%d",&n,&m);
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&w[i],&v[i]);
		sum+=v[i];
	}
	memset(dp,inf,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=n;i++)
		for(int j=sum;j>=v[i];j--)
			dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
	for(int i=sum;i>=0;i--)
		if(dp[i]<=m)
		{
			printf("%d",i);
			return 0;
		}
}

Measured memory_bytes: 4168
#include<bits/stdc++.h>
using namespace std;
int n,k;
int a[1000005],f[1000005];
int solve(int x)
{
	if(f[x]!=-1) return f[x];
	if(x==0) return f[x]=0;
	int ret=0;
	for(int i=1;i<=n;i++)
	{
		if(x>=a[i]) ret|=(solve(x-a[i])^1);
	}
	return f[x]=ret;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	memset(f,-1,sizeof(f));
	puts(solve(k)?"First":"Second");
	return 0;
}

Measured memory_bytes: 8960
#include <bits/extc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int64_t, int64_t>> points(n);
  for (auto&& [x, y] : points) cin >> x >> y;
  int64_t ans = -1;
  auto go = [&](int cx, int cy) -> void {
    sort(begin(points), end(points), [&](auto p, auto q) {
      return cx * p.first + cy * p.second < cx * q.first + cy * q.second;
    });
    auto [x0, y0] = points.front();
    auto [x1, y1] = points.back();
    ans = max(ans, abs(x1 - x0) + abs(y1 - y0));
  };

  go(1, 1);
  go(1, -1);

  cout << ans << '\n';
}


Measured memory_bytes: 6360
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
int H, W, ans; char S[25][25];
int bfs(int sy, int sx) {
  int y, x, dpp, d[25][25] = {}, t[25][25] = {};
  queue<P> q; q.push({sy, sx}); t[sy][sx] = 1;
  while(!q.empty()) {
    P p = q.front(); q.pop();
    y = p.first, x = p.second, dpp = d[y][x]+1;
    if(!t[y+1][x] && S[y+1][x] == '.') q.push({y+1, x}), d[y+1][x]=dpp, t[y+1][x]=1;
    if(!t[y-1][x] && S[y-1][x] == '.') q.push({y-1, x}), d[y-1][x]=dpp, t[y-1][x]=1;
    if(!t[y][x+1] && S[y][x+1] == '.') q.push({y, x+1}), d[y][x+1]=dpp, t[y][x+1]=1;
    if(!t[y][x-1] && S[y][x-1] == '.') q.push({y, x-1}), d[y][x-1]=dpp, t[y][x-1]=1;
  }
  return d[y][x];
}
int main() {
  scanf("%d %d\n", &H, &W);
  for(int i = 1; i <= H; ++i) scanf("%s\n", &S[i][1]);
  for(int y = 1; y <= H; ++y) {
    for(int x = 1; x <= W; ++x) {
      if(S[y][x] == '#') continue;
      ans = max(bfs(y, x), ans);
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 256
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 Nums[]=new int[N];
    int count=0;
    for(int i=0;i<N;i++){
      Nums[i]=sc.nextInt();
    }
  for(int i=2;i<N;i++){
    if(Nums[i-2]<Nums[i-1]&&Nums[i-1]<Nums[i]){
      count++;
   	 }else if(Nums[i-2]>Nums[i-1]&&Nums[i-1]>Nums[i]){
      count++;
    }
  	}System.out.println(count);
  }
}



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

	int a, b, cnt = 0;

	cin >> a >> b;
	for (int i = a; i <= b; i++)
	{
		if ((i / 10000 == i % 10) && ((i / 1000) % 10) == (i / 10) % 10)
		{
			cnt++;
		}
	}
	cout << cnt << endl;
}
	

Measured memory_bytes: 3620
#include<stdio.h>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define Q 1000000007

// ll white, black;
// vector<vector<char>> c(h, vector<char>(w));
// ll ans = 0;
// vector<ll> a(N);
// const int M = 2;
// void dfs(vector<int> &A) {
//     // 終端条件 --- 10 重ループまで回したら処理して打ち切り
    

//     if(A.size() == h+w){
//       // rep(i, A.size()) cout << A[i];
//       // cout << " ";
//       vector<vector<char>> tmp(h, vector<char>(w));
//       rep(i, h){
//         rep(j, w) tmp[i][j] = c[i][j];
//       }
//       ll cnt = black;
//       for(ll i = 0; i < h; i++){
//         if(A[i] == 1){
//           // cout << i << " ";
//           rep(j, w){
//             if(tmp[i][j] == '#'){
//               tmp[i][j] = 'r';
//               cnt--;
//             }
//           }
//         }
//       }
//       for(ll i = h; i < h+w; i++){
//         if(A[i] == 1){
//           // cout << i << " ";
//           rep(j, h){
//             if(tmp[j][i-h] == '#'){
//               tmp[j][i-h] = 'r';
//               cnt--;
//             }
//           }
//         }
//       }

//       // cout << cnt << endl;
//       if(cnt == k) ans++;
      
//       return;
//     }

//     for (int v = 0; v < M; ++v) {
//         A.push_back(v);
//         dfs(A);
//         A.pop_back(); // これが結構ポイント
//     }
// }

int main(){
  
  ll n; cin >> n;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
  }

  ll ans = 0;
  rep(i, n-1){
    if(a[i+1] < a[i]){
      ans += a[i] - a[i+1];
      a[i+1] = a[i];
    }
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main()

{

    int N,ans,a,i;

    ans=0;

    cin>>N;

    for(i=1; i<=N; i++)

    {

        cin>>a;

        if(i%2!=0&&a%2!=0)

            ans++;

    }

    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N),c(N);
  for(int i=0;i<N;i++)cin>>v[i];
  for(int i=0;i<N;i++)cin>>c[i];
  int ans=0;
  for(int i=0;i<N;i++)ans+=max(0LL,v[i]-c[i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<math.h>

#define MAX 100500

using namespace std;

int main(){
    int N, i, j, g[MAX], h[MAX];

    cin >> N;
    
    for(i = 1; i <= N; i++){
        cin >> g[i];
        h[g[i]] = i;
    }

    for(j = 1; j <= N; j++){
        cout << h[j] << " ";
    }

   return 0;
    
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(void){

    long long k, n;
    cin >> k >> n;
    
    vector<long long> a(n);
    for(int i=0;i<n; i++) {
        cin >> a[i];
    }

    int max = 0;
    long long sum = 0;
    for(int i=0; i<n; i++) {
        int temp_max;
        if(i!=n-1) temp_max = a[i+1] - a[i];
        else temp_max = (k-a[i]) + a[0];
        
        sum += temp_max;
        if(temp_max > max) max = temp_max;
    }
    
    cout << sum - max << endl;


    return 0;    
}


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

using namespace std;


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

    long long sum = 0;
    for (int i = N - 1; i >= 0; i--) {
        long long d = (sum + A[i]) % B[i];
        d = (B[i] - d) % B[i];
        sum += d;
    }
    cout << sum << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
   ll n;cin>>n;
   ll a[n];
   for(ll i=0;i<n-1;i++){
       cin>>a[i];
   }
   ll count[n+3]={0};
   for(ll i=0;i<n-1;i++){
       count[a[i]]++;
   }
   
   for(ll i=1;i<=n;i++){
       cout<<count[i]<<endl;
   }
} 

Measured memory_bytes: 6760
#include<bits/stdc++.h>
using namespace std;
#define BOOST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ll long long
#define test(t) int t ; cin>>t ; while(t--)
ll mulmod(ll a, ll b, ll mod){ll res = 0;a = a % mod;while (b > 0){if (b % 2 == 1)res = (res + a) % mod;a = (a * 2) % mod;b /= 2;}return res % mod;}
int n;
int solve(int a , int b , int c){
	return min( (abs(b - a) + abs(c - b)) , (abs(c-a) + abs(b - c)));
}
int main(){
	BOOST;
	// cin >> n;
	int arr[3];
	for(int i = 0 ; i < 3 ; ++i){
		cin >> arr[i];
	}
	sort(arr, arr + 3);
	int a = solve(arr[0] , arr[1] , arr[2]);
	int b = solve(arr[1] , arr[0] , arr[2]);
	int c = solve(arr[2] , arr[1] , arr[0]);
	cout << min(a , min(b , c)) << endl;
	return 0;
}

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

using namespace std;

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

    n=(15-S.length())+std::count(S.begin(),S.end(),'o');

    if(n>7){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;


int main(){
   string w; cin >> w;
   bool ok = true;
   for(char c = 'a'; c <= 'z'; c++){
      int sum = 0;
      rep(i,w.size()){
         if(w[i] == c) sum++;
      }
      if(sum & 1) ok = false;
   }
   if(ok) cout << "Yes" << endl;
   else cout << "No" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define in auto&it
#define out auto it
#define rep(i,si,n) for(int i=si;i<n;++i)
#define all ar.begin(),ar.end()
#define mod 1000000007
const double pi = acos(-1);
int main() {
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// 	freopen("error.txt", "w", stderr);
	// #endif
	fastio
	string s;
	cin>>s;
	if(s[0]=='R' && s[1]=='R' && s[2]=='R') cout<<3;
	else if(s[0]=='R' && s[1]=='R') cout<<2;
	else if(s[1]=='R' && s[2]=='R') cout<<2;
	else if(s[0]=='R' || s[1]=='R' || s[2]=='R') cout<<1;
	else cout<<0;
	//cerr<<"time:  "<<(float)clock()/CLOCKS_PER_SEC<<"secs"<<'\n';
	return 0;
}

Measured memory_bytes: 3648
n=int(input())
al=list(map(int,input().split()))
t=[]
for i in range(n):
    t.append(al[i]-(i+1))
t=sorted(t)
if n%2==0:
    v=(t[n//2-1]+t[n//2])//2
else:
    v=t[n//2]
ans=0
for i in t:
    ans+=abs(i-v)
print(ans)

Measured memory_bytes: 25748
import math
a,b,c,d = map(int,input().split())
divc = b // c - (a-1) // c
divd = b // d - (a-1) // d
cd = b // ((c * d) // math.gcd(c,d)) - (a-1) // ((c * d) // math.gcd(c,d))
print(b - a - divc - divd + cd + 1)

Measured memory_bytes: 9176
import sys
import math
from itertools import accumulate as acc

def cul(x,X):
    dic={0:1}
    for i in range(len(x)):
        tmp={}
        for j in dic:
            tmp[j+x[i]]=1
            tmp[j-x[i]]=1
        dic=tmp
    if X in dic: return True
    else: return False

S=input()
s=list(S.split("T"))

X,Y=map(int,input().split())
x,y=[len(i) for i in s[::2]],[len(i) for i in s[1::2]]
if S[0]=="F": X=abs(X-x.pop(0))
Y=abs(Y)

print("Yes" if cul(x,X) and cul(y,Y) else "No")


Measured memory_bytes: 3952
function main(input){
  input = input.split('\n');
  const [A, B, C, D] = input[0].split(' ').map(Number);

  const ret = (Math.ceil(C/B) > Math.ceil(A/D))?
    'No' : 'Yes'

  console.log(ret)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 29592
n = int(input())
A = list(map(int, input().split()))

#%%
A = [0] + A
A.append(0)
#%%
diff = [abs(A[i] - A[i+1]) for i in range(len(A)-1)]
diff2 = [abs(A[i] - A[i+2]) for i in range(len(A)-2)]
total = sum(diff)

for i in range(n):
    ans = total - sum(diff[i:i+2]) + diff2[i]
    print(ans)

Measured memory_bytes: 20480
//gcc では以下のようにインクルードするといろいろ楽
//ただしきょうぷろ以外の目的での使用は推奨しない
#include<bits/stdc++.h>

//名前空間の指定
//これも競プロ以外だとあんまり推奨されない
using namespace std;

int main(){

    //C言語ではchar型の配列を文字列として使用したが、
    //C++では文字列型が用意されている
    string s, t;

    //printfよりも楽に書けるね！
    cin >> s >> t;
    
    //あとは同じ

    int ans = 0;
    //s.size()は、文字列sの長さを表す
    for (int i = 0;i<s.size();i++){
        if(s[i] != t[i]){
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3924
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
typedef long long ll;

int main() {
	int a, b, q; cin >> a >> b >> q;
	ll x;
	vector<ll>s, t;
	vector<ll>ans;
	for (int i = 0; i < a; i++) {
		cin >> x;
		s.push_back(x);
	}
	for (int i = 0; i < b; i++) {
		cin >> x;
		t.push_back(x);
	}
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	ll z;
	for (int i = 0; i < q; i++) {
		cin >> x;
		z = 200000000010;

		int tright = lower_bound(t.begin(), t.end(), x) - t.begin();
		int sright = lower_bound(s.begin(), s.end(), x) - s.begin();
		if (sright >= a) {
			sright = a - 1;
		}
		if (tright >= b) {
			tright = b - 1;
		}
		int tleft = tright - 1;
		int sleft = sright - 1;
		if (tleft < 0) {
			tleft = 0;
		}
		if (sleft < 0) {
			sleft = 0;
		}
		int c[] = { sright,sleft };
		int d[] = { tright,tleft };
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				z = min(z, abs(x - s[c[i]]) + abs(s[c[i]] - t[d[j]]));
				z = min(z, abs(x - t[d[j]]) + abs(t[d[j]] - s[c[i]]));
			}
		}
		ans.push_back(z);
	}
	for (int i = 0; i < q; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using Graph = vector<vector<int>>;

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

    cout << r * r << endl;
}

Measured memory_bytes: 256
private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

private fun List<String>.isSymmetric(): Boolean {
    for (i in (1 until size)) {
        for (j in (0 until i)) {
            if (this[i][j] != this[j][i]) {
                return false
            }
        }
    }
    return true
}

fun main(args: Array<String>) {
    val N = readInts()[0]
    val S = (1..N).map { readLine()!! }

    val SS = S + S

    println((0 until N).count { (SS.drop(it).take(N)).isSymmetric() } * N)
}

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

using namespace std;

typedef long long ll;

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

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

const int MAX_N = 1000000000;
vector<bool> numbers;
vector<int> primes;
vector<int> factors;

void collect_primes(const int n) {
    numbers.resize(n, true);
    for (int i = 2; i * i <= n; i++) {
        if (numbers[i]) {
            primes.push_back(i);
            for (int j = i; j * j <= n; j += i) {
                numbers[j] = false;
            }
        }
    }
}

void factorize(const int n) {
    int x = n;
    for (int i = 0; i < (int) primes.size(); i++) {
        int prime = primes[i];
        while (x % prime == 0) {
            factors.push_back(prime);
            x /= prime;
        }
    }
    // A prime factor larger than sqrt(x) is added here.
    if (x != 1) {
        factors.push_back(x);
    }
}

// ref. http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A
int main(void) {
    int n;
    cin >> n;

    collect_primes(n);

    factorize(n);
    cout << n << ": " << factors[0];
    for (int i = 1; i < (int) factors.size(); i++) {
        cout << " " << factors[i];
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 125036
#include<iostream>
#include<algorithm>
#include<stack>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
const int N=100100;
unsigned long long ans=1;
unsigned long long a[N],n;
int j,k;
int main(){
cin >> n;
for(int i=0;i<n;i++){
cin>> a[i];
}
for(int i=0;i<n;i++){
if(a[i]==0) k++;
}
if(k==0){
for(int i=0;i<n;i++){

if(ans>1000000000000000000/a[i]) break;
else {j++;
ans=ans*a[i];
continue;
}
}
if(j==n) cout << ans<<endl;
else cout <<"-1"<<endl;
}
else if(k>0) cout <<"0"<<endl;
return 0;
}


Measured memory_bytes: 4404
#include <stdio.h>
int main(void)
{
long a,b,r,c;
while(scanf("%ld %ld",&a,&b)!=EOF)
{
c=a*b;
for( ;b!=0; )
{
r=a%b;
a=b;
b=r;
}
printf("%ld %ld\n",a,c/a);
}
exit(0);
}



Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
using namespace std;

int main(){
    int n,m ;
    cin >> n >> m ;
    vector<int> a(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    a.at(0) %= m ;
    for (size_t i = 0; i < n-1; i++)
    {
        a.at(i+1) += a.at(i) ;
        a.at(i+1) %= m ;
    }
    map<int64_t,int64_t> mod ;
    mod[0] ++ ;
    vector<int> num(1,0) ;
    for (size_t i = 0; i < n; i++)
    {
        mod[a.at(i)] ++ ;
        if (mod[a.at(i)] == 1)
        {
            num.push_back(a.at(i)) ;
        }
        
    }
    int64_t ans = 0 ;
    for (size_t i = 0; i < num.size(); i++)
    {
        int64_t next = mod[num.at(i)] * (mod[num.at(i)] -1) /2 ;
        ans += next ;
    }
    cout << ans << endl ;
}

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


int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<int> a(n),b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    vector<ll> s(n+1),t(m+1);
    s[0] = 0;
    rep(i,n){
        s[i+1] = s[i]+a[i];
    }
    t[0]=0;
    rep(i,m){
        t[i+1] = t[i]+b[i];
    }
    int ans = 0;
    rep(i,n+1){
        ll res = k-s[i];
        if(res < 0) continue;
        int now = i;
        auto itr = upper_bound(t.begin(),t.end(),res);
        now += distance(t.begin(),itr)-1;
        ans = max(ans,now);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8004
N=list(input())

N.insert(0,0)
ans=0
for i in range(len(N)-1,-1,-1):
  n=int(N[i])
  if n//10>=1:
    N[i-1]=str(int(N[i-1])+1)
    continue
    
  if n==5:
    if int(N[i-1])>=5:
      N[i-1]=str(int(N[i-1])+1)
    ans+=5
  elif n>=6:
    ans+=10-n
    N[i-1]=str(int(N[i-1])+1)
  else:
    ans+=n
    
print(ans)

Measured memory_bytes: 66788
x, k, d = map(int, input().split())

if abs(x) >= k * d:
    ans = abs(x) - k * d
else:
    k -= abs(x) // d
    if k % 2 == 0:
        ans = abs(x) % d
    else:
        ans = d - abs(x) % d

print(ans)


Measured memory_bytes: 9164
#include <stdio.h>
int main(void){
    
    int h,w,H,W;
    for(;;){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0)break;
        for(h=0; h<H; h++){
            for(w=0; w<W; w++){
                printf("#");
                
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2124
n = int(input())

m = int(1e9 + 7)
s = "AGCT"
ng = ["AGC", "ACG", "GAC"]
dp = [[0 for _ in range(64)] for _ in range(2)]
for j in range(64):
    t = s[j // 16] + s[(j // 4) % 4] + s[j % 4]
    if t not in ng:
        dp[1][j] = 1
for i in range(4, n + 1):
    for j in range(64):
        dp[i % 2][j] = 0
    for j in range(64):
        for k in range(4):
            t = s[j // 16] + s[(j // 4) % 4] + s[j % 4] + s[k]
            if t[1:] not in ng and t[0] + t[2:] != ng[0] and t[:2] + t[3] != ng[0]:
                dp[i % 2][4 * (j % 16) + k] += dp[1 - i % 2][j]
                dp[i % 2][4 * (j % 16) + k] %= m
ans = sum(dp[n % 2]) % m
print(ans)

Measured memory_bytes: 40176
N = int(input())
S = [0]*N
for i in range(N):
    S[i] = input()
# print(N, S)

T = []
for s in S:
    t = {}
    for i in range(26):
        t[chr(ord('a') + i)] = 0
    for a in s:
        t[a] += 1
    T.append(t)
# print(T)

ans = T[0]
for i in range(1, N):
    t = T[i]
    for j in range(26):
        k = chr(ord('a') + j)
        ans[k] = min(ans[k], t[k])
a = ''
for i in range(26):
    k = chr(ord('a') + i)
    a += k*ans[k]

print(a)


Measured memory_bytes: 40048
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc050/submissions/2589569 を参考に作成
 */
public class Main {

	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long n = scanner.nextLong();
			System.out.println(rec(n, n, new HashMap<>()));
		}
	}

	private static long rec(long x, long s, Map<List<Long>, Long> map) {
		if (s == 0L) {
			return 1L;
		}
		List<Long> key = Arrays.asList(x, s);
		Long result = map.get(key);
		if (null != result) {
			return result;
		} else {
			result = (rec(x / 2, s / 2, map) + rec((x - 1) / 2, (s - 1) / 2, map)
					+ ((s >= 2L) ? rec(x / 2, (s - 2) / 2, map) : 0L)) % MOD;
			map.put(key, result);
			return result;
		}
	}
}


Measured memory_bytes: 23636
import bisect
n = int(input())
*A, = map(int, input().split())
G = [[] for i in range(n)]
for i in range(n - 1):
    x, y = map(int, input().split())
    G[x - 1].append(y - 1)
    G[y - 1].append(x - 1)
inf = 10**10
DP = [inf for i in range(n)]
L = [0 for i in range(n)]
V = [False for i in range(n)]
Q = [(0, -1)]
while Q:
    x, a = Q.pop()
    if a == -1:
        V[x] = True
        i = bisect.bisect_left(DP, A[x])
        Q.append((i, DP[i]))
        DP[i] = A[x]
        L[x] = bisect.bisect_left(DP, inf)
        for y in G[x]:
            if not V[y]:
                Q.append((y, -1))
    else:
        DP[x] = a
print(*L, sep='\n')


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000001)
#define MOD (1000000007)
#define PI (acos(-1))

bool kaibun(string s){
  int n = s.size();
  rep(i,n){
    if(s[i] != s[n-1-i]){
      return false;
    }
  }
  return true;
}

int main(){
  string s,a="";
  cin >> s;
  int n=s.size();
  int hajileft=0,hajiright=0,acnt=0;
  int b[n+1]={};//aのi文字目の右にxが何個あるか
  rep(i,n){
    if(s[i]=='x'){
      b[acnt]++;
    }else{
      acnt++;
      a=a+s[i];
    }
  }
  if(!kaibun(a)){
    cout << -1 << endl;
    return 0;
  }
  int ans=0;
  if(acnt%2==1){
    rep(i,(acnt-1)/2+1){
      ans += abs(b[i]-b[acnt-i]);
    }
  }else{
    rep(i,acnt/2){
      ans += abs(b[i]-b[acnt-i]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1080
#include <stdio.h>
int main() {
  int N, K, i, count;
  count = 0;
  scanf("%d", &N);
  scanf("%d", &K);
  int h[N+1];
  for (i = 0; i < N; ++i) {
    scanf("%d", &h[i]);
    if (h[i] >= K) {
      ++count;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
ll ans[500010];
ll cnt[500010];
ll a[500010];
priority_queue<ll,vector<ll>,greater<ll> > q;
priority_queue<ll,vector<ll>,greater<ll> > p;
ll n;
void run(){
	cin>>n;
	for(int i=0;i<3*n;i++)cin>>a[i];
	ll sum=0;
	for(int i=0;i<n;i++){
		sum+=a[i];
		q.push(a[i]);
	}
	ans[n-1]=sum;
	for(int i=n;i<2*n;i++){
		sum+=a[i];
		q.push(a[i]);
		sum-=q.top();
		q.pop();
		ans[i]=sum;
	}
	sum=0;
	for(int i=3*n-1;i>=2*n;i--){
		sum+=a[i];
		p.push(-a[i]);
	}
	cnt[2*n]=sum;
	for(int i=2*n-1;i>=n;i--){
		sum+=a[i];
		p.push(-a[i]);
		sum-=-p.top();
		p.pop();
		cnt[i]=sum;
	}
	ll mx=-LLINF;
	for(int i=n-1;i<2*n;i++){
		mx=max(mx,ans[i]-cnt[i+1]);
	}
	cout<<mx<<endl;
}
int main(){
	run();
	return 0;
}

Measured memory_bytes: 10100
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    string N;
    cin >> N;

    int ans = count_if(N.begin(), N.end(), [](const char &c) {
        return c == '2';
    });

    cout << ans << endl;

}



























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

using namespace std;

template <typename type>
type BaseChange(type num, type base, type digit)
{
    for(type i=0;i<digit;i++) num/=base;        
    return num%base;
}

int main()
{
    // 基本データ入力
    int n, m, x;
    cin >> n >> m >> x;
    
    // コストとデータ入力
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<n;i++){
        cin >> c[i];
        for(int j=0;j<m;j++) cin >> a[i][j];
    }

    int ans=(1<<30);

    // ビット全探索
    for(int i=1;i<(1<<n);i++){
        int cost=0;
        vector<int> state(m,0);
        for(int j=0;j<n;j++){
            // 検索文字がhit
            // cout << BaseChange(i,2,j);
            if(BaseChange(i,2,j)){
                cost+=c[j];
                for(int k=0;k<m;k++){
                    state[k]+=a[j][k];
                }
            }
        }
        // cout << endl;
        // デバッグ用
        // cout << " " << cost << " ";
        // for(int j=0;j<m;j++) cout << state[j] << " ";
        // cout << endl;
        bool check=true;
        for(int j=0;j<m;j++){
            if(state[j]<x){
                check=false;
                break;
            }
        }
        if(check) ans = min(ans, cost);
    }
    if(ans==(1<<30)) ans=-1;
    cout << ans << endl;
}

Measured memory_bytes: 3608
import Data.List                                                                                                           
                                                                                                                           
main :: IO ()                                                                                                              
main = do                                                                                                                  
  [n,_] <- map read . words <$> getLine :: IO [Int]                                                                        
  xs <- sort . map read . words <$> getLine :: IO [Int]                                                                    
  let zs = sum $ take (n - 1) $ sortBy (\a b -> compare b a) $ zipWith (-) (tail xs) xs                                    
  print $ (last xs - head xs) - zs

Measured memory_bytes: 33404
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int H, N;
  cin >> H >> N;
  int act[100100];
  for(int i = 0; i < N; i++){
    cin >> act[i];
  }
  int dmg = 0;
  for(int i = 0; i < N; i++){
    dmg += act[i];
  }
  if(dmg >= H) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>n>>a>>b;
    rrep(i,1,n+1){
        s=to_string(i);
        rep(j,Size(s)){
            cnt+=(s[j]-'0');
        }
        if(a<=cnt&&cnt<=b)ans+=i;
        cnt=0;
    }
    Cout(ans);
    return 0;
}


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

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

    for (char ch = 'a'; ch <= 'z'; ch++) {
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == ch) {
                break;
            }
            if (i == s.size() - 1) {
                cout << ch << endl;
                return 0;
            }
        }
    }
    cout << "None" << endl;
}

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

int main(){
  string S;
  long long K;
  cin >> S >> K;
  int i=0;
  for (int i=0;i<S.size();i++){
    if (i==K-1){
      cout << S[i] << endl;
      break;
    }
    else if (S[i]!='1'){
      cout << S[i] << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int main() {
    map<string, int> map;
    vector<string> arr;
    int N;
    cin>>N;
    string S;
    for(int i=0;i<N;++i){
        cin>>S;
        if(map[S]==0) arr.push_back(S);
        map[S]++;
    }
    cout<<arr.size()<<endl;
}



Measured memory_bytes: 25140
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>

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

int main(void) {
	int n;
	int a[100001];
	int temp = 1, cnt = 0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	qsort(a, n, sizeof(int), cmp);

	for (int i = 0; i < n; i++) {
		if (a[i] == a[i + 1])temp++;
		else {
			if (temp % 2)cnt++;
			temp = 1;
		}
	}
	printf("%d",cnt);
	return 0;
}


Measured memory_bytes: 892
import bisect

def number(num):
  #0bのぶんを引きます
  number_len = len(bin(num))-2
  #numと同じ桁数で各桁が全て1である数を求めます。
  f = 2**number_len - 1
  #排他的論理和をとって1を足したものを返します
  return (num^f)+1

n=int(input())
line=list(map(int,input().split()))
#sortを忘れないようにしてください
line.sort()

count=0

while len(line)>0:
  #最後の数を取ってくる(最後尾なのでO(1)で済む)
  k=line.pop()
  #lineに要素が存在しないならループから抜ける
  if len(line)==0:
    break
  #整数でないならその数は存在しないと同義なので処理を行わない
  if int(k) != k:
    continue
  x=number(k)
  #もしlineの最大値よりxが大きければ条件を満たすxは存在しないので処理を行わない
  if x>line[-1]:
    continue
  #その数が存在するならば、その数をlistから消去して、カウントする
  if line[bisect.bisect_left(line,x)]==x:
    #0.5を引くことでremoveの代わりとする
    line[bisect.bisect_left(line,x)] -= 0.5
    count+=1

print(count)

Measured memory_bytes: 25708
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;

bool can(int x, int k, vector<int> v) {
  for(int i = 0; i < v.size(); i++) {
    v[i] %= x;
  }
  sort(v.begin(), v.end());
  while(v.size()) {
    if(v[0] == 0) {
      v.erase(v.begin());
      continue;
    }
    assert(v.size() > 1);
    int delta = min(v[0], x - v.back());
    if(delta > k) return false;
    k -= delta;
    v[0] -= delta;
    v[v.size()-1] += delta;
    if(v[0] == 0) {
      v.erase(v.begin());
    }
    if(v.back() == x) {
      v.erase(v.begin() + v.size() - 1);
    }
  }
  return true;
}

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> v;
  int tot = 0;
  for(int i = 0; i < n; i++) {
    int t;
    cin >> t;
    tot += t;
    v.push_back(t);
  }
  int ret = 1;
  for(int i = 1; i * i <= tot; i++) {
    if(tot%i) continue;
    if(tot/i > ret && can(tot/i, k, v)) {
      ret = tot/i;
    }
    if(i > ret && can(i, k, v)) {
      ret = i;
    }
  }
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  // casesolve();
  solve();
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		n, k int
		s    string
	)
	fmt.Scan(&n, &k, &s)
	var (
		ans, sum, l int
		bls, brs    byte = '1', '1'
	)
	for r := 0; r < n; r++ {
		if brs != s[r] {
			brs = s[r]
			if s[r] == '0' {
				k--
			}
		}
		if k < 0 {
			for l < n {
				if bls != s[l] {
					bls = s[l]
					if s[l] == '1' {
						k++
						break
					}
				}
				l++
				sum--
			}
		}
		sum++
		if sum > ans {
			ans = sum
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;

int main(){
    int64_t a[7];
    for(int i=0;i<7;i++){
        cin>>a[i];
    }
    int64_t res = a[1];
    int odd=0;
    if(a[0]%2==1){
        odd++;
    }
    if(a[3]%2==1){
        odd++;
    }
    if(a[4]%2==1){
        odd++;
    }
    bool flag;
    if(a[0]>0 && a[3]>0 && a[4]>0){
        flag = true;
    }else{
        flag = false;
    }
    if(flag && odd>=2){
        res+=3;
        a[0]--;
        a[3]--;
        a[4]--;
    }
    res += (a[0]/2)*2+(a[3]/2)*2+(a[4]/2)*2;
    cout<<res<<endl;
    
    return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;

    vector<i64> s(N);
    rep(i,0,N){
        cin >> s[i];
    }

    i64 ans=0;
    vector<i64> acc(N); // mod xでの累積和
    rep(x,1,N){
        i64 d=(N-1)%x;
        rep(i,1,N){
            i64 j=i*x+d;
            if(j>=N) break;
            acc[j]=acc[j-x]+s[j];
        }

        i64 sum=0;
        rep(k,0,N){
            i64 pk=k*x;
            if(pk>=N-1) break;

            sum+=s[pk];

            i64 a=(N-1)-pk;
            if(a<=0 or N<=a) continue;

            i64 b=a-x;
            if(b<=0 or (k>=1 and b>=a)) continue;

            if(k>=1) {
                if (pk + b >= N - 1) continue;
                if (a <= pk and b % (a - b) == 0) continue;
            }

            i64 add=acc[k*x+b]-acc[b];
            chmax(ans,sum+add);
        }
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 1792