akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
struct STR
{
  string s;
  int n;

  STR(string _s)
  {
    s = _s;
    n = s.size();
  }
  
  vector<int> Z_Algo()
  {
    vector<int> res(n);
    res[0] = n;
    int i = 1;
    int j = 0;
    while(i < n){
      while(i+j < n && s[j] == s[i+j]) ++j;
      res[i] = j;
      if(j == 0){
	++i;
	continue;
      }
      int k = 1;
      while(i+k < n && k+res[k] < j){
	res[i+k] = res[k];
	++k;
      }
      i += k;
      j -= k;
    }
    return res;    
  }

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

  int res = 0;
  string ss = "";
  rep(i,n){
    ss = s[n-1-i] + ss;
    STR st(ss);
    vector<int> vec = st.Z_Algo();
    rep(j,vec.size()){
      res = max(res,min(vec[j],j));
    }
  }

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


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

#define dump(x) cout << x << endl
#define rep(i, n) for(int i = 0; i < n; ++i)

int main() {
  int n;  
  cin >> n;
  string s;
  cin >> s;
  
  vector<int> w(n), e(n);
  
  rep(i, n) {
    if (s[i] == 'W') {
      w[i]++;
    }
    else {
      e[i]++;
    }
  }
  rep(i, n-1) {
    w[i+1] += w[i];
  }
  rep(i, n-1) {
    e[n-2-i] += e[n-1-i];
  }
  int ret = n;
  int x;
  rep(i, n) {
    if (i == 0) {
      x = e[i+1];
    }
    else if (i == n-1) {
      x = w[i-1];
    }
    else {
      x = w[i-1]+e[i+1];
    }
    if (ret > x) {
      ret = x;
    }
  }
  dump(ret);
  
  return 0;
}


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


void solve(long long X, long long Y, long long A, long long B, long long C, std::vector<long long> p, std::vector<long long> q, std::vector<long long> r){
    sort(p.rbegin(),p.rend());
    sort(q.rbegin(),q.rend());
    sort(r.rbegin(),r.rend());
    // AB合計配列(それぞれX,Yまで)
    vector<ll> XY(X+Y);
    long long ans =0;
    for(ll i=0;i<X;i++){
        XY[i] = p[i];
        ans += p[i];
    }
    for(ll i=0;i<Y;i++){
        XY[X+i] = q[i];
        ans += q[i];
    }
    sort(XY.rbegin(),XY.rend());
    for(ll i=0;i<C;i++){
        if(X+Y-1-i <0){
            break;
        }
        if(r[i] > XY[X+Y -1-i]){
            ans = ans -XY[X+Y-1-i] + r[i];
        }else{
            break;
        }
    }
    cout << ans << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> p(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&p[i]);
    }
    std::vector<long long> q(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&q[i]);
    }
    std::vector<long long> r(C);
    for(int i = 0 ; i < C ; i++){
        scanf("%lld",&r[i]);
    }
    solve(X, Y, A, B, C, std::move(p), std::move(q), std::move(r));
    return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

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

	for (int i = 0; i < s.length(); ++i) {
		if (s[i] + n > 'Z')
			s[i] = 'A' + n - ('Z' - s[i]) - 1;
		else
			s[i] += n;
	}

	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    A = [int(x) for x in stdin.readline().rstrip().split()]
    r = 1
    sum_ = A[0]
    count = 0
    for l in range(N):
        while r != N and (sum_ & A[r]) == 0:
            r += 1
            sum_ += A[r - 1]
        count += r - l
        sum_ -= A[l]
    print(count)


if __name__ == '__main__':
    main()


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

int main()
{
    // 整数の入力
    int N;
    int C = 0;
    cin >> N;
    // 配列の入力
    int a[N];
    for ( int i = 0; i < N; i++ ) cin >> a[i];
    for (int i = 0;i < N;i++){
        if(a[i] == a[i+1]){
            if(a[i+1] == a[i+2])i++;
            C++;
        }
    }
    // 出力
    cout << C << endl;
}


Measured memory_bytes: 256
// Palindromic Number
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;


int main()
{
  int N, K, x, sum;
  cin >> N >> K;
  vector<int> l;

  for (int i = 0; i < N; i++) {
    cin >> x;
    l.push_back(x);
  }
  sort(l.begin(), l.end(), greater<int>());

  for (int i = 0; i < K; i++) {
    sum+=l[i];
  }

  cout << sum << endl;
  return 0;
}


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

using namespace std;

int abs(int a){
  if (a>0){
    return a;
  }else{
    return a * (-1);
  }
}

int min(int a,int b){
  if (a<b){
    return a;
  }else{
    return b;
  }

}

int max(int a,int b){
  if (a>b){
    return a;
  }else{
    return b;
  }
}

