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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    set<int> table;
    for(int i = 1; i < 10; i++) {
        for(int j = 1; j < 10; j++) {
            table.insert(i * j);
        }
    }

    int N;
    std::cin >> N;
    if(table.find(N) != table.end()) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<vector>
using namespace std;
using ll = long long;

int main() {
    int X,N,T;
    cin >> N >> X>> T;
    int a, b;
    a = N / X;
    b = N % X;
    if (b != 0) {
        cout << T*(a + 1);
    }
    else {
        cout << T * a;
    }
}

Measured memory_bytes: 3132
#https://atcoder.jp/contests/abc136/tasks/abc136_a

A,B,C=(int(x) for x in input().split())
i=0

if 1<=B<=A<=20 and 1<=C<=20:
    i=C-(A-B)
    if i<0:
        i=0
else:
    print('condition failed')

print(i)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    if(((A * B) & 1) | ((B * C) & 1) | ((C * A) & 1)) cout << "Hom" << endl;
    else cout << "Tem" << endl;
    return 0;
}



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

using namespace std;

int n, ans;

vector < int > a(110), vec;

int check() {
    int res = 1;
    for (int i = 0; i < vec.size(); ++i) {
//        cout << vec[i] << " ";
        res *= vec[i];
    }
//    cout << "\n";
    return !(res % 2);
}

void rec(int now = 1, int last = -1) {
    if (now == n + 1) {
        if (check()) {
            ++ans;
        }
        return;
    }
    for (int i = last + 1; i < n; ++i) {
        vec.push_back(a[i]);
        rec(now + 1, i);
        vec.pop_back();

        vec.push_back(a[i] + 1);
        rec(now + 1, i);
        vec.pop_back();

        vec.push_back(a[i] - 1);
        rec(now + 1, i);
        vec.pop_back();
    }
}

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


Measured memory_bytes: 256
#include <stdio.h> 
#define N 100002
 
int Partition(int A[],int p,int r);
 
int i,j;
 
main(){
  int n,A[N],c;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  c = Partition(A,0,n-1);
  for(i = 0; i < n-1; i++){
    if(i == c){
      printf("[%d] ",A[i]);
    }
else{
      printf("%d ",A[i]);
    }
  }

  printf("%d\n",A[n-1]);
  return 0;
}
   
int Partition(int A[],int p,int r){

  int x,y,z;


  x = A[r];
  i = p-1;

  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      y = A[i];
      A[i] = A[j];
      A[j] = y;
    }
  }

  z = A[i+1];
  A[i+1] = A[r];
  A[r] = z;
  return i+1;

}

Measured memory_bytes: 988
/*
    author: blue_matrix
*/
#include <bits/stdc++.h>
#include <math.h>
using namespace std;

# define M_PI           3.14159265358979323846
#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;
    vector<ll> a(n+1);
    for(ll i=2;i<=n;i++)
    {
        ll b;
        cin>>b;
        a[b]++;
    }
    for(ll i=1;i<=n;i++)
    cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 4784
