akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        string s, t;
        cin >> s >> t;
        if (s == t) {
                cout << N << endl;
                return 0;
        }

        ll cnt = 0;
        rep(i, 0, N) {
                //cout << s.substr(N-1-i, i+1) << ' ' <<  t.substr(0, i+1) << endl;
                if (s.substr(N-1-i, i+1) == t.substr(0, i+1)) {
                        chmax(cnt, i+1);
                }
                // if (s[N-1-i] == t[i] and t[i] == s[N-1]) ++cnt;
                // else break;
        }
        
        cout << 2*N - cnt << endl;
}

Measured memory_bytes: 3576
import sys
import numpy as np
from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse.csgraph import dijkstra

input = sys.stdin.readline

n, x, y = map(int, input().split())
# A,B: 頂点, C: コスト
A, B, C = [], [], []

for i in range(n-1):
    A.append(i)
    B.append(i+1)
    C.append(1)

A.append(x-1)
B.append(y-1)
C.append(1)

# directed: 有効ならTrue, indices: 始点
# WF O(V^3)
# wf = floyd_warshall(csr_matrix((C, (A, B)), shape = (n, n)), directed=False)
# Dijkstra O((V+E)logV)


dist = dijkstra(csr_matrix((C, (A, B)), shape = (n, n)), directed=False).astype(int)
ans = np.bincount(dist.ravel(), minlength=n) // 2
print(*ans[1:], sep='\n')

