akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

// Vectors
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    cin >> x;
    int ans;

    if (x >= 400 && x <= 599) {
        ans = 8;
    } else if (x >= 600 && x <= 799) {
        ans = 7;
    } else if (x >= 800 && x <= 999) {
        ans = 6;
    } else if (x >= 1000 && x <= 1199) {
        ans = 5;
    } else if (x >= 1200 && x <= 1399) {
        ans = 4;
    } else if (x >= 1400 && x <= 1599) {
        ans = 3;
    } else if (x >= 1600 && x <= 1799) {
        ans = 2;
    } else {
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
import sys

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

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

# l.sort()

# max_length = 0
# for item in l[n-1:n-k-1:-1]:
#     max_length += item

# print("{}".format(max_length))

l.sort(reverse=True)

max_length = 0
for i in range(k):
    max_length += l[i]

print("{}".format(max_length))

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

using namespace std;

int main(void) {
	int min = 1000, max = 0, n, t;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t;
		if (t < min) min = t;
		if (t > max) max = t;
	}

	cout << max - min << endl;
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector <int> a(N);
    for(int i=0;i<N;i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int A=0,B=0;
    for(int i=0;i<N;i++){
        if(i%2==0) A+=a.at(i);
        else B+=a.at(i);
    }
    cout << A-B <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    long k,n,i;
    scanf("%ld%ld",&k,&n);
    long a[n];
    for(i=0;i<n;i++) scanf("%ld",&a[i]);
    long max = a[0]+k-a[n-1];
    for(i=0;i<n-1;i++){
        if(max<a[i+1]-a[i]) max=a[i+1]-a[i];
    }
    printf("%ld",k-max);
    return 0;
}

Measured memory_bytes: 1664
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var constants = ReadInts();
        var N = constants[0];
        var M = constants[1];
        var C = constants[2];

        var B = ReadInts();

        var ans = 0;

        for(var i = 0; i < N; i++)
        {
            var A = ReadInts();

            if (A.Select((a, idx) => a * B[idx]).Sum() + C > 0) ans++;
        }

        Console.WriteLine(ans);
    }

    public static string Read() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read()); }

    public static string[] Reads() { return Console.ReadLine().Split(' '); }
    public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); }
    public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); }
    public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
ll gcd(ll a, ll b){
  if(b==0) return a;
  else gcd(b,a%b);
}
ll lcm(ll a, ll b){
  return a/gcd(a,b)*b;
}

int main(){
  int n;
  cin >> n;
  vector<int>vec(4);
  rep(i,n){
    char c;
    cin >> c;
    if(c=='G')vec[0]++;
    if(c=='W')vec[1]++;
    if(c=='P')vec[2]++;
    if(c=='Y')vec[3]++;
  }
  int sum=0;
  rep(i,4){
    if(vec[i])sum++;
  }
  if(sum==3) cout <<"Three" << endl;
  if(sum==4) cout << "Four" << endl;
 
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  long long X=1;
  vector<long long>A(N);
  for (int i=0; i<N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  if (A.at(0) == 0){
    cout << 0 << endl;
    return 0;
  }
  for (int i=0; i<N; i++){
    if(A.at(i) <= 1000000000000000000 / X){
      X *= A.at(i);
    }else {
      cout << -1 <<endl;
      return 0;
    }
  }
  cout << X << endl;
}

Measured memory_bytes: 4044
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    println!("{}",(a+b)%24)
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
#define find(v,n) find(v.begin(),v.end(),n)
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,n) lower_bound(v.begin(),v.end(),n)-v.begin()
#define ub(v,n) upper_bound(v.begin(),v.end(),n)-v.begin()
#define mod 1000000007
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
/*bool fact(l n)
{
	vector<l> v;
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(i%2==1||(n/i)%2==1)
			{
				return true;
			}
		}
	}
	return false;
}*/
l power(l a,l b)
{
	l ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a);
		}
		b>>=1;
		a=(a*a);
	}
	return ans;
}//prefixsums
void frooty()
{
	l r,c,k;
	cin>>r>>c>>k;
	char a[r][c];
	l count[r+c];
	mem(count,0);
	for(l i=0;i<r;i++)
	{
		for(l j=0;j<c;j++)
			cin>>a[i][j];
	}
	l ans=0;
	for(l mask1=0;mask1<(1<<r);mask1++)
	{
		for(l mask2=0;mask2<(1<<c);mask2++)
		{
			l bl=0;
			for(l i=0;i<r;i++)
			{
				for(l j=0;j<c;j++)
				{
					if((mask1)&(1<<i)&&(mask2)&(1<<j)&&a[i][j]=='#')
						bl+=1;
				}
			}
			if(bl==k)
				ans+=1;
		}
	}
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
//	cin>>q;
	while(q--)
	{
		frooty();
	}
}

