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

#define mp make_pair
#define pb push_back
#define x first
#define y second
#define all(a) (a).begin(), (a).end()
typedef long long ll;

template<class A, class B> bool mmin(A& a, B b) {if (b < a) {a = b; return 1;} return 0;}
template<class A, class B> bool mmax(A& a, B b) {if (b > a) {a = b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        b[i]--;
    }
    vector<int> ans;
    for (int i = n; i >= 1; i--) {
        int ind = -1;
        for (int j = 0; j < i; j++) {
            if (j == b[j]) ind = j;
        }
        if (ind == -1) {
            cout << "-1\n";
            return 0;
        }
        ans.pb(ind + 1);
        vector<int> now;
        for (int j = 0; j < i; j++) {
            if (j != ind) now.pb(b[j]);
        }
        b = now;
    }
    reverse(all(ans));
    for (auto z : ans) cout << z << '\n';
    return 0;
}


Measured memory_bytes: 3632
from collections import deque
n, m, k = map(int, input().split())
friend = [set() for _ in range(n + 1)]
block = [set() for _ in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    friend[a].add(b)
    friend[b].add(a)
for i in range(k):
    a, b = map(int, input().split())
    block[a].add(b)
    block[b].add(a)
stack = deque()
ans = [0]*(n+1)
visited = [0]*(n+1)
for i in range(1, n+1):
    if visited[i]:
        continue
    link = {i}
    visited[i] = 1
    stack.append(i)
    while stack:
        n = stack.pop()
        for j in friend[n]:
            if visited[j] == 0:
                stack.append(j)
                visited[j] = 1
                link.add(j)
    for i in link:
        ans[i] = len(link) - len(link & friend[i]) - len(link & block[i]) -1
print(*ans[1:])

Measured memory_bytes: 80700
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  lint N,K;
  cin >> N >> K;
  lint max=((N-1)*(N-2))/2;
  if(K>max) cout << "-1" << endl;
  else{
    cout << N-1+(max-K) << endl;
    rep(i,N-1) cout << 1 << " " << i+2 << endl;;
    lint count=max-K;
    if(count!=0){
      for(int i=2;i<=N-1;i++){
        for(int j=i+1;j<=N;j++){
          cout << i << " " << j << endl;
          count--;
          if(count==0) break;
        }
        if(count==0) break;
      }
    }
  }
}

Measured memory_bytes: 256
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
S = gets.chomp

count = 0
S.split('').each_cons(3) do |arr|
  count += 1 if arr.join == 'ABC'
end

puts count


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

const int MX = 10000;
const int MOD = 1000000007;

long long fac[MX], finv[MX], inv[MX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int s;
    cin >> s;
    COMinit();
    
    int div = s / 3;
    ll sum = 0;
    
   	rep(i,div){
        if(i == 0){
            sum += 1;
        }else{
            int a = s + 1 - 4 - 2*i;
            sum += COM(a, i);
            sum %= MOD;
        }

    }
    cout << sum << endl;
    return 0;
}

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

#define up(i,j,k) for (int i = (j); i <= (k); i++)
#define down(i,j,k) for (int i = (j); i >= (k); i--)
#define DEBUG printf("Passing [%s] in LINE %d\n", __FUNCTION__, __LINE__)

#define lb long double
#define ll long long
#define ull unsigned long long

#define mp std::make_pair
#define pb push_back

