akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

struct Edge{
  int to;
  ll cost;
  Edge(int t, int c){
    to = t;
    cost = c;
  }
};

typedef pair<ll, ll> P;

int d[10005];
vector<Edge> G[10005];

void dijkstra(int s){
  ll inf = LLONG_MAX / 100;
  priority_queue<P, vector<P>, greater<P>> que; 
  for(int i = 0; i < 10005; i++){
    d[i] = inf;
  }

  d[s] = 0;
  que.push(P(0, s));
  while(que.size()){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(int i = 0; i < G[v].size(); i++){
      Edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
	d[e.to] = d[v] + e.cost;
	que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main(){
  int n, u, k, c, v;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> u >> k;
    for(int j = 0; j < k; j++){
      cin >> v >> c;
      G[u].push_back(Edge(v, c));
    }
  }

  dijkstra(0);
  for(int i = 0; i < n; i++){
    cout << i << " " << d[i] << endl;
  }
}



Measured memory_bytes: 12140
#include <stdio.h>

#define SIZE 100000

typedef struct {
	int time;
	int name[100];
} Process;

int head, tail;
Process Q[SIZE];

Process dequeue() {
	int x = head;
	if (head == SIZE-1) {
		head = 0;
	}
	else {
		head++;
	}
	return Q[x];
}

void enqueue(Process x) {
	Q[tail] = x;
	if (tail == SIZE-1) {
		tail = 0;
	}
	else {
		tail++;
	}
}


int main() {
	int i, n, q, time = 0;
	Process cell;

	scanf("%d %d", &n, &q);

	for (i = 0; i < n; i++) {
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].time);
	}

	head = 0;
	tail = n;

	while (head != tail) {
		cell = dequeue();
		if (cell.time <= q) {
			time += cell.time;
			printf("%s %d\n", cell.name, time);
		}
		else {
			cell.time -= q;
			time += q;
			enqueue(cell);
		}
	}

	return 0;
}

Measured memory_bytes: 40052
#include<stdio.h>
#include<stdlib.h>

int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a<=b){
    if(b<=c){
      printf("%d %d %d\n",a,b,c);
    }else if(a<=c){
      printf("%d %d %d\n",a,c,b);
    }else if(c<=a){
      printf("%d %d %d\n",c,a,b);
    }
  }else if(b<=a){
    if(a<=c){
      printf("%d %d %d\n",b,a,c);
    }else if(b<=c){
      printf("%d %d %d\n",b,c,a);
    }else if(c<=b){
      printf("%d %d %d\n",c,b,a);
    }
  }else if(c<=a){
    if(a<=b){
      printf("%d %d %d\n",c,a,b);
    }else if(c<=b){
      printf("%d %d %d\n",c,b,a);
    }else if(b<=c){
      printf("%d %d %d\n",b,c,a);
    }
  }
  return 0;
}



Measured memory_bytes: 2056
sx, sy, tx, ty = map(int,input().split())

n = tx - sx
m = ty - sy

ans = 'R' * n + 'U' * m + 'L' * n + 'D' * m + 'L' + 'U' * (m+1) + 'R' * (n+1) + 'D' + 'R' + 'D' * (m+1) + 'L' * (n+1) + 'U'
print(ans)

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> h(M);
  for(int i = 0; i < M; i++) cin >> h.at(i);
  int play = N;
  for(int i = 0; i < M; i++) {
    play -= h.at(i);
  }
  if(play < 0) play = -1;
  
  cout << play << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ull n, x;
	vector<ull> patty;
	vector<ull> bsize;

	cin >> n >> x;

	patty.push_back(1);
	bsize.push_back(1);
	for ( int i = 0 ; i < 50 ; i++ ){
		patty.push_back(2 * patty[i] + 1);
		bsize.push_back(2 * bsize[i] + 3);
	}
	ll res = 0;
	while ( n > 0 ){
		if ( x == (bsize[n] + 1LL) / 2LL ){
			res += patty[n-1] + 1LL;
			n = 0;
			x = 0;
		}else if ( x > bsize[n] - n ){
			res += patty[n];
			n = 0;
			x = 0;
		}else if ( x < (bsize[n]+1LL) / 2LL ){
			x--;
			n--;
		}else{
			x -= (bsize[n]+1LL) / 2LL;
			res += 1LL + patty[n-1];
			n--;
		}
	}
	if ( n == 0 && x == 1 )
		res++;
	cout << res << "\n";

	return 0;
}


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

using namespace std;