Measured memory_bytes: 3660
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(s: String);

    let mut sum = 0;
    for ss in s.chars() {
        sum += ss as i32 - 48;
    }

    println!("{}", if sum % 9 == 0 { "Yes" } else { "No" });
}


Measured memory_bytes: 2368
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;

const int N = 5005;
int n, m, p, vis[N];
const LL INF = 1LL << 40;
vector<PII> g[N];

void dfs(int u) {
  vis[u] = 1;
  for (auto pr: g[u]) {
    int v = pr.first;
    if (vis[v]) continue;
    dfs(v);
  }
}

LL spfa(int src, int tag) {
  vector<LL> dis(n + 1, -INF), inq(n + 1, 0), cnt(n + 1, 0);
  queue<int> qu;
  qu.push(src), inq[src] = 1, dis[src] = 0;
  while (!qu.empty()) {
    int u = qu.front();
    qu.pop(), inq[u] = 0, cnt[u]++;
    if (cnt[u] >= n) {
      dis[u] = INT_MAX;
      continue;
    }
    for (auto &pr: g[u]) {
      int v, w;
      tie(v, w) = pr;
      if (dis[v] < dis[u] + w) {
        dis[v] = dis[u] + w;
        if (!inq[v]) inq[v] = 1, qu.push(v);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i] && dis[i] >= INT_MAX) dfs(i);
  }
  // for (int i = 1; i <= n; i++) printf("%lld ", dis[i]);
  // puts("");
  return dis[tag];
}

int main() {
  cin >> n >> m >> p;
  FI(i,1,m) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    g[u].emplace_back(v, w - p);
  }
  LL dis = spfa(1, n);
  if (dis >= INF || vis[n]) return puts("-1"), 0;
  cout << max(dis, 0LL) << endl;
}


Measured memory_bytes: 640
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b,k,i,s=0,c;
    cin>>a>>b>>c>>k;
    if(k<=a){
    	cout<<k<<'\n';
    	return 0;
	}
	else{
		s=s+a;
		k=k-a;
		if(k<=b){
			cout<<s<<'\n';
		}
		else{
			k=k-b;
			cout<<(s-k)<<'\n';
		}
	}
}

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

int main()
{
  int n;
  cin >> n;
  
  vector<int> l, r;
  //bool f = true; //true:左から読む（右末尾に追加）
  
  rep(i, n)
  {
    int a;
    cin >> a;
    
    if(i%2 == 0)
    {
      l.push_back(a);
    }
    else
    {
      r.push_back(a);
    }
  }
  
  if(n%2 == 1)
  {
    reverse(l.begin(), l.end());
    rep(i, l.size()) cout << ((i != 0)? " " : "") << l[i];
    rep(i, r.size()) cout << " " << r[i];
  }
  else
  {
    reverse(r.begin(), r.end());
    rep(i, r.size()) cout << ((i != 0)? " " : "") << r[i];
    rep(i, l.size()) cout << " " << l[i];
  }
  cout << endl;
  
  
  return 0;
}

Measured memory_bytes: 3188
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;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            int K = in.Int();
            int[] A = in.Int(N);
            Arrays.sort(A);
            int ans = 0;
            for (int i = 0; i < K; i++) {
                ans += A[i];
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

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

        public int[] Int(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Int();
            }
            return a;
        }

    }
}



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

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