int main(){
  int a,b,x;
  cin >> a >> b >> x;
  if (a + b >= x&& a <= x){
    cout << "YES" <<endl;
  }else{
    cout << "NO" <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int goal[N + 1];
  int ball[N + 1];
  stack<int> balls; 
  memset(ball,0,sizeof(ball)); 
  for (int i = 1; i < N + 1; i++){
    cin >> goal[i]; 
  }
  
  for (int i = (N); i >= 1; i--){
    int total = 0; 
    for (int j = 2; j * i < N + 1; j++){
      total += ball[i*j]; 
    }
    ball[i] = (total + goal[i])%2; 
    if(ball[i]){
      balls.push(i); 
    }
  }
  if (balls.size() > 0){
    cout << balls.size() << endl;  
    while (balls.size() > 0){
      cout << balls.top() << " "; 
      balls.pop(); 
    }
    
  } else {
    cout << "0"; 
  }
}


Measured memory_bytes: 3072
n = int(input())
ss = []
for i in range(n):
    x, l = map(int, input().split())
    start = max(0, x-l)
    stop = min(10**9, x + l)
    ss.append([start, stop])

sorted_ss = sorted(ss, key=lambda x: x[1])
ans = 0
t = 0

for i in range(n):
    if t <= sorted_ss[i][0]:
        ans += 1
        t = sorted_ss[i][1]
print(ans)


Measured memory_bytes: 22088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

// 

public class Procon2019_C // ←Class名変更！！
{
    ////private static Dictionary<int, int[]> list = new Dictionary<int, int[]>();
    ////private static Dictionary<int, int> aDic = new Dictionary<int, int>();
    ////private static Dictionary<int, int> bDic = new Dictionary<int, int>();
    //private static int aPos = 0;
    //private static int bPos = 0;

    public static void Main()
    {
        var list = new Dictionary<int, int[]>();
        var aDic = new Dictionary<int, int>();
        //var bDic = new Dictionary<int, int>();

        var n = Ri();

        for (int i = 0; i < n; i++)
        {
            var ab = Ria();
            list.Add(i, ab);
            aDic.Add(i, ab[1] + ab[0]);
            //bDic.Add(i, ab[0] - ab[1]);
        }

        var bDic = aDic.OrderByDescending((x) => x.Value);

        var aTotal = 0L;
        var bTotal = 0L;
        var turnA = true;
        foreach (var item in bDic)
        {
            var ab = list[item.Key];
            if (turnA)
            {
                aTotal += ab[0];
                turnA = false;
            }
            else
            {
                bTotal += ab[1];
                turnA = true;
            }

        }

        WriteLine($"{aTotal - bTotal}");

    } // Main

    public static string Rs() { return ReadLine(); }
    public static char Rc() { var c = ReadLine(); return c[0]; }    //最初の1文字だけ返す
    public static int Ri() { return int.Parse(ReadLine()); }
    public static long Rl() { return long.Parse(ReadLine()); }
    public static char[] Rca() { return ReadLine().ToCharArray(); }
    public static int[] Ria() { return Array.ConvertAll(ReadLine().Split(' '), int.Parse); }
    public static long[] Rla() { return Array.ConvertAll(ReadLine().Split(' '), long.Parse); }
} // Class


Measured memory_bytes: 35528
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), y = sc.nextInt();
        int b10th = 0, b5th = 0, b1th = y / 1000;
        int redundant = b1th - n;

        for (int i = 0; i <= n; i++) {
            if (redundant < 4) {
                break;
            } else if (redundant % 9 == 0 && 10 * (redundant / 9) <= b1th) {
                b10th = redundant / 9;
                b1th -= 10 * b10th;
                break;
            } else {
                redundant -= 4;
                b5th += 1;
                b1th -= 5;
            }
        }

        if (b10th + b5th + b1th != n) {
            b10th = -1; b5th = -1; b1th = -1;
        }

        System.out.println(b10th + " " + b5th + " " + b1th);
    }
}


Measured memory_bytes: 23124
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var t string
	fmt.Scan(&t)

	wr := bufio.NewWriter(os.Stdout)
	for _, r := range t {
		if r == '?' {
			wr.WriteString("D")
		} else {
			wr.WriteString(string(r))
		}
	}
	wr.WriteString("\n")
	wr.Flush()
}


Measured memory_bytes: 3028
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