# include "bits/stdc++.h"
using namespace std;
int n, h[101010], dp[101010];
const int INF = INT_MAX; 
int main(){
    cin >> n;
    for(int i = 1;i <= n;i++)cin >> h[i];
    for(int i = 1;i <= n;i++)dp[i] = INF;
    dp[1] = 0;
    for(int i = 1;i <= n;i++){
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    cout << dp[n] << endl;
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  string out = "";
  if (a < b) {
    for (int i = 0; i < b; ++i) {
      out += to_string(a);
    }
  } else {
    for (int i = 0; i < a; ++i) {
      out += to_string(b);
    }
  }
  cout << out << endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
c=0
for j in range(105,n+1,2):
  d=[]
  for i in range(1,int(j**0.5)+1):
        if j%i==0:
            d.append(i)
            if i!=n//i:
                d.append(n//i)
  if len(d)==8:
    c+=1
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

int hoge(int n){
    if(n%2==0) return n/2;
    else return 3*n+1;
}

int main(){
    int s;
    cin>>s;
    int a[1000000];
    a[0] = s;
    int cnt=1;
    while(1){
        a[cnt] = hoge(a[cnt-1]);
        rep(i,0,cnt-1){
            if(a[cnt]==a[i]){
                cout<<cnt+1<<endl;
                return 0;
            }
        }
        cnt++;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll i,j,k;
ll mod=1000000007;

long long modpow(long long a,long long n){//繰り返し二乗法
    long long mod=1000000007;
    if(n==1) return a%mod;
    if(n%2==1) return (a*modpow(a,n-1))%mod;
    long long t=modpow(a,n/2);
    return (t*t)%mod;
}

long long combi(long long n,long long r){//繰り返し二乗法を用いてcombination計算
    long long ans,i,under=1,up=1,mod=1000000007;
    for(i=1;i<=r;i++){
        under=under*i;
        under=under%mod;
    }
    under=modpow(under,mod-2);//フェルマーの小定理
    
    for(i=1;i<=r;i++){
        up=up*(n-i+1);
        up=up%mod;
    }
    ans=up*(under%mod);
    return ans%mod;
}
 


int main(){
    ll n,k;cin>>n>>k;
    ll number=n-k+1;


    for(i=1;i<=k;i++){
        cout<<(combi(k-1,i-1)*combi(number,i))%mod<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <cstring>
#include <string>
#include <limits.h>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long int LLN;

int buff[3];

int main(){

    while(scanf("%d%d%d", buff, buff + 1, buff + 2) != -1){
        sort(buff, buff + 3);

        int delta1 = buff[2] - buff[1];
        int delta2 = buff[2] - buff[0];

        if((delta2 - delta1) % 2){
            ++delta1;
            ++delta2;
        }

        int ans = min(delta2, delta1) + (delta2 - delta1 + 1) / 2;
        // printf("debug.. %d %d %d\n", buff[0], buff[1], buff[2]);
        // printf("debug.. %d %d\n", delta1, delta2);

        // printf("debug.. %d %d\n", min(delta2, delta1), (delta2 - delta1 + 1) / 2);

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

    return 0;
}

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

vector<int> v;

void rec(int n, int x){
    if(x == 0){
        for(int i=0;i<int(v.size());i++){
            if(i>0) cout << " ";
            cout << v[i];
        }
        cout << endl;
        return;
    }
    for(int k=min(n,x);k>0;k--){
        v.push_back(k);
        rec(k,x-k);
        v.pop_back();
    }
}

int main() {
    int N;
    while(cin >> N, N){
        rec(N,N);
    }
    return 0;
}



Measured memory_bytes: 3160
#include<cstdio>
#include<utility>
#include<algorithm>
#include<vector>
using namespace std;
typedef pair<int,int> pii;
vector<int> e[2100];
int n,m,x,y,deg[2100],sum[2100];
int fa[2100],dep[2100],p[2100];
bool col[2100],vis[2100];
pii num[2100],q[2100];

void dfs1(int u){
	for (int i=0;i<(int)e[u].size();i++)
		if (e[u][i]!=fa[u]){
			int v=e[u][i];
			fa[v]=u; dep[v]=dep[u]+1;
			dfs1(v);
		}
}

void dfs2(int u){
	int v;
	for (int i=0;i<(int)e[u].size();i++)
		if (e[u][i]!=fa[u]){
			v=e[u][i]; dfs2(v);
			sum[u]+=sum[v];
		} 
}

int lca(int x,int y){
	if (dep[x]<dep[y]) swap(x,y);
	while (dep[x]>dep[y]) x=fa[x];
	while (x!=y) x=fa[x],y=fa[y];
	return x;
}

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
		deg[x]++; deg[y]++;
	}
	dfs1(1);
	for (int i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		q[i]=pii(x,y); num[i]=pii(x,y);
		sum[x]++; sum[y]++;
		sum[lca(x,y)]-=2;
	}
	dfs2(1);
	int ans=0;
	for (int i=2;i<=n;i++) ans+=min(sum[i],2);
	printf("%d\n",ans);
	for (int i=2;i<=n;i++){
		int u=0;
		for (int j=2;j<=n;j++)
			if (deg[j]==1&&!vis[j]){
				u=j;
				break;
			}
		vis[u]=true;
		int v=0;
		for (int j=0;j<(int)e[u].size();j++)
			if (!vis[e[u][j]]){
				v=e[u][j];
				break;
			}
		deg[v]--;
		
		int a=0,b=0;
		for (int j=1;j<=m;j++)
			if ((num[j].first==u)^(num[j].second==u)){
				if (!a) a=j;
				else if (!b) b=j;
				else break;
			}
		if (!a&&!b) continue;
		if (!b){
			if (num[a].first==u) num[a].first=v;
			else num[a].second=v; 
			continue;
		}
		if (num[a].first==u){
			if (num[b].first==u){
				num[a].first=num[b].second;
				col[b]^=1;
			}
			else num[a].first=num[b].first;
		}
		else{
			if (num[b].second==u){
				num[a].second=num[b].first;
				col[b]^=1;
			}
			else num[a].second=num[b].second;
		}
		num[b].first=num[b].second;
		p[b]=a;
		for (int j=1;j<=m;j++)
			if ((num[j].first==u)^(num[j].second==u)){
				if (num[j].first==u) num[j].first=v;
				else num[j].second=v;
			}
	}
	for (int i=1;i<=m;i++)
		if (p[i]) col[i]^=col[p[i]];
		
	for (int i=1;i<=m;i++){
		if (col[i]) swap(q[i].first,q[i].second);
		printf("%d %d\n",q[i].first,q[i].second);
	}
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MOD = 1000000007;

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

int main(){
    ll n,k;
    cin >> n >> k;
    cout << min(n % k,k - (n % k)) << endl;
}


Measured memory_bytes: 256
# AOJ 0112: A Milk Shop
# Python3 2018.6.18 bal4u

while True:
	n = int(input())
	if n == 0: break
	f = [0]*65
	for i in range(n):
		f[int(input())] += 1
	if n == 1:
		print(0)
		continue
	n -= f[0]
	i, ans, m = 1, 0, n
	while m > 0:
		k = f[i];
		if k == 0:
			i += 1
			continue
		if k == 1: ans += (m-1)*i
		else: 
			a = m*k - (k*(k+1))//2
			ans += a*i;
		m -= k;
		i += 1
	print(ans)


Measured memory_bytes: 5620
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [h, w] <- getIntList
    grid <- replicateM h getLine
    let hcompression g = filter (any (== '#')) g
        wcompression g = transpose $ filter (any (== '#')) (transpose g)
    mapM_ putStrLn $ wcompression (hcompression grid)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=b-1;i>=a;i--)
ll n,ans;
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>n;
    rep(i,1,n+1) if(i%3!=0&&i%5!=0) ans+=i;
    cout<<ans<<"\n";
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long mod = 1000000007;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
    A[i]++;
  }
  bool flg = false;
  vector<int> a(N + 1), b(N + 1), c(N + 1);
  for (int i = 1; i <= N; i++){
    a[i] = a[i - 1];
    b[i] = b[i - 1];
    c[i] = c[i - 1];
    if (A[i - 1] == a[i] + 1){
      a[i]++;
    } else if (A[i - 1] == b[i] + 1){
      b[i]++;
    } else if (A[i - 1] == c[i] + 1){
      c[i]++;
    } else {
      flg = true;
      break;
    }
  }
  if (flg){
    cout << 0;
  } else {
    long long res = 1;
    for (int i = 0; i < N; i++){
      if (a[i] == c[i]){
        res *= 3;
      } else if (a[i] == b[i] && c[i] == c[i + 1] || b[i] == c[i] && a[i] == a[i + 1]){
        res *= 2;
      }
      res %= mod;
    }
    cout << res;
  }
}

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

int main() {
	int n;
	cin >> n;
	bool flip=0;
	int min = 1000000000;
	long long sum = 0;
	for (int i = 0, a; i < n; i++) {
		cin >> a;
		if (a < 0) {
			flip ^= 1;
			a = -a;
		}
		sum += a;
		if (a < min)
			min = a;
	}
	if (flip) {
		sum -= min * 2;
	}
	cout << sum << endl;
}



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

const int MAX_V = 100010;
const int MAX_LOG_V = 30;

class LCA {
public:
	vector<int> G[MAX_V];
	int root;

	int parent[MAX_LOG_V][MAX_V];
	int depth[MAX_V];

	void dfs(int v, int p, int d) {
		parent[0][v] = p;
		depth[v] = d;
		for(int i = 0; i < G[v].size(); i++) {
			if(G[v][i] != p) dfs(G[v][i], v, d + 1);
		}
	}

	void add_edge(int a, int b) {
		G[a].push_back(b);
		G[b].push_back(a);
	}

	void init(int V, int root = 0) {
		this->root = root;
		dfs(root, -1, 0);
		for(int k = 0; k + 1 < MAX_LOG_V; k++) {
			for(int v = 0; v < V; v++) {
				if(parent[k][v] < 0) parent[k + 1][v] = -1;
				else parent[k + 1][v] = parent[k][parent[k][v]];
			}
		}
	}

	int lca(int u, int v) {
		if(depth[u] > depth[v]) swap(u, v);
		for(int k = 0; k < MAX_LOG_V; k++) {
			if((depth[v] - depth[u]) >> k & 1) {
				v = parent[k][v];
			}
		}
		if(u == v) return u;
		for(int k = MAX_LOG_V - 1; k >= 0; k--) {
			if(parent[k][u] != parent[k][v]) {
				u = parent[k][u];
				v = parent[k][v];
			}
		}
		return parent[0][u];
	}
};

LCA lca;

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

	int n;
	cin >> n;

	for(int i = 0; i < n; i++) {
		int k;
		cin >> k;
		while(k--) {
			int c;
			cin >> c;
			lca.add_edge(i, c);
		}
	}

	lca.init(n);

	int q;
	cin >> q;
	while(q--) {
		int u, v;
		cin >> u >> v;
		cout << lca.lca(u, v) << endl;
	}
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> b(N + 1, 0);
    for (int i = 1; i <= N; ++i)
    {
        if (i >= K)
        {
            b[i] = N;
        }
        else
        {
            ll p = 2;
            while (i * p < K) p *= 2;
            b[i] = N * p;
        }
    }
    ll sum;
    for (int i = 1; i <= N; ++i) sum += b[1] / b[i];

    long double ans = (long double)sum / b[1];
    cout << fixed;
    cout << setprecision(12) << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
 
const ll mod = 1E9 + 7;

vector<int> adj[200001];
int visited[200001];
int sz = 0;
void dfs(int u){
	sz += 1;
	visited[u] = 1;
	for(auto i: adj[u])
		if(!visited[i])
			dfs(i);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m; cin >> n >> m;
	memset(visited, 0, sizeof(visited));
	int i, j;
	for(i = 0; i < m; i++){
		int u, v;
		cin >> u >> v;
		adj[u - 1].push_back(v - 1);
		adj[v - 1].push_back(u - 1);
	}
	int cnt = 0;
	for(i = 0; i < n; i++){
		if(!visited[i]){
			sz = 0;
			dfs(i);
			cnt = max(cnt, sz);
		}
	}
	cout << cnt;
}


Measured memory_bytes: 21328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  string ans="CODEFESTIVAL2016";
  string s;
  cin >> s;
  ll cnt=0;
  ll n=s.size();
  for(ll i=0;i<n;i++) {
    cnt+=s[i]!=ans[i];
  }
  cout << cnt << endl;
}

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


int main(){
    int a, b, n;
    while( cin >> a >> b >> n ){
        int ans = 0;
        a = (a-a/b*b)*10;
        while( n-- > 0 ){
            ans += a/b;
            a = (a-a/b*b)*10;
        }
        cout << ans << endl;
    }
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M;
int H[111][111];

struct edge{
    int to,cap,cost,rev;
    edge(int a,int b,int c,int d):to(a),cap(b),cost(c),rev(d){}
};

const int INF=1001001001;

const int MV=300;
int src=MV-2,snk=MV-1;
vector<edge>G[MV];
int dist[MV];
int prevv[MV],preve[MV];

void init(){
    rep(i,MV)G[i].clear();
}

void add_edge(int from,int to,int cap,int cost){
    G[from].pb(edge(to,cap,cost,G[to].size()));
    G[to].pb(edge(from,0,-cost,G[from].size()-1));
}

int min_cost_flow(int s,int t,int f){
    int res=0;
    while(f>0){
        fill(dist,dist+MV,INF);
        dist[s]=0;
        bool update=true;
        while(update){
            update=false;
            for(int v=0;v<MV;v++){
                if(dist[v]==INF)continue;
                for(int i=0;i<G[v].size();i++){
                    edge &e=G[v][i];
                    if(e.cap>0&&dist[e.to]>dist[v]+e.cost){
                        dist[e.to]=dist[v]+e.cost;
                        prevv[e.to]=v;
                        preve[e.to]=i;
                        update=true;
                    }
                }
            }
        }
        if(dist[t]==INF)return -1;
        int d=f;
        for(int v=t;v!=s;v=prevv[v]){
            d=min(d,G[prevv[v]][preve[v]].cap);
        }

        f-=d;
        res+=d*dist[t];
        for(int v=t;v!=s;v=prevv[v]){
            edge &e=G[prevv[v]][preve[v]];
            e.cap-=d;
            G[v][e.rev].cap+=d;
        }
    }
    return res;
}

bool C(int x){
    int t=M/N;
    init();
    rep(i,N)add_edge(src,i,t,0);
    rep(i,N)add_edge(src,i,1,1);

    rep(i,N)rep(j,M)if(H[i][j]<=x)add_edge(i,j+N,1,0);
    rep(i,M)add_edge(i+N,snk,1,0);

    int tmp=min_cost_flow(src,snk,M);
    if(tmp==-1)return false;
    if(tmp>M%N)return false;
    return true;
}

signed main(){
    cin>>N>>M;
    rep(i,N)rep(j,M)cin>>H[i][j];

    int lb=0,ub=1001001001;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(C(mid))ub=mid;
        else lb=mid;
    }
    cout<<(M%N!=0)<<endl;
    cout<<ub<<endl;
    return 0;
}

Measured memory_bytes: 3544
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,d; cin>>n>>d;
    vector<int> x(2*n,0);
    rep(i,2*n) cin>>x[i];
    two_sat ts{n};
    for(int i=0;i<2*n-1;i++)for(int j=i+1;j<2*n;j++){
        if(i/2==j/2) continue;
        if(abs(x[i]-x[j])<d) ts.add_clause(i/2,i%2==0,j/2,j%2==0);
    }
    if(!(ts.satisfiable())){
        printf("No\n");
        return 0;
    }
    auto ans=ts.answer();
    printf("Yes\n");
    rep(i,n) printf("%d\n",x[2*i+ans[i]]);
}

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

int main() {
	// your code goes here
	char s[500]; cin >> s;
	bool ok=true;
	for(int i=0;i<strlen(s);i++){
		if(i%2==0&&s[i]=='L') ok=false;
		if(i%2==1&&s[i]=='R') ok=false;
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong(), m = sc.nextLong();
        if (n==1 && m==1) System.out.println(1);
        else if (n==1 || m==1) System.out.println(n*m-2);
        else System.out.println((n-2)*(m-2));
    }
}


Measured memory_bytes: 21972
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
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
 *
 * @author Nikita Mikhailov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {

            int k = in.readInt();

            long sum = 0;
            for (int i = 1; i <= k; i++) {
                for (int j = 1; j <= k; j++) {
                    for (int l = 1; l <= k; l++) {
                        sum += Factorization.gcd(Factorization.gcd(i, j), l);
                    }
                }
            }
            out.println(sum);
        }

    }

    static class Factorization {
        static long gcd(long a, long b) {
            return a == 0 ? b : gcd(b % a, a);
        }

    }

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

        public FastScanner(final InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
        }

        public String readToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int readInt() {
            return Integer.parseInt(readToken());
        }

    }
}



