akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#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 <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//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 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,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;






int main(void) {
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	
	LL maxindex = 0;
	LL maxscore = 0;
	LL minindex = 10000000000;
	LL minscore = 10000000000;
	for( int i=0; i< N; i++) {
		cin >> A[i] >> B[i];
		if (maxindex < A[i]) {
			maxindex = A[i];
			maxscore = B[i];
		}
		if (minindex > A[i]) {
			minindex = A[i];
			minscore = B[i];
		}
	}

	int res = 0;
	res += (minindex - 1);
	res += (maxindex - minindex);
	res += maxscore + 1;

	cout << res << endl;


	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if (x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
uint64_t M = 1000000000000000000;

int main()
{
    int n;
    cin>>n;
    uint64_t a1[n];
    for(int i=0;i<n;i++)
    cin>>a1[i];
    sort(a1,a1+n);
    uint64_t mul=1LL,a,b,x;
    for(int i=0;i<n;i++)
    {
      //  cout<<mul<<" "<<a[i]<<endl;
        a = mul;
        b = a1[i];
        x = a*b;
        if ((a != 0 && x / a != b) || x>M)
        {
            cout<<-1<<endl;
            return 0;
        }
        mul*=a1[i];
    }
    cout<<mul<<endl;
}

Measured memory_bytes: 4376
#![allow(unused_imports, unused_macros, non_snake_case)]
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

//{{{ macros missing in 1.15.1
#[macro_use]
mod macros {
    macro_rules! eprint {
        ($($t:tt)*) => {{
            use ::std::io::Write;
            let _ = write!(::std::io::stderr(), $($t)*);
        }};
    }
    macro_rules! eprintln {
        () => { eprintln!(""); };
        ($($t:tt)*) => {{
            use ::std::io::Write;
            let _ = writeln!(::std::io::stderr(), $($t)*);
        }};
    }
    macro_rules! dbg {
        ($val:expr) => {
            match $val {
                tmp => {
                    eprintln!(
                        "[{}:{}] {} = {:#?}",
                        file!(),
                        line!(),
                        stringify!($val),
                        &tmp
                    );
                    tmp
                }
            }
        };
    }
}
//}}}

fn run() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());
    let n: usize = sc.read();
    let a: Vec<usize> = sc.read_vec(n);
    let mut s = 0;
    for i in 0..n {
        s += a[i];
    }
    let mut t = 0;
    let mut ans = usize::max_value();
    for i in 0..n {
        t += a[i];
        let w = s - t;
        let local = if t >= w { t - w } else { w - t };
        if ans > local {
            ans = local;
        }
    }
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".to_string())
        .stack_size(1024 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap()
}

//{{{ Scanner
pub struct Scanner<R> {
    reader: R,
}

impl<R> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner { reader: r }
    }
}

fn is_whitespace(b: u8) -> bool {
    b == b' ' || b == b'\n' || b == b'\r' || b == b'\t'
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        let buf = std::io::Read::bytes(self.reader.by_ref())
            .map(|b| b.expect("Read failed"))
            .skip_while(|&b| is_whitespace(b))
            .take_while(|&b| !is_whitespace(b))
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error")
    }

    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
//}}}


Measured memory_bytes: 10620
<?php
fscanf(STDIN, "%s %s", $x, $y);
$factors = [];
for ($tmp = 0; $tmp < 6; $tmp++){
    $factors[chr(ord('A')+$tmp)] = $tmp+10;
}
if ($factors[$x] < $factors[$y]){
    print "<\n";
} else if($factors[$x] > $factors[$y]){
    print ">\n";
} else {
    print "=\n";
}
?>

