akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

ll H[101][101];
void updateH(ll x,ll y,ll h){
	ll tmp;
	for(ll i(0);i<=100;++i){
		for(ll j(0);j<=100;++j){
			tmp = h+abs(i-x)+abs(j-y);
			if(H[i][j] == -1){
				H[i][j] = tmp;
			}else if(h == 0){
				if(tmp < H[i][j] ){
					H[i][j] = 0;
				}
			}else{
				if(tmp != H[i][j]){
					H[i][j] = 0;
				}
			}
		}
	}
}

int main(){
	ll N;
	cin >> N;
	ll x[N],y[N];
	ll h[N];
	for(ll i(0);i<N;++i){
		cin >>x[i]>>y[i]>>h[i];
	}
	for(ll i(0);i<=100;++i){
		for(ll j(0);j<=100;++j){
			H[i][j] = -1;
		}
	}
	vector<vector<ll>> zeroPoints;
	for(ll i(0);i<N;++i){
		if(h[i]==0){
			vector<ll> vec = {x[i],y[i],h[i]};
			zeroPoints.push_back(vec);
		}else{
			updateH(x[i],y[i],h[i]);
		}
	}
	for(ll i(0);i<zeroPoints.size();++i){
		updateH(zeroPoints[i][0],zeroPoints[i][1],zeroPoints[i][2]);
	}

	ll ans = 0;
	ll ansX,ansY;
	for(ll i(0);i<=100;++i){
		for(ll j(0);j<=100;++j){
			if(H[i][j] > ans){
				ans = H[i][j];
				ansX = i;
				ansY = j;
			}
		}
	}
	cout << ansX << ' ' << ansY << ' ' << ans << endl;
	return 0;
}


Measured memory_bytes: 384
use proconio::input;

fn main() {
    input! {
     n:usize,
     a:[isize;n]
    }

    let mut dp = vec![vec![isize::min_value() / 10; 4]; n + 2];
    dp[0][0] = 0;
    dp[1][0] = 0;
    for i in 0..n {
        dp[i + 2][0] = dp[i][0] + a[i];
        dp[i + 2][1] = std::cmp::max(dp[i + 1][0], dp[i][1] + a[i]);
        dp[i + 2][2] = std::cmp::max(dp[i + 1][1], dp[i][2] + a[i]);
    }
    let mut ans = dp[n + 1][1];

    if n % 2 != 0 {
        ans = std::cmp::max(ans, dp[n + 1][2]);
    } else {
        ans = std::cmp::max(ans, dp[n + 1][0]);
    }

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

Measured memory_bytes: 19596
n, m = map(int, input().split())
dat = []
for _ in range(n):
    dat.append(list(map(int, input().split())))
datc = []
for _ in range(m):
    datc.append(int(input()))

for i in range(n):
    res = 0
    for j in range(m):
        res += dat[i][j] * datc[j]
    print(res)


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

using namespace std;

int H, W, D, Q;
pair<int, int> positions[90010];
int dists[90010];

int Calc(int A) {
  if (dists[A] >= 0) return dists[A];

  dists[A] = 0;
  for (int v = A % D; v < A; v += D) {
    const auto& nextPos = positions[v + D];
    const auto& currentPos = positions[v];
    dists[A] += abs(nextPos.first - currentPos.first) +
                abs(nextPos.second - currentPos.second);
  }
  return dists[A];
}

int main() {
  cin >> H >> W >> D;
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      int A;
      cin >> A;
      positions[A] = make_pair(y, x);
    }
  }

  memset(dists, -1, sizeof(dists));

  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int L, R;
    cin >> L >> R;
    cout << Calc(R) - Calc(L) << endl;
  }

  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
string str;
int main()
{
	int min_v=INT_MAX;
	cin>>str;
	for(int i=0;i<str.length()-2;i++)
	{
		int num=(str[i]-'0')*100+(str[i+1]-'0')*10+str[i+2]-'0';
		min_v=min(min_v,abs(num-753)); 
	}
	cout<<min_v;
	return 0;
} 

Measured memory_bytes: 256
<?php
$step = trim(fgets(STDIN));
$start = null;
$count = 0;
$rows = [];
while (($row = trim(fgets(STDIN))) !== '') {
  $rows[$count] = explode(' ', $row);
  $count++;
}

$memo = [];

for ($i=0; $i < $step; $i++) {
  $result = 0;
  for ($j=0; $j <= $i; $j++) {
    $result += $rows[0][$j];
  }
  for ($j=$i; $j < $step; $j++) {
    $result += $rows[1][$j];
  }
  $memo[] = $result;
}

echo max($memo)."\n";


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp

