akhauriyash/Code-Regression huggingface dataset:
num = gets.to_i
cities = {}
num.times do |i|
  input_city_name, input_score = gets.split(" ")
  cities[input_city_name] ||= {}
  cities[input_city_name][input_score.to_i] = (i+1)
end

cities.keys.sort.each do |city_name|
  rsts = cities[city_name] 
  rsts.keys.sort.reverse.each do |score|
    puts rsts[score].to_i
  end
end

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_143
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] ab = ReadInts();
            int a = ab[0];
            int b = ab[1];
            WriteLine(Max(a - b * 2, 0));
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int a, b;
	
	cin>>a>>b;
	
	if(b%a == 0) cout<<a+b<<endl;
	else cout<<b-a<<endl;
	
	return 0;
}

Measured memory_bytes: 764
import sys
dx = [0, -1, 1, 0]
dy = [-1, 0, 0, 1]
field = []
H, W = map(int, input().split())
for _ in range(H):
    field.append(list(input()))
for y in range(H):
    for x in range(W):
        if field[y][x] == '#':
            flag = 0
            for i in range(4):
                nx = dx[i] + x
                ny = dy[i] + y
                if nx < 0 or W <= nx or ny < 0 or H <= ny:
                    continue
                if field[ny][nx] == '#':
                    flag = 1
                    break
            if flag == 0:
                print('No')
                sys.exit()
print('Yes')

Measured memory_bytes: 3064
// 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 ;
int main()
{

    string x[3];
    cin >> x[0] >> x[1] >> x[2];
    cout << x[0][0] << x[1][1] << x[2][2] <<"\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
/*ABC 139 C*/

int main(void)
{
  int N;
  int *heap;
  int count=0;
  int max = 0;
  scanf("%d", &N);

  heap = (int *)malloc(sizeof(int) * N);
  if (heap == NULL) {
    exit(0);
  }

  for (size_t i = 0; i < N; i++) {
    scanf("%d", &heap[i]);
  }

  for (size_t i = 0; i < N; i++) {
    for (size_t j = i; j < N-1; j++) {
      if (heap[j] >= heap[j+1]) {
        count++;
      }else break;
    }
    if (max<count) {
      max = count;
    }
    if (max == N-1) {
      printf("%d", N-1);
      return 0;
    }
    count = 0;
  }
  free(heap);

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

  return 0;
}


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


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

vector<int> A(n,0);
vector<int> B(n,0);
for(int i=0;i<n;i++)
cin>>A[i];


//cout<<"-->";

B[0] = 0;
if(n!=1){
    B[1] = abs(A[1]-A[0]);
    //cout<<B[1]<<" ";
   for(int i=2;i<n;i++)
   {  int start = ((i-k)<=0)?0:i-k;
      int mini = INT_MAX;
     for(int j=start;j<=i-1;j++)
     mini = min(B[j]+abs(A[i]-A[j]),mini);
     B[i] = mini;
     
   } 
     cout<<B[n-1];
}


else
cout<<0;
     
return 0;   
}





Measured memory_bytes: 1024
N = int(input())
alp_list = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
ans = []
 
for i in range(1,12):
  if N <= 26 ** i:
    N -= 1
    for j in range(i):
      ans.append(alp_list[N % 26])
      N  = N // 26
    break
  else:
    N -= 26 ** i
ans.reverse()
print("".join(ans)) 

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

count=0

for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        count +=1

print(count)

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

