akhauriyash/Code-Regression huggingface dataset:
N=int(input())

A=[input().split() for i in range(N)]
x=0
y=1
L=0
num=0
import itertools
import math
citylist=[0]*N
#０からN-1までのN要素のリスト生成
for j in range(N):
  citylist[j]=j

Plist=list(itertools.permutations(citylist))

for l in range(math.factorial(N)):
  L=0
  for k in range(N-1):
    L+=((int(A[Plist[l][k]][x])-int(A[Plist[l][k+1]][x]))**2+(int(A[Plist[l][k]][y])-int(A[Plist[l][k+1]][y]))**2)**(1/2)
  num+=L
  
print(num/math.factorial(N))


Measured memory_bytes: 7992
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  int A, B, C;
  unused = scanf("%d %d %d", &A, &B, &C);

  if(A==B) printf("%d", C);
  else if(A==C) printf("%d", B);
  else if(B==C) printf("%d", A);
  return 0;
}

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

int main()
{
	int n1=0,n2=0,n3=0,n4=0,n;
	cin>>n;
	while(n--)
	{
		string j;
		cin>>j;
		if(j=="AC")
			n1++;
		else if(j=="WA")
			n2++;
		else if(j=="TLE")
			n3++;
		else
			n4++;
	}
	cout<<"AC x "<<n1<<"\n";
	cout<<"WA x "<<n2<<"\n";
	cout<<"TLE x "<<n3<<"\n";
	cout<<"RE x "<<n4<<"\n";
}


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

int main(){
    int n,m,s[200001],g[200001],i,ans=0,x,y;
    for(i=0;i<200001;i++){
        s[i] = 0;
        g[i] = 0;
    }
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d %d",&x,&y);
        if(x==1){
            s[y] ++;
        }
        if(y==n){
            g[x] ++;
        }
    }
    for(i=1;i<n;i++){
        if(s[i]==1 && g[i]==1){
            ans = 1;
            break;
        }
    }
    if(ans == 1){
        printf("POSSIBLE\n");
    } else {
        printf("IMPOSSIBLE\n");
    }
}

Measured memory_bytes: 1792
def maximumSubArray(array):
    n = len(array)
    dp = [0]*n # dp[i]: i番目までの全ての部分配列の中の最大の総和
    dp[0] = array[0]
    for i in range(1, n):
        dp[i] = max(dp[i - 1] + array[i], array[i])
    return max(dp)

while True:
    n = int(input())
    a = []
    if n == 0:
        break
    for _ in range(n):
        a.append(int(input()))
    print(maximumSubArray(a))



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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long A, long long B, long long N) {
    auto x = min(B-1, N);
    cout << floor((double)A*x/B) - A*floor((double)x/B) << endl;
}

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long N;
    scanf("%lld", &N);
    solve(A, B, N);
    return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int num_min = INT_MAX;
    int num_max = INT_MIN;
    int x;
    for (int i = 0; i < n; ++i)
    {
        cin >> x;
        num_min = min(num_min, x);
        num_max = max(num_max, x);
    }
    cout << num_max - num_min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    sort(S.begin(), S.end());
    bool ifDup = false;
    rep(i, S.size() - 1){
        if(S[i] == S[i + 1]){
            ifDup = true;
        }
    }

    if(ifDup){
        cout << "no" << endl;
    }else{
        cout << "yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>
int main(void){
    
    int a, b, c, x, y, z;
    scanf("%d %d %d\n", &a, &b, &c);
    if (x < y){
        z = a;
        a = b;
        b = z;
    }
    
    for(y = a; y <= b; y++){
        if(c % y == 0){
            x++;
        }
    }
    
    printf("%d\n", x);
    return 0;
}


Measured memory_bytes: 2104
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer h = scan.nextInt();
        Integer n = scan.nextInt();
        Integer array[] = new Integer[n];

        int sum = 0;
        for(int i=0;i<n;i++){
            array[i] = scan.nextInt();
            sum += array[i];
        }

        if(sum >= h)
            System.out.println("Yes");
        else
        System.out.println("No");

    }

    static int factorial(int n){
        if(n == 0){
          return 1;
        }
        return n * factorial(n-1);
      }
}

Measured memory_bytes: 60064
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(2e5)+10;
int n,a[maxn],b[maxn];
vector<int> g[maxn];
vector<int> ans;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	for (int i=1;i<=n;i++)
	for (int j=i;j<=n;j+=i)
		g[j].push_back(i);
	for (int i=n;i>=1;i--) {
		if (a[i]==b[i]) continue;
		ans.push_back(i);
		for (int j=0;j<g[i].size();j++)
			b[g[i][j]]^=1;
	}
	printf("%d\n",ans.size());
	for (int i=0;i<ans.size();i++) printf("%d ",ans[i]);
	printf("\n");
	return 0;
}

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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

