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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

bool is_prime(int x) {
    if(x==2) return true;
    int dmax = sqrt(x) + 1;
    for(int d=2; d<=dmax; ++d) {
        if(x%d==0) return false;
    }

    return true;
}

int main()
{
    int n;
    while(cin>>n, n) {
        int c = 0;
        for(int i=n+1; i<=2*n; ++i) {
            if(is_prime(i)) c++;
        }
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 3024
using System;
using System.Collections.Generic;
using System.Collections;


namespace ConsoleApplication21
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList T = new ArrayList();

            for (int i = 0; i < i+ 1; i++)
            {
                String[] input = Console.ReadLine().Split(' ');
                int m = int.Parse(input[0]);
                int f = int.Parse(input[1]);
                int r = int.Parse(input[2]);
                if (m == -1 && f == -1 && r == -1)
                    break;
                else if (m == -1 || f == -1)
                    T.Add("F");
                else
                {
                    int test = m + f;
                    if (80 <= test)
                        T.Add("A");
                    else if (65 <= test && test < 80)
                        T.Add("B");
                    else if (50 <= test && test < 65)
                        T.Add("C");
                    else if (30 <= test && test < 50)
                    {
                        if (50 <= r)
                            T.Add("C");
                        else if (r < 50)
                            T.Add("D");
                    }
                    else if (test < 30)
                        T.Add("F");
                }
                Console.WriteLine(T[i]);
            }
        }
    }
}

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

int main() {
  	long long int N;
   	cin >> N;
  	long long int A[N];
  	for (int i = 0; i < N; i++) cin >> A[i];
  
  	long long int num[N + 1];
  	long long int count;
  	long long int res[N];
  	
  	for (int i = 0; i < N + 1; i++) num[i] = 0;
  	for (int i = 0; i < N; i++) num[A[i]]++;
  
  	for (int i = 1; i < N + 1; i++){
      	if (num[i] == 0 || num[i] == 1) continue;
      	count += num[i] * (num[i] - 1) / 2;
    }
  
  	for (int i = 0; i < N; i++){
      	res[i] = count - num[A[i]] + 1;
    }
  
  	for (int i = 0; i < N; i++){
      	cout << res[i] << endl;
    }
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;


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

  ll n, t;
  cin >> n >> t;
  vector<pll> food(n);
  for (int i = 0; i < n; i++) cin >> food[i].first >> food[i].second;
  sort(food.begin(), food.end());
  //cout << "sort" << endl;

  vector<vector<ll>> dp(n+1, vector<ll>(t+1, 0));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= t; j++) {
      dp[i][j] =  max(dp[i-1][j], dp[i][j-1]);
      if (j >= food[i-1].first) dp[i][j] = max(dp[i][j], dp[i-1][j-food[i-1].first] + food[i-1].second);
    }
  }

  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, dp[i-1][t-1] + food[i-1].second);
  }
  cout << ans << endl;
}


Measured memory_bytes: 73680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;

    int l,r;
    int sum;

    for(int i=0; i<N; i++){
        cin >> l >> r;
        sum +=  r-l;
        sum++;
        if(i == N-1){
            cout << sum << endl; 
        }        
    }
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    LIST = [0] * 100001
    for i in range(n):
        l,r = readInts()
        l -=1
        # いもす法
        LIST[l] +=1
        LIST[r] -=1
    # 累積和
    for i in range(1,100001):
        LIST[i] += LIST[i-1]
    cnt = 0
    for i in range(100001):
        if LIST[i] > 0:
            cnt += 1
    #print(LIST)
    print(cnt)
if __name__ == '__main__':
  main()


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