const int INF = 1001001001;

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

    int n, count = 0, minimum = INF;
    cin >> n;
    vector<int> p(n);
    rep(i, n)
    {
        cin >> p.at(i);
        if (p.at(i) < minimum)
            count++;
        minimum = min(minimum, p.at(i));
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1024
//In the name of God
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define all(vec) (vec).begin(), (vec).end()
#define Mp make_pair
#define F first
#define S second

ll n, m, a[maxn], b[maxn], fen[maxn];
vector<pll> c;
vector<ll> vec;

void upd(ll x, ll y){
    for(x += 5; x < maxn; x += x & -x){
        fen[x] += y;
        if(fen[x] >= mod) fen[x] -= mod;
    }
    return;
}
ll get(ll x){
    ll y = 0;
    for(x += 5; x > 0; x -= x & -x){
        y += fen[x];
        if(y >= mod) y -= mod;
    }
    return y;
}

int main(){
    fast_io;

    cin >> n >> m;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
    }
    for(ll i = 0; i < m; i++){
        cin >> b[i];
    }
    for(ll i = 0; i < n; i++){
        if(a[i] < b[0] || a[i] > b[m - 1]) continue;
        ll j = lower_bound(b, b + m, a[i]) - b;
        c.pb(Mp(b[j] - a[i], b[j - 1] - a[i]));
        vec.pb(a[i] - b[j - 1]);
    }
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
    sort(all(c));
    c.resize(unique(all(c)) - c.begin());
    upd(-1, 1);
    for(pll i : c){
        ll x = lower_bound(all(vec), -i.S) - vec.begin();
        upd(x, get(x - 1));
    }
    cout << get(n);

    return 0;
}


Measured memory_bytes: 8424
"use strict"

function dist(a, b){
  const xa = a.trim().split(' ').map(Number)[0];
  const ya = a.trim().split(' ').map(Number)[1];
  const xb = b.trim().split(' ').map(Number)[0];
  const yb = b.trim().split(' ').map(Number)[1];
  const X = xa - xb;
  const Y = ya - yb;

  return Math.sqrt(Math.pow(X, 2) + Math.pow(Y, 2))
}

function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0]);
  const XY = input.slice(1, input.length);
  
  let sum = 0;
  for(let i=0; i<N; i++){
    for(let j=0; j<N; j++){
      let a = XY[i];
      let b = XY[j];
      sum += dist(a, b);
    }
  }

  console.log(sum/N);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;
int numbers[100005];

