akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
ans = 1000 - n % 1000
if ans == 1000:
    ans = 0
print(ans)

Measured memory_bytes: 72640
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

#define ll long long
const int maxN = 100005;
const ll INF = 1000000000000000000LL;

class TaskB {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int a, va;
		int b, vb;
		int t;
		cin >> a >> va;
		cin >> b >> vb;
		cin >> t;
		if(vb >= va){
			cout << "NO" << endl;
			return;
		}
		int d = abs(a-b);
		if(d <= (ll)t*(va - vb)){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskB solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3652
n=int(input())
s=list(input())
ans=0
how_r=[0 for i in range(n+1)]
how_g=[0 for i in range(n+1)]
how_b=[0 for i in range(n+1)]
for i in range(n):
    string=s[i]
    if string=="R":
        how_r[i+1]+=1
    elif string=="G":
        how_g[i+1]+=1
    elif string=="B":
        how_b[i+1]+=1
for i in range(n):
    how_r[i+1]+=how_r[i]
    how_g[i+1]+=how_g[i]
    how_b[i+1]+=how_b[i]


for  i in range(n):
    for j in range(i+1,n):
        x=s[i]
        y=s[j]
        if x!=y:
            if "R" not in [x,y]:
                ans+=how_r[j+1]-how_r[i]
                if (i+j)%2==0:
                    if s[(i+j)//2]=="R":
                        ans-=1
                
            
            elif "G" not in [x,y]:
                ans+=how_g[j+1]-how_g[i]
                if (i+j)%2==0:
                    if s[(i+j)//2]=="G":
                        ans-=1
                
            elif "B" not in [x,y]:
                ans+=how_b[j+1]-how_b[i]
                if (i+j)%2==0:
                    if s[(i+j)//2]=="B":
                        ans-=1  
print(ans)

                
                
            
            
            
                            
                


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

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

    int n;
    std::cin >> n;
    for(int i=1; i<=n; ++i){
        bool flag = false;
        if(i%3==0) flag = true;
        int x = i;
        while(x){
            if(x%10==3){
                flag = true;
                break;
            }
            x/=10;
        }
        if(flag){
            std::cout << " " << i;
        }
    }
    std::cout << "\n";
    return 0;
}

Measured memory_bytes: 3104
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

using ll = long long int;

int main(void) {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  while (v[0] != 1 and v.size() != 1) {
    sort(v.begin(), v.end());
    int x = v[0];
    for (int i = 1; i < n; i++) {
      v[i]=v[i]%x;
    }
    auto res = remove_if(v.begin(), v.end(), [](int x) {return x==0;});
    v.erase(res, v.end());
  }
  std::cout << v[0] << std::endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
using namespace std;
void kouri(int, int,int);
int  sum_max = 0;
int c[90][90];
int c2[90][90] = { 0 };
int a, b;
int nx[] = { 1,0,-1,0 };
int ny[] = { 0,-1,0,1 };
int main() {
	while (1) {
		sum_max = 0;
		cin >> a;
		cin >> b;
		if (a == 0 && b == 0)return 0;
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				cin >> c[i][j];
			}
		}
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				if (c[i][j] == 1) {
					kouri(i, j, 0);
				}
			}
		}
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				c[i][j] = 0;
			}
		}
		cout << sum_max << endl;
	}
}
void kouri(int x, int y, int sum) {
	/*for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) {
			cout << c[i][j]<<" ";
		}
		cout << endl;
	}
	cout << endl << "--------------------------------" << endl;*/
	c[x][y] = 0;
	sum++;
	if (c[x][y + 1] == 1)kouri(x, y + 1, sum);
	if (c[x][y - 1] == 1)kouri(x, y - 1, sum);
	if (c[x + 1][y] == 1)kouri(x + 1, y, sum);
	if (c[x - 1][y] == 1)kouri(x - 1, y, sum);
	c[x][y] = 1;
	if (sum > sum_max)sum_max = sum;
}

Measured memory_bytes: 3108
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
using namespace std;
typedef long long ll;