//プロトタイプ宣言
void faster(void);
ll gcd(auto , auto);
ll get_digent(auto);
ll POW(auto , auto);
ll vec_max(auto & , string);
ll vec_min(auto & , string);

int main(){
  faster();
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


























//以下、ライブラリ

//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
ll gcd(auto a, auto b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
ll get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
ll POW(auto x, auto y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//配列内の最大要素の添え字取得or要素取得
ll vec_max(auto &v, string s){
  auto itr = max_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

//配列内の最小要素の添え字取得or要素取得
ll vec_min(auto &v, string s){
  auto itr = min_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int n; scanf("%d", &n);
	vector<ld> ans(n);
	forn(i, n) {
		int input; scanf("%d", &input);
		ans[i] = (ld)input;
	}
	sort(all(ans));
	int iter = 0;
	while(iter < ans.size() - 1) {
		ans.pb((ans[iter] + ans[iter + 1])/2.0);
		iter+=2;
		sort(ans.begin() + iter, ans.end());
	}
	printf("%Lf", ans[iter]);
}










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

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    int n = s.size();

    string s_ = s;
    reverse(s_.begin(), s_.end());
    string a = s.substr(0, (n-1)/2);
    string a_ = s.substr(0, (n-1)/2);
    reverse(a_.begin(), a_.end());
    string b = s.substr((n+3)/2-1);
    string b_ = s.substr((n+3)/2-1);
    reverse(b_.begin(), b_.end());

    string output = "No";
    if (s == s_ && a == a_ && b == b_) {
        output = "Yes";
    }
    cout << output << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int X,t;
    scanf("%d%d",&X,&t);
    if(X<=t){cout<<0<<endl;return 0;}
    else{cout<<X-t<<endl;return 0;}
    return 0;
}


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

ans = 0

for i in range(N-2):
    if D[i][0] == D[i][1] and D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]:
        ans += 1
    else:
        ans += 0
        
if ans >= 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 62444
n = int(input())
tree = [None for i in range(n +1)]
list_pre = list(map(int, input().split()))
list_in = list(map(int, input().split()))
 
 
def solve(tree_pre, tree_in):
    if not tree_pre:
        return -1
    root = tree_pre[0]
    idx = tree_in.index(root)
    tree[root] = (solve(tree_pre[1:idx + 1], tree_in[:idx]), 
                  solve(tree_pre[idx + 1:],  tree_in[idx + 1:]))
    return root


def post_order_search(i):
    if i == -1:
        return
    l, r = tree[i]
    for j in post_order_search(l):
        yield j
    for j in post_order_search(r):
        yield j
    yield i


solve(list_pre, list_in)

print(*post_order_search(list_pre[0]))

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

using namespace std;

#define ll long long
#define vl vector<ll>
#define pb push_back
#define sz size
#define xx first
#define yy second

#define all(x) begin(x), end(x)

#define FOR(i,start,end) for(ll i=start; i < end; ++i)
#define FORD(i,start,end) for(ll i=start; i < end; --i)

int main() {
  ll N;
  vl v;
  cin >> N;

  FOR(i,0,N) {
    ll x;
    cin >> x;
    v.pb(x);
  }

  sort(all(v));

  double r = v[0];
  FOR(i,1,N) {
    r = (r + v[i]) / 2;
  }

  cout << r << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

main() {
	long long int a=0,b=0,c=0,n, m, k = 0;
	char str[5],str2[5];
	
	scanf("%s%s", str,str2);
	
	if (str[0] == str2[2] && str[1] == str2[1] && str[2] == str2[0]) { printf("YES"); }
	else { printf("NO"); }
}

Measured memory_bytes: 128
def read_input():
    a, b, c, d = map(int, input().split())
    return a, b, c, d


def submit():
    a, b, c, d = read_input()

    l = a + b
    r = c + d

    if l < r:
        print('Right')
    elif l > r:
        print('Left')
    else:
        print('Balanced')


if __name__ == '__main__':
    submit()

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

typedef long long ll;
const ll mod = 1e9 + 7;
const int N=2000000;
const int M=2000;

void Run()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll a[N],b[N];
int main()
{
    Run();
    int n,cnt=0;
    cin>>n;
    for(int x=1;x<100;x++)
    {
        for(int y=1;y<100;y++)
        {
            for(int z=1;z<100;z++)
            {
                int res=x*x+y*y+z*z+z*y+z*x+x*y;
                if(res<=n)
                    b[res]++;
            }
        }
    }
    for(int x=1;x<=n;x++)
        cout<<b[x]<<endl;
}


Measured memory_bytes: 3728
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }
  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[n]);
  

  return 0;
}



