akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  int n, m;
  while(cin>>n>>m) {
    int S[m];
    int p[m];
    REP(i,m) {
      S[i] = 0;
      int k;
      cin >> k;
      REP(j,k) {
        int s;
        cin >> s;
        S[i] |= 1 << (s - 1);
      }
    }
    inputs(p,m);
    int ans = 0;
    REP(i,1<<n) {
      bool ng = 0;
      REP(j,m) {
        int c = __builtin_popcount(i & S[j]);
        if (c % 2 != p[j]) {
          ng = 1;
          break;
        }
      }
      if (!ng) {
        ans++;
      }
    }
    cout << ans << endl;
  }
}


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


int main() {
  bool prim[100010];
  for(int i=0;i<100010;i++){
    prim[i]=true;
  }

  prim[1]=false;
 for(int i=2;i<100010;i++){
   if(prim[i]){
     int b=i*2;
     while(b<=100010){
       prim[b]=false;
       b+=i;
     }
   }
 }
int cnt=0;
int a[100010];a[0]=0;
 for(int i=1;i<100010;i++){
   if(prim[i]&&prim[(i+1)/2]){
     a[i]=1;
   }
   else{
     a[i]=0;
   }
 }
int sum[100010];sum[1]=0;
 for(int i=2;i<100010;i++){
   sum[i]=sum[i-1]+a[i-1];
 }
 int Q;
 cin >> Q;
 int l[Q],r[Q],ans[Q];

 for(int i=0;i<Q;i++){
   cin >> l[i] >>r[i];
   ans[i]=sum[r[i]+1]-sum[l[i]];
 }

 for(int i=0;i<Q;i++){
   cout << ans[i] << endl;
 }

}

Measured memory_bytes: 2688
using System;
class Program
{
	static void Main(string[] args)
	{
		char[] s = Console.ReadLine().ToCharArray();
      	char x ='s';
        foreach(char c in s){
          if(x.Equals(c)){
            Console.WriteLine("Bad");
            return;
          }else{
            x=c;
          }
        }
		Console.WriteLine("Good");
	}
}

Measured memory_bytes: 13140
import math
N, = map(int, input().split())
xs = []
ys = []
for _ in range(N):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)

def bb(a,b,c,d,e,f):
    if not (c-a)*(f-b)-(e-a)*(d-b):
        return None, None
    aa = a * a
    bb = b * b
    cc = c * c
    dd = d * d
    ee = e * e
    ff = f * f
    py = ((e - a) * (aa + bb - cc - dd) - (c - a) * (aa + bb - ee- ff)) / (2 * (e - a)*(b - d) - 2 * (c - a) * (b - f))
    px = (2 * (b - f) * py - aa - bb + ee + ff) / (2 * (e - a)) \
        if (c == a) else (2 * (b - d) * py - aa - bb + cc + dd) / (2 * (c - a))
    return px, py


pxs = []
pys = []
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
#            print(i,j,k)
            px, py = bb(xs[i],ys[i],xs[j],ys[j],xs[k],ys[k])
            if not px:
                continue
            pxs.append(px)
            pys.append(py)
for i in range(N):
    for j in range(i+1, N):
        pxs.append((xs[i]+xs[j])/2)
        pys.append((ys[i]+ys[j])/2)

rr = 10**10
for px, py in zip(pxs,pys):
    r = 0
    for x, y in zip(xs, ys):
        r = max(r, (x-px)**2+(y-py)**2)
    rr = min(rr, r)
print(rr**0.5)


Measured memory_bytes: 46184
n = int(input())
lis = list(map(int, input().split()))
odd_flag = 0
#count = 0
ans = 0

