akhauriyash/Code-Regression huggingface dataset:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      int output = 0;
      for(int i = 0; i < N; i++){
        ArrayList<Integer> tmp = nextIntArray();
        int L = tmp.get(0);
        int R = tmp.get(1);
        output += R - L + 1;
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 34292
#include <bits/stdc++.h>
#define ll long long int 
#define endl '\n'
#define INF 1000000000
#define MOD 1000000007
#define MAX 100000000 
#define mp make_pair
#define pb push_back
using namespace std;
vector<int> graph[100001];
vector<int> dis(100001,-1);
int dfs(int v)
{
	if(dis[v]!=-1)
	{
		return dis[v];
	}
	dis[v]=0;
	for(int child:graph[v])
	{
		dis[v]=max(dis[v],1+dfs(child));
	}
	return dis[v];
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,u,v;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
    	cin>>u>>v;
    	graph[u].pb(v);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
    	ans=max(ans,dfs(i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11096
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define int signed long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f
inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
int n,k;
signed main() {
  IO;
  cin >> n >> k;
  while (true) {
    if (abs(n - k) >= n) break;
    if (n > k) n = n % k;
    else n = k % n;
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    H, W = map(int, input().split())
    a = [[int(e) for e in l.split()] for l in sys.stdin]

    n = 0
    out = []
    m = {}

    for i in range(H):
        for j in range(W):
            if a[i][j] % 2 == 0:
                continue

            # 右があるなら流す
            if j+1 < W and a[i][j+1] % 2 == 1:
                a[i][j+1] += 1
                a[i][j] -= 1
                out.append(get_pos(i, j, i, j+1))
                n += 1
                m[(i+1)*500+(j+1)] = True
            # 左があるなら流す
            elif i+1 < H and a[i+1][j] % 2== 1:
                a[i+1][j] += 1
                a[i][j] -= 1
                out.append(get_pos(i, j, i+1, j))
                n += 1
                m[(i+1)*500+(j+1)] = True
            # どちらもないか、奇数になるので下に流す
            elif i+1 < H:
                a[i+1][j] += 1
                a[i][j] -= 1
                out.append(get_pos(i, j, i+1, j))
                n += 1
                m[(i+1)*500+(j+1)] = True
            # 最終行かつ右に流しても偶数にならない場合
            elif j+1 < W:
                a[i][j+1] += 1
                a[i][j] -= 1
                out.append(get_pos(i, j, i, j+1))
                n += 1
                m[(i+1)*500+(j+1)] = True

    print(n)
    print("\n".join(out))
    # print()

    # for n in a:
    #     for m in n:
    #         print(m, " ", end="")
    #     print()

def get_pos(i, j, i2, j2):
    return "{} {} {} {}".format(i+1, j+1, i2+1, j2+1)

main()


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int res = 0;
  vector<int> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    res += S[i];
  }
  sort(S.begin(), S.end());
  for (int i = 0; i < N; i++) {
    if (res % 10 != 0) break;
    res -= S[i] % 10 != 0 ? S[i] : 0;
  }
  if (res % 10 == 0) res = 0;
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
s = str(input())

lr = 0
rl = 0
for i in range(1, n):
    if s[i-1] == "L" and s[i] == "R":
        lr += 1
    if s[i-1] == "R" and s[i] == "L":
        rl += 1
ans = n - (lr + rl + 1) + (2 * min(min(lr, rl), k))

if k > min(lr, rl):
    if lr > rl and (s[0] == "L" or s[-1] == "R"):
        ans += 1
    if lr < rl and (s[0] == "R" or s[-1] == "L"):
        ans += 1
print(ans)

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

void print_rectangle(int h, int w)
{ 
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (i == 0 || j == 0 || i == h-1 || j == w-1)
				cout << "#";
			else
				cout << ".";
		}
		cout << "\n";
	}
	cout << "\n";
}

int main()
{
	int a, b;
	vector<int> A, B;
	do 
	{
		cin >> a >> b;
		if (a == 0 && b == 0)
			break;
		A.push_back(a);
		B.push_back(b);
	} while (true);

	for (int i = 0; i < A.size(); i++)
		print_rectangle(A[i], B[i]);
	return 0;
}




Measured memory_bytes: 3056
import bisect
def dfs(cnt, s, three, five, seven):
    if cnt == 10:
        return
    if s != "" and min(three, five, seven) > 0:
        v.append(int(s))
    dfs(cnt+1, "3"+s, three+1, five, seven)
    dfs(cnt+1, "5"+s, three, five+1, seven)
    dfs(cnt+1, "7"+s, three, five, seven+1)


v = []
dfs(0, "", 0, 0, 0)
v.sort()

n = int(input())
print(bisect.bisect_right(v, n))

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

using namespace std;

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

    vector<int> v(w);
    iota(v.begin(), v.end(), 1);

    int a, b;
    char c;
    for (int i=0; i<n; ++i) {
        cin >> a >> c >> b;
        swap(v[a - 1], v[b - 1]);
    }

    for (int i=0; i<w; ++i) {
        cout << v[i] << endl;
    }

    return 0;
}

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

int main(){
    string S;
    cin >> S;
    if(S == "SUN"){
        cout << 7 << endl;
    }
    if(S == "MON"){
        cout << 6 << endl;
    }
    if(S == "TUE"){
        cout << 5 << endl;
    }
    if(S == "WED"){
        cout << 4 << endl;
    }
    if(S == "THU"){
        cout << 3 << endl;
    }
    if(S == "FRI"){
        cout << 2 << endl;
    }
    if(S == "SAT"){
        cout << 1 << endl;
    }
    return 0;
}

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

int main(){
  
  int a, b;
  char ope;
  bool flg = true;

  while(flg) {
  	cin >> a >> ope >> b;
    if ( ope == '+' ){
      cout << a + b << endl;
	} else if ( ope == '-' ){
		cout << a - b << endl;
	} else if ( ope == '*' ){
		cout << a * b << endl;
	} else if ( ope == '/' ){
		cout << a / b << endl;
	} else {
		flg = false;
	}
  }

}



Measured memory_bytes: 3132
import Data.List.Split
import Data.Char
 
main :: IO ()
main = do
  [a,b] <- map read . words <$> getLine
  s <- getLine
  putStrLn $ if f s a b then "Yes" else "No"
 
f :: String -> Int -> Int -> Bool
f s a b
  | (head $ drop a s) /= '-' = False
  | not $ any (=='-') s = False
  | (length $ filter (=='-') s) > 1 = False
  | otherwise  =
      all (&&True) $ concatMap (map isDigit) (splitOn "-" s)

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 200000;
ll mod = INF;

ll n;
ll l[maxn];

int main(){

    cin >> n;
    for(int i=0;i<n;i++)cin >> l[i];

    ll ans=0;
    ll M=l[0];

    for(int i=0;i<n;i++){
        M=max(M,l[i]);
        if(M>l[i]){
            ans+=M-l[i];
        }
    }

    cout << ans<<endl;

    return 0;
}

Measured memory_bytes: 5152
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
    int m,nmin,nmax,ans=0,max=0,p[200]={};
  cin>>m>>nmin>>nmax;
  if(m+nmin+nmax==0)break;
  for(int i=0;i<m;i++)cin>>p[i];
  for(int i=nmin;i<=nmax;i++)
    if(p[i-1]-p[i]>=max){
      max=p[i-1]-p[i];
      ans=i;
    }
  cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
class UnionFind:
    def __init__(self, n):
        self.parent = [ -1 for _ in range(n) ]
        self._size = n

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.parent[y] < self.parent[x]:
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x
            self._size -= 1

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def root(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.root(self.parent[x])

    def size(self, x):
        return -self.parent[self.root(x)]


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

uf_tree = UnionFind(N)
for _ in range(M):
    X, Y, Z = map(int, input().split())
    X -= 1; Y -= 1;
    uf_tree.unite(X, Y)

print(uf_tree._size)

Measured memory_bytes: 5464
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#define rep(i,n) for (long long i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

long int f(long long m){
    long long an=0,k=1; 
    while(2*m>=k*(k+1)){
        an+=1;
        k+=1;
    }
    return an;
}

int main(){
    long long N,M;
    cin>>N;
    M=N;
    vector<long long> v;
    if (M==1){
        cout<<0<<endl;
        return 0;
    }
    for(long long i=2;i<=sqrt(M);i++){
        long long n=0;
        while(N%i==0){
            n+=1;
            N=N/i;
        }
        if (n>0) v.push_back(n);
    }
    if (N!=1) v.push_back(1);
    long long ans=0;
    if (v.empty()) ans=1;
    else{
        rep(i,v.size()){
            ans+=f(v[i]);
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int num[100010];

int main() {
	cin >> N;
	rep(i, N) {
		int x;
		cin >> x;
		++num[x];
	}

	int ret = 0;
	bool f = 0;
	for (int i=1;i<=100000;++i) {
		if (num[i]>0) {
			++ret;
			if (num[i] % 2 == 0) f ^= 1;
		}
	}

	if (f) --ret;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    readLine()
    val input = readLine()
        ?.split(" ")
        ?.toTypedArray()
        ?: arrayOf("")
    val bArray = input.clone()
    val sArray = input.clone()
    bubbleSort(bArray)
    selectionSort(sArray)
    println(bArray.joinToString(" "))
    println("Stable")
    println(sArray.joinToString(" "))
    println(
        if (sArray.contentEquals(bArray)) {
            "Stable"
        } else {
            "Not stable"
        }
    )
}

fun bubbleSort(array: Array<String>) {
    for (i in array.indices) {
        for (j in array.size - 2 downTo i) {
            if (compare(array[j], array[j+1])) {
                array.swap(j, j+1)
            }
        }
    }
}

fun selectionSort(array: Array<String>) {
    for (i in 0 until array.size - 1) {
        var min = i
        for (j in i + 1 until array.size) {
            if (compare(array[min], array[j])) {
                min = j
            }
        }
        if (min != i) {
            array.swap(i, min)
        }
    }
}

fun compare(val1: String, val2: String): Boolean {
    val num1 = val1.substring(1).toInt()
    val num2 = val2.substring(1).toInt()
    return num1 > num2
}

fun Array<String>.swap(i: Int, j: Int) {
    val tmp = this[i]
    this[i] = this[j]
    this[j] = tmp
}


Measured memory_bytes: 34128
n=int(input())
s= [int(input()) for i in range(n)]
dp=[0]
for i in s:
    tmp=[]
    for j in dp:
        if i+j not in dp:
            tmp.append(i+j)
    dp.extend(tmp)
dp.sort(reverse=True)
for i in dp:
    if i%10!=0:
        print(i)
        exit(0)
print("0")

Measured memory_bytes: 38896
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================

// Template End =========================

int main(void){
  int a,b,c; cin>>a>>b;
  cout<<fixed<<setprecision(10)<<(double)a/b;
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    int n,x;
    while(cin>>n){
        vvi adj(n+10);
        fore(i,2,n+1){
            cin>>x;
            adj[x].push_back(i);
        }

        fore(i,1,n+1){
            cout<<(int)adj[i].size()<<endl;
        }
    }
    return 0;
}

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

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

    if (D == 22) cout << "Christmas Eve Eve Eve" << endl;
    else if (D == 23) cout << "Christmas Eve Eve" << endl;
    else if (D == 24) cout << "Christmas Eve" << endl;
    else if (D == 25) cout << "Christmas" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    ll water = 0;  // 水の量
    ll sugar = 0;  // 砂糖の量
    ll maxWater = 0;  // 水の量の最大値
    ll maxSugar = 0;  // 砂糖の量の最大値
    double maxNoudo = 0;  // 砂糖水の濃度の最大値
    // 操作1をi回行う
    exrep(i, 0, f/(100*a)) {
        // 操作2をj回行う
        exrep(j, 0, f/(100*b)) {
            water = 100*(a*i + b*j);
            if(water > f || water == 0) {
                break;
            }
            ll genkaiSugar = (water/100)*e;
            // 操作3をk回行う
            exrep(k, 0, genkaiSugar/c) {
                // 操作4をl回行う
                exrep(l, 0, genkaiSugar/d) {
                    sugar = k*c + l*d;
                    if(water + sugar > f) {
                        break;
                    }
                    double noudo = (double)(100*sugar)/(water + sugar);
                    // 砂糖が溶け残らずmaxNoudoより濃度の高い砂糖水が作れるとき
                    if(sugar <= genkaiSugar && noudo >= maxNoudo) {
                        maxWater = water;
                        maxSugar = sugar;
                        maxNoudo = noudo;
                    }
                }
            }
        }
    }
    
    cout << maxWater + maxSugar << " " << maxSugar << endl;
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<double> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    vector<double> b(n);
    for (int i = 0; i < n; i++) {
        b.at(i) = 1 / a.at(i);
    }
    double sum = 0;
    for (int i = 0; i < n; i++) {
        sum += b.at(i);
    }
    cout << fixed << setprecision(10) << 1 / sum << endl;
}


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

int main() {
  int N = 0;
  ll D = 0;
  cin >> N >> D;
  D *= D;
  vector<ll> X(N);
  vector<ll> Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X.at(i) >> Y.at(i);
    X.at(i) *= X.at(i);
    Y.at(i) *= Y.at(i);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (D >= X.at(i) + Y.at(i)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6404
MOD = (10 ** 9) + 7

S = input()
N = len(S)

nums = [1, 0, 0, 0]

for i in range(0, N):
    s = S[i]
    m = 3 if s == "?" else 1
    a = 1 if s == "A" or s == "?" else 0
    b = 1 if s == "B" or s == "?" else 0
    c = 1 if s == "C" or s == "?" else 0

    n0 = (nums[0] * m) % MOD
    n1 = (nums[1] * m + nums[0] * a) % MOD
    n2 = (nums[2] * m + nums[1] * b) % MOD
    n3 = (nums[3] * m + nums[2] * c) % MOD
    nums = [n0, n1, n2, n3]

print(nums[3] % MOD)


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

typedef long long int ll;
#define T int t,q; scanf("%d",&t); for(q=1;q<=t;q++)

int main(){
	ll n;
	cin >> n;
	ll k=100;
	for(int i=1;i<n;i++){
		k=k+k/100;
		if(k>=n){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3636
import copy

if __name__ == '__main__':
    n = int(input())
    p = [int(i) for i in input().split()]
    p2=copy.copy(p)
    p2.sort()

    count=0
    p12=[]
    p22=[]
    for i in range(n):
        if p[i] != p2[i]:
            count = count+1
            p12.append(p[i])
            p22.append(p2[i])
    if (count == 2 and p12[0]==p22[1] and p12[1] == p22[0]) or count==0:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  int n; cin >> n;
  int a[n];
  int num4,num2,num0;
  num4 = num2 = num0 = 0;
  FOR(i,0,n-1) {
    cin >> a[i];
    if(a[i]%4==0) ++num4;
    else if(a[i]%2==0) ++num2;
    else ++num0;
  }

  if(num2==0){
    if(num0 - 1 <= num4) {
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  } else {
    if(num0 > num4){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }


}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <cstring>

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

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> P;

struct item{
	double eff;
	string name;
	bool operator<(const item &r)const{
		if(eff == r.eff) return name>r.name;
		return eff < r.eff;
	}
};

int main(){	
	int n;
	while(cin >> n, n){
		vector<item> v;
		rep(i, n){
			string l;
			int p, a, b, c, d, e, f, s, m;
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			int x = a+b+c;
			int y = d+e;

			int income = f*s;
			int time = x;

			income *= m;
			time += y*m;

			income -= p;
			double eff = (double)income/time;
			item it;
			it.eff = eff;
			it.name = l;
			v.push_back(it);
		}
		sort(v.rbegin(), v.rend());
		rep(i, n){
			cout << v[i].name << endl;
		}
		cout << '#' << endl;
	}
	
	return 0;
}

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

int main()
{
    vector<int> input(3);
    cin >> input[0] >> input[1] >> input[2];

    sort(input.begin(), input.end(), greater<int>());
    cout << input[0]*10+input[1]+input[2];
    
    return 0;
}


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

	int n;
	cin >> n;
	double ans = 0;

	rep(i,n) {
		double a;
		string b;
		cin >> a >> b;
		if (b == "JPY") {
			ans += a;
		} else {
			ans += a*380000;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,k;
  cin>>n>>m>>k;
  int ans=0;
  int b[m];
  int a[n][m];
  int c[n];
  for(int i=0;i<n;i++){c[i]=k;}
  for(int i=0;i<m;i++){cin>>b[i];}
  for(int j=0;j<n;j++){
    for(int i=0;i<m;i++){
      cin>>a[j][i];
      c[j]+=b[i]*a[j][i];
    }
    if(c[j]>0){ans++;}
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
int x[100100];
long long p[101000];
int main()
{
	re int n,s,i1,i2,nw;
	re long long ans=0;
	scanf("%d%d",&n,&s);
	i1=1;i2=n;
	for(re int i=1;i<=n;i++)scanf("%d%lld",&x[i],&p[i]);
	if(x[n]<=s){printf("%d\n",s-x[1]);return 0;}
	else if(x[1]>=s){printf("%d\n",x[n]-s);return 0;}
	if(p[1]>=p[n])nw=1,p[1]+=p[n],i2--;else nw=2,p[n]+=p[1],i1++;
	ans=x[n]-x[1];
	while(1)
	{
		if(x[i1]>=s){printf("%lld\n",ans+x[i2]-s);return 0;}
		if(x[i2]<=s){printf("%lld\n",ans+s-x[i1]);return 0;}
		if(p[i1]>=p[i2])
		{
			if(nw!=1)nw=1,ans+=x[i2]-x[i1];
			p[i1]+=p[i2];i2--;
		}
		else
		{
			if(nw!=2)nw=2,ans+=x[i2]-x[i1];
			p[i2]+=p[i1];i1++;
		}
	}
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std; 
#define mod 1000000007
#define N 100005
#define ll long long
#define ull unsigned long long
#define loop1(i, j, k, step) for (int i=j; i<k; i+=step)
#define loop(i, j, k) for (int i=j; i<k; i++) 
#define rloop1(i, j, k, step) for (int i=j; i>=k; i-=step)
#define rloop(i, j, k) for(int i=j; i>=k; i--)
#define rep(i, k) for(int i = (0); i < (k); i++ )
#define rrep(i, k) for(int i = k-1; i >= 0; i-- )

#define forall(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define pop pop_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define endl "\n"
#define Max (int)INT_MAX
#define Min (int)INT_MIN
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;


void solve()
{
	int n,i,j,k=0,l,m;
	cin>>n>>m;
	rep(i,m)
	{
		cin>>l;
		k+=l;
	}
	if(n>=k)
		cout<<n-k<<endl;
	else
		cout<<"-1"<<endl;
}
int  main() 
{
	fast_io;
    int t=1;
    //cin>>t;
    while(t--)
    	solve();
	return 0; 
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int maxn = 8015;

string s;

int x, y;
int dpx[maxn * 2], dpy[maxn * 2];
int upd[maxn * 2];

int main() {
	cin >> s >> x >> y;
	s += 'T';
	int n = s.size();
	dpx[n] = 1;
	dpy[n] = 1;
	int cnt = 0;
	int u = 1;
	int i = 0;
	while(s[i] == 'F')
		i++;
	x -= i;
	for(; i <= n; i++) {
		if(s[i] == 'F')
			cnt++;
		else {
			fill(upd, upd + 2 * n + 1, 0);
			if(u == 1) {
				for(int i = 0; i <= 2 * n; i++) {
					if(i - cnt >= 0)
						upd[i] = dpx[i - cnt];
					if(i + cnt <= 2 * n)
						upd[i] |= dpx[i + cnt];
				}
				for(int i = 0; i <= 2 * n; i++)
					dpx[i] = upd[i];
			}
			else {
				for(int i = 0; i <= 2 * n; i++) {
					if(i - cnt >= 0)
						upd[i] = dpy[i - cnt];
					if(i + cnt <= 2 * n)
						upd[i] |= dpy[i + cnt];
				}
				for(int i = 0; i <= 2 * n; i++)
					dpy[i] = upd[i];
			}
			u = 1 ^ u;
			cnt = 0;
		}
	}
	if(dpx[n + x] && dpy[n + y])
		return cout << "Yes", 0;
	return cout << "No", 0;
}

Measured memory_bytes: 512
def p_f_2():
    n, m = map(int, input().split())
    *s, = map(int, input())
    s.reverse()
    i = 0
    ans = []
    while i + m < n:
        for j in reversed(range(i + 1, i + m + 1)):
            if s[j] == 0:
                ans.append(j - i)
                i = j
                break
        else:
            print(-1)
            exit()
    ans.append(n-i)
    print(*reversed(ans))

if __name__ == '__main__':
    p_f_2()


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



int main() {
    string s, t;
    cin >> s >> t;
    map<char, vector<int>> mp;
    rep(i, s.size()) {
        mp[s[i]].push_back(i+1);
    }
    long long ans = 0;
    int p = 0;
    rep(i, t.size()) {
        if (!mp[t[i]].size()) {
            ans = -1;
            break;
        }
        auto it = upper_bound(mp[t[i]].begin(), mp[t[i]].end(), p);
        if (it == mp[t[i]].end()) {
            ans += s.size() - p + mp[t[i]][0];
            p = mp[t[i]][0];
        } else {
            ans += *it - p;
            p = *it;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 10000000007
using namespace std;
void run(){
	ll a,b;
	cin>>a>>b;
	ll z=(a+b);
	z=max(z,2*a-1);
	z=max(z,2*b-1);
	cout<<z<<endl;
	
	
	
	
}
int main() {
	
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	
	// your code goes here
	return 0;
}

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

bool G[21][21];
int dp[21][21][21][21];

int h, w;

int grundy(int si, int sj, int gi, int gj){
    int &res = dp[si][sj][gi][gj];
    if(res != -1) return res;

    res = 0;
    if(si > gi || sj > gj) return res;

    vector<int> result;

    for(int i = si; i < gi; i++){
        for(int j = sj; j < gj; j++){
            if(G[i][j]) continue;
            int g = 0;
            g ^= grundy(si, sj, i, j);
            g ^= grundy(si, j + 1, i, gj);
            g ^= grundy(i + 1, sj, gi, j);
            g ^= grundy(i + 1, j + 1, gi, gj);
            result.push_back(g);
        }
    }

    /*sif(si == 0 && sj == 0 && gi == h && gj == w){
        cout << "hoge~~~~" << endl;
        for(int i = 0; i < (int)result.size(); i++){
            cout << result[i] << " ";
        }
        cout << endl;
    }*/
    sort(result.begin(), result.end());
    result.erase(unique(result.begin(), result.end()), result.end());
    

    for(int i = 0; i < (int)result.size(); i++){
        if(result[i] != i) break;
        res++;
    }

    //cout << "[" << si << "][" << sj << "][" << gi << "][" << gj << "] = " << res << endl;
    return res;
}

int main(){

    memset(dp, -1, sizeof(dp));
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char in; cin >> in;
            G[i][j] = (in == 'X');
        }
    }

    if(grundy(0, 0, h, w) == 0) cout << "Second" << endl;
    else cout << "First" << endl;
    return 0;

}


Measured memory_bytes: 3932
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
using namespace std;
int bfs(vector<string> &maze,int row,int col,int &h,int &w){
    if (maze.at(row).at(col) == '#')
    {
        return 0 ;
    }else
    {
        vector<vector<int> > dist(h,vector<int>(w,-1)) ;
        queue<pair<int,int> > wait ;
        int delta[4][2] = {{1,0},{0,1},{-1,0},{0,-1}} ;
        dist.at(row).at(col) = 0 ;
        wait.push(make_pair(row,col)) ;
        while (wait.empty() == 0)
        {
            int r = wait.front().first ;
            int c = wait.front().second ;
            wait.pop() ;
            for (size_t i = 0; i < 4; i++)
            {
                int newr = r + delta[i][0] ;
                int newc = c + delta[i][1] ;
                if (0 <= newr && newr < h && 0 <= newc && newc < w)
                {
                    if (maze.at(newr).at(newc) == '.' && dist.at(newr).at(newc) == -1)
                    {
                        dist.at(newr).at(newc) = dist.at(r).at(c) + 1 ;
                        wait.push(make_pair(newr,newc)) ;
                    }
                    
                }
                
            }
            
        }
        int ans = 0 ;
        for (size_t i = 0; i < h; i++)
        {
            for (size_t j = 0; j < w; j++)
            {
                ans = max(ans,dist.at(i).at(j)) ;
            }
            
        }
        return ans ;
    }
    
    
}

int main(){
    int h,w ;
    cin >> h >> w ;
    vector<string> maze(h) ;
    for (size_t i = 0; i < h; i++)
    {
        cin >> maze.at(i) ;
    }
    vector<vector<int> > dist(h,vector<int>(w,-1)) ;
    queue<pair<int,int> > wait ;
    int delta[4][2] = {{1,0},{0,1},{-1,0},{0,-1}} ;
    int ans = 0 ;
    for (size_t i = 0; i < h; i++)
    {
        for (size_t j = 0; j < w; j++)
        {
            ans = max(ans,bfs(maze,i,j,h,w)) ;
        }
        
    }
    cout << ans << endl ;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
using namespace std;

typedef long long ll;

bool chmax(ll &a, ll b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	int R, C, K;
	scanf("%d%d%d", &R, &C, &K);
	int V[R][C + 1];
	fill(V[0], V[R], 0);
	for (int i = 0; i < K; i++) {
		int r, c, v;
		scanf("%d%d%d", &r, &c, &v);
		r--;
		c--;
		V[r][c] = v;
	}
	ll dp[2][C + 1][4];
	for (int i = 0; i < R; i++) {
		int b = i & 1;
		for (int j = 0; j <= C; j++) {
			for (int k = 0; k < 4; k++) {
				dp[b][j][k] = 0;
				if ((i) && (k == 0)) chmax(dp[b][j][k], dp[!b][j][3]);
				if ((i) && (k == 0))
					chmax(dp[b][j][k], dp[!b][j][2] + V[i - 1][j]);
				if (j) chmax(dp[b][j][k], dp[b][j - 1][k]);
				if (k) chmax(dp[b][j][k], dp[b][j][k - 1]);
				if (k && j)
					chmax(dp[b][j][k], dp[b][j - 1][k - 1] + V[i][j - 1]);
				// fprintf(stderr, " %lld", dp[i][j][k]);
			}
			// fprintf(stderr, "\n");
		}
		// fprintf(stderr, "\n");
	}
	printf("%lld\n", dp[!(R & 1)][C][3]);
	return 0;
}


Measured memory_bytes: 37088
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define mod 1000000007
#define rep(i,n)    for(ll i=0;i<n;++i)
#define forup(i,a,b)    for(ll i=a;i<=b;++i)
#define all(v)    v.begin(),v.end()
#define inf 1000000010
#define pii pair<ll,ll>
#define vl vector<ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define MAXN 110
#define bsze 555
#define endl '\n'
#define sz(v) v.size()
#define flush fflush(stdout)
#define fast  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
ll power(ll x,ll y, ll md){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}

int main(){
    fast;
    ll n,m;
    cin>>n>>m;
    vector<ll> v(n+1,0);
    rep(i,m){
        ll l,r;
        cin>>l>>r;
        v[l]++;
        v[r+1]--;
    }
    forup(i,1,n){
        v[i]+=v[i-1];
    }
    ll ans=0;
    forup(i,1,n){
        if(v[i]==m){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	if (N % K == 0) cout << 0 << endl;
	else cout << 1 << endl;

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){ 
  int n, m;
  cin >> n >> m;
  vector<vector<char>> a(3);
  rep(i,m) {
    int s;
    char c;
    cin >> s >> c;
    s--;
    a[s].emplace_back(c);
  }
  if (n == 1 && m == 0) {
    cout << 0 << endl;
    return 0;
  }
  string res = "";
  for (int i = 0; i < n; i++) {
    bool ok = true;
    int k = sz(a[i]);
    char p;
    if (k > 0) p = a[i][0];
    for (int j = 0; j < k; j++) {
      if (a[i][j] != p) ok = false;
    }
    if (!ok) {
      cout << -1 << endl;
      return 0;
    }
    if (k == 0) res += (i == 0 ? '1' : '0');
    else {
      res += a[i][0];
    }
  }
  if (n > 1 && res[0] == '0') cout << -1 << endl;
  else cout << res << endl;
  return 0;
} 

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); ++i)
#define REP(i,start,end) for(int i=(start);i<=(end);++i)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int a,b;
	cin >> a >> b;

	int ans = round((double)(a + b) / 2);

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

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

int main(){
    string S;
    cin >> S;
    int n ;  //文字数
    while(1){
        if(S[n]=='\0') break;
        else n++;
    }
    int ll[n];
    int rl[n];
    int ln =0;
    int rn = 0;

    for(int i =0 ; i<n;i++){
        if(S[i] == 'L'){
            ll[ln]=i;
            ln++;
        }
        if(S[i] == 'R'){
            rl[rn]=i;
            rn++;
        }
    }
    int d[n];
    for(int i =0;i<n;i++){
        d[i]=0;
    }
    int pre =-1;
    for(int i =0;i<ln;i++){
        d[ll[i]] += (ll[i]-pre-1)/2;
        d[ll[i]-1] += (ll[i]-pre)/2;
        pre = ll[i];
    }

    pre = n;
    for(int i=rn-1;i>=0;i--){
        d[rl[i]] += (pre -rl[i]-1)/2;
        d[rl[i]+1] += (pre - rl[i] )/2;
        pre = rl[i];
    }
    for(int i=0;i<n;i++){
        cout << ' '<<d[i] ;
    }
    return 0;
}

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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define rrep(i, n) for(long long i = (long long)(n - 1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;

int main()
{
	int N;
	cin >> N;
	
	vector<ll> A(N);

	rep(i, N)
	{
		cin >> A[i];
	}
	sort(all(A));
  
  	if(A[0] == 0)
    {
      cout << 0 << endl;
      return 0;
    }

	ll ans = 1;
	ll max = 1000000000000000000;
	rep(i, N)
	{
      	if(A[i] <= max / ans) {
			ans *= A[i];
        } else {
          	cout << -1 << endl;
			return 0;
        }
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4028
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll m = t.size();
 
    vvl dp(n+1, vl(m+1));  // dp[i+1][j+1] : sのi文字目までとtのj文字目までのLCSの長さ 
    rep(i, n) {
        rep(j, m) {
            if(s[i] == t[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else {
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }
 
    string ans = "";
    ll i = n;
    ll j = m;
    while(i > 0 && j > 0) {
        if(dp[i][j] == dp[i-1][j]) {
            i--;
        }
        else if(dp[i][j] == dp[i][j-1]) {
             j--;
        }
        else {
            ans = s[i-1] + ans;
            i--;  j--;
        }
    }
 
    out(ans);
    re0;
}

Measured memory_bytes: 70784
N, P = map(int,input().split())
 
output=1
 
if P==1:
  output=1
elif N==1:
  output=P
else:
  for num in range(2,round(P**(1/N))+1):
    if P%(num**N) == 0:
      output = num
 
print(output)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
ll gA,sA,bA,gB,sB,bB;
vector<ll> memo(5001,INF);
vector<ll> memo2(25000001,INF);
ll rec(ll x){
    if(memo[x]!=INF) return memo[x];
    
    ll tmp=x;
    if(x>=gA) chmax(tmp,rec(x-gA)+gB);
    if(x>=sA) chmax(tmp,rec(x-sA)+sB);
    if(x>=bA) chmax(tmp,rec(x-bA)+bB);
    
    return memo[x]=tmp;
}
ll rec2(ll x){
    if(memo2[x]!=INF) return memo2[x];
    
    ll tmp=x;
    if(x>=gB) chmax(tmp,rec2(x-gB)+gA);
    if(x>=sB) chmax(tmp,rec2(x-sB)+sA);
    if(x>=bB) chmax(tmp,rec2(x-bB)+bA);
    
    return memo2[x]=tmp;
}
int main(){
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N>>gA>>sA>>bA>>gB>>sB>>bB;
    vector<ll> dp(N+1,0);
    vector<ll> dp2(5000*N+1,0);
    rep1(i,N){
        dp[i]=i;
        if(i-gA>=0) chmax(dp[i],dp[i-gA]+gB);
        if(i-sA>=0) chmax(dp[i],dp[i-sA]+sB);
        if(i-bA>=0) chmax(dp[i],dp[i-bA]+bB);
    }
    rep1(i,5000*N){
        dp2[i]=i;
        if(i-gB>=0) chmax(dp2[i],dp2[i-gB]+gA);
        if(i-sB>=0) chmax(dp2[i],dp2[i-sB]+sA);
        if(i-bB>=0) chmax(dp2[i],dp2[i-bB]+bA);
    }
    cout<<dp2[dp[N]]<<endl;
}



Measured memory_bytes: 393960
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;
  vector<vector<ll>> task(m + 1);

  REP(i, n) {
    int a, b;
    cin >> a >> b;
    if(a <= m) task[m - a].push_back(b);
  }
  //
  priority_queue<ll> que;
  ll ans = 0;
  REPR(i, m) {
    int tl = task[i].size();
    REP(j, tl) {
      que.push(task[i][j]);
    }
    if(!que.empty()) {
      ans += que.top();
      que.pop();
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char x; cin >> x;
  if(x=='A' || x == 'T') cout <<char(x^'A'^'T');
  else cout << char(x^'C'^'G');
  return 0;
  int a,b,c,d;cin>>a>>b>>c>>d;
  cout<<(a-c)*(b-d)<<endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp3
{
    internal class Class2
    {
        private static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());

            for (var i = Math.Floor(Math.Sqrt(n)); i >= 1; --i)
            {
                if (n % i == 0)
                {
                    Console.WriteLine(Math.Max(NumberOfDigits(i), NumberOfDigits(n / i)));
                    break;
                }
            }
        }

        private static double NumberOfDigits(double n)
        {
            return Math.Floor(Math.Log10(n) + 1);
        }
    }
}

Measured memory_bytes: 27720
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
const int N=3010,mod=1e9+7,inv2=5e8+4;
int n,Q,x,y,a[N];
ll dp[N][N],t1,t2,t3,t4;
ll ans,tot=1;
int main()
{
	scanf("%d%d",&n,&Q);for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)for (int j=1;j<=n;j++)if (a[i]>a[j]) dp[i][j]=1;
	while (Q--)
	{
		tot=tot*2%mod;
		scanf("%d%d",&x,&y);
		dp[x][y]=dp[y][x]=((ll)dp[x][y]*inv2%mod+(ll)dp[y][x]*inv2%mod)%mod;
		for (int i=1;i<=n;i++) 
		if (i!=x&&i!=y){
			t1=dp[x][i];t2=dp[i][x];t3=dp[y][i];t4=dp[i][y];
			dp[y][i]=dp[x][i]=((ll)t1*inv2%mod+(ll)t3*inv2%mod)%mod;
			dp[i][x]=dp[i][y]=((ll)t2*inv2%mod+(ll)t4*inv2%mod)%mod;
		}
	}
	for (int i=1;i<n;i++) for (int j=i+1;j<=n;j++) ans=(ans+dp[i][j])%mod;
	ans=ans*tot%mod;
	cout<<ans;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const int mod=1e4+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
//LL powmod(LL a,LL b) {LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int a[100010];
int dp[100010][20];
int main() {
    int n,L,q;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    scanf("%d%d",&L,&q);
    for(int i=0;i<n;i++) dp[i][0]=upper_bound(a+i,a+n,a[i]+L)-a-1;;
    for(int i=0;i<18;i++)
        for(int j=0;j<n;j++)
            dp[j][i+1]=dp[dp[j][i]][i];
    while(q--){
        int l,r;
        scanf("%d%d",&l,&r);
        if(l>r) swap(l,r);
        l--;
        r--;
        int ans=0;
        for(int i=17;i>=0;i--){
            if(dp[l][i]<r){
                ans+=1<<i;
                l=dp[l][i];
            }
        }
        printf("%d\n",ans+1);
    }
	return 0;
}


Measured memory_bytes: 9088