akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;

template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)


int n;

signed main() {
    while (cin >> n) {
        deque<int> d;
        rep(i, n) {
            int a;
            cin >> a;
            if (i&1) d.push_back(a);
            else d.push_front(a);
        }
        if (n&1) {
            rep(i, n) cout << d[i] << ' ';
        } else {
            rrep(i, n) cout << d[i] << ' ';
        }
        cout << endl;
    }
}


Measured memory_bytes: 3840
inp = input()
inp = int(inp)

ans = 3

s_up = inp // 100
s_do = inp - s_up * 100

if (s_up > 12) or (s_up == 0):
    ans = 1

if (s_do > 12) or (s_do == 0):
    ans = 2

if ((s_up > 12) or (s_up == 0)) and ((s_do > 12) or (s_do == 0)):
    ans = 4

if ans == 1:
    print("YYMM")
elif ans == 2:
    print("MMYY")
elif ans == 3:
    print("AMBIGUOUS")
else:
    print("NA")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll N;
ll likemap[13];
int main(){
  cin>>N;
  if(24<=N)
    cout<<0<<endl;
  else{
    likemap[0]++;
  for(ll i=0;i<N;i++){
  ll a;cin>>a;likemap[a]++;
  }ll Max=0;
    for(ll i=0;i<13;i++)
      if(Max<likemap[i])Max=likemap[i];
    if(3<=Max)
      cout<<0<<endl;
    else{
    vector<ll>A;vector<ll>B;
      for(ll i=0;i<13;i++)
        if(likemap[i]==1){
        A.push_back(i);
        }else if(likemap[i]==2){
        B.push_back(i);B.push_back(24-i);
        }else{}
    ll M=A.size(); ll ans=0;
      for(ll bit=0;bit<(1<<M);bit++){
        ll Min=24;vector<ll>C=B;
        for(ll i=0;i<M;i++)
          if(bit & (1<<i)){
          C.push_back(A[i]);
           }else{
          C.push_back(24-A[i]);
          }ll SIZE=C.size();
        for(ll I=0;I<SIZE-1;I++)
          for(ll J=I+1;J<SIZE;J++){
            ll x=min(abs(C[I]-C[J]),(24-abs(C[I]-C[J])));
          if(x<Min)Min=x;
          }
               if(ans<Min)ans=Min;
      }cout<<ans<<endl;
    
    
    }
  
  }
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>

using namespace std;


int main(){

    unsigned int A, B, sum;
    cin >> A >> B;

    sum = max(A, B);
    if(A > B)   A--;
    else        B--;
    sum += max(A,B);

    cout << sum << endl;

    return 0;
}

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

int main() {
  
  string S;
  
  cin >> S;
  
  if (S.at(0) == S.at(1) || S.at(2) == S.at(1) 
      || S.at(3) == S.at(2)){
    cout << "Bad" << endl;
  }
  
  else {
    
    cout << "Good" << endl;
  }
  
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	int a, b, c, k, m, res = 0;
	cin >> a >> b >> c >> k;
	m = max({a, b, c});
	res -= m;
	res += m * pow(2, k) + a + b + c;
	cout << res << endl;	
	return 0;
}
	

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int sum = 0;
	char ch;

	while(true)
	{
		while((ch = getchar()) != '\n'){
			sum += ch - '0';
		}
		if(sum == 0)
			break;
		else{
			printf("%d\n",sum);
			sum = 0;
		}
	}
}