Measured memory_bytes: 9600
a = [0 for i in range(6)]
b = [0 for i in range(6)]

for i in range(3):
    a[i], b[i] = map(int, input().split())
    a[i + 3] = b[i]
    b[i + 3] = a[i]

yes = False
for i in range(6):
    for j in range(6):
        for k in range(6):
            if i == j or j == k or i == k:
                continue
            #print(a[i],b[i],a[j],b[j],a[k],b[k])
            if set([a[i],b[i],a[j],b[j],a[k],b[k]]) == {1,2,3,4}:
                if b[i] == a[j] and b[j] == a[k] and a[i] != b[k]:
                    yes = True
                    break

if yes:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int d[10000000];
int main(){
  long long n,t,a=1;
  cin>>n>>t;
  r(i,0,n)cin>>d[i];
  sort(d,d+n);
  r(i,0,n){
    int p=1;
      r(j,i+1,n){
      if(d[j]-d[i]>t)break;p++;
      }
      a*=p;a=a%1000000007;
  }
  cout<<a<<endl;
}

Measured memory_bytes: 3500
/*
ID: taoxiaa1
PROG: concom
LANG: C++
*/
//URAL ID:248353QC
#include<bits/stdc++.h>
using namespace std;
//FILE *fin, *out;
//fin = fopen("money.fin", "r");
//out = fopen("money.out", "w");
//ofstream fout("money.out");
//ifstream fin("money.in");
#define ll long long
#define M 998244353
const int N=300005;
ll fac[N]={1,1},inv[N]={1,1},f[N]={1,1};
ll C(ll a,ll b){
    if(b>a)return 0;
    return fac[a]*inv[b]%M*inv[a-b]%M;
}
void init(){//快速计算阶乘的逆元
    for(int i=2;i<N;i++){
        fac[i]=fac[i-1]*i%M;
        f[i]=(M-M/i)*f[M%i]%M;
        inv[i]=inv[i-1]*f[i]%M;
    }
}
int main(){
     init();
     int n;
     scanf("%d",&n);
     ll a,b,k;
     scanf("%lld%lld%lld",&a,&b,&k);
     long long ans=0;
     for(int i=0;i<=n;i++){
          long long sum=1ll*i*a;
          if((k-sum)>=0&&(k-sum)%b==0){
               long long j=(k-sum)/b;
               if(j>n)continue;
               ans+=(C(n,i)*C(n,j));
               ans%=M;
          }
     }
     printf("%lld\n",ans);
}


