akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		String line;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while ((line = br.readLine()) != null) {
			if (line.equals("0")) {
				break;
			}
			
			int sum = 0;
			for (char c : line.toCharArray()) {
				sum += c - '0';
			}
			
			System.out.println(sum);
		}
	}

}

Measured memory_bytes: 24324
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int[][] A = new int[4][4];
		for (int i = 1; i <= 3; i++) {
			for (int j = 1; j <= 3; j++) {
				A[i][j] = sc.nextInt();
			}
		}

		int N = sc.nextInt();

		for (int k = 0; k < N; k++) {
			int b = sc.nextInt();

			for (int i = 1; i <= 3; i++) {
				for (int j = 1; j <= 3; j++) {
					if (A[i][j] == b) {
						A[i][j] = -1;
					}
				}
			}
		}

		sc.close();

		String ans = "No";

		for (int i = 1; i <= 3; i++) {
			boolean z = true;
			for (int j = 1; j <= 3; j++) {
				if (A[i][j] != -1) {
					z = false;
				}
			}

			if (z) {
				ans = "Yes";
				break;
			}
			z = true;
			for (int j = 1; j <= 3; j++) {
				if (A[j][i] != -1) {
					z = false;
				}
			}
			if (z) {
				ans = "Yes";
				break;
			}
		}

		if (A[1][1] == -1 && A[2][2] == -1 && A[3][3] == -1) {
			ans = "Yes";
		}

		if (A[3][1] == -1 && A[2][2] == -1 && A[1][3] == -1) {
			ans = "Yes";
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll l,r;cin>>l>>r;
	if((r-l+1)>=2019){
		cout<<0<<endl;
		return 0;
	}
	ll ans = 2019;
	Foe(i,l,r) Foe(j,l,r){
		if(i==j) continue;
		ans = min(ans,(i*j)%2019);
	}
	cout<<ans<<endl;































	
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

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

        ArrayList<Integer> board = new ArrayList<>();
        for (int i = 0; i < 9; i++) {
            board.add(cin.nextInt());
        }

        int num = cin.nextInt();

        for (int i = 0; i < num; i++) {
            int temp = cin.nextInt();
            int index = board.indexOf(temp);
            while (index != -1) {
                board.set(index, 0);
                index = board.indexOf(temp);
            }
        }

        if (bingo(board)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static boolean bingo(ArrayList<Integer> board) {
        for (int i = 0; i < 3; i++) {
            if (board.get(3 * i) == 0 && board.get(1 + 3 * i) == 0 && board.get(2 + 3 * i) == 0) {
                return true;
            }
            if (board.get(i) == 0 && board.get(i + 3) == 0 && board.get(i + 6) == 0) {
                return true;
            }
        }
        if (board.get(0) == 0 && board.get(4) == 0 && board.get(8) == 0) {
            return true;
        }
        if (board.get(2) == 0 && board.get(4) == 0 && board.get(6) == 0) {
            return true;
        }

        return false;
    }

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
/* Solution by divyanshu0x16*/
#define int           long long 
#define setbits(x)    __builtin_popcountll(x)
#define zerobits(x)   __builtin_ctzll(x)
#define mod           1000000007 
#define modulo(a, b)  (a%b<0 ? a%b+b : a%b)
#define intpow(a,b)   (int)(pow(a,b) + 0.5)
#define gcd(a,b)      __gcd(a, b)
#define all(x)        (x).begin(), (x).end()
#define ps(x, y)      fixed<<setprecision(y)<<x
#define testcase(x)   int x; cin >> x; while(x--)
#define fastIO        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set   tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef stack<int> si;
typedef queue<int> qi;
typedef priority_queue<int> pqi;

int power(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}

int32_t main() {
    fastIO;
    int t = 1;
    while(t--){
        int s; cin >> s;
        vector<int> dp(s+1, 0);
        dp[0] = 1;
        for (int i = 3; i <= s; i++){
            for (int j = i-3; j >= 0; --j)
                (dp[i]+=dp[j])%=mod;  
        }
        cout << dp[s] << "\n";
    }
    return 0;
}
 

Measured memory_bytes: 3640
n,x,y=map(int,input().split())
ans=[0]*n
for i in range(1,n+1):
  for j in range(i+1,n+1):
    dist1=j-i
    dist2=abs(x-i)+abs(y-j)+1
    dist3=abs(y-i)+abs(x-j)+1
    d=min(dist1,dist2,dist3)
    ans[d]+=1
for i in range(1,n):
  print(ans[i])

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

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

  int i = 1;
  while ((1 + i) * i / 2 < X) {
    i++;
  }

  cout << i << endl;
  return 0;
}


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

int main(){
    int a,b;
    string s;
    cin>>a>>b>>s;
    if(s[a]!='-'){
        cout<<"No"<<endl;
        return 0;
    }
    bool ok=true;
    rep(i,s.size()){
        if(i!=a && '0'<=s[i] && s[i]<='9')ok=true;
        else if(i==a){
            ok=true;
        }
        else{
            ok=false;
            break;
        }
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
S = list(input())
for i in range(len(S)):
    S[i] = int(S[i])
S.reverse()
ans = []
cnt = 0
flag = True
i = 0
while i < N:
    for j in range(0,min(M, N-i)):
        if S[i+min(M,N-i)-j] == 0:
            ans.append(min(M,N-i)-j)
            i += min(M,N-i)-j
            break
    else:
        flag = False
        break
    continue
ans.reverse()
if flag:
    print(*ans)
else:
    print(-1)
        

Measured memory_bytes: 60920
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int n, m;
string s1,s2,s3;
int main() {
  cin>>s1>>s2>>s3;
  string ans="";
  ans.push_back(s1[0]-'a'+'A');
  ans.push_back(s2[0]-'a'+'A');
  ans.push_back(s3[0]-'a'+'A');
  cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n,t,x,y,lt,lx,ly;
int main(){
//	freopen("C.in","r",stdin);
//	freopen("C.out","w",stdout);
	scanf("%d",&n);
	lt=lx=ly=0;
	bool flag=true;
	for (int i=0;i<n;i++){
		scanf("%d%d%d",&t,&x,&y);
		if (abs(x-lx)+abs(y-ly)>t-lt) flag=false;
		else if (abs(abs(x-lx)+abs(y-ly)-t+lt)%2!=0) flag=false; 
		lt=t,lx=x,ly=y;
	}
	if (flag) printf("Yes\n");
	else printf("No\n");
	fclose(stdin);fclose(stdout);
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)
var n int

func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}



func main()  {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d", &n)
	var ret = int64(0)

	for i := 1; i <= n; i++ {
		for j := 1; j <= n; j++ {
			for k := 1; k <= n; k++ {
				ret += int64(GCD(GCD(i, j), k))
			}
		}
	}
	fmt.Fprintf(writer, "%d", ret)
}


Measured memory_bytes: 1876
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, K;
signed main(){
	cin >> N >> K;
	int ans = 1;
	while(N >= K){
		N /= K;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,m;
  scanf("%d %d\n",&n,&m);
  int l[m],r[m];
  for(int i=0; i < m; ++i) scanf("%d %d\n",&l[i],&r[i]);
  int min = n;
  int max = 1;
  for(int i=0; i < m; ++i){
    if(l[i] > max) max = l[i];
    if(r[i] < min) min = r[i];
  }
  int answer = min - max + 1;
  if(answer < 0) answer = 0;
  printf("%d\n",answer);
  return 0;
}

Measured memory_bytes: 896
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Cm = []
Cp = []
for i in range(N):
	if(A[i]-B[i]<0):
		Cm.append(A[i]-B[i])
	elif(A[i]-B[i]>0):
		Cp.append(A[i]-B[i])
Cm.sort()
Cp.sort()


if(len(Cm) == 0):
	print(0)
	exit(0)
if(sum(Cp)<abs(sum(Cm))):
	print(-1)
	exit(0)

j=0
i = 0
nowCp = int(Cp[len(Cp)-i-1])


while(j<len(Cm)):
	if(nowCp>=abs(Cm[j])):
		nowCp -= abs(Cm[j])
		j += 1
	elif(nowCp<abs(Cm[j]) and i<len(Cp)):
		i += 1
		nowCp += int(Cp[len(Cp)-i-1])

	else:
		break
	

if(j == len(Cm)):
	print(j+i+1)
else:
	print(-1)


Measured memory_bytes: 18292
import math
N,M=map(int,input().split())
def primecheck(K):
    A=int(math.sqrt(K))+1
    for i in range(2,A+1):
        if K%i==0:
            return i
    return 1
D=dict()
while(True):
    X=int(math.sqrt(M))+1
    for i in range(2,X+1):
        if M%i==0:
            while(True):
                if i in D:
                    D[i]+=1
                else:
                    D[i]=1
                M=M//i
                if M%i!=0:
                    break
    j=primecheck(M)
    if j==1:
        if M==1:
            break
        D[M]=1
        break
    else:
        if j in D:
            D[j]=1
        else:
            D[j]+=1
P=10**9+7
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
def inv(x):
    return egcd(x,P)[0]
Y=2*10**5
Fact=[0 for i in range(Y+1)]
Finv=[0 for i in range(Y+1)]
Fact[0]=1
Finv[0]=1
for i in range(Y):
    Fact[i+1]=(Fact[i]*(i+1))%P
    Finv[i+1]=inv(Fact[i+1])%P
def C(n,k):
    return (Fact[n]*(Finv[k]*Finv[n-k])%P)%P
ans=1
for p in D:
    e=D[p]
    ans=ans*C(e+N-1,N-1)
    ans=ans%P
print(ans)


Measured memory_bytes: 56524
using System;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static List<List<int>> graph;
        const int N = 100000;
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(" ").Select(s => long.Parse(s)).ToList();
            long n = input[0], m = input[1];

            graph = new List<List<int>>();
            for (var i = 0; i < 3 * N; i++)
            {
                graph.Add(new List<int>());
            }
            for (var i = 0; i < m; i++)
            {
                var line = Console.ReadLine().Split(" ").Select(s => Int32.Parse(s)).ToList();
                var u = line[0] - 1;
                var v = line[1] - 1;
                graph[u].Add(v + N);
                graph[u + N].Add(v + 2 * N);
                graph[u + 2 * N].Add(v);
            }

            var l = Console.ReadLine().Split(" ").Select(s => Int32.Parse(s)).ToList();
            int s = l[0] - 1, t = l[1] - 1;

            List<(int next, int distance)> queue = new List<(int, int)>();
            List<long> steps = new List<long>(new long[3*N]);
            steps = steps.Select(s=>s=long.MaxValue).ToList();
            queue.Add((s, 0));
            while(queue.Count > 0){
                var cur = queue.First().next;
                var d = queue.First().distance;
                queue.RemoveAt(0);

                foreach(var g in graph[cur]){
                    if(steps[g] == long.MaxValue){
                        steps[g] = d + 1;
                        queue.Add((g, d+1));
                    }
                }
            }

            if (steps[t] == long.MaxValue)Console.WriteLine(-1);
            else Console.WriteLine(steps[t] / 3);
        }
    }
}

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

ab = 0 #naka
a = 0 #matsubinomi
b = 0 #sentounomi
ba = 0 #ryouhou

def count(s):
    l = len(s)
    ret = 0
    for i in range(l-1):
        if s[i] == 'A' and s[i+1] == 'B':
            ret += 1
    return ret

for _ in range(N):
    s = input()
    if s[-1] == 'A' and s[0] == 'B':
        ba += 1
    if s[-1] == 'A' and s[0] != 'B':
        a += 1
    if s[-1] != 'A' and s[0] == 'B':
        b += 1
    ab += count(s)
    
ans = ab
if ba > 0:
    ans += ba - 1
    if a > 0:
        a -= 1
        ans += 1
    if b > 0:
        b -= 1
        ans += 1
    ans += min(a,b)
else:
    ans += min(a,b)
print(ans)

Measured memory_bytes: 3064
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> T in() { T v; cin >> v; return v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

#define WHITE true
#define BLACK false

vector<pair<int, int> > DXDY { {1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1} };
const int H = 50;
const int W = 100;

int main() {
  ll a = in<ll>(), b = in<ll>();
  bool G1[H][W];
  bool G2[H][W];
  loop(y,0,H) loop(x,0,W) G1[y][x] = BLACK;
  loop(y,0,H) loop(x,0,W) G2[y][x] = WHITE;
  a--;b--;
  loop(y,0,H-1) { // 一番下は黒いエリアに隣接してるので除外.
    loop(x,0,W) {
      if (a==0) break;
      bool ok = true; // 四方がすべて黒なら白に出来る.
      for (auto dxdy: DXDY) {
        int y1 = y + dxdy.first;
        int x1 = x + dxdy.second;
        if (y1 < 0) continue; // はみ出してるのは考慮不要.
        if (x1 < 0 or x1 >= W) continue;
        ok &= G1[y1][x1] == BLACK;
      }
      if (ok) {
        a--;
        G1[y][x] = WHITE;
      }
    }
  }
  loop(y,1,H) { // 一番上は白いエリアに隣接してるので除外.
    loop(x,0,W) {
      if (b==0) break;
      bool ok = true; // 四方がすべて白なら黒に出来る.
      for (auto dxdy: DXDY) {
        int y1 = y + dxdy.first;
        int x1 = x + dxdy.second;
        if (y1 >= H) continue; // はみ出してるのは考慮不要.
        if (x1 < 0 or x1 >= W) continue;
        ok &= G2[y1][x1] == WHITE;
      }
      if (ok) {
        b--;
        G2[y][x] = BLACK;
      }
    }
  }
  cout << "100 100" << endl;
  
  loop(y,0,H) {
    loop(x,0,W) {
      if (G1[y][x] == BLACK) cout << "#";
      else cout << ".";
    }
    cout << endl;
  }
  loop(y,0,H) {
    loop(x,0,W) {
      if (G2[y][x] == BLACK) cout << "#";
      else cout << ".";
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3644
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
map<string,int>mp;
int Xiaobo()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) {
		string s;
		cin>>s;
		mp[s]++;
	} 
	int mx=-1;
	for(auto item:mp) {
		if(item.second>mx) mx=item.second;
	}
	for(auto item:mp) {
		if(item.second==mx) cout<<item.first<<'\n';
	}
	return 0;
}


Measured memory_bytes: 25216
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll H(N);
  ll now = 0;
  ll current = 0;
  ll longest = 0;
  REP(i, 0, N) {
    ll h;
    cin >> h;
    H[i] = h;

    if (i == 0) {
      now = h;
      continue;
    }

    if (now >= h) {
      current++;
    } else {
      if (longest < current) {
        longest = current;
      }
      current = 0;
    }
    now = h;
  }
  if (longest < current) {
    longest = current;
  }
  cout << longest << endl;

  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  int N, L; cin >> N >> L;
  vector<string> S(N); for (auto& s : S) cin >> s;
  sort(S.begin(), S.end());
  for (auto s : S) cout << s;
  cout << '\n';
  return 0;
}


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

#define all(x) x.begin(), x.end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, LN = 17, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int f[26];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int ret =0;
    for (int i =0; i <min(n,k); i++)ret+=x;
    for (int i =0; i < max(0,n-k);i++)ret+=y;
    cout << ret <<'\n';
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static long Mod = (long)1e9 + 7;
        static long[] primes = new long[1001];
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var HWK = Sarray();
            var H = HWK[0];
            var W = HWK[1];
            var K = HWK[2];
            var sH = new bool[H];
            var ban = new string[H];
            for (var i = 0; i < H; ++i)
            {
                ban[i] = ReadLine();
                if (ban[i].Contains('#'))
                    sH[i] = true;
            }
            var cnt = 0L;
            var setu = new long[H , W];
            for (var h = 0; h < H; ++h)
            {
                if (!sH[h])
                    continue;
                ++cnt;
                var isFirst = true;
                for (var w = 0; w < W; ++w)
                {
                    if (ban[h][w] == '#')
                    {
                        if (!isFirst)
                            ++cnt;
                        isFirst = false;
                    }
                    setu[h, w] = cnt;
                }
            }
            for (var h = 1; h < H; ++h)
            {
                if (setu[h, 0] != 0)
                    continue;
                for(var w=0;w<W;++w)
                setu[h, w] = setu[h - 1, w];
            }

            for (var h = H-1; 0<=h ; --h)
            {
                if (setu[h, 0] != 0)
                    continue;
                for (var w = 0; w < W; ++w)
                    setu[h, w] = setu[h + 1, w];
            }

            for (var h = 0; h < H; ++h)
            {
                for (var w = 0; w < W; ++w)
                    Write($"{setu[h, w]} ");
                WriteLine();
            }
            //Out.Flush();
        }
    }
}