Measured memory_bytes: 2688
/* 
	Name: Mohit Khare
	CSE - MNNIT Allahabad
	never give up!!
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define ALL(x) x.begin(), x.end()
#define fastandfurious ios_base::sync_with_stdio(false);
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define mp make_pair
#define X first
#define Y second

#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b) for(int i=a;i<b;i++)
#define revr(i,a,b) for(int i=a;i>b;i--)
#define pr1(a) cout<<a<<endl;
#define pr2(a,b) cout<<a<<" "<<b<<endl;

const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
#define linf 99999999999999999ll	
#define PI 3.1415926535897932384626
#define mod 1000000007
const int maxn=1e5+1;

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

int a[maxn];
int main()
{
	//freopen("input.in","r",stdin);
    //freopen("output.txt","w",stdout);
	fastandfurious
	int n;
	cin>>n;
	rep(i,n)
	cin>>a[i];
	sort(a,a+n);
	int mn = a[0],mx= a[n-1];
	cout<<mx-mn<<endl;
	return 0;	
}

Measured memory_bytes: 256
while True:
    H,W = map(int, input().split())
    if H==W==0:
        break
    else:
        for i in range(H):
            for j in range(W):
                if (i+j)%2 == 0:
                    print("#", end="")
                else:
                    print(".", end="")
            print()
        print("")
    


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

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);++(i))
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define ppb(x) pop_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;

int main() {
  int d, t, s;
  scanf("%d %d %d ", &d, &t, &s);
  puts(d <= t*s ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 3772
n,m = map(int,input().split())
mod = 10**9 + 7
N = 1
M = 1
if abs(n-m) == 1:
    for i in range(1,n+1):
        N = (N*i)%mod
    for i in range(1,m+1):
        M = (M*i)%mod
    print((N*M)%mod)
elif abs(n-m) == 0:
    for i in range(1,n+1):
        N = (N*i)%mod
    for i in range(1,m+1):
        M = (M*i)%mod
    print((N*M*2)%mod)
else:
    print(0)


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

struct fq
{
    int x;
    int mid;
    int h_h;
}a[200005];

int comp_1(fq a,fq b)
{
    return a.x<b.x;
}

int comp_2(fq a,fq b)
{
    return a.h_h<b.h_h;
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i].x;
        a[i].h_h=i;
    }
    sort(a,a+n,comp_1);
    int flag=n/2;
    for(int i=0;i<n;i++)
    {
        if(a[i].x<a[flag].x)
            a[i].mid=a[flag].x;
        else
            a[i].mid=a[flag-1].x;
    }
    sort(a,a+n,comp_2);
    for(int i=0;i<n;i++)
    {
        cout<<a[i].mid<<endl;
    }
    return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n, a, mi=101, cnt = 0,sum=0;
	cin >> n >> a;
	vector<int> v(n);
	if (a >= 0) {
		for (int i = a; cnt < n; i++) {
			v.at(cnt) = i;
			mi=min(abs(i),mi);
			sum+=v.at(cnt);
			cnt++;
		}
		cout<<sum-mi<<endl;

	} else {
		for (int i = a; cnt < n; i++) {
			v.at(cnt) = i;
			mi=min(abs(i),mi);
			sum+=v.at(cnt);
			cnt++;
		}
		cout<<sum+mi<<endl;
	}

	return 0;
}



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

int main()
{
    int a,b;
    cin >> a >>b;
    if (a>b)
        cout << "a > b" << endl;
    else if (a < b)
        cout << "a < b" << endl;
    else
        cout << "a == b" << endl;
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll mod=1e9+7;
const ll maxs=2e6+6;
ll max2d=1e3+3;


ll v;
vll *g;
ll *p;
ll *lvl;
mll m;
ll *clr;


ll fast(ll base , ll power)
{
    ll res=1;
    while(power)
    {
        if(power&1)
            res=res*base;
        base = base*base;
        power>>=1;
    }
    return res;
}


void addEdge(ll x,ll y)
{
    g[x].pb(y);
    g[y].pb(x);
}


int main()
{
    ll n;
    cin>>n;
    
    ll flg[n+1];
    memset(flg,0,sizeof(flg));
    
    ll a[n];
    ll i;
    
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        flg[a[i]]++;
    }
    
    ll ans = 0;
    
    for(i=0; i<=n; i++)
        ans += (flg[i]*(flg[i] - 1)) / 2;
    
    //cout<<ans<<endl;
    
    for(i=0; i<n ; i++)
    {
        ll tmp = flg[a[i]];
        ll tmp1 = tmp;
        
        ans -= (tmp*(tmp-1))/2;
        
        tmp--;
        
        ans += (tmp*(tmp-1))/2;
        
        cout<<ans<<endl;
        
        ans -= (tmp*(tmp-1))/2;
        
        ans += (tmp1*(tmp1-1))/2;
    }
    
    return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
#include <stdlib.h>

int main()
{   int n;
    scanf("%d",&n);
    int a[n];
    long long ans=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int cur=a[0];
    for(int i=1;i<n;i++){
        if(cur>a[i]){
            ans+=(cur-a[i]);
        }else{
            cur=a[i];
        }
    }
    printf("%lld",ans);
    
    return 0;
}


Measured memory_bytes: 2480
abs(){
    if [ $1 -lt 0 ]; then
        echo $((-$1))
    else
        echo $1
    fi
}

read N
read W

sum=0
for x in $W
do
    sum=$(($sum+$x))
done

acc=0
ans=''
for x in $W
do
    acc=$(($acc+$x))
    rest=$(($sum-$acc))
    V=$(abs $(($acc-$rest)))
    ans="$ans $V"
done

echo $ans | tr ' ' '\n' | sort -n | head -n1

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

using namespace std;

//#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

int gcd (int a, int b) {
  int tmp = 0;
  while(b != 0) {
    tmp = a % b;
    a = b;
    b = tmp;
  }
  return a;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, ma, mb; cin >> n >> ma >> mb;

  vector<int> a(n), b(n), c(n);

  REP(i, n) cin >> a[i] >> b[i] >> c[i];
  REP(i, n) { a[i]--; b[i]--; }

  int ans[40][110][110];

  REP(i, 40) {
    REP(j, 110) {
      REP(k, 110) {
        ans[i][j][k] = INT_MAX;
      }
    }
  }

  ans[0][a[0]][b[0]] = c[0];

  FOR(i, 1, n) {
    ans[i][a[i]][b[i]] = min(ans[i][a[i]][b[i]], c[i]);
    REP(j, 100) {
      REP(k, 100) {
        if(ans[i-1][j][k] != INT_MAX) {
          ans[i][j + a[i]+1][k + b[i]+1] = min(ans[i][j + a[i]+1][k + b[i]+1], ans[i-1][j][k] + c[i]);
          ans[i][j][k] = min(ans[i][j][k], ans[i-1][j][k]);
        }
      }
    }
  }
  /*
  REP(i, n) {
    REP(j, 20) {
      REP(k, 20) {
        if(ans[i][j][k] == INT_MAX) cout << "*" << " ";
        else cout << ans[i][j][k] << " ";
      }
      cout << endl;
    }
    cout << endl;
  }
  */

  int mi = INT_MAX;
  FOR(i, 1, 100) {
    if(i * ma > 100 || i * mb > 100) break;
    mi = min(ans[n-1][i*ma-1][i*mb-1], mi);
  }

  if(mi == INT_MAX) cout << -1 << endl;
  else cout << mi << endl;
}