int main()
{ 
	int n;
	cin >> n;
	int * arr = new int[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	for (int i = 0; i < n; i++)
		if (arr[i] == i + 1)
			numbers[i] = 1;
	/*for (int i = 0; i < n + 1; i++)
		cout << numbers[i] << " ";
		*/
	int switches = 0;
	for (int i = 0; i < n + 1; i++)
	{
		if (numbers[i] == 1 && numbers[i + 1] == 1)
		{
			switches++;
			i++;
		}
		else if (numbers[i] == 1)
			switches++;
	}
	cout << switches;
	return 0;
}

Measured memory_bytes: 1024
import math
import collections

N,P = map(int, input().split())
S = input()

ans = 0
juu = 1
S = S[::-1]
amari = 0
amaris = [0] * (P) #あまりの配列
if P == 2 or P == 5:
    for i,c in enumerate(S):
        n = int(c)
        if n % P == 0:
            ans += N - i
else:


    for c in S:
        i = int(c)
        amari += (i * juu)
        amari %= P
        amaris[amari] += 1
        juu *= 10
        juu %= P


    amaris[0] += 1
    for temp in amaris:
        ans += temp * (temp - 1) //2
print(ans)

Measured memory_bytes: 3884
/**
 * @author torith
 * @date 2018-10-27
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

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

    string s;
    cin >> s;

    if (s.size() == 2) {
        cout << s << "\n";
    }
    else if (s.size() == 3){
        for (int i = s.size() - 1; i >= 0 ; --i) {
            cout << s[i] ;
        }
        cout << "\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
    ci(n);
  vll A(n);
  vll B(n);
  vll C(n-1);
  FOR(i,0,n){
    ci(A[i])
  }
  FOR(i,0,n){
    ci(B[i])
  }
  FOR(i,0,n-1){
    ci(C[i])
  }
  ll ans=0;
  FOR(i,0,n){
    ll a=A[i];
    ans+=B[a-1];
    if(i!=0&&A[i]-A[i-1]==1){
      ans+=C[a-2];
    }
  }
  co(ans)
}

Measured memory_bytes: 1024
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

ll modpow(ll m, ll p) {
    if (p == 0) return 1;
    ll tmp = modpow(m, p / 2);
    if (p & 1) return (tmp * tmp % MOD) * m % MOD;
    else return tmp * tmp % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b; cin >> n >> a >> b;
    ll ans = modpow(2, n);
    ll minus1 = 1;
    for (ll i = n; i >= n - a + 1; i--) (minus1 *= i) %= MOD;
    ll minus2 = 1;
    for (ll i = n; i >= n - b + 1; i--) (minus2 *= i) %= MOD;
    
    for (ll i = 2; i <= a; i++) (minus1 *= modpow(i, MOD - 2)) %= MOD;
    for (ll i = 2; i <= b; i++) (minus2 *= modpow(i, MOD - 2)) %= MOD;

    ans -= minus1;
    if (ans < 0) ans += MOD;
    ans -= minus2;
    if (ans < 0) ans += MOD;
    ans--;
    if (ans < 0) ans += MOD;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
    if(i%3==0||i%10==3){
    printf(" %d",i);
    }
    else{
       for(int x=i/10;x;x/=10){
           if(x%10==3){
               printf(" %d",i);
               break;
           }
       } 
    
    }
}
printf("\n");
return 0;
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
template< typename T > class fenwick_tree{
private:
	static const int default_size = 100100;
	int my_size;
	vector<T> fenwick;
public:
	fenwick_tree(){
		my_size = default_size;
		clear();
	}
	fenwick_tree(int size){
		my_size = size;
		clear();
	}
	void clear(){
		fenwick.assign(my_size, T());
	}
	void add(int pos, T v){
		for(;pos < my_size; pos += pos & - pos)
			fenwick[pos] = fenwick[pos] + v;
	}
	T sum(int pos){
		T ans = T();
		for(;pos; pos -= pos & - pos)
			ans = ans + fenwick[pos];
		return ans;
	}
};
vector<int> p[26];
int main(){
	string s; cin >> s;
	for(int i = 0; i < s.size(); i++) p[s[i] - 'a'].push_back(i);
	vector<pair<int,int> > pp;
	vector<pair<int,int> > center;
	for(int i = 0; i < 26; i++){
		int len = p[i].size();
		for(int j = 0; j < (len + 1) / 2; j++){
			int k = len - j - 1;
			if(p[i][j] != p[i][k])
				pp.push_back({p[i][j] + 1, p[i][k] + 1});
			else center.push_back({p[i][j] + 1, p[i][k] + 1});
		}
	}
	if(center.size() > 1) return cout << -1 << endl, 0;
	fenwick_tree<int> pl(234567), pr(234567);
	sort(pp.rbegin(), pp.rend());
	long long ans = 0;
	for(auto e : pp){
		ans += 2 * (pl.sum(s.size()) - pl.sum(e.second));
		ans += pl.sum(e.second) - pr.sum(e.second);
		pl.add(e.first, 1);
		pr.add(e.second, 1);
	}
	for(auto c : center){
		for(auto e : pp){
			if(e.first < c.first && c.first < e.second);
			else ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 4344
s=list(input())
t=list(input())
n=len(s)-len(t)+1
cli=[]
for i in range(n):
  a=[]
  for j in range(i):
    a.append('')
  a.extend(t)
  for j in range(n-1-i):
    a.append('')
  count=0
  for i in range(len(s)):
    if s[i]==a[i]:
      count+=1
  cli.append(count)
print(len(t)-max(cli))

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

int main() {
    int K;
    cin>>K;
    int count = 0;
    long ans = 0;
    queue<long> que;
    REP(i, 1, 10) que.push(i);
    long maxans = 0;
    while(count != K){
        ans = que.front(); que.pop();
        int keta = ans % 10;
        REP(j, -1, 2){
            long next = keta + j;
            if(next >= 0 && next < 10 && maxans < ans * 10 + next){
                maxans = ans * 10 + next;
                que.push(ans * 10 + next);
            }
        }
        count++;
    }
    cout << ans << endl;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
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; }

int main() {
    cout << "square1001" << endl;
    return (0);
}



Measured memory_bytes: 3096
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.TreeMap;
import java.math.BigDecimal;
import java.math.BigInteger;
    
public class Main{
 
static final InputStream in=System.in;
static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE;
static final long LINF=Long.MAX_VALUE;
 
public static void main(String[] args) throws IOException{
InputReader ir=new InputReader(in);
while(true){
 int h=ir.nextInt();
 int w=ir.nextInt();
 if((h|w)==0) break;
 for(int i=0;i<h;i++){
  for(int j=0;j<w;j++){
   out.print("#");
  }
  out.println();
 }
 out.println();
}
out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;
 
 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
  
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }
 
 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}

 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}

 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public double nextDouble(){return Double.parseDouble(next());}
 
 public BigInteger nextBigInteger(){return new BigInteger(next());}
 
 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }
 
 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}

Measured memory_bytes: 26364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;

    for(int i=0;i<=999;i++){
        string t=to_string(i);
        int m=t.size();
        if(m==1){
            string tt="00";
            tt+=t[0];
            int k=0;
            rep(j,n){
                if(s[j]==tt[k]) k++;
                if(k==3){
                    //cout<<i<<endl;
                    ans++;
                    break;
                }
            }
        }
        else if(m==2){
            string tt="0";
            tt+=t[0];
            tt+=t[1];
            int k=0;
            rep(j,n){
                if(s[j]==tt[k]) k++;
                if(k==3){
                    //cout<<i<<endl;
                    ans++;
                    break;
                }
            }
        }
        else{
            int k=0;
            rep(j,n){
                if(s[j]==t[k]) k++;
                if(k==3){
                    //cout<<i<<endl;
                    ans++;
                    break;
                }
            }
        }
    }

    cout<<ans<<endl;
}


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

int a[1005];
const long long mod= 1e9 + 7;

int main()
{
	int n;
	
	long long res = 1;
	
	scanf("%d",&n);
	
	for (int i = 2;i <= n;i++)
	{
		int tmp = i;
		for (int j = 2;tmp != 1;j++)
		{
			if (tmp % j == 0)
			{
				a[j]++;
				tmp /= j;
				j--;
			}
		}
	}
	
	for (int i = 2;i <= n;i++)
	{
		if (a[i] != 0)
			res = ((res % mod) * ((a[i]+1) % mod)) % mod;
	}
	
	printf("%lld\n",res);
	
	return 0;
}


Measured memory_bytes: 384
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func LCM(a, b int, integers ...int) int {
	result := a * b / GCD(a, b)

	for i := 0; i < len(integers); i++ {
		result = LCM(result, integers[i])
	}

	return result
}

func b2i(b bool) int {
	if b == true {
		return 1
	}
	return 0
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	T := make([]int, N)
	A := make([]int, N)

	for i := 0; i < N; i++ {
		T[i] = getInt()
		A[i] = getInt()
	}

	t := T[0]
	a := A[0]
	for i := 1; i < N; i++ {
		tt := t/T[i] + b2i(t%T[i] != 0)
		aa := a/A[i] + b2i(a%A[i] != 0)
		max := tt
		if tt < aa {
			max = aa
		}
		t = max * T[i]
		a = max * A[i]
	}
	fmt.Println(a + t)
}


Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    int n;
    cin >> n;
    ll  a[n];
    inrep(n,a);
    sort(a,a+n);
    
    ll ans = 1;
    rep(i,0,n){

	if((long double)ans * a[i] > 1e18){
	    ans = -1;
	    break;
	}
	ans *= a[i];
    }
    P(ans);
    return  0;
}


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

int main(){
    int N; cin>>N;
    int ans = 0;
    while(N--){
        int l, r; cin>>l>>r;
        ans += r-l+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>


int main() {
    std::string s;

    std::cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == ',') s[i] = ' ';
        std::cout << s[i];
    }

    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 764
# AtCoder Beginner Contest 154
# D - Dice in Line
# https://atcoder.jp/contests/abc154/tasks/abc154_d
N, K = map(int, input().split())
*A, = map(int, input().split())

E = [0]*N

for i, a in enumerate(A):
    E[i] = (a+1)/2

L = [0]*N

L[0] = E[0]
for i in range(1, N):
    L[i] = L[i-1]+E[i]


ans = L[K-1]
for i in range(1, N-K+1):
    ans = max(ans, L[i+K-1]-L[i-1])
print(ans)


Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
int cnt[26];

int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
		cnt[s[i]-'a']++;
	for(int i=0;i<26;i++)
		if(cnt[i]>1){
			cout<<"no"<<endl;
			return 0;
		}
	cout<<"yes"<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

int main()
{
	int K, X;

	cin >> K >> X;

	int a = X - K + 1;
	int b = X + K - 1;

	for (int i = a; i <= b; ++i)
	{
		cout << i << " ";
	}


	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
int oo(int x){return (x + 9) / 10 * 10;}
int re(int x){return oo(x) - x;}

int main() {
    int H, W;
    int h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>	
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
void solve()
{
	string s;
	cin>>s;
	int n=s.size();
	bool pal=true;
	rep(i,n/2){
		if(s[i]!=s[n-1-i]){
			pal=false;
		}
	}
	rep(i,n/4){
		if(s[i]!=s[n/2-1-i]){
			pal=false;
		}
	}
	rep(i,n/4){
		if(s[i+n/2+1]!=s[n-1-i]){
			pal=false;
					//cout<<i+n/2<<" "<<n-1-i<<endl;

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

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


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

int main(){
    map<string,unsigned int> num;
    num["AC"]=0;
    num["WA"]=0;
    num["TLE"]=0;
    num["RE"]=0;
    int c;
    cin >> c;

    while(c--){
        string s;
        cin >> s;
        num[s]++;
    }

    cout << "AC x " << num["AC"] << '\n';
    cout << "WA x " << num["WA"] << '\n';
    cout << "TLE x " << num["TLE"] << '\n';
    cout << "RE x " << num["RE"] << '\n';
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)

int N;
vector<vector<int> > M;
vector<vector<int> > F;


void printMtx(){
	for (int i = 0; i <= N + 1; i++) {
		for (int j = 0; j <= N + 1; j++) {
			if (M[i][j] == -1) {
				printf(" * ");
			}
			else {
				if (F[i][j] == 1)	printf("\x1b[7m");
				printf("%2d ",M[i][j]);
				if (F[i][j] == 1)	printf("\x1b[0m");
			}
		}
		/*
		printf(" | ");
		for (int j = 0; j <= N + 1; j++) {
			if(M[i][j] == -1) {
				printf(" * ");
			}
			else {
				printf("%2d ", F[i][j]);
			}
		}
		*/
		printf("\n");
	}
}

