akhauriyash/Code-Regression huggingface dataset:
require 'pp'

n = gets.chomp!.to_i
x_n = gets.split.map(&:to_i)

sum_min = 9999999999999
(1..100).each do |i|
    sum = 0
    x_n.each do |x|
        sum += (x - i) ** 2
    end

    if sum < sum_min
        sum_min = sum
    end
end

puts sum_min


Measured memory_bytes: 2172
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

string W[100];
int N;

int main() {
  cin >> N;
  rep(i, N) cin >> W[i];

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < i; ++j) {
      if (W[i] == W[j]) {
        cout << "No" << endl;
        return 0;
      }
    }
    if (i != 0 && W[i-1][W[i-1].length()-1] != W[i][0]) {
      cout << "No" << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 256
// Bismillahirrahmanirrahim
// AgriCoder IPB
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>
#include <cctype>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <sstream>
#include <clocale>
#include <ctime>
#include <climits>
#include <cassert>
//#include <unordered_map>
using namespace std;

#define FOR(i, agri, coder) for (int i = (int)agri; i <= (int)coder; i++)
#define REP(agri,coder) for (int agri = 0; agri < (int)coder; agri++)
#define FOREACH(i,agricoder) for (typeof((agricoder).end()) i = (agricoder).begin(); i != (agricoder).end(); ++i)
//for (auto& it: agricoder)
#define RESET(agri,coder) memset(agri, coder, sizeof(agri))
#define pb push_back
#define mp make_pair
#define NL printf("==========================\n")
#define getchar_unlocked getchar // for codeforces

int arahbar[8] = {0,1,0,-1,1,1,-1,-1};
int arahkol[8] = {1,0,-1,0,1,-1,-1,1};
int kudabar[8] = {-2,-1,1,2, 2,1 , -1 ,-2};
int kudakol[8] = {1 ,2 ,2,1,-1,-2 , -2,-1};

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef unsigned int UNi;

template<typename T>
T getNum() {
   T res=0;
   char c;
   while(1)
   {
      c=getchar_unlocked();
      if(c==' ' || c=='\n') continue;
      else break;
   }
   bool negatif;
   if (c=='-') {
       negatif = true;
       res = 0;
   }
   else {
       res=c-'0';
       negatif = false;
   }
   while(1)
   {
      c=getchar_unlocked();
      if('0'<=c && c<='9') res=res*10 + c-'0';
      else break;
   }
   if (negatif) res*=-1;
   return res;
}

inline void boost() { //dont use with cstdio, dont use in interactives
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
}
//freopen("badmilk.in", "r", stdin);
//freopen("badmilk.out", "w", stdout);
//fclose(stdin);
//fclose(stdout);

#define INF 1000000000
#define EPS 1e-9
#define MAX_N 100005
// ================================  TEMPLATE ENDS HERE ================================================== //

int main() {
	  int n;	  
	  scanf("%d",&n);
	  if (n<=2) {
		  printf("1\n");
		  return 0;
	  }
	  
	  int x;
	  int cur;
	  int status; // 0 = equal, 1 menaik, -1 menurun
	  int ans = 0;
	  
	  scanf("%d %d",&cur,&x);
	  if (x>cur) status = 1;
	  else if (x<cur) status = -1;
	  else status = 0;
	  cur = x;
	  
	  FOR(zz,3,n) {
		 scanf("%d",&x);
		 if ( (x>cur and status==-1) or (x<cur and status==1) ) {
			 ans++;
			 status = 0;
	     }
	     else if (status==0) {
			 if (x>cur) status = 1;
			 else if (x<cur) status = -1;
	     }
		 
		 cur = x;
	  }
	  
	  printf("%d\n",ans+1);
	  return 0;
}
//Alhamdulillahirabbilalamin


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(it,st,en) for(int it=(st);it<(int)(en);++it)
#define allof(c) (c).begin(), (c).end()
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define X first
#define Y second
typedef long long int ll; 
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
const int INF=(int)1e9; 
const double EPS=(ld)1e-7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    vector<vector<bool> > reach(2,vector<bool>(n));
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        --a,--b;
        if(a>b) swap(a,b);
        if(a == 0) reach[0][b] = true;
        if(b == n-1) reach[1][a] = true;
    }
    bool b = false;
    rep(i,0,n){
        if(reach[0][i] && reach[1][i]) b=true;
    }
    if(b) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 384