int main() {
  vector<int>A(9);
  int N;
  for(int i=0;i<9;i++){
    cin>>A[i];
  }
  cin>>N;
  vector<int>b(N);
  for(int i=0;i<N;i++){
    cin>>b[i];
  }
  int C=0;
  for(int i=0;i<9;i++){
    for(int j=0;j<N;j++){
      if(A[i]==b[j]){
        C+=1;
        if(j==N-1){
          if(C>=1){
            A[i]*=0;
            C*=0;
          }
        }
      }
      else{
        if(j==N-1){
          if(C>=1){
            A[i]*=0;
            C*=0;
          }
        }
      }
    }
  }
  if(A[0]==0&&A[1]==0&&A[2]==0){
    cout<<"Yes"<<endl;
  }
  else if(A[0]==0&&A[3]==0&&A[6]==0){
    cout<<"Yes"<<endl;
  }
  else if(A[0]==0&&A[4]==0&&A[8]==0){
    cout<<"Yes"<<endl;
  }
  else if(A[1]==0&&A[4]==0&&A[7]==0){
    cout<<"Yes"<<endl;
  }
  else if(A[2]==0&&A[4]==0&&A[6]==0){
    cout<<"Yes"<<endl;
  }
  else if(A[2]==0&&A[5]==0&&A[8]==0){
    cout<<"Yes"<<endl;
  }
  else if(A[3]==0&&A[4]==0&&A[5]==0){
    cout<<"Yes"<<endl;
  }
  else if(A[6]==0&&A[7]==0&&A[8]==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main() {
  int k;
  vector<int> vec(5);
  for (int i = 0; i < 5; i++) {
    cin >> vec[i];
  }
  cin >> k;
  
  for (int i = 0; i < 5; i++) {
    if (vec[4] - vec[i] > k) {
      cout << ":(" << endl;
      return 0;
    }
  }
  cout << "Yay!" << endl;
  return 0;
}


Measured memory_bytes: 256
let id x = x

module Infseq =
  struct
    type 'a seq = Cons of 'a * (unit -> 'a seq)
    
    let rec nth n sq =
      match (n, sq) with
      | (0, Cons (x, _)) -> x
      | (n, Cons (x, f)) -> nth (n - 1) (f ())
    
    let rec take n sq =
      match (n, sq) with
      | (0, Cons (_, _)) -> []
      | (n, Cons (x, f)) -> x :: take (n - 1) (f ())
    
    let rec drop n sq =
      match (n, sq) with
      | (0, Cons (_, _)) -> sq
      | (n, Cons (x, f)) -> drop (n - 1) (f ())
    
    let rec map g (Cons (x, f)) = Cons (g x, fun () -> map g (f ()))
  end

let rec prime x = 
  let rec is_dividable m l =
    (m >= l * l) && ((x mod l = 0) || is_dividable m (l + 1)) in
  if is_dividable x 2 then prime (x + 1) else Infseq.Cons (x, fun () -> prime (x + 1))

let _ = 
  let rec loop () = 
    let n = Scanf.scanf "%d\n" id in
    if n = 0 then ()
    else
      begin
        Printf.printf "%d\n" (List.fold_left (+) 0 (Infseq.take n (prime 2)));
        loop ()
      end
  in loop ()

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

int power(int m, int n);

int main(void)
{
    int d,g,p[10],c[10],i,j,comp[1024][10],score,ans=1000,num,jmax;

    scanf("%d %d",&d,&g);
    for ( i = 0; i < d; i++)
    {
        scanf("%d %d",p+i,c+i);
    }

    for ( i = 0; i <= power(2,d)-1; i++)
    {
        for ( j = 0; j < d; j++)
        {
            comp[i][j]=(i%power(2,j+1))/power(2,j);
        }
    }

    for ( i = 0; i <= power(2,d)-1; i++)
    {
        score=0;
        num=0;
        for ( j = 0; j < d; j++)
        {
            if(comp[i][j]==1)
            {
                score+=p[j]*100*(j+1)+c[j];
                num+=p[j];
            }
        }
    
        if(score<g)
        {
            jmax=-1;
            for ( j = 0; j < d; j++)
            {
                if(comp[i][j]==0) jmax=j;
            }
            if(jmax!=-1)
            {
                if(((g-score)+(100*(jmax+1))-1)/(100*(jmax+1))<=p[jmax]-1)
                {
                    num+=((g-score)+(100*(jmax+1))-1)/(100*(jmax+1));
                    if(ans>num) ans=num;
                }
            }
        }
        else if(ans>num) ans=num;
    }

    printf("%d",ans);

    return 0;
}

int power(int m, int n)
{
    int p=1;
    for (int i = 0; i < n; i++)
    {
        p*=m;
    }

    return p;
}

Measured memory_bytes: 256
N, W = map(int, input().split())
value, weight = [], []
for _ in range(N):
    v, w = map(int, input().split())
    value.append(v)
    weight.append(w)
dp = [[-1]*(W+1) for _ in range(N+1)]
for i in range(W+1):
    dp[0][i] = 0
for i in range(N):
    for w in range(W+1):
        if weight[i] <= w:
            dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]
print(dp[N][W])



Measured memory_bytes: 41900
#include<iostream>
using namespace std;
int main (){
  int card[3][3];
  for (int i = 0; i < 3; i ++) {
    for (int j = 0; j < 3; j ++) {
      cin >> card[i][j];
    }
  }
  int N;
  cin >> N;
  if (N < 3) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < N; i ++) {
    int b;
    cin >> b;
    for (int j = 0; j < 3; j ++) {
      for (int k = 0; k < 3; k ++) {
        if (card[j][k] == b) card[j][k] = 0;
      }
    }
  }
  bool bi = false;
  for (int i = 0; i < 3; i ++) {
    if (!(card[i][0]) && !(card[i][1]) && !(card[i][2])) {
      bi = true;
    }
    if (!(card[0][i]) && !(card[1][i]) && !(card[2][i])) {
      bi = true;
    }
  }
  if (!(card[0][0]) && !(card[1][1]) && !(card[2][2])) bi = true;
  if (!(card[2][0]) && !(card[1][1]) && !(card[0][2])) bi = true;
  cout << (bi ? "Yes" : "No") << endl;
}

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

using namespace std;

int main(){
	string str;

	cin >> str;

	if (str.size() >= 4 and str.substr(0, 4) == "YAKI"){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
const int N=2005;
int l[N][N],r[N][N],h[N][N],n,m,ans,mp[N][N],a[N][N];
char s[N];
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int main(){
//	freopen("ex.in","r",stdin);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%s",s+1);
		for(int j=1;j<=m;++j) mp[i][j]=(s[j]=='#');
	}
	for(int i=1;i<n;++i) for(int j=2;j<=m;++j) if((mp[i][j]^mp[i+1][j])==(mp[i][j-1]^mp[i+1][j-1])) a[i][j]=1;
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j){
		if(a[i][j]==1) h[i][j]=h[i-1][j]+1,l[i][j]=l[i][j-1]+1;
		if(a[i][m-j+1]==1) r[i][m-j+1]=r[i][m-j+2]+1;
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			if(h[i][j]>1){
				l[i][j]=min(l[i][j],l[i-1][j]);
				r[i][j]=min(r[i][j],r[i-1][j]);
			}
			ans=max(ans,(l[i][j]+r[i][j])*(h[i][j]+1));
		}
	}
	printf("%d\n",max(ans,max(m,n)));
	return 0;
} 