vector<int> iT = { 1,0,-1,0 };
vector<int> jT = { 0,1,0,-1 };

void update(int i, int j) {
	int m = M[i][j];
	int f = F[i][j];
	for (int sw = 0; sw <= 1; sw++) { // sw=0:空白処理, sw=1:セル処理, 空白を先に処理する
		for (int k = 0; k < 4; k++) {
			int it = i + iT[k];
			int jt = j + jT[k];
			if (F[it][jt] == sw) {
				if (M[it][jt] > m + sw) {
					M[it][jt] = m + sw;
					update(it, jt);
				}
			}
		}
	}
}

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

	cin >> N;
	M = vector<vector<int> >(N+2, vector<int>(N+2, -1)); // costを入れる 端っこはsinkで、-1を入れる。
	F = vector<vector<int> >(N+2, vector<int>(N+2, 0)); // セル＝1, 空白=0 端っこは空白

	for (int k = 0; k <= (N + 1) / 2; k++) {
		for (int i = k + 1; i <= N - k; i++) {
			for (int j = k + 1; j <= N - k; j++) {
				M[i][j] = k;
				F[i][j] = 1;
			}
		}
	}
//	printMtx();

	int cost = 0;
	for (int p = 1; p <= (N * N); p++) {
		int P;
		cin >> P;
		int j = ((P - 1) % N) + 1;
		int i = ((P - 1) / N) + 1;

		cost += M[i][j];
		M[i][j]--;
		F[i][j] = 0;
		update(i, j);
//		printf("cost = %d, P(%d) = %d = (%d,%d)\n",cost,p,P,i,j);
//		printMtx();
	}
	printf("%d\n",cost);
	return(0);
}