#define all(x) (x).begin(), (x).end()
#define mem(a) memset((a), 0, sizeof(a))
#define File(x)                       \
    freopen("" #x ".in", "r", stdin); \
    freopen("" #x ".out", "w", stdout);

#define int long long

inline int read() {
    int data = 0, w = 1; char ch = 0;
    while (ch != '-' && (ch > '9' || ch < '0')) ch = getchar();
    if (ch == '-') w = -1, ch = getchar();
    while (ch >= '0' && ch <= '9') { data = data * 10 + ch - '0'; ch = getchar(); }
    return data * w;
}

inline void print (int v) {
    if (v < 0) { putchar('-'); v = -v; }
    if (v > 9) print(v / 10);
    putchar(v % 10 + '0');
}

const int N = 200000 + 10;

int n, m;
int f[N], d[N];

int fi (int x) {
    if (x ^ f[x]) { int t = f[x]; f[x] = fi(f[x]); d[x] += d[t]; }
    return f[x];
}

signed main () {
    n = read(); m = read();
    int l, r, fl, fr, x;
    up (i, 1, n) f[i] = i;
    up (i, 1, m) {
        l = read(); r = read(); x = read();
        fl = fi(l); fr = fi(r);
        if (fl == fr && d[l] - d[r] != x) { return puts("No"), 0; }
        if (fl ^ fr) {
            f[fl] = fr;
            d[fl] = x + d[r] - d[l];
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 1792
l=[]
for i in range(0,120):
    l.append(i**5)
n=int(input())
for i in range(0,120):
    if((l[i]-n) in l):
        print(i,l.index(l[i]-n))
        break
    elif((n-l[i]) in l):
        print(i,-l.index(-l[i]+n))
        break

        
    

Measured memory_bytes: 9048
#include<cstdio>
#include<cstring>
#include<cstdlib>

using namespace std;

int top, S[200];

bool isFull(){
    return top == 200;
}

bool isEmpty(){
    return top == 0;
}

void push(int x){
    top++;
    S[top] = x;
}

int pop(){
    return S[top--];
}

int main(){
    int a,b;
    top = 0;
    char s[100];
    while( scanf("%s", s) != EOF){
        if(s[0]  == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }else if(s[0] == '-'){
            a = pop();
            b = pop();
            push(b-a);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }else{
            push(atoi(s));
        }
    }

    printf("%d\n", pop());

    return 0;
}


Measured memory_bytes: 2740
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

LL mod = 1e9 + 7;

int n, m, k;
char a[10][10];

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif

  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%s", a[i]);
  }

  int ans = 0;
  for (int r = 0; r < (1 << n); r++) {
    for (int c = 0; c < (1 << m); c++) {
      int p = 0;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (a[i][j] == '#' && ((r >> i) & 1) == 0 && ((c >> j) & 1) == 0) {
            p += 1;
          }
        }
      }
      if (p == k) {
        ans += 1;
      }
    }
  }
  printf("%d\n", ans);


  
  
#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#pragma GCC optimize("O3")
#pragma GCC target("avx2,bmi,bmi2,lzcnt")
// 1 - indexed
template <typename T>
struct BIT
{
   vector<T> bit;

   BIT(int sz) : bit(sz + 1, 0) {}

   // sum of [1, k]
   T sum(int k)
   {
      T res = 0;
      for (int x = k; x > 0; x -= x & -x)
         res += bit[x];
      return res;
   }

   void add(int k, T w)
   {
      for (int x = k; x < bit.size(); x += x & -x)
         bit[x] += w;
   }

   // sum of [x, y)
   T getSum(int x, int y)
   {
      return sum(y - 1) - sum(x - 1);
   }

   // find an index i s.t. a[1] + a[2] + ⋯ + a[x] ≧ w
   T lower_bound(T w)
   {
      if (w <= 0)
         return 0;

      T x = 0;
      int p = 1, N = bit.size();

      while (2 * p <= N)
         p *= 2;

      for (T k = p; k > 0; k /= 2)
      {
         if (x + k <= N && bit[x + k] < w)
         {
            w -= bit[x + k];
            x += k;
         }
      }

      return x + 1;
   }
};

int main()
{
   fast();

   int N, Q;
   cin >> N >> Q;
   vector<int> c(N + 1);
   for (int i = 0; i < N; i++)
      cin >> c[i + 1];

   vector<vector<pair<int, int>>> queries(N + 1, vector<pair<int, int>>());

   for (int i = 0, l, r; i < Q; i++)
   {
      cin >> l >> r;
      queries[l].emplace_back(r, i);
   }

   vector<priority_queue<int, vector<int>, greater<int>>> pos(N + 1);

   for (int i = 1; i <= N; i++)
      pos[c[i]].push(i);

   BIT<int> bit(N);

   for (int i = 1; i <= N; i++)
   {
      if (pos[i].empty())
         continue;
      bit.add(pos[i].top(), 1);
      pos[i].pop();
   }

   vector<int> ans(Q);

   for (int l = 1; l <= N; l++)
   {
      for (auto q : queries[l])
      { // 左端がlのクエリ
         int R = q.first + 1, ind = q.second;
         ans[ind] = bit.getSum(l, R);
      }

      if (pos[c[l]].empty())
         continue;

      int nxt = pos[c[l]].top();
      pos[c[l]].pop();
      bit.add(nxt, 1);
   }

   for (int i = 0; i < Q; i++)
      cout << ans[i] << "\n";
}

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

int main() {
  ll n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  sort(x.begin(), x.end());
  
  int sum = accumulate(x.begin(), x.end(), 0);
  int base1 = sum / int(x.size());
  int base2 = sum / int(x.size()) + 1;
  
  int ans1 = 0;
  int ans2 = 0;
  rep(i, x.size()) {
    ans1 += pow(x[i] - base1, 2);
    ans2 += pow(x[i] - base2, 2);
  }
  
  int ans = min(ans1, ans2);
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char t1[1510];
char t2[1510];
char t3[1510];
int main(){
	int n;
	int a,b;
	int i,j;
	char t;
	scanf("%s",&t1);
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",&t3);
		if(strcmp(t3,"replace")==0){
			scanf("%d %d %s",&a,&b,&t2);
			for(j=0;j<b-a+1;j++){
				t1[a+j]=t2[j];
			}
		}
		else if(strcmp(t3,"reverse")==0){
			scanf("%d %d",&a,&b);
			while(a<b){
				t=t1[a];
				t1[a]=t1[b];
				t1[b]=t;
				a++;
				b--;
			}
		}
		else if(strcmp(t3,"print")==0){
			scanf("%d %d",&a,&b);
			for(j=a;j<b+1;j++){
				printf("%c",t1[j]);
			}
			puts("");
		}
	}
	return 0;
}



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

int main()
{
    int n;cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    for(int i=0;i<n;i++){
        if(a[i]==b[n-1]){cout<<b[n-2]<<endl;}
        else{cout<<b[n-1]<<endl;}
    }
    
}


Measured memory_bytes: 3200
def bfs(ini, g)
  dist = Array.new(g.length,-1)
  dist[ini] = 0
  queue = [ini]
  while !queue.empty?
    v = queue[0]
    queue.shift
    g[v].each{|des|
      if dist[des] == -1
        dist[des] = dist[v] + 1
        queue.push(des)
      end
     }
   end
   dist
end

n,x,y = gets.chomp.split(" ").map(&:to_i)
g = Array.new(n).map{Array.new}
(n-1).times do |i|
  g[i].push(i+1)
  g[i+1].push(i)
end
g[x-1].push(y-1)
g[y-1].push(x-1)
ans = Array.new(n,0)
n.times do |i|
  bfs(i,g).each do |z|
    ans[z] += 1
  end
end

(n-1).times do |i|
  puts ans[i+1]/2
end

Measured memory_bytes: 45728
sx, sy, tx, ty = map(int,input().split())
print("U"*abs(ty-sy)+"R"*abs(tx-sx),end="")
print("D"*abs(ty-sy)+"L"*abs(tx-sx),end="")
print("L"+"U"*abs(ty-sy+1)+"R"*abs(tx-sx+1)+"D",end="")
print("R"+"D"*abs(ty-sy+1)+"L"*abs(tx-sx+1)+"U")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using ll = long long;
#define ALL(a)  (a).begin(),(a).end()
#define REP(y) for(ll i=0;i<(y);i++)

using namespace std;
int main(){
ll n,t,a;
cin>>n>>t>>a;
vector<pair<double,ll>> h;
REP(n){
  ll tmp;
  cin>>tmp;;
  h.emplace_back(tmp,i);
}
REP(n){
h[i].first= double(abs(a-(t-h[i].first*0.006)));
}
sort(ALL(h));
cout<<h[0].second+1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
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; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll n,x;
    cin>>n>>x;
    chmax(x,n-x);
    ll ans=0;
    ll now=x;
    ans+=now;
    now=n-now;
    ans+=((n/now)*2-1)*now;
    if(n%now==0) {
        ans-=now;
        cout<<ans<<endl;
        return 0;
    }
    ll pre=now;
    now=n%now;
    while(now>0) {
        //cout<<pre<<" "<<now<<" "<<ans<<endl;
        ans+=((pre/now)*2)*now;
        if(pre%now==0) ans-=now;
        ll tmp=pre;
        pre=now;
        now=tmp%now;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/*********************
*@Author:   CKang *
*@Language: C++11    *
*********************/
#include<bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
//#define DEBUG
#define RI register int
#define endl "\n"

using namespace std;

typedef long long ll;
//typedef __int128 lll;
//const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-9;
const int INF = 0x3fffffff;
const ll LINF = 0x3fffffffffffffff;

inline ll read(){
    long long x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

int main()
{
#ifdef DEBUG
    freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout)
#endif
    //cout.tie(0);
    //ll t = read() ;
    //while(t--){}
    ll n=read(),m=read(),sum=0,ans=0;
    ll num[105]={0};
    for(int i=0;i<n;i++){

        num[i]=read();
        sum+=num[i];

    }

    sort(num,num+n);

    for(int i=0;i<n;i++){
        if(num[i]>=(sum/4.0/m))ans++;
    }

    if(ans>=m)printf("Yes");
    else printf("No");

#ifdef DEBUG
    printf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif
    //cout << "Fuck You !" << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
const int MAXN = 100100;

int N, A, B;
vector <int> edge[MAXN];
int dep[MAXN];
int par[MAXN];
int md[MAXN];

void gogo (int cloc, int last, int cd)
{
    par[cloc] = last;
    dep[cloc] = cd;
    md[cloc] = 0;
    for (int neigh : edge[cloc])
    {
        if (neigh == last) continue;
        gogo (neigh, cloc, cd + 1);
        md[cloc] = max (md[cloc], md[neigh] + 1);
    }
}

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N >> A >> B;
    A--, B--;

    for (int i = 0; i < N - 1; i++)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }

    gogo (B, -1, 0);

    int gd = dep[A];
    int nt = (gd - 1) / 2;
    for (int i = 0; i < nt; i++)
        A = par[A];
    cout << dep[A] + md[A] - 1<< "\n";
}

Measured memory_bytes: 13312
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, K, x;
    cin >> N >> K;
    int res = 0;
    REP(i, N) {
        cin >> x;
        res += 2 * min(x, abs(x - K));
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a;
    string str,Hoshino="Hoshino";
    cin>>n;
    getline(cin,str);
    for(int i=0;i<n;i++){
        getline(cin,str);
        for(int j=0;str[j]!='\0';j++){
            if(str[j]=='H'){
                for(int k=j;k<7+j;k++){
                    if(str[k]!=Hoshino[k-j])break;
                    if(k==j+6)str[k]='a';
                }
            }
        }
        cout<<str<<endl;
    }
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

#define vin(v, N) for (long long i = 0; i < N; i++) cin >> v.at(i)
#define lin(n) long long n; cin >> n
#define chin(x) char x; cin >> x;
#define sin(s) string s; cin >> s;
#define vlin(v, N) vector<long long> v(N); for (long long i = 0; i < N; i++) cin >> v.at(i)

int main(){
    int N;
    cin >> N;
    vector<vector<ll int>> xy(N);
    vector<int> ind(N);
    iota(ind.begin(), ind.end(), 0);

    for(int i = 0; i < N; ++i){
        xy[i].resize(2);
        cin >> xy[i][0] >> xy[i][1];
    }
    double ans = 0.0;
    ll cnt = 0;
    do{
        for(int i = 1; i < N; ++i){
            ans += sqrt(pow(xy[ind[i]][0] - xy[ind[i-1]][0], 2) + pow(xy[ind[i]][1] - xy[ind[i-1]][1], 2));
        }
        cnt++;
    } while (next_permutation(ind.begin(), ind.end()));
    printf("%.10lf", ans/cnt);
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b)
    {
      printf("a < b\n");
	}
  if(a>b)
    {
      printf("a > b\n");
    }
  if(a==b)
    {
      printf("a == b\n");
	}
  return 0;
}

Measured memory_bytes: 1008
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        boolean[] p =new boolean[123456*2+1];
        Arrays.fill(p, true);
        p[0] = false;
        p[1] = false;
        
        for(int i = 2; i<p.length; i++){
            for(int j = 2; i*j <p.length; j++){
                if(!(p[i]))break;
                else
                    p[i*j] = false;
            }
        }
        
        int[] m = new int[p.length];
        m[0] = 0;
        
        for(int i = 1; i<m.length; i++){
            if(p[i])
                m[i] = m[i - 1] + 1;
            else
                m[i] = m[i - 1];
        }
        
        int n = sc.nextInt();
        while(n !=0){
            System.out.println(m[2*n]-m[n]);
            n = sc.nextInt();
        }
    
    }
}
        

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

int main() {
    int n, x;
    for (;;) {
        int count = 0;
        cin >> n >> x;
        if (n == 0&& x == 0)break;
            for (int i = 1; i <= n-2; i++) {
                for (int j = i + 1; j <= n-1; j++) {
                    for (int k = j + 1; k <= n; k++) {
                        if (i + j + k == x) { count++; }
                    }
                }
            }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
const int N = 2005;
const int mod = 1e9 + 7;
int n, m, fa[N];
ll x, ans, val[N], mn;
struct node{int x, y, z;}e[N];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
ll ksm(ll x, int y)
{
	ll res = 1;
	for(; y; y >>= 1, x = x * x % mod)
		if(y & 1) res = res * x % mod;
	return res;
}
int find(int x) {return fa[x] == x ? x : fa[x] = find(fa[x]);}
bool cmp(const node & a, const node & b) {return a.z < b.z;}
ll get(int k)
{
	ll res = 0;
	for(int i = 1; i <= m; i ++)
	{
		int x = find(e[i].x), y = find(e[i].y);
		if(x == y) continue;
		fa[x] = y; res += e[i].z; k ++;
		if(k == n - 1) break;
	}
	return res;
}
void init() {for(int i = 1; i <= n; i ++) fa[i] = i;}
int main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); m = read(); scanf("%lld", &x);
	for(int i = 1; i <= m; i ++) e[i].x = read(), e[i].y = read(), e[i].z = read();
	sort(e + 1, e + m + 1, cmp); init(); mn = get(0);
	if(mn > x) {printf("0\n"); return 0;}
	if(mn == x) ans = (ksm(2, n - 1) - 2) * ksm(2, m - n + 1) % mod;
	for(int i = 1; i <= m; i ++) init(), fa[e[i].x] = e[i].y, val[i] = get(1) + e[i].z;
	sort(val + 1, val + m + 1);
	for(int i = n; i <= m; i ++) if(val[i] == x) ans = (ans + ksm(2, m - i + 1)) % mod;
	printf("%lld\n", ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64; 
long long const INF = 1e18 + 42;
 
 
int main(){
	fast;
	i64 n, k;
    cin >> n >> k;
    i64 zer = 0;
    vector<i64> pos, neg;
    for (int i = 0; i < n; ++i) {
        int x; cin >> x;
        zer += x == 0;
        if (x > 0) pos.push_back(x);
        if (x < 0) neg.push_back(-x);
    }
    sort(ALL(pos));
    sort(ALL(neg));
    auto cnt = [&] (i64 x) {
        if (x == 0) {
            return (i64) SZ(pos) * SZ(neg);
        }
        i64 res = 0;
        if (x > 0) {
            res = (i64) SZ(pos) * SZ(neg);
            res += (i64) zer * (n - zer);
            res += (i64) zer * (zer - 1) / 2;
            int r = 0;
            for (int i = SZ(pos) - 1; i >= 0; --i) {
                 while (r < i && pos[r] * pos[i] < x) {
                    ++r;
                }
            res += min(i, r);
            }
            r = 0;
            for (int i = SZ(neg) - 1; i >= 0; --i) {
                while (r < i && neg[r] * neg[i] < x) {
                    ++r;
                }
                res += min(i, r);
            }
        } else {
            int r = SZ(neg) - 1;
            for (int i = 0; i < SZ(pos); ++i) {
                 while (r >= 0 && pos[i] * neg[r] > -x) {
                    --r;
                }
                res += SZ(neg) - r - 1;
            }
        }
        return res;
    }; 
    i64 lo = -INF, hi = INF;
    while (lo < hi) {
        i64 md = lo + (hi - lo + 1) / 2;
        if (cnt(md) >= k) hi = md - 1;
        else lo = md;
    }     
    cout << lo << '\n';
	
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define fastio() ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef long double ld;

const int maxn = 83, maxs = 80*80*2 + 5, dif = 80*80+1;
bitset<maxs> dp[maxn][maxn];
int n, m, mat[maxn][maxn][2];

int main(){
	scanf("%d %d", &n, &m);
	for(int x = 0; x<=1; x++){
		for(int i = 1; i<=n; i++){
			for(int j = 1; j<=m; j++) scanf("%d", &mat[i][j][x]);
		}
	}
	for(int i = 1; i<=n; i++){
		for(int j = 1; j<=m; j++){
			int t1 = mat[i][j][0], t2 = mat[i][j][1];
			mat[i][j][0] = t1-t2;
			mat[i][j][1] = t2-t1;
		}
	}
	dp[1][1][mat[1][1][0]+dif] = dp[1][1][mat[1][1][1]+dif] = 1;
	for(int i = 1; i<=n; i++){
		for(int j = 1; j<=m; j++){
			for(int x = 0; x<=1; x++){
				if (mat[i+1][j][x]<0) dp[i+1][j] |= (dp[i][j] << abs(mat[i+1][j][x]));
				else dp[i+1][j] |= (dp[i][j] >> mat[i+1][j][x]);
				
				if (mat[i][j+1][x]<0) dp[i][j+1] |= (dp[i][j] << abs(mat[i][j+1][x]));
				else dp[i][j+1] |= (dp[i][j] >> mat[i][j+1][x]);
			}
		}
	}
	int ans = 1e9+7;
	for(int s = 0; s<maxs; s++) if (dp[n][m][s]) ans = min(ans, abs(s-dif));
	printf("%d\n", ans);	
	return 0;
}


Measured memory_bytes: 10880
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Pair> list = new ArrayList<Pair>();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            list.add(new Pair(a, (i + 1)));
        }
        Collections.sort(list);
        int cnt = 0;
        for (Pair p : list) {
            System.out.print(p.value);
            cnt++;
            if (cnt != n) {
                System.out.print(" ");
            }
        }

    }
}

class Pair implements Comparable<Pair> {
    // key , value 昇順ソート
    int key;
    int value;

    Pair(int key, int value) {
        this.key = key;
        this.value = value;
    }

    @Override
    public int compareTo(Pair other) {
        if (this.key == other.key) {
            return this.value - other.value;
        }
        return this.key - other.key;
    }
}


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

using namespace std;
typedef long long ll;

int a[100001];

int main(void) {
    int n;
    scanf("%d", &n);
    for(int i=0 ;i<n; i++) scanf("%d", a+i);
    sort(a, a+n);
    int diff = 1e9+1, ans;
    int half = a[n-1]/2;

    for(int i=0; i<n-1; i++) {
        int tmp;
        if(n%2) tmp = min(abs(half - a[i]), abs(half + 1 - a[i]));
        else    tmp = abs(half - a[i]);
        if(diff > tmp) {
            diff = tmp;
            ans = a[i];
        }
    }

    return !printf("%d %d\n", a[n-1], ans);
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    
	  Scanner sc = new Scanner(System.in);
	  int x = sc.nextInt();
	  
	  int y = sc.nextInt();
	  
	  int menseki = x*y;
	  int shuu = 2*(x + y);
	  
	  System.out.println(menseki +" "+ shuu);
	 
	  
  }
}