signed main(){
	cout << fixed << setprecision(12);
	const long double pi = acos(-1);
	long double a,b,h,m; cin>>a>>b>>h>>m;
	long double k=m*6;
	//cout<<k<<endl;
	long double l=(30*h)+(0.5*m);
	//cout<<l<<endl;
	if(k==l){
		cout<<max(a,b)-min(a,b);
		return 0;
	}
	if(k==0 && l>=30) k=360;
	if(l==0 && k>=30) l=360;
	long double ang=max(k,l)-min(k,l);
	if(ang==180){
		cout<<a+b;
		return 0;
	}
	//cout<<ang<<endl;
	long double c=cos(pi/(180/ang));
	//cout<<c<<endl;
	long double a2=a*a;
	long double b2=b*b;
	long double ans=a2+b2-(2*a*b*c);
	cout<<sqrt(ans);
	
	return 0;
}


Measured memory_bytes: 4096
n = int(input())
x = list(map(int, input().split()))

x.sort()

l = x[0]
r = x[-1]

res = int(1e18)
for i in range(l, r+1):
    _res = 0
    for j in x:
        _res += (i - j) * (i - j)
    if _res < res:
        res = _res

print(res)

Measured memory_bytes: 63436
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    if (b % a == 0) {
      System.out.println(a + b);
    } else {
      System.out.println(b - a);
    }
  }
}

Measured memory_bytes: 23252
#include <iostream>

using namespace std;

long foo(long k, long  s) {
  if (s < 0) return 0;
  if (k >= s) return s + 1;
  if (k * 2 >= s) return k * 2 - s + 1;
  return 0;
}