while odd_flag == 0:
    count = 0
    for i in range(0, n):
        if lis[i] % 2 == 0:
            lis[i] = lis[i]/2
            count += 1
        else:
            odd_flag = 1
    if count == n:
        ans += 1

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

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

		for(int i=0; i<t; i++){
			int n = sc.nextInt();
			int d = sc.nextInt();

			int ans = (n-1)*127;
			ans += (n%2==0)? (127-d) : d;

			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 14412
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int count=0;
    for(int x=a;x<b+1;x++){
        if(c%x==0){
        count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3120
while True:
    n, m, a = map(int, raw_input().split())

    if n == 0 and m == 0 and a == 0:
        break

    hl = [map(int, raw_input().split()) for _ in range(m)]
    hl.sort(key=lambda x:x[0], reverse=True)

    ans = a

    for i in range(m):
        if ans == hl[i][1]:
            ans = hl[i][2]
        elif ans == hl[i][2]:
            ans = hl[i][1]

    print ans



Measured memory_bytes: 4936
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let (ans, _) = S.iter().fold((0, 0), |(res, x), &s| {
        let y = if s == 'I' { x + 1 } else { x - 1 };
        (std::cmp::max(res, y), y)
    });

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


Measured memory_bytes: 4352
/* 

Author: Vishal Singh  
(singhvishal0304@gmail.com)

"The days that break you are the days that make you."

*/

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

#define fastio() ios_base::sync_with_stdio(false);\
cin.tie(NULL);

#define md 1000000007


#define lli long long int
#define pb push_back
#define mp make_pair
#define vvi(r,c) vector<vector<lli>> v(r,vector<lli>(c));
#define fi first
#define se second
#define mem(arr,x) memset(arr,x,sizeof(arr))

lli power(lli a,lli b){
	if(b==0)
		return 1;
	if(b%2)
		return ((a%md)*(power(a,b-1)))%md;
	else
	{
		lli x=power(a,b/2);
		return (x*x)%md;
	}
}

void solve(){
	lli k;
	cin>>k;
	lli x=7;
	lli c=0;
	while(c<1000005){
		c++;
		if(x%k==0){
			break;
		}
		x=(x*10+7)%k;
	}
	if(c>=1000005)
		cout<<-1<<endl;
	else
		cout<<c<<endl;

}


int main()
{	
    fastio();
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}

	return 0;
}

Measured memory_bytes: 3692
<?php
define('DEBUG', 0);
$dx = [0, 1, 0, -1];
$dy = [1, 0, -1, 0];
$cells = array(
  'A'=>[0,0],
  'B'=>[1,0],
  'C'=>[2,0],
  'D'=>[0,1],
  'E'=>[1,1],
  'F'=>[2,1],
  'G'=>[0,2],
  'H'=>[1,2],
  'I'=>[2,2]);

$memo = array();

function f($cx, $cy, $n, $t, $b) { // $cx,$cy:セル座標、$n:残りバッテリ
if (DEBUG) echo "$cx, $cy, $n, $t, $b:";
  global $cells, $dx, $dy, $memo;
  // メモチェック
  if (array_key_exists("$cx:$cy:$n", $memo)) {
if (DEBUG) echo $memo["$cx:$cy:$n"]."\n";
    return $memo["$cx:$cy:$n"];
  }
  if ($n == 0) {
    // バッテリがなくなった
    if ($cx == $cells[$t][0] && $cy == $cells[$t][1]) {
      // 充電器で終了
if (DEBUG) echo "1\n";
      return 1;
    } else {
if (DEBUG) echo "0_1\n";
      return 0;
    }
  }

  // 4方向に移動する
  $ret = 0;
  for($i=0; $i<4; ++$i) {
    $x = $cx + $dx[$i];
    $y = $cy + $dy[$i];
    if ($x < 0 || 2 < $x || $y < 0 || 2 < $y
       || ($x == $cells[$b][0] && $y == $cells[$b][1])) {
      // 壁にあたった、又は、倉庫にぶつかったので座標を元に戻す
      $x = $cx;
      $y = $cy;
    }
if (DEBUG) echo "f\n";
    $ret += f($x, $y, $n-1, $t, $b);
  }
// error_log("ret:$ret");
  // メモ化
  $memo["$cx:$cy:$n"] = $ret;
if (DEBUG) echo "$ret\n";
  return $ret;
}

while ($n = chop(fgets(STDIN))) {
  list($s, $t, $b) = explode(' ', chop(fgets(STDIN)));
  $memo = array();
  $num = f($cells[$s][0], $cells[$s][1], $n, $t, $b);
  echo sprintf('%.8f', $num / pow(4, $n)) . "\n";
  unset($memo);
}



Measured memory_bytes: 9428
#include <bits/stdc++.h>
using namespace std;
/***template***/
#define ll                   long long
#define LL                   long long
#define dd                   double
#define scl(n)               scanf("%lld",&n)
#define sl(n)                scanf("%lld",&n)
#define scd(n)               scanf("%lf",&n)
#define pi                   pair<ll,ll>
#define pll                  pair<ll,ll>
#define pb                   push_back
#define mp                   make_pair
#define uu                   first
#define vv                   second
#define fr                   first
#define sc                   second
#define FOR(i,n)             for(ll i=1;i<=n;i++)
#define LOOP(i,n)            for(ll i=0;i<n;i++)
#define FOOR(i,a,b)          for(ll i=a;i<=b;i++)
#define LOP(i,a,b)           for(ll i=a;i<b;i++)
#define sorted(s)            sort(s.begin(),s.end())
#define sortedd(s)           sort(s.begin(),s.end(),cmp)
#define reversed(s)          reverse(s.begin(),s.end())
#define contains(a,b)        (find((a).begin(), (a).end(), (b)) != (a).end())
#define MAXN                 100005
#define pii                  3.1415926536
#define mod                  1000000007
#define eps                  0.0000000001
#define inf                  9000000000000000
#define INF                  (1LL<<62)
#define mstt(a,b)            memset((a),(b),sizeof (a))
#define sz(x)                (ll)x.size()
#define mx                    92681+10
struct node
{
    ll nod,d;
    node(ll a,ll b)
    {
        nod=a;
        d=b;
    }
    bool operator<(const node &p)const
    {
        return p.d<d;
    }
};
ll Set(ll n,ll pos)
{
    return n=n|(1LL<<pos);
}
ll reset(ll n,ll pos)
{
    return n=n&~(1LL<<pos);
}
bool check(ll n,ll pos)
{
    return (bool)(n&(1LL<<pos));
}
ll power(ll x,ll y)
{
    ll res = 1;
    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}
/***template***/

int main()
{
    ll tes;

       ll n;
       scl(n);
       ll dig=n%10;
       if(dig==2 || dig==4 || dig ==5 || dig == 7 || dig == 9)
       {
           cout<<"hon"<<endl;
       }
       if(dig==0 || dig ==1 || dig==6 || dig==8)
       {
           cout<<"pon"<<endl;
       }
       if(dig==3)
       {
           cout<<"bon"<<endl;
       }

    return 0;
}



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

long long solve(int N, int W, vector<int>& w, vector<long long>& v, vector<vector<long long>>& Memo) {
	if (W <= 0 || N < 0) return 0;
	if (Memo[N][W] > 0ll) return Memo[N][W];
	Memo[N][W] = max((W-w[N]>=0 ? solve(N - 1, W - w[N], w, v, Memo) + v[N] : 0ll), solve(N - 1, W, w, v, Memo));
	return Memo[N][W];
}

int main() {
	int N, W;
	cin >> N >> W;
	vector<int> w(N);
	vector<long long> v(N);
	for (int i = 0; i < N; i++) cin >> w[i] >> v[i];
	vector<vector<long long>> Memo(N, vector<long long>(W + 1, -1));
	cout << solve(N - 1, W, w, v, Memo) << endl;
}


Measured memory_bytes: 82352
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>

using namespace std;

int main(){
  int K, S;
  int ans = 0;
  cin >> K >> S;

  for(int i = 0; i <=K; i++){
    for(int j = 0; j <= i; j++){
      for(int k = 0; k <= j; k++){
        if((i+j+k)==S){
          if(i==j&&j==k&&k==i) ans++;
          else if(i!=j&&j!=k&&k!=i) ans+=6;
          else ans+=3;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
while True:
    line = input()
    data = line.split()
    h = int(data[0])
    w = int(data[1])
    if h == 0 and w == 0:
        break

    for i in range(h):   
        for j in range(w):
            if i == 0 or i == h -1:
                print("#", end="")
            else:
                if j == 0 or j == w -1:
                    print("#", end="")
                else:
                    print(".", end="")
        print("")
    print("")







Measured memory_bytes: 7008
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
        
        System.out.println(Math.sqrt(Math.pow(x1-x2, 2)+Math.pow(y1-y2, 2)));
    }
}


Measured memory_bytes: 28088
class Fixnum
  def &(n)
    [self,n].min
  end

  def |(n)
    [self,n].max
  end
end

def negate(n)
  -n+2
end

def expr(idx)
  c = $a[idx]
  if c == "-"
    e,idx = expr(idx+1)
    return [negate(e),idx]
  elsif c=="("
    e1,idx = expr(idx+1)
    idx+=1
    op=$a[idx]
    e2,idx = expr(idx+1)
    idx+=1
    if op == "+"
      return [e1|e2,idx]
    else 
      return [e1&e2,idx]
    end
  else
    return [c.to_i,idx]
  end
end

def calc
  expr(0)
end

$a = Array.new
loop do
  line = gets.chomp
  break if line =="."
  ans=0
  3.times do |p|
    l1 = line.gsub(/P/,p.to_s)
    3.times do |q|
      l2 = l1.gsub(/Q/,q.to_s)
      3.times do |r|
        $a = l2.gsub(/R/,r.to_s).split("")
        result,i = calc
        ans+=1 if result == 2
      end
    end
  end
  puts ans
end

Measured memory_bytes: 4988
import Control.Monad
import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector as V
 
main = abc161d

abc161d = do
    [k] <- getIntList
    let lunlunNumInfo = getLunlunNumInfo k
        lunlunL = genLunlunNum (fst lunlunNumInfo)
        groupInfo = snd lunlunNumInfo
        fstIndex = uncurry (-) groupInfo + 1
    print $ lunlunL !! (fromIntegral k - fstIndex)

-- ある群の要素数
getLunlunQty :: (Int, Int) -> Int
getLunlunQty (1, _) = 1
getLunlunQty (digit, num)
    | num == 0 = getLunlunQty (digit-1, 0) + lunlunTable !! (9 * (digit-2))
    | num == 1 = getLunlunQty (digit-1, 0) + lunlunTable !! (9 * (digit-2)) + lunlunTable !! (9 * (digit-2) + 1)
    | num == 9 = lunlunTable !! (9 * (digit-2) + 7) + lunlunTable !! (9 * (digit-2) + 8)
    | otherwise = lunlunTable !! (9 * (digit-2) + num - 2) + lunlunTable !! (9 * (digit-2) + num - 1) + lunlunTable !! (9 * (digit-2) + num)

-- getLunlunQty向けメモ
lunlunTable :: [Int]
lunlunTable = [getLunlunQty(digit, num) | digit <- [1..10], num <- [1..9]]

--((桁,上1桁), (属する群数列が、全体で何番目までの要素を持つか, 属する群数列の要素数))
getLunlunNumInfo :: Integer -> ((Int,Int), (Int, Int))
getLunlunNumInfo k = let subSums = filter (>= fromIntegral k) $ tail . reverse $ foldl' (\acc x -> (head acc + x) : acc) [0] lunlunTable
                         group = divMod (100 - length subSums) 9
                      in (group, (head subSums, getLunlunQty group))

genLunlunNum :: (Int, Int) -> [Int]
genLunlunNum (1, num) = [num]
genLunlunNum (digit, num)
    | num == 0 = genLunlunNum (digit - 1, 0) ++ genLunlunNum (digit - 1, 1)
    | num == 9 =
        map (+ 9 * (10 ^ (digit - 1))) (genLunlunNum (digit - 1, 8)) ++
        map (+ 9 * (10 ^ (digit - 1))) (genLunlunNum (digit - 1, 9))
    | otherwise =
        map (+ num * (10 ^ (digit - 1))) (genLunlunNum (digit - 1, num - 1)) ++
        map (+ num * (10 ^ (digit - 1))) (genLunlunNum (digit - 1, num)) ++
        map (+ num * (10 ^ (digit - 1))) (genLunlunNum (digit - 1, num + 1))

-- genLunlunNum向けメモ
lunlunNumList :: [[Int]]
lunlunNumList = [map (+ num * (10 ^ (digit - 1))) (genLunlunNum (digit - 1, num - 1)) | digit <-[1..3], num <- [1..9]]


readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine


Measured memory_bytes: 2428
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;
#define ll long long
#define pb push_back

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

  if(D==22) cout << "Christmas Eve Eve Eve" << endl;
  if(D==23) cout << "Christmas Eve Eve" << endl;
  if(D==24) cout << "Christmas Eve" << endl;
  if(D==25) cout << "Christmas" << endl;

}


Measured memory_bytes: 256
"use strict"

function Main(stdin){
stdin = stdin.trim().split("\n").reverse();
var stdout = [];
function input(){return stdin.pop()};
function print(x){stdout.push(x)};
function mapint(x){return x.map(n=>parseInt(n))};
function max(x){return x.reduce(function(a,b){ return Math.max(a,b) }) }
function min(x){return x.reduce(function(a,b){ return Math.min(a,b) }) }
function sum(x){return x.reduce(function(a,b){ return a+b }) }


var tmp = mapint(input().split(" "))
var a = tmp[0]
var b = tmp[1]
var k = tmp[2]
var x = [1]
for (var i = 2; i < Math.min(a,b) + 1; i++){
    if (a%i==0 && b%i==0){ x.push(i) }
}
print(x[x.length - k])




stdout = stdout.join("\n");
console.log(stdout);
return stdout
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  string s;
  cin >> s;

  ll n = s.size();
  ll dp[n][13];
  REP(i, n){
    REP(j, 13)
      dp[i][j] = 0;
  }

  if(s[0] == '?'){
    REP(i, 10)
      dp[0][i] = 1;
  }
  else
    dp[0][(int)(s[0] - '0')] = 1;


  REP(i, n-1){
    if(s[i+1] == '?'){
      REP(k, 10){
        REP(j, 13){
          dp[i+1][(j*10+k)%13] += dp[i][j];
          dp[i+1][(j*10+k)%13] %= MOD;
        }
      }
      continue;
    }
    ll now = s[i+1] - '0';
    REP(j, 13){
      dp[i+1][(j*10+now)%13] += dp[i][j];
      dp[i+1][(j*10+now)%13] %= MOD;
    }
  }


  cout << dp[n-1][5] << endl;
  
  /*
  REP(i, n){
    REP(j, 13)
      cout << dp[i][j] << " ";
    cout << endl;
  }
  */


  
}


Measured memory_bytes: 10704
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集

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

  ll a;
  string b;
  cin >> a >> b;
  ll bb=0;
  for(int i=0; i<b.size(); i++){
    if(b[i] == '.') continue;
    bb = bb*10 + b[i]-'0';
  }

  a *= bb;
  cout << a/100 << endl;

  return 0;
}

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

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define RepG(i,u) for(int i=head[u];~i;i=e[i].next)

typedef long long ll;

const int N=1005;

template<typename T> void read(T &x){
   x=0;int f=1;
   char c=getchar();
   for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
   for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    x*=f;
}

int n,m,q;
int a[N],b[N],c[N],d[N];
int val[N];
int ans;

void dfs(int u,int last){
    if(u==n+1){
        int res=0;
        Rep(i,1,q)if(val[b[i]]-val[a[i]]==c[i])res+=d[i];
        ans=max(ans,res);
        return;
    }
    Rep(i,last,m)val[u]=i,dfs(u+1,i);
}

int main()
{
    read(n),read(m),read(q);
    Rep(i,1,q)read(a[i]),read(b[i]),read(c[i]),read(d[i]);
    dfs(1,1);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3768
#include <stdio.h>

int main(){
  int x, a, b;
  scanf("%d %d %d", &x, &a, &b);
     
  if(b <= a) {
  printf("delicious\n");
  }else if(b <= (a + x)) {
  printf("safe\n");
  }else { printf("dangerous\n");
  }
  return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var k, a, b int
	fmt.Scan(&k, &a, &b)
	for i := 1; i < 1000; i++ {
		if k*i >= a && k*i <= b {
			fmt.Println("OK")
			return
		}
		if k*i > b {
			fmt.Println("NG")
			return
		}
	}
}


Measured memory_bytes: 1768
//
//  main.cpp
//  ITP1_6-D
//
//  Created by ?????¶??? on 15/8/14.
//  Copyright (c) 2015??´ ?????¶???. All rights reserved.
//

#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;

int main(int argc, const char * argv[]) {

    int n,m;
    
//    cout << "input n , m" << endl;
    cin >> n >> m;
    
//    vector<vector<int>> a (n, vector<int>(m));
    
    int a [n][m];
    
//    vector<int> b (m);
    
    int b [m];
    
    // a?????\???
//    cout << "input a" << endl;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            
            cin >> a[i][j];
        }
    }
    
    // b?????\???
//    cout << "input b" << endl;
    for (int j = 0; j < m; ++j) {
        cin >> b[j];
    }
    
    for (int i = 0; i < n; ++i) {
        
        int result = 0;
        
        for (int j = 0; j < m; ++j) {
            
            result += a[i][j] * b[j];
        }
        
        cout << result << endl;
    }

    
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<string> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
  int AC=0;
  int WA=0;
  int TLE=0;
  int RE=0;
  for(int i=0; i<N; i++){

    if(vec.at(i)=="AC"){
      AC++;}
    else if(vec.at(i)=="WA"){
      WA++;}
    else if(vec.at(i)=="TLE"){
      TLE++;}
    else{
      RE++;}
  }
    cout<<"AC x "<<AC<<endl;
    cout<<"WA x "<<WA<<endl;
    cout<<"TLE x "<<TLE<<endl;
    cout<<"RE x "<<RE<<endl;
  }

Measured memory_bytes: 6424
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto C = new long[](N - 1);
    auto S = new long[](N - 1);
    auto F = new long[](N - 1);
    foreach (i; 0 .. N - 1)
    {
        scan(C[i], S[i], F[i]);
    }

    foreach (i; 0 .. N - 1)
    {
        long t;
        foreach (j; i .. N - 1)
        {
            long s = max(S[j], ((t + F[j] - 1) / F[j]) * F[j]);
            t = s + C[j];
        }
        writeln(t);
    }
    writeln(0);
}


Measured memory_bytes: 380
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let a:i64 = read();
    let b:i64 = read();
    let mut max:i64 = a+b;
    if max < a-b {
	max = a-b;
    }
    if max < a*b{
	max = a*b;
    }
    println!("{}",max);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int num=5;
    string S;
    cin >> S;
    for(int i=0; i<S.size(); i++){
        if(S[i]!= S[0]){
            num = i;
            break;
        }
    }
    if(count(S.begin(), S.end(), S[0])==2 && count(S.begin(), S.end(), S[num])==2){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a, b, d;
    char ch;
    cin >> a >> b;
    cin >> ch >> d;
    b *= 100;
    b += d;
    long long mul = (a*b)/100;
    cout << mul << endl;
    return 0;

}


Measured memory_bytes: 3616
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007


const int N = 200005;
int d[N];
int s[N], t[N], x[N];
int ans[N];
int a[500], b[N];

void setmin(int l, int r, int v) {
	int as = (l + 499) / 500;
	int ae = r / 500;
	FOR(j, as, ae)a[j] = min(a[j], v);
	FOR(j, l, min(as * 500, r))b[j] = min(b[j], v);
	FOR(j, max(ae * 500, l), r)b[j] = min(b[j], v);
}

int main() {
	int n, q;
	scanf("%d%d", &n, &q);
	REP(i, n) scanf("%d%d%d", &s[i], &t[i], &x[i]);
	REP(i, q)scanf("%d", &d[i]);
	memset(a, 0x7f, sizeof(a));
	memset(b, 0x7f, sizeof(b));
	REP(i, n) {
		int l = s[i] - x[i];
		int r = t[i] - x[i];
		int lidx = lower_bound(d, d + q, l) - d;
		int ridx = upper_bound(d, d + q, r-1) - d;
		setmin(lidx, ridx, x[i]);
	}
	REP(i, q) {
		ans[i] = min(a[i/500], b[i]);
	}
	REP(i, q)printf("%d\n", (ans[i] > 1e9 + 5) ? -1 : ans[i]);
	return 0;
}


Measured memory_bytes: 6528
#include<cstdio>
#include<algorithm>
using namespace std;const int N=1e6+10;typedef long long ll;const ll mod=1e9+7;
ll fac[N<<1];ll ifac[N<<1];int n;int m;ll ans;ll xl;ll xr;ll yl;ll yr;
ll sx1;ll sy1;ll sx2;ll sy2;ll tx1;ll ty1;ll tx2;ll ty2;
inline void pre()
{
	fac[0]=1;for(int i=1;i<=(N<<1)-10;i++)fac[i]=(fac[i-1]*i)%mod;
	ifac[0]=ifac[1]=1;for(int i=2;i<=(N<<1)-10;i++)ifac[i]=(mod-mod/i)*ifac[mod%i]%mod;
	for(int i=1;i<=(N<<1)-10;i++)(ifac[i]*=ifac[i-1])%=mod;
}
inline ll c(ll n,ll m){return fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
inline int mabs(int x,int y){return (x>y)?x-y:y-x;}
inline ll f(ll x1,ll y1,ll x2,ll y2){return c(mabs(x1,x2)+mabs(y1,y2),mabs(x1,x2));}
int mp[1000][1000];
inline ll solve(const int& sx,const int& sy,const int& tx,const int& ty)
{
	ll ret=0;
	for(int px=xl;px<=xr;px++)(ret+=(mod-yl-px)*f(sx,sy,px,yl-1)%mod*f(px,yl,tx,ty))%=mod;
	for(int py=yl;py<=yr;py++)(ret+=(mod-py-xl)*f(sx,sy,xl-1,py)%mod*f(xl,py,tx,ty))%=mod;
	for(int px=xl;px<=xr;px++)(ret+=(px+yr+1)*f(sx,sy,px,yr)%mod*f(px,yr+1,tx,ty))%=mod;
	for(int py=yl;py<=yr;py++)(ret+=(py+xr+1)*f(sx,sy,xr,py)%mod*f(xr+1,py,tx,ty))%=mod;
	return ret;
} 
int main()
{
	pre();
	scanf("%lld%lld%lld%lld%lld%lld",&sx1,&sx2,&xl,&xr,&tx1,&tx2);
	scanf("%lld%lld%lld%lld%lld%lld",&sy1,&sy2,&yl,&yr,&ty1,&ty2);
	sx1--;sy1--;tx2++;ty2++;
	(ans+=solve(sx1,sy1,tx1,ty1))%=mod;
	(ans+=solve(sx1,sy1,tx2,ty2))%=mod;
	(ans+=mod-solve(sx1,sy1,tx1,ty2))%=mod;
	(ans+=mod-solve(sx1,sy1,tx2,ty1))%=mod;
	(ans+=solve(sx2,sy2,tx1,ty1))%=mod;
	(ans+=solve(sx2,sy2,tx2,ty2))%=mod;
	(ans+=mod-solve(sx2,sy2,tx1,ty2))%=mod;
	(ans+=mod-solve(sx2,sy2,tx2,ty1))%=mod;
	(ans+=mod-solve(sx1,sy2,tx1,ty1))%=mod;
	(ans+=mod-solve(sx1,sy2,tx2,ty2))%=mod;
	(ans+=solve(sx1,sy2,tx1,ty2))%=mod;
	(ans+=solve(sx1,sy2,tx2,ty1))%=mod;
	(ans+=mod-solve(sx2,sy1,tx1,ty1))%=mod;
	(ans+=mod-solve(sx2,sy1,tx2,ty2))%=mod;
	(ans+=solve(sx2,sy1,tx1,ty2))%=mod;
	(ans+=solve(sx2,sy1,tx2,ty1))%=mod;printf("%lld",ans);return 0;
} 

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

withdrawal = [1]
i, j = 1, 1
while True:
    if 6 ** i <= n:
        withdrawal.append(6 ** i)
        i += 1
    else:
        break

while True:
    if 9 ** j <= n:
        withdrawal.append(9 ** j)
        j += 1
    else:
        break

withdrawal = sorted(withdrawal)

# dp
dp = [0 for _ in range(n + 1)]

for i in range(1, n + 1):
    candidate = []
    for w in withdrawal:
        if i - w >= 0:
           candidate.append(dp[i - w])
        else:
            break

    dp[i] = min(candidate) + 1

print(dp[-1])


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

vector<long> V;

void dfs(long n) {
  if (n > 3234566667) return;
  V.push_back(n);
  int mi = max(0L, n % 10 - 1);
  int mx = min(9L, n % 10 + 1);
  for (long i = mi; i <= mx; i++) dfs(n * 10 + i);
}

int main() {
  int K;
  cin >> K;
  for (int i = 1; i <= 9; i++) dfs(i);
  sort(V.begin(), V.end());
  cout << V.at(K - 1) << "\n";
}

Measured memory_bytes: 4292
n,t=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
c=[]
for i in range(n):
  if a[i][1]<=t:
    c.append(a[i][0])

if not c:
  print('TLE')
else:
  print(min(c))

Measured memory_bytes: 9188
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair 
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) <<"\n"
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9;
const ll MAX = 1e5+10;
const ll inf = 1e18+7;

int main(){
	fastio;
	string s;
	cin>>s;
	if(*s.rbegin()=='s') s+="es";
	else s.pb('s');
	cout<<s<<"\n";
    return 0; 
}

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



int main() {
    int n;
    cin >> n;
    
    ll ans = 0;
    for(int i = 1; i <= n-1; i++) {
        ans += (n-1) / i;
    }
    
    cout << ans << endl;
    
    
    return 0;
}




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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

int n;
int dist[505][505];
int jest[505][505];

void fill() {
	FOR(i,0,n) FOR(j,0,n) dist[i][j] = min(min(i,j), min(n-1-i,n-1-j));
	FOR(i,0,n) FOR(j,0,n) jest[i][j] = 1;
}

VI dx = {1,-1,0,0};
VI dy = {0,0,1,-1};

bool inside(int a, int b) {
	return (a>=0 && b>=0 && a<n && b<n);
}

int compute(int x, int y) {
	int ans = dist[x][y];
	FOR(i,0,4) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (!inside(nx, ny)) return 0;
			ans = min(ans, dist[nx][ny] + jest[nx][ny]);
	}
	return ans;
}
void update(int x, int y) {
	vector<PII> que;
	que.pb({x,y});
	int pos = 0;
	while (pos < que.size()) {
		int x = que[pos].st;
		int y = que[pos].nd;
		pos++;
		FOR(i,0,4) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (!inside(nx, ny)) continue;
			int ndist = compute(nx, ny);
			if (ndist != dist[nx][ny]) {
				dist[nx][ny] = ndist;
				que.pb({nx, ny});
			}
		}
	}
}