int main() {
    int n;
    cin >> n;
    ll ans = 1e+16, sum_snuke = 0, sum_raccoon = 0;

    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        sum_raccoon += a[i];
    }

    for(int i =0;i<n-1;i++){
        sum_snuke += a[i];
        sum_raccoon -= a[i];
        ans = min(abs(sum_snuke - sum_raccoon),ans);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 4840
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 200005;
const int MM = 1000000007;

struct BIT{
	int t[MX];
	void update(int x, int v){ while(x<MX) t[x] = max(t[x], v), x += x&-x; }
	int read(int x){
		int r = 0;
		while(x) r = max(r, t[x]), x -= x&-x;
		return r;
	}
} tree;

pii s, e;
int N;
pii D[MX];

int flip(int &x){ x = (int)1e8 - x; }

int main()
{
	int ch = 0;
	vector<int> Y;
	scanf("%d%d%d%d", &s.first, &s.second, &e.first, &e.second);
	if( s.first > e.first ) swap(s, e);
	if( s.second > e.second ){
		ch = 1;
		flip(s.second); flip(e.second);
	}
	Y.push_back(s.second);
	Y.push_back(e.second);
	scanf("%d", &N);
	for(int i = 1; i <= N; i++){
		scanf("%d%d", &D[i].first, &D[i].second);
		if( ch ) flip(D[i].second);
		Y.push_back(D[i].second);
	}
	sort(Y.begin(), Y.end());
	auto V = [&](int x){ return upper_bound(Y.begin(), Y.end(), x) - Y.begin(); };
	sort(D+1, D+N+1);

	int mx = 1;
	tree.update(V(s.second), 1);
	for(int i = 1; i <= N; i++){
		if( D[i].first < s.first || D[i].first > e.first) continue;
		int t = tree.read(V(D[i].second));
		if( t ) tree.update(V(D[i].second), t+1);

		mx = max(mx, tree.read(V(e.second)));
	} mx--;
	int d = min(e.first - s.first, e.second - s.second);
	double tmp = (PI*5 - 20) * mx;
	if( mx == d+1 ) tmp += PI*5;
	tmp += (e.first + e.second - s.first - s.second) * 100.0;
	printf("%.20lf\n", tmp);
}


Measured memory_bytes: 3444
///////////////////////////////////////////////////
/* __                                       __   */
/*|  |--.-----.---.-.----.----.-----.-----.|  |_ */
/*|  _  |  -__|  _  |  __|  __|  -__|  _  ||   _|*/
/*|_____|_____|___._|____|____|_____|   __||____|*/
/*                                  |__|         */
///////////////////////////////////////////////////
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
#define INF 1000000000000
#define MOD 10000007
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

lint H,W;
 cin >> H >> W;
 
 if(H == 1 || W == 1){
 cout << 1 << endl;
 } else {
 cout << (H * W + 1) / 2 << endl;
 }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    string s;
    cin >> s;
    int n = s.size();

    if (s.front() == 'A')
    {
        int countC = 0;
        int index = 0;
        rem(i, 2, n - 1)
        {
            if (s[i] == 'C')
            {
                index = i;
                countC++;
            }
        }

        if (countC == 1)
        {
            bool flag = true;
            rem(i, 1, n)
            {
                if (i == index)
                    continue;
                if (!islower(s[i]))
                {
                    flag = false;
                    break;
                }
            }
            if (flag)
            {
                cout << "AC"
                     << "\n";
                return 0;
            }
        }
    }

    cout << "WA"
         << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include<math.h>
int main(){
    char palavra[1001];
    scanf("%s", palavra);
    char nova[10001];
    int tam= strlen(palavra);
    if(palavra[tam-1]=='s')
        printf("%ses\n", palavra);
    else
        printf("%ss\n", palavra);
    return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>
int main()
{
	int a[5],i;
	for(i=0;i<5;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<5;i++)
	{
		if(a[i]==0) 
		{
			printf("%d",i+1);
			break;
		}
	}
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, W, w, v, dp[101][100001];
  memset(dp, -1, sizeof(int) * 101 * 100001);
  dp[0][0] = 0;
  cin >> n >> W;
  for(int i = 0; i < n; i++) {
    cin >> w >> v;
    for(int j = 0; j < 100001; j++) {
      if(dp[i][j] != -1) {
        if(dp[i][j] + w <= W) { dp[i + 1][j + v] = dp[i][j] + w; }
        if(dp[i + 1][j] != -1)
          dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
        else
          dp[i + 1][j] = dp[i][j];
      }
    }
  }
  int o;
  for(int i = 0; i < 100001; i++)
    if(dp[n][i] != -1) o = i;
  cout << o << '\n';
}

Measured memory_bytes: 39680
// IOI 2021
 
#include <bits/stdc++.h>
using namespace std;
 
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9, MOD = 1e6 + 7;
 
/////////////////////////////////////////////////////////////////////
 
const int N = 1e5 + 5;

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

	string s; cin >> s;
	int cnt = 0;
	for (int i = 1; i < sz(s); i++) if (s[i] != s[i - 1]) cnt++;
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, x, a[100005] = {};
    ll z = 0;
    cin >> n >> x;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        if (a[i] + a[i - 1] > x) z += a[i] - x + a[i - 1], a[i] = x - a[i - 1];
    }
    cout << z;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
int a[1000005],p[1000006],b[1000006],d[1000006];
vector<int> c[1000006];
int main(){
    int n,t=0;cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];t=__gcd(t,a[i]);b[a[i]]=1;
    }
    if(t>1){
        cout<<"not coprime"<<endl;return 0;
    }
    for(int i=2;i<=1000000;i++){
        if(p[i]) continue;
        for(int j=i;j<=1000000;j+=i){
            p[j]=1;
            if(b[j]) c[j].push_back(i);
        }
    }
    for(int i=1;i<=n;i++){
        int tag=0;
        for(auto j:c[a[i]]){
            if(d[j]){tag=1;break;}
            d[j]++;
        }
        if(tag){
            cout<<"setwise coprime"<<endl;return 0;
        }
    }
    cout<<"pairwise coprime"<<endl;
} 