Measured memory_bytes: 78720
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] nums=new int[sc.nextInt()];
        int biggest=0;
        for(int i=0;i<nums.length;i++){
            nums[i]=sc.nextInt();
            if(nums[i]>biggest)biggest=nums[i];
        }
        int a=biggest;
        for(int i=0;i<nums.length;i++){
            biggest-=nums[i];
        }
        if(biggest+a<0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        
        
        

}

}


Measured memory_bytes: 21844
#include<stdio.h>

int N;

int main(){
    int sum, n;
    scanf("%d", &N);

    sum = 0; n = N;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    printf("%s", N % sum == 0 ? "Yes":"No");
    return 0;
}

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

int main() {
  int n, l, sum=0;
  cin >> n >> l;
  int badTaste = l;
  int goodTaste = l+n-1;
  sum=(badTaste+goodTaste)*n/2;
  if(badTaste>0) sum-=badTaste;
  else
  if(goodTaste<0) sum-=goodTaste;
  cout << sum << endl;
}


Measured memory_bytes: 3632
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  REP(i,n){
    REP(j,n){
      vec b = a;
      swap(b[i],b[j]);
      bool flag = true;
      REP(k,n-1) if(b[k] > b[k+1]) flag = false;
      if(flag){
        cout << "YES" << endl;
        return 0;
      }
    }
  }

  cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int L[2019] , n;
