akhauriyash/Code-Regression huggingface dataset:
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (A, B, C) = (input[0], input[1], input[2])
var ans = "NO"
for i in 1...B {
    if A*i % B == C {
        ans = "YES"
        break
    }
}
print(ans)


Measured memory_bytes: 7780
#include<iostream>

using namespace std;

int main(){
    while(1){
        int h;
        cin >> h;
        if(h==0) break;
        int pt = 0;
        int a[h+1][5];
        for(int i = 1; i <= h; i++){
				for(int j = 0; j < 5; j++){
					cin >> a[i][j];
				}
			}
			bool flg = true;
			while(flg){
				flg = false;
				for(int i = 1; i <= h; i++){
					for(int j = 0; j < 3; j++){
						int count = 1;
						for(int k = j + 1; k < 5; k++){
							if(a[i][j] > 0 && a[i][j] == a[i][k]){
								count += 1;
							}else{
								break;
							}
						}
						if(count > 2){
							flg = true;
							pt += a[i][j] * count;
							for(int k = j; k < j + count; k++){
								for(int l = i; l > 0; l--){
									a[l][k] = a[l - 1][k];
								}
							}
							break;
						}
					}
				}
				
			}
            cout << pt << endl;
    }
}


Measured memory_bytes: 3088
import math
import itertools


def main():
    N = int(input())
    xy = [list(map(int, input().split()))for _ in range(N)]
    comb = [x for x in range(N)]

    dist = 0

    for iter in itertools.permutations(comb):
        for i in range(1, N):
            dist += math.sqrt(pow(xy[iter[i-1]][0]-xy[iter[i]]
                                  [0], 2)+pow(xy[iter[i-1]][1]-xy[iter[i]][1], 2))

    dist = dist/math.factorial(N)
    print(dist)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
	int i, j;
	int x, y;
	int w, h;
	char tile[128][128];
	int tile2[128][128];
	
	while (scanf("%d %d", &h, &w), h != 0 || w != 0){
		for (i = 0; i < h; i++){
			scanf("%s", tile[i]);
			for (j = 0; j < w; j++){
				tile2[i][j] = 0;
			}
		}
		
		x = 0; y = 0;
		while (tile[x][y] != '.' && tile2[x][y] < 2){
			tile2[x][y]++;
			if (tile[x][y] == '^') x--;
			if (tile[x][y] == 'v') x++;
			if (tile[x][y] == '>') y++;
			if (tile[x][y] == '<') y--;
		}
		
		if (tile2[x][y] > 1) printf("LOOP\n");
		else printf("%d %d\n", y, x);
		
	}
	return (0);
}

Measured memory_bytes: 1112
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll a, b;
  cin>>a>>b;
  ll N;
  ll c=a/0.08;
  ll d=b/0.1;
  ll e=max(c,d);
  if(e*0.08>=a && e*0.1>=b && e*0.08<a+1 && e*0.1<b+1){
    cout<<e<<endl;
  }else if((e+1)*0.08>=a && (e+1)*0.1>=b && (e+1)*0.08<a+1 && (e+1)*0.1<b+1){
    cout<<e+1<<endl;
  }else{
    cout<<-1<<endl;
  }
}

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

int main() {
	string s, t;
	cin >> s >> t;
	int count = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) != t.at(i)) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3924
package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}

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

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	xm := make(map[rune]int)
	s1 := scanString()
	for _, r := range s1 {
		xm[r]++
	}
	for i := 0; i < n-1; i++ {
		s := scanString()
		tm := make(map[rune]int)
		for _, r := range s {
			if _, ok := xm[r]; ok && tm[r] < xm[r] {
				tm[r]++
			}
		}
		xm = tm
	}

	var wr = bufio.NewWriter(os.Stdout)
	for _, r := range "abcdefghijklmnopqrstuvwxyz" {
		if cnt, ok := xm[r]; ok {
			wr.WriteString(strings.Repeat(string(r), cnt))
		}
	}
	wr.WriteString("\n")
	wr.Flush()
}


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