int main(){
  ll N;
  cin>>N;
  ll tmp=N;
  ll S=0;
  for(ll i=11;0<=i;i--){
    S+=(int)(tmp/pow(10,i));
//    cout<<tmp<<"/"<<pow(10,i)<<"="<<(int)(tmp/pow(10,i))<<endl;
    tmp-=pow(10,i)*(int)(tmp/pow(10,i));
  }
//  cout<<S<<endl;
  if(N%S==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
ans = 0
res = 0
flag = 0
for i in range(len(A)):
    if A[i]<0:
        res += 1
        A[i] *= -1
    elif A[i] == 0:
        flag = 1
if res%2 == 1 and flag != 1:
    print(sum(A) - min(A)*2)
else:
    print(sum(A))

Measured memory_bytes: 14332
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
//#include <unordered_set>

using namespace std;

#define int long long

//sqrtN -> 最大値のみに対応できればいいので，それを使う
const int sqrtN = 512;
struct SqrtDecomposition {
  int N, K;
  vector<int> data;
  vector<int> bucketData;
  vector<int> bucketSum;
  const int INIT_VALUE = 0;
  
  SqrtDecomposition(int n) : N(n) {
    //分割数
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, INIT_VALUE);
    bucketData.assign(K, INIT_VALUE);
    bucketSum.assign(K, INIT_VALUE);
  }
  //ここまで共通
  
  void add(int s, int t, int x) {
    for(int k = 0; k < K; ++k) {
      //各バケツをループ
      int l = k * sqrtN;
      int r = (k + 1) * sqrtN;
      if(s >= r || t <= l) continue;
      if(l >= s && t >= r) {
        //完全に区間内
        bucketData[k] += x;
      } else {
        //バケツを分配
        // if(bucketData[k] != 0) {
        //   for(int i = l; i < r; ++i) {
        //     data[i] += bucketData[k];
        //   }
        //   bucketData[k] = 0;
        // }
        
        for(int i = max(s, l); i < min(t, r); ++i) {
          data[i] += x;
          bucketSum[k] += x;
        }
      }
    }
  }
  
  int getSum(int s, int t) {
    int sum = 0;
    for(int k = 0; k < K; ++k) {
      int l = k * sqrtN;
      int r = (k + 1) * sqrtN;
      if(r <= s || l >= t) continue;
      if(r <= t && l >= s) {
        sum += bucketData[k] * sqrtN + bucketSum[k];
      } else {
        for(int i = max(s, l); i < min(t, r); ++i) {
          sum += data[i] + bucketData[k];
        }
      }
    }
    return sum;
  }
};

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int n, q;
  cin >> n >> q;
  
  SqrtDecomposition sq(n);
  
  for(int i = 0; i < q; i++) {
    int qtype;
    cin >> qtype;
    if(qtype == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      --s;
      sq.add(s, t, x);
    } else {
      int s, t;
      cin >> s >> t;
      --s;
      cout << sq.getSum(s, t) << endl;
    }
  }  

}


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

const int END = -1;
struct StNod
{
  int m_nDept;
  int m_nHigh;
  int m_nParnt;
  int m_nLeft;
  int m_nRigt;

  StNod() :
    m_nDept(END), m_nHigh(END), m_nParnt(END), m_nLeft(END), m_nRigt(END)
  { }
};

void fnInput(vector<StNod> &rvoNod)
{
  StNod oNod;
  int nMaxSiz;

  cin >> nMaxSiz;
  rvoNod.resize(nMaxSiz, oNod);

  for (int i = 0; i < nMaxSiz; i++)
  {
    int nParnt, nLeft, nRigt;
    cin >> nParnt >> nLeft >> nRigt;

    rvoNod[nParnt].m_nLeft = nLeft;
    rvoNod[nParnt].m_nRigt = nRigt;
    if (nLeft != END)  rvoNod[nLeft].m_nParnt = nParnt;
    if (nRigt != END)  rvoNod[nRigt].m_nParnt = nParnt;
  }
}

void fnSetDepth(vector<StNod> &rvoNod, int nx, int nDept)
{
  rvoNod[nx].m_nDept = nDept;
  
  if (rvoNod[nx].m_nLeft != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nLeft, nDept + 1);

  if (rvoNod[nx].m_nRigt != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nRigt, nDept + 1);
}

int fnSetHight(vector<StNod> &rvoNod, int nx)
{
  int nLHigh =0, nRHigh = 0;

  if (rvoNod[nx].m_nLeft != END)
    nLHigh = fnSetHight(rvoNod, rvoNod[nx].m_nLeft) + 1;
  if (rvoNod[nx].m_nRigt != END)
    nRHigh = fnSetHight(rvoNod, rvoNod[nx].m_nRigt) + 1;
  
  return rvoNod[nx].m_nHigh = max(nLHigh, nRHigh);
}

void fnBinTree(vector<StNod> &rvoNod)
{
  int nx = 0;
  while (rvoNod[nx].m_nParnt != END)
    nx = rvoNod[nx].m_nParnt;

  int nDept = 0;
  fnSetDepth(rvoNod, nx, nDept);
  fnSetHight(rvoNod, nx);
}

