akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;

  while (cin >> n, n) {
    vector<string> s;
    for (int i = 0; i < n; ++i) {
      string in;
      cin >> in;
      s.push_back(in);
    }

    for (int i = 0; i < s.size(); ++i) {

      int length = 0;
      int cnt = 0;

      for (int j = i; j < s.size() && cnt != 5; ++j) {
        length += s[j].size();

        if ((cnt == 0 || cnt == 2) && length == 5) {
          length = 0;
          cnt++;
          continue;
        }
        if ((cnt == 1 || cnt == 3 || cnt == 4) && length == 7) {
          length = 0;
          cnt++;
          continue;
        }
      }

      if (cnt == 5) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
}

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

using namespace std;

const long long MOD = 1000000007;
const long long MAX = 2000000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}


int main() {
  int N;
  cin>>N;
  int P[N],Q[N];
  for(int i=0;i<N;i++){
      cin>>P[i];
  }
  for(int i=0;i<N;i++){
      cin>>Q[i];
  }
  vector<int>v;
  for(int i=1;i<=N;i++){
      v.push_back(i);
  }
  int pp,qq;
  pp=0;
  qq=0;
  int now=1;
  for(int i=0;i<N;i++){
      pp+=P[N-i-1]*now;
      qq+=Q[N-i-1]*now;
      now*=10;
  }
  int sum=0;
  int summ=0;
  int noww=0;
    do {
        int vv=0;
        now=1;
        for(int i=0;i<N;i++){
            vv+=v[N-i-1]*now;
            now*=10;
        }
       if(pp==vv){
           sum=noww;
       }
       if(qq==vv){
           summ=noww;
       }
       noww++;



    } while (std::next_permutation(v.begin(), v.end()));
    cout<<abs(sum-summ)<<endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <tuple>
using namespace std;

int n2[128];

int main(){

    for(int i=1; i<=127; i++){
        n2[i] = i*i;
    }

    int n, d; cin >> n >> d;

    int x[n][d];
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            cin >> x[i][j];
        }
    }

    int cnt = 0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            int d2temp = 0;
            for(int k=0; k<d; k++){
                d2temp += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            }
            for(int k=1; k<=127; k++){
                if(d2temp == n2[k]){
                    cnt++;
                }
            }
        }
    }

    cout << cnt;

    return 0;
}

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

using namespace std;

const int maxi=1e6+6;

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

   cin>>a>>b>>c>>d;

   b=min(b,d);
   a=max(a,c);

   if (b<a) printf("0\n"); else printf("%d\n",b-a);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
  int num,ct;
  node(int a,int b){
    ct = a;
    num = b;
  }
  bool operator < (const node other)const{
    return num > other.num;
  }
};

int main(){
  int n,m;cin>>n>>m;
  vector<int>arr(n);
  for(int i=0;i<n;++i)cin>>arr[i];
  vector<node> nodes;
  int ct,num;
  for(int i=0;i<m;++i){
    cin>>ct>>num;
    nodes.push_back(node(ct,num));
  }
  sort(nodes.begin(),nodes.end());

  vector<int>arr2;
  for(auto i:nodes){
    if(arr2.size() >= n) break;
    for(int j=0;j<i.ct && arr2.size() < n;++j){
      arr2.push_back(i.num);
    }
  }

  long long result = 0;
  sort(arr.begin(),arr.end(),greater<int>());
  /*
  for(auto i:arr){
    cout<<i<<" ";
  }cout<<endl;
  for(auto i:arr2){
    cout<<i<<" ";
  }cout<<endl; 
  */
  ct = 0;
  int l = 0;
  int r = 0;
  while(ct<n){
    if( l<n && r<arr2.size()){
      if(arr[l]>arr2[r]){
        result += arr[l++] * 1L;
      } else{
        result += arr2[r++]* 1L;
      }
    } else if(l==n){
      result += arr2[r++] * 1L;
    } else {
      result += arr[l++] * 1L;
    }
    ct++;
  }
  cout<<result<<endl;
}

Measured memory_bytes: 2292
H,W = map(int,input().split())
S = []
wall = "."*(W+2)
S.append(wall)
for i in range(H):
    s = input()
    s = "."+s+"."
    S.append(s)
S.append(wall)