Measured memory_bytes: 2176
import java.util.*;

public class Main {
    public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            String a = sc.nextLine();
            String b = sc.nextLine();
            if (a.length() < b. length()) {
                System.out.println("LESS");
                return;
            } else if (a.length() > b. length()) {
                System.out.println("GREATER");
                return;
            }
            for (int i=0; i<a.length(); i++) {
                if ((int) a.charAt(i) < (int) b.charAt(i)) {
                    System.out.println("LESS");
                    return;
                } else if ((int) a.charAt(i) > (int) b.charAt(i)) {
                    System.out.println("GREATER");
                    return;
                }
            }
            System.out.println("EQUAL");
    }
}

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

#define sz(x) (int)(x.size())
#define fr(i,a,b) for(int i=a;i<b;++i)
#define fdr(i,a,b) for(int i=b-1;i>=a;--i)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
/////////////////////

int const N = 55;
int const MOD = 1e9 + 7;

int n;
string s1, s2;
int d[N][3][3];

void add(int &a, int b){
	a += b;
	if(a >= MOD) a -= MOD;
}

int mul(int a, int b){
	return a * 1LL * b % MOD;
}

void solve(){
	cin >> n;
	cin >> s1 >> s2;
	if(s1[0] == s2[0]){
		fr(i, 0, 3) d[0][i][i] = 1;
	}else{
		fr(i, 0, 3) fr(j, 0, 3){
			if(i != j) d[0][i][j] = 1;
		}
	}
	fr(i, 1, n){
		if(s1[i] == s1[i-1]){
			fr(j, 0, 3) fr(k, 0, 3){
				d[i][j][k] = d[i-1][j][k];
			}
		}else{
			if(s1[i] == s2[i]){
				fr(c, 0, 3) fr(j, 0, 3) fr(k, 0, 3){
					if(j == c || c == k) continue;
					add(d[i][c][c], d[i-1][j][k]);
				}
			}else{
				fr(c1, 0, 3) fr(c2, 0, 3) fr(j, 0, 3) fr(k, 0, 3){
					if(c1 == c2 || c1 == j || c2 == k) continue;
					add(d[i][c1][c2], d[i-1][j][k]);
				}
			}
		}
	}

	int ans = 0;
	fr(j, 0, 3) fr(k, 0, 3) add(ans, d[n-1][j][k]);
	cout << ans << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();


	return 0;
}

Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  std::cout << std::setprecision(20) << std::fixed;

  long long N, K;
  cin >> N >> K;

  vector<double> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    p[i] = (p[i] + 1) / 2;
  }
  vector<double> S(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    S[i] = S[i - 1];
    S[i] += p[i - 1];
  }

  double ans = 0;
  for (int i = 0; i <= N - K; i++) {
    ans = max(ans, S[i + K] - S[i]);
  }
  cout << ans << endl;

  return 0;
}


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

