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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll n;

int ans = 0;

/////////////////////////////////////////////////////////////
ll mypow_core(ll x, int n, ll result) {
  if (n == 0) {
    return result;
  }

  if (n % 2 == 0) {
    return mypow_core(x * x, n / 2, result);
  }
  else {
    return mypow_core(x, n - 1, x * result);
  }
}

ll mypow(ll x, int n) {
  return mypow_core(x, n, 1);
}
/////////////////////////////////////////////////////////////

void rec(int digit_num, int cnt, ll acc, bool three, bool five, bool seven) {
  if (three && five && seven) {
    if (1 <= acc && acc <= n) ans += 1;
  }
  
  if (cnt == digit_num) {
    return;
  }
  else {
    rec(digit_num, cnt + 1, acc + 3 * mypow(10, cnt), true, five, seven);
    rec(digit_num, cnt + 1, acc + 5 * mypow(10, cnt), three, true, seven);
    rec(digit_num, cnt + 1, acc + 7 * mypow(10, cnt), three, five, true);
  }
}

int main(void) {
  // Here your code !
  scanf("%lld", &n);

  rec(log10(n) + 2, 0, 0, false, false, false);

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

  return 0;
}


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

using namespace std;

int main(){
  int a, b;
  scanf("%d %d", &a, &b);
  puts((a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) ? "Possible": "Impossible");
  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	S := sc.Next()
	K := sc.NextInt()

	now := 0
	for i := 0; i < len(S); i++ {
		r := int(S[i] - '0')
		if r == 1 {
			now++
			if now == K {
				fmt.Println(1)
				return
			}
		} else {
			fmt.Println(r)
			return
		}
	}

}

