akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

ll dp[100001][13];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	dp[0][0] = 1;
	rep(i, n) {
		int c = -1;
		if (s[i] != '?') c = s[i] - '0';
		rep(j, 10) {
			if (c != -1 && j != c) continue;
			rep(k, 13) {
				(dp[i + 1][(k * 10 + j) % 13] += dp[i][k]) %= mod;
			}
		}
	}
	cout << dp[n][5] % mod << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

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

    ll k, a, b;
    cin >> k >> a >> b;

    ll res = k + 1;
    if (a - 1 <= k && 2 < b - a) {
        k -= (a - 1);
        res = max(res, (k / 2) * (b - a) + a + (k % 2));
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import string

s = list(map(str, input()))
s = list(set(s))
s.sort()

ans = ""
arr = []

alp = list(map(str, string.ascii_lowercase))
for char in s:
    alp.remove(char)

if len(alp) == 0:
    print("None")
else:
    print(alp[0])


Measured memory_bytes: 10344
# -*- coding: utf-8 -*-
N, Y = map(int, input().split())
flag = 0
for i in range(N+1):
  for j in range(N-i+1):
    # print(i,j,N-i-j)
    if Y == 1000*i + 5000*j + 10000*(N-i-j):
      flag = 1
      print("{} {} {}".format(N-i-j,j,i))
      break
  if flag:
     break
if flag == 0:
  print("-1 -1 -1")

Measured memory_bytes: 3060
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')[0]
  const A = Number(input.split(' ')[0])
  const B = Number(input.split(' ')[1])

  let plug = 1
  let ans = 0
  while (plug < B) {
    ans++
    plug--
    plug += A
  }
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n,ans;
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	in(n);
	printf("%d\n",n*n);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long
#define INF 10e9

using namespace std;
using P = pair<int, int>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {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;
}

int N;
vector<string> mojis;
int main () {
  cin >> N;

  mojis.assign(N, "");

  Rep(i, N) {
    string str;
    cin >> str;

    vector<char> tmp;

    Rep(j, 10) {
      tmp.push_back(str[j]);
    }
    sort(tmp.begin(), tmp.end());

    string hoge(tmp.begin(), tmp.end());
    mojis[i] = hoge;
  }

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

  bool iscontinued = false;
  string tmp = "";
  ll int ans = 0;
  ll int tmp_num = 1;

  Rep(i, N) {
    if (tmp != mojis[i]) {
      if (tmp_num >= 2) {
        ans += tmp_num * (tmp_num-1) / 2;
      }

      tmp = mojis[i];
      iscontinued = false;
      tmp_num = 1;
    } else {
      tmp_num++;
    }
  }

  if (tmp_num >= 2) {
    ans += tmp_num * (tmp_num-1) / 2;
  }

  printf("%lld\n", ans);
}

Measured memory_bytes: 5760
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<set>
#include<string>
#include <vector>

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

using namespace std;

struct Card{
	char suit, value;
};

void bubble(struct Card A[], int N){
	REP(i, N){
		for (int j = N - 1; j >= i+1; j--){
			if (A[j].value < A[j - 1].value){
				Card t = A[j];
				A[j] = A[j - 1];
				A[j - 1] = t;
			}
		}
	}
}

void selection(struct Card A[], int N){
	REP(i, N){
		int minj = i;
		FOR(j, i, N){
			if (A[j].value < A[minj].value){
				minj = j;
			}
		}
		Card t = A[i];
		A[i] = A[minj];
		A[minj] = t;
	}
}

void print(struct Card A[], int N){
	REP(i, N){
		if (i > 0){
			cout << " ";
		}
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
	REP(i, N){
		if (C1[i].suit != C2[i].suit){
			return false;
		}
	}
	return true;
}

int main(){
	Card C1[100], C2[100];
	int N;
	char ch;

	cin >> N;
	REP(i, N){
		cin >> C1[i].suit >> C1[i].value;
	}

	REP(i, N){
		C2[i] = C1[i];
	}

	bubble(C1, N);
	selection(C2, N);

	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if (isStable(C1, C2, N)){
		cout << "Stable" << endl;
	}
	else{
		cout << "Not stable" << endl;
	}

	return 0;
}


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

#define ll long long
using namespace std;

priority_queue<int> q;


int main() {

    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        q.push(x);
        //cin >> a[i], mp[a[i]]++;
    }

    while (m--) {
        int now = q.top();
        q.pop();
        now /= 2;
        
        q.push(now);
    }
    ll ans = 0;
    while (!q.empty()) {
        ans += 1ll * q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}

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

int main() {

    int n;
    cin >> n;
    vector<int> d(n);

    for(int i = 0; i < n; i++){
          cin >> d.at(i);
    }

   set<int> mochi;

   for(int i = 0; i < n; i++){
      mochi.insert(d.at(i));
   }
   
    cout << mochi.size() << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll ans=0;
	ll pos=n;
	while(pos)
	{
		ans+=pos%10;
		pos/=10;
	}
	if(n%ans) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

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

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}
using vb = vector<bool>;

int suit(char& c){
  switch(c){
    case 'S': return 0;
    case 'H': return 1;
    case 'C': return 2;
    case 'D': return 3;
  }
}

char rsuit(int& n){
  switch(n){
    case 0: return 'S';
    case 1: return 'H';
    case 2: return 'C';
    case 3: return 'D';
  }
}

int main(){
  vector<vb> card(4, vb(13, true));
  int n;cin>>n;
  rep(i,n){
    char c; int r;
    cin>>c>>r;
    r--;
    card[suit(c)][r] = false;
  }
  rep(i,4){
    rep(j,13){
      if(card[i][j]){
        cout<<rsuit(i)<<" "<<j+1<<endl;
      }
    }
  }
}


Measured memory_bytes: 3096
S = list(input())
total=int(S[0])
i = 0
j = 0
k = 0
while True:
    if i == 0:
        total += int(S[1])
    else:
        total -= int(S[1])
    if j == 0:
        total += int(S[2])
    else:
        total -= int(S[2])
    if k == 0:
        total += int(S[3])
    else:
        total -= int(S[3])

    if total == 7:
        break
    else:
        if k == 0:
            k = 1
        else:
            k = 0
            if j == 0:
                j = 1
            else:
                j = 0
                i = 1
    total = int(S[0])
if i == 0:
    op1 = '+'
else:
    op1 = '-'
if j == 0:
    op2 = '+'
else:
    op2 = '-'
if k == 0:
    op3 = '+'
else:
    op3 = '-'


print(S[0]+op1+S[1]+op2+S[2]+op3+S[3]+'=7')

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

ll per[2000005], pre[2000005];
int main()
{
    ll n, ans = 1, mn;
    cin>>n;
    for(int i = 0; i < n; i++)
    {
        cin>>per[i];
        if(!i)
        {
            mn = per[i];
            continue;
        }
        if(per[i] < mn) ans++;
        mn = min(mn, per[i]);
    }
    cout<<ans<<"\n";
    return 0;
}


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

int main()
{
	long long  a , b ;
	long long x ,sum;
	scanf("%lld %lld %lld" ,&a,&b,&x);
	sum=(b/x) - ((a)/x);

    if(a%x == 0)
    ++sum;
    printf("%lld\n",sum);
}


Measured memory_bytes: 384
Public Class Program
  Shared Sub Main()
    Dim n As Integer = Cin.Int()
    Dim x As Integer() = Cin.IntArr()
    Dim a As Integer = 0
    For i As Integer = 0 To n - 1
      a += x(i)
    Next
    a = Math.Round(a / n, MidpointRounding.AwayFromZero)
    Dim ans As Integer = 0
    For i As Integer = 0 To n - 1
      ans += Math.Pow((x(i) - a), 2)
    Next
    Console.WriteLine(ans.ToString())
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){   
   int n,m,c;
   int count=0;
   cin>>n>>m>>c;
   vector<int> b(m);
   rep(i,m){
      cin>>b[i];
   }
   rep(i,n){
      vector<int> a(m);
      rep(j,m){
         cin>>a[j];
      }
      int sum=0;
      rep(j,m){
         sum+=b[j]*a[j];
      }
      sum+=c;
      if(sum>0) count++;
   }
   cout<<count<<endl;
return 0;
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

string s;

int main()
{
	cin >> s;
	for (int i = 0; i < s.size() - 1; i ++ )
		if (s[i] == s[i + 1])
		{
			cout << i + 1 << ' ' << i + 2 << endl;
			return 0;
		}
	
	for (int i = 0; i < s.size() - 2; i ++ )
		if (s[i] == s[i + 2])
		{
			cout << i + 1 << ' ' << i + 3 << endl;
			return 0;
		}
	
	puts("-1 -1");
	return 0;
}

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

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

typedef long long lint;

using namespace std;

int main(){
  int N,Q;
  cin>>N>>Q;
  vector<int> c[N];
  REP(i,N-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    c[a].push_back(b);
    c[b].push_back(a);
  }
  lint ans[N];
  REP(i,N)ans[i]=0;
  REP(i,Q){
    int p;
    lint x;
    cin>>p>>x;
    p--;
    ans[p]+=x;
  }
  queue<int> q;
  q.push(0);
  int d[N];
  REP(i,N)d[i]=0;
  d[0]=1;
  while(!q.empty()){
    int p=q.front();
    q.pop();
    for(auto e:c[p]){
      if(d[e])continue;
      d[e]=1;
      ans[e]+=ans[p];
      q.push(e);
    }
  }
  REP(i,N){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 17140
#include <iostream>
#include <cstdlib>
using namespace std;
const int INF = (1<<29);

int main(){
  int n,m;
  while(cin >> n >> m && (n || m)){
    int dp[150][10][80], a[150][10], x[150][10];
    for(int i=0;i<150;i++){
      for(int j=0;j<10;j++){
	for(int k=0;k<80;k++) dp[i][j][k] = INF;
	a[i][j] = INF;
      }
    }
    for(int i=0;i<n;i++){
      int k;
      cin >> k;
      for(int j=0;j<k;j++){
	int b,c;
	cin >> b >> c;
	x[i][j] = b;
	a[i][j] = c;
      }
    }
    for(int i=0;i<10;i++){
      dp[0][i][0] = 0;
      if(m != 1) dp[1][i][1] = 0;
    }
    for(int i=0;i<n-1;i++){
      for(int l=0;l<=m;l++){
	for(int j=0;j<10;j++){
	  if(a[i][j] == INF) continue;
	  for(int k=0;k<10;k++){
	    if(a[i+1][k] == INF) continue;
	    dp[i+1][k][l] = min(dp[i+1][k][l],dp[i][j][l] + (a[i][j] + a[i+1][k]) * (abs(x[i+1][k]-x[i][j])));
	  }
	  if(i < n - 2 && l != m){
	    for(int k=0;k<10;k++){
	      if(a[i+2][k] == INF) continue;
	      dp[i+2][k][l+1] = min(dp[i+2][k][l+1],dp[i][j][l] + (a[i][j] + a[i+2][k]) * (abs(x[i+2][k]-x[i][j])));
	    }
	  }
	}
      }
    }

    int ans = INF;
    for(int j=0;j<=m;j++) for(int k=0;k<10;k++) ans = min(ans,dp[n-1][k][j]);
    for(int j=0;j<m;j++) for(int k=0;k<10;k++) ans = min(ans,dp[n-2][k][j]);

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

Measured memory_bytes: 1348
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  const K=input[0].split(' ')[1]-0;
  const S=input[1];
  var island=0;
  var previous='';
  for(var i=0;i<N;i++){
    if(previous!==S[i]){
      previous=S[i];
      island++;
    }
  }
  
  console.log(N-Math.max(1,island-2*K));
 
}




//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32388
#include<stdio.h>

int main()
{
	int num[10000];
	int i=0,j=0;
	do
	{
		scanf("%d",&num[i]);
		i++;
	}while(num[i-1] != 0);
	while(num[j] != 0)
	{
		printf("Case %d: %d\n",j+1,num[j]);
		j++;
	}
	return 0;
}

Measured memory_bytes: 2704
a,b,c,d,n;
main(z){
	for(;scanf("%d%d%d%d%d",&n,&a,&b,&c,&d),n/=10;d>0&&printf("500 %d\n",d))
		--z&&puts(""),n-=a+5*b+10*c+50*d,d+=n/50,c+=n%50/10,b+=n%10/5,a+=n%5,a>0&&printf("10 %d\n",a),b>0&&printf("50 %d\n",b),c>0&&printf("100 %d\n",c);
}

Measured memory_bytes: 0
#include<cstdio>
#include<string>
#include<string>
#include<iostream>
using namespace std;
const int mo=1e9+7;
long long n,f[5005][5005],ans,x;
string c;
int main()
{
	scanf("%lld",&n);
	cin>>c;x=c.size();
	f[0][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=n;++j)
			f[i][j]=(2*f[i-1][j+1]+f[i-1][j-1<0?0:j-1])%mo;
	printf("%lld\n",f[n][x]%mo);
	return 0;
}

Measured memory_bytes: 195712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	int n=s.size();
	vector<vector<ll>> dp(n+1,vector<ll>(4));
	dp[0][0]=1;
	rep(i,n){
		if(s.at(i)=='A' || s.at(i)=='?'){
			dp[i+1][0]+=dp[i][0];
			dp[i+1][1]+=dp[i][1];
			dp[i+1][2]+=dp[i][2];
			dp[i+1][3]+=dp[i][3];
			dp[i+1][1]+=dp[i][0];
		}
		if(s.at(i)=='B' || s.at(i)=='?'){
			dp[i+1][0]+=dp[i][0];
			dp[i+1][1]+=dp[i][1];
			dp[i+1][2]+=dp[i][2];
			dp[i+1][3]+=dp[i][3];
			dp[i+1][2]+=dp[i][1];
		}
		if(s.at(i)=='C' || s.at(i)=='?'){
			dp[i+1][0]+=dp[i][0];
			dp[i+1][1]+=dp[i][1];
			dp[i+1][2]+=dp[i][2];
			dp[i+1][3]+=dp[i][3];
			dp[i+1][3]+=dp[i][2];
		}
		dp[i+1][0]%=mod;
		dp[i+1][1]%=mod;
		dp[i+1][2]%=mod;
		dp[i+1][3]%=mod;
	}
	cout << dp[n][3] << endl;
}

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

int top;
char Stack[1000000];

void push(char x) {
  top++;
  Stack[top] = x;
}

int pop() {
  return Stack[top--];
}

int main() {
  top = 0;
  
  string S;
  cin >> S;

  push(S[0]);
  for (int i = 1; i < S.size(); i++) {
    if (Stack[top] == '1' && S[i] == '0') {
      pop();
    } else if (Stack[top] == '0' && S[i] == '1') {
      pop();
    } else {
      push(S[i]);
    }
  }

  cout << S.size() - top << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test int t; cin>>t; while(t--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define f0(i,n) for( ll i = 0; i < ( n ); i ++)
#define f1(i,n) for(i = 1; i <= ( n ); i ++)
#define f(i,m,n) for(auto i = ( m ); i <= ( n ); i ++)
#define nl cout<<"\n"
#define  mod 1000000007
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(x) ((ll)x.size())
#define mem(a, b) memset(a, b, sizeof(a));
#define make_graph(k) int x,y; f0(i,k){cin>>x>>y; adj[x].pb(y); /*adj[y].pb(x);*/}
#define dekh cout<<"dekh"

#define o_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setpll tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update>
typedef vector<ll> vl;




/*ll Pow(ll a, ll b, ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll x = a*a;
        x%=m;
        return Pow(x,b/2,m);
    }
    return (a*Pow(a,b-1,m))%m;
}
*/
vector<ll>adj[200005];
 ll vis[200005]={0};
 ll depth[200005]={0};

//ll p;ll arr[200005];

void dfs(ll x)
{

    vis[x]=1;

    for(auto child : adj[x])
    {   if(!vis[child])
         {
             dfs(child);
         }
         depth[x]= max(depth[x],depth[child]+1);

    }

}





int main()
{
    fast
    ll n,m,i;
    cin>>n>>m;
    make_graph(m);
    f1(i,n)
    {
        if(!vis[i])
        {
            dfs(i);
        }
    }
    auto maxi= max_element(depth, depth+n+1);
    cout<<*maxi;

}





Measured memory_bytes: 15748
#整数の入力

K, X = map(int, input().split())

#初期値は X - (K - 1) で、(K*2 - 2)回、1つずつ増えた数を出力する

P = X - (K - 1) # 出力初期値

R = K * 2 - 1 # 繰り返し範囲定義用

if R < 0:
  print(X)
  
else: i = 0 
while i < R:
    print(P)
    P = P + 1
    i = i + 1

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

template<class T> struct UnionFind {
    std::vector<T> data;
    UnionFind(){};
    UnionFind(T size): data(size, -1){};
    void init(T size) {
        data.resize(size, -1);
    }
    T root(T x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    bool same(T x, T y) {
        return root(x) == root(y);
    }
    T size(T x) {
        return -data[root(x)];
    }
    bool unite(T x, T y) {
        x = root(x);
        y = root(y);
        if(x != y){
            if(data[y] < data[x]){
                std::swap(x, y);
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
};

int N, M;
VI p;

int main() {
    std::cin >> N >> M;
    p.resize(N);
    REP(i, N) {
        std::cin >> p[i];
        --p[i];
    }

    UnionFind<int> uf(N);
    REP(i, M) {
        int x, y;
        std::cin >> x >> y;
        uf.unite(x-1, y-1);
    }

    int i, cnt = 0;
    for(i=0; i<N; ++i) {
        if(i == p[i]) {
            ++cnt;
        } else if(uf.same(i, p[i])) {
            ++cnt;
        }
    }
    std::cout << cnt << std::endl;
}

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

int n, A[1000000];

int binary_search(int k) {
    int left = 0;
    int right = n;
    int mid;
    while (left < right) {
        mid = (left + right) / 2;
        if (A[mid] == k) return 1;
        else if (A[mid] < k) left = mid + 1;
        else right = mid;
    }
    return 0;
}
int main() {
    int i, q, k, sum = 0;
    
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> A[i];
    }
    
    cin >> q;
    for (i = 0; i < q; i++) {
        cin >> k;
        if (binary_search(k)) ++sum;
    }
    
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3456
module Main where
import Data.Char
int = read :: String -> Int
inte = read :: String -> Integer
getWord :: IO String
getWord = do
  c <- getChar
  if isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map inte . words
printer = unlines . (:[]) . show 

solver :: [Integer] -> Integer
solver [n,k] = sum $ map (takahashi n k) [1..n]

takahashi :: Integer -> Integer -> Integer -> Integer
takahashi n k b =
  if k==0 then n else
  if k <= b-1
  then (n `div` b) * (b - k) + max 0 ((n `mod` b) - (k-1))
  else 0
    


Measured memory_bytes: 1020
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
int N;
inline int len(P x){
	return x.sec-x.fi+1;
}
priority_queue<P,vector<P>,greater<P> > ep;
set<T> s;
vector<P> vec[10010];
int idnum;
map<int,int> id;
int rev[10010];
void debug(){
	vector<P> tmp;
	while(!ep.empty()){
		tmp.pb(ep.top());
		ep.pop();
	}
	for(int i=0;i<tmp.size();i++){
		printf("[%d %d]\n",tmp[i].fi,tmp[i].sec);
		ep.push(tmp[i]);
	}
	set<T>::iterator it;
	for(it=s.begin();it!=s.end();++it){
		printf("%d %d %d\n",(it->fi).sec,(it->fi).fi,it->sec);
	}
	return;
}
int solve(){
	while(!ep.empty())ep.pop();
	s.clear();
	for(int i=0;i<10010;i++)vec[i].clear();
	idnum=0;
	id.clear();
	scanf("%d",&N);
	if(N==0)return 1;
	ep.push(P(0,1000000100));
	for(int i=0;i<N;i++){
		char type;
		scanf(" %c",&type);
		if(type=='W'){
			int l,S;
			scanf("%d %d",&l,&S);
			id[l]=idnum;
			rev[idnum]=l;
			l = idnum++;
			while(S>0){
				P nxt = ep.top();
				ep.pop();
				if(len(nxt)>S){
					vec[l].pb(P(nxt.fi,nxt.fi+S-1));
					s.insert(T(P(nxt.fi+S-1,nxt.fi),rev[l])); // s?????????????????¢
					ep.push(P(nxt.fi+S,nxt.sec));
					S=0;
				}else{
					vec[l].pb(nxt);
					s.insert(T(P(nxt.sec,nxt.fi),rev[l])); 
					S -= len(nxt);
				}
			}
			//debug();
		}else if(type=='D'){
			int l;
			scanf("%d",&l);
			l = id[l];
			for(int i=0;i<vec[l].size();i++){
				P tmp = vec[l][i];
				ep.push(tmp);
				s.erase(T(P(tmp.sec,tmp.fi),rev[l]));
			}
			//debug();
		}else{
			int p;
			scanf("%d",&p);
			set<T>::iterator it = s.lower_bound(T(P(p,-1),-1));
			if(it==s.end()){
				printf("-1\n");
			}else{
				int L=(it->fi).sec,R=(it->fi).fi,ID=it->sec;
				if(L<=p&&p<=R)printf("%d\n",ID);
				else printf("-1\n");
			}
		}
	}
	return 0;
}
int main(){
	while(!solve()){
		printf("\n");
	}
	return 0;
}

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

ll n, a, b, c;
vector<ll> l;

ll dfs(ll i, ll la, ll lb, ll lc){
  if(i == n){
      if(min(la, min(lb, lc)) == 0) return 1e18;
      else return abs(a-la) + abs(b-lb) + abs(c-lc) - 30; // 30 is come from first merge.
  }
  ll ret0 = dfs(i+1, la, lb, lc); // l_i is not used for any tree.
  ll ret1 = dfs(i+1, la+l[i], lb, lc) + 10; // l_i is merged to A.
  ll ret2 = dfs(i+1, la, lb+l[i], lc) + 10; 
  ll ret3 = dfs(i+1, la, lb, lc+l[i]) + 10;
  return min(min(ret0, ret1), min(ret2, ret3));
}

int main(){
  cin >> n >> a >> b >> c;
  l.resize(n);
  rep(i, 0, n) cin >> l[i];
  
  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}


Measured memory_bytes: 3616
import copy

def init(init_val):
    for j in range(26):
        #set_val
        for i in range(n):
            if init_val[i] == j:
                seg[j][i+num-1] = 1
        #built
        for i in range(num-2,-1,-1):
            seg[j][i] = seg[j][2*i+1] | seg[j][2*i+2]


def update(k, cs):
    ls = s[k]
    if ls == cs:
        return
    k += num-1
    seg[cs][k] = 1
    seg[ls][k] = 0
    while k:
        k = (k-1)//2
        seg[ls][k] = seg[ls][k*2+1] | seg[ls][k*2+2]
        seg[cs][k] = seg[cs][k*2+1] | seg[cs][k*2+2]


def query(pp, qq): # pからq-1までの最大値
    pp += num-1
    qq += num-2
    total = 0
    for j in range(26):
        p = copy.deepcopy(pp)
        q = copy.deepcopy(qq)
        res = 0
        while q - p > 1:
            if res == 1:
                break
            if p&1 == 0:
                res = res | seg[j][p]
            if q&1 == 1:
                res = res | seg[j][q]
                q -= 1
            p = p//2
            q = (q-1)//2
        if q - p > 1:
            total += res
            continue
        if p == q:
            res = res | seg[j][p]
        else:
            res = res | seg[j][p] | seg[j][q]
        total += res
    return total


n = int(input())
s = list(input())
q = int(input())

for i in range(n):
    s[i] = ord(s[i]) - 97
#num:n以上の最小の2のべき乗
num = 2**(n-1).bit_length()
seg = [[0]*(2*num) for i in range(26)]
init(s)
for i in range(q):
    cq = list(input().split())
    if cq[0] == '1':
        cn, cs = int(cq[1]) - 1, ord(cq[2]) - 97
        update(cn, cs)
        s[cn] = cs
    if cq[0] == '2':
        p, q = int(cq[1]) - 1, int(cq[2])
        print(query(p, q))


Measured memory_bytes: 312720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		int S2 = Integer.parseInt(S);
		
		int out1 = S2 / 100;
		int out2 = S2 - out1*100;
		
		//System.out.println(out1 + "  "+ out2);
		boolean flag1 = false, flag2 = false;
		if(out1 <= 12 && out1 > 0) {
			flag1 = true;
		}
		if(out2 <= 12 && out2 > 0) {
			flag2 = true;
		}
		
		if(flag1 && flag2)System.out.println("AMBIGUOUS");
		else if(flag1)System.out.println("MMYY");
		else if(flag2)System.out.println("YYMM");
		else System.out.println("NA");
	}

}


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

string solve(ll n,ll k){
    ll ten=10;
    int keta=0;
    n--;
    for(int i=0;i<10;i++){
        ll cnt=(ten-ten/10)*(i+1);
        if(n<cnt){
            keta=i+1;
            break;
        }
        else{
            n-=cnt;
            ten*=10;
        }
    }
    ten/=10;
    ll pass=n/keta;
    n-=pass*keta;
    ll s=ten+pass;
    string res;
    while(k){
        string digit=to_string(s);
        for(int i=0;i<digit.size() && k;i++){
            if(n) n--;
            else{
                res+=digit[i];
                k--;
            }
        }
        s++;
    }
    return res;
}

int main(){
    ll n,k;
    while(cin>>n>>k,n){
        cout<<solve(n,k)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3244
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
v=list(map(int,input().split()))

ans=0
for i in range(k+1):
    toru=i
    ireru=k-i
    # print(toru)
    for j in range(toru+1):
        l,r=j,n-(toru-j)
        if l>r:
            lst=v[:]
        else:
            lst=v[:l]+v[r:]
        # print(lst)
        lst.sort(reverse=True)
        for l in range(ireru):
            if lst and lst[-1]<0:
                lst.pop()
        ans=max(ans,sum(lst))

print(ans)

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

int main() {
  ll N;
  cin >> N;
  vector<string> S(N);
  for (ll i = 0; i < N; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    S[i] = s;
  }
  sort(S.begin(), S.end());
  S.push_back("a");
  ll ans = 0;
  vector<ll> cnt(0);
  ll c = 1;
  for (ll i = 0; i < N; i++) {
    if (S[i] == S[i+1]) {
      c++;
    }
    else {
      cnt.push_back(c);
      c = 1;
    }
  }
  for (ll t : cnt) {
    ans += t*(t-1)/2;
  }
  cout << ans << endl;
}

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

namespace practice_csharp
{

    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var strings = Console.ReadLine().Split(' ').ToArray();
            var result = new System.Text.StringBuilder();
            for(int i=0;i < n; i++)
            {
                result.Append(strings[0][i]);
                result.Append(strings[1][i]);
            }

            System.Console.WriteLine(result.ToString());
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define sz(v) (ll)v.size()
using namespace std;

ll MOD=1e9+7;
ll g,h,l;
const ll N=100005;

ll add(ll a,ll b); ll mul(ll a,ll b); ll binpo(ll a,ll b);

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n;cin>>n;
    ll arr[n+1];
    repn(i,n)cin>>arr[i+1];
    ll dp[n+1]={0};
    dp[0]=INT_MAX;
    rep(i,2,n){
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n];
}

ll add(ll a,ll b)
{
    return (a%MOD+b%MOD)%MOD ;
}
ll mul(ll a,ll b)
{
    return (a* 1ll *b)%MOD ;
}
ll binpo(ll a,ll b)
{
    int ans = 1 ;
    while(b)
    {
        if( b % 2 != 0)
        {
            ans = mul(ans,a);
        }
        a = mul(a,a);
        b = b/2;
    }
    return ans;
}

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

int main(void)
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> jobs(m);
    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        if (a > m) continue;
        jobs[m - a].push_back(b);
    }
    priority_queue<int> q;
    ll ans = 0;
    for (int i = m - 1; i >= 0; --i) {
        for (int b : jobs[i]) {
            q.push(b);
        }

        if (!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
}




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

int main()
{
  int n, m;
  double border = 0;
  vector<int> a;
  
  cin >> n >> m;
  for(int i=0; i<n; i++)
  {
    int t;
    cin >> t;
    border += t;
    a.push_back(t);
  }
  
  border /= 4 * m;
  int cnt = 0;
  for(int i=0; i<n; i++)
  {
    if(a[i] >= border)
      cnt++;
    if(cnt >= m)
      break;
  }
  cout << (cnt >= m ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <limits.h>
using namespace std;
typedef long long ll;
int N, M, Q, ans = 0;
vector<pair<int, int>> query1, query2;

void dfs(int idx, vector<int>A)
{
	if (idx == N)
	{
		int sum = 0;
		//for (auto i : A)cout << i << " ";
		//cout << endl;
		for (int i = 0; i < Q; i++)
		{
			if (A[query1[i].second - 1] - A[query1[i].first - 1] == query2[i].first)
				sum += query2[i].second;
		}
		ans = max(ans, sum);
		return;
	}
	int start = (A.empty() ? 1 : A.back());
	for (int i = start; i <= M; i++)
	{
		A.push_back(i);
		dfs(idx + 1, A);
		A.pop_back();
	}
}


int main()
{
	cin >> N >> M >> Q;
	for (int i = 0; i < Q; i++)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		query1.push_back({ a,b });
		query2.push_back({ c,d });
	}
	dfs(0, vector<int>(0));
	cout << ans;
}

Measured memory_bytes: 3536
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
int a[200001];
void divisor(int n, int c[])
{
    for (int i = 1; i * i <= n; i++)
        if (n % i == 0)
        {
            c[i]++;
            if (i != n / i)
                c[n / i]++;
        }
    return;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    int c[n + 1];
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        c[i] = 0;
    }
    vector<int> ans;
    int count = 0;
    for (int i = n; i >= 1; i--)
    {
        if (a[i] != c[i] % 2)
        {
            count++;
            ans.push_back(i);
            divisor(i, c);
        }
    }
    sort(ALL(ans));
    cout << count << "\n";
    if (ans.size() != 0)
    {
        for (int i = 0; i < ans.size(); i++)
        {
            cout << ans[i] << " ";
        }
        cout << "\n";
    }
}

Measured memory_bytes: 3192
# AGC002C - Knot Puzzle
def main():
    N, L, *A = map(int, open(0).read().split())
    B = [i + j for i, j in zip(A, A[1:])]
    x = max(B)
    if x >= L:  # at least one pair must be equal or greater than L
        idx = B.index(x) + 1
        # keep the biggest one until the end
        ans = [i for i in range(1, idx)] + [i for i in range(N - 1, idx, -1)] + [idx]
        print("Possible")
        print("\n".join(map(str, ans)))
    else:
        print("Impossible")


if __name__ == "__main__":
    main()

Measured memory_bytes: 21836
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	bool ok = true;
	if (N % 2 == 1) { ok = false; }
	for (int i = 0; i + N / 2 < N; ++i) {
		if (s[i] != s[i + N / 2]) { ok = false; }
	}

	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


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

using namespace std;

int main() {

    int n;
    cin >> n;
    std::vector<int> v(n);

    for(int i = 0 ; i < n; i++)cin >> v[i];

    long long ans = 0LL;

    for(int i = 0; i < n; i++){
        for(int j = i + 1;j < n; j++){
            ans += (long long)v[i] * v[j];
        }
    }
    cout << ans << endl;

    return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;			
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> 	pii;
typedef vector<bool> vb;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#ifdef LOCAL
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

void solve(){
	int n; cin>>n;
	string s; cin>>s;
	int cntr = 0;
	for(auto &c: s) cntr += (c=='R');
	int pres = 0;
	for(int i = 0; i<cntr; i++) pres += (s[i]=='R');
	cout<<cntr-pres<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef LOCAL
		freopen(".inp.txt", "r", stdin);
    	freopen(".out.txt", "w", stdout);
    	freopen(".err.txt", "w", stderr);
	#endif
	int t=1;
	while(t--)
		solve();
}

Measured memory_bytes: 3760
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    string s;
    cin >> s;

    ll MAX = 0;
    ll count = 0;
    REP(i,s.length()){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
        count++;
        MAX = max(count,MAX);
        }
        else{
            count = 0;
        }
    }
    cout << MAX << endl;
    return 0;
}

Measured memory_bytes: 3640
// Your code here!
use std::io::*;
use std::str::FromStr;
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn string_list(input: String) -> Vec<char> {
    let mut normal = vec![];
    for c in input.chars().into_iter(){
        normal.push(c);
    }
    
    return normal
}


fn main () {
    let s:String = read();
    let mut s_list=string_list(s);
    let mut n : usize = s_list.len();
    
    let mut count:usize = 0;
    let mut ans:usize =0;
    
    for i in 0..n {
        if s_list[i]=='W' {
            ans+=i-count;
            count+=1;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int countt=0;

    char a[3],b[3],c[3];
    for(int i=0;i<3;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<3;i++)
    {
        cin>>b[i];
    }
    c[0]=b[2];
    c[1]=b[1];
    c[2]=b[0];

    for(int i=0;i<3;i++)
    {
        if(a[i]>='a' && a[i]<='z' && c[i]>='a' && c[i]<='z'){
        if(a[i]==c[i]) countt++;
        }
        else countt=-1;
    }
    if(countt==3) cout<<"YES\n";
    else if(countt>=0 && countt<3) cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import heapq

def minus(n):
    return -n

def solve(N: int, a: "List[int]"):
    ## N+iまでのリストの大きい順のNコのわ  
    left_sum = [0]*(N+1)
    heap = a[:N]
    left_sum[0] = sum(heap)
    heapq.heapify(heap)
    for i in range(N,2*N):
        heapq.heappush(heap,a[i])
        min_value = heapq.heappop(heap)
        left_sum[i-(N-1)]=left_sum[i-N]+a[i]-min_value

    b = list(map(minus,reversed(a)))
    right_sum= [0]*(N+1)
    r_heap = b[:N]
    right_sum[0] = -sum(r_heap)
    heapq.heapify(r_heap)
    for i in range(N,2*N):
        heapq.heappush(r_heap,b[i])
        min_value = heapq.heappop(r_heap)
        right_sum[i-(N-1)]=right_sum[i-N]+(-b[i])-(-min_value)
    
    answer = -10**15
    for j in range(N+1):
        answer = max(answer,left_sum[j]-right_sum[N-j])
    print(answer)
    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
    a = [int(next(tokens)) for _ in range(3 * N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61792
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 0

MOD = 10**9+7
for i, a in enumerate(A):
    bef = 0
    aft = 0
    for j, b in enumerate(A):
        if a > b:
            if i > j:
                aft += 1
            else:
                bef += 1
    ans += bef*(K*(K+1))//2
    ans += aft*(K*(K-1))//2
    ans %= MOD
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP){ 
    return firstP.second < secondP.second; 
}//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock

ll a,b,k;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>a>>b>>k;
    ll tmp = 0;
    ll ans = 0;
    for(int i = min(a,b);i>0;i--){
        if(a%i==0 && b%i==0)tmp++;
        if(tmp == k){ans = i;break;}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *x, int *y)
{
    int tmp;
    if (*x > *y)
    {
        tmp = *y;
        *y = *x;
        *x = tmp;
    }
}

int main()
{
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);
    swap(&a, &b);
    swap(&a, &c);
    swap(&b, &c);
    printf("%d %d %d\n", a, b, c);

    return 0;
}

Measured memory_bytes: 1816
let main = Scanf.sscanf (read_line()) "%d %d" (fun n l ->
    let rec inputdata n =
        if n = 0
        then []
        else read_line() :: inputdata (n - 1)
    in let rec sortdata lst = List.sort compare lst
    in let rec printdata lst =
        match lst with
        | [] -> ()
        | first :: lst -> (
            print_string first;
            printdata lst
        )
    in printdata (sortdata (inputdata n));
    print_string "\n"
)

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
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);
  for(ll i = 0; i < n; i++) cin >> a[i];

  ll ans = 0;
  vector<ll> mid(n);
  for(ll i = 0; i < n; i++){
    mid[i] = a[i] - (i+1);
  }
  sort(all(mid));

  ll b = 0;
  if(n % 2 == 0){
    b = (mid[n/2] + mid[n/2-1]) / 2;
  }else{
    b = mid[n/2];
  }
  //cout << b << endl;

  for(ll i = 0; i < n; i++){
    ans += abs(a[i] - i-1 - b);
  }

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

Measured memory_bytes: 3328
#include<iostream>

int digit(int a, int b){
  int digit=0;
  int c=a+b;
  
  if(c == 0){
    return 1;
  }
  else {
    while(c != 0){
      c /= 10;
      digit++;
    }
    return digit;
  }
}

int main(){
  int sum[200];
  int a, b; //2????????´??°
  int count=0; //????????????
    
  //std::cout << "Input two of numbers\n";
  
  while(std::cin >> a >> b){
    if(a == -1 && b== -1)
      break;
    
    sum[count]=digit(a,b);
    count++;
  }

  for(int i=0; i<count; i++){
    std::cout << sum[i] << '\n';
  }

  return 0;
}

Measured memory_bytes: 2992
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define pb push_back
typedef pair<ll,ll> pp;

ll mod = 1e9+7;
ll INF = 1e15;

ll powm(ll a , ll b , ll mod)
{
  ll res = 1;
  while(b)
  {
    if(b & 1)
    res = (res *a)%mod;
    a = (a*a)%mod;
    b>>1;
  }
  return res;
}
ll gcd(ll a , ll b);
ll power(ll x , ll y , ll m);

ll modInverse(ll a , ll m)
{
  ll g = gcd(a,m);
  if(g != 1)
  return 1;
  else
  return power(a,m-2,m);

}

ll power(ll x , ll y , ll m)
{
  if(y == 0)
  return 1;
  ll p = power(x , y/2 , m)%m;
  p = (p*p)%m;

  return (y%2 == 0) ? p : (x *p) % m;
}

ll gcd(ll a , ll b)
{
  if(a == 0)
  return b;
  return gcd(b%a , a);
}





void solve()
{
  ll x;
  cin>>x;
  for(ll i = -200;i<=200;i++)
  {
    for(ll j = -200;j<=200;j++)
    {
      if(i*i*i*i*i-j*j*j*j*j == x)
      {
        cout<<i<<" "<<j<<"\n";
        return;
      }
    }
  }


}



int main()
{
  int tc;
  // cin>>tc;
  tc = 1;
  while(tc--)
  {
    solve();
  }
}


Measured memory_bytes: 3492