int find3rd(int x , int y)
{
    int left = y+1 , right = n - 1 , mid;
    int ans = -1;
    while(left <= right)
    {
        mid = (left + right)/2;
        if(L[mid] < L[x] + L[y])
        {
            left = mid + 1;
            ans = mid;
        }
        else right = mid - 1;
    }
    if(ans == -1)
        return 0;
    return ans - y;
}

int main()
{
    cin >> n;
    for(int i=0 ; i<n ; i++)
        cin >> L[i];
    sort(L , L+n);
    int ans = 0;
    for(int i=0 ; i<n ; i++)
        for(int j=i+1 ; j<n ; j++)
            ans += find3rd(i , j);
    cout << ans;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int N, K;
    cin >> N >> K;

    string str;
    cin >> str;

    str[K-1] = tolower(str[K-1]);
    cout << str << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int x = Integer.parseInt(chr[0]);
			int a = Integer.parseInt(chr[1]);
			int b = Integer.parseInt(chr[2]);
			System.out.println(a-b>=0 ?"delicious"
							  :b-a>x ?"dangerous"
							  :"safe");

		}
	}
}


Measured memory_bytes: 25180
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	char c; cin >> c;
	cout << (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ? "vowel" : "consonant") << endl;
}

Measured memory_bytes: 256
import math
n = int(input())

lis = list(map(int, input().split()))

nlis = sorted(lis)