void fnResult(const vector<StNod> &cnrvoNod)
{
  for (int i = 0; i < cnrvoNod.size(); i++)
  {
    cout << "node " << i << ": parent = " << cnrvoNod[i].m_nParnt << ", sibling = ";

    if (cnrvoNod[i].m_nParnt == END)  cout << END;
    else
    {
      int nx = cnrvoNod[i].m_nParnt;
      if (i == cnrvoNod[nx].m_nLeft)  cout << cnrvoNod[nx].m_nRigt;
      else                            cout << cnrvoNod[nx].m_nLeft;
    }
    
    cout << ", degree = ";
    int nCCnt = 0;
    if (cnrvoNod[i].m_nLeft != END)  nCCnt++;
    if (cnrvoNod[i].m_nRigt != END)  nCCnt++;
    cout << nCCnt << ", depth = " << cnrvoNod[i].m_nDept << ", height = " << cnrvoNod[i].m_nHigh;

    if (!cnrvoNod[i].m_nDept)       cout << ", root";
    else if (!cnrvoNod[i].m_nHigh)  cout << ", leaf";
    else                            cout << ", internal node";
    cout << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<StNod> voNod;

  fnInput(voNod);
  fnBinTree(voNod);
  fnResult(voNod);
  return 0;
}

Measured memory_bytes: 1200
from collections import deque
d = {
        'b': 'd',
        'd': 'b',
        'p': 'q',
        'q': 'p'
        }
s = deque(input())
if len(s) % 2:
    print("No")
    quit(0)
while len(s) > 1:
    l = s.popleft()
    r = s.pop()
    if r != d[l]:
        print("No")
        quit(0)
print("Yes")



Measured memory_bytes: 4204
#解説解答
n = int(input())
s = input()
r = 0
g = 0
b = 0
use = [0 for _ in range(n)]
xyz = []
for i in range(3*n):
  if s[i] == 'R':
    xyz.append(use[r])
    use[r] += 1
    r += 1
  elif s[i] == 'G':
    xyz.append(use[g])
    use[g] += 1
    g += 1
  else:
    xyz.append(use[b])
    use[b] += 1
    b += 1
ans = 1
mod = 998244353
x = 0
for i in range(3*n):
  if xyz[i] == 0:
    x += 1
  elif xyz[i] == 1:
    ans *= x
    ans %= mod
    x -= 1
z = 0
for i in range(3*n):
  if xyz[-1-i] == 2:
    z += 1
  elif xyz[-1-i] == 1:
    ans *= z
    ans %= mod
    z -= 1
for i in range(1,n+1):
  ans *= i
  ans %= mod
print(ans)

Measured memory_bytes: 6820
#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a;
    cin >> b;
    if (a-b>0)
    {
        cout << "a > b" << endl;
    }
    else if (a-b<0)
    {
        cout << "a < b" << endl;
    }
    else
    {
        cout << "a == b" << endl;
    }
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD = 998244353;
// const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()   
#define trav(a, x) for(auto& a : x)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
vector<vector<int>> ans,vis;
int A,B,C,D;
bool found=false;
int solve(int x, int y)
{
    // error(x,y);
    if(x<A or y<B)
        return 0;
    if(ans[x][y]!=-1)
        return ans[x][y];
    ans[x][y]=(y)*1ll*(solve(x-1,y))%MOD;
    ans[x][y]=(ans[x][y]%MOD+((x)*1ll*solve(x,y-1))%MOD)%MOD;
    ans[x][y]=(ans[x][y]%MOD-(solve(x-1,y-1))*1ll*(x-1)*(y-1)%MOD)%MOD;
    ans[x][y]=(ans[x][y]+MOD)%MOD;
    return ans[x][y];
}
int main()
{
    sws
    cin>>A>>B>>C>>D;
    ans.assign(3002,vector<int> (3002,-1));
    vis.assign(3002,vector<int> (3002,0));
    ans[A][B]=1;
    cout<<solve(C,D)<<endl;
    // for(int i=A;i<=C;i++)
    // {
    //     for(int j=B;j<=D;j++)
    //         cout<<ans[i][j]<<" ";
    //     cout<<endl;
    // }
    return 0;
}


Measured memory_bytes: 74216
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
    int n, q, t;
    string name;
    queue<pair<string,int> > Q;
    cin >> n >> q;
    for (int i=0; i<n; i++) {
        cin >> name >> t;
        Q.push(make_pair(name,t));
    }
    pair<string,int> u;
    int elaps=0;
    int a;
    while (!Q.empty()) {
        u=Q.front(); Q.pop();
        a=min(u.second,q);
        u.second-=a;
        elaps+=a;
        if (u.second>0) {
            Q.push(u);
        } else {
            cout << u.first << " " << elaps << endl;
        }
    }
    return 0;
}

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

int main(){
	int n,x,c=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(i!=x) c++;
	}
	if(c==0 || c==2) cout<<"YES\n";
	else cout<<"NO\n";
}

Measured memory_bytes: 256
ans = 0
temp = -1
for i in range(5):
    cur = int(input())
    if cur%10==0:
        ans += cur
    else:
        ans += cur+10-cur%10
        if temp<10-cur%10:
            temp = 10-cur%10

if temp!=-1:
    ans -= temp

print(ans)


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << c  << " " << a << " " << b << endl;
    return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    vector<string> S(3);
    for (ll i = 0; i < 3; i++) {
        cin >> S[i];
    }

    for (ll i = 0; i < 3; i++) {
        cout << S[i][i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
from sys import exit

n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]

for cx in range(101):
    for cy in range(101):
        correct_flag = True
        for i in range(n):
            x, y, h = l[i]
            if h > 0:
                res_h = abs(x - cx) + abs(y - cy) + h
                break
        for i in range(n):
            x, y, h = l[i]
            if max(res_h - abs(x - cx) - abs(y - cy), 0) != h:
                correct_flag = False
                break
        if correct_flag:
            print(cx, cy, res_h)
            exit()

Measured memory_bytes: 73956
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct aa
{
    char* str;
    int num;
} ass;

int str_cmp(const void* a,const void* b){
    return strcmp((char*)a,(char*)b);
}

int main(void)
{
    int n=0,disit=0,max=0;
    char S[200000][11]={};
    ass map[200000]={0,0};
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",S[i]);
    }
    qsort(S,n,sizeof(S[0]),str_cmp);

    map[0].str=S[0];
    for(int i=0;i<n;i++){
        if(strcmp(map[disit].str,S[i])==0){
            map[disit].num+=1;
        } else {
            disit+=1;
            map[disit].str=S[i];
            map[disit].num+=1;
        }
    }

    max=map[0].num;
    for(int i=0;i<=disit;i++){
        if(max<map[i].num){
            max=map[i].num;
        }
    }

    for(int i=0;i<=disit;i++){
        if(map[i].num==max){
            printf("%s\n",map[i].str);
        }
    }
    return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<pair<int64_t, int64_t>> a(n);
    for (auto i : irange(0L, n)) {
        cin >> a[i].first;
        a[i].second = i;
    }

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

    int64_t ans = 0;
    for (auto i : irange(0L, n)) {
        if (i % 2 != a[i].second % 2) {
            ++ans;
        }
    }

    cout << ans / 2 << endl;
}