import Data.Vector.Unboxed (Vector, (!))
import qualified Data.Vector.Unboxed as U

solve :: Vector Char -> Int -> Int
solve s d = min d $ U.maximum $ U.scanl f 0 $ sd where
  sd = U.zip s $ U.drop d s
  f x (a, b)
    | a == b = x + 1
    | otherwise = 0

main = do
  n <- readLn
  s <- U.fromList <$> getLine
  print $ maximum $ [solve s d | d <- [0..n-1]]


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 3e3 + 5;

pii pp[MAXN];

vi g[MAXN];

int v[MAXN];

int state[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REPN(i, 1, n){
		scanf("%d", &v[i]);
	}
	REP(i, 1, n){
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].pb(b);
		g[b].pb(a);
	}
	REPN(i, 1, n){
		pp[i] = mp(v[i], i);
	}
	sort(pp + 1, pp + n + 1);
	REPN(i, 1, n){
		int s = pp[i]._2;
		REP(j, 0, SZ(g[s])){
			int to = g[s][j];
			if (v[to] < v[s] && state[to] == 0){
				state[s] = 1;
				break;
			}
		}
	}
	REPN(i, 1, n){
		if (state[i]){
			printf("%d ", i);
		}
	}
	putchar('\n');
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n;
int a[3000];
long long dp[3001][3001];



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

	
	cin >> n;
	rep(i, n)cin >> a[i];

	for (int i = 1; i <= n; i++) rep(j, n-i+1) {
		int size = i;
		if ((n - size) % 2 == 0) {
			auto ret = max(a[j] + dp[i - 1][j + 1], a[j + i - 1] + dp[i - 1][j]);
			dp[i][j] = ret;
		}
		else {
			auto ret = min(dp[i - 1][j + 1], dp[i - 1][j]);
			dp[i][j] = ret;
		}
	}

	auto sum = accumulate(a, a + n, 0LL);

	cout << 2*dp[n][0] -sum << endl;

	return 0;
}


Measured memory_bytes: 70016
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

const int M = 1<<12;

int main(int argc, char const *argv[]) {
	int n,m; cin>>n>>m;
	vector<int> a(m);
	vector<vector<int>> c(m);
	map<int,int> mp;

	rep(i,m) {
		int b; cin>>a[i]>>b;
		c[i].resize(b);
		rep(j,b) {
			cin>>c[i][j];
			mp[c[i][j]]++;
		}
	}

	if (mp.size()!=n) {
		cout << -1 << endl;
		return 0;
	}


	vector<vector<ll>> dp(m+10, vector<ll>(M, LINF));
	int tap = 0;
	for (auto &&e: c[0]) {
		int tm = (1<<e-1); tap+=tm;
	}
	dp[0][0] = 0;

	for (int i = 0; i < m; ++i) {
		rep(j,M) {
			if (dp[i][j] == LINF) continue;
			dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
			int nex = j;
			for (auto &&k: c[i]) {
				int tmp = (1<<k-1);
				nex |= tmp;
			}
			dp[i+1][nex] = min({dp[i+1][nex], dp[i][j]+a[i]});
		}
	} 

	int bee = 0;
	for (int i = 0; i < n; ++i) {
		int ta = (1<<i);
		bee+=ta;
	}
	cout << dp[m][bee] << endl;

	return 0;
}


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

const double PI = 3.14159265359;
const int INF = (int)1e9;
const ll LINF = 1e18;
const int IMOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[5] = {0, 1, 0, -1};

using namespace std; 

int main(void)
{
    int n;
    cin >> n;
    int mod2 = 0;
    int mod4 = 0;
    int mod1 = 0;
    
    irep(i, n) {
        int tmp;
        cin >> tmp;
        if(tmp % 4 == 0) { 
            mod4++; 
        } else if (tmp % 2 == 0){ 
            mod2++;
        } else {
            mod1++;
        }
    }

    if(mod2) {
        if(mod1 <= mod4) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if(mod1 <= mod4 + 1) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}
/** atcoder **/



Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	int n,m,mtA,mtb,mt;
	cin >> n >> m;
	int A[100][100];
	int b[100];
	int c[100];
	mt = 0;
 
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			A[i][j] = 0;
		}
 
	}
 
	for(int k = 0; k < m; k++){
		b[k] = 0;
		c[k] = 0;
	}
 
	//??????A
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >>  A[i][j];
		}
 
	}
 
	//??????b
	for(int k = 0; k < m; k++){
		cin >>  b[k];
	}
 
	//???????¨????
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			c[i] += A[i][j]* b[j];
		}
	}
 
	//??????
	for(int i = 0; i < n; i++){
		cout << c[i] <<  endl;
	}
	return 0;
}