Measured memory_bytes: 26356
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

bool isOK(int a[], int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int binary_search(int a[], int nax, int key){
    int ng = -1;
    int ok =nax;
    while(abs(ok-ng) > 1){
        int mid = (ok + ng)/2;
        if(isOK(a,mid,key))ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
	int N; cin>>N;
	int L[2020];
	rep(i,N)cin>>L[i];
	sort(L,L+N);
	ll ans = 0;
	rep(i,N){
		for(int j = i+1; j<N; ++j){
			int r = binary_search(L,N,L[i]+L[j]);
			int l = binary_search(L,N,abs(L[i]-L[j])+1);
			int e_ans = r-l;
			if(r>i && i>=l)--e_ans;
			if(r>j && j>=l)--e_ans;
			// printf("[i,j]->[%d,%d] [min,max]->[%d,%d] [l,r]->[%d,%d] [e_ans]->[%d]\n"
			// 	,L[i], L[j], L[j]-L[i], L[i]+L[j], l,r,e_ans);
			ans += e_ans;
		}
	}
	cout<<ans/3<<endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    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
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 << 61;

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

bool isOK(const vector<Int> &A, Int index, Int key) {
    if (A[index] <= key) {
        return true;
    } else {
        return false;
    }
}

Int b_search(const vector<Int> &A, Int key) {
    Int ng = (Int)A.size();
    Int ok = -1;

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

        if (isOK(A, mid, key)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    return ok;
}

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

    Int n, m, k;
    cin >> n >> m >> k;
    vector<Int> a(n), b(m);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (Int i = 0; i < m; i++) {
        cin >> b[i];
    }

    for (Int i = 1; i < n; i++) {
        a[i] += a[i - 1];
    }
    for (Int i = 1; i < m; i++) {
        b[i] += b[i - 1];
    }
	
    Int ans=0 ;
  	if(b[0]<=k)ans = b_search(b, k) + (Int)1;
    // a決めてk超えない範囲でb二分探
    for (Int i = 0; i < n; i++) {
        Int cnt = i + (Int)1;
        Int key = k - a[i];
        if (key < 0) {
            continue;
        }

        cnt += b_search(b, key) + (Int)1;

        ans = max(ans, cnt);
    }

    cout << clamp(ans, (Int)0, (Int)(n + m)) << endl;

    return 0;
}


Measured memory_bytes: 6328
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}


//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
  string S,T;cin>>S>>T;
  int cnt=0;
  rep(i,S.size()){
    if(S[i]!=T[i]){
     
      cnt ++;
    }
  }
  cout<<cnt<<endl;
}








Measured memory_bytes: 3988
import java.util.Scanner;
import java.util.Set;
import java.util.LinkedHashSet;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int cnt = sc.nextInt();
    Set<String> chkList = new LinkedHashSet<>();
    for (int i = 0; i < cnt; i++) {
        chkList.add(sc.next());
    }
    if (chkList.size() == cnt) {
        System.out.println("YES");
    } else {
        System.out.println("NO");
    }
  }
}