Measured memory_bytes: 1792
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A=sorted(A)
B=sorted(B)
C=sorted(C)
A2=[0]*N
s=0
i=0
n=A[s]
while True:
  if B[i]>n:
    A2[i]+=1
    s+=1
    if s==N:
      break
    n=A[s]
  else:
    i+=1
  if i==N:
    break
for i in range(1,N):
  A2[i]=A2[i-1]+A2[i]
B2=[0]*N
s=0
i=0
n=B[s]
while True:
  if C[i]>n:
    B2[i]+=A2[s]
    s+=1
    if s==N:
      break
    n=B[s]
  else:
    i+=1
  if i==N:
    break
for i in range(1,N):
  B2[i]=B2[i-1]+B2[i]
print(sum(B2))

Measured memory_bytes: 31140
#include<bits/stdc++.h>
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define N 100005

using namespace std;

int a[4];

int main()
{
    __

    int n,m,flag=0;
    memset(a,-1,sizeof(a));

    cin >> n >> m;

    for(int s,c,i=0;i<m;i++){
        cin >> s >> c;
        if(a[s]!=-1 && a[s]!=c) flag=1;
        else if(a[s]==-1) a[s]=c;
    }

    if(a[1]==0 && n>1) flag=1;

    if(!flag){
        if((a[2]==0 && a[1]==0) || (a[1]==-1 && n>1)) a[1]=1;
    for(int i=1;i<=n;i++){
        if(a[i]==-1) cout << 0;
        else cout << a[i] ;
    }
    }
    else cout << -1;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int TT,TA,AT,AA;
  scanf("%d%d%d%d",&TT,&TA,&AT,&AA);
  while (!(TT<=0||AT<=0)){
    AT-=TA;
    if(AT<=0){
      printf("Yes");
      break;
    }
    TT-=AA;
    if(TT<=0){
      printf("No");
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 1736
n = int(input())
ab=sorted([list(map(int,input().split())) for i in range(n)],key = lambda x:x[1])
s=[0]
for i in range(n):
    s.append(s[i]+ab[i][0])
if all(s[i+1] <= ab[i][1] for i in range(n)):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 58248
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
string s1,s2;
ll dp[53][4][4];

int main(void){
	scanf("%d",&n);
	cin >> s1;
	cin >> s2;
	dp[0][0][0]=1;
	ll res=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				if(dp[i][j][k]==0)continue;
				if(i==0){
					if(s1[i]==s2[i]){
						for(int j=1;j<=3;j++){
							dp[i+1][j][j]+=dp[i][0][0];
						}
					}else{
						for(int nj=1;nj<=3;nj++){
							for(int nk=1;nk<=3;nk++){
								if(nj==nk)continue;
								dp[i+1][nj][nk]+=dp[i][0][0];
							}
						}
					}
				}else{
					if(s1[i]==s1[i-1] && s2[i]==s2[i-1]){
						dp[i+1][j][k]+=dp[i][j][k];
						if(dp[i+1][j][k]>=MOD)dp[i+1][j][k]%=MOD;
					}else if(s1[i]==s1[i-1]){
						for(int nk=1;nk<=3;nk++){
							if(nk==k || nk==j)continue;
							dp[i+1][j][nk]+=dp[i][j][k];
							if(dp[i+1][j][nk]>=MOD)dp[i+1][j][nk]%=MOD;
						}
					}else if(s2[i]==s2[i-1]){
						for(int nj=1;nj<=3;nj++){
							if(nj==j || nj==k)continue;
							dp[i+1][nj][k]+=dp[i][j][k];
							if(dp[i+1][nj][k]>=MOD)dp[i+1][nj][k]%=MOD;
						}
					}else{
						for(int nj=1;nj<=3;nj++){
							for(int nk=1;nk<=3;nk++){
								if(nj==j || nk==k)continue;
								if(s1[i]!=s2[i] && nj==nk)continue;
								if(s1[i]==s2[i] && nj!=nk)continue;
								dp[i+1][nj][nk]+=dp[i][j][k];
								if(dp[i+1][nj][nk]>=MOD)dp[i+1][nj][nk]%=MOD;
							}
						}
					}
				}
			}
		}
	}
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			res=(res+dp[n][i][j])%MOD;
		}
	}
	printf("%lld\n",res);
	return 0;
}

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


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

    int A,B,C;
    long long K;
    cin >> A >> B >> C>> K;

    if(K%2==0) cout <<A-B << endl;
    else cout << B-A << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define ALL(x) (x).begin(),(x).end()
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

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

    vector<int> v(n);
    REP(i, n) { cin >> v[i]; }

    vector<int> cnt1(100001), cnt2(100001);
    for (int i=0; i<n; i+=2) {
        cnt1[v[i]]++;
        cnt2[v[i+1]]++;
    }

    int ans;
    auto max1 = max_element(ALL(cnt1));
    auto max2 = max_element(ALL(cnt2));
    int idx1 = max1 - cnt1.begin();
    int idx2 = max2 - cnt2.begin();

    if (idx1 == idx2) {
        int ans1, ans2;
        int max1p = *max1, max2p = *max2;

        *max2 = 0;
        auto max2_ = max_element(ALL(cnt2));
        ans1 = (n/2 - *max1) + (n/2 - *max2_);
        *max2 = max2p;

        *max1 = 0;
        auto max1_ = max_element(ALL(cnt1));
        ans2 = (n/2 - *max1_) + (n/2 - *max2);
        ans = min(ans1, ans2);
    }
    else {
        ans = (n/2 - *max1) + (n/2 - *max2);
    }
    cout << ans << LF;

    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 1 << 21;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(void) {
	int N,k;
	int ans = 1000000000;
	std::cin >> N>>k;
	std::vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> a[i];
	}
	int dist1 = 0, dist2 = 0;
	int temp;
	for (int i = 0; i < N-k+1; ++i) {
		dist1 = std::abs(a[i]) + a[i+k-1] - a[i];
		dist2 = std::abs(a[i + k - 1]) + a[i+k-1] - a[i];
		temp = std::min(dist1, dist2);
		ans = std::min(ans, temp);
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 640
def main(n,y):
    for i in range(n+1):
        for j in range(n+1):
            k = n-i-j
            if k < 0 : continue
            if ((10000*i) + (5000*j) + (1000*k)) == y:
                return "{0} {1} {2}".format(i,j,k)
    return "-1 -1 -1"

n,y = map(int, input().split())
print(main(n,y))

Measured memory_bytes: 3060
import sys

input = sys.stdin.readline

class Dict:
    def __init__(self):
        self.table = [None] * 1046527
        self.table_size = 1046527
    
    def insert(self, key):
        colisions = 0
        while True:
            hash_num = self._calc_hash(self._to_num(key), colisions)
            cand = self.table[hash_num]
            if cand is None:
                self.table[hash_num] = key
                return 0
            elif cand == key:
                return 1
            colisions += 1
    
    def has(self, key):
        colisions = 0
        while True:
            hash_num = self._calc_hash(self._to_num(key), colisions)
            cand = self.table[hash_num]
            if cand == key:
                return True
            elif cand is None or colisions >= self.table_size:
                return False
            else:
                colisions += 1
        return 
    
    def _calc_hash(self, key, colisions):
        hash_1 = key % self.table_size
        hash_2 = 1 + (key % (self.table_size - 1))
        return (hash_1 + colisions * hash_2) % self.table_size
    
    def _to_num(self, str_key):
        sum = 0
        p = 1
        for char in str_key:
            if char == 'A':
                sum += 1 * p
            elif char == 'C':
                sum += 2 * p
            elif char == 'G':
                sum += 3 * p
            elif char == 'T':
                sum += 4 * p
            p *= 5
        return sum

def main_():
    N = int(input())
    commands = [(cmd[0], cmd[1]) for cmd in [input().split() for _ in range(N)]]
    hash_map = Dict()
    for cmd in commands:
        if cmd[0] == 'insert':
            hash_map.insert(cmd[1])
        else:
            ans = 'yes' if hash_map.has(cmd[1]) else 'no'
            print(ans)
            

if __name__ == "__main__":
    main_()



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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    int n, y;
    cin >> n >> y;
    y /= 1000;
    for (int i = 0; i <= n; ++i)
    for (int j = 0; j + i <= n; ++j)
    if (10 * i + 5 * j <= y && y - 10 * i - 5 * j + i + j == n) {
        cout << i << ' ' << j << ' ' << y - 10 * i - 5 * j << endl;
        return 0;
    }
    cout << "-1 -1 -1\n";
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s;
    cin>>s;
    if(s.length()==6 && s[2]==s[3] && s[4]==s[5])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int a,b,k;
    while (~scanf("%d %d %d",&a,&b,&k)) {
        int ans = 0;
        int cnt=0;
        for (int i=min(a,b); i>=1; i--) {
            if (a%i==0 && b%i==0) {
                cnt++;
                if (cnt==k) {
                    ans = i;
                    break;
                }
            }
        }
        printf("%d\n", ans);
    }
    
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char S[12];
int N;
char res[12];
int ress;
int main(){
  int i;
  N = rd(S);
  for(i=0;i<(N);i++){
    if(S[i]=='B'){
      ress =max_L(0, ress-1);
    }
    else{
      res[ress++] = S[i];
    }
  }
  res[ress] = '\0';
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// char S[12]; int N;
// char res[12]; int ress;
// {
//   rd(S@N);
//   rep(i,N){
//     if(S[i]=='B') ress = max(0, ress-1);
//     else          res[ress++] = S[i];
//   }
//   res[ress] = '\0';
//   wt(res);
// }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <queue>

using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; const int INF=1e9; const ll LINF=1e18;
const ld PI = 3.14159265358979;

int main(){
  int n,m; cin>>n>>m;
  vector<int> v[n];
  for(int i=0;i<m;i++) {
    int a,b; cin>>a>>b; a--; b--;
    v[a].push_back(b); v[b].push_back(a);
  }
  int an[n]; fill(an,an+n,-1);
  queue<int> que; que.push(0);
  while(!que.empty()) {
    int from = que.front(); que.pop();
    for(int to:v[from]) {
      if (an[to] == -1) {
        an[to] = from;
        que.push(to);
      }
    }
  }
  cout<<"Yes"<<endl;
  for(int i=1;i<n;i++) {
    cout<<an[i]+1<<endl;
  }
}

Measured memory_bytes: 10328
def main():
    n = int(input())
    abc = [list(map(int, input().split())) for _ in range(n)]
    a, b, c = zip(*abc)
    srs_a = {-1: 0}
    srs_b = {-1: 0}
    srs_c = {-1: 0}
    def dp_a(i):
        return max(srs_b[i-1], srs_c[i-1]) + a[i]
    def dp_b(i):
        return max(srs_c[i-1], srs_a[i-1]) + b[i]
    def dp_c(i):
        return max(srs_a[i-1], srs_b[i-1]) + c[i]
    for i in range(n):
        srs_a[i] = dp_a(i)
        srs_b[i] = dp_b(i)
        srs_c[i] = dp_c(i)
    print(max(srs_a[n-1], srs_b[n-1], srs_c[n-1]))


main()


Measured memory_bytes: 65628
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>
using namespace std;

int main(){
	long long h,w,a;
	cin >> h >> w;
	if(h == 1 || w == 1){
		a = 1;
	}else if(h%2 == 1 && w%2 == 1){
		a = (h*w+1)/2;
	}else{
		a = h*w/2;
	}
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
D=dict()
p=2
M=N
while(p*p<=N):
    if M%p==0:
        if p in D:
            D[p]+=1
        else:
            D[p]=1
        M=M//p
    else:
        p+=1
if M>1:
    D[M]=1
#print(D)
def block(K):
    t=1
    tmp=K
    res=0
    while(1):
        if tmp>=t:
            tmp-=t
            t+=1
            res+=1
        else:
            tmp=0
            break
    return res
ans=0
for p in D:
    ans+=block(D[p])
print(ans)


Measured memory_bytes: 9212
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

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

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}

int main(){
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> sum(n+1), plus(n+1);
    rep(i,n){
        sum[i+1] = sum[i] + a[i];
        plus[i+1] = plus[i] + max(0LL, a[i]);
    }
    // print(sum);
    // print(plus);

    ll ans = 0;
    for(int i = 0; i + k <= n; i++){
        chmax(ans, sum[i+k] - sum[i] + plus[i] - plus[0] + plus[n] - plus[i+k]);
        chmax(ans, plus[i] - plus[0] + plus[n] - plus[i+k]);
        // debug(sum[i+k] - sum[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var k = sc.nextInt();
		var s = sc.next();
		sc.close();

		var result = s.length() <= k ? s : s.substring(0, k) + "...";
		System.out.println(result);
	}
}

Measured memory_bytes: 38636
#include <stdio.h>

#define N 100

int main()
{
	int m[N][N];
	int n,u,k,v;
	scanf("%d",&n);
	
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++) m[i][j] = 0;
	}
	
	for(int i = 0; i < n; i++)
	{
		scanf("%d %d",&u,&k);
		u--;
		for(int j = 0; j < k; j++)
		{
			scanf("%d",&v);
			v--;
			m[u][v] = 1;
		}
	}
	
	for(int i = 0; i < n; i++)
	{
		for( int j = 0; j < n; j++)
		{
			if(j) printf(" ");
			printf("%d",m[i][j]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2052
v = [0 for i in range(26)]

try:
	while True:
		for c in list(input()):
			if 'a' <= c and c <= 'z':
				v[ord(c)-ord('a')] += 1
			elif 'A' <= c and c <= 'Z':
				v[ord(c)-ord('A')] += 1
except EOFError:
	pass

for i in range(26):
	print(f"{chr(i+ord('a'))} : {v[i]}")



Measured memory_bytes: 5576
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    ll N,M;
    cin >> N >> M;
    if(N==1 && M==1){
        cout << 1 << endl;
    }else if(N==1){
        cout << M-2 << endl;
    }else if(M==1){
        cout << N-2 << endl;
    }else{
        ll ans=(N-2)*(M-2);
        cout << ans << endl;
    }



    return 0;
}

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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;


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

    vector<int>a(n+2);
    rep2(i,1,n)cin>>a[i];

    vector<int>l(n+2),r(n+2);
    l[1]=a[1];
    rep(i,n-1){
        l[i+2]=max(l[i+1],a[i+2]);
    }

    r[n]=a[n];
    repr(i,n-1,0){
        r[i]=max(r[i+1],a[i]);
    }

    rep(i,n){
        cout<<max(l[i],r[i+2])<<endl;
    }

}


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

int main()
{
  int n,k,q,t;
  cin>>n>>k>>q;
  int a[n+1]={0};
  for(int i=0; i<q; i++)
  {
    cin>>t;
    a[t]++;
  }
  for(int i = 1; i<=n; i++)
  	(k-(q-a[i]) > 0)?cout<<"Yes"<<endl:cout<<"No"<<endl;
  
  
  
  return 0;
}

Measured memory_bytes: 1024
n = int(input())
w = list(map(int, input().split()))
s = [0]
for i in range(n):
  s.append(w[i]+s[i])
ans = sum(w)
for i in range(n):
  t = s[n] - s[i]
  if(abs(s[i] - t) < ans):
    ans = abs(s[i] - t)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int as[100010];

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    ios::sync_with_stdio(false);

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

    int best_i = 0;
    int best_res = min(as[0], as[n - 1] - as[0]);
    for(int i = 1; i < n - 1; ++i) {
        int lo = min(as[i], as[n - 1] - as[i]);
        if(lo > best_res) {
            best_res = lo;
            best_i = i;
        }
    }

    cout << as[n - 1] << " " << as[best_i] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int x,a,b;
  cin >> x >> a >> b;
  if(abs(x-a)<abs(x-b)){
    cout << "A" << endl;
  }else{
    cout << "B" << endl;
  }
}


Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
satisfaction=0
previous=-1
for i in range(n):
    if ((A[i]-previous)==1):
        satisfaction = satisfaction+B[A[i]-1]+C[A[i-1]-1]
    else:
        satisfaction=satisfaction+B[A[i]-1]
    previous=A[i]
print(satisfaction)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())