int main()
{
    int N, sum = 0;
    cin >> N;
    REP(i, to_string(N).length())
    {
        sum += to_string(N)[i] - '0';
    }
    N % sum == 0 ? cout << "Yes" : cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int N;
pair<pair<string,int>,int> p[110];

int main(){
  cin >> N;
  rep(i,N){
    string s;
    int pt;
    cin >> s >> pt;
    p[i] = make_pair(make_pair(s,-pt),i);
  }
  sort(p,p+N);
  rep(i,N){
    cout << p[i].second + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << A << endl; exit(0);}

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

  vector<ll> P(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> P.at(i);
    P.at(i)--;
  }

  ll ans = 0;
  for (ll i = 0; i < N - 1; i++)
  {
    if (P.at(i) == i)
    {
      swap(P.at(i), P.at(i + 1));
      ans++;
    }
  }
  if (P.at(N - 1) == N - 1)
    ans++;

  cout << ans << endl;
}

Measured memory_bytes: 1024
D,G = map(int, input().split())
G //= 100
PC = []
for _ in range(D):
    p,c = map(int, input().split())
    PC.append((p,c // 100))

ans = float("inf")
for i in range(2 ** D):
    cnt, scr = 0, 0
    smax = -1 # 未回答問題で最高配点
    for j in range(D):
        if (i >> j) & 1:
            p,c = PC[j]
            cnt += p
            scr += c + p * (j + 1)
        else:
            smax = j + 1

    if scr < G:
        need = (G - scr + smax - 1) // smax
        # 完答or問題数が足りない場合
        if need >= PC[smax - 1][0]:
            continue
        cnt += need
    
    ans = min(ans, cnt)

print(ans)

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

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<int> h(N);
  int sum = 0;
  for (auto& hi: h) {
    scanf("%d", &hi);
    sum += hi;
  }

  int res = 0;
  while (sum > 0) {
    for (size_t i = 0; i < N; ++i) {
      if (h[i] == 0) continue;
      for (size_t j = i; j < N; ++j) {
        if (h[j] == 0) break;
        --h[j];
        --sum;
      }
      ++res;
      break;
    }
  }
  printf("%d\n", res);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1000000007;
const long long INF = 1LL << 60;
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,x = 0;
    cin >> n;
    VI a(n);
    rep(i,n) cin >> a[i];
    rep(i,n-1){
        if(a[i+1] - a[i] < 0){
            No;
            return 0;
        }else{
            if(a[i+1] - a[i] > 0){
                a[i+1]--;
            }
        }
    }
    Yes;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define SIZE 10000
int main()
{
  int s[SIZE],t;
  int i,j,n,q,ans=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&t);
      for(j=0;j<n;j++)
	{
	  if(t==s[j])
	    {
	      ans++;
	      break;
	    }
	}
    }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_T=1002,MAX_W=31;

int dp[MAX_T][MAX_W];

int main(){
  int X,A,B;
  cin >> X >> A >> B ;
  if(A-B>=0) cout << "delicious" << endl;
  else if(B-A<=X) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string w;
  cin >> w;
  map<char, int> cnt;
  for(int i = 0; i < w.length(); i++) cnt[w[i]]++;
  for(int i = 1; i < n; i++){
    string s;
    cin >> s;
    map<char, int> cnt_s;
    for(int j = 0; j < s.length(); j++) cnt_s[s[j]]++;
    for(auto p: cnt){
      if(cnt_s[p.first] == 0) cnt[p.first] = 0;
      else if(p.second > cnt_s[p.first]) cnt[p.first] = cnt_s[p.first];
    }
  }
  for(auto p: cnt){
    for(int i = 0; i < p.second; i++) cout << p.first;
  }
  return 0;
}

Measured memory_bytes: 256
/* 
   AOJ 1160
   How Many Islands?
   2015.4.28
 */

#include<stdio.h>

int width, height, map[50][50], direction[8][2] = { {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}};

void dfs(int x, int y)
{
  int i, j, prov_x = 0, prov_y = 0;

  /* printf("\n"); */

  /* for(i = 0; i < height; i++) */
  /*   { */
  /*     for(j = 0; j < width; j++) */
  /* 	{ */
  /* 	  printf("%d ", map[i][j]); */
  /* 	} */
  /*     printf("\n"); */
  /*   } */


  map[y][x] = 0;
  for(i = 0; i < 8; i++)
    {
      prov_x = x + direction[i][0];
      prov_y = y + direction[i][1];

      if(prov_x >= 0 && prov_x < width && prov_y >= 0 && prov_y < height && map[prov_y][prov_x] != 0)
	{
	  dfs(prov_x, prov_y);
	}
    }
}

int search_island()
{
  int i, j, count = 0;
  for(i = 0; i < height; i++)
    {
      for(j = 0; j < width; j++)
	{
	  if(map[i][j] == 1)
	    {
	      dfs(j, i);
	      count++;
	    }
	}
    }
  return count;
}

int main(void)
{
  int  i, j, island = 0;
  while(1)
    {
      scanf("%d %d", &width, &height);
      if(width == 0 && height == 0)
	{
	  break;
	}

      for(i = 0; i < 50; i++)
	{
	  for(j = 0; j < 50; j++)
	    {
	      map[i][j] = 0;
	    }
	}

      
      for(i = 0; i < height; i++)
	{
	  for(j = 0; j < width; j++)
	    {
	      scanf("%d", &map[i][j]);
	    }
	}

      /* printf("\n"); */
     
      /* for(i = 0; i < height; i++) */
      /* 	{ */
      /* 	  for(j = 0; j < width; j++) */
      /* 	    { */
      /* 	      printf("%d ", map[i][j]); */
      /* 	    } */
      /* 	  printf("\n"); */
      /* 	} */

      island = search_island();
      printf("%d\n", island);
      
    }
  return 0;
}

Measured memory_bytes: 676
#include<bits/stdc++.h>
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 per(i,n) for(int i = n-1; i >= 0; i--)
#define PER(i,n) for(int i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const int mod = 1e9+7;

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

  int n;
  cin >> n;
  ll p = 1;
  for(ll i = 1; i <= n; i++) {
    p *= i;
    p %= mod;
  }
  cout << p << endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	inputs = input.split("\n");

	var N = parseInt( inputs[0], 10 );
	var max2 = [ 0, 0 ];
	for ( var i = 1; i <= N; i++ ){
		var tmp = parseInt( inputs[i], 10 );
		if ( i == 1 ) {
			max2[0] = tmp;
		} else if ( i == 2 ) {
			if ( tmp >= max2[0] ){
				max2[1] = max2[0];
				max2[0] = tmp;
			} else {
				max2[1] = tmp;
			}
		} else {
			if ( tmp >= max2[0] ) {
				max2[1] = max2[0];
				max2[0] = tmp;
			} else if ( tmp >= max2[1] ) {
				max2[1] = tmp;
			}
		}
	}

	for ( var i = 1; i <= N; i++ ){
		var tmp = parseInt( inputs[i], 10 );
		console.log('%d', tmp == max2[0] ? max2[1] : max2[0]);
	}

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define ll long long

const int N = 2e5+5;
const int mod = 1e9+7;

int add(int x,int y) {
    int ret = (x+y)%mod;
    if(ret<0) {
        ret += mod;
    }
    return ret;
}
int mul(int x,int y) {
    ll ret = (ll)x*y;
    ret %=mod;
    return ret;
}
int myPow(int x,int k) {
    int ret = 1;
    while(k>0) {
        if(k&1) {
            ret = mul(ret, x);
        }
        x = mul(x,x);
        k/=2;
    }
    return ret;
}

int in[N],fac[N];

int combi(int n,int k) {
    int ret = fac[n];
    ret = mul(ret, myPow(fac[k],mod-2));
    ret = mul(ret, myPow(fac[n-k],mod-2));
    return ret;   
}
void solve() {
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    fac[0]=  1;
    for(int i=1;i<N;++i) {
        fac[i] = mul(fac[i-1],i);
    }
    int mm =  combi(n*m-2,k-2);
    int sum = 0,tmp=0,cc = 0;
    for(int i=1;i<=n;++i) {
        int x = add(mul(cc,i),-tmp); 
        ++cc;
        tmp = add(tmp,i);
        x = mul(x, mul(m,m));
        sum = add(sum,x);
    }
    cc = 0, tmp = 0;
    for(int i=1;i<=m;++i) {
        int x = add(mul(cc,i),- tmp);
        ++cc;
        tmp = add(tmp,i);
        x = mul(x,mul(n,n));
        sum = add(sum,x);
    }
    sum = mul(sum, mm);
    printf("%d\n", sum);
}

int main()
{
    //freopen("input.txt","r",stdin);
    solve();
}

Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    double n,k; cin >> n >> k;
    double ans = 0;

    for(double i = 1;i < min(n+1,k);i ++){
        double t = 1 / n;
        double j = i;
        while(j < k){
            t /= 2;
            j *= 2;
        }

        ans += t;
    }

    if(n >= k) ans += (n-k+1) / n;

    cout << fixed << setprecision(11) << ans << endl;
}



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

public class Main {

    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));   


    public static void main ( String [] args ) throws IOException
    {
	
	int end = Integer.parseInt(br.readLine());
	while(end != 0){
	    new Main().cal(end);
	    end = Integer.parseInt(br.readLine());
	}	
    }