Measured memory_bytes: 32872
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector <int> a(A);
  vector <int> b(B);
  int am = 1e9;
  int bm = 1e9;
  REP(i, A) {
	cin >> a[i];
	am = min(am, a[i]);
  }
  REP(i, B) {
	cin >> b[i];
	bm = min(bm, b[i]);
  }
  int ans = am + bm;
  REP(i, M) {
	int x, y, c;
	cin >> x >> y >> c;
	ans = min(ans, a[x - 1] + b[y - 1] - c);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
using namespace std; 
void fastio()
{
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
signed main()
{
    fastio();
   int n;
    cin>>n;
    if(n>=30)
    cout<<"Yes";
    else
    cout<<"No";
       
}
    


Measured memory_bytes: 3644
// author : ayush_nishad
// Road to Expert since : 30 Aug 2020
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define all(x)  x.begin(),x.end()
#define w(x) int x;cin>>x; while(x-->0)
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
/*
think fast
think simple
*/
int n;
int dp[2009];
int fun(int now)
{
	if (now > n)
		return 0 ;
	if (now == n)
		return 1;
	int &ans = dp[now];
	if (ans != -1)
		return ans;
	ans = 0;
	for (int i = 3; i <= n; i++)
	{
		ans += fun(now + i);
		ans %= mod;
	}
	return ans;
}
void mysol()
{
	memset(dp, -1, sizeof(dp));
	cin >> n;
	cout << fun(0);
}

int32_t main()
{
	fast();
	// w(t)
	{
		mysol();
	}
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 3584
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int min = a;
		int max = a;
		long x = a;
		for (int i = 1; n > i; ++i) {
			a = sc.nextInt();

			//標準入力から数値を受け取りｎ、aにそれぞれ代入
			//minがaより大きいときminにaを代入する
			if (min > a) {
				//maxがaより小さいときmaxにaを代入する
				min = a;
			}
			if (max < a) {
				max = a;
			}
			x = x + a;
		}
		System.out.println(min + " " + max + " " + x);
	}

}



Measured memory_bytes: 41644
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    long double a[n];
    long double sum = 0;
    for(int i = 0; i<n; i++){
        cin>>a[i];
        sum+= (1.0/a[i]);
    }
    cout<<fixed<<setprecision(6)<<(1.0)/sum;
}

