akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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 long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
/*void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}*/

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}


int main() {
	ll k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> vis(n, 0);
	ll p = 0;
	rep(i, n) {
		cin >> a[i];
		--a[i];
	}
	if (k <= 1000000000) {
		ll tt = 0;
		rep(i, k) {
			tt = a[tt];
		}
		cout << tt + 1 << endl;
		return 0;
	}
	vis[0] = 1;
	ll cnt = 0;
	ll roop = 0;
	vector<ll> rop(2*n);
	ll i = 0;
	ll tmp = 0;
	while(1) {
		tmp = p;
		p = a[p];
		if (roop > 0 && vis[p] == -1) {
			break;
		}
		if (vis[p] == 0) {
			vis[p] = 1;
		}
		else {
			++roop;
			vis[p]=-1;
			rop[i] = p+1;
			++i;
		}
	}
	rep(i, n) {
		if (vis[i] == 1) {
			++cnt;
		}
	}
	k -= cnt;
	ll res = rop[k%roop];
	cout << res << endl;
}

Measured memory_bytes: 9692
/*
Contest: -
Problem: Aizu 2456
Author: tzc_wk
Time: 2020.7.26
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define y1			y1010101010101
#define y0			y0101010101010
#define int long long
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
int n=read();
int x[1000005],sz[1000005],dp[1000005];
vector<int> g[1000005];
inline void dfs(int u){
	sz[u]=x[u];
	vector<int> son;
	foreach(it,g[u]){
		dfs(*it);
		sz[u]+=sz[*it];
		dp[u]+=dp[*it];
		son.push_back(sz[*it]);
	}
	sort(all(son));
	reverse(all(son));
	for(int i=0;i<son.size();i++){
		dp[u]+=son[i]*i;
	}
}
signed main(){
	fz(i,1,n){
		x[i]=read();
		int f=read();f++;
		g[f].push_back(i);
	}
	int ans=0;
	foreach(it,g[0]){
		dfs(*it);
		ans+=dp[*it];
	}
	cout<<ans<<endl;
	return 0;
}
/*
0
|\
| \
|  \
1   2

 0
 |\
 | \
 |  \
 1   2
(1) (1)
 |\   \
 | \   \
 |  \   \
 3   4   5
(2) (3) (6) 

x_1 x_2 ... x_{n1}
y_1 y_2 ... y_{n2}
x_{n1} y_{n2}
*/


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

using namespace std;
using ll=long long;

#define RREP(i,m,n) for(int i=(int)(m);i>=(int)(n);--i)
#define rrep(i,m) RREP(i,m,0)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
const int MOD=1e9+7;

template<typename T>
void fail(T v){cout << v << endl;exit(0);}

void solve(){
  while(true){
    int a,b;
    cin >> a >> b;
    if(!(a|b))break;
    int len=a*a+b*b;
    int min=1000000,h=-1,w=-1;
    REP(i,1,150)
      REP(j,i+1,150){
        int dif=(i*i+j*j)-len;
        if(dif<0||(i==a&&j==b))continue;
        if((dif|min)&&dif<min){
          if(!dif&&i<=a)continue;
          min=dif;
          h=i;w=j;
        }
      }
    cout << h << " " << w << endl;
  }
}

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



Measured memory_bytes: 3160
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;

const int MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
const int INF = INT_MAX / 2;

int main() {
	int N; cin >> N;
	string s; cin >> s;
	int x = 0, mi = 0;
	rep(i, N) {
		if (s[i] == '(') x++;
		if (s[i] == ')') x--;
		mi = min(mi, x);
	}
	rep(t, -mi) s = "(" + s;
	rep(t, x - mi) s = s + ")";
	cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>]
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(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; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

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

int main() {

	int R;
	cin >> R;

	float ans = R * 2 * 3.14;

	cout << ans << endl;

}


Measured memory_bytes: 3784
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    return arr

a, b = map(int, input().split())
fa = factorization(a)
fb = factorization(b)

i = 0
j = 0
cnt = 1
while i < len(fa) and j < len(fb):
  if fa[i][0] == fb[j][0]:
    cnt += 1
    i += 1
    j += 1
  elif fa[i][0] < fb[j][0]:
    i += 1
  else:
    j += 1

print(cnt)

Measured memory_bytes: 9380
import math
n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]