int main(){
    int N;
    cin>>N;
    int a;
    int ans=0;
    for(int i=0;i<N;i++){
        cin>>a;
        if(a==1){
            ans++;
        }
        for(int j=2;j<=sqrt(a);j++){
            if(a%j==0){
                ans++;
                break;
            }
        }
    }
    ans=N-ans;
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
    register int i, ans = 0;
    
    string str1, str2;
    
    cin >> str1 >> str2;
    
    for(i = 0; i < str1.size(); i++)
    {
        if(str1[i] != str2[i])
            ans++;
    }
    
    cout << ans;
    
    
   return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }

    //cout << sum << endl;

    // 累積わ
    vector<ll> s(n+1, 0);
    rep(i, n) {
        s[i+1] = s[i] + a[i];
        //cout << s[i+1] << endl;
    }

    ll tmp = sum/2;
    int over = 0;
    bool flag = true;
    rep(i, n) {
        if(flag && s[i+1] > tmp) {
            flag = false;
            over = i+1;
            //cout << over << endl;
        }
    }

    ll tmp_a = abs(tmp - s[over]);
    ll tmp_b = abs(tmp - s[over-1]);


    ll ans = 0;
    if(tmp_a <= tmp_b) {
        ans = abs(sum-s[over]-s[over]);
    } else {
        ans = abs(sum-s[over-1]-s[over-1]);
    }

    cout << ans << endl;

    return 0;


}

Measured memory_bytes: 3328
#include<iostream>
#include <algorithm> // sort
using namespace std;

int a[100010];

int main(){

 int N, K;
 cin >> N >> K;

 for (int i=0; i <N; i++) cin >> a[i];
 sort (a, a+N);
 
 long long SUM = 0;

 
 for (int i=0; i<K; i++) SUM += a[N-K+i];
 cout << SUM << endl;

return 0;
} 


Measured memory_bytes: 256
#include <stdio.h>

char hantei(double);

int main(void)
{
  double leyes[40], reyes[40];
  char leye[40], reye[40];
  int i = 0;
  int la=0,lb=0,lc=0,ld=0;
  int ra=0,rb=0,rc=0,rd=0;

  while(scanf("%lf %lf",&leyes[i],&reyes[i]) != EOF) 
    {
      leye[i] = hantei(leyes[i]);
      if(leye[i] == 'A') la++;
      else if(leye[i] == 'B') lb++;
      else if(leye[i] == 'C') lc++;
      else if(leye[i] == 'D') ld++;
      
      reye[i] = hantei(reyes[i]);
      if(reye[i] == 'A') ra++;
      else if(reye[i] == 'B') rb++;
      else if(reye[i] == 'C') rc++;
      else if(reye[i] == 'D') rd++;
      
      i++;
    }
  printf("%d %d\n",la,ra);
  printf("%d %d\n",lb,rb);
  printf("%d %d\n",lc,rc);
  printf("%d %d\n",ld,rd);

  return 0;
}

char hantei(double eye)
{
  char power;

  if(eye >= 1.1) power = 'A';
  else if(eye >= 0.6) power = 'B';
  else if(eye >= 0.2) power = 'C';
  else power = 'D';

  return power;
}

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