int main()
{
    double a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    a *= 100;
    b *= 100;
    int ans1,ans2;
    double rest = e;
    double maxc = 0;
    for(int i = 0; i * a <=  f; i++){
        for(int j = 0; i * a + j * b <= f; j++){
            for(int k = 0; i * a + j * b + k * c <= f; k++){
                for(int l = 0; i * a + j * b + k * c + l * d <= f; l++){
                    double w = i * a + j * b;
                    double s = k * c + l * d;
                    if(w + s == 0){
                        break;
                    }
                    double tmp = (double)(s / (w + s)) * (100 + e);
                    if(tmp > rest || w + s > f){
                        break;
                    }else{
                        if(maxc < tmp){
                            maxc = tmp;
                            ans1 = w + s;
                            ans2 = s;
                        }
                    }
                }
            }
        }
    }
    if(ans2 != 0){
        cout << ans1 << ' ' << ans2 << endl;
    }else{
        cout << min(a,b) << ' ' << ans2 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
typedef long long ll;
const int INF = 1<<29;
const int N = 1e6 + 9;
ll a[N];
int main()
{
    fio;
    ll a, b, c;
    cin >> a >> b >> c;
    if((a == b && c != a) || (a == c && b != a) || (b == c && a != c)){
        cout << "Yes";
    }
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool visit[100010];
vector<int>graph[100010];
vector<int>path,path2;
void dfs(int t){
	visit[t]=true;
	path.push_back(t);
	for(int i=0;i<graph[t].size();i++){
		int nxt=graph[t][i];
		if(visit[nxt]==false){
			dfs(nxt);
			return;
		}
	}
}	
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	dfs(1);
	swap(path,path2);
	dfs(1);
	cout<<path.size()+path2.size()-1<<endl;
	for(int i=(int)path2.size()-1;i>=1;i--){
		cout<<path2[i]<<' ';
	}
	for(int i=0;i<(int)path.size();i++){
		cout<<path[i]<<' ';
	}
	cout<<endl;	
	return 0;
}

Measured memory_bytes: 9720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			double f = sc.nextDouble();
			for (int n = 2; ; n++) {
				if ((7 * Math.sqrt(50 * (n - 1))) / 5 >= f) {
					System.out.println(n);
					break;
				}
			}
		}

	}

}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  ll N;
  std::cin >> N;

  if(N % 2 == 1) {
    std::cout << 0 << '\n';
    return 0;
  }

  ll two = N / 2;
  ll five = 0;
  ll tmp;

  tmp = N / 2;
  while(tmp / 2 > 0) {
    two += tmp / 2;
    tmp /= 2;
  }

  tmp = N / 2;
  while(tmp / 5 > 0) {
    five += tmp / 5;
    tmp /= 5;
  }

  std::cout << std::min(two, five) << '\n';

}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int *a = new int[n];
  int *dp = new int[n];
  for(int i=0;i<n;i++)
    cin >> a[i];
  dp[0] = 0; dp[1] = abs(a[1] - a[0]);
  for(int i=2;i<n;i++)
    dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]),dp[i-2] + abs(a[i]-a[i-2]));
  cout << dp[n-1];
           
}


Measured memory_bytes: 4328
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] flowers = new int[N];
    for(int i = 0; i < N; i++) {
      flowers[i] = sc.nextInt();
    }

    Main abc116C = new Main();
    System.out.println(abc116C.solve(flowers));
  }

  public int solve(int[] flowers) {
    int ans = flowers[0];
    for(int i = 1; i < flowers.length; i++ ){
      int delta = flowers[i] - flowers[i-1];
      if(delta > 0) ans += delta;
    }
    return ans;
  }
}


Measured memory_bytes: 21844
package main
  
import (
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)
    as := make([]int, n)
    var suma, sumb int
    for i := 0; i < n; i++ {
        fmt.Scan(&as[i])
        suma += as[i]
    }
    bs := make([]int, n)
    for i := 0; i < (n-1)*2; i += 2 {
        j := i % n
        k := (i + 1) % n
        l := (i + 2) % n
        bs[l] = bs[j] + as[k]*2 - as[j]*2
        sumb += bs[l]
    }
    dl := (suma - sumb) / n
    for i := 0; i < n; i++ {
        if i == n-1 {
            fmt.Println(bs[i] + dl)
        } else {
            fmt.Printf("%d ", bs[i]+dl)
        }
    }
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int h, w;
vector<string> ban;

const int INF = 114514;
const vector<vector<int>> moves{{1,  0},
                                {-1, 0},
                                {0,  1},
                                {0,  -1}};

bool inRange(int x, int y) {
    return 0 <= x && x < h && 0 <= y && y < w;
}