Measured memory_bytes: 7296
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);
        // ビンゴの値を保持
        List<Integer> bingoList = new ArrayList<>();
        for (int i = 0; i < 9; i++) {
            int bingoNum = scan.nextInt();
            bingoList.add(i,bingoNum);
        }
        
        // 選択された値の個数を保持
        int quantity = scan.nextInt();
        // 選択された値を保持
        List<Integer> chosedNumList = new ArrayList<>();
        for (int i = 0; i < quantity; i++) {
            chosedNumList.add(scan.nextInt());
        }
        
        List<Integer> positionList = new ArrayList<>();
        for (Integer value : chosedNumList) {
            if (bingoList.contains(value)) {
                int position = bingoList.indexOf(value);
                positionList.add(position);
            }
        }
        Collections.sort(positionList);
        
        
        if (positionList.contains(0) && positionList.contains(1) && positionList.contains(2)){
            System.out.println("Yes");
        } else if (positionList.contains(0) && positionList.contains(3) && positionList.contains(6)) {
            System.out.println("Yes");
        } else if (positionList.contains(0) && positionList.contains(4) && positionList.contains(8)) {
            System.out.println("Yes");
        } else if (positionList.contains(1) && positionList.contains(4) && positionList.contains(7)) {
            System.out.println("Yes");
        } else if (positionList.contains(2) && positionList.contains(4) && positionList.contains(6)) {
            System.out.println("Yes");
        } else if (positionList.contains(2) && positionList.contains(5) && positionList.contains(8)) {
            System.out.println("Yes");
        } else if (positionList.contains(3) && positionList.contains(4) && positionList.contains(5)) {
            System.out.println("Yes");
        } else if (positionList.contains(6) && positionList.contains(7) && positionList.contains(8)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
//
// Created by yamunaku on 2020/03/08.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

mti e;
vi depth;
vi cnt;

void dfs(int x, int p, int d){
    depth[x] = d;
    cnt[d % 2]++;
    for(auto &nx:e[x]){
        if(nx == p) continue;
        dfs(nx, x, d + 1);
    }
}

int main(){
    //CFS;
    int n;
    cin >> n;
    e = mti(n);
    depth = vi(n);
    cnt = vi(2, 0);
    int a, b;
    rep(i, n - 1){
        cin >> a >> b;
        a--, b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    dfs(0, -1, 0);
    vi now(3, 0);
    now[0] = 1;
    vi k = {1, 2, 0};
    vi k1 = {1, 0};
    vi k2 = {2, 0};
    if(cnt[0] <= n / 3){
        rep(i, n){
            if(depth[i] % 2 == 0){
                cout << now[0] * 3 << " ";
                now[0]++;
            }else{
                for(auto &j:k){
                    if(3 * now[j] + j <= n){
                        cout << 3 * now[j] + j << " ";
                        now[j]++;
                        break;
                    }
                }
            }
        }
    }else if(cnt[1] <= n / 3){
        rep(i, n){
            if(depth[i] % 2 == 0){
                for(auto &j:k){
                    if(3 * now[j] + j <= n){
                        cout << 3 * now[j] + j << " ";
                        now[j]++;
                        break;
                    }
                }
            }else{
                cout << now[0] * 3 << " ";
                now[0]++;
            }
        }
    }else{
        rep(i, n){
            if(depth[i] % 2 == 0){
                for(auto &j:k1){
                    if(3 * now[j] + j <= n){
                        cout << 3 * now[j] + j << " ";
                        now[j]++;
                        break;
                    }
                }
            }else{
                for(auto &j:k2){
                    if(3 * now[j] + j <= n){
                        cout << 3 * now[j] + j << " ";
                        now[j]++;
                        break;
                    }
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 17280
using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = ("0 " + Console.ReadLine().Trim()).Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(a, n);

    }
    static void getAns(int[] a, int n)
    {
        var b = new int[n + 1];
        var ans = new List<int>();
        for (int i = n; i >= 1; i--)
        {
            var mod2 = getSum(b, n, i) % 2;
            if (a[i] != mod2) { b[i] = 1; ans.Add(i); }
        }
        var ac = ans.Count();
        if (ac == 0) Console.WriteLine(0);
        else
        {
            Console.WriteLine(ac);
            var ans2 = ans.ToArray();
            Array.Reverse(ans2);
            Console.WriteLine(string.Join(" ", ans2));
        }
    }
    static int getSum(int[] b, int n, int t)
    {
        var p = 1;
        var sum = 0;
        var t2 = t;
        while (true)
        {
            t2 = t * p++; 
            if (t2 > n) break;
            sum += b[t2];
        }
        return sum;
    }
}


Measured memory_bytes: 30424
#include<cstdio>
#include<algorithm>
using namespace std;

const int INF = 1000000000;

void solve(int n){
	static int dp[1<<16];
	int t[16][17];
	for(int i=0;i<n;i++){
		for(int j=0;j<=n;j++){
			scanf("%d",&t[i][j]);
		}
	}
	for(int S=0;S<(1<<n);S++){
		if(S==0) dp[S] = 0;
		else{
			dp[S] = INF;
			for(int i=0;i<n;i++){
				if((S>>i)&1){
					int cost = INF;
					for(int j=0;j<=n;j++) if(j-1!=i&&(j==0||(S>>(j-1))&1)) cost = min(cost,t[i][j]);
					dp[S] = min(dp[S],dp[S-(1<<i)]+cost);
				}
			}
		}
	}
	printf("%d\n",dp[(1<<n)-1]);
}

int main(){
	int n;
	while(true){
		scanf("%d",&n);
		if(n==0) break;
		else solve(n);
	}
	return 0;
}

Measured memory_bytes: 2928
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(x) (x).begin(), (x).end()
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   range(i,0,n)
#define SZ(x) ((ll)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int main() {
    ll N, X;
    cin >> N >> X;
    vector<ll> m(N);
    rep(i, N){
        cin >> m.at(i);
    }
    sort(ALL(m));
    ll s;
    s = accumulate(ALL(m), 0LL);
    ll f = m.at(0);
    ll ans = N+(X-s)/f;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int temp;
    scanf("%d", &temp);
    
    if(temp >= 30 && temp <= 40)
        printf("Yes\n");
    else if(temp >= -40 && temp < 30)
        printf("No\n");
    else
        return 1;

    return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	string s;
	cin>>n>>s;
	
	vvi cnt(10);
	REP(i,n){
		int num=s[i]-'0';
		cnt[num].push_back(i);
	}
	
	int ans=0;
	REP(i,1000){
		int a=i%10;
		int b=(i%100-a)/10;
		int c=(i-10*b-a)/100;
		
		if(cnt[a].empty() or cnt[b].empty() or cnt[c].empty()) continue;//REP.
			
		int p=cnt[c][0];
		auto itr=upper_bound(ALL(cnt[b]),p);
		if(itr==cnt[b].end()) continue;//REP.
		p=*itr;
		auto itrr=upper_bound(ALL(cnt[a]),p);
		if(itrr==cnt[a].end()) continue;//REP.
		ans++;
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int long long
#define mod 1000000007
#define maxN 1000005
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pip pair<int,pii>
#define vi vector<int>
#define vpi vector<pii >
//#define endl "\n"
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FOR(a,b,c) for(int(a) = b;a<=c;a++)
#define repr(a,b,c) for(int(a) = b;a>=c;a--)
#define rep(i,n) for(int(i) = 0;i<n;i++)
#define fir first
#define sec second
#define beg begin()
#define e end()
#define len length()
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
bool comp(pii a,pii b){
  if(a.fir != b.fir)
    return a.fir> b.fir;
  return a.sec < b.sec;
}

int32_t main()
{
   fastIO;
   int n,m;
   cin>>n>>m;
   pii arr[n];
   rep(i,n){
     cin>>arr[i].sec>>arr[i].fir;
   }
   sort(arr,arr+n,comp);
   int ans = 0;
   int mark[m+1];
   memset(mark,-1,sizeof mark);
   int last[m+1];
   FOR(i,0,m)last[i] = i-1;
   rep(i,n){
     //cout<<arr[i].sec<<' '<<arr[i].fir<<' ';
     int j = m - arr[i].sec;
     //cout<<j<<endl;
     while(j>=0){
       if(mark[j] == -1){
         mark[j] = i;
         last[j+1] = last[j];
         ans+=arr[i].fir;
         break;
       }
       if(mark[last[j]] != -1 && last[j] != -1)
        last[j] = last[last[j]];
       j = last[j];
     }
   }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 3328
K,N=map(int,input().split())
a_list=list(map(int,input().split()))
b_list=[]
for i in range(N-1):
    X=a_list[i+1]-a_list[i]
    b_list.append(abs(X))
b_list.append(K-a_list[-1]+a_list[0])
print(K-max(b_list))

Measured memory_bytes: 25452
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

#memoize macro
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

###########

n=i()
a=[]
for j in range(n):
    a.append((i(),j))
a.sort()
cnt=0
for j in range(n):
    if a[j][1]%2!=j%2:
        cnt+=1


print cnt/2


Measured memory_bytes: 18544
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,m=0,n=0,p=0,q=0;
  cin>>x;
  m=x/500;
  p=x-(m*500);
  n=p/5;
  q=(m*1000)+(n*5);
  cout<<q;
  return 0;
}

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

using namespace std;

#define int long long

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a == c) {
        cout << 0;
        return;
    }
    cout << 1;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

int main() {
  int A, B;
  int sum_down;
  int sum_up;
  int ct = 0;
  cin >> A >> B;
  for(int i=0;i<B-A+1;i++){
    sum_down = (A+i)%100;
    sum_up = ((A+i)/1000)/10+(((A+i)/1000)%10)*10;
  	if(sum_down == sum_up){
      	ct ++;	
    }
  }
  		cout << ct << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <string>
#include <map>
#include <fstream>
#include <sstream>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;


int main(){

  int T,N,D;
  cin>>T;
  rep(roop,T){
    cin>>N>>D;
    if(N==1){cout<<D<<endl;continue;}

    N--;
    if(N%2==0)cout<<N*127+D<<endl;
    else cout<<N*127+127-D<<endl;


  }



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,N;
    scanf("%d",&N);
    int ans=0x3f3f3f3f;
    for(int i=1;i<N;i++){
        int tmp=0;
        a=i,b=N-i;
        while(a){
            tmp+=a%10;
            a/=10;
        }
        while(b){
            tmp+=b%10;
            b/=10;
        }
        ans=min(ans,tmp);
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;
const int maxn = 1005;
bool cmp(char a,char b)
{
    return a>b;
}
int main()
{
 char s1[105],s2[105];
 scanf("%s%s",s1,s2);

   sort(s1,s1+strlen(s1));
   sort(s2,s2+strlen(s2),cmp);
   if(strcmp(s1,s2)>=0)
    printf("No\n");
   else
   printf("Yes\n");
    return 0;

}


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

int main(){
  string s,ans;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]!='B') ans.push_back(s[i]);
    else if(ans.size()!=0) ans.pop_back();
  }
  cout<<ans<<endl;
}

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

using namespace std;
int main(void){
    int n,l;
    string out,tmp;
    vector<string> str;

    cin >> n >> l;
    for(int i=0;i<n;i++){
        cin >> tmp;
        str.push_back(tmp);
    }

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

    for(int i=0;i<n;i++)out+=str.at(i);

    cout << out << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#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;
vint G[111111];

int deg[1111111];
bool used[111111];

signed main(){
    cin>>N;
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);G[b].pb(a);
    }

    rep(i,N)deg[i]=G[i].size();
    queue<int>que;
    rep(i,N)if(deg[i]==1){
        que.push(i);
    }

    while(que.size()){
        int v=que.front();
        used[v]=true;
        que.pop();
        for(auto u:G[v]){
            if(!used[u]){
                v=u;
                break;
            }
        }

        used[v]=true;
        for(auto u:G[v]){
            if(used[u])continue;
            if(deg[u]==1){
                puts("First");
                return 0;
            }
            deg[u]--;
            if(deg[u]==1){
                que.push(u);
            }
        }
    }

    puts("Second");
    return 0;
}


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

using namespace std;
#define ll long long

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

    int n;
    cin>>n;

    vector<int> arr(n);

    for(int i=0;i<n;i++)
        cin>>arr[i];

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

    ll res = 0;
    int j = 1;

    while(j <n)
    {
        int temp = (j /2); 
        res += arr[n - 1 - temp];
        j++;
    }

    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <queue>
#include <map>
using namespace std;

struct NODE{
	int x,cost;
	NODE(int x,int cost) : x(x) ,cost(cost) {}
};
bool operator <(const NODE &a,const NODE &b){
	return a.cost > b.cost;
}

map<int, vector<NODE> > cost;

int main(){
	int L,n;
	cin >> L >> n;
	vector<int> vertex;
	vertex.push_back(0);
	vertex.push_back(L);
	
	for(int i = 0 ; i < n ; i++){
		int a,b,c;
		cin >> a >> b >> c;
		cost[a].push_back(NODE(b,c));
		vertex.push_back(a);
	}
	priority_queue<NODE> Q;
	map<int,int> memo;
	Q.push(NODE(0,0));
	while( Q.size() ){
		NODE q = Q.top(); Q.pop();
		if( memo[q.x]++ ) continue;
		if( q.x > L ) continue;
		if( q.x == L ){
			cout << q.cost << endl;
			return 0;
		}
		for(int i = 0 ; i < vertex.size() ; i++){
			if( vertex[i] > q.x ){
				Q.push(NODE(vertex[i],q.cost+vertex[i]-q.x));
			}
		}
		for(int i = 0 ; i < cost[q.x].size() ; i++){
			Q.push(NODE(q.x+cost[q.x][i].x,q.cost+cost[q.x][i].cost));
		}
	}
}


Measured memory_bytes: 10472
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

// VMAX is the maximum value of element in progression.
const VMAX = 10000

func main() {
	fmt.Println(answer(os.Stdin))
}

func answer(r io.Reader) string {
	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	// A[0], B[0] and C[0] won't be used due to handling the inconsistency
	// between the size of slice and its number of element.
	A, B := make([]int, n+1), make([]int, n+1)
	C := make([]int, VMAX+1)
	for i := 0; i < n; i++ {
		sc.Scan()
		A[i+1], _ = strconv.Atoi(sc.Text())
		C[A[i+1]]++
	}

	countingSort(A, C, &B, n)
	return String(B)
}

func countingSort(A, C []int, B *[]int, n int) {
	for i := 1; i <= VMAX; i++ {
		C[i] += C[i-1]
	}

	for j := 1; j <= n; j++ {
		(*B)[C[A[j]]] = A[j]
		C[A[j]]--
	}
}

func String(B []int) string {
	// trim junk element B[0] when stringifying the entire elements of progression.
	return strings.Trim(fmt.Sprint(B[1:])[1:], "[]")
}



Measured memory_bytes: 75636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max(a*b,c*d) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
int n;
inline int pow(int x)
{
	int res(1);
	while(x--)
		res<<=1;
	return res;
}
signed main()
{
	scanf("%d",&n);
	for(register int i(6);i>=0;i--)
		if(pow(i)<=n)
			return printf("%d\n",pow(i)),0;
}

Measured memory_bytes: 128
// ABC 59 C

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

typedef long long ll;

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; }
const long long INF = 1LL<<60;

ll foo(const vector<ll>& a, bool oddPositive)
{
  size_t n = a.size();

  vector<ll> b1(n);
  ll ans = 0;
  b1[0] = a[0];
  if (oddPositive && a[0] <= 0) {
    b1[0] = 1;
    ans += abs(a[0]) + 1;
  }

  if (!oddPositive && a[0] >= 0) {
    b1[0] = -1;
    ans += abs(a[0]) + 1;
  }

  for (int i = 1; i < n; i++) {
    if ((b1[i-1] + a[i]) * b1[i-1] < 0) {
      b1[i] = b1[i-1] + a[i];
      continue;
    }
    if (a[i] + b1[i-1] == 0) {
      ans += 1;
    } else if (b1[i-1] * a[i] > 0) {
      // a[i], b[i-1] の符号が同じ
      ans += abs(a[i]) + abs(b1[i-1]) + 1;
    } else {
      // a[i], b[i-1] の符号が逆
      ans += abs(b1[i-1]) - abs(a[i]) + 1;
    }
    b1[i] = b1[i-1] < 0 ? 1 : -1;
  }

  return ans;
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    ll tmp = 0;
    cin >> tmp;
    a[i] = tmp;
  }

  ll ans1 = foo(a, true);   // 奇数番目が正の数
  ll ans2 = foo(a, false);  // 奇数番目が負の数

  cout << min(ans1, ans2) << endl;

  return 0;
}


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

  return 0;
}



Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int table[90][90];
int m,n;
int search(int i, int j)
{
	table[i][j]=false;
	int di[]={0,-1,0,1};
	int dj[]={-1,0,1,0};
	int ret=1;
	for(int k=0;k<4;k++){
		int x=i+di[k];
		int y=j+dj[k];
		if(0<=x&&x<n&&0<=y&&y<m&&table[x][y]){
			ret=max(ret, 1+search(x,y));
		}
	}
	table[i][j]=true;
	return ret;
}
void exec()
{
	cin >> m >> n;
	if(m==0&&n==0)exit(0);
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> table[i][j];
		}
	}
	int ret=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(table[i][j]){
				ret=max(ret,search(i,j));
			}
		}
	}
	cout << ret << endl;
}
int main() {
	while(1)exec();
}