Measured memory_bytes: 70684
a, b = map(int, input().split()) 
A = list(map(int, input().split()))
s=A[0]+a-A[b-1]
for i in range(0,b-1):
  if (A[i+1]-A[i])>s:
    s=A[i+1]-A[i]
print(a-s)

Measured memory_bytes: 25840
import math

def resolve():
    A, B, H, M = map(int, input().split())

    h_rad = math.radians(30*H + M / 2)
    h_y = A * math.cos(h_rad)
    h_x = A * math.sin(h_rad)
    m_rad = math.radians(6*M)
    m_y = B * math.cos(m_rad)
    m_x = B * math.sin(m_rad)

    ans = math.sqrt((h_y - m_y)**2 + (h_x - m_x)**2)
    print(ans)

if __name__ == "__main__":
    resolve()

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

int main(void) {
    int a, b, n, s;
    
    while(cin >> a >> b >> n) {
        s = 0;
        a = a % b;
        
        int i = 0;
        while(i < n) {
            if(a == 0)   break;
            s += (a * 10) / b;
            a = (a * 10) % b;
            ++i;
        }

        cout << s << endl;
    }
    
    return 0;
}


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

const int N = (int) 1e3 + 5;
const long long INF = (long long) 1e18;

int n, m;
long long cake[N][3];

int main() {
	//freopen(".inp", "r", stdin); freopen(".out", "w", stdout);
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> cake[i][0] >> cake[i][1] >> cake[i][2];
	long long ans = -INF;
	for (int mask = 0; mask < 8; mask++) {
		vector <long long> sum; sum.clear();
		for (int i = 1; i <= n; i++) {
			long long res = 0;
			for (int j = 0; j < 3; j++) 
				if ((mask >> j) & 1) res += cake[i][j];
				else res -= cake[i][j];
			sum.push_back(res);
		}
		sort(sum.begin(), sum.end(), greater <long long> ());
		long long temp = 0;
		for (int i = 0; i < m; i++) temp += sum[i];
		ans = max(ans, temp);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  k--;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}

int main(void){
  ll n, m;
  cin >> n >> m;

  vector<ll> divisor(0);
  for (int i = 2; i*i <= m; i++){
    if (m % i == 0){
      int t = 0;
      while (m % i == 0){
        m /= i;
        t++;
      }
      divisor.push_back(t);
    }
  }
  if (m != 1){
    divisor.push_back(1);
  }


  ll ans = 1;
  for (int i = 0; i < divisor.size(); i++){
    ans = ans * nck(n + divisor[i] - 1, divisor[i]) % MOD;
  }
  cout << ans << endl;
  

  return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		var list = new List<Tuple<long, long>>(N);
		for(int i = 0; i < N; i++)
			list.Add(Tuple.Create(GetLong(), GetLong()));
		list.Sort((x, y) => (int)(y.Item1 - x.Item1));

		Console.WriteLine(list[0].Item1 + list[0].Item2);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 20804
// D.

#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	int h, w, k;
	cin >> h >> w >> k;
	int dp[102][8] = {};
	dp[0][0] = 1;
	for (int i = 0; i < h; ++i) {
		for (int b = 0; b < (1 << (w - 1)); ++b) {
			bool skip = false;
			for (int j = 3; j <= b; j *= 2) {
				if ((b & j) == j) {
					skip = true;
				}
			}
			if (!skip) {
				int prev_dir = 0;
				for (int j = 0; j < w; ++j) {
					int dir = (b & (1 << j)) != 0;
					dp[i + 1][j + dir - prev_dir] += dp[i][j];
					dp[i + 1][j + dir - prev_dir] %= 1000000007;
					prev_dir = dir;
				}
			}
		}
	}
	int ans = dp[h][k - 1];
	cout << ans << endl;
	return 0;
}


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

int main() {
    // エラトステネスのふるい
    int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
    }

    // 2017-like 数かどうか
    vector<int> a(MAX, 0);
    for (int i = 0; i < MAX; ++i) {
        if (i % 2 == 0) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }

    // 累積和
    vector<int> s(MAX+1, 0);
    for (int i = 0; i < MAX; ++i) s[i+1] = s[i] + a[i];

    // クエリ処理
    int Q; cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int l, r;
        cin >> l >> r;
        ++r;

        cout << s[r] - s[l] << endl;
    }
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){

  vector<int>prime;
  bool flag[100000];
  memset(flag,true,sizeof(flag));
  for(int i=2;i<100000;i++)
    {
      if(flag[i])
	{
	  prime.push_back(i);
	  for(int j=i+i;j<100000;j+=i)
	    flag[j]=false;
	}
    }

  int n;
  for(;cin>>n;)
    {
      vector<int>::iterator it1=lower_bound(prime.begin(),prime.end(),n);
      it1--;
      vector<int>::iterator it2=upper_bound(prime.begin(),prime.end(),n);
      cout<<*(it1)<<" "<<*(it2)<<endl;
    }

}