int main(void) {
  long K, S;
  cin >> K >> S;

  long ans = 0;
  for (long i = 0; i <= K; i++) {
    ans += foo(K, S - i);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


int main(void)
{	int i,j,h,w;
	scanf("%d %d",&h,&w);
	while(h != 0 && w != 0){
	for(i=0;i<h;i++){
	for(j=0;j<w;j++){printf("#");}
	printf("\n");}
	printf("\n");
	scanf("%d %d",&h,&w);
	}
	return 0;
}

Measured memory_bytes: 572
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from copy import copy
import numpy as np
from numpy.fft import fft, ifft
from fractions import gcd


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

p, q, r = MAP()

m = INF

lis=[p,q,r]

for x in range(2):
    for y in range(x+1,3):
        m = min(m, lis[x] + lis[y])
        
print(m)

Measured memory_bytes: 22872
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <limits.h>
#include <queue>
using namespace std;

int main(){
    string s;
    cin>> s;
    int n=s.size();
    vector<int> dp(n);
    dp[0]=1;
    if(s[0]==s[1]){
        dp[1]=1;
        dp[2]=2;
    }
    else{
        dp[1]=2;
        if(s[1]==s[2]){
            dp[2]=2;
        }
        else{
            dp[2]=3;
        }
    }
    for(int i=3;i<n;i++){
        if(s[i]==s[i-1]){
            dp[i]=dp[i-3]+2;
        }
        else{
            dp[i]=dp[i-1]+1;
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n; cin >> n;
    set<string> s;
    for(int i = 0; i < n; i++){
        string str; cin >> str;
        s.insert(str);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 19128
c2u = {
    500: 1000,
    100: 0,
    50: 0,
    10: 0,
    5: 5,
    1: 0
}

X = int(input())

X0 = X
coin = {}
if X0 // 500 > 0:
    coin[500]  = X0 // 500
    X0 -= 500 * coin[500]
if X0 // 5 > 0:
    coin[5]  = X0 // 5
    X0 -= 5 * coin[5]
if X0 // 100 > 0:
    coin[100]  = X0 // 100
    X0 -= 100 * coin[100]
if X0 // 50 > 0:
    coin[50]  = X0 // 50
    X0 -= 50 * coin[50]
if X0 // 10 > 0:
    coin[10]  = X0 // 10
    X0 -= 10 * coin[10]
coin[1] = X0

u = 0
for k, v in coin.items():
    u += c2u[k] * v
print(u)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
 
const int DAY = 24*60;
const int MAXN = 500;
 
int N;
string name[MAXN];
pair<int,int> V[MAXN];
int P;
int F[MAXN];
bool used[MAXN];
 
bool kaburi(int a, int b) {
  return abs(a-b)<30;
}
 
int solve() {
  for(int i = 0; i < P; ++i) {
    for(int j = 0; j < i; ++j) {
      if(kaburi(V[F[i]].first, V[F[j]].first)) {
        return -1;
      }
    }
  }
 
  vector<pair<int,int> > v;
  for(int i = 0; i < N; ++i) {
    bool flag = true;
    for(int j = 0; j < P; ++j) {
      if(kaburi(V[i].first, V[F[j]].first)) {
        flag = false;
        break;
      }
    }
    if(flag) {
      v.push_back(V[i]);
    }
  }
  sort(v.begin(), v.end());
  fill(used, used+MAXN, false);
  int res = P;
  for(int i = 0; i < v.size(); ++i) {
    bool flag = true;
    for(int j = 0; j < i; ++j) {
      if(used[j] && kaburi(v[i].first, v[j].first)) {
        flag = false;
        break;
      }
    }
    if(flag) {
      ++res;
      used[i] = true;
    }
  }
  return res;
}
 
int main() {
  while(cin >> N && N) {
    for(int i = 0; i < N; ++i) {
      int w, s;
      cin >> name[i] >> w >> s;
      V[i].first = w*DAY + (s/100) * 60 + s%100;
      V[i].second = i;
    }
    cin >> P;
    for(int i = 0; i < P; ++i) {
      string s;
      cin >> s;
      for(int j = 0; j < N; ++j) {
        if(s == name[j]) {
          F[i] = j;
          break;
        }
      }
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 1276
#include<stdio.h>

void scan(int a){
  int i;
  int hako[a];
  if(a==0||a==1){
    printf("1\n");
    return;
  }
  else{
    hako[0]=1;
    hako[1]=1;
    for(i=2;i<=a;i++){
      hako[i]=hako[i-1]+hako[i-2];
    }
    printf("%d\n",hako[i-1]);
    return;
  }
}

int main(){

  int A;

  scanf("%d",&A);

  scan(A);

  return 0;
}

  



Measured memory_bytes: 2112
#include<stdio.h>


#define N 100

typedef struct {

  char art;
  int value;

}Roll;

void BubbleSort(Roll *,int);
void SelectionSort(Roll *,int);
int  isStable(Roll *,Roll *,int n);

int main (){

  int n,i;
  Roll A[N],B[N];

   scanf("%d",&n);
   for(i=0;i<n;i++){
    scanf(" %c",&A[i].art);
    scanf("%d",&A[i].value);
   }
   for(i=0;i<n;i++)
     B[i]=A[i];

  BubbleSort(A,n);

  for(i=0;i<n-1;i++)
    printf("%c%d ",A[i].art,A[i].value);
    printf("%c%d\n",A[n-1].art,A[n-1].value);
   printf("Stable\n");

   SelectionSort(B,n);
   
   for(i=0;i<n-1;i++)
     printf("%c%d ",B[i].art,B[i].value);
   printf("%c%d\n",B[n-1].art,B[n-1].value);
   

   if(isStable(A,B,n)==1)
     printf("Stable\n");
   else printf("Not stable\n");
   
   return 0;
}
void BubbleSort(Roll *Sort,int n){

  int i,flag=1;
  Roll tmp;
  
  while(flag){
    flag = 0;
    for(i = 0;i < n;i++){
      if(Sort[i].value < Sort[i-1].value){
	tmp = Sort[i];
	Sort[i]=Sort[i-1];
	Sort[i-1]=tmp;
	flag = 1;

      }
    }
  }
}

void SelectionSort(Roll *Sort,int n){
 
  int i,j,min;
  Roll tmp;
 
  for(i = 0;i < n;i++){
    min = i;
    for(j = i;j < n;j++){
 
      if(Sort[j].value < Sort[min].value){
    min = j;
 
      }
    }   
    if(Sort[i].value != Sort[min].value){ 
      tmp = Sort[i];
      Sort[i] = Sort[min];
      Sort[min] = tmp;
 
    }
     
  }
}
int  isStable(Roll *in,Roll *out,int n){
  
  int i,j,a,b;

  for(i = 0;i < n;i++){

    for(j = i+1;j < n;j++){

      for(a = 0;a < n;a++){

	for(b = a+1;b < n;b++){

	  if(in[i].value==in[j].value&&in[i].value == out[b].value&&in[i].art==out[b].art&&in[j].value== out[a].value&&in[j].art==out[a].art)
	    return 0;
	}
      }
    }
  }
  return 1;
}

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

int main(){
  string a,b;
  cin>>a>>b;
  int count=0;
  for(int i=0;i<a.size();i++){
      if(a[i]!=b[i]){
        count++;
      }
    }
  cout<<count;
}


Measured memory_bytes: 3900
import sys
readline = sys.stdin.buffer.readline

a,b,m = map(int,readline().split())
lst1 = list(map(int,readline().split()))
lst2 = list(map(int,readline().split()))
lst3 = []
for i in range(m):
    x,y,c = map(int,readline().split())
    lst3.append(lst1[x-1]+lst2[y-1]-c)

amin = min(lst1)
bmin = min(lst2)

abmin = min(lst3)

print(min(amin+bmin,abmin))


Measured memory_bytes: 63072
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int all = Integer.parseInt(s);
		int n = 0;
		for(char c : s.toCharArray()) {
			n += Integer.parseInt(String.valueOf(c));
		}
		System.out.println(all % n == 0 ? "Yes" : "No");
	}
}

Measured memory_bytes: 25556
#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>;

ll getmax(vector<ll> &v, ll K)
{
    ll maxi = LLONG_MIN;
    
    for (int i = 0; i < (int)v.size(); i++) {
        ll sum = 0;
        for (int j = 0; j < min((ll)v.size(), K); j++) {
            sum += v[(i + j) % v.size()];
            if (sum > maxi) maxi = sum;
        }
    }

    ll sum_all = 0;
    for (int i = 0; i < (int)v.size(); i++) {
        sum_all += v[i];
    }

    if (sum_all <= 0) return maxi;
    if (K <= (ll)v.size()) return maxi;

    ll maxi2 = sum_all * (K / v.size() - 1);
    ll remain = v.size() + (K % v.size());

    ll maxi3 = 0;
    for (int i = 0; i < (int)v.size(); i++) {
        ll sum = 0;
        for (int j = 0; j < remain; j++) {
            sum += v[(i + j) % v.size()];
            if (sum > maxi3) maxi3 = sum;
        }
    }

    if (maxi < (maxi2 + maxi3)) maxi = maxi2 + maxi3;
    return maxi;
}

int main() {
    ll N, K;
    cin >> N >> K;
    ll P[N];
    rep(i, N) {
        cin >> P[i];
        P[i]--;
    }
    ll C[N];
    rep(i, N) cin >> C[i];

    int b[N] = {0};

    ll ans = LLONG_MIN;
    
    for (int i = 0; i < N; i++) {
        if (b[i] == 0) {
            vector<ll> v;
            v.push_back(C[i]);
            b[i] = 1;
            
            int next = P[i];
            while (b[next] == 0) {
                v.push_back(C[next]);
                b[next] = 1;
                next = P[next];
            }
            ll maxi = getmax(v, K);
            if (ans < maxi) ans = maxi;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

#define MAX_P 200010
int fact[MAX_P]; //n! mid p

int extgcd(int a, int b, int &x, int &y)
{
    int d = a;
    if (b != 0)
    {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    else
    {
        x = 1;
        y = 0;
    }
    return d;
}
int mod_inverse(int a, int m)
{
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}
//n! = a p^e -> a mod p
void make_fact()
{
    fact[1] = 1;
    for (int i = 2; i < MAX_P; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    return;
}
int mod_fact(int n, int p, int &e)
{
    e = 0;
    if (n == 0)
        return 1;
    int res = mod_fact(n / p, p, e);
    e += n / p;
    if (n / p % 2 != 0)
        return res * (p - fact[n % p]) % p;
    return res * fact[n % p] % p;
}
//nCk mod p
int mod_comb(int n, int k, int p)
{
    if (n < 0 || k < 0 || n < k)
        return 0;
    int e1, e2, e3;
    int a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2), a3 = mod_fact(n - k, p, e3);
    if (e1 > e2 + e3)
        return 0;
    return a1 * mod_inverse(a2 * a3 % p, p) % p;
}

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

    int n, m, k;
    cin >> n >> m >> k;
    make_fact();
    int tmp = mod_comb(n * m - 2, k - 2, mod);
    int ans = 0;
    for (int i = 1; i <= n; i++)
        ans = (ans + (i * (n - i) * m * m) % mod) % mod;
    for (int i = 1; i <= m; i++)
        ans = (ans + (i * (m - i) * n * n) % mod) % mod;
    ans = (ans * tmp) % mod;
    cout << ans << endl;
}

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

typedef long long ll;

const long long MOD = 1000000007;
long long modpow(long long a, long long n, long long m)
{
    long long ans = 1;
    while (n)
    {
        if (n & 1)
        {
            ans = (ans * a) % m;
        }
        a = (a * a) % m;
        n >>= 1;
    }
    return ans;
}
long long combi(long long n, long long a)
{
    long long ans = 1, ans1 = 1;
    for (long long i = n - a + 1; i <= n; i++)
    {
        ans *= i % MOD;
        ans %= MOD;
    }

    for (long long i = 2; i <= a; i++)
        ans1 = (ans1 * i) % MOD;
    ans1 = modpow(ans1, MOD - 2, MOD);
    return ((ans % MOD) * ans1) % MOD;
}

int main()
{

    ll H, W;
    cin >> H >> W;

    if(H==1 || W==1){
        cout << 1 << endl;
        return 0;
    }

    if (H % 2 == 0)
    {
        if (W % 2 == 0)
        {
            cout
                << to_string(H * W / 2).c_str() << endl;
        }
        else
        {
            ll a = (ceil(W / 2.0)) * floor(H / 2.0);
            ll b = (floor(W / 2.0)) * floor(H / 2.0);
            cout
                << to_string(a + b).c_str() << endl;
        }
    }
    else
    {
        if (W % 2 == 0)
        {
            ll a = (floor(W / 2.0)) * ceil(H / 2.0);
            ll b = (floor(W / 2.0) * floor(H / 2.0));
            cout << to_string(a + b).c_str() << endl;
        }
        else
        {
            ll a = (ceil(W / 2.0)) * ceil(H / 2.0);
            ll b = (floor(W / 2.0) * floor(H / 2.0));
            cout << to_string(a + b).c_str() << endl;
        }
    }
    return 0;
}


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

typedef pair<int, int> PII;

int main(){
  int N, M;
  while(cin >> N >> M){
    if(N == 0 && M == 0) break;
    vector<PII> route;
    PII tmp;
    for(int i = 0 ; i < N ; i++){
      cin >> tmp.second >> tmp.first;
      route.push_back(tmp);
    }
    sort(route.begin(), route.end());
    reverse(route.begin(), route.end());
    for(int i = 0 ; i < N ; i++){
      if(M == 0) break;
      if(M >= route[i].second){
	M -= route[i].second;
	route[i].first = 0;
      }
      else if(M < route[i].second){
	route[i].second -= M;
	M = 0;
      }
    }
    int ans = 0;
    for(int i = 0 ; i < N ; i++){
      ans += route[i].first * route[i].second;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1324
N=int(input())
L=list(map(int,input().split()))
L.sort()
count=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i]!=L[j]!=L[k]:
                sum_=L[i]+L[j]+L[k]
                if max(L[i],L[j],L[k])*2<sum_:
                    count+=1                

print(count)

Measured memory_bytes: 9072
#include <stdio.h>

int main(void) {
  int m, f, r;
  while (1) {
    scanf("%d %d %d", &m, &f, &r);
    if (m == -1 && f == -1 && r == -1)
      return 0;
    if (m == -1 || f == -1)
      printf("F\n");
    else {
      if ((m + f) >= 80)
	printf("A\n");
      else if ((m + f) >= 65)
	printf("B\n");
      else if ((m + f) >= 50)
	printf("C\n");
      else if ((m + f) >= 30) {
	if (r >= 50)
	  printf("C\n");
	else
	  printf("D\n");
      } else
	printf("F\n");
    }
  }
  return 0;
}



Measured memory_bytes: 2032
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  rep(i,N) cin >> S[i];
  sort(S.begin(),S.end());
  int ans = 0;

  for(int i = 1;i < N;i++){
    if(S.at(i-1) != S.at(i))ans++;
  }
  cout << ans+1 << endl;
 }


Measured memory_bytes: 9600
x, y = map(int, input().split())
k = 0  # k is number of torts
flag = False
for k in range(y//4+1):
    tot = (4*k)+(2*(x-k))
    if tot == y:
        flag = True
        break
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 61812
use std::cmp::Ordering;

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

use std::collections::BinaryHeap;
#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
        aa: [usize; n],
        mut query: [(usize, usize); m]
    }
    let mut heap: BinaryHeap<_> = aa.into_iter().map(Rev).collect();

    query.sort_by(|&(lb, lc), &(rb, rc)| {
        match lc.cmp(&rc) {
            std::cmp::Ordering::Equal => lb.cmp(&rb),
            other => other
        }
    });

    for &(b, c) in query.iter().rev() {
        if let Some(&Rev(m)) = heap.peek() {
            if m >= c {
                break;
            }
        }
        for _ in 0..min(b, n) {
            heap.push(Rev(c));
        }
        while heap.len() > n {
            heap.pop();
        }
    }
    let result = heap.iter().fold(0, |sum, &Rev(a)| sum + a);
    println!("{}", result);
}



Measured memory_bytes: 10492
#include <iostream>

int main ()
{
  int H, W, N;

  std::cin >> H >> W >> N;

  auto largeSide = std::max(H, W);

  auto mod = N % largeSide;
  int min;
  if (mod == 0)
    min = N/largeSide;
  else
    min = (N / largeSide) + 1;
  std::cout << min << std::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)
using ll = long long;
using P = pair<int,int>;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a == 5 && b == 5){
    if(c == 7){
      puts("YES");
      return 0;
    }
  }
  else if(a == 5 && b == 7){
    if(c == 5){
      puts("YES");
      return 0;
    }
  }
  else if(a == 7 && b == 5){
    if(c == 5){
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}


Measured memory_bytes: 256
/**********************
 * Author: Cloud_     *
 * Date:   19.04.2020 * 
 * Time:   17.53.32   *
 *                    *
***********************/
#include <bits/stdc++.h>
using namespace std;

#define gap " "
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int N=2*100009;
int ar[N];
int main()
{
  fastio; 
  int n,i,r;
  cin>>n;
  for(i=2; i<=n; i++)
  {
  	 cin>>r;
  	 ar[r]++;
  }
  for(i=1; i<=n; i++)
  {
  	cout<<ar[i]<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      int N;
      cin >> N;
      vector<LL> monster (N+1);
      vector<LL> hero (N);
      for(int i = 0;i <= N;i++){
          cin >> monster[i];
      }
      for(int i = 0;i < N;i++){
          cin >> hero[i];
      }

      LL ans = 0;
      for(int i = 0;i < N;i++){
          ans += min(monster[i],hero[i]);
          hero[i] -= monster[i];
          if(hero[i] > 0){
              ans += min(monster[i+1],hero[i]);
              monster[i+1] = monster[i+1]-hero[i];
              if(monster[i+1] < 0)monster[i+1] = 0;
          }
      }
      cout << ans << endl;
}


Measured memory_bytes: 1792
N = int(input())
A= list(map(int,input().split()))
mod_num = int(1.0e+9 + 7)
rest = 0
temp = 0

for i in range(N-1):
  temp+=A[i]
  rest += temp*A[i+1]
  rest = rest%mod_num

print(int(rest%mod_num))

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

int main() {
  int N, j, k;
  cin >> N;
  j=0;
  for (int i=0;i<6;i++){
    if (N < pow(10,i)){
      break;
    }
    j++;
  }
  if (j==1){
    k=N;
  }
  if (j==2){
    k=9;
  }
  if (j==3){
    k=9+(N-99);
  }
  if (j==4){
    k=909;
  }
  if (j==5){
    k=909+(N-9999);
  }
  if (j==6){
    k=90909;
  }
  cout << k << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x, a, b;
	while (~scanf("%d %d %d", &x, &a, &b))
	{
		int a1 = x - a;
		int b1 = a1 - (a1 / b)*b;
		printf("%d\n", b1);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
const int INF = 10e9 + 5;
int main()
{
	int n;
	cin >> n;
	vector<int> h(n);
	vector<int> dp(n,INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) cin >> h[i];
	for (int i = 0; i < n; i++) {
		if (i + 1 < n) dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		if (i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}
	cout << dp[n - 1];
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define lli long long int 
#define ll long long 
#define f(i, n) for(int i=0; i<n; i++)

using namespace std;


void test(){
	int n;
	
	cin>>n;
	
	int  ac=0;
	int  wa=0;
	int tle=0;
	int  re=0;
	string s;
	for( int i=1; i<=n ;i++){
		cin>>s;
		if(s == "AC"){
			ac++;
		}else if(s == "WA"){
			wa++;
		}else if(s == "TLE"){
			tle++;
		}else{
			re++;
		}
	}
	
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
	
}
int main(){
	
	/*int t;
	cin>>t;
	
	while(t--){
		test();
	}
	*/
	test();
	return 0;

}







Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, m, l;
    cin >> n >> m >> l;
    constexpr ll inf = 1e+17;
    vector<vector<ll>> dist(n, vector<ll>(n, inf));
    for(int i = 0; i < n; ++i)  dist[i][i] = 0;
    for(int i = 0; i < m; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        if(c > l)   continue;
        --a, --b;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                chmin(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    vector<vector<ll>> ans(n, vector<ll>(n, inf));
    for(int i = 0; i < n; ++i)  ans[i][i] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < i; ++j){
            if(dist[i][j] == inf)   continue;
            if(dist[i][j] <= l){
                ans[i][j] = ans[j][i] = 1;
            }
        }
    }
    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                chmin(ans[i][j], ans[i][k] + ans[k][j]);
            }
        }
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < i; ++j){
            if(ans[i][j] == inf)    ans[i][j] = ans[j][i] = 0;
        }
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; ++i){
        int s, t;
        cin >> s >> t;
        --s, --t;
        cout << ans[s][t] - 1 << '\n';
    }
}

Measured memory_bytes: 1920
import java.io.InputStream;
import java.io.PrintStream;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    AnsCounter counter = new AnsCounter();
    IntStream.range(0, n).mapToObj(i -> sc.next())
      .forEach(s -> counter.add(Integer.valueOf(s)));
    pw.println(counter.count);
  }

  private static class AnsCounter {

    int count = 0;
    LinkedList<Integer> numbers = new LinkedList<>();

    void add(Integer n) {
      if (numbers.size() == 3) {
        numbers.poll();
      }
      numbers.add(n);
      if (numbers.size() == 3) {
        int elem1 = numbers.get(0);
        int elem2 = numbers.get(1);
        int elem3 = numbers.get(2);
        if (elem1 <= elem2 && elem2 < elem3) {
          count++;
        }
        if (elem3 <= elem2 && elem2 < elem1) {
          count++;
        }
      }
    }
  }
}


Measured memory_bytes: 28624
#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  rep(i, n) {
    char c = s[i];
    if (i == k - 1) {
      c = c - 'A' + 'a';
    }
    cout << c;
  }
  cout << '\n';
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int dp[SIZE][13];

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

    string s;
    cin >> s;
    for(int i = 0; i < s.size(); ++i) {
        int d = s[i] - '0';
        if(i == 0) {
            if(s[i] == '?') {
                for(int j = 0; j < 10; ++j) {
                    dp[i][j] = 1;

                }
            } else {
                dp[i][d] = 1;

            }
        } else {
            if(s[i] == '?') {
                for(int j = 0; j < 13; ++j) {
                    for(int k = 0; k < 10; ++k) {
                        dp[i][(j * 10 + k) % 13] = (dp[i][(j * 10 + k) % 13] + dp[i - 1][j]) % MOD;

                    }
                }
            } else {
                for(int j = 0; j < 13; ++j) {
                    dp[i][(j * 10 + d) % 13] = (dp[i][(j * 10 + d) % 13] + dp[i - 1][j]) % MOD;

                }
            }
        }
    }
    cout << dp[s.size() - 1][5] << endl;

    return 0;
}



Measured memory_bytes: 6608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)
 
int main(){
    int n; cin>> n;
    vector<ll> h(n);
    int ans=0;
    int cnt=0;
    forin(h, n);
    for(int i=0; i<n-1; i++){
        if(h[i] >= h[i+1]){
            cnt++;
        }else{
            cnt=0;
        }
        ans=max(cnt, ans);
    }
    cout<<ans<<endl;
}

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

using namespace std;

const int MX = 100 * 1000 + 7;

int c[MX], s[MX], f[MX];
bool o(char c) {
    return isdigit(c);
}
void n() {
    cout << "No" << endl;
    exit(0);
}
int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;
    for (int i = 0; i < a; i++) {
        if (!o(s[i])) n();
    }
    if (s[a] != '-') n();
    for (int i = a + 1; i < s.length(); i++) {
        if (!o(s[i])) n();
    }
    cout << "Yes" << endl;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long K, long long Q, std::vector<int> A){
    vector<ll> H(N);
    rep(i,N) H[i]=K-Q;
    rep(i,Q) H[A[i]-1]+=1;
    rep(i,N) (H[i]>0) ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long Q;
    scanf("%lld",&Q);
    std::vector<int> A(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%d",&A[i]);
    }
    solve(N, K, Q, std::move(A));
    return 0;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=0;i<=(n);i++)

int main(){
	int x, y;
	cin >> x>> y;

	cout << x * y / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
z = []
isum = 0
for _ in range(n):
    z.append(list(map(int, input().split())))

for i in range(n):
    for j in range(n):
        if i == j:
            continue
        else:
            isum += math.factorial(n-1)*math.sqrt((z[i][0] - z[j][0])*(z[i][0] - z[j][0]) + (z[i][1] - z[j][1])*(z[i][1] - z[j][1]))
            #print(i,j,isum)

print(isum/math.factorial(n))

Measured memory_bytes: 38256
/*
g++ -std=c++11 -o2 -Wall ABC119B.cpp -o .\out\ABC119B.out
.\out\ABC119B.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

double eps = 1e-7;

long double x[15];
string u[15];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int N;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> x[i] >> u[i];
  }
  long double ans = 0.0L;
  for (int i = 0; i < N; ++i) {
    if (u[i]=="JPY") {
      ans += x[i];
    } else {
      ans += 380000 * x[i];
    }
  }
  ans += eps;
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000;

typedef long long ll;
typedef unsigned long long ull;

int main(void) {
  int n; cin >> n;
  int loop = 1 << n;

  int a[20];
  int x[20][20], y[20][20];
  rep(i, n) {
    cin >> a[i];
    rep(j, a[i]) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  int ans = 0;

  rep(i, loop) {
    int flag = 0;
    rep(j, n) {
      int f = ((i >> j) & 1);
      rep(k, a[j]) {
	if (f == 1) {
	  if (((i >> x[j][k]) & 1) != y[j][k]) flag++;
	} 
	if (flag > 0) break;
      }
      if (flag > 0) break;
    }
    if (flag == 0) {
      int cnt = 0;
      rep(j, n) cnt += (i >> j) & 1;
      ans = max(ans, cnt);
    }
  }

  cout << ans << endl;

  return 0;
}
	


Measured memory_bytes: 256
#include<stdio.h>

int main() {
    int a, b, c, k;
    scanf("%d%d%d%d", &a, &b, &c, &k);
    while(a >= b) {
        b *= 2;
        k--;
        if(k < 0) {
            break;
        }
    }
    while(b >= c) {
        c *= 2;
        k--;
        if(k < 0) {
            break;
        }
    }
    if(k < 0) {
        printf("No\n");
    }
    else {
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 1660
N=int(input())
d=[list(map(int,input().split())) for x in range(N)]

for i in range(N-2):
	if d[i][0]==d[i][1]:
		if d[i+1][0]==d[i+1][1]:
			if d[i+2][0]==d[i+2][1]:
				print("Yes")
				exit()

print("No")

Measured memory_bytes: 9188
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
//const ll MOD = 998244353
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll M;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> M;
    ll sum = 0;
    ll x = 0;
    rep(i,M) {
        ll d, c; cin >> d >> c;
        x += d*c;
        sum += c;
    }
    ll ans = sum-1;
    while (x >= 10) {
        ans += x/10;
        x = x/10 + x%10;
    }
    cout << ans << endl; 
}

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

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)

int main(int argc, const char * argv[]) {
    
    ll N;
    cin >> N;
    
    vector<ll> data(N);
    REP(i, N) cin >> data[i];
    
    sort(data.begin(), data.end());
    
    cout << data[N/2] - data[-1 + N/2];
    
    return 0;
}

Measured memory_bytes: 1024
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
A=get_i
res=A.inject(0){|res,x| res^=x}
ans=[]
A.each do|a|
    res^=a
    ans.push(res)
    res^=a
end
puts ans.join(" ")

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

typedef long double ld;

const ld EPS = 1e-9;
const ld INF = 1e10;
const ld PI = M_PI;

struct Point{
  ld x, y;
  Point(ld x, ld y):x(x), y(y){}
  Point(){}
};

Point operator+(const Point &a, const Point &b){
  return Point(a.x + b.x, a.y + b.y);
}
Point operator-(const Point &a, const Point &b){
  return Point(a.x - b.x, a.y - b.y);
}
Point operator*(const Point &a, const ld b){
  return Point(a.x * b, a.y * b);
}
Point operator*(const Point &a, const Point &b){
  return Point(a.x*b.x-a.y*b.y, a.x*b.y+a.y*b.x);
}
Point operator/(const Point &a, const ld b){
  return Point(a.x / b, a.y / b);
}

bool operator<(const Point &a, const Point &b){
  return make_pair(a.x, a.y) < make_pair(b.x, b.y);
}
bool operator==(const Point &a, const Point &b){
  return a.x == b.x && a.y == b.y;
}

ld cross(const Point &a, const Point &b){
  return a.x*b.y - a.y*b.x;
}

ld dot(const Point &a, const Point &b){
  return a.x*b.x + a.y*b.y;
}

ld norm(const Point &a){
  return dot(a, a);
}

struct Line:vector<Point>{
  Line(Point a = Point(0, 0), Point b = Point(0, 0)){
    this->push_back(a);
    this->push_back(b);
  }
};

typedef vector<Point> Polygon;

int ccw(Point a, Point b, Point c){
  b = b - a;
  c = c - a;
  if(cross(b, c) > EPS) return +1; // 反時計周り
  if(cross(b, c) < -EPS) return -1; // 時計周り
  if(dot(b, c) < 0) return +2; // c -- a -- b がこの順番に一直線上
  if(norm(b) < norm(c)) return -2; // a -- b -- c がこの順番に一直線上
  return 0; // a -- c -- b が一直線上
}

Point next(const Polygon &a, int x){
  return a[(x+1)%a.size()];
}

Point prev(const Polygon &a, int x){
  return a[(x-1+a.size()) % a.size()];
}

bool eq(ld a,ld b){ return abs(a-b) < EPS; }

bool compare(const Point &a, const Point &b){
  if(eq(a.y, b.y)) return a.x < b.x;
  return a.y < b.y;
}

Polygon convex_hull(Polygon ps){
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end(), compare);
  Polygon ch(2*n);
  for(int i = 0 ; i < n ; i++){
    while(k > 1 && ccw(ch[k-2], ch[k-1], ps[i]) == -1) --k;    
    ch[k++] = ps[i];
  }
  int t = k;
  for(int i = n-2 ; i >= 0 ; i--){
    while(k > t && ccw(ch[k-2], ch[k-1], ps[i]) == -1) --k;
    ch[k++] = ps[i];
  }
  ch.resize(k-1);
  return ch;
}


int main(){
  int q;
  cin >> q;
  Polygon poly;
  while(q--){
    Point p;
    double x, y;
    scanf("%lf %lf", &x, &y);
    poly.push_back(Point(x, y));
  }
  
  Polygon ans = convex_hull(poly);
  cout << ans.size() << endl;
  for(int i = 0 ; i < (int)ans.size() ; i++){
    cout << ans[i].x << ' ' << ans[i].y << endl;
  }
  
  return 0;
}

Measured memory_bytes: 13800
import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val b = ArrayList(readLine()!!.split(" ").map{it.toInt()})
    val S = ArrayDeque<Int>()

    while (b.isNotEmpty()) {
        var updated = false
        for (i in b.size - 1 downTo 0) {
            if (i + 1 == b[i]) {
                b.removeAt(i)
                S.addLast(i + 1)
                updated = true
                break
            }
        }
        if (!updated) {
            println(-1)
            return
        }
    }

    while (S.isNotEmpty()) {
        println(S.removeLast())
    }
}


Measured memory_bytes: 37692
n = int(input())
h = list(map(int, input().split()))

dp = [0] * n
dp[1] = abs(h[0] - h[1])

for i in range(2, n):
    dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                dp[i - 1] + abs(h[i] - h[i - 1]))

print(dp[-1])

Measured memory_bytes: 52208