Measured memory_bytes: 4856
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) {
  v = vector<T>(n, x);
}
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
vector<lli> a;
vector<vector<lli>> dp;
int main() {
  cin >> n; read_n(a, n);
  init_n(dp, n, vector<lli>(n, 0));
  for (lli l=0; l<n; ++l) {
    dp[l][l] = (n&1)==0 ? -a[l] : a[l];
  }
  for (lli d=1; d<n; ++d) {
    for (lli l=0; l<n-d; ++l) {
      lli r = l+d;
      dp[l][r] = ((n-d)&1)==1 
	? max(dp[l+1][r] + a[l], dp[l][r-1] + a[r])
	: min(dp[l+1][r] - a[l], dp[l][r-1] - a[r]);
    }
  }
  cout << dp[0][n-1] << endl;
  return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

void prime(i64 n, map<i64, i64>& m) {
    for (i64 i = 2; i*i <= n; i++) {
        int cnt = 0;
        while (n%i == 0) {
            n /= i;
            cnt++;
        }
        if (cnt) m[i] += cnt;
    }
    if (n > 1) m[n] += 1;
}

i64 pattern(i64 num) {
    i64 ret=0;
    for (i64 cnt = 1; cnt <= num; ++cnt) {
        ++ret;
        num-=cnt;
    }
    return ret;
}

int main(int argc, char **argv) {
    i64 n;
    cin >> n;
    map<i64,i64> m;

    prime(n, m);

    i64 ans{0};
    for (auto& kv : m) {
        //cout << kv.first << " " << kv.second << " ->" << pattern(kv.second)<< endl;
        ans += pattern(kv.second);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
import collections
import bisect
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N = int(input())
c = collections.Counter(prime_factorize(N))
sums = []
s=1
ans = 0
for v in c.values():
  count = 0
  for i in range(1,v+1):
    if count+i > v:
      break
    else:
      count += i
      ans += 1
print(ans)

Measured memory_bytes: 9328
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll a,b;
    cin >> a >> b;
    if(a<10&&b<10)cout << a*b;else cout << -1;
    return 0;
}


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

typedef pair<ll,ll> P;
const ll MO = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    ll s1,s2,mini=INF;
    rep(i,n)s2+=a[i];
    rep(i,n-1){
        s1 +=a[i];
        s2 -=a[i];
        mini = min(mini,abs(s1-s2));
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 1792
//
//  main.cpp
//  test
//
//  Created by yuta on 2019/05/27.
//  Copyright © 2019 501Software. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

struct RES {
	int 	number;
	string	s;
	int		p;
};



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

	
	int n;
	cin >> n;

	vector<RES> res(n);
	vector<string> s(n);
	vector<int> p(n);

	for(int i=0; i<n; i++){
		cin >> res[i].s >> res[i].p;
		res[i].number = i+1;
	}
	
	// nameをキーに昇順でソート
	sort(res.begin(), res.end(),[&](RES x, RES y) {
		if(x.s == y.s){
			return x.p >  y.p;
		}
		else {
			return x.s < y.s;
		}
	});
	
//	vector<int> v = {3, 1, 4, 2, 5};
//	sort(v.begin(), v.end());

	
	for(int i=0; i<n; i++){
		cout << res[i].number << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int dp[105][4][2];

int main() {
  // dp[i][j][k] i桁目まで見た時の、0でない数がj個ある数字の個数
  // k=0はpending、k=1はN以下が確定
  string S;
  int K;
  cin >> S >> K;
  int lenS = sz(S);
  dp[0][0][0] = 1;
  rep(i, lenS) rep(j, K+1) rep(k, 2) {
    int cd = S[i] - '0';
    rep(nd, 10) {
      int ni = i+1, nj = j, nk = k;
      if (nd != 0) nj++;
      if (nj > K) continue;
      if (k == 0) {
        if (nd > cd) continue;
        if (nd < cd) nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  int ans = dp[lenS][K][0] + dp[lenS][K][1];
  cout << ans << '\n';  
  return 0;
}
// 35

Measured memory_bytes: 3604
import java.util.*;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int N = sc.nextInt();
      int K = sc.nextInt();
      int[] p = new int[N];
      for (int i = 0; i < N; i++) {
        p[i] = sc.nextInt();
      }
      Arrays.sort(p);

      int ans = Integer.MAX_VALUE;
      for (int i = 0; i < N - K + 1; i++) {
        ans = Math.min(ans, p[i + K - 1] - p[i]);
      }

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


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2,s3;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>s1;
    cin>>s2;
    cin>>s3;

    cout<<s1[0]<<s2[1]<<s3[2]<<endl;



}


Measured memory_bytes: 256
function Main(input){
  var lines=input.split('\n');
  var s=0;
  for(var i=0;i<10;++i){
    if(lines[i]=="\n")break;
    s+=parseInt(lines[i]);
  }
  console.log(s);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7388
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
      Scanner sc     = new Scanner(System.in);
  for(int i = 0;i<50;i++){
      int m          = sc.nextInt();
      int f          = sc.nextInt();
      int r          = sc.nextInt();

      if(m==-1 && f==-1 && r==-1)
          break;

      if(m==-1||f==-1){
                System.out.println("F");
          }else if(80 <= m + f){
                System.out.println("A");
          }else if(65 <= m + f){
                System.out.println("B");
          }else if(50 <= m + f){
                System.out.println("C");
          }else if(30 <= m + f){
                if(50 <= r){
                  System.out.println("C");
                }else{
                  System.out.println("D");
                }
          }else{
                System.out.println("F");
          }
  }
  }
}



Measured memory_bytes: 26324
let () =
    let main () =
        let n = Scanf.scanf "%d" (fun n -> n) in
        let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
        let b = Array.init n (fun _ -> Scanf.scanf " %d" (fun b -> b)) in
        let tentou a =
            let l = Array.length a in
            let rec loop i j s =
                if i >= l then s else
                    if j >= l then loop (i + 1) (i + 2) s else
                        let s = if a.(i) > a.(j) then s + 1 else s in
                        loop i (j + 1) s
            in
            loop 0 1 0
        in
        let judge even odd m =
            let evens = List.map (fun k -> (if k mod 2 = 0 then a.(k) else b.(k)), k) even in
            let odds  = List.map (fun k -> (if k mod 2 = 1 then a.(k) else b.(k)), k) odd in
            let evena = List.sort compare evens |> Array.of_list in
            let odda  = List.sort compare odds  |> Array.of_list in
            let rec loop prev i hist =
                if i = n then Some hist else
                    let (r, h) = if i mod 2 = 0 then evena.(i / 2) else odda.(i / 2) in
                    if r < prev then None else loop r (i + 1) (h :: hist)
            in
            match loop (-1) 0 [] with
            | Some hist ->
                let r = List.rev hist |> Array.of_list |> tentou in
                min m r
            | None -> m
        in
        let rec loop e o i even odd m =
            if i = n then judge even odd m else
                if e = 0 then loop e (o - 1) (i + 1) even (i :: odd) m else
                    let m = loop (e - 1) o (i + 1) (i :: even) odd m in
                    if o = 0 then m else loop e (o - 1) (i + 1) even (i :: odd) m
        in
        let e = ((n + 1) / 2) in
        let o = n - e in
        let r = loop e o 0 [] [] max_int in
        let r = if r = max_int then (-1) else r in
        Printf.printf "%d\n" r
    in
    main ()

Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 c[11];
int main() {
  for (i64 i = 0; i < 3; ++i) {
    i64 x; cin >> x;
    c[x]++;
  }
  if (c[5] == 2 && c[7] == 1) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}


Measured memory_bytes: 256
/*====Corycle====*/
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<cstdio>
#include<vector>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
ll read(){
	ll s=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return s*f;
}
ll L,R,Lim,cnt,Ans,dlt;
struct Line{ll l,r;}P[10];
bool cmp(Line A,Line B){return A.l!=B.l?A.l<B.l:A.r<B.r;}
int main(){
//	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	L=read();R=read();Lim=-1;
	for(int i=60;i>=0;i--){
		int x=(L>>i)&1,y=(R>>i)&1;
		if(x==y&&Lim==-1){if(x)dlt+=(1ll<<i);continue;}
		if(Lim==-1){Lim=i;P[++cnt]=(Line){L-dlt+(1ll<<Lim),(1ll<<(Lim+1))-1};}
		else if(y==1){P[++cnt]=(Line){1ll<<Lim,(1ll<<Lim)+(1ll<<(i+1))-1};break;}
	}
	P[++cnt]=(Line){L-dlt,R-dlt};
	sort(P+1,P+cnt+1,cmp);
	ll l=P[1].l,r=P[1].r;
	for(int i=2;i<=cnt;i++){
		if(P[i-1].r>=P[i].l)r=max(r,P[i].r);
		else{Ans+=r-l+1;l=P[i].l;r=P[i].r;}
	}
	Ans+=r-l+1;
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<queue>
using namespace std;
#define MAX 50
struct Data{int tx,ty,kx,ky,cost;};
int main()
{
  int X,Y,tx,ty,kx,ky,d[MAX][MAX];
  int i,j,x,y;
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  queue<Data> q;
  bool f,visited[MAX][MAX][MAX][MAX];
  while(cin>>X>>Y>>tx>>ty>>kx>>ky,X|Y){
    for(j=0;j<Y;j++)for(i=0;i<X;i++)cin>>d[i][j];
    for(j=0;j<Y;j++)for(i=0;i<X;i++)for(y=0;y<Y;y++)for(x=0;x<X;x++)visited[i][j][x][y]=false;
    while(q.size())q.pop();
    tx--;ty--;kx--;ky--;
    Data p={tx,ty,kx,ky,0},pp;
    q.push(p);
    f=false;
    while(q.size()){
      p=q.front();
      q.pop();
      if(p.tx==p.kx&&p.ty==p.ky){f=true;break;}
      visited[p.tx][p.ty][p.kx][p.ky]=true;
      for(i=0;i<4;i++){
	pp=p;
	pp.tx+=dx[i];pp.ty+=dy[i];
	pp.kx+=dx[(i+2)%4];pp.ky+=dy[(i+2)%4];
	pp.cost++;
	if(pp.tx<0||X<=pp.tx||pp.ty<0||Y<=pp.ty||d[pp.tx][pp.ty]){pp.tx=p.tx;pp.ty=p.ty;}
	if(pp.kx<0||X<=pp.kx||pp.ky<0||Y<=pp.ky||d[pp.kx][pp.ky]){pp.kx=p.kx;pp.ky=p.ky;}
	if(visited[pp.tx][pp.ty][pp.kx][pp.ky])continue;
	visited[pp.tx][pp.ty][pp.kx][pp.ky]=true;
	q.push(pp);
      }
    }
    if(f)cout<<p.cost<<endl;
    else puts("NA");
  }
}

Measured memory_bytes: 7364
while True:
    m,f,r= map(int,input().split())
    if m == -1 and f == -1 and r == -1:break
    elif m == -1 or f == -1:print("F")
    elif m+f>=80:print("A")
    elif 80>m+f>=65:print("B")
    elif 65>m+f>=50:print("C")
    elif 50>m+f>=30 and r>=50:print("C")
    elif 50>m+f>=30 and r<50:print("D")
    elif 30>m+f:print("F")



Measured memory_bytes: 5596
package main

import "fmt"

func main() {
	var W, a, b int;

	fmt.Scan(&W, &a, &b);

	if a <= b && a + W >= b {
		fmt.Println(0)
	}else if a+W < b{
		fmt.Println(b - (a + W))
	}else {
		fmt.Println(a - (b + W))
	}

}


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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.end());}
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 (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll N, K;
    cin >> N >> K;
    V<V<ll>> A(N, V<ll>(N, 0));
    REP(i, N){
        REP(j, N){
            cin >> A[i][j];
        }
    }

    ll BM = 1e12;

    ll s = 2*N;
    ll t = 2*N+1;
    mcf_graph<ll, ll> G(2*N+2);

    G.add_edge(s, t, N*K, BM);

    REP(i, N){
        G.add_edge(s, i, K, 0);
        G.add_edge(i+N, t, K, 0);
    }

    REP(i, N){
        REP(j, N){
            G.add_edge(i, j+N, 1, BM-A[i][j]);
        }
    }

    auto res = G.flow(s, t, N*K);
        
    cout << -(res.second - BM*res.first) << endl;

    V<V<char>> B(N, V<char>(N, '.'));

    for(auto e: G.edges()){
        if(e.from == s or e.to == t) continue;
        if(e.flow == 1){
            B[e.from][e.to-N] = 'X';
        }
    }

    REP(i, N){
        REP(j, N){
            cout << B[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3880
#include <iostream>
#include <algorithm>

using namespace std;

string _strA;
string _strB;

bool Compare (char a, char b) {
	return a > b;
}

int main () {
	
	getline(cin, _strA);
	getline(cin, _strB);
	
	sort (_strA.begin(), _strA.end());
	sort (_strB.begin(), _strB.end(), Compare);
	
	if (_strA < _strB) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<char> S(3);
  vector<char> T(3);
  for(int i = 0; i < 3; i++){
    cin >> S.at(i);
  }
  
  for(int i = 0; i < 3; i++){
    cin >> T.at(i);
  }
  
  int ans = 0;
  for(int i = 0; i < 3; i++){
    if(S.at(i) == T.at(i)){
      ans++;
    }
    else{}
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define pii pair<int, int> 
#define pll pair<long , long>
#define all(a) a.begin(), a.end()
#define int long long
#define ll long long
#define mod 998244353
//#define int long long
#define loop(i,a,b) for(int i=a;i<b;i++)
#define bloop(i,a,b) for(int i=a;i>=b;i--)

int max(int a, int b) { return (a > b)? a : b; } 
using namespace std;

ll funct(int n)
{
    if(n<=1) return 0;
    else return (n*(n-1))/2;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int t=1,ca=1;
   //cin>>t;
   while(ca<=t)
   {
      ca+=1;
      int L;
	cin>>L;
 	
 	float a = (float)L/3;
 
 	float ans = (a*a*a);
 	cout << fixed << showpoint << setprecision(12) << ans << endl;
   }
    return 0;
}

Measured memory_bytes: 256
#ifdef FAIRLY_LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <iostream>
using namespace std;

typedef long long int ll;

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

    ll n;

    cin >> n;

    int col = 1;
    ll count = 26;
    while (n > count) {
        n -= count;
        count *= 26;
        ++col;
    }

    --n;
    for (int i = 0; i < col; ++i) {
        count /= 26;
        char c = 'a' + (n / count);
        n %= count;
        cout << c;
    }
    return 0;
}

Measured memory_bytes: 3628
def calc(value, replacement)
  value.each{
    |v| v.gsub!("X", replacement) 
  }
  return true   if  value[0].to_i + value[1].to_i == value[2].to_i
end

def head(str)
  str[0, 1]
end

def checkWrongNumber(input)
  return (head(input[0]) == "0" && input[0].size > 1) || (head(input[1]) == "0" && input[1].size > 1) || (head(input[2]) == "0" && input[2].size > 1)
end

while str = gets
  x = "NA"
  for i in 0..9
    input = str.chomp.scan(/[^(\+=)]+/)
    if  calc(input, i.to_s) && !checkWrongNumber(input)
      x = i.to_s
      break
    end
  end
  puts x
end

#for test : X5+5=1X X+X=X X5+X5=10

Measured memory_bytes: 6220
<?php

function input() {
    return trim(fgets(STDIN));
}
function input_array() {
    return explode(' ', input());
}

function p($card_array) {
    echo implode(' ', array_map(function($card) {
        return ($card->suit) . ($card->value);
    }, $card_array)) . "\n";
}
function isStable($C1, $C2) {
    for ($i = 0, $count = count($C1); $i < $count; $i++) {
        if ($C1[$i]->suit !== $C2[$i]->suit) {
            return false;
        }
    }
    return true;
}

function bubble(&$A) {
    for ($i = 0, $count = count($A); $i < $count; $i++) {
        for ($j = $count - 1; $j >= $i + 1; $j--) {
            if ($A[$j]->value < $A[$j - 1]->value) {
                $t = $A[$j]; $A[$j] = $A[$j - 1]; $A[$j - 1] = $t;
            }
        }
    }
}

function selection(&$A) {
    for ($i = 0, $count = count($A); $i < $count; $i++) {
        $minj = $i;
        for ($j = $i; $j < $count; $j++) {
            if ($A[$j]->value < $A[$minj]->value) {
                $minj = $j;
            }
        }
        $t = $A[$i]; $A[$i] = $A[$minj]; $A[$minj] = $t;
    }
}

class Card
{
    public $suit, $value;
    public function __construct($suit, $value) {
        $this->suit = $suit;
        $this->value = (int)$value;
    }
}

$N = (int)input();
$C1 = array_map(function($suit_and_value) {
    return new Card($suit_and_value[0], $suit_and_value[1]);
}, input_array());
$C2 = array_map(function($card) {
    return clone $card;
}, $C1);

bubble($C1);
selection($C2);

p($C1);
echo "Stable\n";
p($C2);
if (isStable($C1, $C2)) {
    echo "Stable\n";
} else {
    echo "Not stable\n";
}


Measured memory_bytes: 9424
let n = stdin.ReadLine() |> int
let sArr = 
    [| for _ in 1..n -> stdin.ReadLine() |]

let ansS = sArr |> Array.countBy id

[| "AC"; "WA"; "TLE"; "RE"; |] 
|> Array.iter (fun label ->
    ansS |> Array.tryFind (fun (s, _) -> s = label) 
    |> Option.defaultValue (label, 0) 
    |> fun (str, cnt) -> str + " x " + string cnt 
    |> stdout.WriteLine )

Measured memory_bytes: 34608
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<stack>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	float sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	float ave = sum / n;
	float tmp = 500;
	int tmpa = -1;
	for (int i = 0; i < n; i++) {
		if (fabs(a[i] - ave) < tmp) {
			tmp = fabs(a[i] - ave);
			tmpa = i;
	   }
	}
	cout << tmpa << endl;
}







Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
int main() {
	string a;
	cin>>a;
	reverse(a.begin(),a.end());
	cout<<a<<endl;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, n , m) for(int i = n; i <= m; i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
const int mod = 1000000007; 
long long inv[200000],fact[200000],ifact[200000];
long long comb(ll n, ll k){
	if(n<k)return 0;
	else if (n<0||k<0) return 0;
	else return fact[n] * ifact[k] % mod * ifact[n-k] % mod;
}
 
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	/*inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1; for (int i=2;i<200000;i++){ inv[i] = (mod - mod / i) * inv[mod % i] % mod; fact[i] = fact[i-1] * i % mod;ifact[i] = ifact[i-1] * inv[i] % mod;
	}*/ //nCr
	
	ll H,W;
	cin>>H>>W;
	int c[10][10];
	int A[H][W];
	rep(i,10)rep(j,10)cin>>c[i][j];
    rep(i,H)rep(j,W)cin>>A[i][j];
	
	rep(i,10)rep(j,10)rep(k,10)c[j][k]=min(c[j][k],c[j][i]+c[i][k]);
	ll ans=0;
	rep(i,H)rep(j,W) if(A[i][j]!=-1)ans+=c[A[i][j]][1];
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::vector;
using std::stack;

using std::min;
using std::max;

struct point {
    int x;
    int y;
    point() : x(0), y(0) {}
    point(int x, int y) : x(x), y(y) {}
};

int count_point(const vector<point>& pp, int sx, int sy, int tx, int ty) {
    int cnt = 0;
    for (point p : pp) {
        if (sx <= p.x && p.x <= tx && sy <= p.y && p.y <= ty) {
            cnt += 1;
        }
    }
    return cnt;
}

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

    vector<point> pp(n);
    for (int i = 0; i < n; i++) {
        cin >> pp[i].x >> pp[i].y;
    }

    unsigned long ans = 1UL << 63;
    for (point p0 : pp) {
        for (point p1 : pp) {
            for (point p2 : pp) {
                for (point p3 : pp) {
                    if (p0.x != min(min(p0.x, p1.x), min(p2.x, p3.x))) {
                        continue;
                    }
                    if (p1.x != max(max(p0.x, p1.x), max(p2.x, p3.x))) {
                        continue;
                    }
                    if (p2.y != min(min(p0.y, p1.y), min(p2.y, p3.y))) {
                        continue;
                    }
                    if (p3.y != max(max(p0.y, p1.y), max(p2.y, p3.y))) {
                        continue;
                    }
                    if (!(count_point(pp, p0.x, p2.y, p1.x, p3.y) >= k)) {
                        continue;
                    }
                    unsigned long w = p1.x - p0.x;
                    unsigned long h = p3.y - p2.y;
                    ans = min(ans, w * h);
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

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

	string s;
	cin >> s;

	int max_size = 0;

	for (int i=1; i<n; i++){
		string s1, s2;
		s1 = s.substr(0, i);
		s2 = s.substr(i, n-i);

		
		int c[100] = {0};

		for (int j=0; j<i; j++){
			int a = -1;
			a = s2.find(s1.substr(j, 1));

			if (a >= 0) c[a] = 1;
		}

		int sum=0;
		for (int k=0; k<100; k++){
			sum += c[k];
		}

		max_size = max(sum, max_size);

	}
	cout << max_size;	 
}

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

int main(){
  int N,a,b;
  cin >> N >> a >> b;
  
  int x = 0, sum = 0;
  for(int i=0; i<=N; i++){
    int f0 = i%10;
    int f1 = (i%100)/10;
    int f2 = (i%1000)/100;
    int f3 = (i%10000)/1000;
    int f4 = (i%100000)/10000;
    x = f0 + f1 + f2 + f3 + f4;
    if(a<=x && x<=b){
      sum += i;
    }
  }
  
  cout << sum << endl;
}

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

int main(){
    
    int a,b,c,cnt=0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i = a ; i<=b;i++){
        if(c%i == 0)cnt++;
    }
    printf("%d\n",cnt);
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

vll pl;

bool is_prime(const unsigned n) {
  if (n % 2 == 0 || n % 3 == 0) {
    if (n == 2 || n == 3) {
      return true;
    }
    return false;
  }
  if (n == 1) {
    return false;
  }

  for (unsigned i = 5; i * i <= n; i += 6) {
    if (n % i == 0 || n % (i + 2) == 0) {
      return false;
    }
  }

  return true;
}

// prime factorization (素因数分解)
// key: value of prime factor
// value: number of prime factor
std::set<ll> prime_factorization(ll n) {
  std::set<ll> prime_factors;
  for (ll i : pl) {
    if (i * i > n)
      break;

    while (n % i == 0) {
      prime_factors.insert(i);
      n /= i;
    }
  }
  if (n != 1)
    prime_factors.insert(n);
  return prime_factors;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  vll a(n);
  rep(i, n) cin >> a[i];

  set<ll> primes;

  REP(i, 1e6 + 10) {
    if (is_prime(i)) {
      pl.push_back(i);
    }
  }

  vll pp(1e6 + 10);

  rep(i, n) {
    auto pf = prime_factorization(a[i]);
    for (auto& p : pf) {
      pp[p]++;
    }
  }

  bool is_pairwise = true;
  for (auto i : pp) {
    if (i > 1) {
      is_pairwise = false;
    }
  }

  ll all_gcd = a[0];
  rep(i, n) {
    all_gcd = gcd(all_gcd, a[i]);
  }

  if (is_pairwise) {
    cout << "pairwise coprime" << endl;
  } else if (all_gcd == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}


Measured memory_bytes: 19736
#include <iostream>
#include <limits>
#include <cmath>
#include <sstream>

using namespace std;

int main() {

	int a,b,c,p = 0,l = 0;
	while (scanf("%d,%d,%d",&a,&b,&c) != EOF) {
		if (a*a + b*b == c*c) p++;
		if (a == b) l++;
	}

	cout << p << endl << l << endl;

	return 0;
}

Measured memory_bytes: 1200
def solve():
    S = input()
    head2 = int(S[:2])
    tail2 = int(S[2:])
    head_is_mm = False
    if 1 <= head2 <= 12:
        head_is_mm = True
    tail_is_mm = False
    if 1 <= tail2 <= 12:
        tail_is_mm = True
    result = 'NA'
    if head_is_mm and tail_is_mm:
        result = 'AMBIGUOUS'
    elif head_is_mm:
        result = 'MMYY'
    elif tail_is_mm:
        result = 'YYMM'
    print(result)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;



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

ll a,b,c;
cin >> a >> b >> c;

ll l = 4*a*b;
ll r = c - a - b;

if(r > 0 && l < r*r) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}

Measured memory_bytes: 256
function Main(input){
  input = input.split(" ");
  input[3] = input[3].split("").map(Number);
  input[3] = input[3][input[3].length-1];
  console.log(input[3]%2==1?input[1]-input[0]:input[0]-input[1]);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 7372
<?php
$input = fscanf(STDIN, '%d %d');

$n = $input[0];
$m = $input[1];

if ($n > 1 && $m > 1) {
    echo ($n - 2) * ($m - 2) . "\n";
} else if ($n > 1){
    echo $n - 2 . "\n";
} else if ($m > 1){
    echo $m - 2 . "\n";
} else {
    echo 1 . "\n";
}

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N;
    vec s(N);
    rep(i,N) cin>>s[i];
    ll sum = 0;
    rep(i,N) sum += s[i];
    ll ans = 0;
    sort(s.begin(), s.end());
    reverse(s.begin(), s.end());
    rep(i,N){
        if((sum - s[i])%10 != 0) ans = sum - s[i];
    }
    if(sum%10 != 0) ans = sum;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
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; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
#define GetAuto(_N,vect) {cin>>_N;vect.resize(_N);REP(i,_N){cin>>vect[i];}}
#define beginend(vec) (vec).begin(),(vec).end()
#define pb(item) push_back(item)
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
#define WhileCin(n) while(cin>>n)
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) { ll prime; double sqrtmax = sqrt(max); vector<ll> primeVec, searchVec; FOR(i, 2, max + 1) searchVec.push_back(i); do { prime = searchVec[0]; primeVec.push_back(prime); auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; }); searchVec.erase(itr, searchVec.end()); } while (prime < sqrtmax); primeVec.reserve(primeVec.size() + searchVec.size()); primeVec.insert(primeVec.end(), beginend(searchVec)); return primeVec; }

int main()
{
	int n;
	cin >> n;
	vi ans;
	while(n!=0) {
		vector<string> w(n);
		REP(i, n) cin >> w[i];
		string song = "";
		REP(i, n) {
			int spcnt = 0;
			int wordcnts[5]{ 5,7,5,7,7 };
			int w_index = 0;
			bool w_flag = true;
			while (spcnt + i < n&&w_index<5&&w_flag)
			{
				wordcnts[w_index] -= w[i + spcnt].size();
				spcnt++;
				if (wordcnts[w_index] < 0) { w_flag = false; continue; }
				else if (wordcnts[w_index] == 0) w_index++;
			}
			if (!w_flag) continue;
			ans.pb(i + 1);
			break;
		}
		cin >> n;
	}
	ShowAll(ans);
    return 0;
}

Measured memory_bytes: 3172
# 2020/06/03
# AtCoder Beginner Contest 084 - B

# Input
a, b = map(int,input().split())
s = input()

# Calc
is_a_dec = str.isdecimal(s[0:a])
is_b_dec = str.isdecimal(s[a+1:len(s)])
is_hy = (s[a] == '-')

if is_a_dec and is_b_dec and is_hy:
    ans = 'Yes'
else:
    ans = 'No'

# Output
print(ans)


Measured memory_bytes: 3060
import collections
from itertools import groupby

S = input()
K = int(input())

all_s_list = []
for i in range(len(S)):
  all_s_list.append(S[i])

diff_element_count = 0
sum = 0
another_sum = 0
element_list = []
for key, value in groupby(all_s_list):
  sum += len(list(value))//2
for key, value in groupby(all_s_list):
  element_list.append(list(value))
  diff_element_count += 1
#print(element_list)
if len(element_list) >= 2:
  for i in range(len(element_list)):
    if i >= 1 and i != len(element_list)-1:
      another_sum += len(element_list[i])//2
      #print("aa", another_sum)
    if i == len(element_list)-1:
      another_sum += (len(element_list[0])+len(element_list[i]))//2


if all_s_list[0] != all_s_list[len(S)-1]:    
  sum = sum*K
else:
  if diff_element_count == 1:
    sum = 0
    sum += len(S)*K//2
  else:
    if K >= 2:
      sum += another_sum*(K-1)
print(sum)

Measured memory_bytes: 3444
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int a,b,c,d,e,f,k,l,m,n,x,y,z;
	int ans;
	String[] S;

	Main(){
		// 整数の入力
		n = sc.nextInt();

		f = sc.nextInt();
        ans += f;
		for(int i=1;i<n-1;i++){
			int r = sc.nextInt();
			ans += Math.min(f,r);
			f = r;
		}
		ans += f;

		// 出力
		System.out.println(ans);
	}

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

Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
   /* long long L,R;
    cin >>L>>R;
    if(R-L>=2019) cout <<"0\n";
    else{
        long long ans = 5000000,tmp;
        for(int i=L;i<R;i++){
            for(int j=i+1;j<=R; j++){
                tmp = (i%2019 * j%2019) %2019;
                ans = min(ans,tmp);
            }
        }
        cout <<ans<<"\n";
    }*/
   int n,tmp;
   vector<int>v,v2;
   cin >>n;
   while(n--) {
       cin >>tmp;
       v.push_back(tmp);
       v2.push_back(tmp);

   }
   sort(v.begin(),v.end());
   int fr=v[v.size()-1],sec = v[v.size()-2];
   for(int i=0;i<v2.size();i++){
       if(v2[i]==fr) cout <<sec<<"\n";
       else cout << fr<<"\n";
   }
    return 0;
}


Measured memory_bytes: 3436
#include <stdio.h>

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

    int x,i;
    i = 0;
    while(1){

        scanf("%d",&x);
        if(x == 0){
            break;
        }
        i++;
        printf("Case %d: %d\n",i,x);
    }
    return 0;
}



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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


int main() {
    int n; cin >> n;
    if(30 <= n) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  int get_money=(n/15)*200;
  P(n*800 - get_money);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a1(n),a2(n),a3(n);
  vi v1(105,0),v2(105,0),v3(105,0);
  rep(i,n){
    cin>>a1[i]>>a2[i]>>a3[i];
    v1[a1[i]]++;
    v2[a2[i]]++;
    v3[a3[i]]++;
  }
  rep(i,n){
    int ans=0;
    if(v1[a1[i]]==1)ans+=a1[i];
    if(v2[a2[i]]==1)ans+=a2[i];
    if(v3[a3[i]]==1)ans+=a3[i];
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3076
#include <iostream>

#define MOD (1000000007UL)

using namespace std;
int main(){
  long n;
  cin >> n;
  long power = 1;
  for(long i = 1; i < n+1; i++){
    power *= i;
    if(power > MOD) {
      power = power%MOD;
    }
  }

  cout << power << endl;
  return 0;
}



Measured memory_bytes: 3636