ans=0
for i in range(n):
  for j in range(i+1,n):
    res=0
    for k in range(d):
      res+=(x[i][k]-x[j][k])**2
    if math.sqrt(res)==int(math.sqrt(res)):
      ans+=1
print(ans)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

int dp[51][51][2501];
 
signed main()
{
    int2(n, a);
    int data[n];
    rep(i, n) cin >> data[i];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    rep(i, n) {
        for (int j = 0; j <= i; j++) {
            rep(k, 2501) {
                if (dp[i][j][k]) {
                    dp[i+1][j+1][k+data[i]] += dp[i][j][k];
                    dp[i+1][j][k] += dp[i][j][k];
                }
            }
        }
    }
    int ans = 0;
    rep(i, n+1) {
        for (int j = 1; j < 2501; j++) {
            if (i * a == j) {
                ans += dp[n][i][j];
            }
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 51072
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vint C(N - 1), S(N - 1), F(N - 1);
    rep(i, N - 1) cin >> C[i] >> S[i] >> F[i];

    vll ans(N);
    rep(i, N - 1) {
        ll t = S[i];
        REP(j, i + 1, N) {
            t += C[j - 1];
            if (j < N - 1) {
                ll x = t / F[j];
                if (t % F[j] > 0) x++;
                t = max(ll(S[j]), F[j] * x);
            }
        }
        ans[i] = t;
    }
    rep(i, N)
        cout << ans[i] << endl;
    return 0;
}

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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

string s;
string ans;
int main(){
	cin >> s;
	ans = "Yes";
	REP(i,0,s.size()){
		if(i % 2 == 0 && s[i]=='L') ans="No";
		else if(i % 2 == 1 && s[i]=='R') ans="No";
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();        
        int N = r.i();
        long[] A = r.ll();
        long sum = 0;
        for(int i = 0; i < N-1; i++){
            if(A[i] < 0){
                A[i] = -A[i];
                A[i+1] = -A[i+1];
            }
            sum += A[i];
        }
        if(A[N-1] < 0){
            A[N-1] = -A[N-1];
            sum -= 2*min(A);
        }
        sum += A[N-1];
        print(sum);
    }
    static void print(Object o){
        System.out.println(o.toString());
    }
    static int max(int[] ii){
        int max = ii[0];
        for(int i : ii) if(max < i) max = i;
        return max;
    }
    static int min(int[] ii){
        int min = ii[0];
        for(int i : ii) if(i < min) min = i;
        return min;
    }
    static long max(long[] ll){
        long max = ll[0];
        for(long l : ll) if(max < l) max = l;     
        return max;
    }
    static long min(long[] ll){
        long min = ll[0];
        for(long l : ll) if(l < min) min = l;
        return min;
    }
    static double max(double[] dd){
        double max = dd[0];
        for(double d : dd) if(max < d) max = d;
        return max;
    }
    static double min(double[] dd){
        double min = dd[0];
        for(double d : dd) if(d < min) min = d;
        return min;
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return readLine().split(" ");
        }
        int i() throws IOException{
            return Integer.parseInt(readLine());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        int[] ii(int N) throws IOException{
            int[] ii = new int[N];
            for(int j = 0; j < N; j++) ii[j] = i();
            return ii;
        }
        long l() throws IOException{
            return Long.parseLong(readLine());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
        long[] ll(int N) throws IOException{
            long[] ll = new long[N];
            for(int j = 0; j < N; j++) ll[j] = i();            
            return ll;
        }
    }
}

Measured memory_bytes: 47392
n,m = input().split()
A = int(n)
B = int(m)
if (A + B <= A - B <= A * B) or (A - B <= A + B <= A * B):
    print(A * B)
elif(A - B <= A * B <= A + B) or (A * B <= A - B <= A + B):
    print(A + B)
else:
    print(A - B)

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

public class Main {
	static final long MOD = 998244353;
	static long modpow(long n, long y){
		if(y == 0){
			return 1;
		}else if(y == 1){
			return n % MOD;
		}else{
			if(y % 2 == 0){
				long r = modpow(n , y / 2);
				return (r * r) % MOD;
			}else{
				long r = modpow(n , y / 2);
				long r2 = (r * r) % MOD;
				return (r2 * n) % MOD;				
			}
		}
	}
	static long modinv(long n){
		return modpow(n , MOD - 2);
	}
	static long comb(int N , int R, long fact[]){
		long ret = fact[N];
		ret = (ret * modinv(fact[R])) % MOD;
		ret = (ret * modinv(fact[N - R])) % MOD;
		return ret;
	}

	
	static long sum(long A[] , long mod){
		long ret = 0;
		for(long l : A){
			ret = (ret + l) % mod;
		}
		return ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long M = sc.nextLong();
		int K = sc.nextInt();		
		long dp[] = new long[K + 1];
		dp[0] = M;
		long fact[] = new long[N + K + 1];
		fact[0] = 1;
		fact[1] = 1;
		for(int i = 2 ; i < fact.length ; ++i){
			fact[i] = ((long)(i) * fact[i - 1]) % MOD;
		}
		long S = M;
		long dpk = 0;
		for(int n = 1 ; n < N; ++n){
			/*
			long next[] = new long[K + 1];			
			next[0] = ((M - 1) * dp[0]) % MOD;
			for(int k = 1 ; k < dp.length ; ++k){
				next[k] = (dp[k - 1] + (M - 1) * dp[k]) % MOD;
			}
			*/		
			if(n - K == 0){
//				nextS -= M;
			}
			if(n - K - 1 >= 0){
				dpk = M * modpow(M - 1, n - K - 1);
				dpk = dpk % MOD;
				long comb = comb(n - 1, K, fact);
				dpk = (dpk * comb) % MOD;
//				System.out.println("*"+dpk+" "+comb);
			}
			long nextS = (S * M - dpk + MOD) % MOD;
//			long Sp = sum(dp , MOD);			
//			long Sn = sum(next , MOD);
//			System.out.println(Sp+" "+ Sn+" "+(Sp * M - dp[K]) % MOD);
//			System.out.println(dpk+" "+dp[K]);
//			System.out.println(S+" "+nextS);
			S = nextS;
//			dp = next;		
		}
		/*
		long ret = 0;
		for(long d : dp){
			ret = (ret + d) % MOD;
		}
		*/
		System.out.println(S);
	}
}


Measured memory_bytes: 31924
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main()
{
	cout << fixed << setprecision(10);


	LLI n;
	cin >> n;
	LLI ans = 0;
	for (LLI i = 2; i < 2000001; i++)
	{
		LLI v = i;
		while (v <= n)
		{
			if (n % v == 0)
			{
				ans++;
				n /= v;
			}
			v *= i;
		}
		while (n % i == 0)n /= i;
	}
	if (2000001 <= n)ans++;
	cout << ans;


	return 0;
}

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

int main(){

	int a,b;
	while(cin >> a >> b){
		int ans = 0;
		a = a + b;

		while(a > 0){
			a = a / 10;
				++ans;
		}
		cout << ans << '\n';
	}
	return 0;
}

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

int main() {
  int n,x,y;
  cin >> n >> x >> y;
  x--; y--;
  vector<int> ans(n+1,0);
  rep(i,0,n-1) rep(j,i+1,n) {
    if (i < x) {
      if (j <= x) {
        ans[j-i]++;
      } else if (x < j && j <= y) {
        ans[min(j-i,x+y-i-j+1)]++;
      } else {
        ans[x-i+j-y+1]++;
      }
    } else if (x <= i && i < y) {
      if (j <= y) {
        ans[min(j-i,i-x+y-j+1)]++;
      } else {
        ans[min(j-i,i-x+j-y+1)]++;
      }
    } else {
      ans[j-i]++;
    }
  }
  rep(i,1,n) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
matrix = []
vector = []

n, m = map(int, input().split())

for i in range(n):
    matrix.append(list(map(int, input().split())))

for i in range(m):
    vector.append(int(input()))

for i in range(n):
    value = 0
    for j in range (m):
        value += matrix[i][j] * vector[j]
    print(value)


Measured memory_bytes: 6008
#include<stdio.h>

int main(void){
	
	int a,b;
	
	scanf("%d %d\n",&a,&b);
	
	if(a<b){
		printf("a < b\n");
	}
	else if (a>b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
	
	return 0;
	
}

Measured memory_bytes: 584
def area n
  as = (n-1).times.map { gets.to_i }
  as << 360 - as.inject(0, :+)
  as.map {|a| Math.sin(2 * Math::PI * a / 360) }.inject(0, :+)
end

loop do
  m = gets.to_i
  break if m.zero?
  x = area(m)
  y = area(gets.to_i)
  p (x - y).abs < 1e-8 ? 0 : x > y ? 1 : 2
end

Measured memory_bytes: 8944
import java.util.*;
public class Main {
	
	public static void main (String[]args) {
		Scanner sc = new Scanner(System.in);
		
		int N =  sc.nextInt();

        List<Integer>inputList = new ArrayList<Integer>();
        // 入力値分入力を求める	
		for (int i = 0; i < N;i++) {
		
			int num = sc.nextInt();
		
			inputList.add(num);
		}

        // 入力値の重複を削除
         List<Integer> listB = new ArrayList<Integer>(new HashSet<>(inputList));
		
        // 要素数を出力
        System.out.println(listB.size());
	}	


}

Measured memory_bytes: 21844
#include <stdio.h>
 
int main (void)
 
{
int N[34] = {0,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};
 
int k;
 
scanf("%d",&k);
 
printf("%d",N[k]);
 
return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <vector>

bool isNotPrime[1000001];
std::vector<int> primes;

int main(){
    primes.push_back(2);
    for(int i=4;i<=1000000;i+=2){
        isNotPrime[i] = true;
    }

    for(int i=3;i<=1000000;i+=2){
        if(!isNotPrime[i]){
            primes.push_back(i);
            for(int j=2*i;j<=1000000;j+=i){
                isNotPrime[j] = true;
            }
        }
    }

    int A, D, N;
    while(scanf("%d %d %d", &A, &D, &N), A || D || N){
        int t = 0;
        for(int p : primes){
            if(p < A){continue;}
            if((p-A) % D > 0){continue;}
            if(++t == N){printf("%d\n", p); break;}
        }
    }
}

Measured memory_bytes: 2412
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>
#include <stack>
using ll = long long;
const ll ha = 1000000007LL;
ll pow_mod(ll a, ll b) {
  ll ans = 1, res = a;
  while(b) {
    if(1LL & b) ans = ans * res % ha;
    res = res * res % ha; b >>= 1;
  }
  return ans;
}
ll inv(ll x) {
  return pow_mod(x, ha - 2LL);
}

ll fac[200005], ifac[200005];
void process() {
  int n = 200000;
  fac[0] = 1;
  for(int i = 1; i <= n; i ++) fac[i] = (ll)i * fac[i - 1] % ha;
  ifac[n] = inv(fac[n]);
  for(int i = n - 1; i >= 0; i --) ifac[i] = (ll(i + 1)) * ifac[i + 1] % ha;
}
ll C(int n, int m) {
  if(n < m) return 0;
  ll ret = fac[n] * ifac[n - m] % ha;
  ret = ret * ifac[m] % ha;
  return ret;
}

const int maxn = 100005;
const int maxm = 200005;
std::vector<int> G[maxn];
void add_edge(int u, int v) {
  G[u].push_back(v);
}
void ins_edge(int u, int v) {
  add_edge(u, v); add_edge(v, u);
}

int n, m, k;
int bcnt = 0, clk = 0;
int pre[maxn], bccno[maxn];
int pn[maxm], en[maxm];
using pii = std::pair<int, int>;
int dfs(int x, int fa = -1) {
  static std::stack<pii> S;
  int lowu = pre[x] = ++ clk;
  for(int v : G[x]) {
    pii e = pii(x, v);
    if(!pre[v]) {
      S.push(e);
      int lowv = dfs(v, x);
      lowu = std::min(lowu, lowv);
      if(lowv >= pre[x]) {
        bcnt ++;
        pn[bcnt] = en[bcnt] = 0;
        while(true) {
          pii ee = S.top(); S.pop();
          int a = ee.first, b = ee.second;
          en[bcnt] ++;
          if(bccno[a] != bcnt) pn[bcnt] ++, bccno[a] = bcnt;
          if(bccno[b] != bcnt) pn[bcnt] ++, bccno[b] = bcnt;
          if(a == x && v == b) break;
        }
      }
    } else if(v != fa && pre[v] < pre[x]) {
      S.push(e);
      lowu = std::min(lowu, pre[v]);
    }
  }
  return lowu;
}
void calc_bcc() {
  for(int i = 1; i <= n; i ++) {
    if(!pre[i]) dfs(i);
  }
}

int gcd(int a, int b) {
  if(!b) return a;
  else return gcd(b, a % b);
}
ll calc(int x) {
  if(en[x] == 1) {
    return k;
  } else if(en[x] == pn[x]) {
    ll ret = 0;
    for(int i = 0; i < en[x]; i ++) {
      ret = (ret + pow_mod(k, gcd(i, en[x]))) % ha;
    }
    ret = ret * inv(en[x]) % ha;
    return ret;
  } else {
    return C(en[x] + k - 1, k - 1);
  }
}

int main() {
  process();
  scanf("%d%d%d", &n, &m, &k);
  for(int i = 1; i <= m; i ++) {
    int u, v; scanf("%d%d", &u, &v);
    ins_edge(u, v);
  }
  calc_bcc();
  ll ans = 1LL;
  for(int i = 1; i <= bcnt; i ++) {
    ans = ans * calc(i) % ha;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <string.h>
#include <algorithm>
#include <array>
#include <vector>
#include <cmath>
#include <set>

using namespace std;

int main( void ) {

    int A, B;
    cin >> A >> B;

    A = (A - B * 2) <= 0 ? 0 : A - B * 2; 

    cout << A << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x += y;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return (x * 1ll * y) % MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        lld n;
        cin>>n;
        lld ar[n];
        for(i=0;i<n;i++)
            cin>>ar[i];
        lld ans=LLONG_MAX;
        for(i=0;i<=100;i++)
        {
            lld ctr=0;
            for(j=0;j<n;j++)
                ctr+=(ar[j]-i)*(ar[j]-i);

            ans=min(ans,ctr);
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
#include <random>
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { D, R, U, L , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }
bool cklex(string &a, string b) {
	if (b == "") return false;
	if (a == "") return a = b, true;
	if (sz(a) < sz(b)) return false;
	if (sz(b) < sz(a)) return a = b, true;
	if (a < b) return false;
	return a = b, true;
}

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; } //convert index from 2D array to 1D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) { return{ n / nCol, n % nCol }; } //convert index from 1D array to 2D array (row, col). (Zero-indexed)
template<typename T> void inter(T X) { cout << X << endl; fflush(stdout); }


void solveF() {

}

void solveE() {

}

void solveD() {

}

void solveC() {

}

void solveB() {

}

void solveA() {
	int n;
	cin >> n;
	int l = (n / 1.08);
	if ((int)(l*1.08) == n) cout << l << endl;
	else if ((int)((l + 1.0)*1.08) == n) cout << l + 1 << endl;
	else cout << ":(\n";
}


int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	//cin >> t;
	while (t--) {
		solveA();
		//solveB();
		//solveC();
		//solveD();
		//solveE();
		//solveF();
	}


	return 0;
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] cost = new int[n];
			int m = 0;
			
			cost[0] = sc.nextInt();
			for(int i=1;i<n;i++){
				m = sc.nextInt();
				if(cost[i-1]+m>m) cost[i]=cost[i-1]+m;
				else cost[i]=m;
			}
			Arrays.sort(cost);
			System.out.println(cost[n-1]);
		}
	}	
}

Measured memory_bytes: 26416
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N;

	cin >> N;

	string ans = "No";
	for(int i = 1; i <= 9; i++)
	{
		for(int j = 1; j <= 9; j++)
		{
			if(i * j == N)
			{
				ans = "Yes";
				break;
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}



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

int main(){
	// sengen
	LL d,t,s;
	// nyuryoku
	cin >> d >> t >> s;
	// keisan
	if(s*t >= d){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	// syutsuryoku
}

Measured memory_bytes: 3620
#include <iostream>

int gcd(const int& lhs, const int& rhs)
{
    if (rhs == 0)
    {
        return lhs;
    }
    else
    {
        return gcd(rhs, lhs % rhs);
    }
    
}
int main(){
    int k;
    std::cin >> k;
    int sum = 0;
    for (int a = 1; a <= k; ++a)
    {
        for (int b = 1; b <= k; ++b)
        {
            int tmp;
            if (a > b)
            {
                tmp = gcd(a, b);
            }
            else
            {
                tmp = gcd(b, a);
            }
            
            for (int c = 1; c <= k; ++c)
            {
                if (tmp > c)
                {
                    sum += gcd(tmp, c);
                }
                else
                {
                    sum += gcd(c, tmp);
                }
                
            }
        }
    }
    std::cout << sum << std::endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
typedef pair<int,int> P;
const int MOD = 998244353;
const ll mod = 1e9 + 7;
const int mxN = 1e5 + 9;

int calc(int x, int y){
    if( x%y == 0 ){
        return x/y;
    }
    return x/y + 1;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    int k;
    cin >> n >> k;
    vector<int> v1(n);
    for(auto &c: v1) cin >> c;
    int ans = *max_element( v1.begin(), v1.end() );
    int L = 1; int R = ans-1;
    while( L <= R ){
        int mid = L + (R-L)/2;
        int op = 0;
        for(auto &c: v1) {
            op += calc(c, mid) - 1;
            //cout << c << " " << mid << " ceil() = " << ceil(c/mid) << "\n";
        }
        //cout << mid << " " << op << " " << k << "\n";
        if( op <= k ){
            ans = mid;
            R = mid-1;
        }
        else{
            L = mid+1;
        }
    }
    cout << ans;

}




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

int main(){
  int n;
  while(cin>>n && n){
    int sum=0;
    vector<int> t(n);
    for(int i=0;i<n;i++){
      cin>>t[i];
      sum+=t[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
      if( t[i]*n <= sum )ans++;
    }
    cout<<ans<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 3152
n = int(input())
txy = [0]*n

for i in range(n):
  txy[i] = list(map(int,input().split()))

t_ = 0
x_ = 0
y_ = 0

for i in range(n):
  dx = 0
  dy = 0
  t = txy[i][0]
  x = txy[i][1]
  y = txy[i][2]
  dx = abs(x-x_)
  dy = abs(y-y_)
  d = dx + dy
  if d == abs(t - t_):
    t_ = t
    x_ = x
    y_ = y
  elif d > abs(t - t_):
    print("No")
    exit()
  else:
    if (abs(t - t_)-d)%2 == 0:
      t_ = t
      x_ = x
      y_ = y      
    else:
      print("No")
      exit()
      
print("Yes")

Measured memory_bytes: 85784
#include<stdio.h> 
int buble(int a, int b[200]){
   int j=0, i=0, tmp=0;
  for(i=0;i<a;i++){
 	 for(j=0;j<a;j++){
   		 if(b[i]<b[j]){
  	   	   tmp=b[i];
   		   b[i]=b[j];
   		   b[j]=tmp;    
		  }
 	 }
  }
   return b;
  }
  int arrscaner(int a, int b[200]){
    int i=0;
		for(i=0;i<a;i++){
          scanf("%d",&b[i]);
        }
	return b;
  }

int main(){
  int a=0,bar[200]={};
  int i=0,j=0,k=0;
  int count=0;
  scanf("%d",&a);
  bar[200]=arrscaner(a,bar);   
  bar[200]=buble(a,bar);
  for(i=0;i<a-2;i++){
    for(j=i+1;j<a-1;j++){
      for(k=j+1;k<a;k++){
        if(bar[i]!=bar[j]&&bar[j]!=bar[k]&&
           bar[k]<bar[i]+bar[j]){
          count++;
        }
      }
    }
  }
  printf("%d",count);
  return 0;}


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

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

#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if(a && b && !c || !a && !b && c) cout << "Open" << endl;
  else cout << "Close" << endl;
}

Measured memory_bytes: 3144
'use strict';
console.log(function(args){
  const N = args.trim()|0;
  const dp = Array(N+1).fill(Infinity);
  dp[0] = 0;
  for ( let i = 0; i < N; i++ ) {
    if ( dp[i] < dp[i+1] ) dp[i+1] = dp[i] + 1;
    for ( let j = 6; i+j <= N; j*=6 ) {
      if ( dp[i] < dp[i+j] ) dp[i+j] = dp[i] + 1;
    }
    for ( let j = 9; i+j <= N; j*=9 ) {
      if ( dp[i] < dp[i+j] ) dp[i+j] = dp[i] + 1;
    }
  }
  return dp[N].toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 14796
import java.io.*;
import java.util.*;

public class Main {

    static int n;
    static int[] a;
    static int first;


    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        n = 11;
        a = new int[n];
        first = n - 1;
        int q = in.nextInt();
        while (q-- > 0) {
            boolean act = false;
            for (int i = n - 1; i >= first; i--) {
                if (a[i] != 9 && (i == first || a[i] - a[i - 1] < 1)) {
                    clean(i);
                    act = true;
                    break;
                }
            }
            if (!act) levelup();
        }
        int i = 0;
        while (a[i] == 0) i++;
        for (int j = i; j < n; j++) {
            in.out.print(a[j] + "");
        }
        in.out.close();
    }

    static void levelup() {
        first--;
        a[first] = 1;
        for (int i = first + 1; i < n; i++) {
            a[i] = 0;
        }
    }

    static void clean(int i) {
        a[i] = (a[i] + 1);
        for (int j = i + 1; j < n; j++) {
            a[j] = Math.max(0, (a[j - 1] - 1));
        }
    }
}


class FastScanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    PrintWriter out;

    FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    FastScanner(String in, String out_) throws FileNotFoundException {
        br = new BufferedReader(new FileReader(in));
        out = new PrintWriter(out_);
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}

Measured memory_bytes: 22996
from collections import defaultdict
n = int(input())
L_dict, R_dict = defaultdict(int), defaultdict(int)
i = 0
for ipt in input().split():
    L_dict[i + int(ipt)] += 1
    R_dict[i - int(ipt)] += 1
    i += 1
cnt = 0
for Lk, Lv in L_dict.items():
    try:
        cnt += R_dict[Lk] * Lv
    except KeyError:
        pass
print(cnt)

Measured memory_bytes: 66316
n,m=(int(x) for x in input().split())
a=[[0 for i in range(m)] for j in range(n)]
b=[0 for i in range(m)]
c=[0 for i in range(n)]

for i in range(n):
  a[i][:]=(int(x) for x in input().split())

for i in range(m):
  b[i]=int(input())

for i in range(n):
  for j in range(m):
    c[i]+=a[i][j]*b[j]

for i in range(n):
  print(c[i])


Measured memory_bytes: 5788
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int sub(int i,int j){
  int b=1;
  if(j==3)return 0;
  for(int a=1;a<=i;a++){
    b*2;
  }
  return 1/b+(i+1)*sub(i+1,j+1);
}
int main() {
  int a,b;
  int c,d=1;
  cin>>a>>b;
  c=a-b;
  rep(i,b)d*=2;
  cout<<b*d*1900+c*d*100;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	int a[5];
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	for(int q=0;q<5;q++){
		if(a[q]==0) cout<<q+1;
	}
 } 

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	int x, a;
	cin >> x >> a;
	if (x < a)
		cout << "0" << endl;
	else
		cout << "10" << endl;
}

Measured memory_bytes: 4992
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] ren = new int[N];
        int sum = 0;
        for (int i = 0; i < N; i++) {
            ren[i] = sc.nextInt();
            sum+=ren[i];
        }
        int longest = 0;
        for (int i = 0; i < N; i++) {
            if(longest<ren[i])longest=ren[i];
        }
        if(sum-longest>longest)
        System.out.println("Yes");
        else
        System.out.println("No");
        
    }
}

Measured memory_bytes: 21844
import numpy as np
import math

class GradientDescent:
    def __init__(self, f, df, eta=0.01, eps=1e-8):
        self.f = f    # 最適化する関数
        self.df = df    # 関数の勾配（１次導関数）
        self.eta = eta    # 学習率
        self.eps = eps    # 学習のストップ判定に用いる定数
        self.path = None    # 学習の経過、初期値は空

    def solve(self, x, count_max):
        path = []
        grad = self.df(x)    # 勾配
        path.append(x)
        count = 0
        # 多変数の場合のノルムの大きさとself.epsを比較
        # self.epsの二乗より大きい場合、xの更新を続ける
        while (grad**2).sum() > self.eps**2 and count < count_max:
            x = x - self.eta * grad
            grad = self.df(x)
            # print(x, grad)
            path.append(x)
            count += 1
        self.path_ = np.array(path)   # 学習の経過
        self.x_ = x    # 最適化された変数の値
        self.opt_ = f(x)    # 最適化後の f(x)の値
        self.grad_ = grad    # 最適化後の勾配
        
def f(xy):
    x = xy[0]
    y = xy[1]
    ret = 0.
    for i in range(n):
        dx, dy = x - p[i][0], y - p[i][1]
        ret = max(ret, dx**2 + dy**2)
    return math.sqrt(ret)

def df(xy):
    mu = 1e-9
    x = xy[0]
    y = xy[1]
    return np.array([(f([x + mu, y]) - f([x - mu, y])) / (2. * mu), (f([x, y + mu]) - f([x, y - mu])) / (2. * mu)])

n = int(input())
p = []
for i in range(n):
    xy = list(map(float, input().split()))
    p.append(xy)

xy = np.array([500., 500.])
for e_eta in range(2, -9, -1):
    gd = GradientDescent(f, df, eta=10**e_eta)
    initial = np.array(xy)
    gd.solve(initial, 200)
    xy = gd.x_
    # print(xy)

print(gd.opt_)

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

int check(int a,int b,int x){
    return a*x/b-a*(x/b);
}

main (void){
    int x;
    cin>>x;
    int count=0;
    int check=100;
    while(check<x){
        check=check*1.01;
        count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n; cin >> n;
  ll ans = 0, minus = 0;
  vector<ll> a(n);
  vector<P> v(n);
  rep(i, n) cin >> a[i];
  rep(i, n) {
    ll b; cin >> b;
    if (a[i] < b) {
      minus += b - a[i];
      ans++;
    }
    v[i] = make_pair(b - a[i], a[i]);
  }
  sort(v);

  for (int i = 0; i < n && v[i].first < 0 && minus > 0; i++) {
    ll ai = v[i].second;
    ll bi = v[i].first + ai;
    debug2(ai, bi);
    minus -= ai - bi;
    ans++;
  }

  if (minus > 0) outl(-1);
  else outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) {
        cin >> s[i];
    }
    int ans = 0;
    rep(is, 1<<h) rep(js, 1<<w) {
        int cnt = 0;
        rep(i,h)rep(j,w) {
            if (is>>i&1) continue;
            if (js>>j&1) continue;
            if (s[i][j] == '#') cnt++;
        }
        if (cnt == k) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-02 16:57:06
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-02 17:20:04
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> pii;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
ll N,A,B;
using namespace IO;
int main()
{
    read(N),read(A),read(B);
    if(A<B) swap(A,B);
    ll ans1,ans2,ans3;
    ans1=ans2=ans3=2000000000000000000ll;
    if((A-B)%2==0) ans1=(A-B)/2;
    else{
    ans2=min(((A+B)-1)/2,max(A-1,B-1));
    ans3=min(((A-B)-1)/2+N-A+1,max(N-A,N-B));
    }
    
    cout<<min(min(ans1,ans2),ans3);
}

Measured memory_bytes: 256
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

int main()
{
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	int N, rates[9] = {0}, a;
	cin >> N;
	
	REP(i, N)
	{
		cin >> a;

		if (a >= 3200) rates[8]++;
		else rates[a / 400]++;
	}

	int ret = 0, empty = 0;
	REP(i, 8)
	{
		if (rates[i] == 0) empty++;
		else ret++;
	}

	if (ret == 0)
	{
		if (rates[8] >= 8) cout << "1 8\n";
		cout << 1 << " " << rates[8] << "\n";
	} else if (rates[8] > 0)
	{
		cout << ret << " " << ret + rates[8] << "\n";
		
	}
	else
	{
		cout << ret << " " << ret << "\n";
	}

	return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

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

//素数判定 O(√n)
bool is_prime(int64_t n){
  for(int64_t i = 2; i*i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

//約数の列挙 O(√n)
vector<int64_t> dividor(int64_t n){
  vector<int64_t> res;
  for(int64_t i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(i);
    }
  }
  return res;
}

//素因数分解 O(√n)
map<int64_t, int64_t> prime_factor(int64_t n){
  map<int64_t, int64_t> res;
  for(int64_t i=2; i*i<=n; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};



int main(){
  int n; cin >> n;
  vector<int64_t> A(n);
  rep(i, n) cin >> A[i];
  Sort(A);
  Reve(A);
  int64_t ans1=0, ans2=0; 
  for(int i=0; i<n-1; i++){
    if(ans1!=0&&ans2!=0) break;
    else if(ans1==0){
      if(A[i]==A[i+1]){
        ans1 = A[i]; i++;
      } 
    }
     else if(ans2==0){
      if(A[i]==A[i+1]){
        ans2 = A[i]; i++;
      } 
    }
  }
  cout << ans1*ans2 << endl;   
}
  
  





Measured memory_bytes: 1024