Measured memory_bytes: 256
N = int(input())
CSF = [list(map(int, input().split())) for i in range(N-1)]
for i in range(N-1):
    ans = 0
    for j in range(i, N-1):
        C, S, F = CSF[j]
        if ans < S:
            ans = S
        else:
            if ans % F != 0:
                ans += F - (ans % F)
        ans += C
    print(ans)
print(0)

Measured memory_bytes: 44396
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
p = -2
for i in range(N):
    ans += B[A[i]-1]
    if A[i] == p+1:
        ans += C[p-1]
    p = A[i]

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define INF 1e9+7

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 == 1 && b % 2 == 1)
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0 for _ in range(W+10)] for _ in range(N+5)]
dp[0][0] = 0

for w in range(W+1):
    for n in range(N):
        Wi = wv[n][0]
        Vi = wv[n][1]
        if Wi <= w:
            dp[n+1][w] = max(dp[n][w], dp[n][w-Wi] + Vi)
        dp[n+1][w] = max(dp[n][w], dp[n+1][w])

print(dp[N][W])

Measured memory_bytes: 173832
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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

signed main(void) {
	int h,w;
    cin >> h >> w;
	int sx,sy,gx,gy;
	cin >> sx >> sy >> gx >> gy;
	sx--,sy--,gx--,gy--;
	vs s(h);
	rep(i,h)cin >> s[i];
	vvi d(h,vi(w,INF));
	d[sx][sy] = 0;
	priority_queue< pip, vector<pip>, greater<pip> > q;
	q.push(pip(0,pii(sx,sy)));
	while(!q.empty()){
		pii p = q.top().second;
		int x = p.first;
		int y = p.second;
		q.pop();
		//cout << x << " "<<y << " " << d[x][y] << endl;
		for(int nx = x-2; nx <= x+2; nx++)for(int ny = y-2; ny <= y+2; ny++){
			if(nx < 0 || ny < 0 || nx >= h || ny >= w)continue;
			if(s[nx][ny] == '#')continue;
			int cost = 1;
			if(abs(x - nx) + abs(y - ny) <= 1)cost = 0;
			if(d[nx][ny] <= d[x][y] + cost)continue;
			d[nx][ny] = d[x][y] + cost;
			q.push(pip(d[nx][ny],pii(nx,ny)));
		}
	}
	if(d[gx][gy] == INF)cout << -1 << endl;
	else cout << d[gx][gy] << endl;
}