Measured memory_bytes: 76524
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll gcd(ll a,ll b){
  ll r=a%b;
  while(r>0){
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll now;
  cin>>now;
  for(int i=0;i<n-1;i++){
    ll a;cin>>a;
    now=gcd(now,a);
  }
  cout<<now<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1000000007;

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  for (int i=0; i<N; i++) cin >> A[i];
  for (int i=0; i<M; i++) cin >> B[i];
  if (N<M) {
    cout << "No" << endl;
    return 0;
  }
  else {
    for (int y=0; y<N-M+1; y++) {
      for (int x=0; x<N-M+1; x++) {
        bool flag = true;
        for (int i=0; i<M; i++) {
          for (int j=0; j<M; j++) {
            if (A[i+y][j+x]!=B[i][j]) {
              flag = false;
              break;
            }
          }
          if (!flag) break;
        }
        if (flag) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<set>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn =1e5+10;
int a[maxn];
multiset<int> q;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i=1;i<=n;i++)
        cin >> a[i];
    for(int i=1;i<=n;i++)
    {
        multiset<int>:: iterator it =q.lower_bound(a[i]);
        if(it==q.begin())
            q.insert(a[i]);
        else
        {
            it--;
            q.erase(it);
            q.insert(a[i]);
        }
    }
    cout << q.size();
    return 0;
}

Measured memory_bytes: 5376
#include<cstdio>
int main()
{
    int n,m,k,N[201]={0},BOX[201]={0},cnt;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=2*n;i++){
        N[i]=i;
    }
    for(int i=0;i<m;i++){
        scanf("%d",&k);
        cnt=1;
        if(k==0){
            for(int j=1;j<=2*n;j+=2){
                BOX[j]=N[cnt];
                BOX[j+1]=N[n+cnt];
                cnt++;
            }
            for(int j=1;j<2*n;j++){
                N[j]=BOX[j];
            }
        }
        else {
            for(int j=1;k+j<=2*n;j++){
                BOX[j]=N[k+j];
            }
            for(int j=2*n-k+1;j<=2*n;j++){
                BOX[j]=N[j-2*n+k];
            }
            for(int j=1;j<=2*n;j++){
                N[j]=BOX[j];
            }
        }
    }
    for(int i=1;i<=2*n;i++){
        printf("%d\n",N[i]);
    }
    return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    for (int i = 1; i <= 9; i++) {
      int cand = N / i;
      if (1 <= cand && cand <= 9 && cand * i == N) {
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	cout << 0 << endl;
	string s;
	cin >> s;

	int a;
	if (s == "Male") {
		a = 1;
	} else if (s == "Female") {
		a = 0;
	}

	int l = 0, r = n;
	while (s != "Vacant") {
		int c = (l + r) / 2;
		cout << c << endl;
		cin >> s;

		if (s == "Male") {
			if (a) {
				if (c & 1 == 1) {
					r = c;
				} else {
					l = c;
				}
			} else {
				if (c & 1 == 1) {
					l = c;
				} else {
					r = c;
				}
			}
		} else if (s == "Female") {
			if (a) {
				if (c & 1 == 1) {
					l = c;
				} else {
					r = c;
				}
			} else {
				if (c & 1 == 1) {
					r = c;
				} else {
					l = c;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 852
N = int(input())

ans = 0
for a in range(1, N):       # aを固定として回す
    q, mod = divmod(N, a)
    if mod == 0:            # modが0ならb=qとした場合, C=0となるため不採用
        q -= 1
    ans += q

print(ans)


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

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ')
            .Select(x => Int32.Parse(x)).ToArray();
        var s = l[0]; var w = l[1];
        if (w >= s) Console.WriteLine("unsafe");
        else Console.WriteLine("safe");
    }
}


Measured memory_bytes: 28300
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll b=0,c=0,d=0,m,n,min=100000,k,ans=0,ans2=0;
    string s,s2;
    cin >> n >> m >> k;
    VI a(100);
    rep(i,m){cin >> b; a[b]++;} 
    for(int i=k;i<n;i++){
        if(a[i]>0){
            ans++;
        }
    }
    for(int i=0;i<k;i++){
        if(a[i]>0){
            ans2++;
        }
    }
    if(ans>ans2)
        cout << ans2 << endl;
    else cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;

int main()
{
	int N;
	cin >> N;
	vint H(N);
	rep(i, N)
	{
		cin >> H[i];
	}
	vint x;
	int i = 0;
	while(i < N)
	{
		int j = i;
//		print(i)
		while (i + 1 < N and H[i] >= H[i + 1])
		{
			i++;
		}
		if (x.size() != 0)
			x.push_back(i - j);
		else x.push_back(i);
		i++;
	}
	ll max = *max_element(x.begin(), x.end());
	rep(i, x.size())
	{
	//	print(i)
	//		print(x[i])
	//		cout << endl;
	}
	
	cout<<max;
}


Measured memory_bytes: 1276
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	ll int n;
	
	while(cin>>n)
	{
		
		string ans="";
		
		while(n)
		{
			n--;
			
			int now=n%26;
			
			ans+=('a'+now);
			
			n/=26;
		}
		
		reverse(ans.begin(),ans.end());
		
		cout<<ans<<endl;
	}
	
	return 0;
}

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

using namespace std;

#define N 300000

int n,x,y,ans,tot,sg[N],head[N];
struct edge{int v,nxt;}e[N];


void add(int x,int y){e[++tot].v=y; e[tot].nxt=head[x]; head[x]=tot;}

void dfs(int u,int fa){
    sg[u]=1; int cnt=0;
    for (int i=head[u],v;i;i=e[i].nxt)
        if ((v=e[i].v)!=fa){
            dfs(v,u); if (sg[v]) cnt++; sg[u]^=sg[v];
        }
    if (cnt>=2){puts("First"); exit(0);}
}

int main(){
    scanf("%d",&n);
    for (int i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        add(x,y); add(y,x);
    }
    dfs(1,0);
    if (sg[1]) puts("First"); else puts("Second");

    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>

using namespace std;

const int MAX = 2e5;
const int INF = 2e9;
typedef long long ll;

int a[MAX + 1];

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

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

    sort(a, a + n);
    int maxdiff = 0;
    for (int i = 1; i < n; ++i)
    {
        maxdiff = max(maxdiff, a[i] - a[i - 1]);
    }
    maxdiff = max(maxdiff, k - a[n - 1] + a[0]);

    cout << k - maxdiff;


    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n];

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

	cout << a[n-1] - a[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repi(i, a, b) for(int i=(a); i>(b); i--)
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define fi first
#define se second
#define umap unordered_map
#define uset unordered_set
#define pqueue priority_queue
#define si(a) scanf("%d", &a)
#define sll(a) scanf("%lld", &a)
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
#define MOD 1000000007
#define N 3005
using namespace std;

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;

//All indexing is 0-based
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
			 tree_order_statistics_node_update> ordered_set;
//methods: find_by_order(k); & order_of_key(k);
//To make it an ordered_multiset, use pairs of (value, time_of_insertion)
//to distinguish values which are similar.

//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ ll c = a + b; if(c >= p) c -= p; return c;}
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c;}
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p;}



main()
{	
	#ifndef ONLINE_JUDGE
		//freopen("/home/tarun/Desktop/input.txt", "r", stdin);
//		freopen("/home/tarun/Desktop/output.txt", "w", stdout);
	#endif
	sync;
	clock_t clk = clock();
	cerr << "I will return...\n";
	
	string s; cin >> s;
	int k; cin >> k;

	rep(i, 0, s.sz) {
		if(s[i] == '1') k--;
		else k = 0;
		if(k == 0) {
			cout << s[i] << '\n';
			return 0;
		}
	}

	cerr << "...don't you ever hang your head.\n";
	cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << '\n';
}

//Compile using:
//g++ -o filename.exe --std=c++11 filename.cpp
//Use -D CP for defining a macro CP in the local environment







Measured memory_bytes: 256
len_arr = int(input())

conditions = [int(x) for x in input().split(' ')]
arr = [None] * len_arr

for i in reversed(range(0, len_arr)):
    sliced_arr = arr[i::i+1]
    current_condition = sum(sliced_arr[1:]) % 2

    if current_condition == conditions[i]:
        arr[i] = 0
    else:
        arr[i] = 1

# print(arr)
ball_indexes = [j+1 for j, ball in enumerate(arr) if ball == 1]

len_ans = len(ball_indexes)
print(len_ans)

if len_ans != 0:
    print(' '.join(map(str, ball_indexes)))

exit(0)


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

int main()
{
  ll n, k; cin >> n >> k;
  ll ans = pow(n/k, 3);
  if (k%2 == 0) {
    ans += pow((2*n/k)-(n/k), 3);
  }
  cout << ans << endl;

  return 0;
}


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

int const MAXN = 2000;
int const INF = MAXN*MAXN*2;

int dp[MAXN+1][MAXN+1];
int posw[MAXN+1], posb[MAXN+1];
int numw[MAXN*2+1][MAXN+1], numb[MAXN*2+1][MAXN+1];
int N;


int main() {
  std::cin >> N;
  std::fill_n(numw[0], N+1, 0);
  std::fill_n(numb[0], N+1, 0);
  posw[0] = posb[0] = 0;
  for(int i = 1; i <= N+N; ++i) {
    std::fill_n(numw[i], N+1, 0);
    std::fill_n(numb[i], N+1, 0);
    char c;
    int a;
    std::cin >> c >> a;
    if(c=='W') {
      posw[a] = i;
      numw[i][a] = 1;
    } else {
      posb[a] = i;
      numb[i][a] = 1;
    }
  }
  //
  for(int i = 1; i <= N+N; ++i) for(int j = N; j > 0; --j) {
    numw[i][j-1] += numw[i][j];
    numb[i][j-1] += numb[i][j];
  }
  for(int i = 1; i <= N+N; ++i) for(int j = 1; j <= N; ++j) {
    numw[i][j] += numw[i-1][j];
    numb[i][j] += numb[i-1][j];
  }

  for(int i = 0; i <= N; ++i) std::fill_n(dp[i], N+1, INF);
  dp[0][0] = 0;

  for(int i = 0; i <= N; ++i) {
    for(int j = 0; j <= N; ++j) {
      if(i+1 <= N) {
        int pos = posw[i+1];
        dp[i+1][j] = std::min(dp[i+1][j], dp[i][j] + numw[pos-1][i+1] + numb[pos-1][j+1]);
      }
      if(j+1 <= N) {
        int pos = posb[j+1];
        dp[i][j+1] = std::min(dp[i][j+1], dp[i][j] + numw[pos-1][i+1] + numb[pos-1][j+1]);
      }
    }
  }
  std::cout << dp[N][N] << std::endl;
  return 0;
}


Measured memory_bytes: 78464
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll cnt[10];
ll a[200020],b[200020];

int main(){
  ll h,w,n;
  cin >> h >> w >> n;

  map<pll,ll> mp;
  set<pll> se;
  rep(i,n){
    cin >> a[i] >> b[i];
    a[i]--,b[i]--;
  }
  rep(i,n){
    mp[{a[i],b[i]}]++;
    rep(j,9){
      if(0<=a[i]-j%3 && a[i]-j%3<h && 0<=b[i]-((j-j%3)/3) && b[i]-((j-j%3)/3)<w){
        se.insert({a[i]-j%3,b[i]-((j-j%3)/3)});
//        mp[{a[i-j%3],b[i-((j-j%3)/3)]}]++;
      }
    }
  }
//  for(auto i=se.begin();i!=se.end();i++)cout << i->first << i->second << endl;
  for(auto i=se.begin();i!=se.end();i++){
    ll x=i->first,y=i->second;
    if(x+2>h-1 || y+2>w-1)continue;
    int c=0;
    rep(i,9){
      if(mp[{x+i%3,y+(i-i%3)/3}]>0)c++;
    }
    cnt[c]++;
  }
  ll X=(h-2)*(w-2);
  rep(i,9)X-=cnt[i+1];
  cnt[0]=X;
  rep(i,10)cout << cnt[i] << endl;
return 0;}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;


using namespace std;


int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin>>n;

	ll a[n];

	ll c[n];

	

	loop(i,n)
	{
		cin>>a[i];
		c[i] = a[i];
		
	}

	sort(a,a+n);

	loop(i,n)
	{
		if(c[i] < a[n/2]) cout<<a[n/2]<<endl;
		else
			cout<<a[n/2-1]<<endl;
	}



}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;
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() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans;
  ans = gcd(a[0], a[1]);
  for (int i = 2; i < n; ++i) {
    ans = gcd(ans, a[i]);
  }

  cout << ans << endl;
  return 0;
}


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

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for ( int i = 0; i < n; i++ ) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	int sum = 0;

	for ( int i = 0; i < n; i++ ) {
		sum += a[i];
		if ( sum == x ) {
			cout << i + 1 << endl;
			return 0;
		}
		if ( sum > x ) {
			cout << i << endl;
			return 0;
		}
	}

	cout << n - 1 << endl;
}


Measured memory_bytes: 256
//https://beta.atcoder.jp/contests/abc081/tasks/abc081_b
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
    int a,b[210],cnt=0;
    bool flag=false;
    cin >> a;
    for(int i=0;i<a;i++) cin >> b[i];

    while(true){
        for(int i=0;i<a;i++){
            if(b[i]%2==1) flag=true; 
            else b[i]/=2;
        }
        if(flag==true) break;
        else cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define aio()                         \
    do {                              \
        std::ios::sync_with_stdio(0); \
        std::cin.tie(0);              \
    } while (0)
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
    aio();

    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);

    ll minus = min(k, x / d);
    k -= minus;
    x -= d * minus;
    if (k % 2 == 0) {
        cout << x;
    } else {
        cout << d - x;
    }
}


Measured memory_bytes: 3596
from collections import deque
S = deque([input()])
Q=int(input())
query=[[i for i in input().split()] for _ in range(Q)]

rf=0
for q in query:
    if q[0] == "1":
        rf ^= 1
    else:
        if q[1] == '1':
            if rf:
                S.append(q[2])
            else:
                S.appendleft(q[2])
        else:
            if rf:
                S.appendleft(q[2])
            else: 
                S.append(q[2])
print(''.join(S)[::-1] if rf else ''.join(S))

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

namespace AtCoderCs
{

    class Program
    {

        const int Mod = 1000000007;

        static void Main()
        {

            var num = long.Parse(Console.ReadLine());

            for (long i = 0, a; true; i++)
            {

                a = i * i * i * i * i; 

                for (long j = 0, b; true; j++)
                {

                    b = j * j * j * j * j;

                    if (a == num + b)
                    {

                        Console.WriteLine(i.ToString() + " " + j.ToString());
                        return;

                    }
                    else if (a == num - b)
                    {

                        Console.WriteLine(i.ToString() + " " + (-j).ToString());
                        return;

                    }
                    if (a < num + b && a + b > num) break;

                }


            }
        }



    }
}


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

int main(){
  int A, B, cnt = 0;
  int a[5] = {};
  
  cin>>A>>B;

  for(int i=A;i<=B;i++){
      a[0] = i % 10;
      a[1] = (i % 100) / 10;
      a[2] = (i % 1000) / 100;
      a[3] = (i % 10000)/ 1000;
      a[4] = (i % 100000) / 10000;
      if(a[0] == a[4] && a[1] == a[3]) cnt++;
  }

  cout<<cnt<<endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final String line = scanner.nextLine();
        final long k = scanner.nextLong();

        if (all(line)) {
            System.out.println(line.length() * k / 2);
            return;
        }

        long cost = 0;
        for (int i = 0; i < line.length() - 1; i++) {
            if (line.charAt(i) != line.charAt(i + 1)) {
                continue;
            }

            cost++;
            i++;
        }

        cost *= k;

        if (line.charAt(0) == line.charAt(line.length() - 1)) {
            final char begin = line.charAt(0);
            int a;
            for (a = 1; a < line.length() && line.charAt(a) == begin; a++) ;

            final char end = line.charAt(line.length() - 1);
            int b;
            for (b = 1; b < line.length() && line.charAt(line.length() - 1 - b) == end; b++) ;

            cost += (k - 1) * ((a + b) / 2 - a / 2 - b / 2);
        }

        System.out.println(cost);
    }

    private static boolean all(final String string) {
        final char c = string.charAt(0);
        for (int i = 1; i < string.length(); i++) {
            if (string.charAt(i) != c) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 21844
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]


def dfs(i, a, b, c):
    if i == n:
        if a < 1 or b < 1 or c < 1:
            return 10 ** 18
        return abs(A - a) + abs(B - b) + abs(C - c)

    res = dfs(i + 1, a, b, c)
    res = min([res, dfs(i + 1, a + l[i], b, c) + (10 if a > 0 else 0)])
    res = min([res, dfs(i + 1, a, b + l[i], c) + (10 if b > 0 else 0)])
    res = min([res, dfs(i + 1, a, b, c + l[i]) + (10 if c > 0 else 0)])
    return res


print(dfs(0, 0, 0, 0))


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

typedef long long ll;

ll dp[105][100005];

int w[105], v[105];

int main()
{
    int n,W;
    scanf("%d %d",&n,&W);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d %d",&w[i],&v[i]);
    }

    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j <= W; j++)
        {
            dp[i][j] = dp[i-1][j];
            if(w[i] <= j)
                dp[i][j] = max(dp[i][j], dp[i-1][j - w[i]] + v[i]);
        }
    }
    printf("%lld\n",dp[n][W]);
    return 0;
}