for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]==".":
            num = 0
            for k in range(3):
                for l in range(3):
                    x = k-1
                    y = l-1
                    if S[i+x][j+y]=="#":
                        num += 1
            S[i] = S[i][:j] + str(num) + S[i][j+1:]
for i in range(1,H+1):
    s = S[i]
    print(s[1:W+1])

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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 10;

int n, b[maxN], c[maxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for1(i, n)
    {
        int a;
        cin >> a;
        if (i % 2 == 1)
        {
            b[i / 2 + 1] = a;
        }
        else
        {
            c[i / 2] = a;
        }
    }
    map <int, int> mp;
    vector <pair <int, int>> vec_b, vec_c;
    for1(i, n / 2)
    {
        ++mp[b[i]];
    }
    vec_b.assign(all(mp));
    mp.clear();
    for1(i, n / 2)
    {
        ++mp[c[i]];
    }
    vec_c.assign(all(mp));
    sort(all(vec_b), [](pair <int, int> a, pair <int, int> b)
    {
        return tie(a.se, a.fi) > tie(b.se, b.fi);
    });
    sort(all(vec_c), [](pair <int, int> a, pair <int, int> b)
    {
        return tie(a.se, a.fi) > tie(b.se, b.fi);
    });
    int ans = n;
    if (n == 2)
    {
        uin(ans, (int)(b[1] == c[1]));
    }
    else
    {
        for0(i, 2)
        {
            for0(j, 2)
            {
                if (vec_b[i].fi != vec_c[j].fi)
                {
                    uin(ans, n - vec_b[i].se - vec_c[j].se);
                }
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  int k;
  cin>>k;
  int count=0;
  while(a>=b){
    b*=2;
    count++;
  }
  while(b>=c){
    c*=2;
    count++;
  }
  if(count<=k){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
using ll =  long long;

#define rep(i,n) for(int i= 0; i< (n); i++)

using namespace std;

int main(){

    ll x;
    cin >> x;

    ll ans = 0, a = 100;
    while(a<x){
        a += a/100;
        ++ans;

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


}

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

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int pre;
	cin >> pre;
	long ans = 0;
	for(int i=0; i<n - 1; i++){
		int x;
		cin >> x;
		ans += min ((long)(x - pre) * a, (long)b);
		pre = x;
	}
	cout << ans;
	return 0;
}



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

int main() {
    int n;
    cin >> n;
    vector<P> s(n);
    rep(i,n) {
        string st;
        int x;
        cin >> st >> x;
        s[i].first = st;
        s[i].second = -x;
    }
    vector<P> copy_s = s;
    sort(copy_s.begin(),copy_s.end());
    rep(i,n) {
        rep(j,n) {
            if (s[j].first == copy_s[i].first && s[j].second == copy_s[i].second) {
                cout << j+1 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include<unordered_map>

using namespace std;

int main(void)
{
    int n;
    cin >> n;
    vector<int> a(n);
    int cnt = 0;
    for (int i = 0; i < n;i++)
        cin >> a[i];
    
    for (int i = 0; i < n;i++){
        if(a[a[i]-1]==i+1&&a[i]>i+1)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;

namespace Volume0_0005
{
	class Program
	{
		static void Main(string[] args)
		{
			List<Tuple<long, long>> ts = new List<Tuple<long, long>>();

			for(int i = 0; i < 50; i++) {
				string str = Console.ReadLine();
				if(str == null) {
					break;
				}

				string[] vs = str.Split(' ');
				ts.Add(Tuple.Create(long.Parse(vs[0]), long.Parse(vs[1])));
			}

			foreach(Tuple<long, long> t in ts) {
				Console.WriteLine($"{CalcGcd(t.Item1, t.Item2)} {CalcLcm(t.Item1, t.Item2)}");
			}
		}

		private static long CalcGcd(long a, long b)
		{
			if(a < b) {
				return CalcGcd(b, a);
			}

			while(b != 0L) {
				long mod = a % b;
				a = b;
				b = mod;
			}

			return a;
		}

		private static long CalcLcm(long a, long b)
		{
			return a * b / CalcGcd(a, b);
		}
	}
}



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

#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define what_is(x) cout << #x << " is: " << x << endl;
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define ll long long int

#define vi vector<int>
#define pii pair<int,int>
#define vl vector<ll>
#define pll pair<ll, ll>

template<typename T>
T extgcd(T a, T b, T &x, T &y) { if (b == 0) {x = 1;y = 0;return b;}T x1, y1;T g = extgcd(b, a % b,x1, y1);x = y1; y = x1 - (a/b)*y1;return g;}
template<typename T>
T fast_power(T a, T b){T res = (T)1;while( b ){if( b & 1 ) res = res * a;b >>= 1;a *= a; } return res;}
template<typename T>
T fast_powerModulo( T a, T b, T M){T res = (T)1;a %= M;while( b ){if( b & 1 ) res = (res * a) % M;b >>= 1;a *= a;a %= M; }return res;}
template<typename T>
T LCM(T a, T b){ T gd = __gcd(a, b); T ml = a * b; return ml/ gd;}

int main(){
    char a;
    cin >> a;
    char ans = a+1;
    cout << ans << '\n';

    return 0;
}




Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]";
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int N;
    cin >> N;

    ll sum = 0;
    FOR(i, 0, N){
        int a;
        cin >> a;
        sum += a;
    }

    p(sum - N);

    return 0;
}

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

int N,W;
int main(){
	while(cin >> N >> W && N>0){
		vector<pair<int,int> > things;
		for(int i=0;i<N;i++){
			int v,w;
			cin >> v >> w;
			things.push_back(make_pair(v,w));
		}
		int V[N+1][W+1] = {{0}};
		for(int i=0;i<N+1;i++){
			for(int j=0;j<W+1;j++){
				if(i==0 || j==0){
					V[i][j] = 0;
				}else if(things[i-1].second>j){
					V[i][j] = V[i-1][j];
				}
				else{
					V[i][j] = max(things[i-1].first+V[i-1][j-things[i-1].second],V[i-1][j]);
				}
			}
		}
		cout << V[N][W] << endl;
	}
}

#if 0
所要時間は15分程度。有名な問題だったのですぐに書けた。
#endif


Measured memory_bytes: 7040
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

string inv(string s){
	int z=s.size();
	string t;
	for(int i=0;i<z;i++)t+=s[z-i-1];
	return t;
}

int main(){
	int n,z,cnt,sw;
	string s,t[568];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		cnt=0;
		z=s.size();
		for(int j=0;j<z-1;j++){
			for(int k=0;k<8;k++){
				if(k==0)t[j*8]=s.substr(0,j+1)+s.substr(j+1,z);
				if(k==1)t[j*8+1]=s.substr(0,j+1)+inv(s.substr(j+1,z));
				if(k==2)t[j*8+2]=inv(s.substr(0,j+1))+s.substr(j+1,z);
				if(k==3)t[j*8+3]=inv(s.substr(0,j+1))+inv(s.substr(j+1,z));
				if(k==4)t[j*8+4]=s.substr(j+1,z)+s.substr(0,j+1);
				if(k==5)t[j*8+5]=inv(s.substr(j+1,z))+s.substr(0,j+1);
				if(k==6)t[j*8+6]=s.substr(j+1,z)+inv(s.substr(0,j+1));
				if(k==7)t[j*8+7]=inv(s.substr(j+1,z))+inv(s.substr(0,j+1));
				sw=0;
				for(int l=0;l<j*8+k;l++)if(t[j*8+k]==t[l])sw=1;
				if(sw==0)cnt++;
			}
		}
		cout<<cnt<<endl;
	}
}

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


using namespace std;

int N;
vector<int> ans;
vector<vector<pair<int,int>>> adlist;

int DPF(int now) {
	for (pair<int,int> next : adlist[now]) {
		if (ans[next.first] == -1) {
			if (next.second % 2 == 0)
				ans[next.first] = ans[now];
			else
				ans[next.first] = 1 - ans[now];
			DPF(next.first);
		}
	}
}

int main() {
	cin >> N;

	ans.resize(N + 1, -1);
	adlist.resize(N + 1);

	for (int i = 0; i < N-1; i++)
	{
		int u, v, w;
		cin >> u >> v >> w;
		adlist[u].push_back(make_pair(v, w));
		adlist[v].push_back(make_pair(u, w));
	}

	//最初0に
	ans[1] = 0;
	DPF(1);

	for (int i = 0; i < N; i++)
	{
		cout << ans[i + 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N;
  cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  sort(ALL(A));
  int ans=1;
  rep(i,1,N){
    if(A[i]!=A[i-1])
      ans++;
    }
  cout<<ans;
  }


Measured memory_bytes: 256
n = int(input())
s = []
c = {}
nums = {}
for i in range(n):
    ipt = input().split()
    nums[int(ipt[1])] = i + 1
    if not ipt[0] in c:
        s.append(ipt[0])
        c[ipt[0]] = [int(ipt[1])]
    else:
        c[ipt[0]].append(int(ipt[1]))

s.sort()

for i in s:
    c[i].sort()
    for j in c[i][::-1]:
        print(nums[j])



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

int N;
int main() {
    std::cin >> N;
    long long T, A;
    long long x = 1, y = 1;
    for(long long i=0; i<N; i++){
        std::cin >> T >> A;
        long long n = std::max( x/T+(x%T != 0), y/A+(y%A!=0));
        x = n*T;
        y = n*A;
    }
    std::cout << x+y << std::endl;
}


Measured memory_bytes: 256
#!/user/bin/env python
#pythonプログラムであることを示している

# -*- coding: utf-8 -*-
"""
このプログラムはPythonを書く際のテンプレとなっています。これをコピペしてコーディングを行なってください。
なお字下げしないこと！！
"""

__author_ = 'Maruta Yuzuha'
__version_ = '1.0.0'
__date__ = '2019/12/25'

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = input().split()
    a = 0
    b = 0
    for i in range(int(s[1])):
        if i == 0:
            a = s[0]
        else:
            a += s[0]

    for i in range(int(s[0])):
        if i == 0:
            b = s[1]
        else:
            b += s[1]

    if int(a) >= int(b):
        print(a)
    else:
        print(b)

    return 0

if __name__ == '__main__':
    #上記のifの記述によってこのスクリプトファイルが起動された時だけ実行する部分になる。
    #ちなみにスクリプトが "モジュールとして"インポートされた時には実行されない、

    #単体テスト:モジュールのdocstring(ドキュメンテーション文字列)に記載された全ての対話実行例が書かれている通りに動作するかを確認
    #python ファイル名 -v
    import doctest
    doctest.testmod()

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

Measured memory_bytes: 8424
import sys
import bisect
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A.sort()
B.sort()
C.sort()

ans = 0
for b in B :
    al = bisect.bisect_left(A,b)
    cg = N - bisect.bisect_right(C,b)
    ans += al * cg

print(ans)


Measured memory_bytes: 22592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    ll x, a, b;
    cin >> x >> a >> b;
    x -= a;
    cout << x % b << "\n";
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  ll m = pow(10,9) + 7;
  ll ans = 1;
  for(ll i = 1; i <= n; i++){
    ans = (ans*i)%m;
    
  }
  cout << ans << endl;
}


Measured memory_bytes: 3576
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    // Your code here!
    long double a,b,c;
    cin >> a >> b >> c;
    long double a1,b1,c1;
    a1 = sqrtl(a);
    b1 = sqrtl(b);
    c1 = sqrtl(c);
    if(2*a1*b1 + a + b < c ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
    
    
   
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var a, b, x int
	fmt.Scanf("%d %d %d", &a, &b, &x)

	fmt.Printf("%d\n", divisibleUpto(x, b)-divisibleUpto(x, a-1))
}

func divisibleUpto(x, n int) int {
	if n == -1 {
		return 0
	}
	return n/x + 1
}


Measured memory_bytes: 1836
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

//http://www.geocities.jp/p_lan_c/arg02.html

// 最大公約数を求める関数
ll gcd(ll x, ll y)
{
    ll r;

    if(x == 0 || y == 0)  // 引数チェック
    {
        fprintf(stderr, "引数エラーです。\n");
        return 0;
    }

    // ユーグリッドの互除法
    while((r = x % y) != 0) // yで割り切れるまでループ
    {
        x = y;
        y = r;
    }
    return y;
}

// 最大公約数を求める関数
ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0)  // 引数チェック
    {
        fprintf(stderr, "引数エラーです。\n");
        return 0;
    }

    return (x * y / gcd(x, y));
}

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

  ll n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;

  ll ans = lcm(n, m);
  ll v = gcd(n,m);
  ll idx = ans/m, jdx = ans/n;
  
  REP(i, v){
    if(s[idx*i] != t[jdx*i]){
      cout << -1 << endl;
      return 0;
    }
  }  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    string a,b,c; cin>>a>>b>>c;
    cout<<'A'<<b[0]<<'C'<<endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    vector<vector<ll>> A(3);
    rep(i, 3) {
        rep(j, 3) {
            ll a;
            cin >> a;
            A[i].push_back(a);
        }
    }
    ll N;
    cin >> N;
    set<ll> B;
    rep(i, N) {
        ll b;
        cin >> b;
        B.insert(b);
    }
    vector<vector<bool>> G(3, vector<bool>(3, false));
    rep(i, 3) {
        rep(j, 3) {
            ll a = A[i][j];
            if (B.count(a)) {
                G[i][j] = true;
            }
        }
    }
    bool ok = false;
    rep(i, 3) {
        bool o = true;
        rep(j, 3) {
            if (!G[i][j]) {
                o = false;
            }
        }
        if (o) ok = true;
    }

    rep(i, 3) {
        bool o = true;
        rep(j, 3) {
            if (!G[j][i]) {
                o = false;
            }
        }
        if (o) ok = true;
    }

    if (G[0][0] && G[1][1] && G[2][2]) {
        ok = true;
    }
    if (G[0][2] && G[1][1] && G[2][0]) {
        ok = true;
    }
    if (ok) {
        cout << "Yes" << '\n';
    }else{
        cout << "No" << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

#include <random>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

//#define solvsh
//#define multi

#ifdef solvsh
#else

ll mod = 1e4 + 7;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll ml(ll a, ll b) {
    return (a * b) % mod;
}

ll sub(ll a, ll b) {
    return add(a, mod - b);
}

ll b_p(ll b, ll p) {
    if (p == 0) return 1;
    if (p & 1) return ml(b, b_p(b, p ^ 1));
    ll v = ml(b, p >> 1);
    return ml(v, v);
}
const int MAXN = 5e4+ 12;

void solve() {

    string s;
    cin >> s;

    int n = s.size();

    if (s[n - 1] == 's') {
        cout << s << "es";
    } else {
        cout << s << "s";
    }

}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifdef multi
    //        gen();
    multisolve();
#else
    solve();
//    gen();
#endif
//    time_calc();
}


Measured memory_bytes: 3672
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    private static float avgTemp(final int T, final int x) {
        return (T - x * 0.006f);
    }

    public static void main(String[] args) {
        try (
                Scanner in = new Scanner(System.in);
                PrintWriter out = new PrintWriter(System.out))
        {
            final int N = in.nextInt();
            final int T = in.nextInt();
            final int A = in.nextInt();

            int bestIdx = -1;
            float minDiff = Float.POSITIVE_INFINITY;
            for (int i = 0; i < N; ++i) {
                final int Hi = in.nextInt();
                float diff = Math.abs(avgTemp(T, Hi) - A);
                if (diff < minDiff) {
                    bestIdx = i;
                    minDiff = diff;
                }
            }
            out.println(bestIdx + 1);
        }
    }
}


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

struct UnionFind {
    vector<ll> par,rank,cnt; // par[i]:iの親の番号,rank[r]:rを根とする木の高さ,cnt[r]:rを根とする木の要素数

    UnionFind(ll N){ //全て根として初期化
        for(ll i = 0; i < N; i++) par.push_back(i);
        rank.assign(N,0);
        cnt.assign(N,1);
    }

    ll root(ll x){ // xの根を返す
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x,ll y){ // xの木とyの木を併合
        ll rx = root(x); 
        ll ry = root(y);
        if (rx == ry) return;

        if(rank[rx] < rank[ry]){
            par[rx] = ry;
            cnt[ry] += cnt[rx]; 
        }else{
            par[ry] = rx;
            cnt[rx] += cnt[ry];
            if(rank[x] == rank[y]) rank[rx] ++;
        }
    }

    ll tsize(ll x){ //　xの木の要素数を返す
        ll rx = root(x);
        return cnt[rx];
    }

    bool same(ll x,ll y){ // xとyが同一の木に存在するかを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,m,ans=0;
    cin >> n >> m;
    UnionFind tree(n);
    for(int i = 0;i < m;i ++){
        int x,y,z;
        cin >> x >> y >> z;
        x --,y --;
        tree.unite(x,y);
    }
    set<int> st;
    for(int i = 0;i < n;i ++){
        st.insert(tree.root(i));
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 7284
#D
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
C=Counter(A)
ans=sum(A)

for i in range(Q):
    b,c=map(int,input().split())
    if b==c:
        print(ans)
        continue
    ans-=C[b]*b
    ans+=C[b]*c
    C[c]+=C[b]
    C[b]=0
    print(ans)

Measured memory_bytes: 88984
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

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

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

	ll ans = 0;
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			ans += lower_bound(L.begin()+j+1, L.end(), L[i]+L[j])
				- (L.begin()+j+1);
		}
	}

//	ll t = 0;
//	for(int i=0; i<N; i++) for(int j=i+1; j<N; j++) for(int k=j+1; k<N; k++){
//		if(L[i]<L[j]+L[k]&&L[j]<L[i]+L[k]&&L[k]<L[i]+L[j]) t++;
//	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
list1=[]
list2=[]
for i in range(10):
    list1.append(int(input()))
list1.sort(reverse=True)
    
for i in range(10):
    list2.append(int(input()))
list2.sort(reverse=True)

s=sum(list1[0:3])
m=sum(list2[0:3])
print(f'{s} {m}')


Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

ll pow5(ll x){
    ll ret=1;
    for(int i=0; i<5; i++){
        ret*=x;
    }
    return ret;
}

int main(){
    ll X;
    cin >> X;

    
    for(ll A=0; A<100; A++){
        for(ll B=A; B<100; B++){
            ll A5=pow5(A);
            ll B5=pow5(B);
            if(A5+B5==X){
                cout << A << ' ' << -B << endl;
                return 0;
            }
        }
    }

    for(ll A=0; A<150; A++){
        for(ll B=0; B<A; B++){
            ll A5=pow5(A);
            ll B5=pow5(B);
            if(A5==X+B5){
                cout << A << ' ' << B << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;


int main(){
  string s;cin>>s;
  int n = s.size();
  int a= 0 ,b = 0;
  fol(i,n){
    if(s[i]=='0')a++;
    else b++;
  }
  int ans = min(a,b);
  cout << ans*2 << endl;
  return 0;
}


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

int main() {
    string s,t;
    cin >> s >> t;
    int count = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i]==t[i]) {
            count++;
        }
    }
    
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    int a[120]={0},s,t;
    while(cin>>s>>t,s)a[s]++,a[t]++;
    if(a[1]==0)return 0;
    for(int i=3;i<120;i++)if(a[i]%2||!(a[1]%2&&a[2]%2))goto L;
    cout<<"OK"<<endl;
    if(0)L:cout<<"NG"<<endl;
  }
}

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

int main()
{
    int A, B;
    cin >> A >> B;

    int ans;
    if (A >= 13)
    {
        ans = B;
    }
    else if (A >= 6)
    {
        ans = B / 2;
    }
    else
    {
        ans = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
from numba import njit

n, k = map(int, input().split())
h = np.array(list(map(int, input().split())), np.int64)
INF = 10 ** 18


@njit
def f():
    dp = np.full(n, INF, np.int64)
    dp[0] = 0

    for i, e in enumerate(h[1:], 1):
        lb = np.maximum(0, i - k)
        dp[i] = np.min(dp[lb:i] + np.abs(h[lb:i] - e))

    ans = dp[-1]
    return ans


ans = f()
print(ans)


Measured memory_bytes: 151036
def generator(n=9):
    if n == 0:
        yield 0
    else:
        for a in generator(n - 1):
            for i in (0, 3, 5, 7):
                yield 10 * a + i


n = int(input())
cnt = 0
for a in generator():
    if a > n:
        break
    if set(str(a)) == {'3', '5', '7'}:
        cnt += 1
print(cnt)


Measured memory_bytes: 3064
"""
https://abc089.contest.atcoder.jp/tasks/abc089_b
"""
n=int(input())
s=[i for i in input().split()]
a=1
for i in s:
    if i=="Y":
        a=a*0
    else:
        a=a*1

if a==0:
    print("Four")
else:
    print("Three")


Measured memory_bytes: 2940
import java.util.Scanner;

// 提出時にclass Main に書き換え
public class Main {
	public static void main(String[] args)  {
		// 標準入力を受け取る
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong(); // long aを受け取る
		long b = sc.nextLong(); // long bを受け取る
		long c = sc.nextLong(); // long cを受け取る
		long d = sc.nextLong(); // long dを受け取る
		sc.close(); // 標準入力を終了

		long x = b;
		long y = d;

		if (b <= 0 && d <= 0) {
			// 負×負 x=a, y=c が最大
			x = a;
			y = c;
		} else if (a >= 0 && d <= 0) {
			// 正×負 x=a, y=d が最大
			x = a;
		} else if (b <= 0 && c >= 0) {
			// 負×正 x=b, y=c が最大
			y = c;
		} else if (a * c > b * d) {
			// a*cの方が、b*dよりも解が大きい場合 x=a, y=c が最大
			x = a;
			y = c;
		}

		long ans = x * y;

		System.out.println(ans);
	}

}

Measured memory_bytes: 35572
/*
13 =0;
  1   2   3   4   5  6  7  8   9  10  11  12  13
  2   3   4   5   6  7  8  9  10  11  12  13   1
 +1  +2  +3  +4  +5 +6 +7 +8  +9 +10 +11 +12  +0
      3   6  10  15 21 28 36  45  55  66  
*/
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(void){
	long long N,ans=0;
	cin>>N;
	for(int i=1;i<N;i++)
	{
		ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
  int sum, ans, n1, n2;
  while(cin>>n1>>n2){
    sum = n1+n2;
    ans = (int)log10((double)sum) + 1;
    cout<<ans<<endl;
}
  return 0;
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define ump gp_hash_table<int,int,custom_hash>
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*int **dp,in main function,int row,col;dp=new int*[n];rep(i,n)dp[i]=new int[m]*/
//**** Maths Section*******/
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);
/***************************/
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  fastio
  int n;
  cin>>n;
  if(n%2)
  {
    cout<<0<<endl;
    exit(0);
  }
    int a=0;
    n=n/2;
    while(n)
    {
      a+=n/5;
      n=n/5;
    }
    cout<<a<<endl;
  return 0;
}

int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}

int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}

bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    nums = list(map(int, input().split()))
    
    if 0 in nums:
        print(0)
        return
    
    mul = 1
    for i in nums:
        mul *= i
        if mul > 1000000000000000000:
            print(-1)
            return
        
    print(mul)
    
main()

Measured memory_bytes: 21508
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(15) << std::fixed;
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);
    precise
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        cout<<a*b<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};


int main()
{
    int x, y, a, b, c;
    cin>>x>>y>>a>>b>>c;
    VLL p(a), q(b), r(c);
    REP(i,a) cin>>p[i];
    REP(i,b) cin>>q[i];
    REP(i,c) cin>>r[i];
    SORT(p); SORT(q); SORT(r);
    VLL candidate;
    FOR(i,a-x,a) candidate.push_back(p[i]);
    FOR(i,b-y,b) candidate.push_back(q[i]);
    SORT(candidate);
    int idx = c - 1;
    ll ans = 0ll;
    REP(i,x+y) {
        if (idx >= 0 && candidate[i] < r[idx]) {
            ans += r[idx];
            idx--;
        } else {
            ans += candidate[i];
        }
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 7724
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String a=gs();
	    String b=gs();

	    System.out.print(b+a);

//        if ((a==1 && b==2) || (a==2 && b==1)) {
//        	System.out.print(3);
//        } else if ((a==1 && b==3) || (a==3 && b==1)) {
//        	System.out.print(2);
//        }else {
//        	System.out.print(1);
//        }


	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 38948
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main() {
  fast_io

  int n, m;
  cin >> n >> m;
  vector<int> p(m), y(m);
  vector<vector<int>> yd(n);
  rep(i, m) {
    cin >> p[i] >> y[i];
    p[i]--;
    yd[p[i]].push_back(y[i]);
  }
  rep(i, n) sort(yd[i].begin(), yd[i].end());
  rep(i, m) {
    vector<int> pp = yd[p[i]];
    int num = lower_bound(pp.begin(), pp.end(), y[i]) - pp.begin();
    printf("%06d%06d\n", p[i] + 1, num + 1);
  }
  return 0;
}


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

#define all(v) (v).begin(), (v).end()
using namespace std;

struct event
{
    int time, deadline;

    event(){}

    event(int t, int d)
    {
        time = t, deadline = d;
    }

    const int operator <(const event &E)
    {
        return (deadline < E.deadline);
    }
};

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

    vector <event> E(no_of_events);
    for(int i = 0; i < no_of_events; i++)
    {
        cin >> E[i].time >> E[i].deadline;
    }

    sort(all(E));

    int time_now = 0, possible = true;
    for(int i = 0; i < no_of_events; i++)
    {
        time_now += E[i].time;

        if(time_now > E[i].deadline)
            possible = false;
    }

    cout << (possible ? "Yes" : "No");
    return 0;
}


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

int main() {
  string S;
  cin>>S;
  string s = to_string(S.size()-2);
  string T = S[0]+s+S[S.size()-1];
  cout << T << endl;
  return 0;
}


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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int N, X; cin >> N >> X;
    VI M(N);
    REP(i, N)
    {
        cin >> M.at(i);
    }
    sort(ALL(M));
    int p;
    p  = (X- accumulate(ALL(M), 0)) / M.front();

    cout << N+p << endl;
  
    return 0;
}



Measured memory_bytes: 256
reiwa="?"
while True:
    data=input().split()
    g=data[0]
    if g == "#":
        break
    else:
        y=int(data[1])
        m=int(data[2])
        d=int(data[3])
    
    #平成
    if y<31 or (y==31 and m<5):
        print(f"{g} {y} {m} {d}")
    #新元号
    else:
        y=y-30
        print(f"{reiwa} {y} {m} {d}")


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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;


int main(){
	int n,sum=0;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	int m;
	cin>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		--x;
		cout<<sum-a[x]+y<<'\n';
	}
}





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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    cin >> N;
    for(ll i = 1;i < 50000;i++) {
        if(i * 108 / 100 == N) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n,i,sum=0,a;
	while(1){
		scanf("%d",&n);
		if(n==0)
			break;

		for(i=0;i<n/4;i++){
			scanf("%d",&a);
			sum+=a;
		}
		printf("%d\n",sum);

		sum=0;
	}
	return 0;
}

Measured memory_bytes: 596
n = int(input())
s = input()
lstW = [0]
c = 0
#累積和
for i in range(1,len(s)):
    if s[i-1] == "W":
        c += 1
    lstW.append(c)
    
lstE = [0]
c = 0
for i in range(len(s)-2,-1,-1):
    if s[i+1] == "E":
        c += 1 
    lstE.append(c)
lst = []
for i in range(len(lstW)):
    lst.append(lstW[i] + lstE[n-i-1])
lst.sort()
print(lst[0])

Measured memory_bytes: 72152
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

using namespace std;

int main(int argc, const char *argv[]){
    int k,x;
    cin >> k >> x;
    cout << x-k+1;
    for(int i=(x-k+2);i<(x+k);i++){
        cout << " " << i;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
s = input() #sys.stdin.readlineは最後が改行

from collections import Counter

c = Counter(s)

if c['N'] >0 and c['S']==0:
    print('No')
    exit()
if c['S'] >0 and c['N']==0:
    print('No')
    exit()
if c['W'] >0 and c['E']==0:
    print('No')
    exit()
if c['E'] >0 and c['W']==0:
    print('No')
    exit()

print('Yes')

Measured memory_bytes: 3316
S = input()
n = len(S)
ans = 0
flag = True

for i in range(n):
  for j in range(i):
    for k in range(i,n+1):
      S_part = S[j:k]
      for s in S_part:
        if not s in "ACGT":
          flag = False
      if flag:
        ans = max(ans,len(S_part))
      flag = True

if n == 1:
  if S[0] in "ACGT": ans = 1
print(ans)

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

int main(){
  int N, K;
  int l[60];
  cin >> N >> K;
  for(int i = 0; i < N; ++i) cin >> l[i];
  sort(l, l + N, greater<int>());
  int ans = 0;
  for(int j = 0; j < K; ++j) ans += l[j];
  cout << ans << endl;
}


Measured memory_bytes: 256