Measured memory_bytes: 3132
#include<stdio.h>
int main (void){
    int n,i,j=0,a[200],b[200],v;
    
    scanf("%d",&n);
    for(i = 0; i < n; i++){
        scanf("%d",&v);
        a[i] = v;
    }
    printf("%d",a[i-1]);
    for(i = i-2; i >= 0; i--){
        printf(" ");
        b[j] = a[i];
        printf("%d",b[j]);
        j++;
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2756
alphabets = "abcdefghijklmnopqrstuvwxyz"

N = int(input())

c = 26
w = 1
n = N
while c < n:
	n -= c
	c *= 26
	w += 1

#print(c, w, n)

name = ""
n -= 1
for i in range(w):
	name = alphabets[n % 26] + name
	n //= 26

print(name)


Measured memory_bytes: 9168
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long N = scan.nextLong();
		long A = scan.nextLong();
		long B = scan.nextLong();
		String S = scan.nextLine();
		S = scan.nextLine();

		int a = 0;
		int b = 0;
		for(int i=0;i<N;i++){
			String s = S.substring(i, i+1);
			if(s.equals("a")){
				if(a+b<A+B){
					System.out.println("Yes");
					a++;
				}else{
					System.out.println("No");
				}
			}else if(s.equals("b")){
				if((a+b<A+B)&&(b<B)){
					System.out.println("Yes");
					b++;
				}else{
					System.out.println("No");
				}
			}else{
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 28364
import java.util.*;
import java.math.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int result = 0;

		for(int i=0;i<n;i++){
			int a = sc.nextInt();
			int b = sc.nextInt();

			if(a <h || b < w){
				continue;
			}
			// System.out.println(a/h);
			// System.out.println(b/w);
			result += Math.min(a/h,b/w);
		}

		System.out.println(result);
	}


}

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

typedef long long ll;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
	if(!b) return a;
	return gcd(b, a % b);
}

ll Pow(ll a, ll b)
{
	ll ans = 1;
	for(; b; b >>= 1)
	{
		if(b & 1) ans = ans * a % MOD;
		a = a * a % MOD;
	}
	return ans;
}

ll H, W, T, g, h;

int main()
{
	cin >> H >> W >> T;
	g = H / gcd(H, T), h = W / gcd(W, T);
	ll ans = 1ll + Pow(2, g) - 1ll + Pow(2, h) - 1ll + Pow(2, gcd(g, h)) - 2ll;
	ans = (ans % MOD + MOD) % MOD;
	ans = Pow(ans, (H / g) * (W / h));
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    int n = s.size();
    int l = 0;
    int r = n+1;
    while (r-l > 1) {
        int mid = (l+r)/2;
        bool check = [&] {
            for (int i = n-mid; i < mid-1; i++) {
                if (s[i] != s[i+1]) return false;
            }
            return true;
        } ();
        if (check) l = mid;
        else r = mid;
    }
    cout << l << endl;
}

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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, d, n, sum, A[500010], B[500000], rui[500000], dp[5000];
ll suma[500000], sumb[500000];
str S, T, U; bool check = true;	vector<ll> v;
map<ll, ll> m;


int main() {
	//Code Line
	cin >> n;
	

		for (int i = 1; i <= 100; i++) {

			for (int j = 1; j <= 100; j++) {

				for (int k = 1; k <= 100; k++) {

				a = i * i + j * j + k * k + i*j + j*k + k*i;
				m[a]++;

				}

			}

		}

	for(int i = 1;i <= n;i++){
	cout << m[i] << endl;
	}
	
	cin >> n;

	return 0;
}


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

using namespace std;

using int64 = long long;

// えーわからん
// これはなに

int main() {
  string S, T;
  cin >> S >> T;
  bool locked[26] = {};
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == T[i]) {
      locked[S[i] - 'a'] = true;
    } else {
      char u = S[i], v = T[i];
      if(locked[v - 'a'] || locked[u - 'a']) {
        cout << "No\n";
        return 0;
      }
      for(int j = i; j < S.size(); j++) {
        if(u == S[j]) S[j] = v;
        else if(v == S[j]) S[j] = u;
      }
      locked[v - 'a'] = true;
    }
  }
  cout << "Yes\n";
}