Measured memory_bytes: 1424
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    ll n,a,b;cin>>n>>a>>b;
    if((b-a)%2==0){
        cout<<(b-a)/2<<endl;
        return 0;
    }
    ll bb=b-1;
    ll aa=n-a;
    ll t1=(a-1+1)+(b-1-(a-1+1))/2;
    ll t2=(n-b+1)+(n-a-(n-b+1))/2;
    cout<<min({bb,aa,t1,t2})<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] T = new int[n];
        for(int i = 0; i < n ; i ++){
            T[i] = sc.nextInt();
        }

        int q = sc.nextInt();
        for(int i = 0; i < q ; i ++){
            int v = sc.nextInt();
            boolean flag = solve(T,0,v);
            System.out.println(flag ? "yes" : "no");
        }
    }


    static boolean solve(int[] T,int k,int m){
        if(m == 0) return true;
        if(m < 0 || k >= T.length) return false;
        return solve(T,k + 1,m - T[k]) || solve(T,k + 1,m);
    }
}



Measured memory_bytes: 26916
#include <stdio.h>
#include <stdlib.h>
int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  ((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d)?puts("Yes"):puts("No");
  return 0;
}

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

using namespace std;
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    return GCD(b, a % b);
}

int main() {
    long long A, B; cin >> A >> B;
    cout << A * B / GCD(A, B) << endl;
}


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