Measured memory_bytes: 12600
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define along long(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  int d[10];
  clr(d,0);
  ll n,k;
  cin>>n>>k;
  rep(i,0,k){
    ll a;
    cin>>a;
    d[a]=1;
  }
  vector<ll> v;
  rep(i,0,10){
    if(d[i]==0){
      v.pb(i);
    }
  }
  ll nn = v.sz;
  ll mn = 100000000;
  rep(i,1,7){
    rep(j,0,pow(nn,i)){
      vector<ll> v1;
      ll a = j;
      rep(k,0,i){
        v1.pb(a%nn);
        a/=nn;
      }
      ll b = 0;
      rep(k,0,i){
        b += v[v1[k]]*pow(10,k);
      }
      if(b>=n){
        mn = min(mn,b);
      }
    }
  }
  cout << mn << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int N=2e5+4;
const int mod=998244353;
int dp[N];
int pre[N];
void solve(){
    memset(dp,0,sizeof dp);
    memset(pre,0,sizeof pre);
    int n,k; cin>>n>>k;
    std::vector<pair<int,int>> v;
    while(k--){
        int a,b; cin>>a>>b;
        v.push_back({a,b});
    }
    dp[1]=1;
    pre[0]=0,pre[1]=1;
    for(int i=2;i<=n;i++){
        for(auto j:v){
            int r=max(0LL,i-j.first);
            int l=max(0LL,i-j.second-1);
            dp[i]=(dp[i]+pre[r]-pre[l])%mod;
        }
        pre[i]=pre[i-1]+dp[i];
    }
    cout<<dp[n]<<endl;
}   
int32_t main(){
    int tt; 
    tt=1;
    // cin>>tt;
    for(int t=1;t<=tt;t++){
        solve();
    }
}

  

Measured memory_bytes: 6724
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <list>
#include <deque>
typedef long long ll;
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 int MOD = 1000000007;
const ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) {return a / GCD(a, b) * b;}