Measured memory_bytes: 18764
#include<stdio.h>
#define INF 20000000

void matrixChainOrder(int );
int min(int, int);
struct matrix{

  int height;
  int width;

};

struct matrix inputdata[200];

int outputdata[200][200];
int p[200];


int main(){

  int i,j,summatrix;

  scanf("%d",&summatrix);

  for(i = 1; i<= summatrix; i++){

    scanf("%d",&inputdata[i].height);
    scanf("%d",&inputdata[i].width);

  }

  for(i = 1; i <= summatrix ; i++){

 
    p[i-1] = inputdata[i].height;

  }

  p[summatrix] = inputdata[summatrix].width;


  matrixChainOrder(summatrix);

  printf("%d\n",outputdata[1][summatrix]);
  return 0;

}


void matrixChainOrder(int summatrix){

  int i,j,l,k,q;

  for(i = 1; i <=summatrix; i++){

    outputdata[i][i] = 0;

  }

  for(l = 2; l <= summatrix; l++){

    for(i = 1; i <= summatrix-l+1;i++){

      j = i+l-1;

      outputdata[i][j] = INF;

      for(k = i; k <= j-1; k++){

	q = outputdata[i][k] + outputdata[k+1][j] + p[i-1]*p[k] * p[j];

	outputdata[i][j] = min(outputdata[i][j],q);

      }

    }

  }

}