int main() {
  double N,K;
  cin>>N>>K;
  double ans;
  for(int i=1;i<=N;i++){//最初に出た目をiとする
    int p=i;//point
    double m=1/N;//確率
    while(p<K){
      p *= 2;
      m /= 2;
    }
    ans += m;
  }
  cout<<setprecision(16)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <sstream>

/*

bool isOK(int index, int key) {
	if (a[index] >= key) return true;
	else return false;
}
int binary_search(int key) {
	int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;

		if (isOK(mid, key)) ok = mid;
		else ng = mid;
	}
	return ok;
}
*/

//vector<vector<ll> > data(3, vector<ll>(4));
//vector<ll> data(N);
//v.erase(remove(v.begin(), v.end(), value_to_remove), v.end());
//int num = atoi(numStr.c_str());
//str s = to_string(i);
//int i = c - '0'
//sort(data.begin(), data.end());
//reverse(data.begin(), data.end());
//data.erase(unique(data.begin(), data.end()), data.end()); //重複なし
//str.substr(n)//n番以降スライス
//str.substr(n,m)//n番以降m文字スライス
//str.erase(n)//n番以降削除
//str.erase(n,m)//n番以降m文字削除
//str.find(str_to_find)//位置 or string::npos
//cout << fixed << setprecision(15) << n;
//while (cin >> c){if (c == EOF) break;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=ll(a);i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define PB push_back
#define SIZE(x) ll(x.size())
#define ALL(x) x.begin(),x.end()
#define INF 1000000000000
#define MOD 1000000007
#define PI 3.14159265358979323846

using namespace std;
typedef pair<ll, ll> P;

int main() {
	string S;
	cin >> S;
	ll SUM = 0;
	ll n = 0;
	istringstream ss;

	REP(bit, (ll(1) << (SIZE(S) - 1))) {
		string s = to_string(S[0]-'0');
		ll sum = 0;
		REP(i, SIZE(S) - 1) {
			if (bit & (ll(1) << i)) {
				ss = istringstream(s);
				ss >> n;
				sum += n;
				s = "";
			}
			s += to_string(S[i + 1] - '0');
		}
		ss = istringstream(s);
		ss >> n;
		sum += n;
		SUM += sum;
	}
	cout << SUM << endl;
	
}



Measured memory_bytes: 3672
N = int(input())
memo = [{} for _ in range(N+1)]
def isOk(last4):
  for i in range(4):
    t = list(last4)
    if i < 3:
      t[i],t[i+1] = t[i+1],t[i]
    if "".join(t).count("AGC") > 0:
      return False
  return True
def dfs(cur, last3):
  if last3 in memo[cur]:
    return memo[cur][last3]
  if cur == N:
    return 1
  ret = 0
  for c in "ACGT":
    if isOk(last3+c):
      ret = (dfs(cur+1,last3[1:]+c)+ret)%(10**9+7)
  memo[cur][last3] = ret
  return ret

print(dfs(0,"TTT"))
    



Measured memory_bytes: 3876
#include<stdio.h>
int main(void)
{
	int i=0;
	int cnt=0;
	char S[101];
	scanf("%s",S);
	do
	{
		if(i%2==0)
		{
			if(S[i]=='R' || S[i]=='U' || S[i]=='D')
			cnt=cnt+0;
			else
			cnt++;
		}
		else
		{
			if(S[i]=='L' || S[i]=='U' || S[i]=='D')
			cnt=cnt+0;
			else
			cnt++;
		}
		i++;
	}while(S[i]!='\0');
	if(cnt==0)
	printf("Yes");
	else
	printf("No");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int q,p,t,ans=1,i=2;
  cin>>q>>p;t=p;
  p/=__gcd(q,p);
  for(;i*i<=t;i++)
    if(p%i==0){
      if(ans%i)ans*=i;
      p/=i--;
    }
  cout<<ans*p<<endl;
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, M, C;
    cin >> N >> M >> C;

    vector<int> B(M);
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }   

    int A[N][M];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    int ans = 0;

    for (int i = 0; i < N; i++) {
        int pro = 0;
        for (int j = 0; j < M; j++) {
            pro += A[i][j] * B[j];
        }
        pro += C;
        if (pro > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
while 1:
    b, r, g, c, s, t = map(int, input().split())
    if [b, r, g, c, s, t] == [0, 0, 0, 0, 0, 0]:
        break

    medal = 100
    bonus = b * 5 + r * 3
    normal = t - bonus - s
    medal = medal + b * 15 + r * 15 + bonus * 15 + g * 7 + c * 2
    medal = medal - normal * 3 - bonus * 2

    print(medal)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a <= b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first; printf("\n"); }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first; printf(" "); put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first; printf("\n"); putn(rest...); }

void dfs(vector<vector<int>>& path, ll temp);

int main() {
	int n,q;
	cin >> n >> q;
	vector<ll> a(n - 1), b(n - 1), p(q), x(q);
	vector<vector<int>> path(n);
	vector<ll> cnt(n, 0);
	vector<ll> temp(n, 0);
	vector<bool> vi(n, false);
	REP(i, n-1) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		path[a[i]].push_back(b[i]);
		path[b[i]].push_back(a[i]);
	}
	REP(i, q) {
		cin >> p[i] >> x[i];
		p[i]--;
		cnt[p[i]] += x[i];
	}
	queue<int> qu;
	qu.push(0);
	vi[0] = true;
	while (!qu.empty()) {
		int p = qu.front();
		qu.pop();
		REP(i, path[p].size()) {
			if (!vi[path[p][i]]) {
				vi [path[p][i]] = true;
				cnt[path[p][i]] += cnt[p];
				qu.push(path[p][i]);
			}
			
		}
	}
	put(cnt);
	return 0;
}