Measured memory_bytes: 776
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    long long n,h,nr,w;
    scanf("%lld",&n);
    for(h=1;h<=3500;h++){
        for(w=1;w<=3500;w++){
            if(4*h*w-n*h-n*w <= 0){continue;}
            if((n*h*w)%(4*h*w-n*h-n*w) != 0){continue;}
            nr = (n*h*w)/(4*h*w-n*h-n*w);
            printf("%lld %lld %lld\n",h,nr,w);
            return 0;
        }
    }
    return 0;
}

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

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

	long long ans = 0;
	while (x < a[0]) {
		a[0]--;
		ans++;
	}

	for (int i = 0; i < n - 1; i++) {
		if (a[i] + a[i + 1] <= x);
		else {
			long long diff = a[i] + a[i + 1] - x;
			while (diff) {
				ans++;
				diff--;
				a[i + 1]--;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
	int a, b; cin >> a >> b;
	if(a + b == 15) {
		cout << "+" << endl;
	} else if(a * b == 15) {
		cout << "*" << endl;
	} else {
		cout << "x" << endl;
	}
}


Measured memory_bytes: 888
/*
 * atcoder/abc136/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * RRLLRRRLLL
 * RLはともに1 1で変わらず. その左右からいくら集まってくるか.
 *
 * 2 2 3 3
 *
 * 0 1 2 2 2
 */
template <class T, class T2>
void group(T &xs, vector<pair<T2, int> > &result) {
  int i=0, j;
  while (i<xs.size()) {
    j=i;
    while (j < xs.size() and xs[j] == xs[i]) j++;
    result.push_back({ xs[i], j-i });
    if (j==i) i++;
    i=j;
  }
}
string S;
int N;
void solve() {
  cin >> S; N = S.size();
  vector<pair<char, int> > result;
  group(S, result);
  int index = 0;
  for (int i=0; i+1<result.size(); i += 2) { // RLは必ずペア
    int R = result[i].second;
    int L = result[i+1].second;
    loop(i,1,R) cout << "0 ";
    int halfR = (R+1)/2;
    int halfL = (L+1)/2;
    int numR = halfR;
    int numL = halfL;
    numR += L - halfL;
    numL += R - halfR;
    cout << numR << " " << numL << " ";
    loop(i,1,L) cout << "0 ";
  }
  cout << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 1528
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n,k;
  cin>>n>>k;

  if( k > (n-2)*(n-1)/2 ){
    cout << "-1" << endl;
  }
  else{
    ll m=n*(n-1)/2 - k;
    cout << m << endl;
    ll cnt=0;
    for(ll i=1;i<n;i++){
      for(ll j=i+1;j<n;j++){        
        cnt++;
        if(cnt >k){
          cout << i << " " << j << endl;
        }
      }
    }
    for(ll i=1;i<n;i++){
      cout << i << " " << n << endl;
    }

  }

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main(){
	long long int n, ans = 1;
	cin >> n;
	for(int i = 1;i<=n;i++){
		ans = ans * i % (long long int)(pow(10, 9) + 7);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int h, w;
    cin >> h >> w;
    vector<string> a(h );
    REP(i, h) cin >> a[i];
    bool white;
    REP(i, h){
        white = true;
        REP(j, w) {
            if(a[i][j] == '#') white = false;
        }
        if(white){
            REP(j, w) a[i][j] = '*';
        }
    }
    REP(j, w){
        white = true;
        REP(i, h) {
            if(a[i][j] == '#') white = false;
        }
        if(white){
            REP(i, h) a[i][j] = '*';
        }
    }
    REP(i, h){
        white = true;
        REP(j, w) {
            if(a[i][j] != '*') {
                cout << a[i][j];
                white = false;
            }
        }
        if(!white) cout << endl;
    }
    //cout << ans << endl;
}

Measured memory_bytes: 256
#define Bobyama
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 2000, MAX_M = 2000;
int N, M;
int S[MAX_N+1], T[MAX_M+1];

ll dp[MAX_N+1][MAX_M+1];

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

  cin >> N >> M;
  rep(i, 1, N) cin >> S[i];
  rep(i, 1, M) cin >> T[i];

  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= M; ++j) {
      dp[i][j] = mod(dp[i-1][j] + dp[i][j-1], MOD);
      if (S[i] != T[j]) dp[i][j] = mod(dp[i][j]-dp[i-1][j-1], MOD);
      else dp[i][j] = mod(dp[i][j]+1, MOD);
    }
  }

  cout << mod(dp[N][M] + 1, MOD) << endl;

  return 0;
}


Measured memory_bytes: 31488
#include <iostream>
using namespace std;
int main() {
  int i, j, H, W;
  while(cin >> H >> W) {
	if(H == 0 && W == 0) { break; }
	for(i = 0; i < H; i++) {
	  for(j = 0; j < W; j++) {
		cout << "#";
	  }
	  cout << endl;
	}
	cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(c,i) for(i = c.begin(); i != c.end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e;++i)
#define forsn(i,s,e) for(int i = s; i < e;++i)
#define rforn(i,s) for(int i = s; i >= 0;--i)
#define rforsn(i,s,e) for(int i = s; i >= e;--i)
# define INF 0x3f3f3f3f 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=1e5+5,MOD=1e9+7;

int main()
{
    ll i,j,k,x,y;
    ll h,w;
    cin>>h>>w;
    char a[h][w];
    forn(i,h)
    {
        forn(j,w)
        {
            cin>>a[i][j];
        }
    }
    ll dp[h][w];
    forn(i,h)
    {
        forn(j,w)
        {
            if(i==0 && j==0)
            {
                dp[i][j]=1;
                continue;
            }
            if(a[i][j]=='#')
                dp[i][j]=0;
            else
            {
                ll x1=0,x2=0;
                if(i>0)
                    x1=dp[i-1][j];
                if(j>0)
                    x2=dp[i][j-1];
                dp[i][j]=(x1+x2)%MOD;
            }
        }
    }
    cout<<dp[h-1][w-1]<<"\n";
}

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

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

  int ans = 0;
  int ba = 0;
  int b = 0;
  int a = 0;
  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    for (int j = 0; j < s.size()-1; j++)
    {
      if(s[j]=='A'&&s[j+1]=='B') ans++;
    }

    if(s[0]=='B'&&s[s.size()-1]=='A') ba++;
    else if (s[0]=='B') b++;
    else if (s[s.size()-1]=='A') a++;    
  }

  if(ba==0){
    ans+=min(a,b);
  }
  else{
    if(a+b>0){
      ans+=ba+min(a,b);
    }
    else{
      ans+=ba-1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 2 * 100'000 + 5;

i64 n;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    string s, t;
    cin >> s >> t;
    if (s.size() + 1 != t.size()) {
        cout << "No" << endl;
        return 0;
    }

    if (t.substr(0, s.size()) != s) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const int N = 3e3 + 10;
int n, m;
int A[N], B[N], C[N], D[N], E[N], F[N];
ll ans;
vector<int>xx, yy;
int id(vector<int>&vc, int x) {
	return lower_bound(vc.begin(), vc.end(), x) - vc.begin();
}
int dx[]{ 0,0,-1,1 };
int dy[]{ -1,1,0,0 };
int die[N][N][4];
typedef pair<int, int> pii;
queue<pii>q;
int vis[N][N];
int main() {
	scanf("%d%d", &n, &m);
	xx.push_back(0);
	yy.push_back(0);
	xx.push_back(-INF); xx.push_back(INF);
	yy.push_back(-INF); yy.push_back(INF);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d%d", &A[i], &B[i], &C[i]);
		xx.push_back(A[i]);
		xx.push_back(B[i]);
		yy.push_back(C[i]);
	}
	for (int i = 1; i <= m; i++) {
		scanf("%d%d%d", &D[i], &E[i], &F[i]);
		yy.push_back(E[i]);
		yy.push_back(F[i]);
		xx.push_back(D[i]);
	}
	sort(xx.begin(), xx.end()); xx.erase(unique(xx.begin(), xx.end()), xx.end());
	sort(yy.begin(), yy.end()); yy.erase(unique(yy.begin(), yy.end()), yy.end());
	for (int i = 1; i <= n; i++) {
		A[i] = id(xx, A[i]);
		B[i] = id(xx, B[i]);
		C[i] = id(yy, C[i]);
		for (int j = A[i]; j < B[i]; j++) {
			die[j][C[i]][0] = 1;
			die[j][C[i] - 1][1] = 1;
		}
	}
	for (int i = 1; i <= m; i++) {
		D[i] = id(xx, D[i]);
		E[i] = id(yy, E[i]);
		F[i] = id(yy, F[i]);
		for (int j = E[i]; j < F[i]; j++) {
			die[D[i]][j][2] = 1;
			die[D[i] - 1][j][3] = 1;
		}
	}
	q.push(pii(id(xx, 0), id(yy, 0)));
	while (!q.empty()) {
		int x = q.front().first, y = q.front().second; q.pop();
		
		for (int i = 0; i < 4; i++) {
			if (die[x][y][i])continue;
			int nx = x + dx[i], ny = y + dy[i];
			if (nx == 0 || nx == (int)xx.size() - 1 || ny == 0 || ny == (int)yy.size() - 1) {
				puts("INF");
				return 0;
			}
			if (vis[nx][ny])continue;
			vis[nx][ny] = 1;
			ans += 1ll * (xx[nx + 1] - xx[nx])*(yy[ny + 1] - yy[ny]);
			q.push(pii(nx, ny));
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 160520
nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(nums[K-1])

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

using namespace std;


int main() {
    int n;
    cin>>n;
    int num[n+1];
    for (int i = 1; i < n+1; ++i) {
        cin>>num[i];
    }
    int count=0,now=1;
    for (int j = 0; j < n; ++j) {
        now=num[now];
        count++;
        if(now==2){
            cout<<count<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

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

int main() {
	long long h, w; 
	long long z = 100000000000 ;
	cin >> h >> w;
    if (h%3==0) z = 0;
    else z = min(z, w);
    if (w%3==0) z = 0;
    else z = min(z, h);

    long long a, b, c;
    for (int i=1; i<h; i++){
      a = i*w;
      if (w%2==0){
        b = w/2*(h-i);
        z = min(z, abs(a-b));
      }
      else{
        b = w/2*(h-i);
        c = (w/2+1)*(h-i);
        long long n1 = min(a, min(b, c));
        long long n2 = max(a, max(b, c));
        z = min(z, (n2-n1));
      }
    }
    for (int i=1; i<w; i++){
      a = i*h;
      if (h%2==0){
        b = h/2*(w-i);
        z = min(z, abs(a-b));
      }
      else{
        b = h/2*(w-i);
        c = (h/2+1)*(w-i);
        long long n1 = min(a, min(b,c));
        long long n2 = max(a, max(b,c));
        z = min(z, (n2-n1));
      }
    }
    cout << z << '\n';
	
}


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

const int mod = 1e9 + 7;

int modpow(long long a, long long b){
    if(b == 0) return 1;
    if((b & 1) == 0) return modpow(a*a % mod, b/2);
    return a * modpow(a, b-1) % mod;
}

int main(){
    int a, b; cin >> a >> b;
    
    cout << modpow(a, b) << endl;
}


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

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

  int sum = 0;
  rep(i, N.size()) sum += N[i] - '0';
  if (sum % 9 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> sum(100003);
	for (int i = 0, a, b; i < N; i++) {
		cin >> a >> b;
		sum[a]++;
		sum[b + 1]--;
	}
	int res = -1;
	for (int i = 1; i <= 100002; i++) {
		sum[i] += sum[i - 1];
		if (sum[i] + 1 >= i) {
			res = i;
		}
	}
	cout << res - 1 << endl;
	return 0;
}

Measured memory_bytes: 3104
n, a, b = map(int, input().split())

A = list(map(int, input().split()))

t = 0
for i in range(n - 1):
    if (A[i+1] - A[i]) * a > b:
        t += b
    else:
        t += (A[i+1] - A[i]) * a
print(t)

Measured memory_bytes: 62704
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair
#define pb push_back
#define pp pop_back
#define pii pair<int,int>
#define fi first
#define se second 
#define in insert
#define er erase
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
using namespace std;
const int mx=1e5+10;
int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	ll n,m;cin>>n>>m;
	if(m<2*n) return cout<<m/2,0;
	else{
		m-=n*2ll;
		cout<<n+(m/4);
	}
}


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

int main() {
    int n, k; std::cin >> n >> k;
    std::vector<bool> sunuke(n, true);
    rep(i,k) {
        int d; std::cin >> d;
        rep(j, d) {
            int a; std::cin >> a;
            sunuke[a-1] = false;
        }
    }
    int ans=0;
    rep(i, n) if (sunuke[i]) ++ans;
    std::cout << ans << std::endl;
    return 0;
}


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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
constexpr int inf = 1000000;
int main(){
    string str;
    cin>>str;
    stack<char> s;
    for(int i=0;i<(int)str.size();++i){
        if(str[i] == 'S') s.push('S');
        else if(str[i] == 'T' && (s.empty() || s.top() == 'T')) s.push('T');
        else s.pop();
    }
    cout << s.size() << endl;
    return 0;
}



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

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i) >> b.at(i) >> c.at(i);
    }

    vector<vector<vector<int>>> dp(41, vector<vector<int>>(410, vector<int>(410, 1000)));
    dp[0][0][0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 400; j++) {
            for (int k = 0; k <= 400; k++) {
                if (dp.at(i).at(j).at(k) < 1000) dp.at(i + 1).at(j).at(k) = dp.at(i).at(j).at(k);
                
                if (j - a.at(i) >= 0 && k - b.at(i) >= 0 && dp.at(i).at(j - a.at(i)).at(k - b.at(i)) < 1000) {
                    dp.at(i + 1).at(j).at(k) = min(dp.at(i + 1).at(j).at(k), dp.at(i).at(j - a.at(i)).at(k - b.at(i)) + c.at(i));
                }
            }
        }
    }
    
    int ax = ma, bx = mb;
    int x = 1;
    int ans = 10000;
    while (ax * x <= 400 && bx * x <= 400) {
        if (dp.at(n).at(ax * x).at(bx * x) < 1000) ans = min(ans, dp.at(n).at(ax * x).at(bx * x));
        x++;
    }

    if (ans == 10000) cout << -1 << endl;
    else cout << ans << endl;
}   

Measured memory_bytes: 28416
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;

#define ITER( c ) __typeof( c ).begin()
#define REP( i, m, n ) for ( int i = m; i < n; i++ )
#define UREP( i, m, n ) for ( unsigned int i = m; i < n; i++ )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) c.begin(), c.end()
#define PB( n ) push_back( n );
#define MP( a, b ) make_pair( a, b )
#define fst first
#define snd second

bool leap( int y )
{
	if ( !( y % 400 ) )
	{
		return true;
	}
	else if ( !( y % 100 ) )
	{
		return false;
	}
	else if ( !( y % 4 ) )
	{
		return true;
	}

	return false;
}

int main()
{
	int a, b;
	bool first = true;

	while ( cin >> a >> b )
	{
		if ( a == 0 && b == 0 )
		{
			break;
		}

		bool be = false;


		if ( !first )
		{
			cout << endl;
		}
		else
		{
			first = false;
		}

		for ( int i = a; i <= b; i++ )
		{
			if ( leap( i ) )
			{
				be = true;
				cout << i << endl;
			}
		}

		if ( !be )
		{
			cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int main() {

int n ;
cin >> n ;
vector<int> a(n+1) ;

for (int i = 1; i <=n ; i++)
{
  for (int j = i; j <=n ; j+=i)
  {
    a[j]++ ;
  }
}

ll ans = 0 ;
for (int i = 1; i <= n; i++)
{
  ans += ll(i)*a[i] ;
}

cout << ans << endl;

return 0; 
}

Measured memory_bytes: 42276
#include<stdio.h>

int main()
{
	int w , h , x , y , r;
	scanf("%d %d %d %d %d", &w , &h , &x , &y , &r);
	if((x+r <= w && x - r >= 0)&&(y+r <= h && y-r >= 0))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
	int a, b;
	cin >> a >> b;
	cout << max(a, b) + max((max(a, b) - 1), min(a, b)) << endl;	
}

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

int main() {

	int n;
	int a[199];

	cin >> n;

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


	for (int m = 0; 1; m++) {

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

			if (!(a[i] % 2 == 0)) {
				cout << m << endl;
					return 0;
				
			}

			a[i] = a[i] / 2;

		}
	}



}


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

signed main() {
  int N, M;
  cin >> N >> M;
  
  vector<tuple<int, int, int>> SI(M);
  int P, Y;
  for( int i = 0; i < M; i++ ){
    cin >> P >> Y;
    SI.at(i) = make_tuple(P, Y, i);
  }
  sort( SI.begin(), SI.end() );
  
  int cnt = 0;
  vector<string> ans(M);
  for( int i = 0; i < M; i++ ){
    string S;
    if( i > 0 && get<0>(SI.at(i)) != get<0>(SI.at(i-1)) ){
      cnt = 1;
    }else{
      cnt++;
    }
    
    for( int j = 0; j < 6 - (int)to_string( get<0>(SI.at(i)) ).length(); j++ ) S += "0";
    S += to_string( get<0>(SI.at(i)) );
    for( int j = 0; j < 6 - (int)to_string(cnt).length(); j++ ) S += "0";
    S += to_string(cnt);
    ans.at( get<2>(SI.at(i)) ) = S;
  }
  
  for( int i = 0; i < M; i++ ) cout << ans.at(i) << endl;
}


Measured memory_bytes: 10880
from sys import exit, stdin
S = stdin.readline().rstrip()
T = stdin.readline().rstrip()
LOS, LOT = len(S), len(T)
for i in range(LOS)[::-1]:
    p = S[i:i+LOT]
    LOP = len(p)
    if LOP != LOT:
        continue

    ok = True
    for j in range(LOP):
        if p[j] == '?':
            continue
        if p[j] != T[j]:
            ok = False

    if ok:
        print(S[:i].replace('?', 'a')+T+S[i+LOT:].replace('?', 'a'))
        exit()
print("UNRESTORABLE")

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        static final int MODULO = (int) (1e9 + 7);

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int zeroes = in.nextInt();
            int ones = in.nextInt();
            int k = in.nextInt();
            int depth = (zeroes + ones - 1) / (k - 1);
            int[] ways = new int[ones + 1];
            ways[0] = 1;
            long res = 0;
            boolean[] nice = new boolean[ones + 1];
            for (int i = 1; i <= depth; ++i) {
                Arrays.fill(nice, false);
                for (int extra = 0; i + extra <= depth; ++extra) {
                    int now = ones - extra * (k - 1);
                    if (now >= 0) {
                        nice[now] = true;
                    }
                }
                for (int old = ones; old >= 0; --old)
                    if (ways[old] != 0) {
                        for (int cur = 1; cur < k && old + cur <= ones; ++cur) {
                            if (nice[old + cur]) {
                                res += ways[old];
                                if (res >= MODULO) res -= MODULO;
                            }
                            ways[old + cur] += ways[old];
                            if (ways[old + cur] >= MODULO) ways[old + cur] -= MODULO;
                        }
                    }
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main(void){
    long long int n,k,i,ans;
    ans = 0;

    cin >> n >> k;

    vector<long long int> h(n);

    for(i=0; i<n; i++){
        cin >> h.at(i);
    }

    sort(h.begin(),h.end());


    if(k >= n){
        cout << 0 << endl;
    }else{
        for(i=0; i<n-k; i++){
            ans += h.at(i);
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

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

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    a *= 100;
    b *= 100;
    double mcon = -1.0;
    int mwat = 0;
    int msug = 0;

    for (int i = 0, nli = f / a; i <= nli; ++i)
    {
        for (int j = 0, nlj = (f - (a * i)) / b; j <= nlj; ++j)
        {
            int wat = a * i + b * j;
            if (wat > f) continue;
            int maxsug = (wat/100)*e;
            for (int k = 0, nlk = maxsug / c; k <= nlk; ++k)
            {
                for (int l = 0, nll = (maxsug - c * k) / d; l <= nll; ++l)
                {
                    int sug = c * k + d * l;
                    if (wat + sug > f) continue;
                    double con = 100.0 * sug / (wat + sug);
                    if (con > mcon) 
                    {
                        mcon = con;
                        mwat = wat;
                        msug = sug;
                    }
                }
            }

        }
    }
    cout << mwat + msug << " " << msug << endl;

    return 0;
}


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

const int N = 100010;

int n;
int cnt[N];

int main(){
	scanf("%d", &n);
	for (int i = 0, x; i < n; ++ i){
		scanf("%d", &x);
		++ cnt[x];
	}
	int ans = 0;
	for (int i = 1; i < N - 1; ++ i){
		ans = std::max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1]);
	}
	return printf("%d\n", ans), 0;
}

Measured memory_bytes: 640