ll qmult(ll X, ll Y, ll M) {    
    return (X * Y) % M;
}

ll qexp(ll A, ll B, ll M) {
    if (B == 0) return 1;
    ll half = qexp(A, B/2, M);
    half = qmult(half, half, M);
    half %= M;
    if (B%2==1) half *= A%M;
    return half%M;
}

int A[MAXN], B[MAXN];
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N,K;cin>>N>>K;
	FOR(i,1,K) A[i]=qexp(K/i,N,MOD);
	int ans = 0;
	DEC(i,K,1){
		B[i]=A[i];
		for(int j=2*i; j<=K; j+=i){
			B[i]=(B[i]-B[j]+MOD)%MOD;
		}
		ans += (B[i]*i)%MOD;
		ans %= MOD;
	}
	cout << ans;
}


Measured memory_bytes: 5236
#include <cstdio>
using namespace std;
const int N=3010;
int n;
int MOD;
int fact[N],iact[N];
int s[N][N];
int fastPow(int x,int y,int MOD=::MOD){
	int res=1;
	for(;y;x=1ll*x*x%MOD,y>>=1)
		if(y&1)
			res=1ll*res*x%MOD;
	return res;
}
void readData(){
	scanf("%d%d",&n,&MOD);
}
void initMath(int n){
	fact[0]=fact[1]=1;
	for(int i=2;i<=n;i++) fact[i]=1ll*fact[i-1]*i%MOD;
	iact[0]=iact[1]=1;
	iact[n]=fastPow(fact[n],MOD-2);
	for(int i=n-1;i>=2;i--) iact[i]=1ll*iact[i+1]*(i+1)%MOD;
}
inline int C(int n,int m){
	return (0<=m&&m<=n)?1ll*fact[n]*iact[m]%MOD*iact[n-m]%MOD:0;
}
void initStirling(int n){ // prefix of each line
	for(int i=0;i<=n;i++) s[i][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=i;j++)
			s[i][j]=(1ll*s[i-1][j]*(j+1)%MOD+s[i-1][j-1])%MOD;
}
void calc(){
	int ans=fastPow(2,fastPow(2,n,MOD-1));
	int f;
	for(int i=1;i<=n;i++){
		f=0;
		for(int j=0;j<=i;j++)
			(f+=1ll*s[i][j]*fastPow(fastPow(2,n-i),j)%MOD)%=MOD;
		f=1ll*f*fastPow(2,fastPow(2,n-i,MOD-1))%MOD;
		(ans+=((i&1)?-1ll:1ll)*C(n,i)*f%MOD)%=MOD;
	}
	printf("%d\n",ans>=0?ans:ans+MOD);
}
int main(){
	readData();
	initMath(n);
	initStirling(n);
	calc();
	return 0;
}


Measured memory_bytes: 34176
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}


signed main() {
	char a, b;
	cin >> a >> b;
	if (a == b) {
		cout << "H" << endl;
	}
	else {
		cout << "D" << endl;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;

char s[100002];

int main(){
  scanf("%s", s); int L = strlen(s);

  int x = 0, y = L - 1, ans = 0;

  while(x < y){
    if(s[x] == 'x'){
      if(s[y] == 'x'){ x++; y--; }
      else{ ans++; x++; }
    }
    else if(s[y] == 'x'){
      ans++; y--;
    }
    else if(s[x] == s[y]){ x++; y--; }
    else{ ans = -1; break; }
  }

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256