akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;

int dp[100010][3];

signed main(){
    int n; cin >> n;
    REP(i,n){
        int a, b, c; cin >> a >> b >> c;
        chmax(dp[i+1][0],max(dp[i][1]+a,dp[i][2]+a));
        chmax(dp[i+1][1],max(dp[i][2]+b,dp[i][0]+b));
        chmax(dp[i+1][2],max(dp[i][0]+c,dp[i][1]+c));
    }
    cout << max({dp[n][0],dp[n][1],dp[n][2]}) << endl;
}

Measured memory_bytes: 2560
// 問題の URL を書いておく
// https://atcoder.jp/contests/diverta2019/tasks/diverta2019_c

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

int main(int, const char**)
{
    int n;
    cin >> n;
    int ab = 0, a = 0, b = 0;
    int ans = 0;
    rep(i, n)
    {
        string s;
        cin >> s;
        if(s[0] == 'B' && s.back() == 'A')
        {
            ab++;
        }
        else if(s[0] == 'B')
        {
            b++;
        }
        else if(s.back() == 'A')
        {
            a++;
        }

        rep(j, s.size() - 1)
        {
            if(s[j] == 'A' && s[j + 1] == 'B')
            {
                ans++;
            }
        }
    }
    ans += max(ab - 1, 0);
    if(ab > 0)
    {
        if(a > 0)
        {
            a--;
            ans++;
        }
        if(b > 0)
        {
            b--;
            ans++;
        }
    }
    ans += min(a, b);

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


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

int main() {
	int k;cin>>k;
	long long num=1;
	long long num_ex;
	long long add=1;
	int count=1;
	while(k){
		num_ex=num;
		num+=add;
		count++;
		if(count==10){
			count=0;
		}
		long long s_ex=0;
		long long num_ex2=num_ex;
		long long s=0;
		long long num2=num;
		while(num_ex2){
			s_ex+=num_ex2%10;
			num_ex2/=10;
		}
		while(num2){
			s+=num2%10;
			num2/=10;
		}
		if(double(num_ex)/s_ex>double(num)/s){
			if(count){
			num+=(9-count)*add;
			add*=10;
			count=(num/add)%10;
			}
		}else{
			cout<<num_ex<<endl;
			k--;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys

n = int(input())
G = [None]*n
for i in range(n):
    u, k, *vs = map(int, input().split())
    G[u-1] = [e-1 for e in vs]

from collections import deque
dist = [-1]*n
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w in G[v]:
        if dist[w] > -1: #already visited
            continue
        dist[w] = d + 1
        que.append(w)

for i in range(n):
    print(i+1, dist[i])


Measured memory_bytes: 6036
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
f = 0
s = 0
t = 0
for i in p:
  if i <= a:
    f += 1
  elif i <= b:
    s += 1
  else:
    t += 1
print(min(f,s,t))

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int a;
void input(){
    fast_io();
    cin >> a;
}

int solve(){
    int ans = a+a*a+a*a*a;
    cout << ans << endl;
    return 0;
}   

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

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();

            int count = 0;
            for (int n = 1; n <= N; n += 2) {
                int count2 = 0;
                for (int d = 1; d <= n; d++) {
                    if (n % d == 0) {
                        count2++;
                    }
                }
                if (count2 == 8) {
                    count++;
                }
            }

            System.out.println(count);
        }
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

//
void solve(long long M, long long D){
  ll cnt=0;
  repf(i,1,M+1){
    repf(j,1,D+1){
      if(i==(j/10)*(j%10)&&j/10>=2&&j%10>=2)cnt++;
    }
  }
  op(cnt)
}

// Generated by 1.1.4 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 M;
    scanf("%lld",&M);
    long long D;
    scanf("%lld",&D);
    solve(M, D);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define MAX 2000
using namespace std;
struct P
{
  int x,y,index;
  P(int x=inf,int y=inf,int index=inf):x(x),y(y),index(index){}
};
int h,w,sx,sy,gx,gy,sindex,gindex;
int mincost[6000];//mincost[j] := 現在地j の最小コスト
char G[MAX][MAX];
vector<P> vec[7];

int main()
{
  while(cin >> w >> h,w|h)
    {
      rep(i,7)vec[i].clear();

      int index = 0;
      rep(i,h)rep(j,w)
	{
	  cin >> G[i][j];
	  if(G[i][j] == 'S')vec[5].push_back(P(j,i,index++));
	  else if(G[i][j] == 'G')vec[6].push_back(P(j,i,index++));
	  else if(G[i][j] == '1')vec[0].push_back(P(j,i,index++));
	  else if(G[i][j] == '2')vec[1].push_back(P(j,i,index++));
	  else if(G[i][j] == '3')vec[2].push_back(P(j,i,index++));
	  else if(G[i][j] == '4')vec[3].push_back(P(j,i,index++));
	  else if(G[i][j] == '5')vec[4].push_back(P(j,i,index++));
	}
      assert(index < 6000);
      //assert((vec[5].size() == 1 || vec[5].size() == 0) && (vec[6].size() == 1 || vec[6].size() == 0));
      int ans_cost,ans_first;
      ans_cost = inf;
      rep(i,5)//最初に選んだぽきもん
	{
	  rep(j,6000)mincost[j] = inf;
	  rep(j,vec[5].size())mincost[vec[5][j].index] = 0;

	  int npk = (i+1)%5;
	  for(int k=0;k<vec[5].size();k++)
	    {
	      for(int j=0;j<vec[npk].size();j++)
		{
		  int nx = vec[npk][j].x;
		  int ny = vec[npk][j].y;
		  mincost[vec[npk][j].index] = abs(nx-vec[5][k].x)+abs(ny-vec[5][k].y);
		}
	    }

	  for(int cur=npk,cnt=0;cnt<3;cnt++,cur=(cur+1)%5)
	    {
	      for(int j=0;j<vec[cur].size();j++)
		{
		  int next = (cur+1)%5;

		  int x = vec[cur][j].x;
		  int y = vec[cur][j].y;
		  for(int k=0;k<vec[next].size();k++)
		    {
		      int nx = vec[next][k].x;
		      int ny = vec[next][k].y;
		      mincost[vec[next][k].index] = min(mincost[vec[next][k].index],
							mincost[vec[cur][j].index] + abs(nx-x) + abs(ny-y)); 
		    }
		}
	      if(cnt == 3)assert(cur == (i+3)%5);
	    }

	  int last = (i+4)%5;
	  for(int k=0;k<vec[6].size();k++)
	    {
	      for(int j=0;j<vec[last].size();j++)
		{
		  int nx = vec[last][j].x;
		  int ny = vec[last][j].y;
		  
		  if(ans_cost > mincost[vec[last][j].index] + abs(nx-vec[6][k].x) + abs(ny-vec[6][k].y))
		    {
		      ans_cost = mincost[vec[last][j].index] + abs(nx-vec[6][k].x) + abs(ny-vec[6][k].y);
		      ans_first = i+1;
		    }
		}
	    }

	}
      if(ans_cost == inf)cout << "NA" << endl;
      else               cout << ans_first << " " << ans_cost << endl;
    }
  return 0;
}

Measured memory_bytes: 3244
import heapq


class Graph(object):

    class Node:
        def __init__(self, dist: int, number: int):
            self.dist = dist
            self.number = number

        def __lt__(self, other):
            return self.dist < other.dist \
                   or (self.dist == other.dist
                       and self.number < other.number)

        def __le__(self, other):
            return self.dist <= other.dist

        def __gt__(self, other):
            return other <= self

        def __ge__(self, other):
            return other < self

        def __str__(self):
            return "Node: (" + str(self.number) + ", " \
                   + str(self.dist) + ")"

    class Edge:
        def __init__(self, to: int, cost: int):
            self.to = to
            self.cost = cost

        def __str__(self):
            return "Edge: (" + str(self.to) + ", " \
                   + str(self.cost) + ")"

    INF = 10e10

    def __init__(self, node_n: int, start: int):
        self.node_n = node_n
        self.start = start
        self.edges = [{} for _ in range(self.node_n)]
        self.dist = [self.INF for _ in range(self.node_n)]

    def set_edge(self, from_pos: int, to_pos: int, cost: int, reversible: bool) -> None:
        self.edges[from_pos][to_pos] = (self.Edge(to_pos, cost))
        if reversible:
            self.edges[to_pos][from_pos] = (self.Edge(from_pos, cost))

    def solve(self) -> list:
        raise NotImplementedError


class Dijkstra(Graph):
    hq = []
    prev: list

    def __init__(self, node_n: int, start: int):
        super(Dijkstra, self).__init__(node_n, start)
        self.dist[self.start] = 0
        self.prev = [None for _ in range(node_n)]

    def solve(self) -> list:
        heapq.heappush(self.hq, self.Node(0, self.start))

        while len(self.hq) != 0:
            node = heapq.heappop(self.hq)
            if node.dist > self.dist[node.number]:
                continue

            for edge in self.edges[node.number].values():
                alt = self.dist[node.number] + edge.cost
                if self.dist[edge.to] > alt:
                    self.dist[edge.to] = alt
                    self.prev[edge.to] = node.number
                    heapq.heappush(self.hq, self.Node(alt, edge.to))

        return self.dist


if __name__ == '__main__':
    n = int(input())
    graph = Dijkstra(n, 0)

    for _ in range(n):
        buff = list(map(int, input().split()))
        u = buff[0]
        k = buff[1]
        for i in range(k):
            graph.set_edge(u,
                           buff[2 + i * 2],
                           buff[3 + i * 2],
                           False)
    dist = graph.solve()
    for i, d in enumerate(dist):
        print(i, d)



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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;

ll MOD (ll a) {
    if (a < 0)
        a += mod;
    return (a % mod);
}

void testCase() {
    int h, w;
    cin >> h >> w;
    char mat[h+3][w+3];
    for (int i=1; i<=h; i++) {
        for (int j=1; j<=w; j++)
            cin >> mat[i][j];
    }
    ll ans[h+3][w+3];
    for (int i=1; i<=h; i++) {
        for (int j=1; j<=w; j++) {
            if (mat[i][j] == '.')
                ans[i][j] = 0;
            else
                ans[i][j] = -1;
        }
    }
    ans[h][w] = 1;
    for (int i=h; i>=1; i--) {
        for (int j=w; j>=1; j--) {
            if (ans[i][j] != -1) {
                if (j-1 > 0 && ans[i][j-1] != -1) {
                    ans[i][j-1] = MOD(MOD(ans[i][j-1]) + MOD(ans[i][j]));
                }
                if (i-1 > 0 && ans[i-1][j] != -1) {
                    ans[i-1][j] = MOD(MOD(ans[i-1][j]) + MOD(ans[i][j]));
                }
            }
        }
    }
    cout << ans[1][1] << endl;
}

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int n,m,q;cin>>n>>m>>q;
    int num[505][505];
    rep(i,0,m){
        int a,b;cin>>a>>b;
        num[a][b]++;
    }
    rep(i,1,505){
        rep(j,1,505){
            num[i][j]+=num[i-1][j];
        }
    }
    rep(i,1,505){
        rep(j,1,505){
            num[i][j]+=num[i][j-1];
        }
    }
    rep(i,0,q){
        int a,b;cin>>a>>b;
        cout<<num[a-1][a-1]+num[b][b]-num[a-1][b]-num[b][a-1]<<endl;
    }return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll gcd(ll a, ll b){
    if(a < b)  swap(a,b);
    if(a%b==0) return b;
    else return gcd(b,a%b);
}
ll ngcd(vector<ll> a){
    ll res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    vector<ll> l(n,0), r(n,0);
    l[0] = v[0];
    r[n-1] = v[n-1];
    rep(i,n-1){
        l[i+1] = gcd(v[i+1],l[i]);
    }
    for(int i=n-2;i>=0;i--){
        r[i] = gcd(r[i+1],v[i]);
    }
    ll ans = 0;
    rep(i,n){
        if(i==0) ans = max(ans,r[1]);
        else if(i==n-1) ans = max(ans,l[n-2]);
        else ans = max(ans,gcd(l[i-1],r[i+1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int A,B,C,D;
    cin>>A>>B>>C>>D;

    int x=max(A,C);
    int y=min(B,D);
    int ans=0;
    if(y>x){
        ans=y-x;
    }
    cout << ans << endl;

}


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

#define int long long
const int MAXN = 4 * 100 * 1000 + 1234;
int n, k;
string s;

char rev(char c) {
	return (c == 'A')? 'B': 'A';
}
string gen(int c) {
	string ss;
	if (c % 2 == 0)
		for (int i = 0; i <= n; i++)
			ss += s[i + c];
	else 
		for (int i = 0; i <= n; i++)
			ss += rev(s[i + c]);
	return ss;
}

string prv(string s) {
	if (s[0] == 'A') {
		s[0] = 'B';
		return s;
	}
	return s;
}

void out(string s) {
	if (s == "")
		return ;
	for (int i = 0; i < n; i++)
		putchar(s[i]);
	exit(0);
}

signed main() {
	cin >> n >> k;
	cin >> s;
	int ans[MAXN];
	char ch[2] = {'B', 'A'};
	for (int i = 0; i <= 2 * n + 100; i++)
		s += ch[i % 2];
	ans[0] = (s[0] == ch[1]);
	for (int i = 1; i <= n + 10; i++) {
		ans[i] = ans[i - 1] + 1;
//		cerr << ans[i] << ' ' << s[i] << ' ' << ch[i & 1] << endl;
		ans[i] += s[i] == ch[i % 2 ^ 1];
	}
//	for (int i = 0; i <= n; i++)
//		cerr << i << ' ' << ans[i] << endl;
	for (int i = 0; i <= n + 10; i++) {
//		cerr << i << ' ' << gen(i) << endl;
		if (k == ans[i]) 
			out(prv(gen(i)));
		else if (k == ans[i] - 1)
			out(gen(i));
	}
	cerr << "yoho " << ans[n + 1] << endl;
	k -= ans[n + 1] - 1;
	k %= 2;
	if (k == 0 || n % 2 == 0)
		out(gen(n));
	else
		out(prv(gen(n)));
}


Measured memory_bytes: 4612
#include <iostream>

int main()
{
    int a, b;
    std::cin >> a >> b;

    if      (a == b) std::cout << "Draw"  << std::endl;
    else if (a == 1) std::cout << "Alice" << std::endl;
    else if (b == 1) std::cout << "Bob"   << std::endl;
    else if (a >  b) std::cout << "Alice" << std::endl;
    else             std::cout << "Bob"   << std::endl;       

    return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 a,b,c,d; cin >> a >> b  >> c >> d;
    bool can = ( abs(a-b) <= d && abs(b-c) <= d );
    bool can2 = ( abs(a-c) <= d );

    if(can || can2) cout << "Yes" << '\n';
    else cout << "No" << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,A,B = 0;
  
  cin >>K >>A >> B;
  for(int i = A;i < B+1;i++){
    
    if(i%K == 0){
      cout << "OK";
      return 0;
    }
  }
  cout << "NG";
}

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

using namespace std;

using ll = long long;

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

    string n;
    cin >> n;
    if (n[0] == n[2]) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int a[200100],pos[200100],dp[200100];
int main()
{
	int n,out=0;
	cin>>n;
	rep(i,n){
		cin>>a[i];a[i]--;pos[a[i]]=i;
	}
	rep(i,n){
		if(a[i]<1 || pos[a[i]-1]>i) dp[i]=1;else dp[i]=dp[pos[a[i]-1]]+1;
		out=max(out,dp[i]);
	}
	cout<<n-out<<endl;
}


Measured memory_bytes: 2560
#include<stdio.h>

int main()
{
	int A,B,R;
	scanf("%d%d",&A,&B);

	if(abs(B-A)%2==0)
	{
		R =abs(B-A)/2;
		if (A<B){
            R=A+R;
            }
		else
		{
		    R=B+R;
		}
		printf("%d",R);
	}

	else
	{
		printf("IMPOSSIBLE\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

int n;
ll a[100010];
ll s[100010];
ll ps[100010];

int main()
{
	read(n);
	for(int i=1; i<=n; ++i) read(a[i]), s[i]=a[i];
	sort(s+1, s+n+1);
	for(int i=1; i<=n; ++i) ps[i]=s[i]+ps[i-1];
	int ans=0;
	for(int i=1; i<=n; ++i){
        int j=upper_bound(s+1, s+n+1, a[i])-s-1;
        ll sz=ps[j];
        while(j<n){
            if(upper_bound(s+1, s+n+1, 2*sz)-s-1 == j) break;
            j=upper_bound(s+1, s+n+1, 2*sz)-s-1;
            sz = ps[j];
        }
        if(j == n) ++ans;
	}
	printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 500005;
const int mod = 998244353;

int n, a[MAXN];

vector<lint> solve(){
	vector<lint> dap;
	dap.push_back(0);
	dap.push_back(0);
	vector<pi> stk;
	for(int i=1; i<n; i++){
		int flr = 0;
		if(a[i-1] < a[i]){
			for(lint x = a[i-1]; x < a[i]; x *= 4) flr += 2;
		}
		else{
			for(lint x = a[i]; x * 4 <= a[i-1]; x *= 4) flr -= 2;
		}
		if(flr < 0){
			stk.emplace_back(flr, i);
			dap.push_back(dap.back());	
		}
		else{
			lint ret= dap.back();
			int prv = i;
			while(!stk.empty() && flr > 0 && stk.back().first < 0){
				int min_diff = min(-stk.back().first, flr);
				ret += (prv - stk.back().second) * flr;
				prv = stk.back().second;
				flr -= min_diff;
				stk.back().first += min_diff;
				if(stk.back().first == 0) stk.pop_back();
			}
			ret += prv * flr;
			if(flr > 0) stk.emplace_back(flr, i);
			dap.push_back(ret);
		}
	}
	assert(dap.size() == n + 1);
	return dap;
}


int main(){
	cin >> n;
	for(int i=0; i<n; i++) scanf("%d",&a[i]);
	vector<lint> sol_pfx = solve();
	reverse(a, a + n);
	vector<lint> sol_sfx = solve();
	reverse(sol_sfx.begin(), sol_sfx.end());
	lint ret = 1e18;
	for(int i=0; i<=n; i++){
		ret = min(ret, sol_pfx[i] + i + sol_sfx[i]);
	}
	cout << ret << endl;
}


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

int main(){
  int X;
  cin>>X;
  vector<int> a={2};
  for(int i=3;i<=100003;i++){
    bool boo=true;
    for(int j=0;a.at(j)*a.at(j)<=i;j++)
      if(i%a.at(j)==0){
        boo=false;
        break;
      }
    if(boo){
      a.push_back(i);
    }
  }
  cout<<*lower_bound(a.begin(),a.end(),X)<<endl;
}

Measured memory_bytes: 384
def xorsum(n):
	if n & 1:
		return 1 - ((n >> 1) & 1)
	return n | ((n >> 1) & 1)

A, B = map(int, input().split())

if 0 < A:
	print(xorsum(B) ^ xorsum(A-1))
else:
	print(xorsum(B))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int n, maxsofar=0, curr, s=0;
  cin >> n;
  while(n--) {
    cin >> curr;
    if(curr>=maxsofar) {
      maxsofar=curr;
      s++;
    }
  }
  cout << s;
}

Measured memory_bytes: 256
import math

n = int(input())
s = int(input())
ans = -1

def func(b, n):
    if n < b:
        return n
    else:
        return func(b, n//b) + n%b

if n < s:
    ans = -1
elif n == s:
    ans = n+1
else:
    for b in range(2,int(math.sqrt(n))+1):
      if func(b, n) == s:
          ans = b
          break

    if ans == -1:
        for p in range(1,int(math.sqrt(n))+1):
            b = int((n-s)/p+1)
            if b >= 2 and func(b, n) == s:
                ans = b
print(ans)

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


using namespace std;



int main(){
	int a,b; 
	
	cin >> a >> b;
	
	
	for(int i=1;i<=3;i++){
		if(i*a*b%2==1){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	
	
	
 return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

string s;

int a[200005];
int b[200005];
bool dead[200005];
vector<int> adj[200005];

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);

    cin >> s;

    for (int i = 0; i < m; i++)
    {
        int x, y;
        scanf("%d %d", &x, &y);

        if (x != y)
        {
            if (s[x-1] == 'A')
                a[y]++;
            else
                b[y]++;

            if (s[y-1] == 'A')
                a[x]++;
            else
                b[x]++;

            adj[x].push_back(y);
            adj[y].push_back(x);
        }
        else
        {
            if (s[x-1] == 'A')
                a[x]++;
            else
                b[x]++;

            adj[x].push_back(x);
        }
    }

    queue<int> q;

    for (int i = 1; i <= n; i++)
    {
        if (a[i] == 0 || b[i] == 0)
        {
            dead[i] = true;
            q.push(i);
        }
    }

    while (!q.empty())
    {
        int now = q.front();
        q.pop();

        for (auto& e : adj[now])
        {
            if (dead[e])
                continue;

            if (s[now-1] == 'A')
                a[e]--;
            else
                b[e]--;

            if (a[e] == 0 || b[e] == 0)
            {
                dead[e] = true;
                q.push(e);
            }
        }
    }

    int live = 0;

    for (int i = 1; i <= n; i++)
        if (!dead[i])
            live++;

    if (live > 0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 12676
#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<ll, ll>;
using namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H[i];

    int ans = 1;
    for (int i=1; i<N; ++i) {
        bool ok = true;
        for (int j=0; j<i; ++j) {
            if (H[j] > H[i]) ok = false;
        }
        ans += ok;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;
vector<ll> adj[100005];
ll vis[100005]={0};
ll ans[100005]={0};

int main()
{
	ll  n,m;
	ll i,j;
	cin>>n>>m;
	ll a,b;
	for(i=0;i<m;i++)
	{	cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	queue<ll> q;
	q.push(1);
	while(!q.empty())
	{
		ll v = q.front();
		q.pop();
		for(auto u: adj[v])
		{
			if(vis[u]==0)
			{
				vis[u]=1;
				ans[u] = v;
				q.push(u);
			}
		}
	}
	ll flag =0;
	for(i=2;i<=n;i++)
	{
		if(ans[i]==1)
			flag=1;
		if(ans[i]==0)
			flag= 2;
		
	}
	if(flag==2)
		cout<<"No"<<endl;
	else if(flag==0)
			cout<<"No"<<endl;
	else
	{
		cout<<"Yes"<<endl;
		for(i=2;i<=n;i++)
			cout<<ans[i]<<endl;
	}	



return 0;
}

Measured memory_bytes: 13780
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back

typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
//include  long long func(long long)
string solve(int ans){
    cout<<ans<<endl;
    string res;
    cin>>res;
    return res;
}

int main(){
    int n;
    cin >>n;
    int ans=0;
    
    vector<pair<int,bool>>data(3);
    string res = solve(0);
    data[0]=mp(0,res=="Male"?true:false);
    if(res=="Vacant"){return 0;}
    res = solve(n-1);
    data[1] = mp(n-1, res == "Male" ? true : false);
    if (res == "Vacant"){return 0;}
    data[2]=mp(0,true);
    while(res!="Vacant"){
        data[2].F = ((data[0].F+data[1].F+1) / 2);
        res=solve(data[2].F);
        if(res=="Male"){
            data[2].S=true;
        }else{
            data[2].S=false;
        }
        //前ずれない
       // clog<<(data[2].F-data[0].F)<<" "<<data[0].S<<" "<<data[2].S<<endl;
        if(((data[2].F-data[0].F)%2==1)==(data[2].S xor data[0].S)){
            data[0]=data[2];
        }else{
            data[1]=data[2];
        }
      //  clog<<data[0].F<<" "<<data[1].F<<endl;
    }
    return 0;
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
int s_count(string s,string t){
    int ans=0;
    for(char c='a';c<='z';c++){
        bool founds=false,foundt=false;
        for(int i=0;i<s.length();i++){
            if(s[i]==c){
                founds=true;
            }
        }
        for(int i=0;i<t.length();i++){
            if(t[i]==c){
                foundt=true;
            }
        }
        if(founds&&foundt)ans++;
    }
    return ans;
}
int main(){
	int n;string s;cin>>n>>s;int ans=0;
	for(int i=0;i<=n;i++){
		int tmp=s_count(s.substr(0,i),s.substr(i));
		ans=max(ans,tmp);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000

int dp[3300][3300];

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

    for (int i = 1; i <= s.size(); i++) {
        for (int j = 1; j <= t.size(); j++) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
            }
        }
    }

    vector<char> ans;
    int i = s.size(), j = t.size();
    while (i > 0 && j > 0) {
        if (dp[i - 1][j] == dp[i][j]) {
            i--;
        } else if (dp[i][j - 1] == dp[i][j]) {
            j--;
        } else {
            ans.push_back(s[i - 1]);
            i--;
            j--;
        }
    }

    for (int i = ans.size() - 1; i >= 0; i--) {
        cout << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 39168
#include <bits/stdc++.h>
#define N 1000000007;

using namespace std;
int main()
{
 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 int x;
 cin>>x;
 if(x>=30)
    cout<<"Yes";
 else
    cout<<"No";


 return(0);
}


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

int main()
{
  long long int N, A, B;
  cin >> N >> A >> B;
  long long int ans = 1LL << 60;
  if ((max(A, B) - min(A, B)) % 2 == 0)
  {
    ans = (max(A, B) - min(A, B)) / 2;
  }
  else
  {
    long long int ans1, ans2 = 0;
    ans1 = min(A, B) + (max(A, B) - min(A, B) - 1) / 2;
    ans2 = N - max(A, B) + 1 + (max(A, B) - min(A, B) - 1) / 2;
    ans = min(min(ans, ans1), ans2);
  }
  cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N-1; i++) {
    int a;
    cin >> a;
    vec.at(a-1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 4044
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.annotation.tailrec
import scala.collection.mutable
import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map(converter)
  }

  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))

    val memo = mutable.HashSet.empty[String]
    val n = get[Int]

    @tailrec
    def valid(rest: Int, last: String): Boolean = {
      if (rest == 0) {
        true
      } else {
        val w = get[String]
        if (memo.contains(w)) {
          false
        } else if(last.last != w.head) {
          false
        } else {
          memo += w
          valid(rest - 1, w)
        }
      }
    }

    val w = get[String]
    memo += w

    out.println(
      if (valid(n - 1, w)) {
        "Yes"
      } else {
        "No"
      }
    )

    out.flush()
  }
}

Measured memory_bytes: 27068
#include<cstdio>
#define MAX 105
using namespace std;
int h,w;
char map[MAX][MAX];
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1}; 
void dfs(int sx,int sy,char ch)
{
//	char ch=map[sx][sy];
	map[sx][sy]='0';
	for(int i=0;i<4;i++)
	{
		int nx=sx+dx[i];
		int ny=sy+dy[i];
		if(nx>=0&&nx<h&&ny>=0&&ny<w&&map[nx][ny]==ch)
		dfs(nx,ny,ch);
	}
	return ;
}
int main(void)
{
	while(scanf("%d%d",&h,&w)==2)
	{
		if(h==0&&w==0)
		break;
		for(int i=0;i<h;i++)
		scanf("%s",&map[i]);
		int res=0;
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				if(map[i][j]!='0')
				{
//					printf("\n");
					dfs(i,j,map[i][j]);
//					for(int k=0;k<h;k++)
//					printf("%s\n",map[k]); 
					res++;
				}
			}
		}
		printf("%d\n",res);
	}
	return 0;
}

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

int ds = 6;

void dprint( int a[] ){
	for( int i = 0; i < ds; i++ ) {
		cout << a[i] << ":";
	}
	cout << endl;

	return; 
}

void dsort( int a[], int i0, int i1, int i2, int i3 ) {
	int ta[] = { a[i0], a[i1], a[i2], a[i3] };
	int min = ta[0];
	for( int i = 0; i < 4; i++ ) {
		if( min > ta[i] ) {
			min = ta[i];
		}
	}

	int t = 0;
	while( true ) {
		if( a[i0] == min ) {
			break;
		}
		t = a[i0];a[i0]=a[i1];a[i1]=a[i2];a[i2]=a[i3];a[i3]=t;
	}

	return;
}

bool dcomp( int a[], int b[] )
{
	for( int i = 0; i < ds; i++ ) {
		if( a[i] != b[i] ) {
			return false;
		}
	}

	return true;
}

bool drollcomp( int a[], int b[], int i0, int i1, int i2, int i3 )
{
	bool ret = false;
	int t = 0;
	for( int i = 0; i < 4; i++ ) {
		t = b[i0];b[i0]=b[i1];b[i1]=b[i2];b[i2]=b[i3];b[i3]=t;
		ret = dcomp( a, b );
		if( ret == true ) {
			break;
		}
	}
	return ret;
}

bool dcheck( int a[], int b[] ) {
	bool ret = false;

	ret = dcomp( a, b );
	if( ret == true ) {
		return ret;
	}

	ret = drollcomp( a, b, 0, 1, 5, 4 );
	if( ret == true ) {
		return ret;
	}

	ret = drollcomp( a, b, 0, 3, 5, 2 );
	if( ret == true ) {
		return ret;
	}

	ret = drollcomp( a, b, 1, 2, 4, 3 );
	if( ret == true ) {
		return ret;
	}

	return ret;
}

int main()
{
	int n, dx[ds], dbuff[100][ds];
	bool ret = false;

	cin >> n;

	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j < ds; j++ ) {
			cin >> dx[j];
		}
		dsort( dx, 0, 1, 5, 4 );
		dsort( dx, 0, 3, 5, 2 );
		dsort( dx, 1, 2, 4, 3 );

		for( int j = 0; j < i; j++ ) {
			ret = dcheck( dx, dbuff[j] );
			if( ret == true ) {
				break;
			}
		}
		if( ret == true ) {
			break;
		}

		for( int j = 0; j < ds; j++ ) {
			dbuff[i][j] = dx[j];
		}
	}

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

	return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
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(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int h, w, k;
    cin >> h >> w >> k;
    vector<string> a(h);
    rep(i, h) cin >> a[i];
    int ans = 0;
    rep(s, 1<<h) rep(t, 1<<w) {
        int cnt = 0;
        rep(i, h) rep(j, w) {
            if (s >> i & 1) continue;
            if (t >> j & 1) continue;
            if (a[i][j] == '#') cnt++;
        }
        if (cnt == k) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = 800 * n;
		int y = ((n - n%15) /15) * 200;

		System.out.println((x-y));
	}
}


Measured memory_bytes: 21712
x,y,a,b,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

p = p[:x]
q = q[:y]

s = p+q+r
s.sort(reverse=True)

print(sum(s[:(x+y)]))

Measured memory_bytes: 22560
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u64 = read();
    let b: u64 = read();
    let k: u64 = read();

    if k <= a {
        println!("{} {}", a - k, b);
    } else if k <= a + b {
        println!("{} {}", 0, a + b - k);
    } else {
        println!("{} {}", 0, 0);
    }
}


Measured memory_bytes: 4476
import java.util.*;

class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();

        if (N % 2 == 0) {
            if (N < 10) {
                System.out.println(0);
                System.exit(0);
            }

            long ans = 0;
            long div = 10;
            while (div <= N) {
                ans += (N/div);
                div *= 5;
            }

            System.out.println(ans);
        } else {
            System.out.println(0);
        }

    }
}


Measured memory_bytes: 21716
#include  <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
typedef long long ll;
using namespace std;
int main()
{
    ll n;
    cin>>n;
    double x=n/2;

    if(n%2==1)
        cout<<(x+1)/n;
    else
        cout<<0.5;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int l,a,b,c,d,e,max,s,ss,sss;
	max=-1;
	scanf("%d",&l);
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	s=a/c;
	ss=b/d;
	if(a%c!=0){
		s++;
	}
	if(b%d!=0){
		ss++;
	}
	if(s<ss){
		sss=l-ss;
		printf("%d\n",sss);
	}
	else{
		sss=l-s;
		printf("%d\n",sss);
	}
	return 0;
}
	

Measured memory_bytes: 1024
object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  val str = readLine.trim.toCharArray.map{_ == 'B'}
  val count = str.map{if (_) 1 else 0: Long}
  for (i ← 1 until count.length){
    count(i) += count(i - 1)
  }
  println(
    str.indices.map{i ⇒
      if (!str(i)) count(i)
      else 0
    }.sum
  )
  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 40288
#include <iostream>

using namespace std;

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

	int ans = 0;
	for (int a = 0; a <= A; ++a) {
		for (int b = 0; b <= B; ++b) {
			for (int c = 0; c <= C; ++c) {
				if (500 * a + 100 * b + 50 * c == X) {
					++ans;
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 55 + 3;
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
#endif
	string a, b;
	cin >> a >> b;
	int res = 0;
	for (int i = 0; i < 3; ++i) 
		res += a[i] == b[i];
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
package main
import "fmt"

func main() {
	var a, b, n int64
	fmt.Scan(&a, &b, &n)

	var x int64
	if n < b {
		x = n
	} else {
		x = b-1
	}

	ans := a*x/b - a*(x/b)
	fmt.Println(ans)
}

Measured memory_bytes: 1748
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
#define MOD  1000000007


int main(int argc, char const *argv[]) {
  ll n,ab[100010],ans=0,sum=0;
  std::cin >> n;
  for(int i=0; i<n; i++){
    ll s,t;
    std::cin >> s >> t;
    sum-=t;
    ab[i]=s+t;
  }
  sort(ab,ab+n,std::greater<ll>());
  
  for(int i=0; i<n; i++){
    if(i%2==0){
      sum+=ab[i];
      //std::cout << "sum+=" << ab[i]<< '\n';
    }
  }
  std::cout << sum << '\n';
  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
    long long c[51];
    long long k,a,b;
    int j=0;
    scanf("%lld",&k);
    a=k/50;
    b=k%50;
    cout<<"50"<<endl;
    if(k%50==0)
	{
        for(long long i=50+a-1;i>=a;i--)
            cout<<i<<" ";
    }
    else
	{
        for(long long i=50+a;i>=a;i--)
		{
            c[j]=i;
            j++;
        }
        for(long long i=0;i<51;i++)
		{
            if(i==b)
                continue;
            else
                cout<<c[i]<<" ";
        }
    }
    cout<<endl;
    return 0;
}
/*
    49 48 47.........0    K=0
50     48 47.........0    K=1
50  49    47.........0    K=2
    50 49 48.........1    K=50
*/

Measured memory_bytes: 256
import sys
N,K=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())

mod=10**9+7

naka=[ 0 for _ in range(N)]
soto=[ 0 for _ in range(N)]

for i in range(N):
	for j in range(i+1,N):
			if A[i]>A[j]:
				naka[i]+=1
A.sort()

v=0
for i in range(N-1):
	if A[i]<A[i+1]:
		v=i+1
		soto[i+1]=v
	else:
		soto[i+1]=v		


print (sum(naka)*K+sum(soto)*K*(K-1)/2)%mod

Measured memory_bytes: 32620
from itertools import accumulate
N, Q = map(int, input().split())
S = input()
res = [0] * N
for i in range(N - 1):
    if S[i] + S[i + 1] == "AC":
        res[i + 1] = 1
resm = [0] + list(accumulate(res))
for i in range(Q):
    ans = 0
    l, r = map(int, input().split())
    if S[l] == "C":
        ans -= 1
    ans = resm[r] - resm[l]
    print(ans)

Measured memory_bytes: 54944
#include <bits/stdc++.h>
#define ld long double
#define ll long long
#define ull unsigned ll
#define pll pair<ll, ll>
#define itr(a) begin(a), end(a)
#define pb push_back
#define x first
#define y second
#define endl '\n'
#define FAST cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define FILES(namein, nameout) freopen(namein, "r", stdin); freopen(nameout, "w", stdout);
#define M 1000000007
#define N 200000
#define INF 101111111111111
#define PI 3.1415926535897932384626433
using namespace std;
const ll EPS = 10000000;
main(){
	FAST;
	ll a, b, x;	
	cin >> a >> b >> x;
	ll vol = a*a*b;
	ld xs = a*b;
	ld xx = ((ld)x)/((ld)a);
	if(2*x == vol){
		printf("45.0\n");
	}else if(x == vol){
		printf("0.0\n");
	}else if(x == 0){
		printf("90.0\n");
	}else if(2*x < vol){
		ld xa = (((ld)2)*xx)/((ld)b);
		ld ang = atan(((ld)b)/xa);
		ld res = ang;
		cout << fixed << setprecision(10) << (res * 180.0) / PI << endl;
	}else if(2*x > vol){
		ld xbsb = 2*xx/((ld)a);
		ld xsb = xbsb - ((ld)b);
		ld xz = ((ld)b) - xsb;
		ld tana = ((ld)a)/(xz);
		ld ang = PI/((ld)2) - atan(tana);//atan((tana * PI)/((ld)180));
		cout << fixed << setprecision(10) << (ang * ((ld)180)) / PI << endl;
	}
}

Measured memory_bytes: 256