Measured memory_bytes: 79360
x,y=map(int,input().split())

x1,y1=x,y
if x1<=y1:
    ans1=y1-x1
else:
    ans1=10**10

x2,y2=-x,y
if x2<=y2:
    ans2=y2-x2+1
else:
    ans2=10**10

x3,y3=x,-y
if x3<=y3:
    ans3=y3-x3+1
else:
    ans3=10**10

x4,y4=-x,-y
if x4<=y4:
    ans4=y4-x4+2
else:
    ans4=10**10


print(min(ans1,ans2,ans3,ans4))








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


int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i = 0; i < N; i++){
        cin >> X.at(i);
    }
    sort(X.begin(), X.end());
    reverse(X.begin(), X.end());
    long hp = 0;
    int k = X.at(0);
    vector<long> hparray(k);
    for(int i = 1; i <= k; i++){
        for(int j = 0; j < N; j++){
            hp += pow(X.at(j) - i, 2);
        }
        hparray.at(i - 1) = hp;
        hp = 0;
    }
    sort(hparray.begin(), hparray.end());
    cout << hparray.at(0) << endl;
}

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

using ll = long long;

#define int ll

const int INF = 1e9 + 5;

int32_t main()
{
	int n,k;
	scanf("%lld%lld",&n,&k);
	vector<int> h(n);
	for(int& x : h)
	{
		scanf("%lld", &x);
	}
	vector<int> dp(n,INF);
	dp[0] = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<=i+k;j++)
		{
			if(j < n)
			{
				dp[j] = min(dp[j],dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	printf("%lld\n",dp[n-1]);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int dp[n],h[n];
    for(int i=0;i<n;i++)
    cin>>h[i];
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k;j++)
        {
            if(i-j>=0)
             dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
        }
    }
    cout<<dp[n-1]<<endl;
}

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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s, t, u;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if (s == u) a--;
  if (t == u) b--;
  cout << a << " " << b << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define MOD 1000000007