Measured memory_bytes: 83264
#include <bits/stdc++.h>
using namespace std;
const int MAX=200,MAX_N=1e6+10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> reg(MAX),dp0(MAX_N,MAX_N),dp1(MAX_N,MAX_N);
    for (int i=0;i<MAX;++i)
        reg[i]=i*(i+1)*(i+2)/6;
    dp0[0]=dp1[0]=0;
    for (int i=0;i<MAX_N;++i){
        for (int j=1;i+reg[j]<MAX_N;++j){
            dp0[i+reg[j]]=min(dp0[i+reg[j]],dp0[i]+1);
            if (reg[j]&1) dp1[i+reg[j]]=min(dp1[i+reg[j]],dp1[i]+1);
        }
    }
    int n;
    while(cin >> n,n){
        cout << dp0[n] << ' ' << dp1[n] << '\n';
    }
}


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

int n;
int dis[2][212345];
vector <int > a[212345];
int ans;

void dfs(int k, int x, int f) {
    dis[k][x] = dis[k][f] + 1;
    for (int i = 0  ; i < a[x].size() ; i++) {
        if ( a[x][i] != f) {
            dfs(k,a[x][i],x);
        }
    }
    return ;
}


int main() {
  //  freopen("test.txt","r",stdin);
    cin >> n ;
    for (int i = 1 ; i < n ; i++) {
        int x,y;
        cin >> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    dis[1][0] = dis[0][0] = -1;
    dfs(0,1,0) ; dfs(1,n,0);

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

    cout << ((ans > n/2) ? "Fennec" : "Snuke" );
    return 0;
}


Measured memory_bytes: 15872
use proconio::input;

// https://atcoder.jp/contests/abc168

fn main() {
    input! {
        n: usize,
    }
    let n = n.to_string();
    let m = n.chars().nth(n.len()-1).unwrap().to_string();

    let ans = match m.as_str() {
        "3" => "bon",
        "0"|"1"|"6"|"8" => "pon",
        _ => "hon",
    };
    println!("{}", ans);
}


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

#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define pb  push_back
#define clr(a, n) memset(a, n, sizeof a)

typedef vector<int> vi;
typedef long long ll;
const int mod = 1e9+7;
const int N = 3e5 + 9;
const int MAXNODES = 1e5+9;

int main() {

	int n, m;
	cin >> n >> m;
	int ans = 0;
	while(n > 0) {
		n -= m;
		ans++;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,pas,jm;
map <long long, long long> m;
int main(){
	cin>>a>>d;
	m[0]++;
	for(b=1; b<=a; b++){
		cin>>c;
		jm+=c;
		pas+=m[jm%d];
		m[jm%d]++;
	}
	cout<<pas;
	return 0;
}

Measured memory_bytes: 4224
while n = gets.to_i
  break if n==0
  a = Array.new(7,0)
  n.times do
    x = gets.to_i
    if x<10
      a[0]+=1
    elsif x<20
      a[1]+=1
    elsif x<30
      a[2]+=1
    elsif x<40
      a[3]+=1
    elsif x<50
      a[4]+=1
    elsif x<60
      a[5]+=1
    else
      a[6]+=1
    end
  end
  for i in 0..6
    puts a[i]
  end
end


Measured memory_bytes: 6108
import numpy as np
n = int(input())
h = [int(i) for i in input().split(" ")]
t = np.diff(h)
ind = [-1] + np.where(t>0)[0].tolist() + [n-1]
c = np.max(np.diff(ind))-1
if np.sum(t<=0) == 0:
    c = 0
print(c)

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

using namespace std;

int main(){
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	if(a1 + a2 + a3 >= 22){
		cout << "bust";
	} else {
		cout << "win";
	}
	return 0;
}

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

class Team
{
public:
	string name;
	int win,lost,InNo;

	Team(string name = string("str"), int win = 0, int lost = 0, int InNo = 0) :
	name(name),win(win),lost(lost),InNo(InNo){}

	bool operator < (const Team &ano) const
	{
		if(win != ano.win){
			return win > ano.win;
		}
		if(lost != ano.lost){
			return lost < ano.lost;
		}
		if(InNo != ano.InNo){
			return InNo < ano.InNo;
		}
		return name > ano.name;
	}

};

int n;

void solve()
{
	vector<Team> team(n);
	int res;

	for(int i = 0; i < n; i++){
		int win = 0, lost = 0;
		cin >> team[i].name;

		team[i].InNo = i;
		for(int j = 0; j < n-1; j++){
			cin >> res;

			switch(res){
				case 0:
					win++;
				case 1:
					lost++;
			}
		}
		team[i].lost = lost;
		team[i].win = win;
	}

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

	for(int i = 0; i < n; i++)
		cout << team[i].name << endl;

}

int main(void)
{
	while(cin >> n, n){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1216
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
    ll p,q,r;
    cin>>p>>q>>r;
    cout<<p+q+r-max({p,q,r});
    exit(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{	
	vector<char> ans;
	while (true)
	{
		int m, f, r; cin >> m >> f >> r;
		if(m == -1&&f == -1&&r == -1)break;
		if(m == -1 || f == -1)ans.push_back('F');
		else if(m + f >= 80)ans.push_back('A');
		else if(m + f >= 65)ans.push_back('B');
		else if(m + f >= 50)ans.push_back('C');
		else if(m + f >= 30)
		{
			if(r >= 50)ans.push_back('C');
			else ans.push_back('D');
		}
		else ans.push_back('F');
	}
	rep(i,sz(ans))cout << ans[i] << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



Measured memory_bytes: 3120
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
#import numpy as np
import bisect
import sys
#import sympy
sys.setrecursionlimit(10**6)


def bfs(s, n, node):
    # 頂点が探索済みかどうかのチェック配列
    check = [False for _ in range(n)]
    check[s] = True
    # 次見る頂点を格納するキュー
    queue = deque([s])
    visited_num = 1

    # 問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color = [-1 for _ in range(n)]
    color[s] = 0

    while visited_num < n:
        # グラフが全連結ではない場合
        if len(queue) == 0:
            # 空配列を返す
            # 現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex = queue.popleft()
        # インデックスがない場合は
        for next_vertex in node[now_vertex]:

            if check[next_vertex] == True:
                continue

            queue.append(next_vertex)
            check[next_vertex] = True

            # 問題固有の計算
            color[next_vertex] = color[now_vertex]+1
            visited_num += 1

    return color


mod = 10**9+7
# n=int(input())
# n,m=list(map(int,input().split()))
# a=list(map(int,input().split()))
def ceil(x, y): return (x+y-1)//y
def input_list(): return list(map(int, input().split()))


n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    if i % 2 == 1:
        continue
    if a[i] % 2 == 1:
        ans += 1

print(ans)


Measured memory_bytes: 9568
X = [int(input()) for _ in range(5)]

import itertools

ans = 10 ** 9 + 7
for order in itertools.permutations(range(5)):
    ans_tmp = 0
    for i in range(5):
        if ans_tmp % 10 > 0:
            ans_tmp += (10 - (ans_tmp % 10))
        ans_tmp += X[order[i]]
    ans = min(ans, ans_tmp)

print(ans)

Measured memory_bytes: 3316
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if a * 500 + b * 100 + c * 50 == X and a + b + c > 0:
                ans += 1
print(ans)

Measured memory_bytes: 3064
using System;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using System.Linq;

class Project
{
    static void Main(string[] args)
    {
        double N = int.Parse(Console.ReadLine());
        double n = Math.Floor(N / 200); 
        if (n == 2)
        {
            Console.WriteLine("8");
        }
        else if (n == 3)
        {
            Console.WriteLine("7");
        }
        else if (n == 4)
        {
            Console.WriteLine("6");
        }
        else if (n == 5)
        {
            Console.WriteLine("5");
        }
        else if (n == 6)
        {
            Console.WriteLine("4");
        }
        else if (n == 7)
        {
            Console.WriteLine("3");
        }
        else if (n == 8)
        {
            Console.WriteLine("2");
        }
        else if (n == 9)
        {
            Console.WriteLine("1");
        }
    } 
}

Measured memory_bytes: 27544
#include <iostream>
#include <algorithm>

using namespace std;

//typedef long long lli;

const int INF = 1<<30;

int n, m, data[16], dp[2][256], in;

main(){
  while(cin >> n >> m && (n|m)){
    for(int i=0;i<m;i++) cin >> data[i];
    fill(dp[0], dp[2], INF);
    dp[0][128] = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<256;j++) dp[(i+1)%2][j] = INF;
      cin >> in;
      for(int j=0;j<256;j++){
        if(dp[i%2][j] == INF) continue;
        for(int k=0;k<m;k++){
          int next = j + data[k];
          if(next < 0) next = 0;
          if(next > 255) next = 255;
          dp[(i+1)%2][next] = min(dp[(i+1)%2][next], abs(in-(next)) * abs(in-(next)) + dp[i%2][j]);
        }
      }
    }
    int ans = INF;
    for(int i=0;i<256;i++) ans = min(ans, dp[n%2][i]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
/*    Don’t Quit
    
    When things go wrong as they sometimes will;
        When the road you’re trudging seems all uphill;
            When the funds are low, and the debts are high;
                And you want to smile, but you have to sigh;
                    When care is pressing you down a bit
                        Rest if you must, but don’t you quit.
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
    string s[5];
    for(int i=0;i<3;i++)
    {
        cin>>s[i];
        cout<<s[i][i];
    }
    cout<<endl;









}

Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

ll a[maxn];
const ll MAX = 1000000000 * (long long)1000000000;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  if(a[0]==0)cout<<0<<endl;
  else {
    ll ret = 1;
    for(int i=0;i<n;i++){
      if(ret> MAX/a[i]){
        ret = -1;
        break;
      }
      ret *= a[i];
    }
    cout<<ret<<endl;
  }
  return 0;
}

Measured memory_bytes: 4420
//In the Name of God
#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int n,a[1111];
map<int,int>m;

int main () {

scanf ("%d", &n);

for (int i = 1; i <= n; i ++) {
    scanf ("%d", &a[i]);
    m[a[i]] ++;
}

printf ("%d", (int)m.size());

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n;
int m[110], a[110], b[110];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      cin >> m[i] >> a[i] >> b[i];
    }
    bool ng = false;
    for (int i = 0; i < n; i++) {
      int sum1 = 0, sum2 = 0;
      for (int j = 0; j < n; j++) {
        if (a[j] <= a[i] && a[i] < b[j]) sum1 += m[j];
        if (a[j] < b[i] && b[i] <= a[j]) sum2 += m[j];
      }
      ng |= max(sum1, sum2) > 150;
    }
    cout << (ng ? "NG" : "OK") << endl;
  }
  

  return 0;
}


Measured memory_bytes: 3112