akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
	int x[3100];
	int y[3100];
	int i=0;
	int h=0;
	for(h=0;h<3050;h++){
		cin>>x[h]>>y[h];
		if(x[h]==0&&y[h]==0){
			break;
		}
		i++;
	}
	for(h=0;h<i;h++){
		if(x[h]<=y[h]){
			cout<<x[h]<<" "<<y[h]<<endl;
		}else{
			cout<<y[h]<<" "<<x[h]<<endl;
		}
	}
}

Measured memory_bytes: 1184
from collections import deque
from bisect import bisect_left
n = int(input())
a = sorted(list(map(int,input().split())),reverse=True)

c = 0
q = deque([a[0]])
for i in a[1:]:
    m = q.pop()
    c += m
    q.appendleft(i)
    q.appendleft(i)
print(c)

Measured memory_bytes: 33124
#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++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<vector<ll>> Matrix;

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a, b);}

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

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  int g = a[0];
  rep1(i, n-1) {
    g = gcd(g, a[i]);
  }
  cout << g << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int[] a = new int[5];
			int[] b = new int[4];
			
			a[0] = sc.nextInt();
			if(a[0]==0)break;
			b[a[0]]++;
			for(int i=1;i<5;i++){
				a[i] = sc.nextInt();
				b[a[i]]++;
			}
			
			if((b[1]>0 && b[2]>0 && b[3]>0) || b[1]==5 || b[2]==5 || b[3]==5){
				for(int i=0;i<5;i++){
					System.out.println("3");
				}
			}else{
				for(int i=0;i<5;i++){
					if(b[1]==0){
						if(a[i]==2) System.out.println("1");
						else System.out.println("2");
					}
					if(b[2]==0){
						if(a[i]==3) System.out.println("1");
						else System.out.println("2");
					}
					if(b[3]==0){
						if(a[i]==1) System.out.println("1");
						else System.out.println("2");
					}
				}
			}
	
		}
	}	
}