Measured memory_bytes: 24180
/*
** author:mahmoud magdy
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
int n , m ,Mod=1e9+7;
char s[1005][1005];
ll dp[1005][1005];
ll solve(int i , int j){
if(i>=n||j>=m||s[i][j]=='#')
    return 0;
if(i==n-1&&j==m-1){
    return 1;
}
if(dp[i][j]!=-1)
    return dp[i][j];
return dp[i][j]=((solve(i,j+1)%Mod)+(solve(i+1,j)%Mod))%Mod;

}
int main()
{
    fast();
   n=D(),m=D();
    for(int i=0;i<n;++i){
      for(int j =0;j<m;++j){
        cin>>s[i][j];
      }
   }
   memset(dp,-1,sizeof dp);
   cout<<solve(0,0)<<endl;

}


Measured memory_bytes: 12580
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/

int main(){
  int N;cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  sort(rall(A));
  queue<ll> que;
  ll ans = 0;
  rep(i,N){
    if(i == 0){
      que.push(A[i]);
      continue;
    }else{
      ans+=que.front();
      que.pop();
      que.push(A[i]);
      que.push(A[i]);
    }
  }
  cout << ans << endl; 
}

Measured memory_bytes: 6348
use std::io::prelude::*;
use std::str::FromStr;
pub struct Scanner<R: Read>(R);
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self(reader)
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| (b as char).is_whitespace())
            .take_while(|&b| !(b as char).is_whitespace())
            .collect::<Vec<u8>>();
        unsafe { std::str::from_utf8_unchecked(token.as_slice()) }
            .parse()
            .ok()
            .expect("Can't parse it.")
    }
    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut sc = Scanner::new(stdin.lock());
    let mut out = std::io::BufWriter::new(stdout.lock());
    solve(&mut sc, &mut out);
    out.flush().ok().unwrap();
}
fn solve(sc: &mut Scanner<std::io::StdinLock>, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let (n, a, b): (u32, u32, u32) = (sc.read(), sc.read(), sc.read());

    let ans: u32 = (1..=n)
        .filter(|s| {
            let sum: u32 = s.to_string().chars().map(|c| (c as u8 - b'0') as u32).sum();
            sum >= a && sum <= b
        })
        .sum();

    println!("{}", ans);
}


Measured memory_bytes: 2184
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
bool my_compare(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    rep(i,n) sum+=i;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <utility> 

int main()
{
	int M, N;
    std::cin >> M >> N;
    
	std::map<int, std::map<int, int>> ken_shi_y;
	for(int i=0; i<N; i++)
    {
    	int P, Y;
    	std::cin >> P>> Y;
		ken_shi_y[P][Y] = i;
    }
  		
  	std::vector<std::pair<int,int>> result(N);
  	for(const auto& ken : ken_shi_y)
    {
      int c=1;
      for(const auto& e : ken.second)
      {
 		result[e.second] = std::pair<int,int>(ken.first, c);
        c++;
      }
    }
  
  	for(const auto& e : result)
    {
		std::cout.fill('0');
		std::cout.width(6);      
	    std::cout << e.first;
		std::cout.fill('0');
		std::cout.width(6);      
      	std::cout << e.second << std::endl;
    }
  
	return 0;
}


Measured memory_bytes: 15932
#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#define il inline
#define vd void
#define rg register
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
int n,a[100005];
int main(){
    n=rd();
    rep(i,1,n) a[i]=rd();
    sort(a+1,a+n+1);
    int i=n,j=1;
    while(a[i-1]>=j+1) --i,++j;
    int k=i;
    while(a[k-1]==j) --k;
    puts(((i-k)&1)||((a[i]-j)&1)?"First":"Second");
    return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
    while(!isdigit(c=gc())&&c!='-');
    int f=c=='-'?c=gc(),1:0,x=c^48;
    while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
    return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

Measured memory_bytes: 2688
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define REP(i, n) for(int i = 0; (i) < (n); ++(i))
#define FOR(i, n) for(int i = 1; (i) <= (n); ++(i))
#define dump(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9 + 7;
// const lint LINF = 1e18;
const double eps = 0.000000001;  //もとの値の10^(-16)まで

using namespace std;

// typedef pair<int, int> P;
// priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
// cout << fixed << setprecision(10) << ans << endl;

int n, k;
int h[400];
int dp[400][400][400];  // i列目、j回、その高さ のとき、何回で塗り終わるか

signed main() {
  cin >> n >> k;
  h[0] = 0;
  REP(i, n) {
    cin >> h[i + 1];
  }
  h[n + 1] = 0;
  REP(i, n + 1) {
    REP(j, n + 1) {
      REP(l, n + 1) {
        dp[i][j][l] = INF;
      }
    }
  }
  dp[0][0][0] = 0;
  REP(i, n + 1) {
    REP(j, n + 1) {
      REP(l, n + 1) {
        dp[i + 1][j][i + 1] = min(dp[i + 1][j][i + 1], dp[i][j][l] + max((int)0,h[i + 1] - h[l]));
        dp[i + 1][j + 1][l] = min(dp[i + 1][j + 1][l], dp[i][j][l]);
      }
    }
  }
  int ans = INF;
  REP(j, k + 1) {
    REP(l, n + 1) {
      ans = min(ans, dp[n][j][l]);
    }
  }

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

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

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

int N;
int a[2 * ten(5) + 1];
int b[2 * ten(5) + 1];
int c[2 * ten(5) + 1];
int adp[2 * ten(5) + 1];
int bdp[2 * ten(5) + 1];
int cdp[2 * ten(5) + 1];

int main()
{
    cin >> N;
    REP(i, N) cin >> a[i] >> b[i] >> c[i];

    int before = -1;
    REP(i, N) {
        if (i == 0) {
            adp[i] = a[i];
            bdp[i] = b[i];
            cdp[i] = c[i];
            continue;
        }
        adp[i] = max(bdp[i-1], cdp[i-1]) + a[i];
        bdp[i] = max(cdp[i-1], adp[i-1]) + b[i];
        cdp[i] = max(adp[i-1], bdp[i-1]) + c[i];
    }

    cout << max(max(adp[N-1], bdp[N-1]), cdp[N-1]) << endl;
}

Measured memory_bytes: 3712
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    n = ii()
    a = li()
    BIG = 10**18
    ans = a[0]
    if 0 in a:
        print(0)
        exit()
    for i in range(1,n):
        if BIG//a[i] < ans:
            print(-1)
            exit()
        else:
            ans*= a[i]
        if ans > BIG:
            print(-1)
            exit()
    print(ans)


main()




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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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 int INF = 1001001001;

int main()
{   
    int n;
    cin >> n;
    vi h(n);
    rep(i, n) cin >> h[i];

    vi dp(n, INF);
    dp[0] = 0;
    for(int i = 1; i < n; i++) {
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if(i - 2 >= 0) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 3980
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<fstream>
#include<stdio.h>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define PI  3.141592
//----------------------------------------


int keta(int a)
{
	int n = 1;
	while (a >= 10)
	{
		a /= 10;
		n++;
	}
	return n;

}



int main(void)
{

	int n, m;

	cin >> n >> m;


	
	int kmax = pow(10, n);

	vector<int> s(kmax+3);
	rep(i, kmax) s[i] = -1;

	rep(i, m)
	{
		int a,b;
		cin >> a>>b;

		if (s[a] == -1) s[a] = b;
		else if (s[a] == b) continue;
		else
		{
			cout << -1 << endl;
			return 0;
		}

	}

	for (int j = 0; j < kmax; j++)
	{	
		if (keta(j) != n)continue;
		
		
		string k = to_string(j);
	
		bool co = true;
		for (int l = 1; l <= n; l++)
		{
			char w;
			string h = to_string(s[l]);
			w = h[0];
			if (s[l] == -1 ||w == k[l-1]) continue;
			else co = false;
		}

		if (co)
		{
			cout << j << endl;
			return 0;
		}


		
	}
cout << -1 << endl;
	//string an;

	//if (s[1] == 0 && n != 1)
	//{
	//	cout << -1 << endl;
	//	return 0;
	//}
	//if (s[1] == -1) an += "1";
	//else an += to_string(s[1]);
	//for (int k = 2; k <= n; k++)
	//{
	//	if (s[k] == -1) an += "0";
	//	else an += to_string(s[k]);
	//}

	//cout << an << endl;
}

Measured memory_bytes: 256
N=int(input())
info=[input().split() for i in range(N)] #mojiretu
#print(info)
from operator import itemgetter
dic1={}
for i in range(len(info)):
    dic1[i+1]=info[i]
#print(dic1)
info1=sorted(info,key=lambda x:int(x[1]),reverse=True)
info2=sorted(info1,key=itemgetter(0))
#print(info2)
for i in info2:
    for key,value in dic1.items():
        if value==i:
            print(key)


Measured memory_bytes: 3060
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 07/17/20 22:14:12
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  ll l[2] = {2,1};
  if (n < 2) {
    cout << l[n] << endl;
  } else {
    for (int i = 2; i <= n; i++) {
      ll r[2] = {l[1], l[0]+l[1]};
      l[0] = r[0];
      l[1] = r[1];
    }
    cout << l[1] << endl;
  }

  return 0;
}


Measured memory_bytes: 3616