akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
 
class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
 
 
    void solve()
    {
        int H = cin.nextint;
        int W = cin.nextint;
        input(10);
        warshall_floyd(10);
 
        long ans = 0;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                int k = cin.nextint;
                if (k != -1)
                {
                    ans += D[k, 1];
                }
            }
        }
        WriteLine(ans);
    }
 
 
    long[,] D;
    const long inf = long.MaxValue / 3;
    void input(int n)
    {
        D = new long[n, n];
        for (int i = 0; i < n; i++)
        { 
            for (int j = 0; j < n; j++)
            {
                D[i, j] = cin.nextint;
            }
        }
 
    }
    void warshall_floyd(int n)
    {
        for (int k = 0; k < n; k++)
        {
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    D[i, j] = Math.Min(D[i, j], D[i, k] + D[k, j]);
                }
            }
        }
    }
}
 
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	
	string S;
	cin >> S;

	if (S.size() == 3) {
		cout << S[2] << S[1] << S[0];
	}

	else { cout << S; }
	system("PAUSE");
}


Measured memory_bytes: 504
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LDB;
typedef pair<int, int> PII; 
const double eps = 1e-7;
const double PI = acos(-1);
const LL INFF = (LL)1e18;
const int INF = (int)1e9;
const int mod = (int)1e9+7;
const int MAX = (int)2e5+7;
int a[MAX];
int main(void){
	DRIII(n, k, q);
	rep1(i, 1, n+1) scanf("%d", a + i);
	int ans = INF;
	rep1(i, 1, n+1){
		int v = a[i];
		int l = 1;
		multiset<int>st;
		multiset<int>buf;
		while(l <= n){
			if(a[l] < v){
				l++; continue;
			}
			int r = l;
			rep1(j, l+1, n+1){
				if(a[j] < v) break;
				r = j;
			}
			if(r-l+1 < k){
				l = r + 2;
				continue;
			}
			else{
				buf.clear();
				rep1(j, l, r+1) buf.insert(a[j]);
				int t = r-l+1-k+1;
				auto it = buf.begin();
				while(t--){
					st.insert(*it);
					it++;
				}
			}
			l = r+2;
		}
		if(SZ(st) < q) continue;
		auto it = st.begin();
		rep(j, q-1) it++;
		ans = min(ans, *it-*st.begin());
	}

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


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s, t, u;
  cin >> s >> t >> u;
  cout << "A" << t[0] << "C" << endl;
  return 0;
}


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

using namespace std;

int main() {
    uint64_t k;
    string s;
    cin >> k >> s;
    if (s.size() <= k) {
        cout << s;
        return 0;
    }
    cout << s.substr(0, k) << "...";
    return 0;
}

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