int main() {
	read(n);
	fill();
	int ans = 0;
	makev(v, n*n);
	FOR(i,0,v.size()) {
		int a = v[i]-1;
		ans += dist[a%n][a/n];
		jest[a%n][a/n] = 0;
		update(a%n, a/n);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 10120
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  char c;
  cin >> c;
  if('A'<=c && c<='Z')cout << 'A' << endl;
  else cout << 'a'  << endl;
  return 0;
}


Measured memory_bytes: 3608
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

input = sys.stdin.readline

from collections import Counter

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

#
n = int(input().strip())
a = list(map(int, input().strip().split()))

#
C=Counter()
for i in range(n):
    C[a[i]] += 1
xsum=0
for key, value in C.items():
    xsum += value*(value-1)//2
    
#
for k in range(n):
    print( xsum - (C[a[k]] - 1) )

Measured memory_bytes: 82780
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int m, f, r;
    int s;
 
    while (1) {
        scanf("%d%d%d", &m, &f, &r);
        if (m == -1 && f == -1 && r == -1) break;
 
        if (m < 0 || f < 0) puts("F");
        else {
            s = m + f;
            if (s >= 80) puts("A");
            else if (s >= 65) puts("B");
            else if (s >= 50) puts("C");
            else if (s < 30) puts("F");
            else puts(r >= 50 ? "C" : "D");
        }
    }
    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265359;

int main()
{
	int a, b, h, m;
	scanf("%d %d %d %d", &a, &b, &h, &m);
	double omega_h = 2*pi/12;
	double omega_m = 2*pi/1;
	double t = h + m/60.0;
	double alpha = (omega_m - omega_h)*t;
	double dist = sqrt(a*a + b*b - 2*a*b*cos(alpha));
	printf("%.9lf", dist);
}


Measured memory_bytes: 4256
import java.io.*;

class Main{
    public static void main(String[] args) throws Exception{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String num1 = br.readLine();
        String[] num2 = num1.split(" ");

        Double a = Double.parseDouble(num2[0]);

        double s = a * a * Math.PI;
        double l = (a + a) * Math.PI;
        String S = String.format("%.6f", s);
        String L = String.format("%.6f", l);

        System.out.println(S + " " + L);
    }
}

Measured memory_bytes: 24744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    string s; cin >> s;
    set<string> se;
    int k, len = s.size(); sc(k)
    for (int i = 1; i <= k; i++){
        for (int j = 0; j <= len-i; j++) se.insert(s.substr(j, i));
    }
    auto it = se.begin();
    for (int i = 0; i < k-1; i++) it++;
    cout << *it << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
using namespace std;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; i++){
		if(i % 5 != 0 and i % 3 != 0){
			sum += i;
		}
	}
	cout << sum;
   return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n,k; cin >> n >> k;
	vector<int> v(n);
	int count = 0;
	rep(i,n){
		cin >> v[i];
		v[i] > k-v[i]? count += (k-v[i])*2 : count += v[i]*2;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef double db;
#define ls(x) x<<1
#define rs(x) x<<1|1
#define low(x) (x&-x)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define X first
#define Y second
#ifdef _DEBUG
    const int N=1e3+10;
#else
    const int N=1e6+10;
#endif
const ll mod=1e9+7;
template<typename T> inline T gcd(T a,T b){return !b?a:gcd(b,a%b);}
template<typename T> inline T q_pow(T a,T x){T ans=1,tmp=a;while(x){if(x&1)(ans*=tmp)%=mod;(tmp*=tmp)%=mod;x>>=1;}return ans;}
template<typename T> inline void re(T &N){int f=1;char c;while((c=getchar())< '0'||c> '9')if(c=='-')f=-1;N=c-'0';while((c=getchar())>='0'&&c<='9')N=N*10+c-'0';N*=f;}
int m,n,t=1,st,en;
int a[N],b[N],d[N];
char s[N];

int main()
{
    // freopen("data.txt","r",stdin);
    re(n);
    for(int i=1;i<=n;i++)re(a[i]);
    int l=0,r=0;ll ans=0;
    while(r< n)
    {
        r++;int ma=-1;
        for(int i=0;i<=20;i++)if((a[r]>>i)&1)
        {
            if(d[i])ma=max(ma,d[i]);
            d[i]=r;
        }
        if(ma>=0)l=max(l,ma);
        ans+=r-l;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 3072
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
public class Simple {
    public static void Main() {new Simple().Solve();}
    int N, A, B;
    long[] v;
    void Solve(){
        //input
        var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        N = inp[0];
        A = inp[1];
        B = inp[2];
        v=Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        v = v.OrderByDescending(v => v).ToArray();

        //average
        var ave = (double)v.Take(A).Average();

        //patern
        var patern = 0L;
        var Comb = C(50);
        var top = v.First();
        var bot = v[A - 1];
        var usable = v.Where(v => v == bot).Count();
        if(v[0]==v[A-1]){
            for (int i = A; i <= B;i++){
                if (usable < i) break;
                patern += Comb[usable, i];
            }
        }else{
            var use = v.Select((e, i) => new { e, i }).
                       Where(v => v.e == bot && v.i < A).Count();
            patern = Comb[usable, use];
        }

        //res
        Console.WriteLine(ave);
        Console.WriteLine(patern);
    }

    long[,] C(int N) {
        long[,] ret = new long[N + 1, N + 1];
        for (int i = 0; i <= N; i++)
            for (int j = 0; j <= i; j++)
                ret[i, j] = (j == 0 || j == i) ? 1L : ret[i - 1, j - 1] + ret[i - 1, j];
        return ret;
    }
    
        
}

Measured memory_bytes: 13620
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // square869120Contest #3 A - カレンダー
  // 左上の数のmod11がいくつかになるかで総和のmod11も一意に決まる
  // sol={6, 4, 2, 0, 9, 7, 5, 3, 1, 10, 8}
  // あとはその数を範囲内にいくつ確保できるかの問題になる
  // ただし、段数nが10^9なので、全探索は間に合わない。
  // 11段ごとに同じ繰り返し各5個ずつ出現するので、まずans=(n-2)/11*5
  // (n-2)%11については全探索
  ll n, k; cin >> n >> k;
  vector<ll> sol = {6, 4, 2, 0, 9, 7, 5, 3, 1, 10, 8};
  ll ans = (n-2) / 11 * 5; // kがなんであっても答えは同じ
  
  REP(i, (n-2) % 11){
    REP(j, 5){
      if(sol[(7*(i+1)+(j+1)-7)%11] == k) ans++; // 左上の数値で総和mod11が決まる
    }
  }
  cout << ans << endl;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    int pars;

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
        pars = N;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry){
        	return; //xとyの根が同じ(=同じ木にある)時はそのまま
        }
    	pars--;
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int retnm(){
    	return pars;
    }
};

int main() {
    int N, M;
    cin >> N >> M;

    UnionFind tree(N);

    int x, y;
    for(int i = 0; i < M; i++) {
        cin >> x >> y;
        tree.unite(x-1,y-1);
    }

    cout << tree.retnm()-1 << endl;

    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n;
vector<vector<ll>> g, dp;

vector<ll> ide(){
    return {1, 0};
}

vector<ll> f1(vector<ll> a, vector<ll> b){
    return {a[0]*b[0]%MOD, (a[0]*b[1]%MOD+a[1]*b[0]%MOD+a[1]*b[1]%MOD)%MOD};
}

vector<ll> f2(vector<ll> a){
    return {(a[0]+a[1])%MOD, a[0]};
}

void dfs1(ll at, ll from = -1){
    dp[at] = ide();
    zep(i, 0, g[at].size()){
        ll nx = g[at][i];
        if(nx != from){
            dfs1(nx, at);
            dp[at] = f1(dp[at], f2(dp[nx]));
        }
    }
}

void dfs2(ll at, ll from = -1, vector<ll> x = ide()){
    dp[at] = f2(f1(dp[at], x));

    ll m = g[at].size();
    vector<ll> l[m], r[m];
    zep(i, 0, m){l[i] = r[i] = (g[at][i] == from)? x : f2(dp[g[at][i]]);}
    rep(i, 1, m-1){l[i] = f1(l[i], l[i-1]);}
    rrep(i, m-2, 0){r[i] = f1(r[i], r[i+1]);}

    zep(i, 0, m){
        ll nx = g[at][i];
        if(nx != from){
            vector<ll> tmp = ide();
            if(i > 0){tmp = f1(tmp, l[i-1]);}
            if(i < m-1){tmp = f1(tmp, r[i+1]);}
            dfs2(nx, at, f2(tmp));
        }
    }
}

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

    cin >> n;
    g.resize(n);
    dp.resize(n);
    zep(i, 0, n-1){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs1(0);
    dfs2(0);
    print((dp[0][0]+dp[0][1])%MOD)
    return 0;
}

Measured memory_bytes: 101632
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll N;
    cin >> N;
    vector<ll> a1(N);
    vector<ll> a2(N);
    rep(i, N) cin >> a1[i];
    rep(i, N) cin >> a2[i];

    vector<ll> a1_sum(N, 0);
    vector<ll> a2_sum(N, 0);

    a1_sum[0] = a1[0];
    for (ll i = 1; i < N; i++) {
        a1_sum[i] += a1_sum[i - 1] + a1[i];
    }

    a2_sum[N - 1] = a2[N - 1];
    for (ll i = N - 2; i >= 0; i--) {
        a2_sum[i] += a2_sum[i + 1] + a2[i];
    }

    ll ans = 0;
    rep(i, N) { ans = max(ans, a1_sum[i] + a2_sum[i]); }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3608