Measured memory_bytes: 1188
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

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

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

    Int d, t, s;
    cin >> d >> t >> s;

    if (d <= t * s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3660
h, w = map(int, input().split())
a = []
for i in range(h):
    a.append(input())
for i in range(w+1):
    print('#',end='')
print('#')
for i in range(h):
    print('#',end='')
    print(a[i],end='')
    print('#')
for i in range(w+1):
    print('#',end='')
print('#')

Measured memory_bytes: 3064
//#define DEB1 //input from input.txt
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
//const int MX = 31001;
//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


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


/*
constant values
*/

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


// Main program
void solve(){
    LL a,b,c;
    cin >> a >> b >> c;
    LL r = c - a - b;
    if(r <= 0){
        cout << "No" << endl;
    }else if(r*r - 4*a*b <= 0){
        cout << "No" << endl;    
    }else{
        cout << "Yes" << endl;
    }

    return;
}

// ----------------------------------------------
int main(){

#ifdef DEB1
    cout << "DEBUG MODE"  << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf()); //for debug
#endif

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	int a[100];
	int i, j;
	int minj;
	int count;
	int tmp;
	count = 0;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	
	for (i = 0; i < n; i++){
		minj = i;
		for (j = i; j < n; j++){
			if (a[minj] > a[j]){
				minj = j;
			}
		}
		if (minj != i){
			tmp = a[minj];
			a[minj] = a[i];
			a[i] = tmp;
			count++;
		}
	}

	for (i = 0; i < n - 1; i++){
		printf("%d ", a[i]);
	}
	printf("%d\n", a[n - 1]);
	printf("%d\n", count);
	
	return 0;
}

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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

 bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            return false;
        }
    }
    return true;
}

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

    vector<int> wa(n, 0);
    vector<bool> ok(n, false);
    for(ll i = 0; i < m; i++){
        ll p = 0;
        string s;
        cin >> p >> s;
        p--;

        if(s == "WA"){
            if(!ok[p]){
                wa[p]++;
            }
        }else{
            if(!ok[p]){
                ok[p] = true;
            }
        }
    }

    ll ansa = 0, answ = 0;
    for(ll i = 0; i < n; i++){
        ansa += (ok[i] == true);
        if(ok[i]){
            answ += wa[i];
        }
    }
    cout << ansa << " " << answ << endl;
    return 0;
}

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