int main(){
    std::string str;
    std::cin >> str;
    
    int begin = 0, end = str.size() - 1;
    
    if(str[begin] == 'x' && str[end] == 'x') std::cout << 'x' << std::endl;
    else std::cout << 'o' << std::endl;
    return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAX 1000
int stock[MAX] = {0};
int top;


void push(int x){
    stock[++top] = x;
}

int pop(){
    top--;
    return stock[top+1];
}



int main(){

    int a,b;
    top = 0;
    char sam[100];
    
    while (scanf("%s",sam) != EOF) {
        if(sam[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }else if(sam[0] == '-'){
            b = pop();
            a = pop();
            push(a-b);
        }else if(sam[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }else{
            push(atoi(sam));
        }
        
    }
    
    printf("%d\n", pop());
    
    return 0;
}

Measured memory_bytes: 552
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve(long long N){
    ll val=0;
    val = (N+2-1)/2;
    cout << val-1 << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,i,j,temp,idx;
    int count=0;
    cin >> n;
    int array[n];
    for (i=0;i<n;i++){
        cin>>array[i];
    }
    for (i=0;i<n-1;i++){
        idx=i;
        for (j=i+1;j<n;j++){
            if(array[j]<array[idx]) {
                idx=j;
            }
        }
        if(idx!=i){
            temp=array[i];
            array[i]=array[idx];
            array[idx]=temp;
            count++;
        }

    }
    for (i=0;i<n;i++){
        cout<<array[i]<<((i==n-1)?"\n":" ");
    }
    cout<<count<<endl;

}



Measured memory_bytes: 3068
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            Double[] list = Arrays.stream(sc.nextLine().split(",")).map(Double::parseDouble).toArray(Double[]::new);
            double sum = Arrays.stream(list).mapToDouble(x -> x).sum() - list[10] - list[11];
            double[] l = new double[11];
            l[0] = 0;
            for (int i = 1; i < 11; i++) {
                l[i] = l[i - 1] + list[i - 1];
            }
            for (int i = 0; i < l.length; i++) {
                if (l[i] >= list[10] * sum / (list[10] + list[11])) {
                    System.out.println(i);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 32556
N,M = map(int,raw_input().split())

data = [map(int,raw_input().split()) for i in xrange(M)]

data.sort(key = lambda x:x[1])

ans = [data[0][1]-1]
cnt = 0

for i in xrange(M):
    if data[i][0] <= ans[cnt] and ans[cnt] < data[i][1]:
        continue
    else:
        cnt += 1
        ans.append(data[i][1]-1)

print cnt+1

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

int main() {
  long long n,a,sum=0, mod=2019;
  cin>>n;
  vector<pair<int, int>> vec;
  rep(i,n){
    cin>>a;
    vec.push_back(make_pair((-1)*a,i));
  }
  sort(vec.begin(), vec.end());
  for(int i=0; i<n; i++){
    if(i==vec[0].second)
      cout<<(vec[1].first)*(-1)<<endl;
    else
       cout<<(vec[0].first)*(-1)<<endl;
  }
}

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

using namespace std;

int main(){
    long ans,H,W;
    cin >> H >> W;
    int dp[H][W];
    vector<string> s(H);
    for(int i=0;i<H;i++){
        cin >> s[i];
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){

            if(i + j ==0){
                dp[i][j] = (s[i][j] == '#');
            }else{
                dp[i][j] = 1e9;
                if(0<i){
                    dp[i][j] = dp[i-1][j]+(s[i][j]=='#' && s[i-1][j]=='.');
                }

                if(0<j){
                    dp[i][j] = min(dp[i][j-1] + (s[i][j-1]=='.' && s[i][j] == '#'), dp[i][j]);
                }
            }
        }
    }

    cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = input()
pt = S.find("#")
ct = 0
bl_ls = []
wh_ls = []
last_wh = 0
last_bl = 0
S = "." + S + "#"
N += 2
for i in range(N):
    if S[i] == ".":
        last_wh += 1
        wh_ls.append(last_wh)
        bl_ls.append(last_bl)
    else:
        last_bl += 1
        wh_ls.append(last_wh)
        bl_ls.append(last_bl)
_min = 1e9
for i in range(N):
    res = wh_ls[N-1] - wh_ls[max(0,i-1)] + bl_ls[max(0,i-1)]
    _min = res if res < _min else _min
print(_min)

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

using namespace std;
using ll = long long;

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

int main() {
  int x;
  cin >> x;
  if (x >= 30)
    cout << "Yes" << endl;
  else
    cout << "No";
  return 0;
}


Measured memory_bytes: 3588
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX


int w,h,tc;
int dat[10][10];

int gone[10][10];

int dd[5]={1,0,-1,0,1};

void df(int y,int x,int fc,int c){
	if(gone[y][x])return;
	gone[y][x]=1;
	dat[y][x]=c;
	rep(i,4){
		int ty=y+dd[i],
			tx=x+dd[i+1];
		if(ty<0 || ty>=h || tx<0 || tx>=w)continue;
		if((!gone[ty][tx]) && dat[ty][tx]==fc){
			df(ty,tx,fc,c);
		}
	}
}

	
void flp(int c){
	memset(gone,0,sizeof(gone));
	df(0,0,dat[0][0],c);
}

int dfs(int d){
	
	int res=0;
	int md[10][10];
	reg(i,1,6){
		if(d==5){
			if(i!=tc)continue;
		}
		rep(y,h){
			rep(x,w){
				md[y][x]=dat[y][x];
			}
		}
		
		flp(i);
		
		if(d==5){
			flp(-2);
			int na=0;
			rep(y,h){
				rep(x,w){
					if(dat[y][x]==-2)na++;
				}
			}
			res=max(res,na);
		}
		else{
			res=max(res,dfs(d+1));
		}
		
		rep(y,h){
			rep(x,w){
				dat[y][x]=md[y][x];
			}
		}
	}
	return res;
}

int main(void){
	
	for(;;){
		scanf("%d%d%d",&h,&w,&tc);
		memset(dat,0,sizeof(dat));
		if(h<=0)break;
		rep(y,h){
			rep(x,w){
				scanf("%d",&dat[y][x]);
			}
		}
		
		printf("%d\n",dfs(1));
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535
const long long int MOD = 998244353;
#define pb push_back
#define mp make_pair
#define fill(a)  memset(a, 0, sizeof (a))
#define SORT(v)  sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define MAX(v) *max_element(v.begin(), v.end())
#define MIN(v) *min_element(v.begin(), v.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout << (#x) << " is " << (x) << endl;
const long long int MAXX = 2e6 + 5;
const long long int MINN = 2e5 + 5;
const long long int inf = 1e8;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector< iii > viii;

ll lcm(ll a, ll b) {
   return a / __gcd(a, b) * b;
}
int XOR(int x, int y){
  return (x | y) & (~x | ~y);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
    return (a.second < b.second);
}
// bool isl = binary_search(x.begin(), x.end(), 5);
// __builtin_popcount(x)  - Returns the number of set bits in x
const long long int N = 1000+5;
const int MAXN = 105;
int binsearch(int lo, int hi){
	while(lo<hi){
		int mid=(lo+hi)/2;
		if((mid))   // check(mid)
			hi=mid;
		else
			lo=mid+1;
	}
	return lo;
}
ll power(ll x,ll y){
    ll res=1;
    while(y>0){
      if(y&1) res=(res*x);

      y/=2;
      x=(x*x);
    }
    return res;
}

int main(){
    FAST
    int k,n;
    cin>>k>>n;
    int a[n+2],b[n+2];

    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<n;i++){
        b[i]=a[i+1]-a[i];
    }
    b[n]=k-a[n]+a[1];
    ll sum=0;
    int mx=0;
    for(int i=1;i<=n;i++){
        sum+=b[i];
        mx=max(mx,b[i]);
    }
    cout<<sum-mx;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
bool sosu(int n){
  if(n<=1) return false;
  else {
    for(int i=2;i<n;i++){
      if(n%i==0) return false;
    }
    return true;
  }
}

int main(){
  int n,ans;
  cin>>n;
  for(int i=n; ;i++){
    if(sosu(i)){
      ans=i; break;}
  }
  cout<<ans<<endl;
  return 0;
}

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

int getlen(long long n)
{
    int l = 0;
    while(n)
    {
        l++,n/=10;
    }
    return l;
}

string convert(long long p,long long c)
{
    string st = "";
    int i;
    for(i = 0; i < 6 - getlen(p);i++)
        st += '0';
    st+=to_string(p);
    for(i = 0; i < 6 - getlen(c);i++)
        st += '0';
    st+=to_string(c);
    return st;
}

int main() {
    int n,m;
    cin >> n >> m;
    long long p,y;
    int i;
    vector < pair<long long,long long> > v,v2;
    for(i=0;i<m;i++)
        cin >> p >> y, v.push_back({p,y});
    v2 = v;
    sort(v.begin(),v.end());
    map< pair<long long,long long> , string > mp;
    int c = 1;
    for(i=1;i<m;i++)
    {
        if(v[i].first != v[i-1].first)
            mp[{v[i-1].first,v[i-1].second}] = convert(v[i-1].first,c),c = 1;
        else
            mp[{v[i-1].first,v[i-1].second}] = convert(v[i-1].first,c),c ++;
    }
    mp[{v[i-1].first,v[i-1].second}] = convert(v[i-1].first,c);
    for(i =0;i < m;i++)
        cout << mp[{v2[i].first,v2[i].second}] <<endl;
	return 0;
}

Measured memory_bytes: 17136
import sys
n=int(input())
s=[input()[0] for i in range(n)]
m,a,r,c,h=0,0,0,0,0
for i in range(n):
    if s[i]=="M": m+=1
    elif s[i]=="A": a+=1
    elif s[i]=="R": r+=1
    elif s[i]=="C": c+=1
    elif s[i]=="H": h+=1
t=sorted([m,a,r,c,h])
q,w,e,r,u=0,0,0,0,0
if t[2]==0:
    print(0)
    sys.exit()
if t[1]==0:
    print(t[2]*t[3]*t[4])
    sys.exit()
if t[0]==0:
    q,w,e,r=t[1],t[2],t[3],t[4]
    print(q*w*e+q*w*r+q*e*r+w*e*r)
    sys.exit()
else:
    q,w,e,r,u=t[0],t[1],t[2],t[3],t[4]
    x=q*w*e+q*w*r+q*w*u+q*e*r+q*e*u+q*r*u
    y=w*e*r+w*e*u+w*r*u+e*r*u
    print(x+y)

Measured memory_bytes: 4032
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val N, T, E = sc.nextInt
    val ans = List.fill[Int](N)(sc.nextInt).indexWhere(x => ((T + E) / x) != ((T - E) / x))
    println(if (ans != -1) (ans + 1) else (ans))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 45196
use std::io;

// I'm really really not sure if this is the right way
fn get_line() -> Vec<char> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf.chars().collect()
}

fn find_locs(input: Vec<char>) -> (Option<usize>, Option<usize>) {
    input.iter().enumerate().fold((None, None), |(a, z), (i, c)| {
        match *c {
            'A' => if a.is_none() { (Some(i), z) } else { (a, z) },
            'Z' => (a, Some(i)),
            _ => (a, z),
        }
    })
}

fn solve(input: Vec<char>) -> usize {
    match find_locs(input) {
        (Some(a), Some(z)) => 1+ z - a,
        _ => 0,
    }
}

fn main() {
    let input = get_line();
    println!("{}", solve(input));
}

Measured memory_bytes: 1404
#include <stdio.h>
#include <algorithm>
int n, x, z;
int a[100];
int b[100];
int c[100];
int d[100];
int e[100];
int f[100];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", a + i, b + i);
		e[i] = a[i] * 1000 + b[i];
	}
	std::sort(e, e + n);
	for (int i = 0; i < n; i++) {
		a[i] = e[i] / 1000;
		b[i] = e[i] % 1000;
	}
	for (int i = 0; i < n; i++) {
		scanf("%d%d", c + i, d + i);
		e[i] = c[i] * 1000 + d[i];
	}
	std::sort(e, e + n);
	for (int i = 0; i < n; i++) {
		c[i] = e[i] / 1000;
		d[i] = e[i] % 1000;
	}
	for (int i = 0; i < n; i++) {
		x = 0;
		for (int j = 0; j < n; j++) {
			if (f[j] == 0 && a[j] < c[i] && b[j] < d[i]) {
				e[x] = b[j] * 1000 + j;
				x++;
			}
		}
		if (x)std::sort(e, e + x);
		if (x) {
			f[e[x - 1] % 1000] = 1;
			z++;
		}
	}
	printf("%d\n", z);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool rec(int v,int s,int n,int c,int *a){
  if(v==n) return s==c;
  bool res=0;
  res|=rec(v+1,s+a[v],n,c,a);
  res|=rec(v+1,s,n,c,a);
  return res;
}
signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int q;
  cin>>q;
  int m[q];
  for(int i=0;i<q;i++) cin>>m[i];
  for(int i=0;i<q;i++) cout<<(rec(0,0,n,m[i],a)?"yes":"no")<<endl;
  
  return 0;
}

Measured memory_bytes: 3092
def main():
    N = int(input())
    a = list(map(int, input().split()))
    # 互いにできるだけ点数を高くしたい
    # 単に先頭と末尾を比較して大きい方を選択した場合には、選択した要素の次の要素のほうが大きい場合がある
    # dp[i][j]で左からi番目からj-1番目までだけ残っている場合にそこからとり得る最大値を考える
    # dp[0][0]

    dp = [[0 for i in range(N)] for j in range(N)]

    for i in range(N):
        dp[i][i] = a[i]

    for i in range(N-1, -1, -1):
        for j in range(i+1, N):
            right = a[i] - dp[i+1][j]
            left = a[j] - dp[i][j-1]
            if right > left:
                dp[i][j] = right
            else:
                dp[i][j] = left
    # print(dp)
    print(dp[0][N-1])


main()


Measured memory_bytes: 120028
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#include "atcoder/all"
#else
#define NDEBUG
#include <atcoder/all>
#include <bits/stdc++.h>
#endif

using namespace std;
using namespace atcoder;
using large = long long;
constexpr auto M = 998'244'353;
static large tens[200'005];
static large ones[200'005];

struct X {
    large len;
    large val;
};
X op(X lhs, X rhs)
{
    X res;
    res.len = lhs.len + rhs.len;
    res.val = (lhs.val * tens[rhs.len] + rhs.val) % M;
    return res;
}
X e() { return X{0, 0}; }

using F = int;
X mapping(F f, X x)
{
    X res = x;
    if (f) {
        res.val = ones[x.len] * f % M;
    }
    return res;
}
F composition(F l, F r) { return (l == 0 ? r : l); }
F id() { return 0; }

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

    tens[0] = 1;
    for (int i = 1; i <= 200'000; ++i) {
        tens[i] = tens[i - 1] * 10 % M;
    }
    ones[1] = 1;
    for (int i = 1; i <= 200'000; ++i) {
        ones[i] = (ones[i - 1] * 10 + 1) % M;
    }

    auto ls = lazy_segtree<X, op, e, F, mapping, composition, id>(vector<X>(n, X{1, 1}));
    for (int i = 0; i < q; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        ls.apply(l - 1, r, d);
        cout << ls.all_prod().val << "\n";
    }

    return 0;
}


Measured memory_bytes: 18856
#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(){
    int n;
    cin >> n;
    string ans = "No";
    for (int a = 1; a < 10; a++){
        for (int b = 1; b < 10; b++){
            if (n == a * b){
                ans = "Yes";
            }
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;

ll dp[101][100010]={};

int main(void){
    ll N,W;
    cin>>N>>W;
    ll w[101],v[101];
    for(int i=0;i<=N;i++){
        for(int j=0;j<100010;j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<N;i++) cin>>w[i]>>v[i];
    for(int i=0;i<N;i++){
        for(int j=0;j<100010;j++){
            if(j-v[i]<0) dp[i+1][j]=dp[i][j];
            else dp[i+1][j]=min(dp[i][j-v[i]]+w[i],dp[i][j]);
        }
    }
    ll ans=0;
    for(int i=0;i<100010;i++){
        if(dp[N][i]<=W) ans=i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 82536
#include <iostream>
using namespace std;
long long X, Y;
void Solve()
{
    int cnt = 0;
    while(X <= Y)
    {
        ++cnt;
        X *= 2;
    }
    cout << cnt<< "\n";
}
int main()
{
    cin >> X >> Y;
    Solve();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split(' ')))

total = sum(a)
now = a[0]
ans = abs(total - 2*now)
for i in range(1, len(a)-1):
    now += a[i]
    ans = min(abs(total - 2*now), ans)
print(ans)


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

namespace ITP2_3_C
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            int[] line = ReadIntAr();

            int q = ReadInt();
            for (int i = 0 ; i < q ; i++)
            {
                int[] items = ReadIntAr();
                Console.WriteLine(line.Where((x, index) => items[0] <= index && index < items[1]).Count(x => x == items[2]));
            }
        }

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

    }

}



Measured memory_bytes: 18292
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <iomanip>
#include <sstream>
#include <list>
using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define sz(x) (int)(x).size()
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

template <typename A, typename B> 
ostream& operator<<(ostream& os, pair<A,B> &p) {
	return os << "(" << p.first << "," << p.second << ")";
} 

template <typename A> 
ostream& operator<<(ostream& os, vector<A> &p) {
	for (auto &x : p) {
		os << x << " ";
	}
	os << endl;
	return os;
} 

vector<int> primes;

void siv(int n) {
	vector<bool> is_prime(n+1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			primes.push_back(i);
		}

	    if (is_prime[i] && (long long)i * i <= n) {
	        for (int j = i * i; j <= n; j += i)
	            is_prime[j] = false;
	    }
	}
}

template <typename T>
T gcd(T a, T b) {
	if (a < 0) a *= -1;
	if (b < 0) b *= -1;
	
	while (b != 0) {
		T temp = a;
		a = b;
		b = temp % b;
	}

	return a;
}


// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string


void solve() {
	
	ll n, m, k;
	cin >> n >> m >> k;
	std::vector<ll> a(n), b(m);
	ll amax = 0, bmax = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i] += ((i > 0) ? a[i-1] : 0);
		if (a[i] <= k)
			amax = i + 1;
	}
	
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
		b[i] += ((i > 0) ? b[i-1] : 0);
		if (b[i] <= k)
			bmax = i + 1;
	}


	ll left = amax - 1;
	ll right = bmax - 1;
	// cout << left << " and " << right << endl;
	ll i = 0, j = right;
	ll res = max(amax, bmax), temp = res;
	while (i <= left && j >= 0) {
		// cout << "before : " << i << " and " << j << endl;
		while (j >= 0 && a[i] + b[j] > k) {
			j--;
		}

		while (j >= 0 && i + 1 <= left && a[i + 1] + b[j] <= k) {
			i++;
		}

		if (a[i] + b[j] > k) {
			break;
		}

		// cout << "after : " << i << " and " << j << endl;
		temp = i + 1 + j + 1;
		++i;
		res = max(res, temp);
	}

	cout << res << endl;
}


int main(){
	IOS;
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    (void)freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    (void)freopen("output.txt", "w", stdout);
	#endif

	int t = 1;
	// cin >> t;
	while(t--) 
		solve();

	// return 0;
}



























 

Measured memory_bytes: 6344
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
#include <set>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int ctoi(char c){
	return (int)(c - 'a');
}

int main(){
	int n, q;
	string s;
	cin >> n >> s >> q;
	vector<set<int> > st(26);
	for (int i = 0; i < s.length(); i++){
		st[ctoi(s[i])].insert(i);
	}
	for (int i = 0; i < q; i++){
		int x;
		cin >> x;
		if (x == 1){
			int a;
			char c;
			cin >> a >> c;
			st[ctoi(s[a-1])].erase(a-1);
			st[ctoi(c)].insert(a-1);
			s[a-1] = c;
		}else{
			int a, b;
			cin >> a >> b;
			int coun = 0;
			for (int j = 0; j < 26; j++){
				auto iter1 = st[j].lower_bound(a-1);
				if (*iter1 <= b-1 && iter1 != st[j].end()) coun++;
			}
			cout << coun << endl;
		}
	}
	return 0;
}


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

int x, y;

void swap(int *a, int *b){
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

int main(int argc, const char * argv[]) {
    
    while(1){
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        if(x > y){
        swap(&x, &y);
        }
        cout << x << " " << y << endl;
    }


    return 0;
}


Measured memory_bytes: 3008
#include <iostream>
using namespace std;
int main(){
    int w,n;
    int a[30]={-1};
    int j,k;
    int temp1;
    
    while(cin >> w){
        
        if(w==0)break;

        for(int i=0;i<w;i++){
            a[i]=i+1;
        }
        

        cin >> n;       

        for(int i=0;i<n;i++){
            char temp;

            cin >> j >> temp >> k;
            
            temp1=a[j-1];
            a[j-1]=a[k-1];
            a[k-1]=temp1;

        }

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

    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }


signed main(void){
  int n,k;cin >> n >> k;
  int ans = 1;
  rep(i,n){
    if(ans+k<=ans*2)
      ans+=k;
    else 
      ans*=2;
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
    int N;
    int mochi = 0;
    int cntm =0;
    cin >> N;
    vector <int> a(N);
    for(int i=0;i<N;++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for(int i=0;i<N;++i){
        if(mochi < a[i]){
            mochi = a[i];
            ++cntm; 
        }
    }
    cout << cntm <<endl;
}


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

char ary[10010];
int main(){
	int cnt,cnj,cni;
	while(true){
		cin>>ary;
		if(cin.eof()) break;
		cnj=cni=0;
		cnt=strlen(ary);
		for(int i=2;i<cnt;i++){
			if(ary[i]=='I'&&ary[i-1]=='O'){
				if(ary[i-2]=='J') cnj++;
				else if(ary[i-2]=='I') cni++;
			}
		}
		cout<<cnj<<endl<<cni<<endl;
	}
	return 0;
}

Measured memory_bytes: 1148
s = input()
ans = 'WA'
if s[0] == 'A':
    if s[2:-1].count('C') == 1:
        position = s[2:-1].find('C')+2
        if position == 2 and s[1].islower() and s[position+1:].islower():
            ans='AC'
        elif position == len(s) - 1 and s[1:position].islower() and s[-1].islower():
            ans='AC'
        elif s[1:position].islower() and s[position+1:].islower():
            ans = 'AC'

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String []args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int in =scan.nextInt();
			String[] ans=new String[in];
			for(int k=0;k<in;k++){
				int[] ball=new int[10];
				int[] a=new int[10];
				int[] b=new int[10];
				int atop=0;
				int btop=0;
				for(int j=0;j<10;j++){
					ball[j]=scan.nextInt();
				}
				for (int i = 0; i < 10; i++) {
					if(ball[i]>atop){
						a[i]=ball[i];
						atop=a[i];
						//System.out.println("a"+a[i]);
					}else{
						b[i]=ball[i];
						//System.out.println("b"+b[i]);
					}
				}
				atop=0;
				btop=0;
				for(int i=0;i<10;i++){
					if(a[i]!=0){
						if(atop<a[i]){
							atop=a[i];
						}else{
							ans[k]="NO";
							break;
						}
					}else{
						if(btop<b[i]){
							btop=b[i];
						}else{
							ans[k]="NO";
							break;
						}
					}
					if(i==9)
						ans[k]="YES";
				}
			}
			for(int k=0;k<in;k++){
				if(ans[k]=="YES" || ans[k]=="NO")
					System.out.println(ans[k]);
			}
		}
	}
}

Measured memory_bytes: 11000
//tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll temp=a/c;
    temp=abs(temp);
    if(a<0)
    {
       if(temp>=b)
       {
        temp=a+b*c;
       }
       else
       {
        if((b-temp)%2)
        temp=a+temp*c+c;
        else
        temp=a+temp*c;
       }
    }
    else if(a>0)
    {
        if(temp>=b)
       {
        temp=a-b*c;
       }
       else
       {
        if((b-temp)%2)
        temp=a-temp*c-c;
        else
        temp=a-temp*c;
       }
    }
    else
    {
        if(b%2)
        temp=a+c;
        else
        temp=0;
    }
    cout<<abs(temp)<<endl;
}


Measured memory_bytes: 3568
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
if n == 0:
    print([-1, 1][a[0] == 1])
    exit()
if a[0] > 0:
    print(-1)
    exit()
s = sum(a)
ans = 1
dp = [0] * (n + 1)
dp[0] = 1
for i in range(n):
    dp[i + 1] = min(s, 2 * dp[i])
    ans += dp[i + 1]
    dp[i + 1] -= a[i + 1]
    s -= a[i + 1]
    if dp[i] <= 0:
        print(-1)
        exit()
if dp[-1] < 0:
    print(-1)
    exit()
print(ans)


Measured memory_bytes: 20148
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 200005;
vector<int> gra[MAXN];
int sz[MAXN], mx[MAXN], se[MAXN], mn[MAXN], n;
LL ans;
char str[MAXN];

void dfs1(int u, int fa) {
	sz[u] = str[u] == '1';
	mn[u] = str[u] == '1' ? 0 : 1e9;
	for (int v : gra[u]) if (v != fa) {
		dfs1(v, u);
		sz[u] += sz[v];
		int d = mx[v] + 1;
		if (d > mx[u]) se[u] = mx[u], mx[u] = d;
		else if (d > se[u]) se[u] = d;
		if (sz[v]) chkmin(mn[u], d);
	}
}

void dfs2(int u, int fa) {
	int mxd = min(mx[u] - 1, se[u] + 1);
	if (mxd >= mn[u]) ans += mxd - mn[u] + 1;
	for (int v : gra[u]) if (v != fa) {
		int d = mx[u] == mx[v] + 1 ? se[u] + 1 : mx[u] + 1;
		if (d > mx[v]) se[v] = mx[v], mx[v] = d;
		else if (d > se[v]) se[v] = d;
		if (sz[1] > sz[v]) chkmin(mn[v], d);
		dfs2(v, u);
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int u, v; scanf("%d%d", &u, &v);
		gra[u].push_back(v), gra[v].push_back(u);
	}
	scanf("%s", str + 1);
	dfs1(1, 0);
	dfs2(1, 0);
	printf("%lld\n", ans + 1);
	return 0;
}

Measured memory_bytes: 24064
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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 gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

#define int ll

int h,w,k;
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
vector<string>c;


template<typename T>
struct edge{
  int to;
  T cost;
  edge(int to,T cost):to(to),cost(cost){}
};


template<typename T>
vector<vector<vector<int>>> dijkstra(int sx,int sy){//sは始点
  const auto INFTY=numeric_limits<int>::max()/10;//2回以上使うときはオーバーフローに気をつける(INFTYのときはif文で弾くなど)
  vector<vector<vector<int>>>dist(h,vector<vector<int>>(w,vector<int>(4,INFTY)));
	using PP=pair<int,int>;
  using P=pair<int,pair<PP,int>>;//firstは最短距離,secondは頂点の番号
  priority_queue<P,vector<P>,greater<P>>pq;
  rep(i,4)dist[sx][sy][i]=0;
	rep(i,4)pq.emplace(dist[sx][sy][i],make_pair(PP{sx,sy},i));
  while(!pq.empty()){
    auto x=pq.top();pq.pop();
    int vx=x.second.first.first,vy=x.second.first.second;
		int dir=x.second.second;
    if(dist[vx][vy][dir]<x.first)continue;//最短距離でなければ飛ばす
    rep(i,4){
			int nx=vx+dx[i],ny=vy+dy[i];
			if(nx<0||nx>=h||ny<0||ny>=w)continue;
			if(c[nx][ny]=='@')continue;
			if(dir==i){
				if(chmin(dist[nx][ny][i],dist[vx][vy][dir]+1)){
					pq.emplace(dist[nx][ny][i],make_pair(PP{nx,ny},i));
				}
			}
			else{
				if(chmin(dist[nx][ny][i],(dist[vx][vy][dir]+k-1)/k*k+1)){
					pq.emplace(dist[nx][ny][i],make_pair(PP{nx,ny},i));
				}
			}
		}
  }
  return dist;
}

void solve()
{
	cin>>h>>w>>k;
	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	x1--;y1--;
	x2--;y2--;
	c.resize(h);
	rep(i,h)cin>>c[i];
	const int INFTY=numeric_limits<int>::max()/10;
	auto d=dijkstra<int>(x1,y1);
	// rep(i,h){
	// 	rep(j,w){
	// 		int s=INFTY;
	// 		chmin(s,d[i][j]);
	// 		if(s==INFTY){
	// 			cout<<'@';
	// 		}
	// 		else cout<<s;
	// 		cout<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	int ans=INFTY;
	rep(i,4)chmin(ans,d[x2][y2][i]);
	if(ans==INFTY)cout<<-1;
	else cout<<(ans+k-1)/k;
}

#undef int
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

bool isnp[100001];

int main(){
	for(int i = 2; i * i <= 100000; ++i){
		if( isnp[i] ) continue;
		for(int j = i * i; j <= 100000; j += i){
			isnp[j] = true;
		}
	}
	
	vector<int> p;
	for(int i = 2; i < 100000; ++i){
		if( !isnp[i] ) p.push_back(i);
	}
	
	int m, a, b;
	while( scanf("%d%d%d", &m, &a, &b), m != 0 ){
		int ms = 0, ma = 0, mb = 0;
		
		for(int i = 0; p[i] * p[i] <= m; ++i){
			int t = min(p[i] * b / a, m / p[i]);
			int x = upper_bound(p.begin(), p.end(), t) - p.begin() - 1;

			int s = p[i] * p[x];
			if( s <= m && s > ms ){
				ms = s;
				ma = p[i];
				mb = p[x];
			}
		}
		printf("%d %d\n", ma, mb);
	}
}

Measured memory_bytes: 1252
module AOJ_Volume0107;

import std.stdio,std.string,std.conv;

int main()
{
	int a[13];
	while(true)
	{
		int n = readln.chomp.to!int;
		if(n == 0) break;

		foreach(i;0..13) a[i] = 0;
		int res[];

		string[] s = readln.chomp.split(" ");
		foreach(i;0..n)
		{
			a[i] = s[i].to!int;
			res ~= a[i];
		}

		int count = 0;
		while(true)
		{
			int[int] m;

			foreach(i;0..n)
			{
				m[a[i]]++;
			}

			foreach(i;0..n)
			{
				a[i] = m[a[i]];
			}

			bool flag = true;
			foreach(i;0..n)
			{
				if(res[i] != a[i]) flag = false;
			}

			if(flag)
			{
				count.writeln;
				foreach(i;0..n)
				{
					if(i == n-1) a[i].writeln;
					else write(a[i]," ");
				}
				break;
			}
			else
			{
				foreach(i;0..n)
				{
					res[i] = a[i];
				}
				count++;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>
const int N=1e3+10;
int min(int a,int b){return a>b?b:a;}
int max(int a,int b){return a>b?a:b;}
int main(){
    int n,q,a[N],bot[N][N],top[N][N],l,r;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<n;i++)bot[i][i]=top[i][i]=a[i];
    for(int k=1;k<n;k++)for(int i=0;i<n-k;i++){
        bot[i][i+k]=min(bot[i][i+k-1],bot[i+1][i+k]);
        top[i][i+k]=max(top[i][i+k-1],top[i+1][i+k]);
    }
    scanf("%d",&q);
    while(q--){
        scanf("%d%d%d",&n,&l,&r);
        if(n==0)printf("%d\n",bot[l][r-1]);
        else printf("%d\n",top[l][r-1]);
    }
}


Measured memory_bytes: 10472
import java.util.*;

import static java.lang.System.*;

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

        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        // 矛盾チェック
        Arrays.sort(a);

        // 奇数なら、[0, 2, 2, 4, 4, ...]
        // 偶数なら、[1, 1, 3, 3, ...]
        if (N % 2 == 1) {
            if (a[0] != 0) {
                out.println(0);
                return;
            }

            for (int i = 1; i < N; i++) {
                if (a[i] != (int) Math.ceil(i / 2.0) * 2) {
                    out.println(0);
                    return;
                }
            }
        } else {
            for (int i = 0; i < N; i++) {
                if (a[i] != (i / 2) * 2 + 1) {
                    out.println(0);
                    return;
                }
            }

        }

        N /= 2;
        long ans = 1;
        long mod = 1_000_000_007;
        while (N > 0) {
            ans = (ans * 2) % mod;
            N--;
        }

        out.println(ans);
    }
}

Measured memory_bytes: 50900
#include<cstdio>
#include<cstring>
#include<string>

char w[105];
int flag[27];
int k;

int main()
{
	scanf("%s",w);
	int len = strlen(w);
	for(int i = 0;i < len; i++){
		flag[w[i] - 'a']++;
	}
	for(int i = 0;i < 26;i++){
		if(flag[i]%2 != 0) {
			printf("No\n");return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    string s[3];
    string ans = "";
    rep(i, 3) {
        cin >> s[i];
        s[i][0] += 'A' - 'a';
        ans += s[i][0];
    }

    cout << ans << endl;

    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
from fractions import gcd


def li():
    return list(map(int, input().split()))


def multiplier_num(a, b, x):
    if a % x == 0:
        return b // x - a // x + 1
    else:
        return b // x - a // x


if __name__ == "__main__":
    [a, b, c, d] = li()
    lcm = c * d // gcd(c, d)
    # print(lcm)
    # print(multiplier_num(a, b, c))
    # print(multiplier_num(a, b, d))
    # print(multiplier_num(a, b, lcm))
    answer = b - a + 1 - multiplier_num(a, b, c) - multiplier_num(a, b, d) + multiplier_num(a, b, lcm)
    print(answer)

# cでもdでも割り切れない
# 全体からcで割り切れる個数を引き、dで割り切れる個数を引くと
# 　cでもdでも割り切れる個数を引きすぎるので足して戻す
# a以上b以下でxで割り切れる個数
# 　b//x - a//x


Measured memory_bytes: 65064
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var inputs = new List<int>();
        while (true)
        {
            var input = Console.ReadLine();
            if (String.IsNullOrEmpty(input))
            {
                break;
            }
            else
            {
                inputs.Add(int.Parse(input));
            }
        }

        Console.WriteLine(inputs.Distinct().Count());
    }
}

Measured memory_bytes: 13152
import java.util.*;
class Main{
	public static void main(String args[]){
    	Scanner in = new Scanner(System.in);
      long a = in.nextLong();
      long b = in.nextLong();
      long x = in.nextLong();
      long cnt = 0;
      if(a%x==0)cnt++;
      cnt+=b/x-a/x;
      System.out.println(cnt);
    }
}

Measured memory_bytes: 23124
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;

vector<double> ans(2);

void reflection(double x1, double y1, double x2, double y2, double x, double y){
	double keisu = ((x-x1)*(x2-x1)+(y-y1)*(y2-y1))/((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
	double s1=2*(keisu*(x2-x1)+x1)-x;
	double s2=2*(keisu*(y2-y1)+y1)-y;
	ans[0]=s1;
	ans[1]=s2;
}

int main(){
	double x1,y1,x2,y2,q,x,y;
	cin >> x1 >> y1 >> x2 >> y2 >> q ;
	for(int i=0;i<q;i++){
		cin >> x >> y;
		reflection(x1,y1,x2,y2,x,y);
		printf("%.10lf %.10lf \n",ans[0],ans[1]);
	}
	return 0;
}

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

typedef long long ll;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> K(N);
	vector<vector<int> > A(N);
	map<int,int> m;
	for (int i = 0; i < N; i++) {
		cin >> K[i];
		for (int j = 0; j < K[i]; j++) {
			int a; cin >> a;
			A[i].push_back(a);
			m[a]++;
		}
	}

	int cnt=0;
	for (auto itr = m.begin(); itr != m.end(); itr++) {
		if(itr->second == N) cnt++;
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c = map(int, input().split())
    print("Yes" if a == b == c else "No")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <stdio.h>
#define N 100

int main(){

  int i,n,p[N+1],m[N+1][N+1],l,j,k,a;

  scanf("%d",&n);
  for(i=1;i<=n;i++)  scanf("%d%d",&p[i-1],&p[i]);

  for(i=1;i<=n;i++) m[i][i]=0;
  
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=1000000;
      for(k=i;k<=j-1;k++){
	a= m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(m[i][j] > a) m[i][j] = a;
      }
    }
  }
  printf("%d\n",m[1][n]);

  return 0;
}



Measured memory_bytes: 2112
#include<iostream>
#include<math.h>
#include<stdio.h>

#include <algorithm>

using namespace std;

int main(){
    int n, max_num = -1e7, min_num = 1e7,a;
    long long int sum = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin>>a;
        sum += a;
		max_num = max(max_num, a);
		min_num = min(min_num,a);
    }
   cout<<min_num<<" "<<max_num<<" "<<sum<<endl;
   return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>

int main(void){
 char S[20],T[20],U[20];
  int A,B;
  
  scanf("%s %s",&S[0],&T[0]);
  scanf("%d %d",&A,&B);
  scanf("%s",&U[0]);
  
  if(S[0]==U[0]){
   A=A-1; 
  }else if(T[0]==U[0]){
   B=B-1; 
  }
  
  printf("%d %d",A,B);
  return 0;
}

Measured memory_bytes: 128
#include<map>
#include<set>
#include<cmath>
#include<climits>
#include<vector>
#include<queue>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<unordered_map>
#define mod 1000000007
using namespace std;
#define LL long long int
int main() 
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    cout<<S;
    if(S.back()=='s')
        cout<<"e"<<"";
    cout<<"s";
}


Measured memory_bytes: 3620