int main(){
	string s;
	cin >> s;
	int eo[256] = {};
	for(int c: s){
		eo[c] = 1-eo[c];
	}
	bool yes = true;
	for(int i='a'; i<='z'; i++){
		if(eo[i] == 1){
			yes = false;
			break;
		}
	}
	if(yes){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9,MOD=INF+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  std::vector<int> w(N),ww(N);
  w[0]=v[0];
  for(int i=1;i<N;i++)w[i]=__gcd(w[i-1],v[i]);
  ww[N-1]=v[N-1];
  for(int i=N-2;i>=0;i--)ww[i]=__gcd(ww[i+1],v[i]);
  int ans=0;
  for(int i=0;i<N-2;i++)ans=max(ans,__gcd(w[i],ww[i+2]));
  int ans1=v[1];
  for(int i=2;i<N;i++)ans1=__gcd(ans1,v[i]);
  int ans2=v[N-2];
  for(int i=N-3;i>=0;i--)ans2=__gcd(ans2,v[i]);
  cout<<max({ans,ans1,ans2})<<endl;
}


Measured memory_bytes: 2560
from collections import deque


H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

INF = 10 ** 6
visited = [[10 ** 6] * W for _ in range(H)]
dy = [-1, 1, 0, 0]
dx = [0, 0, -1, 1]


def bfs(y, x):
    q = deque()
    q.append((y, x))

    while len(q):
        y, x = q.popleft()

        for i in range(4):
            ny = y + dy[i]
            nx = x + dx[i]

            if (0 <= ny < H and 0 <= nx < W and
                visited[ny][nx] == INF and S[ny][nx] != '#'):

                q.append((ny, nx))
                visited[ny][nx] = visited[y][x] + 1

ans = 0
for y in range(H):
    for x in range(W):
        if S[y][x] != "#":
            visited = [[10 ** 6] * W for _ in range(H)]
            visited[y][x] = 0
            bfs(y, x)
            for i in range(H):
                for j in range(W):
                    if visited[i][j] != INF:
                        ans = max(ans, visited[i][j])

print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> point(N, K);
    for (int i = 0; i < Q; ++i) {
        int a;
        cin >> a;
        a--;
        point[a]++;
    }
    for (int i = 0; i < N; ++i) {
        point[i] -= Q;
    }

    for (int i = 0; i < N; ++i) {
        if (point[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n;
int a[20];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	int maxn=-1,ans=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]>=maxn)
		{
			++ans;
			maxn=a[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;
class P
{
    static void Main()
    {
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        List<int> reacheableFromS = new List<int>();
        List<int> reacheableFromE = new List<int>();
        for (int i = 0; i < nm[1]; i++)
        {
            int[] ab = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
            if (ab[0] == 1) reacheableFromS.Add(ab[1]);
            if (ab[1] == nm[0]) reacheableFromE.Add(ab[0]);
        }
        if (reacheableFromS.Intersect(reacheableFromE).Count() == 0) Console.WriteLine("IMPOSSIBLE");
        else Console.WriteLine("POSSIBLE");
    }
}

Measured memory_bytes: 21340
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;
constexpr size_t invalid = ~0ull;

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

  ll k;
  ll x;
  cin >> k >> x;
  auto ans = (500 * k >= x);
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long MOD = 1e9 + 7;

int main() {
    ll A, B, X;
    cin >> A >> B >> X;
    ll aa = (A == 0 ? 0 : ((A - 1) / X) + 1);
    ll bb = (B / X) + 1;
    cout << bb - aa << endl;
}

Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		loop:
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			Integer[] a = new Integer[n];
			Integer[] b = new Integer[n];
			for (int i = 0; i < n; i++)
				a[i] = scanner.nextInt();
			for (int i = 0; i < n; i++)
				b[i] = scanner.nextInt();
			Arrays.sort(a, Collections.reverseOrder());
			Arrays.sort(b, Collections.reverseOrder());
			n /= 2;
			for (int i = 0; i < n; i++) {
				if (a[i * 2] > b[i]) {
					System.out.println((i * 2) + 1);
					continue loop;
				}
			}
			System.out.println("NA");
		}
	}
}

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

int main() {
  int N;
  cin >> N;
  int a,b;
  int c=0;
  for (int i=0;i<N;i++){
    cin >> a>>b;
    c+=(b-a+1);
  }
  cout << c<<endl;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> S(N);
  for(int i=0;i<N;i++){
    cin>>S.at(i);
  }
  sort(S.begin(),S.end());
  if(N==K) cout<<S.at(N-1)-S.at(0)<<endl;
  else{
    vector<int> T(N-K+1);
  for(int i=0;i<N-K+1;i++){
    T.at(i)=S.at(i+K-1)-S.at(i);
  }
  sort(T.begin(),T.end());
  cout<<T.at(0)<<endl;
}
}
  

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

std::vector<int> graph[200000];
bool visited[200000];

int countPeople(int start)
{
    visited[start] = true;

    int result = 1;
    for (int next : graph[start])
        if (!visited[next])
            result += countPeople(next);
    
    return result;
}

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

    for (int i = 0; i < m; ++i)
    {
        int u, v;
        scanf("%d %d", &u, &v);
        graph[u-1].push_back(v-1);
        graph[v-1].push_back(u-1);
    }

    int answer = 0;

    for (int i = 0; i < n; ++i)
        if (!visited[i])
            answer = std::max(countPeople(i), answer);
        
    printf("%d", answer);

    return 0;
}

Measured memory_bytes: 24260
integer N,K
integer cnt
read*,N,K
if(K>(N-1)*(N-2)/2)then
  print"(i0)",-1
  stop
endif

print"(i0)",(N-1) +((N-1)*(N-2)/2 - K)
do i=1,n-1
  print"(i0,A,i0)",i," ",N
end do

cnt=0

if( cnt==(N-1)*(N-2)/2 -K )then
  stop
end if

do i=1,n-2
  do j=i+1,n-1
    print"(i0,A,i0)",i," ",j
    cnt=cnt+1
    if( cnt==(N-1)*(N-2)/2 -K )then
      stop
    end if
  end do
end do
end

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