int min(int x,int y){

  if(x > y){

    return y;

  }

  else{

    return x;

  }

}

Measured memory_bytes: 676
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

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

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


int main(void) {
	
	int a, b, c,i,count=0;
	scanf("%d %d %d", &a, &b, &c);
	//if (a == b) printf("0");
	for (i = a; i <= b; i++) {
		if (c%i == 0) count++;
	}

	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 596
from itertools import product


def solve(string):
    h, w, *s = string.split()
    h, w = int(h), int(w)
    s = ["#" * (w + 2)] + ["#" + _s + "#" for _s in s] + ["#" * (w + 2)]
    ans = 0
    d = [(1, 0), (-1, 0), (0, 1), (0, -1)]

    def n(q, cx, cy):
        for x, y in d:
            nx = cx + x
            ny = cy + y
            if s[nx][ny] == ".":
                q.append((nx, ny, cx, cy))

    for _h, _w in product(range(1, h + 1), range(1, w + 1)):
        if s[_h][_w] == "#":
            continue
        q = list()
        n(q, _h, _w)
        if len(q) > 2:
            continue
        c = [[h * w] * (w + 2) for _ in range(h + 2)]
        c[_h][_w] = 0
        while q:
            cx, cy, px, py = q.pop()
            if c[px][py] + 1 >= c[cx][cy]:
                continue
            c[cx][cy] = c[px][py] + 1
            n(q, cx, cy)
        for i, j in product(range(1, h + 1), range(1, w + 1)):
            ans = max(ans, c[i][j] * (s[i][j] == "."))
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


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

using namespace std;

int n;
vector<string> ans;

void d(string s, char app, char last, int len)
{
    s += app;
    if (len == n)
        ans.push_back(s);
    else
    {
        for (int i = 'a'; i <= last; i++)
            d(s, i, last, len + 1);
        d(s, last + 1, last + 1, len + 1);
    }
}

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

	cin >> n;

    d("", 'a', 'a', 1);

    for (auto a : ans)
        cout << a << "\n";

	return 0;
}