//#define MOD 998244353
#define EPS (1 >> 30)
//#define INF (1 << 30)
#define INF (1LL << 60)
#define ff first
#define ss second
//#define int long long
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};

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

using Graph = vector<vector<pair<int, int>>>;

Graph G;
vector<int> co;

void dfs(const Graph &G, int now, int gk)
{
    //debug(now);
    if (gk == 0)
    {
        co[now] = 0;
    }
    else
    {
        co[now] = 1;
    }
    for (int next = 0; next < G[now].size(); next++)
    {
        int ikisaki = G[now][next].ff;
        int cost = G[now][next].ss;
        if (co[ikisaki] == -1)
        {
            if (cost == 0)
            {
                dfs(G, ikisaki, co[now]);
            }
            else
            {
                dfs(G, ikisaki, (co[now] + 1) % 2);
            }
        }
    }
    return;
}

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

    int n;
    cin >> n;
    int u, v, w;
    G.resize(n);
    co.resize(n, -1);
    rep(i, n - 1)
    {
        cin >> u >> v >> w;
        u--, v--;
        w %= 2;
        G[u].push_back(pair<int, int>(v, w));
        G[v].push_back(pair<int, int>(u, w));
    }
    dfs(G, 0, 0);
    rep(i, n)
    {
        cout << co[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 8192
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>
#include <complex>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int a[100001] = {};
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);

	if(n == 2){
		cout << a[1] - a[0] << endl;
		cout << a[1] << " " << a[0] << endl;
		return 0;
	}

	long long int suma[100001] = {};
	for(int i = 1; i <= n; i++){
		suma[i] = suma[i - 1] + a[i - 1];
	}
	long long int ans = -mod;
	int max_i = 0;
	for(int i = 1; i < n; i++){
		long long int tmp = (suma[n] - suma[i]) - suma[i];
		if(tmp > ans){
			ans = tmp;
			max_i = i;
		}
	}
	// cout << max_i << endl;
	// 0 ... max_i - 1 まではマイナス
	// max_i, ... , n - 1 はプラス
	cout << ans << endl;
	if(max_i == n - 1){
		long long int now = a[n - 1];
		for(int i = n - 2; i >= 0; i--){
			cout << now << " " << a[i] << endl;
			now -= a[i];
		}
		return 0;
	}
	cout << a[0] << " " << a[max_i] << endl;
	long long int now = a[0] - a[max_i];
	for(int i = max_i + 1; i < n - 1; i++){
		cout << now << " " << a[i] << endl;
		now -= a[i];
	}
	cout << a[n - 1] << " " << now << endl;
	now = a[n - 1] - now;
	for(int i = max_i - 1; i >= 1; i--){
		cout << now << " " << a[i] << endl;
		now -= a[i];
	}

}

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