Measured memory_bytes: 24984
//ABC 049-A
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

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


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

using namespace std;
using ll = long long;

int main() {
    ll r, d, x;
    cin >> r >> d >> x;

    for (int i = 0; i < 10; ++i) {
        cout << r * x - d << endl;
        x = r * x - d;
    }

    return 0;
}


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

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define piii    pair<int, pair<int, int>>

struct edge {
        long long to, cost;
        bool operator > (const edge &r) const { return cost > r.cost; }
        bool operator < (const edge &r) const { return cost < r.cost; }
};

static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;

vector<edge> g[101010];
long long dis[101010];                             
int n;

void dijkstra(int start) {
        priority_queue<edge, vector<edge>, greater<edge>> q;
        fill(dis, dis + n, INFL);
        dis[start] = 0;
        q.push((edge){ start, 0 });
        while (!q.empty()) {
                edge e1 = q.top(); q.pop();
                for (auto e2 : g[e1.to]) {
                        if (dis[e2.to] > dis[e1.to] + e2.cost) {
                                dis[e2.to] = dis[e1.to] + e2.cost;
                                q.push((edge){ e2.to, dis[e2.to] });
                        }
                }
        }
}

int main() {
        cin >> n;
        for (int i = 0; i < n - 1; i ++) {
                int a, b, c;
                cin >> a >> b >> c;
                a --, b --;
                g[a].push_back({b, c});
                g[b].push_back({a, c});
        }
        int q, k;
        cin >> q >> k;
        k --;
        dijkstra(k);
        for (int i = 0; i < q; i ++) {
                int x, y;
                cin >> x >> y;
                x --, y --;
                cout << dis[x] + dis[y] << endl;
        }
        return 0;
}