Measured memory_bytes: 7796
#![allow(unused_imports)]pub mod pcl{}
fn main() {
    let (n, a, b) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let sp: Vec<_> = s
            .split_whitespace()
            .map(|x| x.parse::<i64>().unwrap())
            .collect();
        (sp[0], sp[1], sp[2])
    };
    let ab = a + b;
    let res = (n / ab) * a + std::cmp::min(a, n % ab);
    println!("{}", res);
}



Measured memory_bytes: 4352
n=int(input())

a=list(map(int, input().split()))
Alice=[]
Bob=[]
a.sort(reverse=True)

for i in range(0,n,2):
    Alice.append(a[i])
    if i!=n-1:
        Bob.append(a[i+1])
    
d=sum(Alice)-sum(Bob)
print(d)

Measured memory_bytes: 3060
/* compatible with http://kk.kake.info.waseda.ac.jp/~kakehi/lp12/wl/ */
#include <stdio.h>
enum{M=5000};
bigint_init(int a[], int x){
	int z;
	z=0;
	while(z<=M){a[z]=0;z=z+1;}
	a[M]=0;
	while(x/10){a[a[M]]=x%10;a[M]=a[M]+1;x=x/10;}
	a[a[M]]=x%10;
	a[M]=a[M]+1;
}
bigint_print(int a[]){
	int i;
	i=a[M]-1;
	while(i>-1){fputc(a[i]+'0',stdout);i=i-1;}
}
bigint_add(int a[], int x[]){
	int i,c;
	i=0;
	c=0;
	while(i<M){
		a[i]=a[i]+x[i]+c;
		c=a[i]/10;
		a[i]=a[i]%10;
		if(a[i])a[M]=i+1;
		i=i+1;
	}
}
bigint_mul(int _a[], int x[]){
    int i=_a[M]-1,j,c=0;
    int a[M];
    while(c<M){a[c]=0;c=c+1;}
	c=0;
    for(;~i;i--)
      for(j=0;j<x[M];j++)
        a[i+j]+=_a[i]*x[j];
    for(i=0;i<M;i++){
      a[i]+=c;
      c=a[i]/10,a[i]%=10;
      if(a[i])_a[M]=i+1;
    }
    memcpy(_a,a,sizeof(a));
}