int[] thr;


    private void cal(int end) throws IOException 
    {
	int z = end;
	int limit = z*z*z;
	int tmp;
	int max;

	thr = new int[z];
	for(int i=1; i< z; i++){
		thr[i] = i*i*i;
	}
    	

	max = thr[1] + thr[1];
	for( int i =1; i< z; i++){
		for(int j=1; j< z; j++){
			tmp = thr[i] + thr[j];
			if( tmp <= limit && tmp > max ){
				max = tmp;
			}
			if( tmp >= limit ){
				break;
			}
		}
	}
	
	System.out.println(limit - max);
    }
}

Measured memory_bytes: 9764
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    ll n;
    cin >> n;
    vector<pll> t(n);
    vector<double> v(n);
    ll sum=0;
    rep(i,n){
        ll d;
        cin >> d;
        if(i==0){
            t[i].fi=0;
            t[i].se=2*d;
        }
        else{
            t[i].fi=t[i-1].se;
            t[i].se=t[i].fi+2*d;
        }
    }
    vector<double> maxv(t[n-1].se+1);
    
    rep(i,n){
        cin >> v[i];
    }
    rep(i,n){
        for(ll j=t[i].fi;j<=t[i].se;j++){
            if(j==t[i].fi){
                maxv[j]=min(maxv[j],v[i]);
            }
            else{
                maxv[j]=v[i];
            }
        }
    }
    maxv[t[n-1].se]=0;
    for(ll i=1;i<=t[n-1].se;i++){
        maxv[i]=min(maxv[i],maxv[i-1]+0.5);
    }
    for(ll i=t[n-1].se-1;i>=0;i--){
        maxv[i]=min(maxv[i],maxv[i+1]+0.5);
    }
    double ans=0;
    for(ll i=1;i<=t[n-1].se;i++){
        ans+=(maxv[i-1]+maxv[i])*0.5*0.5;
    }
    cout << fixed << setprecision(30);
    cout << ans << endl;
}