using ll=long long;

int main() {
  int N; cin >>N;
  vector<string> s(N);
  vector<int> t(N);
  rep(i,0,N) {cin >>s[i] >>t[i];}
  string X; cin >>X;
  int idx=0;
  rep(i,0,N) {
    if (s[i]==X) {
      idx=i+1;
    }
  }
  int ans=0;
  rep(i,idx,N) {
    ans+=t[i];
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 3588
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)




void mainmain(){
	int n;
	cin>>n;
	vint x(n);
	rep(i,n) cin>>x[i],x[i]--;
	vint v(n*n,-1);
	priority_queue<pii,vector<pii>, greater<pii> > pq;
	vint cnt(n);
	rep(i,n){
		v[x[i]]=i;
		if(i) pq.push(pii(x[i], i));
		if(n-1-i) pq.push(pii(x[i]+INF, n-1-i));
	}
	bool ok = true;
	rep(i,n*n){
		if(v[i]!=-1){
			// cout<<v[i]<<" "<<cnt[v[i]]<<endl;
			ok &= cnt[v[i]]==v[i];
		}
		else{
			pii top = pq.top();
			pq.pop();
			top.S--;
			if(top.F<INF) v[i]=v[top.F];
			else v[i]=v[top.F-INF];
			cnt[v[i]]++;
			if(top.S) pq.push(top);
		}
		// cout<<v[i]<<" "<<ok<<endl;
	}
	if(ok){
		cout<<"Yes"<<endl;
		rep(i,n*n){
			if(i) cout<<" ";
			cout<<v[i]+1;
		}
		cout<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 2304
s,k = input(),int(input())
n = len(s)
c = 0
x = []
a = 1
 
for i in range(n):
    if i<n-1 and s[i]==s[i+1]:
        a += 1
    else:
        c += a//2
        x.append(a)
        a = 1
 
c2 = 0
if s[0]==s[-1]:
    c2 = x[0]//2+x[-1]//2-(x[0]+x[-1])//2
 
print(len(s)*k//2 if len(set(s))==1 else c*k-c2*(k-1))

Measured memory_bytes: 9208
cnt = 0
n = int(input())
if n>=10:
    cnt += 9
    if n>=1000:
        cnt += 900
        if n>=100000:
            cnt += 90000
        elif n>=10000:
            cnt += n-9999
    elif n>=100:
        cnt += n-99
else:
    cnt += n
print(cnt)

Measured memory_bytes: 3060
import java.util.*;

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


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

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

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


Measured memory_bytes: 640
S=input()
T=input()

dp=[[0]*(len(T)+1) for _ in range(len(S)+1)]

for i in range(1,len(S)+1):
    s=S[i-1]
    for j in range(1,len(T)+1):
        t=T[j-1]
        if s==t:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])

ans=""
i=len(S)
j=len(T)
while i>0 and j>0:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    elif dp[i][j]==dp[i-1][j-1]+1:
        ans+=S[i-1]
        i-=1
        j-=1
print("".join(reversed(list(ans))))


Measured memory_bytes: 112732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> pa(N + 1);
    repp(i, 1, N) {
        pa[i] = pa[i-1] + A[i-1];
    }
    ll ans = LONG_MAX;
    int j1 = 0, j2 = 0, j3 = 0;
    repp(i2, 2, N - 2) {
        // pa[i1], pa[i2]-pa[i1], pa[i3]-pa[i2], pa[N]-pa[i3]
        ll PQ = pa[i2], RS = pa[N] - pa[i2];
        int i1 = lower_bound(pa.begin() + 1, pa.begin() + i2 + 1, PQ / 2.0) - pa.begin();
        int i3 = lower_bound(pa.begin() + i2 + 1, pa.begin() + N + 1, PQ + RS / 2.0) - pa.begin();
        if(i1 > 1) {
            if(abs(2 * pa[i1] - pa[i2]) > abs(2 * pa[i1 - 1] - pa[i2])){
                i1 = i1 - 1;
            }
        }
        if(i3 > i2 + 1) {
            if(abs(2 * pa[i3] - pa[i2] - pa[N]) > abs(2 * pa[i3 - 1] - pa[i2] - pa[N])){
                i3 = i3 - 1;
            }
        }
        ll P = pa[i1], Q = pa[i2] - pa[i1], R = pa[i3] - pa[i2], S = pa[N] - pa[i3];
        ll minSum = min(min(P, Q), min(R, S)), maxSum = max(max(P, Q), max(R, S));
        ans = min(ans, maxSum - minSum);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

vector<vector<int>> calc(int i, int now, int n, int m, vector<int> c) {
        if (i == n) {
                return vector<vector<int>>{c};
        }

        vector<vector<int>> ret;
        for (int o = now; o <= m; o++) {
                vector<int> cc = c;
                cc.push_back(o);
                auto r = calc(i + 1, o, n, m, cc);

                for (auto v : r) ret.push_back(v);
        }

        return ret;
}

int main() {
        int n, m, q;
        cin >> n >> m >> q;

        vector<int> a(q), b(q), c(q), d(q);
        rep (i, q) {
                cin >> a[i] >> b[i] >> c[i] >> d[i];
                --a[i]; --b[i];
        }

        auto vv = calc(0, 1, n, m, vector<int>());

        int ans = 0;
        for (auto v : vv) {
                int t = 0;
                rep (i, q) {
                        if (v[b[i]] - v[a[i]] == c[i]) {
                                t += d[i];
                        }
                }

                ans = max(ans, t);
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 11516
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
   int n;
   cin>>n;
   int ans=0;
   for(int i=1;i<=n;i++)
   {
       ans+=(n-1)/i;
   }
   cout<<ans<<endl;
    return 0;
}




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

int main() {
	string S, T;
  	int ans=0;
  	
  	cin >> S >> T;
  	for(int i=0;i<3;i++){
      	if(S.at(i) == T.at(i)){
        	ans++;
        }      
    }
  	
  	cout << ans << endl;
}

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

namespace MP2019B
{
    class MainClass
    {

        static int[] s;
        static int[] t;
        static int[] u;

        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            t = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            u = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);

            var lst = new List<int>
            {
                s[0],
                s[1],
                t[0],
                t[1],
                u[0],
                u[1]
            };

            var grp = lst.GroupBy(a => a).Select(c => c.Count()).ToList();
            grp.Sort();

            if (grp.Count() != 4)
            {
                Console.WriteLine("NO");
            }
            else
            {
                if (grp[0] == 1 && grp[1] == 1 && grp[2] == 2 && grp[3] == 2)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }




            return;


        }
    }
}


Measured memory_bytes: 13408
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll M=2e5+5;
const ll mod=998244353;
ll dp[M];
ll seg[4*M],nxt[M];
void update(ll i,ll s,ll e,ll x,ll y)
{
	if(s==e)
	{
		seg[i]=y;
		return;
	}
	ll m=(s+e)/2;
	if(x<=m)
		update(2*i,s,m,x,y);
	else
		update(2*i+1,m+1,e,x,y);
	seg[i]=max(seg[2*i],seg[2*i+1]);
}
ll query(ll i,ll s,ll e,ll l,ll r)
{
	if(s>r || l>e)
		return 0;
	if(s>=l && e<=r)
		return seg[i];
	ll m=(s+e)/2;
	return max(query(2*i,s,m,l,r),query(2*i+1,m+1,e,l,r));
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	std::vector<pair<ll,ll> > v;
	for(ll i=1;i<=n;i++)
	{
		ll x,d;
		cin>>x>>d;
		v.pb({x,d});
	}
	sort(all(v));
	dp[n]=1;
	for(ll i=n-1;i>=0;i--)
	{
		ll z=(ll)(lower_bound(all(v),mp(v[i].ff+v[i].ss,(ll)-1))-v.begin());
		//start from i end at z-1
		if(z==i+1)
		{
			update(1,0,n-1,i,i+1);
			dp[i]=(2*dp[i+1])%mod;
		}
		else
		{
			ll q=query(1,0,n-1,i+1,z-1);
			dp[i]=(dp[q]+dp[i+1])%mod;
			update(1,0,n-1,i,q);			
		}	
	}
	cout<<dp[0]<<"\n";
	return 0;
}

Measured memory_bytes: 12268
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	vector<int> v(3,0);
	for (int i = 0; i < 3; i++) {
		cin >> v[i];
	}

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

	cout << v[0] + v[1] + v[2] * 10 << endl;
	return 0;
}


Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    N = input()
    if N[len(N)-1] in '24579':
        print('hon')
    elif N[-1] in '0168':
        print('pon')
    else:
        print('bon')

if __name__ == '__main__':
  main()


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

void solve(){

	string s ;
	cin>>s ;

	int n=s.length() ;

	for(int i=n-1;i>=0;i--){


		string temp=s.substr(0,i) ;

		int l=temp.length() ;
		if(l%2==0){

			string x=temp.substr(0,l/2) ;

			x=x+x ;
			if(x==temp){
				cout<<x.length() ;
				return ;
			}

		}

	//	cout<<temp<<"\n" ;
	}

}


int main(){

     	int y ;

		y=1 ;
		//cin>>y ;

		while(y--){
 
			solve() ;

		}

}

Measured memory_bytes: 3560
#include <iostream>

using namespace std;

void solve()
{
	int x, y, z;
	int rect_count = 0;
	int lozenge_count = 0;
	while(~scanf("%d,%d,%d", &x, &y, &z))
	{
		if(x * x + y * y - z * z == 0)
		{
			rect_count++;
		}
		else if(x == y)
		{
			lozenge_count++;
		}
	}
	cout << rect_count << endl;
	cout << lozenge_count << endl;
}

int main()
{
	solve();
	return(0);
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> vec(N,0);

  for(int i=0; i<K; i++){
    int d;
    cin >> d;
    for(int j=0; j<d; j++){
      int k;
      cin >> k;
      vec.at(k-1)++;
    }
  }

  int count=0;
  for(int i=0; i<N; i++){
    if (vec.at(i)==0) {count++;}
  }

  cout << count << endl;
  
}

Measured memory_bytes: 3636
using System;

namespace workspace{
  public class Program{
    static void Main(){
      var S = Console.ReadLine();
      var T = Console.ReadLine();

      var ans = T.Length;

      for(int start= 0; start <= S.Length - T.Length; start++){
        var diff = 0;
        for(int i = 0; i < T.Length; i++){
          if(T[i] != S[start + i]){
            diff++;
          }
        }
        ans = Math.Min(ans, diff);
      }
      Console.WriteLine(ans);
    }
  }
}

Measured memory_bytes: 25932
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    int h,n; cin>>h>>n;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    int sum = 0;
    for(int i=0;i<n;i++) sum += arr[i];
    if(sum >= h) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
const double PI = acos(-1);
int main()
{
    vector<int> h, w;
    int _h, _w;
    while (1)
    {
        cin >> _h >> _w;
        if (_h == 0 && _w == 0)
        {
            break;
        }
        h.push_back(_h);
        w.push_back(_w);
    }
    int n = h.size();
    rep(i, n)
    {
        string rect = "";
        rep(y, h[i])
        {
            rep(x, w[i])
            {
                if((y%2==0 && x%2==0)||(y%2==1 && x%2==1)){
                    rect += "#";
                }
                else{
                    rect += ".";
                }
            }
            rect += "\n";
        }
    cout<<rect<<endl;        
    }
 //   system("pause");
    return 0;
}


Measured memory_bytes: 3168
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,v;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
 
  
for(i = 1 ; i <= n ;i++){
    v = A[i];
    j = i -1;
    while (j>= 0 && A[j] >v)
      {
	A[j+1] = A[j];
	j--;
      }
	A[j+1] = v;      
	trace(A,n);
      }

  return 0;
}

Measured memory_bytes: 604