int main()
{
    int a;
    cin>>a;
    int ok=0;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(i*j==a)
            {
                cout<<"Yes\n";
                ok=1;
                return 0;
            }
        }
    }
    if(!ok)
    {
        cout<<"No\n"<<endl;
    }
}


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

int main(){
  int price_a,price_b,price_c,x,y;
  cin>>price_a>>price_b>>price_c>>x>>y;
  int price_ab=2*price_c;
  int ans=pow(10,9);
  int money;
  for(int i=0;i<=max(x,y);i++){
    money=price_ab*i+price_a*max(0,x-i)+price_b*max(0,y-i);
    ans=min(ans,money);
  }
  cout<<ans<<endl;

}

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

int D;
long long G;
int p[10];
long c[10];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> D >> G;
  for(int i = 0; i < D; i++){
    cin >> p[i] >> c[i];
  }
  int ans = 1e9;
  for(int mask = 0; mask < (1 << D); mask++){
    int s = 0, num = 0, rest_max = -1;
    for(int i = 0; i < D; i++){
      if(mask >> i & 1){
        s += 100*(i+1)*p[i] + c[i];
        num += p[i];
      }
      else{
        rest_max = i;
      }
    }
    if(s < G){
      int s1 = 100*(rest_max + 1);
      int need = (G - s + s1 - 1) / s1;
      if(need >= p[rest_max]) continue;
      num += need;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n, m; cin >> n >> m;
  vector<pair<int, int>> ba;
  rep(i, m) {
    int a, b; cin >> a >> b; a--; b--;
    ba.emplace_back(b, a);
  }
  sort(ALL(ba));

  int ans = 0;
  int t = 0;   // t 番目の島の手前の橋が切れている
  for (auto& p : ba) {
    if (p.second >= t) {
      t = p.first;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1400
#!/usr/bin/env python3
import sys


def solve(N: int, B: "List[int]"):
    B.append(10000000)
    result = 0
    for i in range(N):
        j = N - i - 1
        # 左から
        result += min(B[j], B[j-1])
    print(result)


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    B = [int(next(tokens)) for _ in range(N - 1)]  # type: "List[int]"
    solve(N, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

string S;
map<string, bool> seen;

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  while (cin >> S) {
    if (S == "0") break;
    int N = S.length();
    rep(i, N) {
      if (S[i] == 'r') S[i] = 1;
      else if (S[i] == 'g') S[i] = 2;
      else S[i] = 3;
    }
    queue< pair<string, int> > q;
    seen.clear();
    seen[S] = true;
    q.push(make_pair(S, 0));

    bool done = false;
    while (q.size()) {
      string s = q.front()._1;
      int r = q.front()._2;
      q.pop();
      if (r > 20) break;

      bool ok = true;
      rep(i, N) if (s[i] != s[0]) ok = false;
      if (ok) {
        done = true;
        cout << r << "\n";
        break;
      }
      rep(i, N-1) {
        if (s[i] == s[i+1]) continue;
        string t(s);
        t[i] = t[i+1] = s[i]^s[i+1];
        if (seen[t]) continue;
        seen[t] = true;
        q.push(make_pair(t, r+1));
      }
    }
    if (!done) {
      cout << "NA\n";
    }
  }
  return 0;
}

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

const int N = (int) 1e5 + 10;
const int inf = (int) 2e9 + 10;

int main() {
//    freopen("in.txt", "r", stdin);
    long long a, b; scanf("%lld %lld", &a, &b);
    long long ans = a - 2LL * b;
    if (ans < 0) ans = 0;
    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    string s;
    cin >> s;
    rep(i, s.size()){
        if(s.at(i) == ','){
            s.at(i) = ' ';
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    int x;
    cin >> x;
    if(x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  cout << 6 - a - b <<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <climits>

using namespace std;

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

  int ans = N - i + 1;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import numpy as np

a,b,x=map(int,input().split())
S=a**2*b-x

if a**2*b/2 <= x:
    z=S*2/(a**2)
    rad=np.arctan(z/a)
else:
    z=x*2/(a*b)
    rad=np.arctan(b/z)
print(np.rad2deg(rad))


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

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define REP(i,n) FOR(i,0,n)

int N;
char S[101];
int C[100];

int main() {
  scanf("%d", &N);
  scanf("%s", S);
  REP(i,N) C[i] = 1 << (S[i] - 'a');
  
  int s1 = 0x0, s2;
  int maxval = 0;
  FOR(i,1,N) {
    s1 |= C[i-1];
    s2 = 0x0;
    FOR(j,i,N) s2 |= C[j];
    int check = s1 & s2;

    int val = 0;
    REP(j,26) val += (check >> j) & 1;
    if (val > maxval) maxval = val;
  }

  printf("%d\n", maxval);
  return 0;
}

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


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

int count=0;
for(int i=0;i<n;i++)
{
	double x;
	double y;
	cin>>x>>y;
	double s=pow((x*x)+(y*y),0.5);
	//cout<<s<<endl;
	if(s<=d)
	{
		count++;
	}
} 
cout<<count;


	return 0;
	

}

  
   


Measured memory_bytes: 4424
n = int(input())
aaa = list(map(int, input().split()))
n2 = 1 << n
dp = [[a, 0] for a in aaa]

for j in range(n):
    b = 1 << j
    for i in range(n2):
        if not i & b:
            dpi, dpk = dp[i], dp[i | b]
            if dpk[0] < dpi[0]:
                dpk[1] = max(dpk[0], dpi[1])
                dpk[0] = dpi[0]
            elif dpk[1] < dpi[0]:
                dpk[1] = dpi[0]

ans = []
tmp = 0
for a in dp[1:]:
    tmp = max(tmp, a[0] + a[1])
    ans.append(tmp)
print(*ans)


Measured memory_bytes: 129356
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int t = sc.nextInt();
        int count = (t - t % a) / a;
    
		// 出力
		System.out.println(b * count);
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int x;
    cin >> x;
    string ans = "No";
    if (x >= 30) ans = "Yes";
    cout << ans << endl;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<long long>;
using ld = long double;

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n;
vll nums;

ll GetBest(int L, int R, int ca, int cb) {
  if (R - L == 1) {
    return 0;
  }

  ll ans = 1e18;
  const int cm = ca + cb;

  for (int mid = L + 1; mid < R; ++mid) {
    ll cand =
      GetBest(L, mid, ca, cm) + GetBest(mid, R, cm, cb) + cm * nums[mid];
    debug(L, R, mid, cand);
    mini(ans, cand);
  }

  debug(L, R, ca, cb, ans);

  return ans;
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  cin >> n;
  nums.resize(n);
  for (ll &x : nums) { cin >> x; }

  cout << GetBest(0, n - 1, 1, 1) + nums[0] + nums[n - 1] << "\n";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,d,c,i;
    cin>>n>>m;
    d=m/n;
    c=m%n;
    for(i=d;i>0;i--)
    {
        if(c%i==0)
        {
            cout<<i<<endl;
            return 0;
        }
        c+=n;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF (2e9)
#define EPS (1e-7)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
  int k;
  string s;
  cin >> k;
  cin >> s;

  if (s.size() > k) {
    cout << s.substr(0, k) << "..." << endl;
  } else {
    cout << s << endl;
  }
}

Measured memory_bytes: 3632
import java.util.*;

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

        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();

            if(h==0 && w==0){
                break;
            }else{
            for(int i = 0;i<h;i++){
                for(int j = 0;j<w;j++){
                    System.out.print("#");
                }
                System.out.println();
            }
        }
            System.out.println();

        }
    }
}


Measured memory_bytes: 35580
#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using VLL = vector<long long>;
using VS = vector<string>;
using VVI = vector<vector<int>>;
using VVLL = vector<vector<long long>>;
using VVS = vector<vector<string>>;

const static string el = "\n";
int main () {
  int n; cin >> n;
  map<string, int> s {
    {"AC", 0},
    {"WA", 0},
    {"TLE", 0},
    {"RE", 0}
  };
  for (int i = 0;i < n;i++) 
  {
    string tmp;cin >> tmp;
    s[tmp]++;
  }
  
  cout << "AC x " << s["AC"] << endl;
  cout << "WA x " << s["WA"] << endl;
  cout << "TLE x " << s["TLE"] << endl;
  cout << "RE x " << s["RE"] << endl;
   
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const string DRAW = "33333";
const int N = 5;

int main(void){
    while(1){
        set<char> comb;
        string in;
        rep(i, N){
            char c; cin >> c;
            if(c == '0') return 0;
            comb.insert(c);
            in.pb(c);
        }
        string res = DRAW;

        if(comb.size() == 2){
            char w;
            COUNT(i, 3) if(comb.insert('0' + i).second) w = '1' + i % 3;
            rep(i, N) res[i] = in[i] == w ? '1':'2';
        }

        rep(i, N) cout << res.at(i) << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1188
n,k=map(int,input().split())
d={}
l=[]
num=0
for i in range(n):
    a,b=map(int,input().split())
    try:
        d[a]+=b
    except:
        d[a]=b
        l.append(a)
l.sort()

for i in range(len(l)):
    num+=d[l[i]]
    if num>=k:
        print(l[i])
        break
    


Measured memory_bytes: 10868
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    string a,b,c; cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;

    return 0;
}

Measured memory_bytes: 384
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	d := nextInt()
	c := 0
	for i := 0; i < n; i++ {
		x := nextInt()
		y := nextInt()
		if math.Sqrt(float64(x*x+y*y)) <= float64(d) {
			c++
		}
	}
	fmt.Println(c)
}

func nextInt() int {
	i, err := strconv.Atoi(nextWord())
	pnc(err)
	return i
}

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

func pnc(err error) {
	if err != nil {
		panic(err)
	}
}


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

map<int64_t, int64_t> m;

int main() {
    int64_t n = 0;
    int64_t a[200000];

    cin >> n;
    for (int64_t i = 0; i < n; i++) {
        cin >> a[i];
    }

    int64_t ans = 0;
    for (int64_t i = 0; i < n; i++) {
        ans += m[i - a[i] + 1];
        m[i + a[i] + 1]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 27732
#include <bits/stdc++.h>
#define INF 100000000
using namespace std;
using ll = long long;
using p = pair <int, int>;

int		main(void){
	int			n, k;
	cin >> n >> k;
	vector<int>	p(n);
	vector<ll> sum(n);
	ll			max;
	int			i = 0;
	while (i < n)
		cin >> p.at(i++);
	i = 0;
	while (i < n)
		p.at(i++)++;
	sum.at(0) = p.at(0);
	i = 1;
	while (i < n){
		sum.at(i) = sum.at(i-1) + p.at(i);
		i++;
	}
	max = sum.at(k - 1);
	ll			tmp;
	i = k;
	while (i < n){
		tmp = sum.at(i) - sum.at(i - k);
		if (tmp > max)
			max = tmp;
		i++;
	}
	double	ans;
	ans = max;
	ans /= 2;
	printf("%.10f\n", ans);
	return (0);
}


Measured memory_bytes: 2560
#include <stdio.h>
int main()
{
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	if(A==5 && B==5 && C==7){
		printf("YES");
	}else if(A==5 && B==7 &&C==5){
		printf("YES");
	}else if(A==7 && B==5 && C==5){
		printf("YES");
	}else{
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string S = Console.ReadLine();

            string T = Console.ReadLine();

            var Len = S.Length;
            var Count = 0;
            
            for(int inumA = 0; inumA < Len; inumA++)
            {
                var ST = S.Substring(inumA, 1);
                var TT = T.Substring(inumA, 1);

                if (ST != TT)
                {
                    Count++;
                }


            }

            Console.WriteLine(Count);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 36668
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
X = np.array(lr())
X.sort()
if N >= M:
    print(0); exit()

Xdiff = np.abs(np.diff(X))
Xdiff.sort()
need = M - N
answer = Xdiff[:need].sum()
print(answer)


Measured memory_bytes: 23076
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int i1 = Integer.parseInt(s.substring(0, 2));
        boolean isMM1 = (1 <= i1 && i1 <= 12);
        int i2 = Integer.parseInt(s.substring(2, 4));
        boolean isMM2 = (1 <= i2 && i2 <= 12);

        if (isMM1 && isMM2) {
            System.out.println("AMBIGUOUS");
        } else if (!isMM1 && !isMM2) {
            System.out.println("NA");
        } else if (isMM1) {
            System.out.println("MMYY");
        } else {
            System.out.println("YYMM");
        }
    }
}


Measured memory_bytes: 21716
a, b, k = map(int, input().split())

if a != 0 and a >= k:
    a -= k
elif a != 0 and a < k:
    k -= a
    a = 0
    if b != 0 and b >= k:
        b -= k
    elif b != 0 and b < k:
        b = 0
elif a == 0:
    if b != 0 and b >= k:
        b -= k
    elif b != 0 and b < k:
        b = 0

print(a, b)


Measured memory_bytes: 38256
def main():
    N, Y = map(int, input().split())

    if Y > 10000*N or Y < 1000*N: return -1, -1, -1

    for i in range(N, -1, -1):
        for j in range(N-i, -1, -1):
            v = 10000 * i + 5000 * j
            if Y-v >= 0:
                k = (Y - v) // 1000
                if i + j + k == N:
                    return i, j, k
    return -1, -1, -1

if __name__ == '__main__':
    output = main()
    print(" ".join(map(str, output)))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  int ans = 0;
  REP(i, n) {
    if (i % 2 == 0 && a[i] % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define mem(array,n) memset(array,n,sizeof(array));
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;

int dp[110][2][1010];
int ans=0;
int rec(string s,int k=0,bool tight=true,int sum=0){
//	cout<<k<<" "<<sum<<endl;
	if(k==s.size()){
		ans=max(ans,sum);
		return ans;
	}
	int x=s[k]-'0';
	int r=tight? x:9;
	int res=dp[k][tight][sum];
	if(res>=0)return res;
	res=0;
	for(int i=max(0,r-1);i<=r;i++){
		res=max(res,rec(s,k+1,tight&&i==r,sum+i));
	}
	return res;
}

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	string s;
	cin>>s;
	mem(dp,-1);
	
	cout<<rec(s)<<endl;
	
	
	
	
	
//////////////////////////////////////////////////////
return 0;}











Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
// __uint128_t



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

    vector<vector<ll>> DP((1<<N)+1, vector<ll>(55, INF)); DP[0][0] = 0;
    for(int i = 0; i < (1<<N) ; i++){
        bitset<20> b = i;
        ll c = b.count();


        ll p = 0; // 立っているビットが左にソートされた上で、自分がどの位置にいるか
        for(int j = N-1; j >= 0; j--){
            if(b[j] == 1) {p++; continue;}
            for(int k = 0; k <= 50; k++){
                if(DP[i][k] == INF) continue;
                bitset<20> b2 = 0; b2[j] = 1;
                ll n;
                if( abs(c-j)%2 == 0) n = A[j];
                else n = B[j];
                if(n >= k) { //照準にならないなら棄却
                    DP[(b|b2).to_ullong()][n] = min(DP[i][k] + abs(c-(j+p)), DP[(b|b2).to_ullong()][n]);
                }
            }
        }
    }
    ll ans = INF;
    for(int i = 0; i <= 50; i++) ans = min(ans, DP[(1<<N)-1][i]);
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;



}

Measured memory_bytes: 121088
//#define DEB1 //input from input.txt
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}




/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    int K,X;
    cin >> K >> X;
    if(K*500>=X){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" <<endl;
    }
    
    return;
}



// ----------------------------------------------
int main(){

#ifdef DEB1
    cout << "DEBUG MODE"  << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf()); //for debug
#endif

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

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

int main(){
	string s;
	cin >> s;
	bool even = !(s.size() % 2);
	bool same = (s[0] == s[s.size() - 1]);
	if(even ^ same) cout << "Second";
	else cout << "First";
	return 0;
}




Measured memory_bytes: 512
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n;
//SUN, MON, TUE, WED, THU, FRI, or SAT.
void solve(){
	string s;
	cin>>s;
	if(s=="SUN")cout<<7;
	else if(s=="MON")cout<<6;
	else if(s=="TUE")cout<<5;
	else if(s=="WED")cout<<4;
	else if(s=="THU")cout<<3;
	else if(s=="FRI")cout<<2;
	else cout<<1; 
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}



 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  int n,k;cin >>n>>k;
  int out =1;
  while(n>0){
    if(n>=k)++out;
    n/=k;
  }
  cout << out << endl;
  return 0;
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
A = [0] * Q
for i in range(Q):
    A[i] = int(input())

initial_point = [(K-Q)]*N

for i in range(Q):
    initial_point[(A[i]-1)] += 1

for i in range(N):
    if initial_point[i] > 0 :
        print("Yes")
    else:
        print("No")   

Measured memory_bytes: 51032
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#define ll long long

using namespace std;
ll MOD = 1000000007;


int main(void){
    string s;
    cin >> s;
    ll k;
    cin >> k;
    ll ans = 0;
    vector<ll> count;
    count.push_back(0);
    bool a = true;
    for(ll i = 0; i < s.length()-1; i++){
        if(s[i]!=s[i+1])
            a = false;
    }
    if(a == false){
        for(ll i = 1; i < s.length(); i++){
            if(s[i-1]!=s[i])
                count.push_back(i);
        }
        ll check = 0;
        for(ll i = 1; i < count.size()-1; i++){
            check += (count[i+1]-count[i])/2;
            //cout << count[i] << endl;
        }
        if(s[0]==s[s.length()-1]){
            ans = check*k+(s.length()-count[count.size()-1]+count[1])/2*(k-1);
            ans+=count[1]/2;
            ans+=(s.length()-count[count.size()-1])/2;
        }
        else{
            check+=count[1]/2+(s.length()-count[count.size()-1])/2;
            ans = check*k;
        }
        cout << ans << endl;
    }
    else{

        ans = (s.length()*k)/2;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n,a,b = map(int, input().split())
ab = a+b
S = input()
total = 0
b_total = 0
for s in S:
    if (s == "a" and total < ab):
        total += 1
        print("Yes")
    elif (s == "b" and total < ab and b_total < b):
        b_total += 1
        total += 1
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 9296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

ll mod = 998244353;

ll POW(ll A, ll B) {
	if (B == 0) return 1;
	if (B % 2 == 0) {
		ll hannbunn = POW(A, B / 2);
		return hannbunn * hannbunn % mod;
	}
	else {
		return A * POW(A, B - 1) % mod;
	}
}

//ll COMB(ll A, ll B) {
//	if (B > A - B) return COMB(A, A - B);
//	ll kakeru = 1;
//	ll waru = 1;
//	rep(i, B) {
//		kakeru = (kakeru * (A - i)) % mod;
//		waru = (waru * (i + 1)) % mod;
//	}
//	return kakeru * POW(waru, mod - 2) % mod;
//}

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


	ll N, A, B, K;
	cin >> N >> A >> B >> K;

	vector<pair<ll, ll>> kumiawase;

	rep(i, N + 1) {
		ll kari = K - A * i;
		if (kari % B == 0 && kari >= 0 && kari / B <= N) {
			kumiawase.push_back(make_pair(i, (K - A * i) / B));
		}
	}

	ll kotae = 0;

	ll COMB[300000];
	COMB[0] = 1;
	rep1(i, N) {
		COMB[i] = COMB[i - 1] * (N + 1 - i) % mod;
		COMB[i] = COMB[i] * POW(i, mod - 2) % mod;
	}

	for (auto itr : kumiawase) {
		kotae += COMB[itr.first] * COMB[itr.second] % mod;
		kotae %= mod;
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 6252
N, M = gets.split.map(&:to_i)
S = gets.chomp
ANS = []

N.times.inject(N) do |pos,c|
  break if pos == 0
  k_ = (1 .. M).reverse_each.find do |k|
    pos - k >= 0 && S[pos - k] == '0'
  end
  if k_.nil?
    puts -1
    exit
  end
  ANS << k_
  pos - k_
end
puts ANS.reverse * ' '



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

template<class T> inline bool chmin(T &a, T b) {
    if (a > b) {a = b; return true;}
    return false;
}

signed main(){
    int n; cin >> n;
    
    vector<vector<int>> dp(n+1,vector<int>(12,INT_MAX));
    
    vector<int> op;
    int six = 1, nine = 1;
    rep(i,6){
        six *= 6; op.emplace_back(six);
        op.emplace_back(nine); nine *= 9;
    }
    sort(ALL(op));
    
    dp[0] = vector<int>(12,0);
    reps(i,1,n){
        rep(j,12){
            if(i-op[j] >= 0) chmin(dp[i][j], dp[i-op[j]][j] + 1);
            if(j != 0) chmin(dp[i][j], dp[i][j-1]);
        }
    }
    
    cout << dp[n][11] << endl;
}

Measured memory_bytes: 13568
import scala.io.StdIn.readInt

object Main {
  val r = Array(2,3,5,7)

  def pow(x:Long, y:Long, z:Long):Long = {

    def multi(m:Long, n:Long) = { ( (m%z) * (n%z) ) % z }

    def pow2(m:Long, n:Long, odd:Long, b:Long):Long = {
      n match {
        case 0 => 1
        case 1 => multi(m, odd)
        case _ =>
          pow2(multi(m,m), n/2, (if(n%2==1) multi(odd, b) else odd), multi(b,b))
      }
    }
    pow2(x, y, 1, x)
  }

  def twoPow(d:Int,s:Int):(Int,Int) = {
    if(d%2 == 1) (d,s)
    else twoPow(d>>1,s+1)
  }

  def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {
    if(i>3) true
    else {
      val a = r(i)
      val x = pow(a,d,n)

      if(x==1 || x==n-1) maybePrime(i+1,d,s,n)
      else repeat(s-1,x*x%n, i, d, s, n)
    }
  }

  def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {
    if(j==0) false
    else if(x==1) false
    else if(x==n-1) maybePrime(i+1,d,s,n)
    else repeat(j-1,x*x%n,i,d,s,n)
  }

  def isPrime(n:Int):Boolean = {
    if(n<5000) (2 to Math.sqrt(n).toInt).forall(n%_ != 0)
    else if(n%2==0) false
    else {
      val (d,s) = twoPow(n-1,0)
      maybePrime(0,d,s,n)
    }
  }

  def main(args:Array[String]) = {
    val n = readInt
    println((0 until n).count{ _=> isPrime(readInt) })
  }
}

Measured memory_bytes: 49872
#include<iostream>
#include<cstdio>
using namespace std;
const int N=200005,mod=1e9+7;
int n,a[N],b[N],f[4005][4005],fac[N],inv[N],ans;
int read()
{
	int r=0,f=1;
	char p=getchar();
	while(p>'9'||p<'0')
	{
		if(p=='-')
			f=-1;
		p=getchar();
	}
	while(p>='0'&&p<='9')
	{
		r=r*10+p-48;
		p=getchar();
	}
	return r*f;
}
int ksm(int a,int b)
{
	int r=1;
	while(b)
	{
		if(b&1)
			r=1ll*r*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return r;
}
int C(int n,int m)
{
	return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
	fac[0]=inv[0]=1;
	for(int i=1;i<=10000;i++)
		fac[i]=1ll*fac[i-1]*i%mod;
	inv[10000]=ksm(fac[10000],mod-2);
	for(int i=9999;i>=1;i--)
		inv[i]=1ll*inv[i+1]*(i+1)%mod;
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read(),b[i]=read();
		f[2001-a[i]][2001-b[i]]++;
		ans=(ans-C(a[i]*2+b[i]*2,a[i]*2))%mod;
	}
	for(int i=1;i<=4002;i++)
		for(int j=1;j<=4002;j++)
			f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%mod;
	for(int i=1;i<=n;i++)
		ans=(ans+f[2001+a[i]][2001+b[i]])%mod;
	printf("%d\n",(1ll*ans*ksm(2,mod-2)%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 64512
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int f(vector<vector<int>> &graph, vector<int> &dp, vector<int> &flag, int x){
	if(flag[x])
		return dp[x];
	flag[x] = 1;
	int temp = 0;
	for (auto nxt:graph[x]){
		temp = max(temp, f(graph, dp, flag, nxt) + 1);
	}
	return dp[x] = temp;
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> graph(n);
	vector<int> dp(n, 0);
	vector<int> flag(n, 0);
	rep(i, m)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
	}
	int ans = 0;
	rep(i, n){
		ans = max(ans, f(graph, dp, flag, i));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9856
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    cin >> n;

    ll dp[110][4 * 4 * 4];

    memset(dp, 0, sizeof(dp));

    for (int j = 0; j < 4; j++)
    {
        for (int k = 0; k < 4; k++)
        {
            dp[2][j * 16 + k * 4] = 1;
        }
    }

    for (int i = 3; i <= n; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            for (int k = 0; k < 4; k++)
            {
                for (int l = 0; l < 4; l++)
                {
                    dp[i][3 * 16 + j * 4 + k] += dp[i - 1][l + j * 16 + k * 4];
                    dp[i][0 * 16 + j * 4 + k] += dp[i - 1][l + j * 16 + k * 4];
                    dp[i][2 * 16 + j * 4 + k] += dp[i - 1][l + j * 16 + k * 4] * !(j == 1 && k == 0);
                    dp[i][1 * 16 + j * 4 + k] += dp[i - 1][l + j * 16 + k * 4] * (!(j == 2 && k == 0) && !(j == 0 && k == 2) && !(i > 3 && j == 2 && k == 2 && l == 0) && !(i > 3 && j == 2 && k == 3 && l == 0) && !(i > 3 && j == 3 && k == 2 && l == 0));

                    for (int m = 0; m < 4; m++)
                        dp[i][m * 16 + j * 4 + k] %= MOD;
                }
            }
        }
    }

    ll res = 0;
    for (int j = 0; j < 4; j++)
    {
        for (int k = 0; k < 4; k++)
        {
            for (int l = 0; l < 4; l++)
            {
                res += dp[n][j * 16 + k * 4 + l];
                res %= MOD;
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 11111111111111111
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//--------------------------------------------------------------------------

#define MAX 10000

ll vcnt(vll &v, ll start, ll end) {
  return upper_bound(ALL(v), end) - lower_bound(ALL(v), start);
}

ll c[30];
int main(void) {
  ll mod;
  vll a, b;
  cin >> n;
  FOR(i, 0, n) {
	cin >> temp;
	a.push_back(temp);
  }
  FOR(i, 0, n) {
	cin >> temp;
	b.push_back(temp);
  }

  RFOR(i, 0, 30) {
	mod = pow(2, i);
	FOR(j, 0, n) {
	  a[j] %= 2 * mod;
	  b[j] %= 2 * mod;
	}
	sort(ALL(a));
	sort(ALL(b));
	FOR(j, 0, n) {
	  c[i] += vcnt(a, mod - b[j], 2 * mod - b[j] - 1);
      c[i] += vcnt(a, 3 * mod - b[j], 4 * mod - b[j] - 1);
	}
  }

  FOR(i, 0, 30) {
	if (c[i] % 2 != 0) ans += pow(2, i);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4848
#include <stdio.h>
#include <math.h>
int main() {
  double a, b;
  double tmp, r;
  double ans;
  scanf ("%lf %lf", &a, &b);

  ans = a * b;

  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }

  r = fmod (a, b);
  while (r != 0) {
    a = b;
    b = r;
    r = fmod (a, b);
  }

  ans = ans / b;
  printf ("%.0lf\n", ans);

  return 0;
}


Measured memory_bytes: 384