int main()
{
	int N,Q;
	string str;
	cin >> N >> Q >> str;
	int l[Q],r[Q];
	vector<int> s(N);
	for(int i = 0; i < Q; i++) cin >> l[i] >> r[i], l[i]--,r[i]--;
	s[0] = 0;
	for(int i = 0; i < N -1; i++)
	{
		if(str[i] == 'A' && str[i + 1] == 'C') s[i + 1] = s[i] + 1;
		else s[i + 1] = s[i];
	}
	for(int i = 0; i < Q; i++)
	{
		cout << s[r[i]] - s[l[i]] << endl;
	}
}

Measured memory_bytes: 2240
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define po pop_back
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false)
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
#define tostr to_string
#define toint stoi
#define gcd __gcd
#define maximum INT_MAX
#define minimum INT_MIN

int main() {

int n,i,flag=1; string s;
cin>>n; cin>>s;
if((n%2)!=0) cout<<"No";
else{

for(i=0;i<n/2;i++)
{
    if(s[i]!=s[n/2+i]) {  flag=0; break; }

}

 if(flag==0) cout<<"No";
 else cout<<"Yes";

 }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,x,y,z;
    cin>>n;
    long long a[n+5];
    map<long long,long long>mp;
    vector<long long>v;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
        if(mp[a[i]]==1)
        {
            v.push_back(a[i]);
        }
    }
    long long ans=0;
    for(int i=0;i<v.size();i++)
    {
        ans=ans+((mp[v[i]]*(mp[v[i]]-1))/2);
    }
    for(int i=1;i<=n;i++)
    {
        x=ans-(((mp[a[i]])*(mp[a[i]]-1))/2);
        y=mp[a[i]]-1;
        z=mp[a[i]]-2;
        if(y>0 && z>0)
        {
            x=x+((y*z)/2);
        }
        cout<<x<<endl;
    }

}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, m;
    cin >> n >> m;

    vector<int64_t> nums(n, 1);
    vector<bool> has_red(n);
    has_red[0] = true;
    for (auto _ : irange(0L, m)) {
        int64_t x, y;
        cin >> x >> y;
        --x;
        --y;

        if (has_red[x]) {
            if (nums[x] == 1) {
                has_red[x] = false;
            }

            has_red[y] = true;
        }

        --nums[x];
        ++nums[y];
    }

    cout << count(has_red.begin(), has_red.end(), true) << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <tuple>
#include <functional>
#include <map>
#include <unordered_map>
#include <queue>
#include <tuple>

using namespace std;

#define endl '\n'

