akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main() {
    long long int N, K;
    while(1) {
        scanf("%lld%lld", &N, &K);
        if(!N) break;
        long long int base = 9;
        for(int d=1; d<10; d++) {
            long long int sum = d * base;
            if(N > sum) {
                N -= sum;
                base *= 10;
            }
            else {
                long long int div = (N - 1) / d + base / 9, mo = (N - 1 + d) % d;
                string s = "";
                for(int i=0; s.length()<K+10; i++) {
                    s += to_string(div + i);
                }
                cout << s.substr(mo, K) << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3156
#!/usr/bin/python3

import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(S):
    N = len(S)

    if S[0] == '0' or S[-1] == '1':
        return None

    for i in range((N - 1) // 2):
        if S[i] != S[-2 - i]:
            return None

    mxsz = 1
    for i in range((N - 2) // 2):
        if S[i + 1] == '1':
            mxsz = i + 2

    G = []
    # print(mxsz)
    root = mxsz + 1
    croot = root

    for i in range(root - 1, 0, -1):
        G.append((croot, i))
        if S[i - 1] == '1':
            croot = i

    for i in range(mxsz + 2, N + 1):
        G.append((root, i))

    return G


def main():
    ans = solve(inp())
    if ans is None:
        print('-1')
        return
    for (p, q) in ans:
        print(p, q)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14988
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<time.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define tp(a, b, c) make_tuple(a, b, c)
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef pair<ll, P> TP;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
	for (auto &i : arr) {
		fill_all(i, v);
	}
}
//------------------変数-----------------------//

ll n;
//-------------------関数----------------------//
int main() {
	ll h;
	vector<ll> a, b;
	cin >> n >> h;
	REP(i, n) {
		ll c, d;
		cin >> c >> d;
		a.pb(c);
		b.pb(d);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	vector<ll> B;
	REP(i, (signed)b.size()) {
		if (a.back() <= b[i]) {
			B.pb(b[i]);
		}
	}
	ll cntt = 0;
	if (B.size()) {
		sort(B.begin(), B.end());
		EREP(i, (signed)B.size()) {
			h -= B[i];
			if (h <= 0) {
				cout << cntt + 1 << endl;
				return 0;
			}
			cntt++;
		}
	}

	ll ng = -1, ok = 1145141919;
	while (ok - ng > 1) {
		ll m = (ok + ng) / 2;
		ll cnt = (m * a.back());
		if (cnt < h) {
			ng = m;
		}
		else {
			ok = m;
		}
	}
	cout << cntt + ok << endl;
}

Measured memory_bytes: 3308
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  [_,k] <- map (read::String->Int) . words <$> getLine
  ls <- sortBy (flip compare) .map (read::String->Int) . words <$> getLine
  (print .sum .take k) ls

Measured memory_bytes: 4124
#include<bits/stdc++.h>
using namespace std;
int n,k;
bool d[10];
int main()
{
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		int x;
		cin>>x;
		d[x]=true;
	}
	string s;
	bool f;
	char c[10];
	for(int i=0;i<10;i++)
		c[i]='0'+i;
	for(int i=n;i<100*n;i++)
	{
		stringstream ss;
		ss<<i;
		s=ss.str();
		f=true;
		for(int j=0;j<10;j++)
			if(d[j]&&s.find(c[j])!=-1)
			{
				f=false;
				break;
			}
		if(f)
		{
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(N);
    map<int,int> list;
    while(N>1){
        vector<P> pd=prime_division(N);
        for(P p:pd){
            list[p.first]+=p.second;
        }
        N--;
    }
    ll ans=1;
    for(P p:list){
        ans=ans*(p.second+1)%MOD;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)


#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vector{
    double x, y;
};

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;
}
using namespace std;

int facctorial(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int Combination(int n, int r) {
  if ( r * 2 > n ) r = n - r;
  int dividend = 1;
  int  divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main()
{
    int n,m, ans = 0;
    cin >> n >> m;
    if (n >= 2) ans += Combination(n, 2);
    if (m >= 2) ans += Combination(m, 2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 3628
fun main(arr: Array<String>) {
    val (a,b,x) = readLine()!!.split(" ").map { it.toLong() }
    val min = if(a%x==0L) a else x*(a/x+1)
    val max = if(b%x==0L) b else x*(b/x)
    val ans = if(max-min < 0) 0 else (max-min)/x+1
    println(ans)
}

Measured memory_bytes: 36368
using System;
using System.Collections.Generic;

public class AtCoderC
{
    static List<string> patterns;

    static void Main()
    {
        long a;
        long b;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            a = long.Parse(words[0]);
            b = long.Parse(words[1]);
        }

        Console.WriteLine(Lcm(a, b));
    }

    // 最大公約数
    private static long Gcd(long a, long b)
    {
        if (a < b)
        {
            return Gcd(b, a);
        }
        while (b != 0)
        {
            long r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    private static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }
}

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

int main() {
	int N;
	cin >> N;
	bool flg = false;
	for (int i = 0; i < N; ++i) {
		ll a;
		cin >> a;
		if (a % 2 == 1) { flg = true; }
	}

	if (flg) { cout << "first" << endl; }
	else { cout << "second" << endl; }

	return 0;
}


Measured memory_bytes: 384
// in case of multiple test cases and N=1e5 don't intialize arrays as global except for graph vector-array
// always check whether or not you are doing mod of a negative number
// always use 1LL instead of 1
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

// using long doubles saves you from corner cases but is very time consuming
#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
// just comment the line below in case of interactive problems
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(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 trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

struct dataa{
	int x;
	int y;
	int val;
};

bool comp(dataa a,dataa b){
	return a.val < b.val;
}

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int n;
		cin >> n;
		vector<dataa> v1;
		vector<dataa> v2;
		rep(i,1,n)
		{
			int xx;int yy;
			cin >> xx >> yy;
			dataa a;
			a.x = xx;
			a.y = yy;
			a.val = xx + yy;
			v1.pb(a);
			a.val = xx - yy;
			v2.pb(a);
		}
		sort(all(v1),comp);
		sort(all(v2),comp);
		int ans1 = abs(v1[0].x - v1[n-1].x) + abs(v1[0].y - v1[n-1].y);
		int ans2 = abs(v2[0].x - v2[n-1].x) + abs(v2[0].y - v2[n-1].y);
		cout << max(ans1,ans2);
	}
}

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

using ll = long long;
ll N;

int dp(int num, int count);

int main(){
    cin >> N;
    ll count = N / 100;
    ll num = N % 100;
    if(num == 0){
        cout << 1 << endl;
    }else if(count == 0){
        cout << 0 << endl;
    }else{
        dp(num, count);
    }
   
    return 0;
}


int dp(int num, int count){
    vector<vector<bool>> dpp(count+1, vector<bool>(num+6, false));
    dpp.at(0).at(5) = true;
    for(int i = 1; i<=count ; i++){
        for(int j = 6; j<= num+5; j++){
            dpp.at(i).at(j) = dpp.at(i-1).at(j) || dpp.at(i-1).at(j - 1) || dpp.at(i-1).at(j - 2) || dpp.at(i-1).at(j - 3) || dpp.at(i-1).at(j - 4) || dpp.at(i-1).at(j - 5);
        }
    }

    // for (int i = 0; i <= count; i++)
    // {
    //     for (int j = 0; j <= num + 5; j++)
    //     {
    //         cout << dpp.at(i).at(j) << " " ;

    //     }
    //     cout << endl;
    // }
    if(dpp.at(count).at(num+5)){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define range(i,a) for(ll i=(0);i<(a);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define debug(x) do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<#x<<': "';\
for(auto&e: x)cerr<<e<<" ";cerr<<"\n";}while(0)

using namespace std;
using ll=long long;

const int NN=100*1000+10;

int color[NN];

vector<pair<int,int>> A[NN];

void dfs(int u, int c, int f) {
  color[u] = c;
  for(auto e: A[u]) {
    if (e.first != f) {
      if (e.second == 1) dfs(e.first, 1-c, u);
      else dfs(e.first, c, u);
    }
  }
}


int main() {
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
  int N; cin >> N;
  rep(i,0,N-2) {
    int u, v, w;
    cin >> u >>  v >> w;
    u--, v--; w %= 2;
    A[u].emplace_back( v,w);
    A[v].emplace_back( u,w);
  }

  dfs(0,0,-1);
  rep(i, 0, N-1) cout << color[i] << "\n";
}


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

using namespace std;

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

int mod=1e9+7;
const int N=2e5+100;


int main()
{
   int x;
   ll sum=0;
   cin>>x;
   for(int i=1;i<=x;i++){
    if(i%3==0||i%5==0) continue;
    sum+=i;
   }
   cout<<sum;
   return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<ull> L(N);
    for (int i=0; i<N; i++) {
        cin >> L[i];
    }
    ull cnt = 0;
    for (int i=0; i<N-2; i++) {
        for (int j=i+1; j<N-1; j++) {
            if (L[i] != L[j]) {
                for (int k=j+1; k<N; k++) {
                    if (L[i] != L[k] && L[j] != L[k]) {
                        ull L_s = L[i] + L[j] + L[k];
                        ull L_l = max(max(L[i], L[j]), L[k]);
                        if (L_s - L_l > L_l) {
                            cnt ++;
                        }
                    }
                }
            }
        }
    }
    cout << cnt << endl;
}

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

#define pb push_back
const int N = 1e5L + 11;
vector <int> e[N];

int sg[N];
void dfs(int x, int p) {
	for(int i : e[x]) if(i != p) {
		dfs(i, x);
		sg[x] ^= (sg[i] + 1);
	}
}

int main() {
	ios :: sync_with_stdio(0);
	int n; cin >> n;
	for(int i = 1; i < n; i ++) {
		int u, v; cin >> u >> v;
		e[u].pb(v); e[v].pb(u);
	}
	dfs(1, 0);
	cout << (sg[1] ? "Alice" : "Bob") << '\n';
}

Measured memory_bytes: 12416
#include<iostream>

using namespace std;

int main(void){
  
  int d_num;
  
  for(cin >> d_num;d_num !=0;cin >> d_num){
    //cout << "d_num:" << d_num << endl;
    int ref_num;
    cin >> ref_num;
    //cout << "ref_num:" << ref_num << endl;
    //int **ref_arr = new int*[ref_num];
    int ref_arr[10][2];

    //cout << "[ref]" << endl;
    
    for(int i=0;i<ref_num;i++){
      int x,y;
      cin >> x;
      cin >> y;
      //ref_arr[i] = new int[2];
      ref_arr[i][0]=x;
      ref_arr[i][1]=y;
      //cout << ref_arr[i][0] << "," << ref_arr[i][1] << endl;
    }
    
    //operation for reference
    
    for(int i=0;i<d_num;i++){
      int d_each_num;
      int match=0;			
      cin >> d_each_num;
      //cout << "d_each_num:" << d_each_num << endl;
      //int **d_arr = new int*[d_each_num];
      int d_arr[10][2];
      for(int j=0;j<d_each_num;j++){
	int x,y;
	cin >> x;
	cin >> y;					
	//d_arr[j] = new int[2];
	d_arr[j][0]=x;
	d_arr[j][1]=y;
	if(i==3){ 
	  //cout << d_arr[j][0] << "," << d_arr[j][1] << endl;
	}
      }
      if(ref_num != d_each_num) continue;  
      //operation for d_arr
      
      int k;
      int dx,dy;
      int ref_dx,ref_dy;
      int pre_dx=0,pre_dy=0;
      int ref_pre_dx=0,ref_pre_dy=0;
      for(k=0;k<d_each_num-1;k++){
	//operation
	dx = d_arr[k+1][0] - d_arr[k][0];
	ref_dx = ref_arr[k+1][0] - ref_arr[k][0];
	dy = d_arr[k+1][1] - d_arr[k][1];
	ref_dy = ref_arr[k+1][1] - ref_arr[k][1];
	
	//cout << "dx,dy:"  <<dx << "," << dy;
	//cout << "ref_dx,ref_dy:"  <<ref_dx << "," << ref_dy;
	//cout << endl;
	
	if( dx*dx + dy*dy != ref_dx*ref_dx + ref_dy*ref_dy  ) break;
	
	if( pre_dx*dy - dx*pre_dy != ref_pre_dx*ref_dy - ref_dx*ref_pre_dy ) break;
	
	pre_dx=dx;
	pre_dy=dy;
	ref_pre_dx=ref_dx;
	ref_pre_dy=ref_dy;
	
      }
      //cout << "k:" << k << endl;
      if(k==d_each_num-1){
	match=1;
      }
      
      if(match!=1){
      int pre_dx=0,pre_dy=0;
      int ref_pre_dx=0,ref_pre_dy=0;	
	for(k=0;k<d_each_num-1;k++){
	  //operation
	  dx = d_arr[k+1][0] - d_arr[k][0];
	  ref_dx = ref_arr[d_each_num-1-(k+1)][0] - ref_arr[d_each_num-1-k][0];
	  dy = d_arr[k+1][1] - d_arr[k][1];
	  ref_dy = ref_arr[d_each_num-1-(k+1)][1] - ref_arr[d_each_num-1-k][1];
	  
	  //cout << "dx,dy:"  <<dx << "," << dy;
	  //cout << "ref_dx,ref_dy:"  <<ref_dx << "," << ref_dy;
	  //cout << endl;				  
	  
	  if( dx*dx + dy*dy != ref_dx*ref_dx + ref_dy*ref_dy  ) break;
	  
	  if( pre_dx*dy - dx*pre_dy != ref_pre_dx*ref_dy - ref_dx*ref_pre_dy ) break;
	  
	  pre_dx=dx;
	  pre_dy=dy;
	  ref_pre_dx=ref_dx;
	  ref_pre_dy=ref_dy;
	  
	}
	//cout << "k:" << k << endl;
	if(k==d_each_num-1){
	  match=1;
	}
      //delete[] d_arr;
      }
      if(match == 1){
	cout << i+1  << endl; // need to answer
      }	    
    }
  
  //delete[] ref_arr;
    cout << "+++++" << endl; // need to answer
  
  
  }
  return 0;
}



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

typedef long long LL;
int main(int argc, char* argv[])
{
	int N,i,j;
	cin>>N;
	vector<LL> H(N);
	for (i=0;i<N;i++){
		cin>>H[i];
	}
	int MaxCount=0;
	for (i=0;i<N-1;i++){
		if (H[i]<H[i+1]){
			continue;
		}
		int maxCount=0;
		for (j=i;j<N-1;j++){
			if (H[j]<H[j+1]){
				break;
			}
			maxCount++;
		}
		i+=maxCount-1;
		if (MaxCount<maxCount){
			MaxCount=maxCount;
		}
	}
	cout<<MaxCount<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    /**
     * @param args
     * @throws IOException
     * @throws NumberFormatException
     */
    public static void main(String[] args) throws NumberFormatException,
            IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(
                System.in));

        int len = Integer.parseInt(reader.readLine());
        int[] arr = new int[len];

        String line;

        for (int i = 0; i < len; i++) {
            line = reader.readLine();
            arr[i] = Integer.parseInt(line);
        }
        
        int resultCount = 0;
        for (int j = 0; j < arr.length; j++) {
            if (isPrime(arr[j])) {
                resultCount++;
            }
        }

        System.out.println(resultCount);

    }
    
    private static boolean isPrime(int value) {

        if(value == 2) return true;
        if(value ==  3) return true;
        if(value ==  5) return true;
        if(value ==  7) return true;
        
        if(value % 2 == 0) return false;
        if(value % 3 == 0) return false;
        if(value % 5 == 0) return false;
        if(value % 7 == 0) return false;

        int max = (int) Math.sqrt(value);
        for (int i = 7; i <= max; i +=2 ) {
            if (value % i == 0) return false;
        }
        
        return true;
    }

}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
int main(){
  int r=0;
string S,T;
cin >> S >> T ;
	for(int i=0; i < S.size() ;i++){
  		if(S.at(i) != T.at(i)){
    		r = 1;
  		}
	}

  if(r == 1){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}
  


Measured memory_bytes: 3624
/* -- 2100:Saizo --*/
#include	<iostream>

using namespace std;

int main(void) {
	int t, n, mx, mn, pv, nx;

	cin >> t;
	for(int i=0; i<t; i++) {
		mx = 0; mn = 0;
		cin >> n >> pv;
		for(int j=1; j<n; j++) {
			cin >> nx;
			if(nx > pv && nx - pv > mx) { mx = nx - pv; }
			else if(pv > nx && pv - nx > mn) { mn = pv - nx; }
			pv = nx;
		}
		cout << mx << ' ' << mn << endl;
	}
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int cnt =0;
    int max =0;
    s.push_back(0);
    for(int i=0; i<s.size(); i++){
        if(s.at(i)=='A' || s.at(i)=='C' || s.at(i)=='G' || s.at(i)=='T') cnt++;
        else {
            if(max < cnt ) max = cnt;
            cnt=0; 
        }
    }
    cout << max << endl;
    return 0;
}



Measured memory_bytes: 256
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int a, b,count=0;
	string s,ans="Yes";
	cin >> a >> b >> s;
	FOR(i, 0, a + b + 1) {
		if (s[i] == '-') { count++; }
		if (count >= 2) { ans = "No"; cout << ans << endl; return 0; }
	}
	cout << ((s[a] == '-') ? "Yes" : "No") << endl;
}


Measured memory_bytes: 384
#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;
#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);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    string s; cin>>s;
    ll ans=0;
    rep(i,sz(s)-1){
        if(s[i]!=s[i+1]) ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

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

	vector<int> ans;

	int cntr = 1;
	int cntl = 0;
	char flag = 'R';

	for(int i = 1; i < S.size(); i++)
	{
		if(i == S.size()-1) cntl++;

		if((flag == 'L' and S[i] == 'R') or i == S.size()-1)
		{
			int sum = cntr + cntl;
			int rr, ll;
			if(sum % 2 == 0)
			{
				rr = sum / 2;
				ll = sum / 2;
			}
			else
			{
				if(cntr > cntl)
				{
					if((cntr-1) % 2 == 0)
					{
						rr = sum / 2 + 1;
						ll = sum / 2;
					}
					else
					{
						rr = sum / 2;
						ll = sum / 2 + 1;
					}
				}
				else
				{
					if((cntl-1) % 2 == 0)
					{
						rr = sum / 2;
						ll = sum / 2 + 1;
					}
					else
					{
						rr = sum / 2 + 1;
						ll = sum / 2;
					}
				}
			}
			for(int j = 0; j < cntr-1; j++) ans.push_back(0);
			ans.push_back(rr);
			ans.push_back(ll);
			for(int j = 0; j < cntl-1; j++) ans.push_back(0);
			//init
			cntr = 0;
			cntl = 0;
		}

		if(S[i] == 'R') cntr++;
		else if(S[i] == 'L') cntl++;

		flag = S[i];
	}

	for(int i = 0; i < ans.size(); i++)
	{
		cout << ans[i];
		if(i != ans.size()-1) cout << " ";
	}
	cout << endl;

	return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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; }

const ll MRINF = 5000000000000000;

int main() {

  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  REP(i, N)cin >> p[i];
  sort(p.begin(), p.end());
  ll ans = 0;
  REP(i, K)ans += p[i];

  cout << ans << endl;
    
  
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3632
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;


      cin>>a>>b;

      if(b>=a)cout<<"unsafe"<<endl;

      else cout<<"safe"<<endl;












}



Measured memory_bytes: 3612
from math import factorial
n,p=map(int,input().split())
a=list(map(int,input().split()))
a1=[]
a0=[]

for i in a:
    if i%2==1:
        a1.append(i)
    else:
        a0.append(i)

a1c=len(a1)
a0c=len(a0)
#print(a1)
#print(a0)
ans1=0
for i in range(a0c+1):
    ans1+=factorial(a0c) / factorial(i) / factorial(a0c - i)
#print(ans1)
ans2=0
if p==1:
    for i in range(1,a1c+1,2):
        ans2+=factorial(a1c) / factorial(i) / factorial(a1c - i)

else:
    for i in range(0,a1c+1,2):
        ans2+=factorial(a1c) / factorial(i) / factorial(a1c - i)

print(int(ans2*ans1))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string w;
	cin >> w;
	map<char, int> counter;

	for (int i = 0; i < w.size(); i++)
	{
		counter[w[i]]++;
	}

	bool ans = true;
	for (int i = 0; i < w.size(); i++)
	{
		if (counter[w[i]] % 2 != 0)
			ans = false;
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

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

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

		long[] b = new long[N];
		for(int i=0; i<N; i++) {
			b[i] = sc.nextLong();
		}

		sc.close();

		long cnt=0, tmp = 0;
		for(int i=0; i<N; i++) {

			if(i==0) {
				cnt += Math.min(a[i], b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i],b[i]));
				cnt += tmp;
			}

			if(i!=0) {
				cnt += Math.min(a[i] - tmp, b[i]);
				tmp = Math.min(a[i+1],b[i] - Math.min(a[i] - tmp, b[i]));
				cnt += tmp;
			}
		}

		System.out.println(cnt);
	}
}

Measured memory_bytes: 64232
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int a,b;
  	cin >>a>>b;
  
  	if (a*b%2 == 1) //odd
      cout <<"Odd"<<endl;
  
  	else if(a*b%2 == 0) //even
      cout <<"Even"<<endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int m;
    cin >> m;
    cout << 48 - m << endl;

    return 0;
}



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

string FILENAME = "template";
#define io ifstream fin(FILENAME + ".in"); ofstream fout(FILENAME + ".out")
#define fwrite(X) fout << X;
#define fwriteln(X) fout << X << endl;

#define forl(V, N) for(int V = 0; V < N; V++)
#define fore(E, X) for(auto &E:X)
#define print(X) cout << X
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
#define rem(X) X.top(); X.pop()
#define mid(A, B) ((A+B) / 2)
#define setmin(A, B) A = min(A, B)
#define setmax(A, B) A = max(A, B)
#define graph unordered_map<int, unordered_set<int>>
#define vi vector<int>
#define pb push_back
#define ll long long

int main() {
    int N, K;
    cin >> N >> K;
    vi stones(N);
    forl(i, N) cin >> stones[i];
    vector<ll> dp(2*N+K+10);
    fill(dp.begin(), dp.end(), 999999999999);
    dp[0] = 0;
    forl(i, N) {
        forl(j, K) setmin(dp[i+j+1], dp[i]+abs(stones[i]-stones[i+j+1]));
    }
    println(dp[N-1]);
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == 5 && b == 5 && c == 7){
    cout << "YES" << endl;
    return 0;
  }
  
  if(a == 5 && b == 7 && c == 5){
    cout << "YES" << endl;
    return 0;
  }
  
  if(a == 7 && b == 5 && c == 5){
    cout << "YES" << endl;
    return 0;
  }
  
  cout << "NO" << endl;
  
}

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

int main(void)
{
	int t;
	cin >> t;
	while (t--){
		int n, ma = 0, mi = 0, tmp, now = 0;
		cin >> n;
		cin >> tmp;
		now = tmp;
		n--;
		while (n--){
			cin >> tmp;
			if (now <= tmp){
				ma = max(ma, tmp - now);
				now = tmp;
			}
			else {
				mi = max(mi, now - tmp);
				now = tmp;
			}
		}
		
		cout << ma << " " << mi << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
n,m=map(int,input().split())
s=list(input())
t=list(input())
import fractions
x=n*m//fractions.gcd(n,m)
s_lis=[i*x//n+1 for i in range(n)]
t_lis=[i*x//m+1 for i in range(m)]
import bisect
for i in range(n):
    ind=bisect.bisect_left(t_lis,s_lis[i])
    if ind==m:
        continue
    if t_lis[ind]==s_lis[i]:
        if s[i]!=t[ind]:
            print(-1)
            exit()

print(x)


Measured memory_bytes: 14156
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main() {
	int n, k;
	while(1){
		cin >> n >> k;
		if(n + k == 0) break;
		vector<string> s(n);
		set<string> st;
		rep(i, 0, n){
			cin >> s[i];
		}
		sort(all(s));
		do{
			string tmp = "";
			rep(i, 0, k){
				tmp += s[i];
			}
			//cout << tmp <<endl;
			if(st.count(tmp)) continue;
			st.insert(tmp);
		}while(next_permutation(all(s)));
		cout << st.size() <<endl;
	}
}

Measured memory_bytes: 3392
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> t(N+1);
  vector<int> x(N+1);
  vector<int> y(N+1);
  bool flag = false;
  int absx, absy;
  
  t[0]=0;
  x[0]=0;
  y[0]=0;
  
  for(int i=1; i<N+1; i++){
    cin >> t[i] >> x[i] >> y[i];
  	absx = abs(x[i] - x[i-1]);
    absy = abs(y[i] - y[i-1]);
    if((absx+absy > t[i]-t[i-1]) || (absx+absy)%2 != (t[i]-t[i-1])%2) break;
    if(i==N) flag = true;
  }
  
  if(flag == false) cout << "No" <<endl;
  else cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<long long> a(n);
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    int cnt=0;
    long long v=0;
    while(cnt!=n-1-cnt){
        if(cnt%2==0){
            v+=a[cnt];
            v+=a[n-1-cnt];
        }
        else{
            v-=a[cnt];
            v-=a[n-1-cnt];
        }
        ++cnt;
    }
    if(cnt%2==0){
        v+=a[cnt];
    }
    else{
        v-=a[cnt];
    }
    for (int i = 0; i < n; ++i) {
        cout<<v;
        if(i==n-1)cout<<endl;
        else{
            cout<<" ";
            long long nv=2*a[i]-v;
            v=nv;
        }
    }
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=405;
int n,m,mp[maxn][maxn],fa[maxn*maxn],b[maxn*maxn],w[maxn*maxn],vis[maxn*maxn];
char s[maxn];
ll ans=0;

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

inline int find(int x){
	return fa[x]==x? x : fa[x]=find(fa[x]);
}

inline void merge(int x,int y){
	int fx=find(x),fy=find(y);
	if(fx == fy) return ;
	fa[fx]=fy;
	b[fy]+=b[fx]; w[fy]+=w[fx];
}

int main(){
	n=rd(); m=rd();
	go(i,n+1,1){
		scanf("%s",s);
		go(j,m+1,1){
			int id=(i-1)*m+j;
			if(s[j-1] == '#') mp[i][j]=1,b[id]=1;
			else mp[i][j]=0,w[id]=1;
		}	
	}
	go(i,n*m+1,0) fa[i]=i;
	go(i,n+1,1)
		go(j,m+1,1){
			int id=(i-1)*m+j;
			if(i > 1 && mp[i-1][j]!=mp[i][j]) 
				merge(id,(i-2)*m+j);
			if(i < n && mp[i+1][j]!=mp[i][j]) 
				merge(id,i*m+j);
			if(j > 1 && mp[i][j-1]!=mp[i][j]) 
				merge(id,id-1);
			if(j < m && mp[i][j+1]!=mp[i][j]) 
				merge(id,id+1);
		}
	go(i,n*m+1,1){
		int ff=find(i); if(vis[ff]) continue;
		ans+=(ll)b[ff]*(ll)w[ff]; vis[ff]=1;
	}
	printf("%lld",ans);
	return 0;
}//Faze


Measured memory_bytes: 3456
# encoding:utf-8

import copy
import numpy as np
import random

k,a,b = map(int,input().split())

cookie = 1

if b-a < 2:
    cookie += k

else:
    k -= (a-cookie)
    cookie = a

    cookie += (k//2)*(b-a)

    if k % 2 == 1:
        cookie += 1
    else:
        pass

print(cookie)


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

int main(){
	map<string,int> M;

	int n;	cin>>n;
	vector<string> ID(n);
	for(int i=0;i<n;i++){
		cin>>ID[i];
	}

	bool opened=false;

	int m;	cin>>m;
	string t;
	for(int i=0;i<m;i++){
		cin>>t;
		bool flag=false;

		for(int i=0;i<n;i++){
			if(ID[i]==t){
				flag=true;
				if(opened){
					opened=false;
					cout<<"Closed by ";
				}else{
					opened=true;
					cout<<"Opened by ";
				}
				cout<<t<<endl;
				break;
			}
		}
		if(flag==false){
			cout<<"Unknown "<<t<<endl;
		}
	}


	return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){int n;cin>>n;vector<int>v(n),m(n);rep(i,n){int a;cin>>a;rep(j,a){int x,y;cin>>x>>y;x--;v[i]|=y<<x;m[i]|=1<<x;}}int r=0;rep(i,(1<<n)){rep(j,n){if((i>>j)&1){int check=(i^v[j])&m[j];if(check>0)break;}if(j==n-1)r=max(r,__builtin_popcount(i));}}cout<<r<<endl;}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()

#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
const int INF = (1LL << 60);
using namespace std;

const int MAX_V = 10005;

class Edge{
	public:
		int to, cap, rev;
		Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
};

class Flow{
	private:
		vector<Edge> G[MAX_V];
		bool used[MAX_V];
		int level[MAX_V]; //sからの距離
		int iter[MAX_V]; //どこまで調べ終わったか
		int dfs(int v, int t, int f){
			if(v == t) return f;
			used[v] = true;
			rep(i,G[v].size()){
				Edge &e = G[v][i];
				if(not used[e.to] && e.cap > 0){
					int d = dfs(e.to, t, min(f, e.cap));
					if(d > 0){
						e.cap -= d;
						G[e.to][e.rev].cap += d;
						return d;
					}
				}
			}
			return 0;
		}
		int dfs_(int v, int t, int f){
			if(v == t) return f;
			for(int &i = iter[v]; i < G[v].size(); i++){
				Edge &e = G[v][i];
				if(e.cap > 0 && level[v] < level[e.to]){
					int d = dfs_(e.to, t, min(f, e.cap));
					if(d > 0){
						e.cap -= d;
						G[e.to][e.rev].cap += d;
						return d;
					}
				}
			}
			return 0;
		}
		void bfs(int s){
			memset(level, -1, sizeof(level));
			queue<int> que;
			level[s] = 0;
			que.push(s);
			while(not que.empty()){
				int v = que.front(); que.pop();
				rep(i,G[v].size()){
					Edge &e = G[v][i];
					if(e.cap > 0 && level[e.to] < 0){
						level[e.to] = level[v] + 1;
						que.push(e.to);
					}
				}
			}
		}
	public:
		void addEdge(int from, int to, int cap){
			G[from].push_back(Edge(to, cap, static_cast<int>(G[to].size())));
			G[to].push_back(Edge(from, 0, static_cast<int>(G[from].size() - 1)));
		}
		int fordFulkerson(int s, int t){
			int flow = 0;
			while(true){
				memset(used, 0, sizeof(used));
				int f = dfs(s, t, INF);
				if(f == 0) return flow;
				flow += f;
			}
		}
		int dinic(int s, int t){
			int flow = 0;
			while(true){
				bfs(s);
				if(level[t] < 0) return flow;
				memset(iter, 0, sizeof(iter));
				int f;
				while( (f = dfs_(s, t, INF)) > 0){
					flow += f;
				}
			}
		}
};

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

	vector<int> a(n);
	int mini = INF;
	int sum = 0;
	rep(i,n){
		cin >> a[i];
		mini = min(mini, a[i]);
		sum += max(0LL, a[i]);
	}
	int s = n, t = s + 1;
	//rep(i,n) a[i] += mini;

	Flow flow;
	rep(i,n){
		if(a[i] > 0){
			flow.addEdge(s, i, a[i]);
			//cout << s << ' ' << i << endl;
		}else if(a[i] < 0){
			flow.addEdge(i, t, -a[i]);
			//cout << i << ' ' << t  << endl;
		}
	}
	range(i,1,n + 1){
		range(j,i + 1,n + 1){
			if(j % i == 0){
				//cout << j - 1 << ' ' << i - 1 << ' ' << a[j  - 1] << endl;
				flow.addEdge(j - 1, i - 1, max(0LL, a[j - 1]));
			}
		}
	}

	cout << sum - flow.dinic(s,t) << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<math.h>
#define _USE_MATH_DEFINES
using namespace std;

int main(void){

  double input;
  double circle,line;

  cin >> input;

  circle = M_PI*input*input;
  line = 2*M_PI*input;

  printf("%.6lf %.6lf\n",circle,line);

  return 0;

}

Measured memory_bytes: 1240
import math
N,M = map(int, input().split())
#約数列挙
flag = True
yakusuu = []
for i in range(1, math.floor(math.sqrt(M))+1):
    if(M % i == 0):
        yakusuu.append(i)
        yakusuu.append(int(M / i))
yakusuu.sort()
yakusuu.reverse()
for i in yakusuu:
    if M / i >= N and flag == True:
        print(i)
        flag = False

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int s=0,kans=0;
	int h,h2,k,k2;
	cin>>h>>h2>>k>>k2;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	s+=h*a+h2*b+(h/10)*c+(h2/20)*d;
	kans+=k*a+k2*b+(k/10)*c+(k2/20)*d;
	//cout<<s<<" "<<kans<<endl;
	if(kans>s){
		cout<<"kenjiro"<<endl;
	}else if(kans<s){
		cout<<"hiroshi"<<endl;
	}else{
		cout<<"even"<<endl;
	}
}
	


Measured memory_bytes: 3108
(let ((a (read))
      (b (read))
      (s (concatenate 'list (read-line))))

  (defun judge-hyphen (p lst)
    (if (char= (nth p lst) #\-)
      t
      nil))

  (defun judge-length (q r lst)
    (if (= (length lst) (+ q r 1))
      t
      nil))

  (defun judge-unique (lst)
    (if (= (count #\- lst) 1)
      t
      nil))

  (format t "~A~%"
          (if (and (judge-hyphen a s)
                   (judge-length a b s)
                   (judge-unique s))
            "Yes"
            "No")))


Measured memory_bytes: 23552
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, mod = 1;
	cin >> n;
	if(n == 0){
		cout << 0 << endl;
		return 0;
	}
	string ans = "";
	while(n != 0){
		ll nex = mod * (-2);
		ll hoge = (n % nex != 0);
		ans += to_string(hoge);
		n -= hoge * mod;
		mod = nex;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    buf = input()
    X = buf
    length = len(X)
    S_count = 0
    for i in X:
        if i == 'S':
            S_count += 1
        else: # i == 'T'
            if S_count > 0:
                S_count -= 1
                length -= 2
    print(length)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define mod 1000000007
#define MOD 998244353
#define pb push_back
#define fi first
#define se second
#define vii vector<pair<int,int> >
#define vi vector<ll>
#define ll long long
#define rep(i,a,b) for(i=a;i<=b;i++)
#define inf 100000000000000000
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld long double 
#define pi 3.1415926535
 
using namespace std;

bool vis[401][401];

int dx[]={1,0,-1,0}, dy[]={0,1,0,-1}; 

int main()
{
    IOS;
    int h,w;
    cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++)
    {
        cin>>s[i];
        for(int j=0;j<w;j++)
        {
            vis[i][j]=false;
        }
    }
    ll ans=0,wt,b;
    queue<pair<int,int> > q;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(vis[i][j]) continue;
            vis[i][j]=true;
            q.push({i,j});
            wt=b=0;
            while(!q.empty())
            {
                pair<int,int> p=q.front();
                q.pop();
                if(s[p.fi][p.se]=='.') wt++;
                else b++;
                for(int j=0;j<4;j++)
                {
                    int x=p.fi+dx[j], y=p.se+dy[j];
                    if(x>=0 && x<h && y>=0 && y<w)
                    {
                        if(s[p.fi][p.se]!=s[x][y] && !vis[x][y])
                        {
                            vis[x][y]=true;
                            q.push({x,y});
                        }
                    }
                }
            }
            ans+=b*wt;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    final double eps = 0.000000001;
    void run() {
        Scanner sc = new Scanner(System.in);
        int x,y,s,max;
        while(true){
            x = sc.nextInt();
            y = sc.nextInt();
            s = sc.nextInt();
            max = 0;
            if(x+y+s == 0) break;
            for(int i = 1; i <= s/2; i++){
                int s1 = i;
                int s2 = s-i;
                int ps1 = getNoTaxPrice(s1, x);
                int ps2 = getNoTaxPrice(s2, x);
                int ys1 = (int) Math.floor(ps1 * ((100.0+y)/100.0) + eps);
                int ys2 = (int) Math.floor(ps2 * ((100.0+y)/100.0) + eps);
                max = Math.max(max, ys1+ys2);
            }
            System.out.println(max);
        }
    }
    /*
     * 税抜き価格を返します
     * 
     * 税抜き価格は必ず税込価格以下なので
     * sから1つずつ試して、再度税込価格を計算し、元の税込価格を等しかったら返す
     */
    int getNoTaxPrice(int s,int x){
        for(int i = s; 0 < i; i--){
            int temp = (int) Math.floor(i * ((100.0+x)/100.0) + + eps);
            if(temp == s){
                return i;
            }
        }
        return -1;
    }

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

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

typedef pair<int,int> pii;
typedef pair<int,pii> P;

int main(){
    int h,w;
    while(cin>>h>>w,h||w){
        P in=make_pair(w*w+h*h,pii(h,w));
        P ans=make_pair(1e9,pii(100000,100000));
        reep(i,1,1000){
            reep(j,i+1,1000){
                P tmp=make_pair(i*i+j*j,pii(i,j));
                if(tmp>in){
                    ans=min(ans,tmp);
                }
            }
        }
        cout<<ans.second.first<<" "<<ans.second.second<<endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int w, a, b; cin >> w >> a >> b;
	if( ( a <= b && b <= a+w ) || ( a <= b+w && b+w <= a+w ) ){
		if( ( a <= b && b <= a+w ) && ( a <= b+w && b+w <= a+w ) ){
			cout << min(abs(a+w-(b+w)), abs(b-a)) << endl;
		}
		else cout << 0 << endl; 
	}
	else cout << min(abs(b-(a+w)), abs(b+w-a)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[100010],s=1,check=1e18;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		{
			cout<<0<<endl;
			return 0;
		}
	}
	for(int i=1;i<=n;i++)
	{
		s*=a[i];
		check/=a[i];
	}
	if(check<1)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 4424
#include<bits/stdc++.h>
    using namespace std;
    typedef vector<string>vi;
    int main()
    {
        int n,l;
        cin>>n>>l;
        vi v(n);
        for(int i=0;i<n;i++){
            cin>>v[i];
        }
        sort(v.begin(),v.end());
        for(auto s:v){
            cout<<s;
        }
        return 0;
    }

Measured memory_bytes: 256