Measured memory_bytes: 11120
N, M, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

for i in range(1, N+1):
    A[i] += A[i-1]
for i in range(1, M+1):
    B[i] += B[i-1]

ans = 0

b_index = M

for a_index in range(N+1):
    left = K - A[a_index]
    if left < 0: continue

    while left - B[b_index] < 0:
        b_index -= 1

    ans = max(ans, a_index + b_index)

print(ans)

Measured memory_bytes: 39952
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
  ll W, H, x, y;
  
  cin >> W >> H >> x >> y;
  
  auto ans = (float) W * H / 2;
  
  cout << ans << " ";
  
  if(W % 2 == 0 && W / 2 == x && H % 2 == 0 && H / 2 == y) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
/*
Look at the star
Look at the shine for U
*/
#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
#define sl(x) scanf("%lld",&x)
using namespace std;
const int N = 2e6+5;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}
ll c[N],v[N],que[N],dis[N];

int main()
{
	ll s[10];
	cin>>s[0]>>s[1]>>s[2];
	sort(s,s+3);
	cout<<s[2]*10+s[1]+s[0]<<endl; 
}
/*
3 1
1 1 2
2 2 1
*/

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
char s[20];
int t=0;
char c;
int ind;
int main()
{
    while (1)
    {
        scanf("%c",&c);
        if (c=='\n') break;
        s[t++]=c;
    }
    int f=1;
    if (s[0]!='A') f=0;
    int sum=0;
    for (int i=2; i<=t-1-1; ++i)
        if (s[i]=='C') 
        {
            ind=i;
            sum++;
        }
    
    if (sum!=1) f=0;
    for (int i=1; i<t; ++i)
        if (i!=ind)
        if (s[i]>='A' && s[i]<='Z')
            f=0;
    if (f==0) cout<<"WA"<<endl;
    else cout<<"AC"<<endl;
    return 0;
}



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