Measured memory_bytes: 3820
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    a=ord('a')
    s=list(map(lambda x:ord(x)-a,input()))
    N=len(s)
    t=list(map(lambda x:ord(x)-a,input()))
    l=[[-1]*26 for _ in range(len(s))]
    for i in range(N-1,-N,-1):
        for j in range(26):
            if s[i]==j:
                l[i-1][j]=i%N
            else:
                l[i-1][j]=l[i][j]
    ans=0
    index=N-1
    for a in t:
        n=l[index][a]
        if n==-1:
            print(-1)
            exit()
        if n>index:
            ans+=n-index
        else:
            ans+=n+N-index
        index=n
    print(ans)

if __name__ == '__main__':
    main()


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

signed main() {
    int n,k;
    cin >> n >> k;

    int d = n / k;
    int x = abs(n - (d * k));
    int y = abs(n - ((d + 1) * k));
    cout << min(x , y) << endl;
}
    



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

int main() {
  ll A, B, C, K;

  cin >> A >> B >> C >> K;

  ll res;
  if (K <= A) {
    res = K;
  }
  else if (A < K && K <= (A+B)) {
    res = A;
  }
  else if ((A+B) < K && K <= (A+B+C)) {
    res = A - (K - A - B);
  }
  else {
    res = A - C;
  }

  cout << res << endl;
  return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL a, b, c;

int main() {
	cin >> a >> b >> c;
	
	cout << b + min(a + b + 1, c) << endl;
	
	return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

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

    queue<pair<int, int>> q;
    vector<vector<int>> d(n, vector<int>(3, -1));
    q.emplace(s, 0); d[s][0] = 0;
    while (!q.empty()) {
        int now, cond;
        tie(now, cond) = q.front(); q.pop();
        if (now == t && cond == 0) {
            cout << d[t][0] / 3 << endl;
            return 0;
        }

        for (auto &nxt: g[now]) {
            int ncond = (cond + 1) % 3;
            if (d[nxt][ncond] == -1) {
                d[nxt][ncond] = d[now][cond] + 1;
                q.emplace(nxt, ncond);
            }
        }
    }
    cout << -1 << endl;
    return 0;
}

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

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


    int ans = 0;
    while(true) {
        for(auto& e : v) {
            if(e & 1) {
                cout << ans << endl;
                return 0;
            }
            e >>= 1;
        }
        ans++;
    }

    cout << ans << endl;

    return 0;
}

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

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

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  rep(i, 9) {
    rep(j, 9) {
      if ((i + 1) * (j + 1) == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define in() ( { int a ; scanf("%d",&a); a; } )
 
const int N = 1e6 + 4;
const int mod = 1e9 + 7;
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};

bool chk[N];
vector<ll>prime;
void sieve()
{
    ll i, j;
    chk[0] = chk[1] = 1;
    for(i = 2; i < sqrt(N); i++){
        for(j = i*i; j < N; j += i){
            chk[j] = 1;
        }
    }
    for(i = 0; i < N; i++){
        if(!chk[i]){
            prime.eb(i);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    sieve();
    ll n, i, j, alda = 0;
    cin >> n;
    for(i = 0; i < prime.size() && prime[i] <= sqrt(n); i++){
        ll cnt = 0, temp = 0;
        if(n%prime[i] == 0){
            while(n%prime[i] == 0){
                cnt++;
                if(temp < cnt){
                    temp = cnt;
                    cnt = 0;
                    alda++;
                    //cout << prime[i] << endl;
                }
                n /= prime[i];
                if(n < 2) break;
            }

        }
    }
    if(n > 1) alda++;
    cout << alda << endl;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  bool ok = false;
  for(int i = 0; i< S.size(); i++){
    char c = S.back();
    S.pop_back();
    S = c + S;
    if(S == T){
      ok = true;
      break;
    }
  }
  if(ok){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n=list((input()))

tail=n[len(n)-1]
if(tail=='2' or tail=='4' or tail=='5' or tail=='7' or tail=='9'):
    print('hon')
if(tail=='0' or tail=='1' or tail=='6' or tail=='8'):
    print('pon')
if(tail=='3'):
    print('bon')

Measured memory_bytes: 9060
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int w, h, n, x[1010], y[1010], ans=0;
    cin>>w>>h>>n;
    for (int i=1; i<=n; i++) cin>>x[i]>>y[i];
    for (int i=2; i<=n; i++)
    {
        if ((x[i-1]<x[i] && y[i-1]>y[i]) || (x[i-1]>x[i] && y[i-1]<y[i])) ans+=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
        else ans+=max(abs(x[i]-x[i-1]), abs(y[i]-y[i-1]));
    }
    cout<<ans<<'\n';
    return 0;
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

ll n,a,b,t;

pl s[200005];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a >> b;
        s[i]={a-b,b};
    }
    sort(s+1,s+n+1);
    if(s[1].x==0){
        cout << 0;
        return 0;
    }
    a=0; b=0;
    for(int i=1;i<=n;i++){
        a+=s[i].y;
    }
    ll mn=INF;
    for(int i=1;i<=n;i++){
        if(s[i].x>0) mn=min(mn,s[i].y);
    }
    cout << a-mn;
}


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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second
 
Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n), b(n), c(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (Int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (Int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    Int res = 0;
    for (Int i = 0; i < n; i++) {
        Int x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        Int y = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
        res += x * y;
    }
    dump(res);
    return 0;
}

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

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int a[] = new int[n];
		List<Integer> list = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			int tar = scanner.nextInt();
			a[i] = tar;
			list.add(tar);
		}
		Collections.sort(list);

		for (int i = 0; i < n; i++) {
			if (a[i] < list.get(n / 2))
				System.out.println(list.get(n / 2));
			else
				System.out.println(list.get(n / 2 - 1));
		}
		
	}
}


Measured memory_bytes: 98552
#include <bits/stdc++.h>
using namespace std;
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 = 1e12;

int V, E;

vector< vector<long long> > graph(110, vector<long long>(110, INF));
long long dp[110][110];

int main() {
    cin >> V >> E;
    for(int i = 0; i < E; ++i) {
        long long s, t, d;
        cin >> s >> t >> d;
        graph.at(s).at(t) = d;
    }

    for(int i = 0; i < V; ++i) {
        for(int j = 0; j < V; ++j) {
            if(i == j) dp[i][j] = 0;
            else dp[i][j] = graph.at(i).at(j);
        }
    }

    for(int k = 0; k < V; ++k) {
        for(int i = 0; i < V; ++i) {
            for(int j = 0; j < V; ++j) {
                if(dp[i][k] != INF && dp[k][j] != INF) {
                    dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
                }
            }
        }
    }

    bool flg = true;
    for(int i = 0; i < V; ++i) {
        for(int j = 0; j < V; ++j) {
            if(i == j) {
                if(dp[i][j] < 0) flg = false;
                break;
            }
        }
    }

    if(flg) {
        for(int i = 0; i < V; ++i) {
            for(int j = 0; j < V; ++j) {
                if(j == V-1) {
                    if(dp[i][j] == INF) cout << "INF" << endl;
                    else cout << dp[i][j] << endl;
                }else {
                    if(dp[i][j] == INF) cout << "INF" << " ";
                    else cout << dp[i][j] << " ";
                }
            }
        }
    }else {
        cout << "NEGATIVE CYCLE" << endl;
    }
}


Measured memory_bytes: 3340
#include <bits/stdc++.h>
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++)
typedef long long ll;

int main(){
	ll x;
	cin >> x;
	
	int temp = x/100;
	
	int val = x % 100;
	
	if (0<= val && val <= 5*temp){
		cout << 1 << endl;
	}else{
		cout << 0 << endl;
	}
	
}

Measured memory_bytes: 256
#coding: utf-8

num = STDIN.gets.to_i

for i in 1..num do
  data = STDIN.gets
  num = data.split()
  a = num[0].to_i
  b = num[1].to_i
  c = num[2].to_i
  a2 = Math.sqrt(b * b + c * c)
  b2 = Math.sqrt(c * c + a * a)
  c2 = Math.sqrt(a * a + b * b)
  if ((a == a2) || (b == b2) || (c == c2)) then
    print("YES\n")
  else
    print("NO\n")
  end
end

Measured memory_bytes: 8784
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
int n;
cin >> n;
int a[n-1];
int x;
x=0;
int s;
s=0;
for(int i = 0; i <= n - 1; ++i){
    cin >>a[i];
}
for(int i = 0; i <= n - 1; ++i){
    x=max(a[i],x);
    s=s+a[i];
}
if(s>2*x){
    cout << "Yes" <<endl;
}else{
    cout << "No" <<endl;
}
return 0;
}


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