Measured memory_bytes: 20752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _1129
{
    public class Program

    {
        public static void Main(string[] args)
        {

            while (true)
            {


                int[] line = ReadIntAr();
                if (line[0] + line[1] == 0) break;

                List<int> cards = new List<int>();
                for (int i = 0 ; i < line[0] ; i++) cards.Add(line[0] - i);
                for (int i = 0 ; i < line[1] ; i++)
                {
                    int[] query = ReadIntAr();
                    List<int> before = cards.Take(query[0] - 1).ToList();
                    List<int> selected = cards.Skip(query[0] - 1).Take(query[1]).ToList();
                    List<int> after = cards.Skip(query[0] - 1 + query[1]).Take(cards.Count - (query[0] - 1) - query[1]).ToList();
                    cards = selected.Concat(before).Concat(after).ToList();
                }
                Console.WriteLine(cards.First());
            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 20380
#include <cstdio>
#include <algorithm>
using namespace std;
int n,m,x;
int c[15],a[15][15],b[15],d[15],len,sum=100000000,cost;
void init(){//数据读取
	int i,j;
	scanf("%d%d%d",&n,&m,&x);
	for(i=1;i<=n;i++){
		scanf("%d",&c[i]);
		for(j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	}
}
void dfs(int step){
	int i,j,k;
	if(step==len+1){//深搜结束条件
		for(k=1;k<=m;k++)d[k]=0;//d[k]表示被选择的书店，在k列位置上的和
		for(j=1;j<=len;j++)
			for(k=1;k<=m;k++)
				d[k]+=a[b[j]][k];//计算被选择的书店，在k列位置上的和
		for(k=1;k<=m;k++)
			if(d[k]<x)return;//不满足条件
		cost=0;
		for(j=1;j<=len;j++)cost+=c[b[j]];//计算花费
		sum=min(sum,cost);//找最小值
		return ;
	}
	for(i=b[step-1]+1;i<=n;i++)//找组合情况，就让后查找的位置越来越大，请注意i=b[step-1]+1
		b[step]=i,dfs(step+1);
}
int main(){
	init();
	for(len=1;len<=n;len++)//len界定选择的书店的数量
		b[0]=0,dfs(1);
	if(sum==100000000)printf("-1\n");//没找到
	else printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 1728
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (A, B): (Vec<i64>, Vec<i64>) = {
        let (mut A, mut B) = (vec![], vec![]);
        for _ in 0..N {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            A.push(iter.next().unwrap().parse().unwrap());
            B.push(iter.next().unwrap().parse().unwrap());
        }
        (A, B)
    };

    let ans = (0..N)
        .rev()
        .fold(0, |s, i| s + ((B[i] - (A[i] + s)) % B[i] + B[i]) % B[i] );

    println!("{}", ans);
}

Measured memory_bytes: 8444
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=200001;

int f[101][10];
int p[101][11];
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    for (int j=0;j<10;j++){
      cin>>f[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<11;j++){
      cin>>p[i][j];
    }
  }
  int res=-1*INT_MAX;
  for(int i=1;i<((1<<10));i++){
    int ans=0;
    for(int j=0;j<n;j++){
      int cnt=0;
      for(int k=0;k<10;k++){
        if(i>>k&1 and f[j][k]==1){
          cnt++;
        }
      }
      ans+=p[j][cnt];
    }
    res=max(res,ans);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            long A = in.Long();
            long B = Math.round(in.Double() * 100);
            BigInteger a = BigInteger.valueOf(A);
            BigInteger b = BigInteger.valueOf(B);
            BigInteger ans = a.multiply(b).divide(BigInteger.valueOf(100));
            out.println(ans.toString());
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public long Long() {
            return Long.parseLong(next());
        }

        public double Double() {
            return Double.parseDouble(next());
        }

    }
}



Measured memory_bytes: 33416
#include <stdio.h>
int main()
{
    long long n;
    scanf("%lld",&n);
    long long ans = 0;

    for (long long i = 1; i <= n; ++i)
    {
        if (i % 3 == 0 || i % 5 == 0) {
		continue;}
        else {
		ans += i;
	}
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll n,d;
  cin>>n>>d; 
  ll x[n][d];
  
  for(ll i=0;i<n;i++){
    for(ll j=0;j<d;j++){
      cin>>x[i][j];
    }
  }
  
  ll count =0;
  for(ll i=0;i<n;i++){
    for(ll j=i+1;j<n;j++){
      double dis2=0;
      for(ll e=0;e<d;e++){
        dis2+=(x[i][e]-x[j][e])*(x[i][e]-x[j][e]);
      }
      double dis=sqrt(dis2);
      //cout<<i<<" "<<j<<" "<<dis<<endl;
      if(ceil(dis)==floor(dis))count++;
    }
  }
  cout<<count;
  
  return 0;
}

Measured memory_bytes: 256
s=input()
a=0
z=0
i=0
j=len(s)-1
while a==0 :
    if s[i]=="A":
        a=1
    else:
        i+=1
while z==0:
    if s[j]=="Z":
        z=1
    else:
        j-=1
print(j-i+1)



Measured memory_bytes: 3512
N, K = map(int, input().split())
S = input()
T = []

g = S[0]
cnt = 0
for s in S:
    if s == g:
        cnt += 1
    else:
        T.append(cnt)
        cnt = 1
        g = s
else:
    T.append(cnt)


t = len(T)
for k in range(K):
    t -= 2

if t <= 1:
    print(N - 1)
else:
    print(N - t)


Measured memory_bytes: 3956
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var a = inta();
        int n = a[0], x = a[1], t = a[2];
        int ans = (int)Ceiling((double)n / x)*t;
        Write(ans);
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 27536
N = int(input())
march = ["M", "A", "R", "C", "H"]
S = [0,0,0,0,0]

for i in range(N):
  s = str(input())
  if s[0] in march:
    index = march.index(s[0])
    S[index] += 1
    
for i in range(5):
  if 0 in S:
    S.remove(0)
   
N = len(S)
if N <= 2:
  ans = 0
elif N == 3:
  ans = S[0]*S[1]*S[2]
elif N == 4:
  mul = S[0]*S[1]*S[2]*S[3]
  ans = 0
  for i in range(4):
    ans += mul//S[i]
else:#N = 5
  mul = S[0]*S[1]*S[2]*S[3]*S[4]
  ans = 0
  for i in range(5):
    for j in range(i+1,5):
      ans += mul//(S[i]*S[j])
      
print(ans)
    
    


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>

using namespace std;

inline bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }

typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef long long ll;
typedef unsigned long long ull;

#define For(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };
const int mod = 1000000007;
const int INF = 1e9;

int d[1000001];
int d2[1000001];

int main()
{
	int n;
	Fill(d, INF);
	Fill(d2, INF);
	
	vector<int> v,v2;
	for (int i = 1;; i++){
		int t = i * (i + 1) * (i + 2) / 6;
		if (t > 1e6)break;
		v.push_back(t);
		d[t] = 1;
		if (t % 2){
			d2[t] = 1;
			v2.push_back(t);
		}
	}

	For(i,1, 1e6){
		rep(j, v.size())if(i + v[j] < 1e6){
			d[i + v[j]] = min(d[i + v[j]], d[i] + 1);
		}
		rep(j, v2.size())if (i + v2[j] < 1e6){
			d2[i + v2[j]] = min(d2[i + v2[j]], d2[i] + 1);
		}
	}

	while (cin >> n && n){

		cout << d[n] << " " << d2[n] << endl;

	}

	return 0;
}

Measured memory_bytes: 9032
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
   int n;
   cin >> n;
   
   int a = 0, b = n;
   
   for(int i = 0; i < 9; i++) a += b % 10, b /= 10;
   if(n % a == 0) {
       cout << "Yes" << endl;
   }else {
       cout << "No" << endl;
   }
}


Measured memory_bytes: 256
import sys
#from collections import defaultdict
sys.setrecursionlimit(10**6)

def input():
	return sys.stdin.readline()[:-1]
n, l = map(int, input().split())
ss = [list(input())[::-1] for _ in range(n)]

def addTree(tree, sentence):
	if not sentence:
		return None   

	if sentence[-1] not in tree:
		tree[sentence[-1]] = {}

	p = sentence.pop()
	tree[p] = addTree(tree[p], sentence)

	return tree

def createTree(sentences):    
	tree = {}
	for sentence in sentences:
		tree = addTree(tree, sentence)

	return tree

tree = createTree(ss)
#print(tree)

grundy = 0
def dfs(cur, level):
	global grundy
	if cur is None:
		return
	elif len(cur) == 1:
		grundy ^= (l-level) & (-l+level)
	for k in cur.keys():
		dfs(cur[k], level+1)
	return
	
dfs(tree, 0)

if grundy == 0:
	print("Bob")
else:
	print("Alice")


Measured memory_bytes: 126736
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long LL;
const int INF = 100000000;

int main()
{
#ifdef LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    string S;
    cin >> S;

    vector<string> w = {
        "Sunny", "Cloudy", "Rainy"
    };

    for(int i=0;i<3;i++){
        if(w[i] == S){
            cout << w[(i+1)%3] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, k, dp[64][2];
vector<i64> a;

i64 dfs(i64 d, bool f) {
  if (d < 0) return 0;
  if (dp[d][f] > 0) return dp[d][f];
  i64 bit = i64(1) << d;
  i64 y0 = 0, y1 = 0;
  for (i64 x : a) {
    y0 += x & bit;
  }
  y0 += dfs(d - 1, f && !(k & bit));
  if (!f || (k & bit)) {
    for (i64 x : a) {
      y1 += (x ^ bit) & bit;
    }
    y1 += dfs(d - 1, f);
  }
  return dp[d][f] = max(y0, y1);
}

int main() {
  cin >> n >> k;
  read_n(a, n);
  i64 y = dfs(60, true);
  cout << y << '\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
int n;


int main(int argc, char const *argv[]) {
    cin>>n;
    vector<int> v(n);
    rep(i,n) cin>>v[i];
    sort(v.begin(), v.end());

    double x = v[0]*1.0;

    for (int i = 1; i < n; ++i) {
        x = (x+v[i])/2;
    }    
    
    cout << x << endl;

    return 0;
}


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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 5000000000000000;
constexpr auto MOD = 1000000007;



int main() {

	int n;
	string s;
	cin >> n >> s;

	if (n % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}

	bool k = true;
	rep(i, n/2) {
		if (s[i] != s[n/2+i]) k = false;
	}

	if (k)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
# coding=utf-8

if __name__ == '__main__':

    N, Y = map(int, input().split())

    x = 0
    y = 0
    z = 0

    while (x <= N):
        y = 0
        z = 0

        for y in range(N - x + 1):
             #print('x=',x)
             #print('y=',y)
            z = N - x - y

            if (10000 * x + 5000 * y + 1000 * z == Y):
                print (x,y,z)
                exit()

        x += 1

    print(-1,-1,-1)

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

int main(void) {
  int N;
  cin >> N;
  long long ans = 1;
  long long pre = 1;
  const long long limit = 1000000000000000000;
  vector<long long> A(N);
  bool zeroFlag = false;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 0) {
      zeroFlag = true;
    }
  }

  if (zeroFlag) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < N; i++) {
    ans *= A[i];
    if (ans < pre || ans > limit) {
      ans = -1;
      break;
    }
    pre = ans;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
#include<time.h>
#pragma GCC optimize(2)
using namespace std;
int n,m,k,i,ia,ib;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>k;
    int a[200009],b[200009];
    for(i=1;i<=n;i++)
        cin>>a[i];
    long long tt=0;
    for(i=1;i<=m;i++)
	{
        cin>>b[i];
        tt+=b[i];
    }
    int ans=0;
    ia=0;
    ib=m;
    for(ia=0,ib=m;ia<=n;ia++)
	{
        tt+=a[ia];
        while(tt>k&&ib>0)
        	tt-=b[ib--];
        if(tt>k)
        	break;
        ans=max(ans,ia+ib);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5216
n, y = map(int, input().split())

ans = [-1, -1, -1]

for i in range(n + 1):
    for j in range(n - i + 1):
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            ans = [i, j, n - i - j]

print(*ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#define printArray(array, alen) \
    do{ \
        for(int i = 0; i < alen; i++){ \
            fprintf(stderr, "%d ", array[i]); \
        } \
        fprintf(stderr, "\n"); \
    }while(0)
int main() {
    int n, k, q;
    scanf("%d %d %d", &n, &k, &q);
    int a[q];
    for (int i = 0; i < q; i++) {
        scanf("%d", &a[i]);
    }
    
    int cnt[n];
    for(int i = 0; i < n; i++) {
        cnt[i] = 0;
    }
    printArray(cnt, n);

    for (int i = 0; i < q; i++ ) {
        cnt[a[i] - 1]++;
    }
    printArray(cnt, n);

    for(int i = 0; i < n; i++) {
        if((k - (q - cnt[i])) > 0) {
            printf("Yes\n");
        }else {
            printf("No\n");
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

const ll mod = 1e9 + 7LL;

ll modPow(ll a, ll n)
{
    if(n == 0LL)return 1LL;
    else if(n % 2LL == 0LL)
    {
        ll polaVrednost = modPow(a, n/2)%mod;
        return (polaVrednost*polaVrednost)%mod;
    }
    else
    {
        ll polaVrednost = modPow(a, n/2)%mod;
        return (((polaVrednost*polaVrednost)%mod)*a)%mod;
    }
}

ll nCr(ll n, ll k)
{
    if(k > n)return 0LL;

    if(n - k < k)k = n - k;

    ll gornjiProizvod = 1LL;

    for(ll i = n-k+1; i <= n; i++)
    {
        gornjiProizvod = (gornjiProizvod*i)%mod;
    }

    ll donjiProizvod = 1LL;

    for(ll i = 1; i <= k; ++i)
    {
        donjiProizvod = (donjiProizvod*i)%mod;
    }

    return (gornjiProizvod * modPow(donjiProizvod, mod-2LL))%mod;
}

int main()
{
    ll k, n;

    cin >> n >> k;

    for(ll i = 1LL; i <= k; ++i)
    {
        cout << (nCr(n-k+1LL, i) * nCr(k-1LL, i-1LL))%mod << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
// by syu
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var in = NewScanner(os.Stdin, 0)

func main() {
	N, K := in.Int(), in.Int()
	x := in.ArrayInt32(N)
	var min int32 = math.MaxInt32
	for i := 0; i < N-K+1; i++ {
		a, b := x[i], x[i+K-1]
		sum := Min232(Abs32(a), Abs32(b)) + b - a
		if sum < min {
			min = sum
		}
	}
	Pln(min)
}

type Scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader, max int) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if max <= 0 {
		max = 1048576
	}
	s.Buffer([]byte{}, max)
	return &Scanner{s}
}
func (s *Scanner) Int() int {
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}
func (s *Scanner) Int32() int32 {
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 32)
	if e != nil {
		panic(e)
	}
	return int32(i)
}
func (s *Scanner) ArrayInt32(n int) []int32 {
	r := make([]int32, n)
	for i := 0; i < n; i++ {
		r[i] = s.Int32()
	}
	return r
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for start < len(data) && isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i + 1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func Min232(a, b int32) int32 {
	if a < b {
		return a
	}
	return b
}
func Abs32(n int32) int32 {
	y := n >> 31
	return (n ^ y) - y
}
func Pln(s ...interface{}) {
	fmt.Println(s...)
}


Measured memory_bytes: 2560
"use strict"

const arg_str = require('fs').readFileSync('/dev/stdin', 'UTF-8')
const args_lines = arg_str.split('\n')
const n = args_lines[0]
const v_array = args_lines[1].split(' ')

const v_array_num = v_array.map(x=>parseInt(x))
const v_array_num_sort = v_array_num.sort((a,b)=>(a-b))

const result = v_array_num_sort.reduce((a,b)=>((a+b)/2))

console.log(result)

Measured memory_bytes: 7500
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>

using namespace std;

int ha[30], wa[30], xa[30];
int board[32][32];

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

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <chrono>
#include<bitset>
#include<deque>
#include <map>
#include<string>
#define vint vector<int>
#define vint2 vector<vint>
#define vchar vector<char>
#define vchar2 vector<vchar> 
#define vchar3 vector<vchar2> 
#define pr pair<int,int>
#define vpr vector<pr>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
typedef  long long int ll;
using namespace std;
//CHAR_BIT	ビット フィールドではない最小変数のビット数。	8
//SCHAR_MIN	signed char 型変数の最小値。	–128
//SCHAR_MAX	signed char 型変数の最大値。	127
//UCHAR_MAX	unsigned char 型変数の最大値。	255 (0xff)
//CHAR_MIN	char 型変数の最小値。 - 128、 / J オプション使用時は 0
//CHAR_MAX	char 型変数の最大値。	127、 / J オプション使用時は 255
//MB_LEN_MAX	多文字定数の最大バイト数。	5
//SHRT_MIN	short 型変数の最小値。	–32768
//SHRT_MAX	short 型変数の最大値。	32767
//USHRT_MAX	unsigned short 型変数の最大値。	65535 (0xffff)
//INT_MIN	int 型変数の最小値。	–2147483647 – 1
//INT_MAX	int 型変数の最大値。	2147483647
//UINT_MAX	unsigned int 型変数の最大値。	4294967295 (0xffffffff)
//LONG_MIN	long 型変数の最小値。	–2147483647 – 1
//LONG_MAX	long 型変数の最大値。	2147483647
//ULONG_MAX	unsigned long 型変数の最大値。	4294967295 (0xffffffff)




int  main(){
	int  A, B;
	cin  >> A >> B;
	cout << max(A + B, max(A - B, A*B)) << endl;


	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DSnukeNumbers solver = new DSnukeNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class DSnukeNumbers {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.nextInt();

            long[] answer = new long[k];
            int index = 0;
            long nines = 0;

            HashSet<Long> seen = new HashSet<>();

            outer:
            while (true) {
                long tens = nines + 1;
                for (int i = 1; ; i++) {
                    long candidate = tens * i + nines;
                    long opponent = tens * (i + 1) + nines;
                    if (isSnukier(candidate, opponent)) {
                        if (!seen.contains(candidate)) {
                            seen.add(candidate);
                            answer[index++] = candidate;
                            if (index == k) {
                                break outer;
                            }
                        }
                    } else {
                        break;
                    }
                }

                nines = nines * 10 + 9;
            }

            for (long x : answer) {
                out.println(x);
            }
        }

        static boolean isSnukier(long n, long other) {
            return (other * S(n) >= n * S(other));
        }

        static long S(long n) {
            long sum = 0;
            for (char c : Long.toString(n).toCharArray()) {
                sum += c - '0';
            }
            return sum;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 19880
#include<bits/stdc++.h>
using namespace std;
const int limit=50;
int N, M;
bool graph[limit][limit];
bool visited[limit];



void dfs(int v) {
   visited[v]=true;
	for (int v2 = 0; v2 <N; v2++) {
		if (!graph[v][v2]) continue;
		if (visited[v2]) continue;
       
		dfs(v2);
	}
}
int main(void) {
	cin >> N >> M;
	
	
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			graph[i][j] = false;
		}
	}
	pair<int, int> P[M];
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
        a--;
        b--;
		P[i].first = a;
		P[i].second = b;
		graph[a][b] = true;
		graph[b][a] = true;
	}
	int ans = 0;
	for (int i = 0; i < M; i++) {
		graph[P[i].first][P[i].second] = false;
		graph[P[i].second][P[i].first] = false;
		
		fill(visited, visited + N, false);
		dfs(0);
       bool bridge=false;
		for (int i = 0; i < N; i++) {
			if (!visited[i]) bridge =true;
		}
        if(bridge) ans++;
		graph[P[i].first][P[i].second] = true;
		graph[P[i].second][P[i].first] = true;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k,ans;
    cin >> k;
    ans = a[k-1];

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
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;}


int nextInt() { int x; scanf("%d", &x); return x;}

ll grundy(ll x) {
  return 1LL << __builtin_ctzll(x);
}

const int SZ = 112345 * 2;

ll L;
ll ans;
int tree[SZ][2];
int depth[SZ];
int sp = 0;

void add(int idx, const string& s, int pos) {
  if ((int)s.size() == pos) {
    return;
  }
  depth[idx] = pos;
  int next = s[pos] - '0';
  if (tree[idx][next] == -1) {
    tree[idx][next] = ++sp;
  }
  add(tree[idx][next], s, pos+1);
}

void walk(int idx) {
  if (tree[idx][0] == -1 && tree[idx][1] == -1) return;

  for (int i = 0; i < 2; i++) {
    if (tree[idx][i] != -1)
      walk(tree[idx][i]);
    else
      ans ^= grundy(L - depth[idx]);
  }
  return;
}

int main2() {
  REP(i, SZ) { tree[i][0] = tree[i][1] = -1; }
  sp = 0;
  int N;
  cin >> N >> L;
  REP(i, N) {
    string s;
    cin >> s;
    add(0, s, 0);
  }
  ans = 0;
  walk(0);
  cout << (ans == 0 ? "Bob" : "Alice") << endl;
  return 0;
}

int main() {
  // const int N = 30;
  // int g[N] = {0};
  // int f[N] = {0};
  // g[0] = 0;
  // g[1] = 1;
  // for (int i = 2; i < N; i++) {
  //   set<int> s;
  //   int nim = 0;
  //   for (int j = i - 1; j >= 1; j--) {
  //     nim ^= g[j];
  //     s.insert(nim);
  //   }
  //   int res = 1;
  //   while (s.count(res) > 0) res++;
  //   g[i] = res;
  // }
  // pv(g, g + N);

  // for (int i = 1; i < N; i++) {
  //   f[i] = 1 << __builtin_ctz(i);
  // }
  // pv(f, f + N);
  for (;!cin.eof();cin>>ws) main2();
  // main2();
  return 0;
}



Measured memory_bytes: 7196
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/math/common_factor_rt.hpp>
#define USE_MATH_DEFINES
#define rep(i, n) for (int i = 0; i < (n); i++)
#define SENTINEL 2000000000
typedef long long ll;

using namespace std;
// namespace mp = boost::multiprecision;
// namespace mt = boost::math
// using Bint = mp::cpp_int;

int cnt = 0;

void merge(int a[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int l[n1 + 1], r[n2 + 1];
    rep(i, n1) l[i] = a[left + i];
    rep(i, n2) r[i] = a[mid + i];
    l[n1] = r[n2] = SENTINEL;
    int p = 0, q = 0;
    for (int i = left; i < right; i++) {
        if (l[p] <= r[q]) {
            a[i] = l[p];
            p++;
        } else {
            a[i] = r[q];
            q++;
        }
        cnt++;
    }
}

void mergeSort(int a[], int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(a, left, mid);
        mergeSort(a, mid, right);
        merge(a, left, mid, right);
    }
}

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    mergeSort(a, 0, n);
    rep(i, n) {
        if (i != n - 1)
            cout << a[i] << " ";
        else
            cout << a[i] << endl;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 6904
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
c = input()
d = c.count('R')
ans = d
for i in range(d):
    if c[i] == 'R':
        ans -= 1
print(ans)

Measured memory_bytes: 68404
#include <stdio.h>

int main(void){
  int w, three[12], k = 0, zero = 0;

  scanf("%d", &w);
  w += 265720;
  while(k < 12){
    three[k] = w % 3;
    w /= 3;
    k++;
  }
  for(k = 11; k >= 0; k--){
    switch(three[k]){
    case 0:
      printf("-");
      zero = 1;
      break;
    case 1:
      if(zero == 1){
	printf("0");
      }
      break;
    case 2:
      printf("+");
      zero = 1;
      break;
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 568
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    cin>>n;
    for (int i = 0; i < 50000;i++){
        x = i * 1.08;
        if(x==n){
            cout << i << endl;
            break;
        }
        if(i==49999){
            cout << ":(" << endl;
        }
    }
        return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int s=0,a,b,c,x,i,j,k;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&x);
	for(i=0;i<=a;i++)
	{
		for(j=0;j<=b;j++)
		{
			for(k=0;k<=c;k++)
			{
				if(i*500+j*100+k*50==x)
					s++;
			}
		}
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[]){
    long test = 1000000000000000000L;
    int n = readI();
    long a[]=new long[n];
    long r=1;
    for(int i=0;i<n;i++){
      a[i]=readLong();
      if(a[i]==0){
        r=0;break;
      }
    }
    if(r!=0){
      for(int i=0;i<n;i++){
        r*=a[i];
        if(r>test||r<a[i]){
          r=-1;break;
        }
      }
    }
    pl(r+"");
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static long readLong(){
    return Long.parseLong(readS());
  }
  public static int readI(){
    return stoi(readS());
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
  public static int[] Itoi(Integer a[]){
    int[]result=new int[a.length];
    for(int i=0;i<a.length;i++){
      result[i]=a[i];
    }
    return result;
  }
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    string s;
    ll x,y;
    cin >> s >> x >> y;
    ll n = s.size();
    vector<ll> yoko;
    vector<ll> tate;
    bool now = true;
    ll tmp = 0;
    for(i = 0;i < n;++i){
        if(s.at(i) == 'F') ++tmp;
        else{
            if(tmp == 0){
                if(now) now =false;
                else now = true;
                continue;
            }
            if(now){
                yoko.push_back(tmp);
                now = false;
                tmp = 0;
            }else{
                tate.push_back(tmp);
                now = true;
                tmp = 0;
            }
        }
    }
    if(tmp != 0){
        if(now) yoko.push_back(tmp);
        else tate.push_back(tmp);
    }
    ll n1 = yoko.size();
    ll n2 = tate.size();

    vector<vector<ll>> dp1(n1+1,vector<ll>(16001, 0));
    dp1.at(0).at(8000) = 1;
    if(n1){
        if(s.at(0) == 'F') dp1.at(1).at(8000 + yoko.at(0)) = 1;
        else{
            dp1.at(1).at(8000 + yoko.at(0)) = 1;
            dp1.at(1).at(8000 - yoko.at(0)) = 1;
        }
    }
    for(i = 2;i <= n1;++i){
        rep(j,16001){
            ll moto1 = j + yoko.at(i-1);
            ll moto2 = j - yoko.at(i-1);
            if(moto1 <= 16000) dp1.at(i).at(j) += dp1.at(i-1).at(moto1);
            if(moto2 >= 0) dp1.at(i).at(j) += dp1.at(i-1).at(moto2);
        }
    }

    vector<vector<ll>> dp2(n2+1,vector<ll>(16001, 0));
    dp2.at(0).at(8000) = 1;
    for(i = 1;i <= n2;++i){
        rep(j,16001){
            ll moto1 = j + tate.at(i-1);
            ll moto2 = j - tate.at(i-1);
            if(moto1 <= 16000) dp2.at(i).at(j) += dp2.at(i-1).at(moto1);
            if(moto2 >= 0) dp2.at(i).at(j) += dp2.at(i-1).at(moto2);
        }
    }
    if(dp1.at(n1).at(8000 + x) && dp2.at(n2).at(8000 + y)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 500864
import java.util.Scanner;

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

                int N = scan.nextInt();

                N %= 1000;

                if (N == 0) {
                	N = 1000;
                }

                System.out.println(1000 - N);

                scan.close();

        }
}

Measured memory_bytes: 35672
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();

    let a: u8 = iter.next().unwrap().parse().unwrap();
    let b: u8 = iter.next().unwrap().parse().unwrap();
    let c: u8 = iter.next().unwrap().parse().unwrap();

    let result = if a >= b && b >= c {
        10 * a + b + c
    } else if a >= c && c >= b {
        10 * a + c + b
    } else if b >= a && a >= c {
        10 * b + a + c
    } else if b >= c && c >= a {
        10 * b + c + a
    } else if c >= a && a >= b {
        10 * c + a + b
    } else {
        10 * c + b + a
    };

    println!("{}", result);
}


Measured memory_bytes: 4352
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO
 
readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete


divRoundHalfUp n d = if frac*2>=d then int+1 else int
  where
    (int, frac) = divMod n d

f d = [s, a]
  where
    s = sum . map product $ d
    cts = map (!!1) $ d
    a = divRoundHalfUp (sum cts) $ length cts

main = map (map read . wordsBy (==',')) . lines <$> getContents >>= mapM_ print . f

Measured memory_bytes: 3676
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const long long MOD = 1000000000 + 7;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = 1LL << 60;//numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>g;
vector<edge>ed;
vector<Pll>pv;
set<LL>st;
map<Pll, LL>ma;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
string str, ss;
bool f;
LL n, m, s, t, h, w, k, q, p, ans, cnt, sum, a[5000], b[5000];
Pll X, Y;
struct query {
	LL x, y, r;
};
query qu[2000];
typedef pair<double, LL> pdl;
double dijkstra(int s,int t) {
	vector<double>dist(n, numeric_limits<double>::max());
	priority_queue<pdl, vector<pdl>, greater<pdl>> q;
	dist[s] = 0;
	q.emplace(dist[s], s);
	while (!q.empty()) {
		double cost;
		int idx;
		tie(cost, idx) = q.top();
		q.pop();
		if (dist[idx] < cost) continue;
		rep(i,n) {
			double nexc = max(sqrt(pow((qu[idx].x - qu[i].x), 2) + pow((qu[idx].y - qu[i].y), 2)) - qu[idx].r - qu[i].r, 0.0);
			auto next = cost + nexc;
			if (dist[i] <= next) continue;
			dist[i] = next;
			q.emplace(dist[i], i);
		}
	}
	return dist[t];
}
int main() {
	cin >> X.fir >> X.sec;
	cin >> Y.fir >> Y.sec;
	cin >> n;
	rep(i, n) {
		cin >> qu[i].x >> qu[i].y >> qu[i].r;
	}
	qu[n] = query{ X.fir,X.sec,0 };
	qu[n+1] = query{ Y.fir,Y.sec,0 };
	n += 2;
	printf("%.15f\n", dijkstra(n - 2, n-1));

	return 0;
}

Measured memory_bytes: 5876
package main

import "fmt"

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var n int
	fmt.Scan(&n)

	inputs := make([][]int, 3)
	dp := make([][]int, 3)
	for i := 0; i < 3; i++ {
		inputs[i] = make([]int, n+1)
		dp[i] = make([]int, n+1)
	}
	for i := 1; i <= n; i++ {
		fmt.Scan(&inputs[0][i], &inputs[1][i], &inputs[2][i])
	}

	for i := 1; i <= n; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if j == k {
					continue
				}
				dp[k][i] = max(dp[k][i], dp[j][i-1]+inputs[k][i])
			}
		}
	}

	var result int
	for i := 0; i < 3; i++ {
		result = max(result, dp[i][n])
	}

	fmt.Println(result)
}

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

int main() {
    int N, i;
    cin >> N;
    for (i = 0; i < N; i++) {
        if (N < pow(2, i)) {
            cout << pow(2, i - 1) << endl;
            break;
        } else if (N == pow(2, i)) {
            cout << N << endl;
            break;
        }
    }
    
}

Measured memory_bytes: 256