int main() {

  int n; cin >> n;
  vector<vector<pair<int, int>>> v(n);

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

    int a; cin >> a;

    for (int j = 0; j < a; j++) {

      int x, y; cin >> x >> y;
      pair<int, int> tmp;

      tmp.first = x - 1; tmp.second = y;
      v[i].push_back(tmp);
    }
  }

  int ans = 0;
  
  for (int bit = 0; bit < (1 << n); bit++) {
  
    bool flag = true;
    int cnthonor = 0;

    vector<int> vbit(n);
    for (int i = 0; i < n; ++i) {
      if (bit & (1 << i)) vbit[i] = 1;
      else vbit[i] = 0;
    }

    //for (int i = 0; i < n; ++i) cout << vbit[i] << (i == n - 1 ? "\n" : " ");

    for (int j = 0; j < n; j++) {

      if (vbit[j] == 0) continue;

      //j is honor
      int m = v[j].size();
      int cnt = 0;

      for (int k = 0; k < m; k++) {
        //cout << "j, k: " << j << " " << k << endl;
        //cout << vbit[j] << " " << vbit[v[j][k].first] << " " <<  v[j][k].second << endl;

        if (vbit[v[j][k].first] == v[j][k].second) cnt += 1;
      }

      if (cnt == m) cnthonor += 1;
      else flag = false;

      if (!flag) break;
    }

    if (!flag) continue;
    else ans = max(ans, cnthonor);
    //cout << "cnthonor: " << cnthonor << endl;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;

signed main(){
    string L; cin>>L;
    ll N = (ll)L.size();
    //dp1 is smaller, dp2 is exact
    vector<ll> dp1(N), dp2(N);
    dp1[0] = 1;
    dp2[0] = 2;
    for(ll d=1; d<N; d++){
        // 上からd bit目が立っている        
        if(L[d]-'0'==1){
            dp2[d] = (dp2[d-1] * 2) % MOD;
            dp1[d] = (dp1[d-1] * 3 + dp2[d-1])%MOD;
        }
        else{
            dp2[d] = dp2[d-1];
            dp1[d] = (dp1[d-1] * 3) %MOD;
        }
    }
    cout << (dp1[N-1] + dp2[N-1])%MOD << endl;
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;

const int maxn = 100 + 5;
int N;
int mem[maxn];
int d[maxn]; 
queue<int> Min;
queue<int> Max;

int solve()
{
	for(int i = 1; i < N; i++) d[i] = mem[i]-mem[i-1];
	bool K; if(d[0] >= 0) K = 1; else K = 0;
	int i;
	for(i = 1; i < N; i++)
	{
		if(K) 
		{	
			if(d[i] < 0)
			{
				Max.push(i-1);
				K = 0;
			} 
		} 
		else
		{
			if(d[i] > 0)
			{
				if(!Max.empty()) Min.push(i-1);
				K = 1;
			}
		}
	}
	if(K) Max.push(i-1); // else Min.push(i-1);

	if(Min.empty()) return mem[Max.front()];

	int sum = 0;
	while(!Max.empty())
	{
		int p = Max.front(); Max.pop();
		sum += mem[p];
	}
	while(!Min.empty())
	{
		int p = Min.front(); Min.pop();
		sum -= mem[p];
	}
	return sum;
}

int main()
{
	cin >> N;
	for(int i = 0; i < N; i++) cin >> mem[i];
	printf("%d\n", solve());
}

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

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


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

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve() {
        String s = in.nextLine();
        for(int i=0;i<s.length();i++){
            if(s.charAt(i) == ','){
                out.print(" ");
            }else{
                out.print(s.charAt(i));
            }
        }
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


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


Measured memory_bytes: 7004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




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

    int n;
    cin >> n;
    string s;
    cin >> s;
    
    vector<int> v[26];
    rep(i, sz(s)) {
        v[s[i] - '0'].eb(i);
    }
    
    int ans = 0;
    rep(i, 10) rep(j, 10) rep(k, 10) {
        if (!sz(v[i]) || !sz(v[j]) || !sz(v[k])) continue;
        
        int a = v[i][0];
        auto b = upper_bound(all(v[j]), a) - v[j].begin();
        if (b == sz(v[j])) continue;
        
        auto c = upper_bound(all(v[k]), v[j][b]) - v[k].begin();
        if (c == sz(v[k])) continue;
        
        ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Text;

class TEST{
	static void Main(){
		String s="";
		while( (s = Console.ReadLine()) != null ){
			if(int.Parse(s)==0)break;
			var myCM = new Cal_Min(int.Parse(s));
			Console.WriteLine(myCM.ans);
		}
	}
}


class Cal_Min{
	public int ans;
	public Cal_Min(int n){
		ans=99999999;
		for(int i=0;i<=(n/200);i++){
			for(int j=0;j<=(n/300);j++){
				for(int k=0;k<=(n/500);k++){
					if(200*i+300*j+500*k==n){
						var cost =CalCost(i,j,k);
//Console.WriteLine("n="+n+",i="+i+",j="+j+",k="+k+",cost="+cost);
						if(ans>=cost)ans=cost;
					}
				}
			}
		}
	}
	
	int CalCost(int x,int y,int z){
		return (int)(380*(x%5)+(x/5)*380*5*0.8+550*(y%4)+(y/4)*550*4*0.85+850*(z%3)+(z/3)*850*3*0.88);
	}
}

Measured memory_bytes: 5612
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int num3 = sc.nextInt();

		//????????????????????????????????£?¨?
		int[][] gyoretu1 = new int[num1][num2];
		//?????????????????????????????????????????£?¨?
		int[][] gyoretu2 = new int[num2][num3];

		//??????????????£??\
		for(int i = 0;i < gyoretu1.length; i++ ) {
			for(int j = 0;j < gyoretu1[i].length;j++) {
				gyoretu1[i][j] = sc.nextInt();
			}
		}
		for(int i = 0;i < gyoretu2.length ;i++) {
			for(int j = 0;j < gyoretu2[i].length; j++){
				gyoretu2[i][j] = sc.nextInt();
			}
		}



		long[][] ans = new long[num1][num3];

		for(int i = 0;i < ans.length;i++) {
			for(int j = 0;j < ans[i].length;j++) {
				for(int y = 0;y < gyoretu2.length;y++) {
					ans[i][j] += gyoretu1[i][y] * gyoretu2[y][j];
				}
			}
		}

		for(int i = 0;i < ans.length;i++) {
			for(int j = 0;j < ans[i].length;j++) {
				System.out.print(ans[i][j]);
				if(j != ans[i].length - 1){
					System.out.print(" ");
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 53268
from itertools import permutations
from collections import defaultdict

N, C = list(map(int, input().split()))
D =[list(map(int, input().split())) for _ in range(C)]

remains = {0: defaultdict(int), 1: defaultdict(int), 2: defaultdict(int)}
for i in range(1, N+1):
    line = list(map(int, input().split()))
    for j in range(N):
        remains[(i+j+1)%3][line[j]] += 1

INF = float('inf')

answer = INF
for choice in permutations(range(1, C+1), 3):
    _answer = 0
    for i, c in enumerate(choice):
        _answer += sum([D[r-1][c-1] * remains[i][r] for r in remains[i] if c != r])
    answer = min(answer, _answer)

print(answer)

Measured memory_bytes: 3444
n=int(input())
L=[]
ans=0
for i in range(n):
   a=int(input())
   D=[]
   for j in range(a):
      x,y=map(int,input().split())
      D.append((x,y))
   L.append(D)
for i in range(2**n):
   B=[0]*n
   for j in range(n):
      if i>>j&1:
         B[j]=1
   if sum(B)!=0:
      flag=True
      for k in range(n):
         if B[k]==1:
            for m in range(len(L[k])):
               if B[L[k][m][0]-1]!=L[k][m][1]:
                  flag=False
      if flag==True:
         ans=max(ans,sum(B))
print(ans)
         

Measured memory_bytes: 44380
# modulo:mod

# inverse x^(-1)
def inv(x):
    global mod
    return pow(x,mod-2,mod)

# factorial x!
def fact(x):
    global mod
    res=1
    for i in range(2,x+1):
        res=res*i%mod
    return res

# combination nCr
def combi(n,r):
    if r<0 or r>n:
        return 0
    else:
        return fact(n)*inv(fact(r))*inv(fact(n-r))%mod

mod=10**9+7

N=int(input())
x=[0]
x.extend(list(map(int,input().split())))
invs=[inv(d) for d in range(N)]
# print(invs)
ans=0;s=0
for d in range(1,(N-1)//2+1):
    s=(s+x[N-d]-x[d])%mod
    ans=(ans+s*invs[d]*invs[d+1])%mod
    if d!=N-d-1:
        ans=(ans+s*invs[N-d-1]*invs[N-d])%mod
for i in range(1,N):
    ans=(ans+(x[N]-x[i])*invs[N-i])%mod
ans=ans*fact(N-1)%mod

print(ans)

Measured memory_bytes: 64792