int main() {
	string b;
	cin >> b;
	string before = "ATGC";
	string after = "TACG";

	char ans = 'A';

	for (int i = 0; i < before.size(); i++) {
		if (b[0] == before[i]) ans = after[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
public class Hello{
    public static void Main(){
        int[] n = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        Array.Sort(n);
        Array.Reverse(n);
        int ans = 0;
        
        ans += n[0] - n[1];
        
        if(n[1] == n[2]){
            Console.WriteLine(ans);
            return;
        }else{
            if((n[1] - n[2]) % 2 == 0){
                ans += (n[1] - n[2]) / 2;
            }else{
                ans += (n[1] - n[2]) / 2 + 2;
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11220
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var B = ReadLongs();

            var A = new long[N];

            A[0] = B[0];
            for (int i = 0; i < N - 1; i++)
            {
                A[i] = Math.Min(A[i], B[i]);
                A[i + 1] = B[i];
            }

            return A.Sum();
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 13396
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll target;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    //double mini=INF;
    ll maxi=0,f=0,sum=0,mini=INF;
    string str,str1,str2;
    ll i,w;
    double h;
    ll n,x,m;
    ll a,b,d,c;
    set<string> s;
    cin>>n>>h>>x;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    rep(i,n){
        if(mini>abs(-x*1000+h*1000-6*v[i])){
            f=i+1;
            mini=abs(-x*1000+h*1000-6*v[i]);
        }
        //cout<<h-0.006*v[i]<<endl;
    }
    cout<<f<<endl;

    return 0;
}


Measured memory_bytes: 256
// C.

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(int argc, char *argv[])
{
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	sort(h.begin(), h.end());
	int ans = 1 << 30;
	for (int i = 0; i <= n - k; ++i) {
		ans = min(ans, h[i + k - 1] - h[i]);
	}
	cout << ans << endl;
	return 0;
}


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

int main(void){
    int n,p;
    cin >> n >> p;
    int a[n],k = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(a[i] % 2 == 0)k++;
    }
    if(k == n){
        if(p == 0)cout << (long long int)pow(2,n);
        else cout << 0;
    } else {
        cout << (long long int)pow(2,n-1);
    }
    
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int h, w, k;  scanf("%d %d %d", &h, &w, &k);
  int field[8][8] = {0};
  for(int i=0; i<h; i++){
    char s[8];  scanf("%s", s);
    for(int j=0; j<w; j++)
      if(s[j] == '#')  field[i+1][j+1] = 1;
  }
  long ans = 0;
  for(long bit=0; bit<(1<<(h+w)); bit++){
    int tate[8] = {0}, yoko[8] = {0};
    for(int i=1; i<=h; i++)
      if( bit & (1<<(i-1)) )
	tate[i] = 1;
    for(int i=1; i<=w; i++)
      if( bit & (1<<(i-1+h)) )
	yoko[i] = 1;
    int count = 0;
    for(int i=1; i<=h; i++){
      if(tate[i])  continue;
      for(int j=1; j<=w; j++){
	if(yoko[j])  continue;
	if(field[i][j])  count++;
      }
    }
    if(count == k)  ans++;
  }

  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    ll x;
    cin >> x;
    ll y = 100;
    ll ans = 0;
    while (y<x) {
        
        y = static_cast<ll>(y * 1.01);
        ans++;
    }
    
    cout << ans << endl;
    return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    set<int> sunuke;
    for (int i = 0; i < n; i++){
        sunuke.insert(i+1);
    }

    for (int i = 0; i < k; i++){
        int d;
        cin >> d;
        for (int j = 0; j < d; j ++){
            int okashi;
            cin >> okashi;
            if (sunuke.count(okashi)){
                sunuke.erase(okashi);
            }
        }
    }
        
    cout << sunuke.size() << endl;
    return 0;
    
}

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

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

  if(R<1200){
    cout << "ABC" << endl;
  }
  else if(1200<=R && R<2800){
    cout << "ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }

return 0;  
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef pair<double,int> pdi;

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;
const int MAX_V=10000;

int main(){
	int n;
	cin>>n;
	int a[n];
	REP(i,n)cin>>a[i];
	vector<pii> p;
	REP(i,n)p.push_back(pii(a[i],i));
	sort(p.begin(),p.end());
	int ans[n];
	REP(i,n){
		int id=p[i].second;
		if(i<n/2)ans[id]=p[n/2].first;
		else if(i==n/2-1)ans[id]=p[n/2].first;
		else if(n==n/2)ans[id]=p[n/2-1].first;
		else ans[id]=p[n/2-1].first;
	}
	REP(i,n)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 5488