using namespace std;

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

    string s[n];
    int p[n];
    int cnt = 1;
    int num[101] = {};

    for (int i = 0; i < n; i++) {
        cin >> s[i] >> p[i];
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i != j) {
                if (s[i] > s[j]) {
                    cnt++;
                }
                else if (s[i] == s[j]) {
                    if (p[i] < p[j]) {
                        cnt++;
                    }
                }
            }
        }
        num[cnt] = i+1;
        cnt = 1;
    }

    for (int i = 1; i <= n; i++) {
        cout << num[i] << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

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

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 998244353
#define F first
#define S second

int gcd(int a, int b) {

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

int main() {

// freopen("input.in","r",stdin);
// freopen("output.out","w",stdout);

  int x;
  cin >> x;
  cout << 360/gcd(360, x) << endl;

  return 0;
}


Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG

#include <unistd.h>
#include <stdlib.h>

void get_nums(int *array, char *s, int count)
{
    int num;
    int i;
    int j;
    
    i = -1;
    while (s[++i] != 10)
    {
        if (s[i] != 32)
        {
            num = 0;
            while ('0' <= s[i] && s[i] <= '9')
            {
                num = num * 10 + s[i++] - '0';
                if (!s[i])
                {
                    array[count++] = num;
                    return ;                    
                }
            }
            array[count++] = num;
            i--;
        }
    }  
}

void get_stirngs(char *s, char *tmp, int pass_flag, int count)
{
    int i;
    int j;
    
    i = -1;
    while (count < pass_flag)
    {
        while (tmp[++i] != 10)
            ;
        count++;
    }
    j = 0;
    while (tmp[++i] != 10)
    {
        while (31 < tmp[i] && tmp[i] < 127)
        {
            s[j++] = tmp[i++];
            if (!tmp[i])
            {
                s[j] = 0;
                return ;                    
            }
        }
        s[j] = 0;
        i--;
    }  
}

void get_ans(int x, int y, char *tmp)
{
    int i;
    int j;
    char s[x + 1];
    
    j = -1;
    while (++j < y + 2)
    {
        if (0 < j  && j <= y)
            get_stirngs(s, tmp, j, 0);
        i = -1;
        while (++i < x + 2)
        {
            if (0 < j  && j <= y && 0 < i && i <= x)
                write(1, &s[i - 1], 1);
            else
                write(1, "#", 1);
        }
        write(1, "\n", 1);
    }
}

char *create_array(char *s, char *new_arr, char *t, int size)
{
    int i;
    int j;
    
    i = -1;
    while (s[++i])
        new_arr[i] = s[i];
    free(s);
    j = -1;
    while (++j < size)
        new_arr[i++] = t[j];   
    new_arr[i] = 0;
    return (new_arr);
}

char *get_data(char *s)
{
    int size;
    int sum_size;
    char t[1000];
    char *new_arr;
    
    sum_size = 0;
    while ((size = read(0, t, 1000)))
    {
        if (size == -1)
            return (NULL);
        sum_size += size;
        if (!(new_arr = (char*)malloc(sum_size + 1)))
            return (NULL);
        s = create_array(s, new_arr, t, size);
    }
    return (s);
}

int main(void){
    int num[2];
    char *s;
    
    s = malloc(1);
    s = get_data(s);
    
    //printf("%s\n\n",s);
    //write(1,s,6);
    get_nums(num, s, 0);
    //printf("num[0]=%d,num[1]=%d\n",num[0],num[1]);
    get_ans(num[1],num[0], s);
    return (0);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin >> n >> l;
  std::vector<string> s(n);
  for (size_t i = 0; i < n; i++) {
    cin >> s[i];
  }
  sort(s.begin(),s.end());
  string ans;
  for (size_t i = 0; i < n; i++) {
    ans = ans+s[i];
  }
  cout << ans;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i=0;i<m;++i) cin >> a[i];
  
  int sum=0;
  for (int i=0;i<m;++i){
    sum+=a[i];
  }
   
  if (n-sum<0) cout << -1 << endl;
  else cout << n-sum << endl;
}

Measured memory_bytes: 3664
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include "bits/stdc++.h"
using namespace std;

// #define int long long

signed main(void)
{
  int num; // num
  // num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  num = numeric_limits<int>::max(); // min
  int n;
  int k;
  array<int, 100000> a;

  cin>> n >> k;
  for(auto it = a.begin(); it < a.begin() + n; ++it){
    cin >> *it;
  }

  sort(a.begin(),a.begin() + n,greater<int>());

  for(auto it = a.begin(); it + k - 1< a.begin() + n; ++it)
    num = min(num, *it - *(it + k - 1));

  cout << num << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
const int N = 2505;
const int MAX_ITER = 2505;
const ll INF = 1e18;

int n, m;
ll p;
vector <pair <int, ll> > nb[N], rev_nb[N];
bool vis[N], in_path[N], connected[N];

void DFS_connected(int v)
{
    connected[v] = true;
    for(auto t: rev_nb[v])
        if(!connected[t.first])
            DFS_connected(t.first);
}

vector <pair <int, ll> > path;
bool infinite = false;
void DFS_check_infinite(int v, ll w = 0)
{
    vis[v] = true;
    path.pb({v, w});
    in_path[v] = true;
    for(auto t: nb[v])
    {
        if(!vis[t.first])
            DFS_check_infinite(t.first, t.second);
        else if(in_path[t.first])
        {
            ll sum = t.second;
            for(int j = (int)path.size() - 1; j >= 0; j--)
            {
                if(path[j].first == t.first)
                    break;
                sum += path[j].second;
            }
            if(sum > 0 && connected[v])
                infinite = true;
        }
    }

    path.pop_back();
    in_path[v] = false;
}

ll dp[N][MAX_ITER];
void solve(int time)
{
    for(int i = 1; i <= n; i++)
    {
        dp[i][time] = dp[i][time - 1];
        for(auto t: rev_nb[i])
            dp[i][time] = max(dp[i][time], dp[t.first][time - 1] + t.second);
    }
}

ll dist[N];
bool neg_cycle()
{
    dist[1] = 0;
    for(int i = 2; i <= n; i++)
        dist[i] = INF;
    for(int time = 1; time < n; time++)
    {
        for(int i = 1; i <= n; i++)
            for(auto t: rev_nb[i])
                dist[i] = min(dist[i], dist[t.first] - t.second);
    }

    for(int i = 1; i <= n; i++)
        for(auto t: rev_nb[i])
            if(dist[t.first] - t.second < dist[i] && connected[i] && vis[i])
            {
                cerr << i << " " << t.first << endl;
                return true;
            }

    return false;
}

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

    int u, v, c;

    cin >> n >> m >> p;
    for(int i = 1; i <= m; i++)
    {
        cin >> u >> v >> c;
        nb[u].pb({v, c - p});
        rev_nb[v].pb({u, c - p});
    }

    DFS_connected(n);
    DFS_check_infinite(1);
    if(infinite || neg_cycle())
    {
        cout << -1 << endl;
        return 0;
    }

    dp[1][0] = 0;
    for(int i = 2; i <= n; i++)
        dp[i][0] = -INF;

    ll ans = 0;
    for(int i = 1; i < n; i++)
    {
        solve(i);
        ans = max(ans, dp[n][i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 49792
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   :
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 2e5 + 5, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int n, m;
ll x, arr[N] = { }, sum, tot;
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	cin >> n >> m;
	lp(i,1,n)
	{
		cin >> x;
		arr[i] = (x * (i - 1)) - sum;
		sum += x;
	}
	sum = 0;
	lp(i,1,m)
	{
		cin >> x;
		tot += ((x * (i - 1)) - sum);
		tot %= mod;
		sum += x;
	}
	sum = 0;
	lp(i,1,n)
	{
		sum += (((arr[i] % mod) * tot) % mod);
		sum %= mod;
	}
	f(sum);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    long long a, b;
    cin >> n >> a >> b;

    if (n < a + b - 1 || n > a * b)
    {
        cout << -1 << endl;
        return 0;
    }

    vector<int> ans;
    for (int i = n; i > 0; i -= a)
    {
        for (int j = a - 1; j >= 0; j--)
        {
            if (i - j > 0)
            {
                ans.push_back(i - j);
            }
        }
    }

    int lds = 1;
    for (int i = 0; i < n - 1; i++)
    {
        if (ans[i] > ans[i + 1])
        {
            lds++;
        }
    }

    if (lds != b)
    {
        for (int i = n - 2; i >= 0; i--)
        {
            if (ans[i] < ans[i + 1])
            {
                lds++;
            }
            if (lds == b)
            {
                sort(ans.begin() + i, ans.end());
                reverse(ans.begin() + i, ans.end());
                break;
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        if (i)
            cout << " ";
        cout << ans[i];
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 3440
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

int n,S,T;

vector<int> g1[200005],g2[200005];

int dist1[200005],dist2[200005],par[200005];

int getd2(int a,int b){
  if(dist2[a]>dist2[b]) swap(a,b);
  if(dist2[a]-dist2[b]>2) return 3;
  int res=0;
  while(dist2[b]>dist2[a]) b=par[b],++res;
  while(res<=2 && a!=b){
    res+=2;
    a=par[a];b=par[b];
  }
  return res;
}

void dfs(int v,int p){
  par[v]=p;
  for(auto to:g2[v]){
    if(to==p) continue;
    dist2[to]=dist2[v]+1;
    dfs(to,v);
  }
}

void dfs2(int v,int p){
  if(dist1[v]>dist2[v]){
    dist1[v]=-1;
    return;
  }
  if(dist1[v]==dist2[v]) return;
  for(auto to:g1[v]){
    if(to==p) continue;
    dist1[to]=dist1[v]+1;
    dfs2(to,v);
  }
}

int main(){
  cin>>n>>S>>T;
  --S;--T;
  REP(i,n-1){
    int a,b;scanf("%d%d",&a,&b);--a;--b;
    g1[a].pb(b);
    g1[b].pb(a);
  }
  REP(i,n-1){
    int a,b;scanf("%d%d",&a,&b);--a;--b;
    g2[a].pb(b);
    g2[b].pb(a);
  }

  dfs(T,-1);

  memset(dist1,-1,sizeof(dist1));
  dist1[S]=0;
  dfs2(S,-1);

  int res=0;
  REP(i,n) if(~dist1[i] && dist1[i]<dist2[i]){
    for(auto to:g1[i]){
      int d=getd2(i,to);
      if(d>2){
        puts("-1");
        return 0;
      }
    }
  }
  REP(i,n) if(~dist1[i]) chmax(res,dist2[i]*2);
  cout<<res<<endl;

  return 0;
}





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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

lli dp[100001]; // i 円を引き出す最小の手数

int main() {
    lli n;
    cin1(n);

    // 1円
    REP(i,0,n+1) {
        dp[i] = i;
    }

    // 6系
    lli x = 1;
    REP(i,6,n+1) {
        if (i >= x*6)
            x *= 6;
        dp[i] = min(dp[i], dp[i-x]+1);
    }
    // 9系
    x = 1;
    REP(i,9,n+1) {
        for (lli j = 1; j <= n; j *= 9) {
            if (i-j < 0)
                break;
            dp[i] = min(dp[i], dp[i-j]+1);
        }
    }
    //REP(i,0,n+1) {
    //    cout2(i,dp[i]);
    //}
    cout << dp[n] << endl;
}


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

ll N, D[51];

int main(void) {
  cin >> N;
  D[0] = 0;
  REP(i, 1, N + 1) cin >> D[i];
  N++;

  if(N > 24) {
    cout << 0 << endl;
  } else {
    vector<ll> d(N);
    vector<ll> cnt(25);
    ll ans = 0;
    REP(i, 0, 1LL << N) {
      bool f = true;
      REP(j, 0, 25) cnt[j] = 0;
      REP(j, 0, N) {
        d[j] = ((i & (1LL << j)) == 0 ? D[j] : 24 - D[j]);
        if(cnt[d[j]] > 0) {
          f = false;
          break;
        }
        cnt[d[j]]++;
      }
      if(!f) continue;

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

      ll s = (1LL << 60);
      REP(j, 0, N) s = min(s, min(abs(d[(j + 1) % N] - d[j]), 24 - abs(d[(j + 1) % N] - d[j])));

      ans = max(ans, s);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int carry(int n, int k, int w[], int p) {
    int i, j=0;
    int sum;

    for(i=0; i<k; i++) {
        sum=0;
        while(sum+w[j]<=p) {
            sum+=w[j];
            j++;
            if(j==n){//乗せれた量==荷物の量　もう全部積めちゃった
                return j;
            }
        }
    }
    return j;
}

int P(int n, int k, int w[]) {
    int left = 0, right = 100000000000;
    int mid;    
    while (2<=right-left) {
        mid=(left+right)/2;//p
        if (carry(n, k, w, mid)<n) {//ｐ減らしすぎた
            left=mid;
        }
    	else{
            right=mid;
    	}
    }
    return right;
}

int main(void){
	int n, k;
	scanf("%d %d", &n, &k);
	
	int i, w[n], sum=0;
	for(i=0; i<n; i++){
		scanf("%d", &w[i]);
	}
    printf("%d\n", P(n, k, w));

	return 0;
}


Measured memory_bytes: 2252
def solve(li):
    if len(li) == n:
        ans.append(li)
        return
    tmp = max(li)
    for i in range(1, tmp + 2):
        solve(li + [i])

ans = []
n = int(input())
solve([1])
res = []
alph = "abcdefghijklmnopq"

for ptn in ans:
    for i in range(n):
        ptn[i] = alph[ptn[i] - 1]
    res.append("".join(ptn))
res = sorted(res)
for i in res:
    print(i)  

Measured memory_bytes: 148104
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> v(N + 1, INT_MAX);
    v[0] = 0;
    for(int i = 0; i < N; i++){
        for(int w = 1; i + w <= N; w *= 6) v[i + w] = min(v[i + w], v[i] + 1);
        for(int w = 9; i + w <= N; w *= 9) v[i + w] = min(v[i + w], v[i] + 1);
    }
    cout << v[N] << endl;
    return 0;
}


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

int div(int x){
    int count=0,score = x%2;
    for (; score == 0;){
        x = x / 2;
        count++;
        score = x % 2;
        }
        return count;
}

int main(void)
{
    int n;
    cin >> n;
    if(n>=64)
        cout << 64;
        else if(n>=32&&n<64)
            cout << 32;
            else if(n>=16&&n<32)
                cout << 16;
                else if(n>=8&&n<16)
                    cout << 8;
                    else if(n>=4&&n<8)
                        cout << 4;
                        else if(n>=2&&n<4)
                            cout << 2;
                            else
                                cout << 1;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int dp[100010][3];

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

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i] >> b[i] >> c[i];
    rep(i, n)
    {
        dp[i + 1][0] = max(dp[i][1] + a[i], dp[i][2] + a[i]);
        dp[i + 1][1] = max(dp[i][0] + b[i], dp[i][2] + b[i]);
        dp[i + 1][2] = max(dp[i][0] + c[i], dp[i][1] + c[i]);
    }
    int ans = max(max(dp[n][0], dp[n][1]), dp[n][2]);
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <stdio.h>
int main()
{
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if (  W >= x + r && x - r >= 0  && H >= y +r && y - r >= 0 )
         printf("Yes\n");
    else
         printf("No\n");
    return 0;
}


Measured memory_bytes: 2140
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
class UnionFind {
public:
    vector<int> par, rank;
    int cnt;

    UnionFind(int n) : cnt(n) {
        par = vector<int>(n);
        iota(par.begin(), par.end(), 0);
        rank = vector<int>(n, 0);
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = root(par[x]);
        }
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
        cnt--;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

signed main() {
    int N, K, L;
    cin >> N >> K >> L;

    UnionFind uf1 = UnionFind(N);
    UnionFind uf2 = UnionFind(N);

    for (int i = 0; i < K; i++) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        uf1.unite(p, q);
    }

    for (int i = 0; i < L; i++) {
        int r, s;
        cin >> r >> s;
        r--; s--;
        uf2.unite(r, s);
    }

    int root1[N];
    int root2[N];
    map<P, int> m;

    for (int i = 0; i < N; i++) {
        root1[i] = uf1.root(i);
        root2[i] = uf2.root(i);
        m[P(root1[i], root2[i])]++;
    }

    for (int i = 0; i < N; i++) {
        cout << m[P(root1[i], root2[i])];

        if (i == N - 1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }

    return 0;
}

Measured memory_bytes: 21120
#include<stdio.h>
//#define MAX_SIZE 100000
int main(){
	long long int N;
	scanf("%lld",&N);
	long long int A[N];
	long long int i;
	long long int prod=1;
	long long int x=1e18;

	for(i=0;i<N;i++){
		scanf("%lld",&A[i]);
	}
	for(i=0;i<N;i++){
		if(A[i]==0){
			puts("0");
			return 0;
		}
	}
	for(i=0;i<N;i++){
		if(A[i]<=x/prod){
			prod*=A[i];
			}
			else{
				puts("-1");
				return 0;
				}
	}
	
	printf("%lld\n",prod);
	
	return 0;
}


Measured memory_bytes: 2448
/*
Author : Hocky Yudhiono
6/27/2020 7:22:23 PM

1. You can sort the query if offline!
2. Don't bring the dp remaining state when dfsing on DP on Tree.
3. Try to reverse (Think from the back) if you stuck.
4. Be careful when submitting Div. 2 D-F, dont waste it on stupid WAs.
5. Try to reduce a problem
*/

#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef vector<int> vi;
typedef pair<LL,LL> PLL;
typedef pair<LL,int> PLI;
typedef pair<int,int> PII;
typedef pair<int,int> pii;
typedef vector<vector<LL>> VVL;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define popf pop_front
#define pf push_front
#define popb pop_back
#define mp make_pair
#define pb push_back
#define remove erase
#define fi first
#define se second

// If the time limit is strict, try not to use long double

// Remember to undefine if the problem is interactive
#define endl '\n'
#define DEBUG(X) cout << ">>> DEBUG(" << __LINE__ << ") " << #X << " = " << (X) << endl

const double EPS = 1e-9;
const int INFMEM = 63;
const int INF = 1061109567;
const LL LINF = 4557430888798830399LL;
const double DINF = numeric_limits<double>::infinity();
const LL MOD = 1000000007;
const int dx[8] = {0,0,1,-1,1,-1,1,-1};
const int dy[8] = {1,-1,0,0,1,-1,-1,1};
// Do dir^1 to get reverse direction
const char dch[4] = {'R','L','D','U'};
// const string ds[8] = {"E","W","S","N","SE","NW","SW","NE"};
const double PI = 3.141592653589793;

inline void open(string a){
    freopen((a+".in").c_str(),"r",stdin);
    freopen((a+".out").c_str(),"w",stdout);
}

inline void fasterios(){
    // Do not use if interactive
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // cout << fixed << setprecision(10);
}

LL n,m,k;
LL isi[200005];
LL sum[200005];

LL get(LL rem){
    LL kiri = 0;
    LL kanan = n;
    while(kiri < kanan){
        LL mid = (kiri+kanan+1)>>1;
        if(sum[mid] <= rem) kiri = mid;
        else kanan = mid-1;
    }
    return kiri;
}

int main(){
    cin >> n >> m >> k;
    for(int i = 1;i <= n;i++) cin >> isi[i], sum[i] += isi[i]+sum[i-1];
    LL ans = get(k);
    for(int i = 1;i <= m;i++){
        LL tmp; cin >> tmp;
        k -= tmp;
        if(k < 0) break;
        ans = max(ans,get(k)+i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6756
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>

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

using namespace std;

typedef long long ll;


ll n;
ll w[100];


int main() {

//    ifstream in("/Users/koichihasegawa/src/repository/cpp/AtCoder/ABC/abc130/input.txt");
//    cin.rdbuf(in.rdbuf());

    cin >> n;
    REP(i, 100) {
        w[i] = 0;
    }
    ll sum = 0;
    ll ruisekiSum[100];
    REP(i, n) {
        cin >> w[i];
        sum += w[i];
        if (i > 0) {
            ruisekiSum[i] = ruisekiSum[i - 1] + w[i];
        } else {
            ruisekiSum[i] = w[i];
        }
    }
    ll ans = 10000000000;
    REP(i, n) {
        ruisekiSum[i] = abs(sum - 2 * ruisekiSum[i]);
        ans = min(ans, ruisekiSum[i]);
    }

    cout << ans;



    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    ld pi = 3.1415926535;
    ld r;
    cin >> r;
    cout << sp(10) << 2*r*pi << endl;
}

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


using namespace std;
int main() {
  string S;
  string s1 = "es";
  string s2 = "s";
  string ansS;
  cin >> S;
  char c;
  c = S[S.size()-1];
  if(c=='s'){
    ansS =S+s1;
  }else{
    ansS =S+s2;
  }
  cout << ansS<< endl;
  return 0;
} 

Measured memory_bytes: 3600
use proconio::{fastout, input};
use std::cmp::{max, min};

#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize
    }
    let lim = (n as f64).sqrt() as usize + 1;
    let mut res = std::usize::MAX;
    for i in 1..lim {
        if n % i == 0 {
            res = min(res, f(i, n / i));
        }
    }
    println!("{}", res);
}

fn f(a: usize, b: usize) -> usize {
    max(a.to_string().len(), b.to_string().len())
}


Measured memory_bytes: 2172
hp,n=map(int,input().split())
magics=[list(map(int,input().split())) for i in range(n)]

inf=10**9
dp=[[0]+[inf]*hp for i in range(n+1)]
for i in range(n):
  damage=magics[i][0]
  cost=magics[i][1]
  for j in range(hp+1):
    if j<damage:
      dp[i+1][j]=min(dp[i][j],cost)
    else:
      dp[i+1][j]=min(dp[i][j],(dp[i+1][j-damage]+cost))
print(dp[n][hp])

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int A, B;
    cin >> A >> B;

    printf("%lld\n", A * B);

    return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll =unsigned long long;
using dl = long double;
const ll m=1000000007;

ll fac[1000001];

void pre(){
    fac[0]=fac[1]=1;
    for(int i=2;i<=1000001;i++)
{

    fac[i]=(fac[i-1]*1LL*i)%m;
}
}

ll power(ll a,ll n){
    ll res=1;
    while(n){

    if(n%2)
        res = (res*1LL*a)%m;

        n/=2;
        a=(a*1LL*a)%m;

    }
    return res;

}

ll nCr(ll n,ll r){


ll res= fac[n];
res = (res*1LL*power(fac[r],m-2))%m;
res= (res*1LL*power(fac[n-r],m-2))%m;
return res;

}



int main()
{
    pre();
    ll x,y;
    cin>>x>>y;
    int z=max(x,y);
   int necr=x;
   int necc=y;
   ll ans=0;
   ll one = (2*y-x)/3;

   ll two = (2*x-y)/3;
   if(one<0||two<0||(2*y-x)%3!=0)cout<<0<<endl;
   else if(one+two==0||one+two<0||(2*x-y)%3!=0)cout<<0<<endl;
   else{
    ll a= one;
    ll b= two;
   // cout<<one<<" "<<two<<endl;
    //cout<<a<<b;
    ll f=1;ll nos = a+b;

    cout<<nCr(nos,a);

   }


    return 0;
}


Measured memory_bytes: 11436
#include <stdio.h>
#include <string.h>

int main(int argc,char* argv[]){
  char str[101];
  int len;
  int count = 0;
  
  while(scanf("%s",str) != EOF){
    int i,k;
    len = strlen(str);
    
    if(len == 1){
      count++;
      continue;
    }

    i = 0;
    k = 0;
    while(i < len/2){
      if(str[i] != str[(len-1) - i]){
	k = 1;
	break;
      }
      
      i++;
    }
    
    if(k == 0){
      count++;
    }
    
  }

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

Measured memory_bytes: 0
S = input()[:-1]

#残り文字数
lest = len(S)

while 1:
  if lest % 2 == 1:
    lest -= 1
    S = S[:lest]
    continue
  if S[:lest//2]==S[lest//2:]:
    print(lest)
    exit()
  else:
    lest -= 2
    S = S[:lest]


Measured memory_bytes: 38256
import math
a,b,x=map(int,input().split())
taiseki=a*a*b
if taiseki//2<x:
    water=taiseki-x
    c=2*water/a/a
    print(math.degrees(math.atan(c/a)))
else:
    water=x
    c=2*water/a/b
    print(math.degrees(math.atan(b/c)))

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define gc getchar()
#define N 20
#define BAS 1ll*37
#define mod 998244353
using namespace std;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int nxt[N],z[N],f[N];char s[N][N],t[N][N];
bool vis[N],chose[N],has_ans;
inline int calc_z(int x,int n)
{
	int ans=0;
	for(int i=1;i<=n;i++) ans=(ans+t[i][x]-'a'+1)*BAS%mod;
	return ans;
}
inline int calc_f(int x,int n)
{
	int ans=0;
	for(int i=n;i>=1;i--) ans=(ans+t[i][x]-'a'+1)*BAS%mod;
	return ans;
}
inline bool check(int n,int m)
{
	for(int i=1,j=0;i<=n;i++) if(nxt[i]) j++,
		memcpy(t[j],s[i],sizeof(char)*(m+1)),memcpy(t[n-j+1],s[nxt[i]],sizeof(char)*(m+1));
	if(n&1) memcpy(t[n/2+1],s[n],sizeof(char)*(m+1));
	for(int i=1;i<=m;i++) z[i]=calc_z(i,n),f[i]=calc_f(i,n);
	int res=0;memset(vis,false,sizeof(bool)*(m+1));
	for(int i=1;i<=m;i++)
		if(!vis[i]) for(int j=1;j<=m;j++) if(i^j)
			if(!vis[j]&&z[i]==f[j]) { vis[i]=vis[j]=true,res+=2;break; }
	return m-res<=1;
}
bool dfs(int n,int m,int alr,int x=1)
{
	if(n-alr<=1) return has_ans|=check(n,m);if(has_ans) return true;
	for(int i=1;i<=n/2*2;i++) if(!chose[i]) { x=i;break; }
	chose[x]=true;
	for(int i=x+1;i<=n/2*2;i++) if(!chose[i])
		nxt[x]=i,chose[i]=true,dfs(n,m,alr+2),nxt[x]=0,chose[i]=false;
	return chose[x]=false,has_ans;
}
int main()
{
	int n=inn(),m=inn();has_ans=false;
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	if(n%2==0) dfs(n,m,0);
	else for(int i=1;i<=n;i++) swap(s[i],s[n]),dfs(n,m,0),swap(s[i],s[n]);
	if(has_ans) printf("YES\n");else printf("NO\n");return 0;
}

Measured memory_bytes: 256