int bfs(int sx, int sy) {
    vector<vector<int>> dis(h, vector<int>(w, INF));
    dis[sx][sy] = 0;

    queue<vector<int>> que;
    que.push({sx, sy}), que.push({-1, -1});
    int depth = 1;
    while (true) {
        vector<int> now = que.front();
        que.pop();
        if (now[0] < 0) {
            if (que.empty())break;
            else que.push({-1, -1}), depth++;
        } else {
            for (auto move:moves) {
                vector<int> next{now[0] + move[0], now[1] + move[1]};
                if (inRange(next[0], next[1]) && ban[next[0]][next[1]] == '.' && dis[next[0]][next[1]] == INF) {
                    dis[next[0]][next[1]] = depth, que.push(next);
                }
            }
        }
    }

    int ret = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (ban[i][j] == '.')ret = max(ret, dis[i][j]);
        }
    }
    return ret;
}

int main() {
    cin >> h >> w;
    ban = vector<string>(h);
    for (int i = 0; i < h; i++)cin >> ban[i];

    int ret = 0;
    for (int sx = 0; sx < h; sx++) {
        for (int sy = 0; sy < w; sy++) {
            if (ban[sx][sy] == '.')ret = max(ret, bfs(sx, sy));
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


bool check(ll x, int N, vector<ll> &h, ll A, ll B){
  // 爆発をx回で全員殺せるか
  ll times = 0;
  ll C = A-B;
  rep(i, N){
    if (h[i] <= x * B) continue; // こいつを中心に爆発させる必要はない
    ll sub = h[i] - x*B; // こいつを中心に爆撃
    times += (sub + C - 1) / C;
  }
  return times <= x;
}

int main() {
  int N; ll A,B; cin >>N >>A >>B;
  vector<ll> h(N); rep(i, N) cin >>h[i];
  int ok = 1000000000, ng = 0;
  while (abs(ok-ng) > 1){
    int mid = (ok + ng) / 2;
    if (check(mid, N, h, A, B)) ok = mid;
    else ng = mid;
  }
  int res = ok;
  cout <<res <<endl;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
ab = [list(map(lambda x:int(x)-1, input().split())) for i in range(m)][::-1]
uf = [-1]*n
def root(a):
    if uf[a]<0:
        return a
    uf[a] = root(uf[a])
    return uf[a]
def unite(a,b):
    ra = root(a)
    rb = root(b)
    if ra == rb:
        return 0
    delta = 0
    # 絶対raのほうが要素数が多いようにする
    if uf[ra] > uf[rb]:
        ra, rb = rb, ra
    if uf[rb] == -1:
        delta = -uf[ra]
    else:
        delta = (uf[ra]*uf[rb])
    uf[ra] += uf[rb]
    uf[rb] = ra
    return delta
huben = n*(n-1)//2
ans = [huben]
for a, b in ab:
    d = unite(a,b)
    huben -= d
    ans.append(huben)
print(*ans[:-1][::-1], sep="\n")

Measured memory_bytes: 36172
#include<stdio.h>
int main(void){
    int a,b,c,d;
    double f;
    scanf("%d%d",&a,&b);
    c=a/b;
    d=a%b;
    f=(double)a/(double)b;
    printf("%d %d %f\n",c,d,f);
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int h, w; cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	vector<vi> d(h * w, vi(h * w, inf));
	rep(i, h) rep(j, w) if(s[i][j] == '.'){
		int cur = i * w + j;
		d[cur][cur] = 0;
		rep(k, 2) if(i + k < h && j + 1 - k < w && s[i + k][j + 1 - k] == '.'){
			int next = (i + k) * w + j + 1 - k;
			d[cur][next] = d[next][cur] = 1;
		}
	}
	rep(k, d.size()) rep(i, d.size()) rep(j, d.size()) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	
	int ans = 0;
	rep(i, d.size()) rep(j, d.size()) if(d[i][j] < inf) ans = max(ans, d[i][j]);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;
ll N;
ll a;

int main(){
  cin>>N;
  bool b = 0;
  rep(i,N){
    cin>>a;
    if(a%2==1) b=1;
  }
  if(b){
    puts("first");
  }
  else{
    puts("second");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
int main() 
{
     fast;
     int n,k;
     cin>>n>>k;
     vi h(n);
     ffor(i,0,n)
     cin>>h[i];
     int dp[n+1];
     ffor(i,0,n+1)
     dp[i]=INT_MAX;
    //  mem(dp, INT_MAX);
     dp[0]=0;
     ffor(i,1,n)
     {      
           ffor(j,1,k+1)
           {
               if(i>=j)
                 dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
           }
     } 
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(true) {
				int n = sc.nextInt();
				int m = sc.nextInt();
			
				if(n==0 && m==0)	break;
			
				int hsum = 0;
				int tsum = 0;
				int[] taro = new int[n];
				int[] hanako = new int[m];
				for(int i=0; i<n;i++) {
					taro[i] = sc.nextInt();
					tsum += taro[i];
				}
				for(int i=0; i<m; i++) {
					hanako[i] = sc.nextInt();
					hsum += hanako[i];
				}
				int tt = 1000;
				int hh = 1000;
			
				for(int i=0; i<n; i++) {
					for(int j=0; j<m; j++) {
						if(tsum - taro[i] + hanako[j] == hsum - hanako[j] + taro[i] && tt + hh > taro[i] + hanako[j]) {
							tt = taro[i];
							hh = hanako[j];
						}
					}
				}
				if(tt == 1000 && hh == 1000) {
					System.out.println(-1);
				}else {
					System.out.println(tt +" "+hh);
				}
				
				
					
				
			}
			
			
			
			
				
		}
	}
}


Measured memory_bytes: 29296
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,a,b;
	cin>>n>>a>>b;

	cout<<min(n*a,b);
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
H,W,K= map(int,input().split())
sx,sy,gx,gy = (i-1 for i in map(int,input().split()))
grid = []
inf = 1<<30
reach = [[inf for _ in range(W)] for _ in range(H)]
reach[sx][sy]=0
dif = [(1,0),(-1,0),(0,1),(0,-1)] #向かう方向

for i in range(H):
    grid.append(list(input()))

que = deque([(sx,sy)])
while que:
    x,y = que.popleft()
    for i in range(4): #方向決め
        for k in range(1,K+1):
            nx = x+k*dif[i][0]
            ny = y+k*dif[i][1]
            if nx<0 or nx>=H or ny<0 or ny>= W or grid[nx][ny] == "@":
                break
            if reach[x][y]+1 > reach[nx][ny]:
                break
            if reach[x][y]+1 < reach[nx][ny]:
                reach[nx][ny] = min(reach[x][y]+1,reach[nx][ny])
                que.append((nx,ny))
            if nx == gx and ny == gy:
                print(reach[nx][ny])
                exit()
print(-1)

Measured memory_bytes: 159396
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline

from collections import deque, defaultdict, Counter

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

cnt = defaultdict(int)
cnt_h = defaultdict(int)
cnt_w = defaultdict(int)

for h, w in hw:
    cnt[(h, w)] += 1

for h, w in hw:
    cnt_h[h] += 1
    cnt_w[w] += 1
cnt_h = list(cnt_h.items())
cnt_w = list(cnt_w.items())
cnt_h.sort(key = lambda x: -x[1])
cnt_w.sort(key = lambda x: -x[1])

max_h = []
max_w = []
for h, n in cnt_h:
    if n == cnt_h[0][1]:
        max_h.append(h)
for w, n in cnt_w:
    if n == cnt_w[0][1]:
        max_w.append(w)

answer = cnt_h[0][1] + cnt_w[0][1]
for mh in max_h:
    for mw in max_w:
        if cnt[(mh, mw)] == 0:
            print(answer)
            exit()

print(answer - 1)

Measured memory_bytes: 246672
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}

template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){
    vector<pair<T,T>> out(input.size()-1);
    rep(i,input.size()-1){
        out[i].first =input[i  ];
        out[i].second=input[i+1];
    }
    return(out);
}
vector<char> String_to_vector_char(const string& input){
    vector<char> out(input.size());
    rep(i,input.size()){
        out[i]=input[i];
    }
    return out;
}

ll a,p;
void input(){
    cin>>a>>p;
}

void src(){
    cout<<(3*a+p)/2;
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    int ans = 1;
    for (int i = 1; i * i <= N; ++i) {
        ans = i * i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())

def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            tmp = []
            tmp.append(i)
            tmp.append(n//i)
            divisors.append(tmp)
    return divisors

L = divisors(N)
ans = float('inf')

for l in L:
    tmp = sum(l) - 2
    ans = min(ans,tmp)
print(ans)

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String longest = "";
        for (int i=0; i<S.length(); i++) {
            for (int j=i+1; j<=S.length(); j++) {
                String temp = S.substring(i,j);
                if (check(temp) && temp.length()>longest.length()) {
                    longest = temp;
                }
            }
        }
        System.out.println(longest.length());
    }
    public static boolean check (String S) {
        for (int i=0; i<S.length(); i++) {
            if (S.charAt(i)!='A' && S.charAt(i)!='C' && S.charAt(i)!='G' && S.charAt(i)!='T') {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 23380
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef complex<ld> Point;
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
int n;
int a[10][3];
int c[10];

bool ok() {
	rep(j, n) {
		if (c[j] == 0)return false;
	}
	return true;
}
bool exi[43200][10];

void output_as_time(int x) {
	string s;
	if (x / 3600 < 10)s += "0";
	s += to_string(x/3600);
	s.push_back(':');
	x %= 3600;
	if (x / 60 < 10)s += "0";
	s += to_string(x / 60);
	s.push_back(':');
	x %= 60;
	if (x < 10)s += "0";
	s += to_string(x);
	cout << s;
}
void solve() {
	while (cin >> n, n) {
		rep(i, 43200) {
			rep(j, n) {
				exi[i][j] = false;
			}
		}
		fill(c, c + n, 0);
		rep(i, n) {
			rep(j, 3) {
				cin >> a[i][j];
			}
		}
		rep(i, n) {
			rep(j, 60) {
				vector<int> v;
				rep(k, 3) {
					v.push_back((a[i][k]+j) % 60);
				}
				sort(v.begin(), v.end());
				while (true) {
					if (v[0] % 5 == v[1] / 12) {
						int sum = (v[0] / 5) * 3600 + v[1] * 60 + v[2];
						exi[sum][i] = true;
					}
					if (!next_permutation(v.begin(), v.end()))break;
				}
			}
		}
		int mi = 50000; int le = 0;
		int ri = 0;
		rep(i, 43200) {
			while (true) {
				if (ok())break;
				if (ri ==43200)break;
				rep(j, n) {
					if (exi[ri][j])c[j]++;
				}
				ri++;
			}
			if (!ok())break;
			if (ri - i < mi) {
				mi = ri - i; le = i;
			}
			rep(j, n) {
				if (exi[i][j])c[j]--;
			}
		}
		output_as_time(le);
		cout << " ";
		output_as_time(le + mi-1);
		cout << endl;
	}
}
int main() {
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI  3.14159265358979323846
#define M   1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }
    }
}
ll f(ll x,ll y)
{
    ll pro=1;
    for(ll i=x;i<=y;i++)
    {
        pro=((pro%M)*(i%M))%M;
    }
    return pro;
}
int main()
{
   ll n,b;
   cin>>n>>b;
   ll ans=0;
   while(n>0)
   {
       n/=b;
       ans++;
   }
   cout<<ans;

}












Measured memory_bytes: 256
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 5e5 + 120;
 

int main(){FAST;
    int n;
    cin >> n;
    n > 999 ? cout << "ABD" : cout << "ABC";


}
 










Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
string s,t;
int n;
cin>>s>>t;
  n = t.length()-1;
if(s == t.substr(0,n)){
 cout<<"Yes";
}
else{
cout<<"No";
}
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 998244353;

int main() {
    input;
    ll n;
    cin >> n;
    double b;
    cin >> b;
    b = b * 100;
    int bb = b;
    ll nn = n * bb;
    debug(n, b, bb, nn);
    nn = nn / 100;
    cout << nn;

}


Measured memory_bytes: 3748
#include <iostream>

using namespace std;

int main(){
    int N, T, cost, time, Min = 1001;
    /* vector<pair<int, int>> routes; */
    scanf("%d %d", &N, &T);
    while(N--){
        scanf("%d %d", &cost, &time);
        if(time <= T)
            if(Min > cost){
                Min = cost;
            }
    }
    if(Min > 1000)
        printf("TLE\n");
    else
        printf("%d\n", Min);
    return 0;
}

Measured memory_bytes: 256
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    a,b=map(int,input().split())
    print(max(a+b,a-b,a*b))
                    
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 5736
n = int(input())
l = list(map(int,input().split()))

l.sort()

ans = 0
for i in range(n-2):
    l1 = l[i]

    l3_ind = i+2
    for j in range(i+1,n):
        l2 = l[j]
        while(True):
            if(l3_ind == n):
                ans += l3_ind - j - 1
                break

            if(l[l3_ind] >= l1+l2):
                ans += l3_ind - j - 1
                break
            l3_ind += 1
            
print(ans)


Measured memory_bytes: 43484
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

bool isPrime(int n ){
	if(n<2)return false;
	for(int i=2;i*i<=n;i++){
		if(n%i==0) return false;
	}
	return true;
}

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

	for(int i=n;i<N;i++){
		if(isPrime(i)){
			cout<<i<<endl;
			return 0;
		}
	}
}

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

fn main() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    s = s.replace("1", "@");
    s = s.replace("9", "1");
    s = s.replace("@", "9");

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


Measured memory_bytes: 4352
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    N, K = MI()
    prob = fractions.Fraction()
    for i in range(1, N + 1):
        if i >= K:
            prob += 1
        else:
            k = K / i
            t = math.ceil(math.log2(k))
            prob += 1 / 2**t
    return float(prob / N)


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 5260
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
const int mod = 998244353;

using namespace std;

int s, n;

void knapsackSubset()		//coeff x^s du polynome Pi(2+x^ai)
{	
	scanf("%d%d", &n, &s);
	int x;
	vector<long long> coeff(3000, 0);
	cin >> x;
	coeff[0] = 2, coeff[x] = 1;
	for(int i = 1; i < n; i++)
	{
		scanf("%d", &x);
		vector<long long>oldCo = coeff; //ancient coordonnes, (ne pas oublier qu'on mulitplie par 2, on doit se rappeler des ancierts coo, quitte a diviser par 2 aussi)
		for (int j = 0; j <= s; j++)
		{
			coeff[j] = (2*coeff[j])%mod;
			if (j >= x)
				coeff[j] += oldCo[j-x];
			coeff[j] %= mod;
		}
	} 
	cout << coeff[s] << endl;	
}

int main()
{
	#ifdef ME
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	knapsackSubset();
	return 0;
}




Measured memory_bytes: 3732
#include <iostream>
using namespace std;
typedef long long ll;
static const ll Z = 1 << 21;

char s[Z];
int main() {
	cin >> s;
	char *p = &s[0];
	while (*p) {
		ll i = 1;
		while (*(p + i)) {
			if (*p == *(p + i++)) {
				cout << "no" << endl;;
				return 0;
			}
		}
		p++;
	}
	cout << "yes" << endl;

	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

void get() {

}

class AGarden {
public:
	void solve(std::istream& in, std::ostream& out) {
		int a, b;
		in >> a >> b;
		out << a * b - (a + b - 1) << '\n';
	}
};


int main() {
	AGarden solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#
# agc027 a
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 70
20 30 10"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 10
20 30 10"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """4 1111
1 10 100 1000"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """2 10
20 20"""
        output = """0"""
        self.assertIO(input, output)


def resolve():
    N, x = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    for i in range(N-1):
        if x - a[i] >= 0:
            x -= a[i]
            ans += 1
    if a[-1] == x:
        ans += 1
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

template<class T>
T gcd(T a, T b)
{
    while (a > 0)
    {
        T t = a;
        a = b%a;
        b = t;
    }
    return b;
}

int main()
{
    long long A, B;
    cin>>A>>B;
    long long C = gcd(A, B);

    long long ans = 1;
    for (long long f=2; f*f<=C; f++)
        if (C%f==0)
        {
            ans++;
            while (C%f==0)
                C /= f;
        }
    if (C>1)
        ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 888
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};
bool use[100010];


vector<edge> te[100010];
vector<edge> fe[100010];
int d[100100];
ll rec(int num) {
	if (num == 0) return 0;
	return rec(num - 1) + num;
}
ll gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll calc(ll b,ll n){
	if (n < b) return n;
	return calc(b, n / b) + n % b;
}

void Solve() {
	int n;
	cin >> n;
	ll a[10010], b[10010];
	for (size_t i = 0; i < n; i++)
		cin >> a[i];
	for (size_t i = 0; i < n; i++)
		cin >> b[i];

	ll ai = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (a[i] <= b[i]) continue;
		while(ai < n)
		{
			if (a[ai] < b[ai]) {
				ll rem = (b[ai] - a[ai]);
				ll ad = min(rem / 2, a[i] - b[i]);
				b[i] += ad;
				a[ai] += ad * 2;
			}
			if (a[i] == b[i]) break;
			ai++;
		}
	}
	
	for (size_t i = 0; i < n; i++)
	{
		if (a[i] > b[i]) {
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes"<< endl;
}


int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,cnt=0,mini;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        mini=i;
        for(int j=i;j<n;j++)
        {
            if(a[j]<a[mini])
            {
                mini=j;
            }
        }
        if(i!=mini)
        {
            swap(a[i],a[mini]);
            cnt++;
        }

    }
    for(int i=0;i<n-1;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<a[n-1]<<endl;
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
using namespace std;
typedef	long long int ll;

int main(){
    int n;
    cin >> n;
    vector<int> a1, a2;
    int a;
    for(int i = 0; i < n; i++){
        cin >> a;
        a1.push_back(a);
    }
    for(int i = 0; i < n; i++){
        cin >> a;
        a2.push_back(a);
    }
    int res;
    vector<int> p;
    for(int i = 0; i < n; i++){
        res = 0;
        for(int j = 0; j <= i; j++){
            res += a1[j];
        }
        for(int j = n-1; j >= i; j--){
            res += a2[j];
        }
        p.push_back(res);
    }
    sort(p.begin(), p.end());
    cout << p[n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heapify, heappop

def main():
    X, Y, Z, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    
    que = []
    heapify(que)
    heappush(que, (-A[0]-B[0]-C[0], 0, 0, 0))
    s = set()
    
    for i in range(K):
        ans = heappop(que)
        print(-ans[0])
        if(ans[1] < X-1 and not (ans[1]+1, ans[2], ans[3]) in s):
            heappush(que, [-A[ans[1]+1]-B[ans[2]]-C[ans[3]], ans[1]+1, ans[2], ans[3]])
            s.add((ans[1]+1, ans[2], ans[3]))
        if(ans[2] < Y-1 and not (ans[1], ans[2]+1, ans[3]) in s):
            heappush(que, [-A[ans[1]]-B[ans[2]+1]-C[ans[3]], ans[1], ans[2]+1, ans[3]])
            s.add((ans[1], ans[2]+1, ans[3]))
        if(ans[3] < Z-1 and not (ans[1], ans[2], ans[3]+1) in s):
            heappush(que, [-A[ans[1]]-B[ans[2]]-C[ans[3]+1], ans[1], ans[2], ans[3]+1])
            s.add((ans[1], ans[2], ans[3]+1))   
main()

Measured memory_bytes: 4980
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> data(M);
    for (int i = 0; i < M; i++) {
        cin >> data.at(i);
    }
    int sum0 = 0;
    int sumN = 0;
    for (int x : data) {
        if (x < X) {
            sum0++;
        }
        else {
            sumN++;
        }
    }
    int ans = min(sum0, sumN);
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(n):
    for j in range(i+1,n):
        dis=0
        for k in range(d):
            dis+=(x[i][k]-x[j][k])**2
        r=math.sqrt(dis)
        if r.is_integer():
            ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 10000
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, k, a[100000];
int ans;

signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (k <= a[i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

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

  B += A * 3;

  int ans = B / 2;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  sort(begin(a),end(a));
  vector<bool> win(k+1);
  for(int i = 1; i <= k; ++i){
    for(int j : a){
      if(j > i) break;
      if(win[i-j] == false){
        win[i] = true;
        break;
      }
    }
  }
  if(win[k]) cout << "First";
  else cout << "Second";
  return 0;
}

Measured memory_bytes: 3652
#include<iostream>

using namespace std;

int main() {

    char s[1000] = {0};

    while (1) {

        cin >> s;

        if(s[0] == '0') {
            break;
        }

        int cnt = 0;

        int i = 0;
        while (1) {
            if ('0' <= s[i] && s[i] <= '9') {
                cnt += s[i] - '0';
            } else {
                break;
            }
            i++;
        }

        cout << cnt << endl;

    }

    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;

int main(void) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while (1) {
        c -= b;
        if (c<=0) {
            puts("Yes");
            return 0;
        }
        a -= d;
        if (a<=0) {
            puts("No");
            return 0;
        }
    }
    



	return 0;
}


Measured memory_bytes: 3624
/*
sonu_verma1
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(a) push_back(a)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
	ll a,b,c;
	cin>>a>>b>>c;
	ll d=c-a-b;
	if(d*d>4*a*b&&d>0)
		cout<<"Yes";
	else
		cout<<"No";


	return 0;
}

Measured memory_bytes: 256