const long long MOD = 998244353;

long long mod_pow(long long x, long long n) {
  if (n == 0)
    return 1;
  return n % 2 == 1 ? mod_pow(x * x % MOD, n / 2) * x % MOD
                    : mod_pow(x * x % MOD, n / 2);
}

int main() {
  int N;
  cin >> N;
  vector<long long> D(N);
  for (int i = 0; i < N; ++i) {
    cin >> D[i];
  }

  map<long long, int> m;
  for (int i = 0; i < N; ++i) {
    ++m[D[i]];
  }

  long long ans = D[0] == 0 && m[0] == 1 ? 1 : 0;
  for (size_t i = 2; i < m.size(); ++i) {
    ans = ans * mod_pow(m[i - 1], m[i]) % MOD;
  }

  cout << ans << endl;
}


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

// DPテーブル
const int MAX_W = 110000;
int dp[MAX_W];

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

    // 品物を列挙 (価値はすべて 1)
    vector<int> weight;
    for (int i = 1; i <= W; i *= 6) weight.push_back(i);
    for (int i = 9; i <= W; i *= 9) weight.push_back(i); // 1 が重複しないように (しても問題はない)
    int n = (int)weight.size();

    // DP初期条件: dp[i][0] = 0
    for (int w = 0; w < MAX_W; ++w) dp[w] = 1 << 29; // INF
    dp[0] = 0;

    // DPループ
    for (int i = 0; i < n; ++i) {
        for (int w = weight[i]; w <= W; ++w) {
            dp[w] = min(dp[w], dp[w - weight[i]] + 1);
        }
    }

    cout << dp[W] << endl;
}

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