using ull = unsigned long int;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  const int precision = 13;
  cout.precision(precision);
  cout.setf(ios_base::fixed);

  int n, m; cin >> n >> m;
  vector<vector<int>> g(n+1);

  for (int i = 0; i < m; ++i) {
    int u, v; cin >> u >> v;
    g[u].push_back(v);
  }

  vector<int> depth(n+1, -1);

  function<int(int, int)> dfs =
    [&](int u, int p) -> int {
      if (g[u].size() == 0) return 0;
      int& ans = depth[u];
      if (ans == -1) {
        ans = 0;
        for (auto v : g[u]) {
          if (v == p) continue;
          ans = max(ans, 1 + dfs(v, u));
        }
      }
      return ans;
    };
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, dfs(i, -1));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

vector<int> Iv;
vector<int> Jv;
int N;
int main() {
	cin>>N;
	int cnt =0;
	if(N%2 == 0){
		rep1(i,N+1)rep1(j,N+1){
			if(i<j)
			if(i+j!=N+1){
				cnt++;
				Iv.push_back(i);
				Jv.push_back(j);
			}
		}
	}
	else{
		rep1(i,N+1)rep1(j,N+1){
			if(i<j)
			if(i+j!=N){
				cnt++;
				Iv.push_back(i);
				Jv.push_back(j);
			}
		}
	}

	cout<<cnt<<endl;
	rep(i,cnt){
		cout<<Iv[i]<<' '<<Jv[i]<<endl;
	}
}

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

const int MAX_V=101;
struct edge{
    int to;
    int cost;
    int idx;
};
vector<edge> G[MAX_V];
bool passed[101];
int maxCost;
vector<int> minNodePath;
vector<int> path;

// depth first search
void dfs(int s,int sumCost){
    bool fin=true;
    path.push_back(s);
    for(int i = 0; i < G[s].size(); i++){
        edge e=G[s][i];
        if(passed[e.idx])
            continue;
        fin=false;
        passed[e.idx]=true;
        dfs(e.to,sumCost+e.cost);
        passed[e.idx]=false;
    }
    if(fin){
        if(maxCost<sumCost){
            maxCost=sumCost;
            minNodePath=path;
        }
        else if(maxCost==sumCost){
            if(minNodePath>path){
                minNodePath=path;
            }
        }
    }
    path.erase(path.begin()+path.size()-1);
}

int main(){

    int ns,nl;
    while(cin>>ns>>nl&&!(ns==0&&nl==0)){
        int idx=0;
        maxCost=0;
        minNodePath.clear();
        fill(passed,passed+101,false);
        for(int i = 0; i < ns; i++)
            G[i].clear();
        for(int i = 0; i < nl; i++){
            int from,to,cost;
            cin>>from>>to>>cost;
            from--;to--;
            edge e;
            e.to=to;e.cost=cost;e.idx=idx++;
            G[from].push_back(e);
            e.to=from;
            G[to].push_back(e);
        }
        for(int i = 0; i < ns; i++){
            fill(passed,passed+101,false);
            path.clear();
            dfs(i,0);
        }
        cout<<maxCost<<endl;
        for(int i = 0; i < minNodePath.size(); i++){
            cout<<minNodePath[i]+1;
            if(i==minNodePath.size()-1)
                cout<<endl;
            else
                cout<<" ";
        }
    }
    return 0;
}

Measured memory_bytes: 0
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