//aのb乗をします O(log b)
func pow(a int, b int) int {
	total := 1
	tmp := a
	for b > 0 {
		if b%2 == 1 {
			total *= tmp
		}
		b /= 2
		tmp *= tmp
	}
	return total
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
n,m = map(int, input().split())
if n == 1 and m == 1:
  print(1)
elif (n == 1 and m == 2) or (n == 2 and m == 1):
    print(0)
elif n == 1 or m == 1:
  print(max(n-2, m-2))
else:
  print(m*n - 2*m - 2*n + 4)


Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

int N, K;
typedef pair<int, int> pii;
vector<pii> V;

int main() {
	string str;
	cin >> N >> K >> str;
	V.push_back(pii(str[0] - '0', 1));
	for (int n = 1; n < N; n++) {
		if (str[n] != str[n - 1])V.push_back(pii(str[n] - '0', 1));
		else V.back().second++;
	}
	if (V.back().first == 0)V.push_back(pii(1, 0));
	int counter = 0;
	int ans = 0;
	int start = 0, last = -1, k = 0;
	for (int n = 0; n < V.size(); n++) {
		if (V[n].first == 0 && k == K)break;
		counter += V[n].second;
		last++;
		if (V[n].first == 0)k++;
	}
	ans = counter;
	while (last < V.size()-1) {
		//次の1まで伸ばす
		counter += V[last+1].second + V[last+2].second;
		last += 2;
		if (V[start].first == 1) {
			counter -= V[start++].second;
			counter -= V[start++].second;
		}
		else counter -= V[start++].second;
		ans = max(ans, counter);
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int n,d,x;
    cin >> n >> d >> x;
    vector<int> a(n);

    int i,j;
    int ans = x;
    for (i = 0; i < n; i++)
    {
        cin >> a[i];
        ans += (d + a[i] - 1) / a[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main()
{
    int n,m;
    int a,b;
    cin>>n>>m;
    int i;
    if(n%2){
             a=1,b=n;
    for(i=0;i<m;i++)
        printf("%d %d\n",a++,b--);
        }
    else{
         a=1;b=n/2;
        while(a<b&&m--)
           printf("%d %d\n",a++,b--);
        a=n/2+2;b=n;
        while(m--&&m>=0)
            printf("%d %d\n",a++,b--);

    }
    return 0;
}


Measured memory_bytes: 3680
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int n = sc.nextInt(), m = sc.nextInt(), x = sc.nextInt();
        int[][] as = new int[n][m];
        int[] cs = new int[n];

        for (int i = 0; i < n; i++) {
            cs[i] = sc.nextInt();
            for (int j = 0; j < m; j++) {
                as[i][j] = sc.nextInt();
            }
        }

        int ans = 1 << 28;
        for (int i = 0; i < 1 << n; i++) {
            int[] sums = new int[m];
            int cost = 0;
            for (int j = 0; j < n; j++) {
                if (((i >> j) & 1) == 0) continue;
                cost += cs[j];
                for (int k = 0; k < m; k++) {
                    sums[k] += as[j][k];
                }
            }
            boolean ok = true;
            for (int j = 0; j < m; j++) {
                ok &= sums[j] >= x;
            }
            if (ok) ans = Math.min(ans, cost);
        }

        out.println(ans == 1 << 28 ? -1 : ans);

        out.flush();
    }

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

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

Measured memory_bytes: 37704
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#define Debug 0
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int h[21];

int main(){
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    int ma = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (ma <= h[i]) ans++;
        ma = max(h[i], ma);
    }
    cout << ans << endl;
}




Measured memory_bytes: 888
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels

let dbg x = Printf.eprintf "[debug]%s\n" @@ dump x

let id = identity

let (++) n m = List.range n `To m
let (++^) n m = List.range n `To (pred m)

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then Enum.empty ()
  else
    List.map (fun _ -> scan fmt f) (List.range 1 `To n)
    |> List.enum

let scan_list cnv =
  String.split_on_char ' ' @@ read_line ()
  |> List.map cnv

let scan_array cnv = Array.of_list @@ scan_list cnv

let scan_matrix n m e conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (List.range 0 `To (pred n))
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let n = scan "%d" id
let p = scan_list Int.of_string
let q = scan_list Int.of_string

let () =
  let perms = permutations (1 -- n) in
  let ps = List.of_enum @@ EnumL.map ~f:List.of_enum perms in
  (Option.get @@ List.index_of p ps) - (Option.get @@ List.index_of q ps)
  |> Int.abs
  |> Printf.printf "%d\n"


Measured memory_bytes: 27264
#include<iostream>
#include<string>
using namespace std;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  string s;
  while(1){
    b=0;
    cin >>s;
    if(s=="0"){
      break;
    }
    for(int n=0;n<s.size();n++){
      if(s[n]=='1'){
	b+=1;
      }
      if(s[n]=='2'){
	b+=2;
      }
      if(s[n]=='3'){
	b+=3;
      }
      if(s[n]=='4'){
	b+=4;
      }
      if(s[n]=='5'){
	b+=5;
      }
      if(s[n]=='6'){
	b+=6;
      }
      if(s[n]=='7'){
	b+=7;
      }
      if(s[n]=='8'){
	b+=8;
      }
      if(s[n]=='9'){
	b+=9;
      }
    }
    cout <<b<<'\n';
  }
  return(0);
}



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

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> cost(n);
    cost[0] = 0;
    cost[1] = abs(a[1] - a[0]);
    int c1, c2;
    for (int i = 2; i < n; ++i) {
        c1 = abs(a[i] - a[i - 1]) + cost[i - 1];
        c2 = abs(a[i] - a[i - 2]) + cost[i - 2];
        cost[i] = min(c1, c2);
    }
    cout << cost[n - 1];
    return 0;
}

Measured memory_bytes: 1024
import fractions
n, m = map(int, input().split())
s = input()
t = input()
sr = fractions.gcd(n, m)
sg, tg = n // sr, m // sr
for i in range(sr):
    if s[i * sg] != t[i * tg]:
        print(-1)
        exit()
print(sg * m)


Measured memory_bytes: 5436
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
typedef long long  ll;

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

Measured memory_bytes: 384
#include <iostream>
using namespace std;
void ABC70(void);
void ABC71(void);
void ABC72(void);
void ABC73(void);
void ABC75(void);
void ABC77(void);
void ABC78(void);
void ABC79(void);

int main(void){
    ABC73();
}

void ABC73(void){
    int n;
    cin>>n;
    if(n/10==9||n%10==9)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main() {
	double A1, A2, A3, B1, B2, B3, C1=1, C2=1, C3=1, E1, E2, E3, x, y, z, n;
	vector<double> X, Y, Z;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A1 >> B1 >> A2 >> B2 >> A3 >> B3;
		E1 = -A1*A1 - B1*B1;
		E2 = -A2*A2 - B2*B2;
		E3 = -A3*A3 - B3*B3;
		x = (E1*B2*C3 + E2*B3*C1 + E3*B1*C2 - E1*B3*C2 - E2*B1*C3 - E3*B2*C1) / (A1*B2*C3 + A2*B3*C1 + A3*B1*C2 - A1*B3*C2 - A2*B1*C3 - A3*B2*C1);
		y = (A1*E2*C3 + A2*E3*C1 + A3*E1*C2 - A1*E3*C2 - A2*E1*C3 - A3*E2*C1) / (A1*B2*C3 + A2*B3*C1 + A3*B1*C2 - A1*B3*C2 - A2*B1*C3 - A3*B2*C1);
		z = (A1*B2*E3 + A2*B3*E1 + A3*B1*E2 - A1*B3*E2 - A2*B1*E3 - A3*B2*E1) / (A1*B2*C3 + A2*B3*C1 + A3*B1*C2 - A1*B3*C2 - A2*B1*C3 - A3*B2*C1);
		double xr, yr, r;
		xr = -x / 2; yr = -y / 2; r = sqrt((x*x + y*y) / 4 - z);
		xr *= 1000; yr *= 1000; r *= 1000;
		if (xr >= 0)xr += 0.5;
		else xr -= 0.5;
		xr = int(xr);
		xr /= 1000;
		if (yr >= 0)yr += 0.5;
		else yr -= 0.5;
		yr = int(yr);
		yr /= 1000;
		r += 0.5;
		r = int(r);
		r /= 1000;
		X.push_back(xr);
		Y.push_back(yr);
		Z.push_back(r);
	}
	for (int i = 0; i < n; i++) {
		cout << fixed << setprecision(3) << X[i] << " " << Y[i] << " " << Z[i] << endl;
	}
	return 0;
}

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


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

  return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }

int main() {
  unsigned long long k, a, b;
  cin >> k >> a >> b;

  unsigned long long bis = 1;
  unsigned long long yen = 0;

  auto is_upper_ratio = ((a+1) < b);
  if (!is_upper_ratio) {
    cout << k+1 << endl;
    return 0;
  }

  each(i, k) {

    if (yen == 1) {
      bis += b;
      yen = 0;
      continue;

    } else if ((bis >= a) && (k-i-1)) {
      yen++;
      bis -= a;
      continue;

    } else {
      bis++;
      continue;
    }
  }

  cout << bis << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String args[]) throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        while(true){
            String data[] = reader.readLine().split(" ");
            int a= Integer.parseInt(data[0]);
            int b= Integer.parseInt(data[1]);
             
            if(a==0 && b==0)
                break;
             
            for(int y=0; y<a; y++){
                for(int x=0; x<b; x++){
                    builder.append("#");
                }
                builder.append("\n");
            }
            builder.append("\n");
         
        }
        System.out.print(builder);
    }
}

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

using namespace std;

 int main()
{
    string a,b;
    int l,i,d=1;
    cin>>a>>b;
    l=a.length();
    for(i=0;i<l;i++)
    {
        if(a[i]==b[i])
        {
            d=1;
        }
        else
        {
            d=0;
            break;
        }
    }
    if(d==1)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3540
/*
  AtCoder Beginner Contest 080
  B - Harshad Number

  方針
    各桁の数字の和をどのように計算すればよいか。
    1の位を確認した後、10で割る操作を繰り返す。

  実装
    最後にX % f(X)を計算するため、Xのバッファを用意して、
    そのバッファに対して上述の操作を行う。
*/

#include<iostream>
using namespace std;

int X;

int main() {
  scanf("%d", &X);

  int sum_digits = 0;
  int bufX = X;
  while (bufX != 0) {
    sum_digits += bufX % 10;
    bufX /= 10;
  }

  if (X % sum_digits == 0) printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

int main(int argc, char const *argv[]) {
  string s1,s2,s3,s4;
  cin>>s1>>s2>>s3;
  s4+=s1[0];
  s4+=s2[0];
  s4+=s3[0];
  transform(s4.begin(),s4.end(),s4.begin(),::toupper);
  cout<<s4<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <stdio.h>
#include <string>


using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
int main()
{
    vector<int> intArray(3);

    for (int i = 0; i < 3; i++)
    {
        cin >> intArray[i];
    }

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

    vector<string> strArray(3);

    for (int i = 0; i < 3; i++)
    {
        strArray[i] = std::to_string(intArray[i]);
    }

    string str2 = strArray[2] + strArray[1];
    int num1 = atoi(str2.c_str());

    int num2 = atoi(strArray[0].c_str());
        
    cout << num1+num2<< endl;

    return 0;


}



Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define int long long
const int maxn=1000001,mo=1e9+7;
using namespace std;
int ksm(int x,int k)
{
    int res=1;
    while(k)
    {
        if(k&1)res=res*x%mo;
        x=x*x%mo;
        k>>=1;
    }
    return res;
}
int mn[maxn],c[maxn],w[maxn],cnt[maxn],jc[maxn],inv[maxn],n,A,B,ans;
signed main()
{
	cin>>n>>A>>B;
    memset(mn,0x3f,sizeof(mn));
    jc[0]=1;
    for(int i=1;i<=n;i++)jc[i]=jc[i-1]*i%mo;
    inv[n]=ksm(jc[n],mo-2);
    for(int i=n-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mo;
	for (int i=1;i<=n;++i)
    {
		cin>>c[i]>>w[i];
		mn[c[i]]=min(mn[c[i]],w[i]);
		++cnt[c[i]];
	}
	int Mn=1,mnn=1e9;
	for (int i=1;i<=n;++i)
		if (mn[i]<mn[Mn])Mn=i;
	for (int i=1;i<=n;++i)
		if (i!=Mn)mnn=min(mn[i],mnn); 
	for (int i=1;i<=n;++i)
    {
		if (w[i]!=mn[c[i]]&&w[i]+mn[c[i]]<=A)continue; 
		if (c[i]!=Mn&&w[i]+mn[Mn]<=B)continue;
		if (c[i]==Mn&&w[i]+mnn<=B)continue;
		--cnt[c[i]];
	}
	int num=cnt[Mn];
	for (int i=1;i<=n;++i)
		if (i!=Mn&&mn[Mn]+mn[i]<=B)
			num+=cnt[i];
	ans=1;
	for (int i=1;i<=n;++i)
        if(mn[i]!=1e9&&(i==Mn||mn[i]+mn[Mn]<=B))
            ans=ans*inv[cnt[i]]%mo;
	for (int i=1;i<=num;++i)
		ans=ans*i%mo;
	printf("%lld",ans);
}

Measured memory_bytes: 19404
#include <cstdio>
#include <cmath>
#include <string>
#include <iostream>

using namespace std;

int main(void){
	string s;
	cin >> s;
	int scnt=0,cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='S')scnt++;
		if(s[i]=='T'){
			if(scnt>0){
				scnt--;
				cnt++;
			}
		}
	}
	printf("%d\n",(int)s.size()-cnt*2);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#define Q 100005
using namespace std;
typedef long long ll;
int n,q,u,t[Q],p[Q];
bool marked[Q];
char c[Q];
ll ans;

int find(int x){
  if(marked[x]) return x;
  return p[x]=find(p[x]);
}

int main(){
  while(1){
    cin>>n>>q;
    if(!n&&!q) break;
    for(int i=1;i<=n;i++) marked[i]=false;
    for(int i=2;i<=n;i++) cin>>u,p[i]=u;
    marked[1]=true;
    for(int i=0;i<q;i++){
      cin>>c[i]>>t[i];
      if(c[i]=='M'){
	if(marked[t[i]]) c[i]='E';
	marked[t[i]]=true;
      }
    }
    ans=0;
    for(int i=q-1;i>=0;i--){
      if(c[i]=='E') continue;
      if(c[i]=='M'&&t[i]!=1) marked[t[i]]=false;
      else ans+=find(t[i]);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2284
n,m=map(int,input().split())
l=[list(map(int,input().split()))[1:] for i in range(m)]
p=list(map(int,input().split()))
form = "0" + str(n) + "b"
ans=0
for i in range(2**n):
	ptr = format(i,form)
	flg = True
	for j in range(m):
		s= sum(int(ptr[k-1]) for k in l[j])
		if s%2 != p[j]:
			flg = False
	if flg == True:
		ans+=1
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main()
{
  int k;
  char str[256];
  scanf("%d", &k);
  scanf("%s", str);
  if(k >=  strlen(str)){
    printf("%s\n", str);
  }else{
    printf("%.*s", k , str);
    printf("...\n");
  }

  // printf("Hello World!\n");
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;

int main() {
    int color[3];
    rep(i, 3) {
        cin >> color[i];
        
    }
    int count = 3;
    if (color[0] == color[1] && 
        color[1] == color[2]) {
        count -= 2;
    }

    else if (color[0] == color[1] || 
             color[1] == color[2] || 
             color[2] == color[0]) {
        count -= 1;
    }

    cout << count << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
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; }

int main()
{
	int n, k; cin >> n >> k;
	int r, s, p; cin >> r >> s >> p;
	string t; cin >> t;
	int ans = 0;
	vector<bool> R(k, false), S(k, false), P(k, false);
	rep(i, n)
	{
		int d = 0;
		if (i < k)
		{
			if (t[i] == 'r')d = p;
			if (t[i] == 's')d = r;
			if (t[i] == 'p')d = s;
		}
		else
		{
			int j = i % k;
			if (t[i] == 'r')
			{
				if (t[i - k] != 'r')
				{
					d = p;
					R[j] = false;
				}
				else if (R[j])
				{
					d = p;
					R[j] = false;
				}
				else R[j] = true;
			}
			if (t[i] == 's')
			{
				if (t[i - k] != 's')
				{
					d = r;
					S[j] = false;
				}
				else if (S[j])
				{
					d = r;
					S[j] = false;
				}
				else S[j] = true;
			}
			if (t[i] == 'p')
			{
				if (t[i - k] != 'p')
				{
					d = s;
					P[j] = false;
				}
				else if (P[j])
				{
					d = s;
					P[j] = false;
				}
				else P[j] = true;
			}
		}
		ans += d;
	}
	co(ans);
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    long long n,sum=0,T,max,min;
    scanf("%lld",&T);
    for(int i=0; i<T; i++)
    {
        scanf("%lld ",&n);
        if(i==0)
            max=min=n;
        if(max<n)
            max=n;
        else if(min>n)
            min=n;
        sum=sum+n;
    }
    printf("%d %d %lld\n",min,max,sum);
    return 0;
}



Measured memory_bytes: 2148
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

map<int, int>memo;
vector<pair<int, int>>rels;
int getans(bitset<16>&used) {
	if (memo.find(used.to_ulong()) == memo.end()) {
		if (used.count() == 16)return 1;
		else {
			int sum = 0;
			bool flag = false;
			for (int y = 0; y < 4; ++y) {
				for (int x = 0; x < 4; ++x) {
					if (!flag&&!used[y*4+x]) {
						flag = true;
						for (int k = 0; k < 4; ++k) {
							const int nexty = y + rels[k].second;
							const int nextx = x + rels[k].first;
							if (nextx >= 0 && nextx <= 3 && nexty>= 0 && nexty <= 3) {
								const int ne = nexty * 4 + nextx;
								if (!used[ne]) {
									used[ne] = true;
									used[y * 4 + x] = true;
									sum += getans(used);
									used[ne] = false;
									used[y * 4 + x] = false;
								}
							}
						}
					}
				}
			}
			memo[used.to_ulong()] = sum;
		}
	}
	return memo[used.to_ulong()];
	
}

int main() {
	while (1) {
		memo.clear();
		int a; cin >> a;
		if (a > 4)break;
		int b; cin >> b;
		rels.clear();
		rels.emplace_back(a, b);
		for (int i = 0; i < 3; ++i) {
			int c, d; cin >> c >> d;
			rels.push_back(make_pair(c, d));
		}
		for (auto&rel : rels) {
			if (rel.second < 0||(rel.first<0&&rel.second==0)) {
				rel.first = -rel.first;
				rel.second = -rel.second;
			}
		}
		bitset<16>bs;
		int ans = getans(bs);
		cout << ans << endl;
	}
	return 0;
}

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

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

  int s;
  const int MOD = 1e9 + 7;
  cin >> s;

  vector<int> dp(s + 1, 0);

  dp[0] = 1;
  for (int i = 3; i <= s; i++)
    for (int j = 3; j <= i; j++)
      dp[i] = (dp[i] + dp[i - j]) % MOD;

  cout << dp[s] << endl;

  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
//define
#define int long long
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define elif else if
//vectordefine
#define vint vector<int>
#define vc vector<char>
#define vstr vector<string>
#define pb(n) push_back(n)
//queuedefine
#define qint queue<int>
#define qc queue<char>
#define qstr queue<str>
//mapdefine
#define mint map<int>
#define mc map<char>
//pairdefine
#define pint pair<int,int>
#define pis pair<int,str>
#define pic pair<int,char>
#define pci pair<char,int>
#define mod 100000007
//main
signed main(){
  int N,M,O,P,count=0,count2=0,count3=0,stack=0;
  str S,T;
  cin>>N;
  if(N<112)cout<<111<<endl;
  elif(N<223)cout<<222<<endl;
  elif(N<334)cout<<333<<endl;
  elif(N<445)cout<<444<<endl;
  elif(N<556)cout<<555<<endl;
  elif(N<667)cout<<666<<endl;
  elif(N<778)cout<<777<<endl;
  elif(N<889)cout<<888<<endl;
  else cout<<999<<endl;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

n=I()
a=LI()
a=sorted(a)[::-1]
p=a.pop()
while a:
    p=(a.pop()+p)/2
print(p)

Measured memory_bytes: 38512
# import numpy as np

# import sys
# sys.setrecursionlimit(200000)

from collections import Counter


a1, b1 = list(map(int, input().split(" ")))
a2, b2 = list(map(int, input().split(" ")))
a3, b3 = list(map(int, input().split(" ")))

c = Counter([a1, b1, a2, b2, a3, b3])

if c.most_common(1)[0][1] == 2:
    print("YES")
else:
    print("NO")

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << ": " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<"| ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int n , k;

int32_t main(){
    boost;

    //code
    cin >> n >> k;
    int x = ((n-1)*(n-2))/2;

    if( k > x){
    	cout << -1;
    	return 0;
    }

    int diff = (n*(n-1)) / 2 - k;

    vector<pair<int,int>> ans;

    for(int i = 1 ; i < n ; ++i){
    	ans.emplace_back(1,i+1);
    	diff -= 1;
    }


    for(int i = 2 ; i <= n and diff ; ++i){
    	for(int j = i + 1 ; j <= n and diff ; ++j){
    		ans.emplace_back(i,j);
    		diff -= 1;
    	}
    }
    cout << ans.size() << "\n";
    for(auto i : ans)
    	cout << i.first << " " << i.second << "\n";
    return 0;
}

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

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

  vector<pair<int, int>> student(n);
  vector<pair<int, int>> check(m);

  for(int i=0;i<n;i++) {
    cin >> student[i].first;
    cin >> student[i].second;
  }

  for(int i=0;i<m;i++) {
    cin >> check[i].first;
    cin >> check[i].second;
  }

  vector<int> ans(n);

  for(int i=0;i<n;i++) {
    int min = 1e9;
    int checkPoint = 0;
    for(int j=0;j<m;j++) {
      int dis = abs(student[i].first-check[j].first)+abs(student[i].second-check[j].second);
      if(dis < min) {
        min = dis;
        checkPoint = j + 1;
      }
    }

    ans[i] = checkPoint;
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back

const ll mod = 1000000007;

int main() {
	char ch;
	cin >> ch;
	for (int i = 1; i < 4; i++) {
		char next;
		cin >> next;
		if (ch == next) {
			cout << "Bad" << endl;
			return 0;
		}
		ch = next;
	}
	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N, M; cin >> N >> M;
    int a[N];
    vector<vector<int>> G(N);
    int v1,v2;
    for (int i = 0; i < M; i++) {
        cin >> v1 >> v2; v1--; v2--;
        G[v1].push_back(v2);
        G[v2].push_back(v1);
    }

    for (int i = 0; i < N; i++) {
        a[i] = i;
    }

    int cnt = 0; bool check;
    do{
        for (int i = 0; i < N-1; i++) {
            check = false;
            for ( int v : G[a[i]] ){
                if(v == a[i+1]){
                    check = true;
                }
            }
            if(!check){
                break;
            }
        }
        if(check){
            cnt++;
        }


    } while(next_permutation(a + 1, a + N));

    printf("%d\n", cnt);
}


Measured memory_bytes: 384
/**
     *      ABC 64 A
     *      author  : kyomukyomupurin
     *      created : 2018-09-04 23:44:14
    **/
     
    #include <bits/stdc++.h>
    using namespace std;
     
    int main(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        
        int r, g, b; cin >> r >> g >> b;
        (g * 10 + b) % 4 == 0 ? cout << "YES" : cout << "NO";
     
        return 0;
    }

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var mm = int.Parse(line[0]);
            if (mm == 0) break;
            var dd = int.Parse(line[1]);
            var a2004 = new DateTime(2004, mm, dd, 0, 0, 0).DayOfWeek;
            Console.WriteLine(a2004);
        }
    }
}

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

int main()
{
    int n;
    string S[55];
    cin >> n;
    REP(i, n) cin >> S[i];

    int li_let[26];
    fill(&li_let[0], &li_let[26], 100);
    int count_let;
    char tar;
    REP(i, n)       //i文字目を判定
    {
        REP(j, 26)  //アルファベットj文字目
        {
            if (li_let[j] == -1) continue;
            tar = 'a' + j;
            count_let = count_if(S[i].begin(), S[i].end(), [tar](char let) { return let == tar; });
            0 < count_let ? li_let[j] = min(count_let, li_let[j]) : li_let[j] = -1;
        }
    }

    REP(i, 26) if(0 < li_let) REP(j, li_let[i]) cout << char('a' + i);
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()

int main() {
  ll n, ans = 0;
  cin >> n;
  for (ll i = 1; i <= n; i++) {
    if (i % 5 != 0 && i % 3 != 0) {
      ans += i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll n;
    cin>>n;
    unordered_map<ll, ll> mapp;
    ll summ = 0;
    for(ll i=0; i<n; i++){
        ll x;
        cin>>x;
        mapp[x]++;
        summ+=x;
    }
    ll q;
    cin>>q;
    while(q--){
        ll b, c;
        cin>>b>>c;
        ll prevContri = mapp[b]*b;
        ll newContri = mapp[b]*c;
        mapp[c]+= mapp[b];
        mapp.erase(b);
        summ+=newContri;
        summ-=prevContri;
        cout<<summ<<endl;
    }
    return 0;
}




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

int main() {
  int N;
  cin >> N;
  
  vector<int64_t> ans(N+1);
  ans.at(0) = 2;
  ans.at(1) = 1;
  if(N >=2){
    for(int i = 2; i<= N; i++){
      ans.at(i) = ans.at(i-1) + ans.at(i-2);
    }
  }
 
  cout << ans.at(N) << endl;
 
  return 0;
}

Measured memory_bytes: 256
def main():
    S = input()
    N = len(S)
    if all("9" == s for s in S):
        print(N*9)
    elif N == 1:
        print(S)
    elif all("9" == s for s in S[1:]):
        print(int(S[0]) + 9*(N-1))
    elif S[0] == "1":
        print(9*(N-1))
    else:
        print((int(S[0])-1) + 9*(N-1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int n;
double p[3010],dp[3010][3010];
int main(int argc,char** argv){
	cin>>n;
	forn(i,n){
		cin>>p[i];
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			if(i==j){
				dp[i][j]=dp[i-1][j-1]*p[i];
			}
			else if(j==0){
				dp[i][j]=dp[i-1][j]*(1-p[i]);
			}
			else{
				dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
			}
		}
	}
	double sum=0;
	/*
	for(int i=0;i<=n;i++){
		for(int j=0;j<=i;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}
	*/
	for(int i=n/2+1;i<=n;i++){
		sum+=dp[n][i];
	}
	printf("%.10lf",sum);
	return 0;
}

Measured memory_bytes: 69120
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
B=[]
C=[]

for _ in range(Q):
    bi, ci = list(map(int, input().split()))
    B.append(bi)
    C.append(ci)

dic = {}
for i in A:
    dic[i] = dic.get(i,0) + 1

sum = sum(A)

for i in range(Q):
    sum += dic.get(B[i], 0) * (C[i] -B[i])
    dic[C[i]] = dic.get(C[i], 0) + dic.get(B[i], 0)
    dic[B[i]] = dic.get(B[i], 0)
    dic[B[i]] = 0
    print(sum)

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

int main() {
  long long X, waru500, waru5;
  cin >> X;
  waru500 = X / 500;
  if( X >= 500){
    X -= waru500 * 500;
  }  
  waru5 = X / 5;
  cout << waru500 *1000 + waru5 * 5 << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;

public class Main {
  private static void solve() {
    int n = ni();
    int[] a = na(n);
    
    Arrays.sort(a);
    
    int x = a[a.length - 1];
    int r1 = x / 2;
    int r2 = (x + 1) / 2;
//5C2=5C3

    int min = Integer.MAX_VALUE;
    int minV = 0;
    for (int v : a) {
      int d = Math.min(Math.abs(r1 - v), Math.abs(r2 - v));
      if (min > d) {
        min = d;
        minV = v;
      }
    }

    System.out.println(x + " " + minV);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

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

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

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

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 36244
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, x;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> x;
    vector<int> v(2*n);
    if (x == 1 || x == 2*n-1) {
        cout << "No" << endl;
        return 0;
    } else {
        rep(i, 0, 2*n) v[i] = i;
        if (x < n) {
            v[n-1] = x;
            v[x] = n - 1;
            v[n] = 1;
            v[1] = n; 
        } else if (x > n) {
            v[n+1] = x;
            v[x] = n + 1;
            v[2*n-1] = n;
            v[n] = 2*n-1;
        }
    }
    cout << "Yes" << endl;
    rep(i, 1, 2*n) {
        cout << v[i] << endl;
    }
    return 0;
}

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

typedef long long ll;

int main() {
	
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
		
	ll a, b, c;
	scanf("%lld/%lld/%lld", &a, &b, &c);
	printf("2018/%02d/%02d\n", b, c);
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			998244353

ll mod_pow(ll a,ll b) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2);
}

void solve()
{
	int n;
	
	cin >> n;
	
	int a[n+1];
	
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	
	int pre[n+10] {};
	int sre[n+10] {};
	
	for(int i = 1; i <= n; ++i) {
		pre[i] = pre[i-1]^a[i];
	}
	
	for(int i = n; i >= 1; --i) {
		sre[i] = sre[i+1]^a[i];
	}
	
	for(int i = 1; i <= n; ++i) {
		cout << (pre[i-1]^sre[i+1]) << " " ;
	}
}

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 8248
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<stack>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int in;
  stack<int>out;
  while(cin>>in){
    if(in)out.push(in);
    else {
      cout<<out.top()<<endl;
      out.pop();
    }
  }


}

Measured memory_bytes: 1200
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define M 105

long long dp[M][2];
int n,p;

int main(){
	scanf("%d %d",&n,&p);
	dp[0][0]=1;
	for(int i=1,x;i<=n;i++){
		scanf("%d",&x);
		int pp=x&1;
		for(int j=0;j<2;j++)
			dp[i][j]=dp[i-1][j];
		for(int j=0;j<2;j++)
			dp[i][(j+pp)&1]+=dp[i-1][j];
	}
	cout<<dp[n][p]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int S(int n) {
    if (n < 10) {
        return n;
    } else {
        return n % 10 + S(n / 10);
    }
}

int main() {
    int N;
    std::cin >> N;

    if (N % S(N) == 0) {
        std::cout << "Yes" << std::endl;
    } else
    {
        std::cout << "No" << std::endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
  
void CountTriangles(vector <int> A){  
  
    int n=A.size(); 
  
    sort(A.begin(), A.end());  
  
    int count = 0; 
      
    for( int i = n-1; i >= 1; i--){ 
        int l = 0, r = i-1; 
        while( l < r){ 
            if( A[l] + A[r] > A[i]){ 
                count += r - l ;  
                r--;   
            } 
            else 
                l++;   
        } 
    } 
    cout <<count << endl;; 
} 
int main(){ 
    int n, a;
    cin >> n;
    vector <int> A;
    for(int i = 0; i < n; i++){
        cin >> a;
        A.push_back(a);
    }
  
    CountTriangles(A); 
    
} 

Measured memory_bytes: 256