#define rp(i, k, n) for (ll i = k; i < n; i++)
#define ll  long long

ll mod = 1e9 + 7;

int main() {
    int x;
    cin >> x;
    if (x == 3 || x == 5 || x == 7) {
        printf("YES");
        return 0;
    } else {
        printf("NO");
        return 0;
    }
}


Measured memory_bytes: 256
s = int(input())
def f(x):
    if x%2 == 0:
        return int(x/2)
    else:
        return int(3*x+1)
a =[s]
for i in range(1,1000000):
    b = f(a[i-1])
    if b in a:
        print(i+1)
        break
    else:
        a.append(b)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int a,b;
	cin >> a >> b;
	
	const int MAX_H = 100 , MAX_W = 100;

	char c[MAX_H][MAX_W];

	rep(i,0,MAX_H/2){
		rep(j,0,MAX_W){
			c[i][j] = '.';	
		}
	}
	
	a--;

	rep(i,MAX_H/2,MAX_H){
		rep(j,0,MAX_W){
			c[i][j] = '#';	
		}
	}
	b--;

	for(int i = 0 ; i < MAX_H - 1 && b ; i+=2 ){
		for(int j = 0 ; j < MAX_W ; j+=2 ){
			c[i][j] = '#';
			b--;
			if(!b)
				break;
		}	
		
	}	
	
	for(int i = MAX_H/2 + 1 ; i < MAX_H && a; i+=2 ){
		for(int j = 0 ; j < MAX_W ; j+=2 ){
			c[i][j] = '.';	
			a--;
			if(!a)
				break;
		}	
	}	

	cout << MAX_H << " " << MAX_W << endl;
	rep(i,0,MAX_H){
		rep(j,0,MAX_W)
			cout << c[i][j];

		P("");
	}
	
	ret 0;
}

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