int x[105], y[105];
int d[105][1010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int w, h, n;
  cin >> w >> h >> n;
  REP(i, n) {
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
  }

  REP(i, 105) REP(j, 1010) d[i][j] = LLINF;
  priority_queue<VI, VVI, greater<VI>> que;
  // スタート地点から街灯iに向かう
  REP(i, n) {
    int cost = x[i]+y[i];
    d[i][cost] = cost;
    que.push({cost, i, cost});
  }

  while(que.size()) {
    VI v = que.top(); que.pop();
    int dist = v[0], idx = v[1], cost = v[2];
    if(dist > d[idx][cost]) continue;
    REP(i, n) {
      if(idx == i) continue;
      int n_cost = max(0LL, abs(x[idx]-x[i]) + abs(y[idx]-y[i]) - cost - 1);
      if(d[i][n_cost] > d[idx][cost] + n_cost) {
        d[i][n_cost] = d[idx][cost] + n_cost;
        que.push({d[i][n_cost], i, n_cost});
      }
    }
  }

  int ans = LLINF;
  REP(i, n) REP(j, 1010) {
    chmin(ans, d[i][j] + max(0LL, abs(w-1-x[i]) + abs(h-1-y[i]) - j));
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 6724
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

map<int, int> mapto;
string Next(string str, int l) {
  vector<int> lhs, rhs;
  FORIT(it, str) { lhs.push_back(*it - '0'); rhs.push_back(*it - '0'); }
  while ((int)lhs.size() < l) { lhs.push_back(0); rhs.push_back(0); }
  assert((int)lhs.size() == l);
  assert((int)rhs.size() == l);
  sort(lhs.rbegin(), lhs.rend());
  sort(rhs.begin(), rhs.end());
  int lv = 0;
  int rv = 0;
  REP(i, l) {
    lv = lv * 10 + lhs[i];
    rv = rv * 10 + rhs[i];
  }
  int ret = lv - rv;
  char s[100];
  sprintf(s, "%d", ret);
  return (string)s;
}

int main() {
  string str;
  int l;
  while (cin >> str >> l, l) {
    mapto.clear();
    REP(i, 100) {
      int v = atoi(str.c_str());
      if (mapto.count(v)) {
        printf("%d %d %d\n", mapto[v], v, i - mapto[v]);
        break;
      }
      mapto[v] = i;
      str = Next(str, l);
    }
  }
}

Measured memory_bytes: 0
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;

int main(){
    fastio
 double a,b;
 cin>>a>>b;
printf("%.10f",a/b);
    return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937 rng(time(NULL));

const int D = 365, N = 26;
int d;
ll c[N+1];
ll s[D+1][N+1];
ll last[N];
int contest[D];

ll calc(int idx, int x) {
	ll ans = 0;
	ll l = idx-1, r = idx+1;
	ll len, len2;
	while(l > 0 && contest[l] != contest[idx]) l--;
	len = idx - l;
	while(r <= d && contest[r] != contest[idx]) r++;
	len2 = r - idx;
	ans -= s[idx][contest[idx]];
	ans -= c[contest[idx]] * len * len2;
	ll tmp = contest[idx];
	contest[idx] = x;

	l = idx-1, r = idx+1;
	while(l > 0 && contest[l] != contest[idx]) l--;
	len = idx - l;
	while(r <= d && contest[r] != contest[idx]) r++;
	len2 = r - idx;
	ans += s[idx][x];
	ans += c[x] * len * len2;
	contest[idx] = tmp;
	return ans;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> d;
	for(int i = 1; i <= N; i++)
		cin >> c[i];
	for(int i = 1; i <= d; i++) {
		for(int j = 1; j <= N; j++)
			cin >> s[i][j];
	}
	memset(last, 0, sizeof last);
	ll ans = 0;
	for(int i = 1; i <= d; i++) {
		ll penalty = 0;
		for(int j = 1; j <= 26; j++)
			penalty += c[j] * (last[j] - i);
		ll best = -1, idx = -1;
		for(int j = 1; j <= 26; j++) {
			ll cur = s[i][j] - penalty + c[j] * (i - last[j]);
			if(best < cur)
				best = cur, idx = j;
		}
		last[idx] = i;
		ans += best;
		contest[i] = idx;
	}

	for(int i = 0; i < 3000000; i++) {
		int idx = rng() % d + 1;
		int to = rng() % N + 1;
		while(to == contest[idx]) to = rng() % N + 1;
		ll change = calc(idx, to);
		if(change > 0) {
			contest[idx] = to;
			ans += change;
		}
	}

	for(int i = 1; i <= d; i++)
		cout << contest[i] << '\n';

	return 0;
}

Measured memory_bytes: 3660
import java.util.*;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();
		
			try {
				if((N>=1&&N<=20)&&(A>=1&&A<=100)&&(B>=1&&B<=2000)){
					int m=(N*A)>B?B:(N*A);
					System.out.println(m);
				}
				
			} catch (Exception e) {
				
				e.printStackTrace();
			}
		
		
	}

}

Measured memory_bytes: 22868
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

struct Node {
	int key;
	Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
	Node *cur = nil->next;
	while (cur != nil && cur->key != key){
		cur = cur->next;
	}
	return cur;
}

void init(){
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList(){
	Node *cur = nil->next;
	int isf = 0;
	while (1){
		if (cur == nil) break;
		// if (isf++ > 0) printf(" ");
		if (isf++ > 0) cout << " ";
		// printf("%d", cur->key);
		cout << cur->key;
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t){
	if (t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deleteKey(int key){
	deleteNode(listSearch(key));
}

void insert(int key){
	Node *x =  (Node *)malloc(sizeof(Node));
	x->key = key;

	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main(){
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for (i = 0; i < n; i++){
		scanf("%s%d", com, &key);
		if (com[0] == 'i'){ insert(key); np++; size++; }
		else if (com[0] == 'd'){
			if (strlen(com) > 6){
				if (com[6] == 'F') deleteFirst();
				else if (com[6] == 'L') deleteLast();
			} else {
				deleteKey(key); nd++;
			}
			size--;
		}
	}

	printList();

	return 0;
}

Measured memory_bytes: 32364
a = input()
b = [0]
c = len(a)
for i in range(0, c):
	if a[i] == "A" or a[i] == "T" or a[i] == "G" or a[i] == "C":
		b[-1] +=1
	else:
		b.append(0)
print(max(b))

Measured memory_bytes: 3060