med1 = nlis[n//2-1]
med2 = nlis[n//2]

for i in lis:
    if i <= med1:
        print(med2)
    else:
        print(med1)

Measured memory_bytes: 30704
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <math.h>
using namespace std;

int main(void){
    int n, l;
    cin >> n >> l;

    int sum = 0;

    for(int i = 1; i <= n; i++){
        sum += l + i - 1;
    }

    int min = 1000000;
    for(int i = 1; i <= n; i++){
        if(abs(l + i - 1) < abs(min)){
            min = l + i - 1;
        }
    }

    cout << sum - min << endl;
}

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

#define N 100000

int A[N];

int partition(int p, int r) {
    
    int x = A[r], i = p - 1, j, tmp;
    
    for (j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    tmp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = tmp;
    
    return i + 1;
}

int main(void){
    int i, n, j;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    
    i = partition(0, n - 1);
    
    for (j = 0; j < n - 1; j++) {
        if (j == i) {
            printf("[%d] ", A[j]);
        } else {
            printf("%d ", A[j]);
        }
    }
    if (j == i) {
        printf("[%d]\n", A[j]);
    } else {
        printf("%d\n", A[j]);
    }

    return 0;
}



Measured memory_bytes: 2108
n = int(input())

INF = 1 << 60
dp = [[INF] * n + [0] for _ in range(3)]

# 直前の行動と次の行動だけシミュレーションすればよい
for i in range(n):
    a, b, c = map(int, input().split())
    dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a
    dp[1][i] = max(dp[2][i - 1], dp[0][i - 1]) + b
    dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + c

print(max(list(zip(*dp))[n - 1]))

Measured memory_bytes: 23584
A,B,K = map(int,input().split())
counter = 0
while True:
    if A%2 != 0:
        A -= 1
    A = A/2
    B += A
    counter += 1

    if counter == K:
        break
    if B%2 != 0:
        B -= 1
    B = B/2
    A += B
    counter += 1

    if counter == K:
        break

print(int(A),int(B))


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
using namespace std;

const ll MAX =  1000 * 1000 ;
const int dx[] = { 1, -1 , 0 , 0  };
const int dy [] = { 0 ,0 , 1 , -1  };
const int MOD = 1000 * 1000 * 1000 + 7 ;
const int N = 301 ;
const int INF = INT_MAX ;
const int M = 200005;
int a[MAX] , b[MAX] ; 
int dp[MAX] ; 
int main ( ){
int h , n ; 
cin >> h >> n ; 
for ( int i = 0 ; i < n ; ++i )
	cin >> a[i] >> b[i] ;
memset(dp, 0x3f, sizeof(dp));

dp[0] = 0 ; 
for ( int j = 0 ; j < n ; ++j ){
	for ( int i = 1 ; i <= h ;  ++i ){
	
		dp[i] = min ( dp[i] , b[j] + dp[max ( 0 , i - a[j])]);  
		// cout <<dp[i] << " " <<  b[j] <<"+" <<  dp[max ( 0 , i - a[j])];br
		// cout << i <<"="<< dp[i] ; br  
	}
}
cout << dp[h] ; 
 
return 0 ;

}


Measured memory_bytes: 6400
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
const int N = 16;
const ll MN = -1e9*N;
int n;
int a[N][N];
ll dp[(1<<N)];
ll value[(1<<N)];
int arr[N];
ll solve(int msk = (1<<n)-1)
{
  if (!msk)return 0;
  ll &ret = dp[msk];
  if (~ret)return ret;
  ret = MN;
  for (int cur_msk = msk; cur_msk; cur_msk=(cur_msk-1)&msk)
  {
    ret = max(ret, value[cur_msk] + solve(msk^cur_msk));
  }
  return ret;
}
ll get_cost(int sz)
{
  ll ret = 0;
  for (int i = 0; i < sz; i++)
    for (int j = i+1; j < sz; j++)
      ret += a[arr[i]][arr[j]];
  return ret;
}
int main()
{
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      scanf("%d", a[i]+ j);
  memset(dp, -1, sizeof dp);
  for (int i = 0; i < (1<<n); i++)
  {
    int idx = 0;
    for (int j = 0; j < n; j++)
    {
      if (i & (1<<j))arr[idx++] = j;
    }
    value[i] = get_cost(idx);
  }
  printf("%lld\n", solve());
}


Measured memory_bytes: 4812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define ALLRANGE(x) x.begin(), x.end()
using namespace std;

int main(){
  int R, G;
  cin >> R >> G;
  cout << (G-R)*2+R << endl;
  return 0;
}

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

typedef long long ll;
// #define int ll
#define pb push_back
// const int INF = 1e18;
const int inf = 1e9;

signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);





	string s;
	cin>>s;
	if (s=="ARC")
		cout<<"ABC";
	else
		cout<<"ARC";
	

	return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String N = sc.next();
		String ans = "Yes";

		if(N.contains("9")) {
			ans = "Yes";
		} else {
			ans = "No";
		}

		System.out.println(ans);
	}
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i, n) for (ll i = 0; i < (n); i++)
#define forn for (ll i = 0; i < (n); i++)
#define fori(i, k, n) for (ll i = k; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
template <typename T>
void print(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(deque<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(vector<vector<T>> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

int main()
{
	fast;
	long double A, B;
	cin >> A >> B;
	cout << (ll)(A * B) << endl;
	return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    vector<vector<ll>> A(3,vector<ll>(3));
    rep(i,3){
        rep(j,3){
            cin>>A[i][j];
        }
    }
    ll N;
    cin >>N;
    vector<ll> b(N);

    rep(i,N){
        cin>>b[i];
    }

    rep(i,N){
        rep(j,3){
            rep(k,3){
                if(b[i] == A[j][k]){
                    A[j][k] = -1;
                }
            }
        }
    }
    ll flag = 0;
    rep(i,3){
        rep(j,3){
            if(A[i][j] == -1){

            }else{
                //flag = 1;
                break;
            }
            if(j==2){
                flag = 1;
            }
        }
    }
    rep(i,3){
        rep(j,3){
            if(A[j][i] == -1){

            }else{
                //flag = 1;
                break;
            }
            if(j==2){
                flag = 1;
            }
        }
    }

    rep(i,3){
        if(A[i][i] == -1){

            }else{
                //flag = 1;
                break;
            }
            if(i==2){
                flag = 1;
            }
    }
    rep(i,3){
        if(A[2-i][i] == -1){

            }else{
                //flag = 1;
                break;
            }
            if(i==2){
                flag = 1;
            }
    }

    if(flag ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3580
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int d[][]=new int[n][26];
        for (int i=0; i<n; i++) {
           char c[] = sc.nextString().toCharArray();
            for (int t=0; t<c.length; t++) {
                d[i][c[t]-'a']++;
            }
        }
        String s="";
        for (int i=0; i<26; i++) {
            int min=100;
            for (int t=0; t<n; t++) {
                min=min(d[t][i], min);
            }
            for (int t=0; t<min; t++) {
                s+=(char)('a'+i);
            }
        }

        out.println(s);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 21076
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース

*/

/*おーじさんのやつ
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll>
#define m_p make_pair

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,x2,y2;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
P p[ohara];
ll p_cou;
bool vi[ohara];
*/
//main.cpp----------------------------
#define MAX 100000

ll n, m;
ll a[100000+1];
ll b[100000+1];
vector<pair<ll, ll>> p(MAX+1);

int main() {
  cin >> n >> m;
  rep(i, n) cin >> a[i] >> b[i];

  rep(i, n) {
    p[i] = make_pair(a[i], b[i]);
  }

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

  ll cnt = 0;
  for(int i=0; m>0; ++i) {
    if(m>=p[i].second) {
      cnt += p[i].first*p[i].second;
      m -= p[i].second;
    }else {
      cnt += p[i].first*m;
      m -= p[i].second;
    }
  }

  cout << cnt << endl;

  return 0;
}

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

using pint = pair<ll, ll>;
ll N;
vector<pint> A;

int main(){
    cin >> N;
    A.resize(N);
    for(ll i = 0; i < N; i++){
        cin >> A[i].first;
        A[i].second = i+1;
    }
    sort(A.begin(), A.end());
    for(ll i=0; i<N; i++){
        if(i==N-1){
          cout << A[i].second << endl;
          break;
        }
        cout << A[i].second << " ";
    }

    return 0;
}

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

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

    int ans = 0;
    vector<int> time(n);

    REP(i, n) cin >> time[i];

    REP(i, n) {
        if(i != n-1) {
            if(time[i+1] - time[i] < t) {
                ans += time[i+1] - time[i];
            } else {
                ans += t;
            }
        } else {
            ans += t;
        }
    }

    cout << ans << endl;

    return 0;
}
 

Measured memory_bytes: 1024
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;

 int main()
 {
   int m,f,r;
   while(cin>>m>>f>>r)
   {
     if(m==-1&&f==-1&&r==-1) break;
     if(m==-1||f==-1) cout<<"F"<<endl;
     else
     {
       if(m==-1) m=0;
       if(f==-1) f=0;
       int sum=m+f;
       if(sum>=80) cout<<"A"<<endl;
       else if(sum>=65&&sum<80) cout<<"B"<<endl;
       else if(sum>=50&&sum<65) cout<<"C"<<endl;
       else if(sum>=30&&sum<50)
       {
         if(r>=50) cout<<"C"<<endl;
         else cout<<"D"<<endl;     
       }
       else cout<<"F"<<endl;
     }
   } 
   //while(1);
   return 0;
 }
 

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

int main() {
    ios::sync_with_stdio(false);
    int n, a, b, e = 0, f = 0;
    ll c[55] = {}, d = 0, g[55][55] = {1};
    for (int i = 1; i <= 50; i++) {
        g[i][0] = 1;
        for (int j = 1; j <= i; j++) g[i][j] = g[i - 1][j] + g[i - 1][j - 1];
    }
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(c, c + n); reverse(c, c + n);
    for (int i = 0; i < a; i++) d += c[i];
    for (int i = 0; i < n; i++) {
        if (c[i] == c[a - 1]) e++;
        if (c[i] > c[a - 1]) f++;
    }
    ll z = 0;
    if (c[0] == c[a - 1]) for (int i = a; i <= b; i++) z += g[e][i - f];
    else z = g[e][a - f];
    cout << fixed << setprecision(13) << d * 1.0 / a << '\n';
    cout << z << '\n';
}


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

int main(int argc, char const *argv[]) {
  int q;
  std::cin >> q;
  for (size_t _ = 0; _ < q; _++) {
    std::string x, y;
    std::cin >> x;
    std::cin >> y;

    std::vector<std::vector<int> > dp(x.size()+1, std::vector<int>(y.size()+1));
    for (size_t ii=0; ii<x.size(); ++ii){
      for(size_t jj=0; jj<y.size(); ++jj){
        size_t i = ii + 1;
        size_t j = jj + 1;
        if (x[ii]==y[jj]){
          dp[i][j] = dp[i-1][j-1] + 1;
        }
        else{
          dp[i][j] = std::max(dp[i-1][j], dp[i][j-1]);
        }
      }
    }
    std::cout << dp[x.size()][y.size()] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 5040
from collections import deque
S = deque(input())

ans = 0
while len(S):
    if S[0] == S[-1]:
        if len(S) > 1:
            S.popleft()
            S.pop()
        else:
            S.pop()
    else:
        if S[0] != "x" and S[-1] != "x":
            print(-1)
            exit()
        elif S[0] != "x":
            S.pop()
            ans += 1
        elif S[-1] != "x":
            S.popleft()
            ans += 1
print(ans)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

ll gcd(ll x, ll y) {
	while (y) {
		x %= y;
		swap(x, y);
	}
	return x;
}

ll lcm(ll x, ll y) {
	return x / gcd(x, y) * y;
}

int main() {
	ll N, A, T;
	cin >> N;
	vector<ll> As(N), Ts(N);
	for (int i = 0;i < N;i++)cin >> As[i] >> Ts[i];

	ll ng = 0, ok = (1LL << 61), mid, x, y, a, b;
	while (ng + 1 != ok) {
		mid = (ok + ng) / 2;

		x = mid / (As[N - 1] + Ts[N - 1]);
		a = x * As[N - 1];
		b = x * (Ts[N - 1]);
		for (int i = N - 2;i >= 0;i--) {
			x = a / As[i];
			y = b / Ts[i];
			x = min(x, y);
			a = As[i] * x;
			b = Ts[i] * x;
		}
		if (a != 0 && b != 0)
			ok = mid;
		else
			ng = mid;
	}
	cout << ok << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,i,j,a[50],b[50],cnt,x,y,c;
	int par[51],leng[51];
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)	scanf("%d %d",&a[i],&b[i]);
	cnt=0;
	for(i=0;i<m;i++)	{
		c=0;
		for(j=1;j<=n;j++)	{
			par[j]=j;	leng[j]=1;
		}
		for(j=0;j<m;j++)	{
			if(i!=j)	{
				x=a[j];	y=b[j];
				while(x!=par[x])	x=par[x];
				while(y!=par[y])	y=par[y];
				if(x!=y)	{
					c++;
					if(leng[x]<leng[y])	{
						par[x]=y;
					}
					else if(leng[x]>leng[y])	{
						par[y]=x;
					}
					else {
						par[x]=y;
						leng[y]++;
					}
				}
			}
		}
//		printf("c=%d\n",c);
		if(n-c!=1)	cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	string s;
	cin>>s;

	int f=0;
	rep(i,s.size()){
		if((i+1)%2==0&&s[i]=='R'){
			cout<<"No"<<endl;
			return 0;
		}
		if((i+1)%2>0&&s[i]=='L'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = 0
if N % 2 != 0:
    print(0)
    exit()
else:
    i = 1
    while True:
        a = 2 * 5**i
        if N // a == 0:
            break
        ans += (N // a)
        i += 1
print(ans)

Measured memory_bytes: 2940
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long MODPOW(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}


int main(){
	ll x;
    cin >> x;
    if(400<=x && x<=599){
        cout << 8 << endl;
    }else if(600<=x && x<=799){
        cout << 7 << endl;
    }else if(800<=x && x<=999){
        cout << 6 << endl;
    }else if(1000<=x && x<=1199){
        cout << 5 << endl;
    }else if(1200<=x && x<=1399){
        cout << 4 << endl;
    }else if(1400<=x && x<=1599){
        cout << 3 << endl;
    }else if(1600<=x && x<=1799){
        cout << 2 << endl;
    }else if(1800<=x && x<=1999){
        cout << 1 << endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<long> A(N), B(N);
  vector<pair<long, long>> C(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
    C[i] = make_pair(A[i] + B[i], i);
  }
  sort(C.begin(), C.end()); reverse(C.begin(), C.end());
  long tsum = 0, asum = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      tsum += A[C[i].second];
    } else {
      asum += B[C[i].second];
    }
  }
  cout << tsum - asum << endl;
}

Measured memory_bytes: 3328
#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)
	break;
		if(m + f < 30 || m == -1 || f == -1)
		puts("F");
		else if(m + f >= 80 )
		puts("A");
		else if(m + f >= 65)
		puts("B");
		else if(m + f >= 50 )
		puts("C");
		else if(m + f >= 30){
			if(r >= 50)
			puts("C");
		else 
		puts("D");
		}
	}
		return 0;
}


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

public class Main {
	static final int M = 1_000_000_007;
	
	void run() {
		int n = in.nextInt();
		int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = in.nextInt();
		}
		long ans = 1;
		int m = 0;
		for (int i = 0; i < n; i++) {
			if (x[i] == 2 * m) {
				ans *= m + 1;
				ans %= M;
			} else {
				m++;
			}
		}
		while (m > 0) {
			ans *= m;
			ans %= M;
			m--;
		}
		out.println(ans);
	}

	static MyScanner in;
	static PrintWriter out;

	public static void main(String[] args) throws IOException {
		boolean stdStreams = true;
		String fileName = Main.class.getSimpleName().replaceFirst("_.*", "").toLowerCase();
		String inputFileName = fileName + ".in";
		String outputFileName = fileName + ".out";
		
		Locale.setDefault(Locale.US);
		BufferedReader br;
		if (stdStreams) {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			br = new BufferedReader(new FileReader(inputFileName));
			out = new PrintWriter(outputFileName);
		}
		in = new MyScanner(br);
		int tests = 1;//in.nextInt();
		for (int test = 0; test < tests; test++) {
			new Main().run();
		}
		br.close();
		out.close();
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		MyScanner(BufferedReader br) {
			this.br = br;
		}
		
		void findToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		
		String next() {
			findToken();
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 35548
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll v[62][200010];
int main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
    ll N,K;
    cin>>N>>K;
    for(ll i=0;i<N;i++){
      cin>>v[0][i];
      v[0][i]--;
    }
    for(ll i=1;i<62;i++){
      for(ll j=0;j<N;j++){
        v[i][j]=v[i-1][v[i-1][j]];
      }
    }
    ll pos=0;
    for(ll i=0;i<=60;i++){
      ll k=1LL<<i;
      if(K&k){
        pos=v[i][pos];
      }
    }
    cout<<pos+1;
    return 0;
}

Measured memory_bytes: 100536