int main(){
	int f1[M+1],f2[M+1],f3[M+1];
	bigint_init(f1,1);
	int i=2,n;
	while(i<1501){
		bigint_init(f2,i);
		bigint_mul(f1,f2);
		i=i+1;
	}
	bigint_init(f2,2);
	bigint_add(f1,f2);
	bigint_print(f1);
	fputc('\n',stdout);
	i=0;
	scanf("%d",&n);
	while(i<n){
		bigint_init(f1,i+2);
		bigint_print(f1);
		fputc('\n',stdout);
		i=i+1;
	}
	return 0;
}

/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/

Measured memory_bytes: 640
#include<stdio.h>
using namespace std;

int main(){
    int m,f,r;
    while(1){
        scanf("%d %d %d", &m,&f,&r);
        if(m==-1 && f==-1 && r==-1){
            break;
        }else{
            if(m == -1){
                printf("F\n");
            }else if(f==-1){
                printf("F\n");
            }
            else if(m+f >= 80){
                printf("A\n");
            }else if(m+f >= 65 && m+f < 80){
                printf("B\n");
                }
            else if(m+f >= 50 && m+f < 65){
                printf("C\n");
                }
            else if(m+f >= 30 && m+f < 50){
                if(r >= 50){
                    printf("C\n");
                }else{
                    printf("D\n");
                }
            }
            else{
                printf("F\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if(N%10==3){
    cout << "bon" <<endl;
  }
  else if(N%10==0||N%10==1||N%10==6||N%10==8){
    cout << "pon" <<endl;
  }
  else{
    cout << "hon" <<endl;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>

int main() {
	int c_pos = -1;
	bool ans = false;
	std::string s;
	
	std::cin >> s;
	
	for(int i = 0; i < s.length(); i++){
		if(s[i] == 'C') c_pos = i;
		if(s[i] == 'F' && c_pos != -1) ans = true; 
	}
	
	std::cout << (ans ? "Yes" : "No") << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 ALL(a) a.begin(),a.end()
int main()
{
    int N;
    cin >> N;
    cout << N*N << endl;
    return 0;
}

Measured memory_bytes: 256
const int N = 400005;
const int LG = 21;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <bitset>
#include <deque>

using namespace std;

#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

ll n, k;

ll f(ll n, ll k)
{
    return inq(k, n / 2) * (n % 2 ? k : 1) % MOD;
}

ll ans = 0;
ll res[5050];

signed main()
{
    srand(time(NULL));
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
    cin >> n >> k;
    vector<int> divs;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            divs.push_back(i);
            if (i * i != n) divs.push_back(n / i);
        }
    }
    sort(all(divs));
    for (int i = 0; i < divs.size(); i++)
    {
        res[i] = f(divs[i], k);
        for (int j = 0; j < i; j++)
        {
            if (divs[i] % divs[j] == 0)
            {
                res[i] = (res[i] + MOD - res[j]) % MOD;
            }
        }
        if (divs[i] % 2 == 0) ans = (ans + res[i] * divs[i] / 2) % MOD;
        else ans = (ans + res[i] * divs[i]) % MOD;
    }
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
N is set to 4e5 but be careful in problems with large constant factor.
Check corner cases.
No def int long long for now.
*/


Measured memory_bytes: 256
import itertools
dic={"61":"z","62":".","63":"?","64":"!","65":" "}
cnt=ord("a")
for i in itertools.product(range(1,6),repeat=2):
    dic["".join(map(str,i))]=chr(cnt)
    cnt+=1

while True:
    try:
        s=raw_input()
    except EOFError:
        break
    if len(s)%2!=0:
        print "NA"
    else:
        try:
            print "".join(dic[s[i:i+2]] for i in range(0,len(s),2))
        except KeyError:
            print "NA"

Measured memory_bytes: 4388
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using ull = unsigned long long;
using namespace std;

ll M = 1000000007;


void solve()
{
	int n;
	string s;
	cin >> n >> s;
	vector<set<int>> al(26);
	rep(i, n)
	{

		al[s[i] - 'a'].insert(i);
	}
	int q;
	cin >> q;
	rep(i, q)
	{
		int type;
		cin >> type;
		if (type == 1)
		{
			int i_q;
			char c_q;
			cin >> i_q >> c_q;
			i_q--;
			al[s[i_q] - 'a'].erase(i_q);
			s[i_q]=c_q;
			al[c_q - 'a'].insert(i_q);
		}
		else
		{
			int l, r;
			cin >> l >> r;
			l--;
			r--;
			//cout << l << " " << r << endl;
			int cnt = 0;
			FOR(j, 0, 26)
			{
				int t;
			
					t = *al[j].lower_bound(l);
					//char a = 'a' + j;
					//cout << a << " " << t << endl;
					if (l <= t && t <= r&&al[j].count(t) )
					{
						cnt++;
					}
				
			}
			cout << cnt << endl;
		}
	}
}

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


Measured memory_bytes: 24348
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

const ll INF=1e18;
int N;
const int MAX_V=100100;
vector<vector<pair<int,ll>>> to;
ll d[MAX_V];

void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> que;
    fill(d,d+N,INF);
    d[s]=0;
    que.push(P(0,s));

    while(!que.empty()){
        P p=que.top();que.pop();
        ll v=p.second;
        if(d[v]<p.first)continue;

        for(int i=0;i<to.at(v).size();i++){
            pair<int,ll> e=to.at(v).at(i);
            if(d[e.first]>d[v]+e.second){
                d[e.first]=d[v]+e.second;
                que.push(P(d[e.first],e.first));
            }
        }
    }
}

int main() {
    int M;
    cin>>N>>M;
    to.resize(N,vector<pair<int,ll>>(0));
    rep(i,M){
        int L,R;
        ll C;
        cin>>L>>R>>C;
        --L;--R;
        to.at(L).pb({R,C});
    }
    rep(i,N-1){
        to.at(i+1).pb({i,0});
    }

    dijkstra(0);
    if(d[N-1]==INF){cout<<-1<<endl;}
    else{cout<<d[N-1]<<endl;}
}

Measured memory_bytes: 9340
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt(),a = scanner.nextInt(),b = scanner.nextInt();
		if(b <= a){
			System.out.println("delicious");
		}else if(b > a && b-x <= a){
			System.out.println("safe");
		}else{
			System.out.println("dangerous");
		}
	}

}


Measured memory_bytes: 20820
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
A, B, C = 0, 0, 0


def set_inputs():
    global A, B, C
    A, B, C = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    x, y, z = sorted([A, B, C])
    xd, xm = divmod(x, 2)
    yd, ym = divmod(y, 2)
    zd, zm = divmod(z, 2)
    m = xm + ym + zm
    if m == 0 or m == 3:
        print(zd - xd + zd - yd)
    elif m == 2:
        print(zd - xd + zd - yd + 2)
    else:
        print(zd - xd + zd - yd + 1)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5136
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
char ss[10];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    scanf("%s",ss+1);
    if(ss[3]==ss[4] && ss[5]==ss[6])puts("Yes");
    else puts("No");
    return 0;
}

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

using namespace std;

#define ll long long




void solve() {

	int n;
	cin >> n;
	int arr[n + 1];
	for(int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++) {
		if(i & 1 && arr[i] & 1) {
			cnt++;
		}
	}
	cout << cnt;




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3632
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
   
#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e12 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a[N], f[N];
ll ans, k;

inline bool check (ll x) {
   ll res = 0;
   for (int i = 1; i <= n; i ++) {
      ll need = a[i] - x / f[i];
      if (need <= 0) continue;  
      res += need;
   }
   return (res <= k);
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> k;
   for (int i = 1; i <= n; i ++) cin >> a[i];
   for (int i=  1; i <= n; i ++) cin >> f[i];
   sort (a + 1, a + n + 1);
   sort (f + 1, f + n + 1);
   reverse (f + 1, f + n + 1);
   ll l = -1, r = inf + 1;
   while (r - l > 1) {
      ll mid = l + r >> 1;
      if (check (mid)) r = mid;
      else l = mid;
   }
   cout << r;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 1792
N=int(input())
s=input().strip().split()
for j in range (N):
  n=int(s[j])
  if n %2 ==0:
    if n % 3 != 0 and n % 5 != 0:
      print("DENIED")
      break
  if j==N-1:
    print("APPROVED")

Measured memory_bytes: 2940
package main

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

func lib_AbsInt64(value int64) int64 {
	return int64(math.Abs(float64(value)))
}
func lib_MinInt64(values ...int64) (min int64, err error) {
	if len(values) == 0 {
		return 0, errors.New("empty slice is given")
	}
	min = values[0]
	for _, value := range values {
		if min > value {
			min = value
		}
	}
	return
}
func lib_MustMinInt64(values ...int64) (min int64) {
	min, err := lib_MinInt64(values...)
	if err != nil {
		panic(err)
	}
	return min
}
func lib_NewInt64SliceWithInitialValue(length int, initialValue int64) []int64 {
	ret := make([]int64, length)
	for i := 0; i < length; i++ {
		ret[i] = initialValue
	}
	return ret
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int64
	scanner.Scan()
	N, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	var K int64
	scanner.Scan()
	K, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	h := make([]int64, N)
	for i := int64(0); i < N; i++ {
		scanner.Scan()
		h[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)
	}
	fmt.Println(solve(N, K, h))
}
func solve(N int64, K int64, h []int64) int64 {
	dummyH := make([]int64, K)
	h = append(h, dummyH...)
	dp := lib_NewInt64SliceWithInitialValue(int(N+K), math.MaxInt64/2)
	dp[0] = 0
	for i := 0; i < int(N); i++ {
		for j := 1; j <= int(K); j++ {
			dp[i+j] = lib_MustMinInt64(dp[i+j], dp[i]+lib_AbsInt64(h[i]-h[i+j]))
		}
	}
	return dp[N-1]
}


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

int main(){
    long long x;
    cin >> x;
    for(long long A=-200; A<=200; A++){
        for(long long B=A-1; B>=-201; B--){  
            long long A5 = A*A*A*A*A;
            long long B5 = B*B*B*B*B;
            if(A5-B5==x){
                cout << A << " " << B << endl;
                return 0;
            }
        }      
    }

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 305;
const int P = 1e9 + 7;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
bool vis[MAXN * 2];
int n, a[MAXN * 2], dp[MAXN * 2][MAXN][MAXN];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	read(n);
	for (int i = 1; i <= n * 2; i++) {
		read(a[i]);
		if (a[i] == -1) a[i] = 0;
	}
	for (int i = 1; i <= n * 2; i += 2) {
		if (a[i] != 0 && a[i + 1] != 0) {
			int x = a[i], y = a[i + 1];
			for (int j = 1; j <= n * 2; j++)
				a[j] -= (a[j] >= x) + (a[j] >= y);
			for (int j = i; j <= n * 2; j++)
				a[j] = a[j + 2];
			n--, i -= 2;
		}
	}
	int now = 0, ans = 1;
	for (int i = 1; i <= n * 2; i += 2) {
		vis[a[i]] = vis[a[i + 1]] = true;
		if (a[i] == 0 && a[i + 1] == 0) ans = 1ll * ans * ++now % P;
	}
	dp[1][0][0] = 1;
	for (int i = 1; i <= n * 2; i++) {
		for (int j = 0; j <= n; j++)
		for (int k = 0; j + k <= n; k++) {
			int tmp = dp[i][j][k];
			if (tmp == 0) continue;
			if (vis[i]) {
				update(dp[i + 1][j][k + 1], tmp);
				if (j) update(dp[i + 1][j - 1][k], 1ll * j * tmp % P);
			} else {
				update(dp[i + 1][j][k + 1], tmp);
				update(dp[i + 1][j + 1][k], tmp);
				if (k) update(dp[i + 1][j][k - 1], tmp);
			}
		}
	}
	cout << 1ll * ans * dp[n * 2 + 1][0][0] % P << endl;
	return 0;
}

Measured memory_bytes: 217344
//
// Created by kuroneko on 2019-08-04.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

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

    a[0] -= 1;
    for (int i = 1; i < N - 1; i++) {
        if (a[i] - a[i+1] > 1 || (a[i] - a[i+1] == 1 && a[i] - a[i-1] <= 0)) {
            cout << "No" << endl;
            return 0;
        } else if (a[i] - a[i+1] <= 1 && a[i] - a[i-1] > 0){
            a[i] -= 1;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 888