int main(void)
{
  int n;
  std::cin >> n;

  int a=0, w=0, t=0, r=0;
  for (int i = 0; i < n; i++) {
    std::string ans;
    std::cin >> ans;

    if (ans == "AC") {
      a++;
    }
    else if (ans == "WA") {
      w++;
    }
    else if (ans == "TLE") {
      t++;
    }
    else {
      r++;
    }
  }

  std::cout << "AC x " << a << std::endl;
  std::cout << "WA x " << w << std::endl;
  std::cout << "TLE x " << t << std::endl;
  std::cout << "RE x " << r << std::endl;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    for (int i = 0; i < a; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> q[i];
    }
    for (int i = 0; i < c; i++) {
        cin >> r[i];
    }
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend());
    vector<int> v;
    ll ans = 0;
    for (int i = 0; i < min(a, x); i++) {
        v.push_back(p[i]);
    }
    for (int i = 0; i < min(b, y); i++) {
        v.push_back(q[i]);
    }
    for (int i = 0; i < c; i++) {
        v.push_back(r[i]);
    }
    sort(v.rbegin(), v.rend());
    for (int i = 0; i < x + y; i++) {
        ans += v[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int R=0, G=0;
  
  cin >> R;
  cin >> G;
  
  if( ( 0 > R ) || ( 4500 < G ) ){
  	return -1;
  }
  
  cout << 2 * G - R << endl;
  
  return 0;
}

Measured memory_bytes: 256