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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define all(x) begin(x),end(x)

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

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld EPS = 1e-9;


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

    const int MAX = 1e6;
    vi prime(MAX, 1);
    prime[0] = prime[1] = 0;
    for (int i = 2; i * i < MAX; ++i) {
        if (!prime[i]) continue;
        for (int j = 2*i; j < MAX; j += i) {
            prime[j] = 0;
        }
    }

    for (;;) {
        int a, d, n; cin >> a >> d >> n;
        if (a == 0) break;

        int cnt = 0, ans;
        for (int i = a;; i += d) {
            if (prime[i]) {
                if (++cnt == n) {
                    ans = i;
                    break;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 6612
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> s(N);
    int score = 0;
    for (int i = 0; i < N; i++) {
        cin >> s[i];
        score += s[i];
    }
    
    int min = 1e+5;
    int count = 0;
    for (int i = 0; i < N; i++) {
        if (s[i]%10 == 0) count++;
        else if (s[i]<min) min = s[i];
    }

    if (score % 10 != 0) cout << score << endl;
    else if (count == N) cout << 0 << endl;
    else cout << score - min << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
    ll n;   cin >> n;
    ll *x = new ll[n];
    for (int i = 0; i < n; i++)
        cin >> x[i];

    ll aaa = 9000000;
    for (int p = 0; p <= 100; p++) {
        ll sum = 0;
        for (int i = 0; i < n; i++) {
            sum += (p-x[i])*(p-x[i]);
        }
        aaa = min(aaa, sum);
    }

    cout << aaa << endl;

    return 0;
}

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

int main() {
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  double ans = (double)H*W/2.0;
  int c=0;
  if(2*x==W&&2*y==H) c=1;
  printf("%.10f %d\n", ans, c);
  return 0;
}

Measured memory_bytes: 256
let rec select acc trace = function
  | [] -> acc
  | x :: xs -> select ((trace, x, xs) :: acc) (x :: trace) xs
let select xs = select [] [] xs

(* 与えられたリストからn要素を選ぶ順列 *)
let rec perm : int -> 'a list -> 'a list list = fun n xs ->
  match n, xs with
  | 0, _ -> [[]]
  | _, [] -> []
  | n, xs ->
      List.concat @@
        List.map (fun (xs, x, ys) ->
          List.map (fun xs -> x :: xs) @@
            perm (n - 1) @@ List.rev_append xs ys) @@ select xs;;

let () = Scanf.scanf "%d %d\n" @@ fun n c ->
  let dss =
    Array.init c @@ fun _ ->
      Array.init c @@ fun _ ->
        Scanf.scanf "%d " @@ fun d -> d in
  let css =
    Array.init n @@ fun _ ->
      Array.init n @@ fun _ ->
        Scanf.scanf "%d " @@ fun c -> c in
  let colours = Array.make_matrix 3 c 0 in
  Array.iteri (fun i ->
    Array.iteri (fun j c ->
      colours.((i + j + 2) mod 3).(c - 1) <- colours.((i + j + 2) mod 3).(c - 1) + 1)) css;
  Array.init c (fun c -> c)
  |> Array.to_list
  |> perm 3
  |> List.map (List.mapi (fun m y ->
      Array.mapi (fun x n -> n * dss.(x).(y)) colours.(m)
      |> Array.fold_left ( + ) 0))
  |> List.map (List.fold_left ( + ) 0)
  |> List.fold_left min max_int
  |> Printf.printf "%d\n"


Measured memory_bytes: 7936
def return_sorted_string(string):
    lst=list(map(ord,list(string)))
    lst.sort()
    lst=list(map(chr,lst))
    string="".join(lst)
    return string
    



n = int(input())
strings=[input() for i in range(n)]
dic={}
for i in range(n):
    string=return_sorted_string(strings[i])
    if string in dic:
        dic[string]+=1
    else:
        dic[string]=1

count=0        

for i in dic.values():
    count += i*(i-1)/2


print(int(count))

Measured memory_bytes: 25020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,ll> pi;
#define inf 1000000000000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define ss second
#define pb push_back
//#define mp make_pair



int main(){
int n;

cin >> n;
cout << n*(n+1)/2;




return 0;}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string s;
  cin >> s;
  bool ok = true;
  if (s[0] == s[1]) ok = false;
  if (s[1] == s[2]) ok = false;
  if (s[2] == s[3]) ok = false;
  cout << (ok ? "Good" : "Bad") << endl;
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
#import math
num = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0


for i in range(num):
    word = input()
    if word == "AC":
        AC = AC + 1
    elif word == "WA":
        WA = WA + 1
    elif word == "TLE":
        TLE = TLE + 1
    else:
        RE = RE + 1
        
print("AC x "+str(AC))
print("WA x "+str(WA))
print("TLE x "+str(TLE))
print("RE x "+str(RE))

Measured memory_bytes: 9216
import java.util.*;

public class Main{
  public static int dp[][];
  public static int func(char[][] g,int i,int j)
  {
    if(i==g.length-1 && j==g[0].length-1)
    return 1;
    if(i>=g.length || j>=g[0].length || g[i][j]=='#')
    return 0;
    if(dp[i][j]!=-1)
    return dp[i][j];
    dp[i][j]=func(g,i+1,j)%1000000007+func(g,i,j+1)%1000000007;
    return dp[i][j]%1000000007;
  }
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int h=sc.nextInt();
    int w=sc.nextInt();
    char g[][]=new char[h][w];
    dp=new int[h+1][w+1];
    String tp=sc.nextLine();
    for(int i=0;i<h;i++)
    {
      String s=sc.nextLine();
      for(int j=0;j<w;j++)
      {
        dp[i][j]=-1;
        g[i][j]=s.charAt(j);
      }
    }
    System.out.println(func(g,0,0));
  }
}
    

Measured memory_bytes: 50260
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

int main(void) {
    int num;
    cin >> num;
    // range
    //vector<pii> arr(num);
    vector<int> lows(num);
    vector<int> highs(num);
    for(int i = 0; i < num; i++) {
        int low, high;
        cin >> low >> high;
        lows[i] = low;
        highs[i] = high;
    }
    sort(lows.begin(), lows.end());
    sort(highs.begin(), highs.end());
    int mmin, mmax;

    if(num%2 == 1) {
        mmin = lows[num/2];
        mmax = highs[num/2];
    } else {
        mmin = lows[num/2 - 1] + lows[num/2];
        mmax = highs[num/2 - 1] + highs[num/2];
    }
    cout << mmax - mmin + 1 << endl;
    return 0;
}

Measured memory_bytes: 4824
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ulli unsigned long long int
#define lli long long int
#define d double
#define mod 1000000007
#define mx 200001
using namespace std;
void add_me(lli &a,lli b){
	a+=b;
	if(a>=mod) a-=mod;
}
void sub_me(lli &a,lli b){
	a-=b;
	if(a<0) a+=mod;
}
struct disjointset{
	int parent[mx];
	disjointset(){
		for(int i=1;i<mx;i++) parent[i]=i;
	}
	int find(int x){
		int par=parent[x];
		if(par==x) return x;
		return find(parent[x]);
	}
	void union_(int x,int y){
		int par1=find(x);
		int par2=find(y);
		if(par1==par2) return;
		parent[par2]=par1;
	}
};
int main() {
	FIO;
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22) cout<<"bust"<<endl;
	else cout<<"win"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(a + b + c > 21 ? "bust" : "win");
	}
}


Measured memory_bytes: 23892
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 105
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

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

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	// WF("output.txt");
	DF("err.txt");

	int N;
	scanf("%d", &N);
	vector <int> A(N);
	int maxx[2] = { 0 };
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		if (A[i] >= maxx[0]) {
			maxx[1] = maxx[0];
			maxx[0] = A[i];
		}
		else if (A[i] >= maxx[1]) {
			maxx[1] = A[i];
		}
	}
	for (int i = 0; i < N; i++) {
		if (A[i] == maxx[0])
			printf("%d\n", maxx[1]);
		else
			printf("%d\n", maxx[0]);
	}
	return 0;
}

Measured memory_bytes: 2432
s = input()
cnt = 0
for i in range (3):
    if s[i] == 'R':
        cnt += 1
if cnt == 3:
    print(3)
elif cnt == 2:
    if s[1] == 'S':
        print(1)
    else:
        print(2)
else:
    print(cnt)

Measured memory_bytes: 8984
#include <bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pll pair<long long int, long long int>
#define pii pair<int, int>
#define vii vector<int>
#define vll vector<long long int>
#define sii set<int>
#define sll set<long long int>
#define usi unordered_set<int, custom_hash>
#define usl unordered_set<long long int, custom_hash>
#define mii map<int, int>
#define mll map<long long int, long long int>
#define umi unordered_map<int, int, custom_hash>
#define uml unordered_map<long long int, long long int, custom_hash>
#define ski stack<int>
#define skl stack<long long int>
#define all(v) v.begin(),v.end()
using namespace std;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c`
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


const int N=1e5+1;
const int mod=998244353;
ll a[N], b[N], c[N];

vii graph[N];

int dfs(int u){
    if(a[u]!=-1){
        return a[u];
    }
    a[u]=0;
    for(int v:graph[u]){
        a[u]=max(a[u], 1ll+dfs(v));
    }

    return a[u];
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
    
    int n, m;
    cin>>n>>m;

    for(int i=m;i--;){
        int u, v;
        cin>>u>>v;
        graph[u].pb(v);
    }
    memset(a, -1, sizeof(a));

    for(int i=1;i<=n;++i){
        dfs(i);
    }

    ll ans=0;
    for(int i=1;i<=n;++i){
        ans=max(ans, a[i]);
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 9472
#include <iostream>

using namespace std;
int main() {
	int s;
	cin >> s;
	int h = s / 60 / 60;
	int m = s/60-h*60;
	int ss = s % 60 % 60;
	cout << h << ":" << m << ":" << ss << endl;
	return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>

int main(){
	
	long long int n;
	scanf("%lld", &n);
	int i=0, temp;;
	char word[100];
	while(n>0){
		temp=0;
		temp=n%26;
		if(temp==0){
			word[i] = 'z';
			n=n/26-1;
		}
		else{
			word[i] = temp+'a'-1;
			n/=26;
		}
//		n/=26;
//		printf("%c", temp+'a'-1);
		i++;
	}
//	printf("%d", i);
	word[i]='\0';
	for(int j=i-1; j>=0; j--){
		printf("%c", word[j]);
	}
	return 0;
}

Measured memory_bytes: 1628
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#define MAX 100001
using namespace std;

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

    vector<int> vec;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &temp);
        vec.push_back(temp);
    }

    int q, num;
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        scanf("%d", &num);
        vector<int>::iterator itr = lower_bound(vec.begin(), vec.end(), num);
        printf("%d\n", itr - vec.begin());
    }


    return 0;
}



Measured memory_bytes: 3512
#include<stdio.h>
#define sentinel 2000000000
#define MAX 500000
int n,cnt;
int L[MAX/2+2],R[MAX/2+2];
void merge(int A[],int left,int mid,int right){
    int n1,n2,i,j,k;
    n1=mid-left;
    n2=right-mid;
    for(i=0;i<n1;i++) L[i]=A[left+i];
    for(i=0;i<n2;i++) R[i]=A[mid+i];
 
    i=j=0;
    L[n1]=R[n2]=sentinel;
    for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]) A[k]=L[i++];
    else A[k]=R[j++];
    }
}
 
void mergeSort(int A[],int left,int right){
    int mid;
    if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
    }
}
 
int main(void){
    int i;
    int A[MAX];
 
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
 
    mergeSort(A,0,n);
     
    for(i=0;i<n;i++){
    if(i) printf(" ");
    printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",cnt);
 
    return 0;
}


Measured memory_bytes: 5648
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
  	
  	set<char> st;
	string s;
	cin >> s;
	forn(i, s.size())st.insert(s[i]);
	cout << (st.size()== 2?"Yes" : "No");
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    
    long long int sum = 0;
    std::vector<long long int> h;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        h.push_back(tmp);
    }
    
    std::sort(h.begin(), h.end()/*, std::greater<int>()*/);
    int res = n - k;
    //cout << res << "," << n << "," << k << endl;
    if(res <= 0){
        cout << 0 << endl;
        return 0;
    }else{
        for(int i=0; i<k; i++){
            h.pop_back();
        }
        for(int i=0; i<h.size(); i++){
            sum += h[i];
        }
    }
    cout << sum << endl;   
    return 0;
}

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

int main() {
  int N, M, R;
  cin >> N >> M >> R;
  vector<int> r(R);
  for (int i = 0; i < R; i++) {
    cin >> r.at(i);
    r.at(i)--;
  }

  vector<vector<int>> G(N, vector<int>(N, 1e9));
  for (int a, b, c; cin >> a >> b >> c;) {
    G.at(--a).at(--b) = c;
    G.at(b).at(a) = c;
  }
  for (int i = 0; i < N; i++) {
    G.at(i).at(i) = 0;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        G.at(j).at(k) = min(G.at(j).at(k), G.at(j).at(i) + G.at(i).at(k));
      }
    }
  }

  int ans = 1e9;
  sort(r.begin(), r.end());
  do {
    int tmp = 0;
    for (int i = 0; i + 1 < R; i++) {
      tmp += G.at(r.at(i)).at(r.at(i + 1));
    }
    ans = min(ans, tmp);
  } while (next_permutation(r.begin(), r.end()));
  cout << ans << "\n";
}

Measured memory_bytes: 512
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

int N, M, S;

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M >> S;
	while (N) {
		int dp[50][3001] = {};
		dp[0][0] = 1;
		for (int i = 1; i <= M; i++) {
			for (int j = N*N; j >= 1; j--) {
				for (int k = S; k >= i; k--) {
					dp[j][k] += dp[j - 1][k - i];
					dp[j][k] %= 100000;
				}
			}
		}
		cout << dp[N*N][S] << endl;
		cin >> N >> M >> S;
	}
	return 0;
}

Measured memory_bytes: 3664
import  java.util.*;
class Main{
    int t;
    int n;
    
    Main(){
	Scanner sc=new Scanner(System.in);
	for(int i=1; i<5; i++){
	    t=sc.nextInt();
	    n=sc.nextInt();
	    if(t==1){
		System.out.println(6000*n);
	    }else if(t==2){
		System.out.println(4000*n);
	    }else if(t==3){
		System.out.println(3000*n);
	    }else if(t==4){
		System.out.println(2000*n);
	    }
			   
	}

    }

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

Measured memory_bytes: 17360
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

int main(void) {
	int d, n;
	cin >> d >> n;
	int num = pow(100, d);
	if (n != 100) {
		cout << num * n;
	}
	else {
		cout << num * 101;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    set<Int> s;
    rep(i,n) {
        Int a; cin>>a; 
        s.insert(a);
        }
    int q; cin>>q;
    vector<Int> t(q,0);
    rep(i,q) cin>>t[i];
    int ans=0;
    for(int i=0; i<q; i++){
        for(auto x: s){
            if(t[i]==x) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3204
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]

import itertools

for i in range(h):
  ans=""
  for j in range(w):
    if s[i][j]=="#":
      ans+="#"
      continue
    temp=0
    for dx,dy in itertools.product([-1,0,1],repeat=2):
      if i+dx<0 or i+dx>=h:
        continue
      if j+dy<0 or j+dy>=w:
        continue
      if s[i+dx][j+dy]=="#":
        temp+=1
    ans+=str(temp)
  print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
  int h[100], w[100];
  int i, j, k;
  int num = 0;

  while ( (h[num-1] != 0) || (w[num-1] != 0) ) {
    scanf("%d %d", &h[num], &w[num]);
    ++num;
  }

  for ( k = 0; k < num; ++k ) {
    for ( i = 0; i < h[k]; ++i ) {
      for ( j = 0; j < w[k]; ++j ) {
        if ( (i+j) % 2 == 0 ) {
          printf("#");
        } else {
          printf(".");
        }
      }
      putchar('\n');
    }
    if ( k != num-1 ){
      putchar('\n');
    }
  }

  return 0;

}


Measured memory_bytes: 2052
#include <iostream>
#include <vector>

struct Tree {
  int parent = -1;
  int left;
  int right;
};

class Trees {
private:
  std::vector<Tree> trees_;
  int root_ = -1;
  void findRoot_();
  void r_preorderTreeWalk_(int n);
  void r_inorderTreeWalk_(int n);
  void r_postorderTreeWalk_(int n);
public:
  Trees(int n);
  void makeTree(int id, int left, int right);
  void preorderTreeWalk();
  void inorderTreeWalk();
  void postorderTreeWalk();
};

Trees::Trees(int n) {
  trees_ = std::vector<Tree>(n);
}

void Trees::makeTree(int id, int left, int right) {
  trees_[id].left = left;
  trees_[left].parent = id;
  trees_[id].right = right;
  trees_[right].parent = id;
}

void Trees::findRoot_() {
  for (int i = 0 ; i < (int)trees_.size(); ++i) {
    auto t = trees_[i];
    if (t.parent == -1) {
      root_ = i;
      return;
    }
  }
}

void Trees::r_preorderTreeWalk_(int n) {
  std::cout << " " << n;
  if (trees_[n].left != -1)
    r_preorderTreeWalk_(trees_[n].left);
  if (trees_[n].right != -1)
    r_preorderTreeWalk_(trees_[n].right);
}

void Trees::preorderTreeWalk() {
  if (root_ == -1)
    findRoot_();
  r_preorderTreeWalk_(root_);
  std::cout << std::endl;
}

void Trees::r_inorderTreeWalk_(int n) {
  if (trees_[n].left != -1)
    r_inorderTreeWalk_(trees_[n].left);
  std::cout << " " << n;
  if (trees_[n].right != -1)
    r_inorderTreeWalk_(trees_[n].right);
}

void Trees::inorderTreeWalk() {
  if (root_ == -1)
    findRoot_();
  r_inorderTreeWalk_(root_);
  std::cout << std::endl;
}

void Trees::r_postorderTreeWalk_(int n) {
  if (trees_[n].left != -1)
    r_postorderTreeWalk_(trees_[n].left);
  if (trees_[n].right != -1)
    r_postorderTreeWalk_(trees_[n].right);
  std::cout << " " << n;
}

void Trees::postorderTreeWalk() {
  if (root_ == -1)
    findRoot_();
  r_postorderTreeWalk_(root_);
  std::cout << std::endl;
}

int main() {
  int n;
  std::cin >> n;
  Trees t(n);
  for (int i = 0; i < n; ++i) {
    int id, left, right;
    std::cin >> id >> left >> right;
    t.makeTree(id, left, right);
  }
  std::cout << "Preorder" << std::endl;
  t.preorderTreeWalk();
  std::cout << "Inorder" << std::endl;
  t.inorderTreeWalk();
  std::cout << "Postorder" << std::endl;
  t.postorderTreeWalk();
}
   

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

int main() {
    int N;
    string S, s="";
    cin >> N >> S;

    s += S[0];
    for (int i=1; i<S.size(); i++) {
        if (s.back() != S[i]) s += S[i];
    }

    cout << s.size() << endl;

    return 0;
}



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

using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

ordered_set< pair<ll,ll> > up , dw;
const int N = 2e5+5;
ll n , m , a[N] , b[N] , c[N];

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

    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
        up.insert({a[i] , i});
    }
    for(int i=1; i<=n; i++)
        cin >> b[i];
    for(int i=1; i<=n; i++)
    {
        cin >> c[i];
        dw.insert({c[i] , i});
    }

    ll ans=0 , u , d;
    for(int i=1; i<=n; i++)
    {
        u = up.order_of_key({b[i] , -1e9});
        d = dw.order_of_key({b[i] , 1e9});
        d = dw.size() - d;
        ans += (u*d);
    }

    cout << ans << '\n';

    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int c;
    if(b/10==0) c=10*a+b;
    else if(b/10>1&&b/10<10)  c=100*a+b;
    else c=1000*a+b;
    for(int i=1;i<=c;i++){
        if(i*i==c){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> A(m);
    int ans = 0;
    rep(i, m) {
        cin >> A[i];
        if(x > A[i]) ans++;
    }
    ans = min(ans, m - ans);

    cout << ans << endl;

    return 0;
}

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

int main(){
    int s;
    int w;
    cin >> s >> w;
    if(w>=s){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
    

}

Measured memory_bytes: 3132
#include <iostream>

using namespace std;
typedef long long ll;
#define MOD 1000000007

int main() {
  ll N, M;

  cin >> N >> M;

  ll S[N + 1], T[M + 1];
  for(int i = 1; i < N + 1; i++) {
    cin >> S[i];
  }
  for(int j = 1; j < M + 1; j++) {
    cin >> T[j];
  }
  
  int dp[N + 1][M + 1];
  for(int i = 0; i < N + 1; i++) {
    for(int j = 0; j < M + 1; j++) {
      dp[i][j]=1;
    }
  }
  
  for(int i = 1; i < N + 1; i++) {
    for(int j = 1; j < M + 1; j++) {
      dp[i][j]=((dp[i-1][j] % MOD) + (dp[i][j-1] % MOD)) % MOD;
      if(S[i] != T[j]) dp[i][j]=dp[i][j]-dp[i-1][j-1];
      if(dp[i][j]<0) dp[i][j] += MOD;
    }
  }

  cout << dp[N][M] << endl;
  
  return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    int n;cin>>n;
    map<pair<int,int>,ll>W;
    vector<vector<int> >uv(n);
    vector<ll>sumw(n,-1);sumw[0]=0;
    REP(i,n-1)
    {
        int u,v,w;cin>>u>>v>>w;
        u--;v--;
        uv[u].pb(v);
        uv[v].pb(u);
        W[mp(u,v)]=w;
        W[mp(v,u)]=w;
    }
    queue<int>bfs;
    bfs.push(0);
    while(!bfs.empty())
    {
        int now=bfs.front();bfs.pop();
        ll noww=sumw[now];
        REP(i,uv[now].size())
        {
            if(sumw[uv[now][i]]==-1){sumw[uv[now][i]]=noww+W[mp(now,uv[now][i])];bfs.push(uv[now][i]);}
        }
    }
    REP(i,n)
    {
        cout<<sumw[i]%2<<endl;
    }
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, c;
	cin >>n >>c;
	vector<VI> dt(n, VI(4)), dt2; 
	rep(i, n) cin >>dt[i][1] >>dt[i][2] >>dt[i][0];
	sort(all(dt));
	VI ccr = dt[0];
	rep2(i, 1, n){
		if(ccr[0] == dt[i][0] && ccr[2]==dt[i][1]){
			ccr[2] = dt[i][2];
		}else{
			dt2.push_back(ccr);
			ccr = dt[i];
		}
	}
	dt2.push_back(ccr);
	sort(all(dt2), [](auto& l, auto& r){return l[1] < r[1];});
	VI vdr; int ans = 0;
	for(const auto& x: dt2){
		int add = 1;
		for(auto& z: vdr){
			if( z < x[1]){
				z = x[2]; add = 0; break;
			}
		}
		if(add==1){
			vdr.push_back(x[2]);
			ans = max(ans, sz(vdr));
		}
	}
	cout <<ans <<"\n";
	return 0;
}


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

#define rep(i,a,n) for(int i = a; n > i; i++)
#define REP(i,n) rep(i,0,n)
 
signed main()
{
  int n;
  cin >> n;
  vector<vector<int>> graph(n), par(n, vector<int>(30));
  vector<int> d(n);

  REP(i,n){
    int k;
    cin >> k;
    REP(j,k){
      int c;
      cin >> c;
      graph[i].push_back(c);
      graph[c].push_back(i);
    }
  }

  function<void(int,int,int)> dfs = [&](int c, int p, int depth){
    d[c] = depth;
    par[c][0] = p;
    for(auto ch : graph[c]){
      if(ch != p)
        dfs(ch, c, depth + 1);
    }
  };
  dfs(0, 0, 0);
  
  int q;
  cin >> q;

  /*calc par*/
  for (int i = 1; 30 > i; i++)
  {
    REP(j, n)
    {
      par[j][i] = par[par[j][i - 1]][i - 1];
    }
  }

  REP(__, q)
  {
    int u, v;
    cin >> u >> v;
    if (d[u] > d[v])
      swap(u, v);

    /*LCA!!!*/
    
    for (int i = 29; 0 <= i; i--)
    {
      //cout << d[u] << " " << d[v] << endl;
      if (d[u] <= d[par[v][i]])
      {
        v = par[v][i];
      }
    }
    /* LCA */
    for (int i = 29; 0 <= i; i--)
    {
      //cout << u << " " << v << endl;
      if (par[u][i] != par[v][i])
      {
        v = par[v][i];
        u = par[u][i];
      }
    }
    if(u == v) cout << u << endl;
    else cout << par[v][0] << endl;
  }
}


Measured memory_bytes: 31248
import numpy as np
N = int(input())
S = input()

l_r = set()
l_g = set()
l_b = set()
for i in range(N):
  if S[i]=='R':
    l_r.add(i)
  if S[i]=='G':
    l_g.add(i)
  if S[i]=='B':
    l_b.add(i)

ans = len(l_r)*len(l_g)*len(l_b)

for r in l_r:
  for g in l_g:
    mi = min(r, g)
    ma = max(r, g)
    l = ma - mi
    if ma+l in l_b:
      ans -= 1
    if mi-l in l_b:
      ans -= 1
    if l%2==0 and l//2 + mi in l_b:
      ans -= 1

print(ans)

Measured memory_bytes: 27228
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
double pi=3.14159265358;
int main(){
  double now=90;
  double x=0.0,y=0.0;
  while(1){
    double a,b;
    scanf("%lf,%lf",&a,&b);
    if (a==0.0 and b==0.0)break;
    double xx=0.0,yy=0.0;
    xx=cos(now/180*pi)*a;
    yy=sin(now/180*pi)*a;
    x+=xx;
    y+=yy;
    now-=(b);
    
    
    
  }  
  printf("%d\n%d\n",(int)x,(int)y);
}



Measured memory_bytes: 3528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());

		if (x % y != 0) {
			System.out.println(x);
		} else {
			System.out.println(-1);
		}

		sc.close();
	}
}

Measured memory_bytes: 21844
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                count += 1

print(count)


Measured memory_bytes: 3060
import sys
import math
input = lambda: sys.stdin.readline().rstrip()
aint = lambda: int(input())

k = aint()
s = 0
for a in range(1,k+1):
    for b in range(a,k+1):
        for c in range(b,k+1):
            gcdab=math.gcd(a,b)
            if a==b and b==c:
                t=1
            elif a==b or b==c:
                t=3
            else:
                t=6
            s += t*math.gcd(gcdab, c)
print(s)

Measured memory_bytes: 9196
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<tuple>
#include<iomanip>
//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(const vector<vector<T>>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(const vector<T>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (!ts[i][j])return false;
	return true;
}

vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}

int main() {
	double W, H, x, y;
	cin >> W >> H >> x >> y;
	cout  << W * H / 2.0 << " " << (W / 2 == x && H / 2 == y ? 1 : 0) << endl;
}


Measured memory_bytes: 256
import java.util.*

// ABC 086 A - Product
// https://atcoder.jp/contests/abc086/tasks/abc086_a
fun main(args:Array<String>) {
    val scn = Scanner(System.`in`)
    val in1 = scn.nextInt()
    val in2 = scn.nextInt()

    if((in1*in2)%2 == 0){
        println("Even")
    }else{
        println("Odd")
    }
}

Measured memory_bytes: 31132
import numpy as np
h, n = map(int, input().split())
ab = np.array([list(map(int, input().split())) for _ in range(n)])

a = ab[:, 0]
b = ab[:, 1]

dp = np.zeros(10**8, dtype=np.int)

for i in range(1,h+1):
    dp[i] = min(dp[i-a]+b)

print(dp[h])

Measured memory_bytes: 12608
N, K = gets.chomp.split(' ').map(&:to_i);

ret = 0
last = N
if N >= K
  last = K - 1
  ret += (N - K + 1) / N.to_f if N >= K
end
(1..last).each { |p|
  log = 0
  x = p
  while (x < K) do
    x *= 2
    log += 1
  end
  ret += (1 / N.to_f) * (0.5 ** log)
}
print(ret)


Measured memory_bytes: 1788
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
bool dp[2][8010][40000];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int x, y; cin >> x >> y;
    reverse(S.begin(), S.end());
    while(S.length() && S.back() != 'T') {
        x--;
        S.pop_back();
    }
    reverse(S.begin(), S.end());
    vector<int> v[2];
    int len = 0;
    bool turn = false;
    rep(i, S.length()) {
        if(S[i] == 'F') len++;
        else {
            if(len > 0) v[turn].push_back(len);
            len = 0;
            turn = !turn;
        }
    }
    if(len > 0) v[turn].push_back(len);
    dp[0][0][20000] = dp[1][0][20000] = true;
    rep(k, 2) {
        rep(i, v[k].size()) {
            REP(j, -8000, 8000) {
                dp[k][i + 1][j + 20000 + v[k][i]] |= dp[k][i][j + 20000];
                dp[k][i + 1][j + 20000 - v[k][i]] |= dp[k][i][j + 20000];
            }
        }
    }
    if(dp[0][v[0].size()][20000 + x] && dp[1][v[1].size()][20000 + y]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    // cout << S << endl;
    // cout << x << " " << y << endl;
    // for(auto& e: v[0]) cout << e << " ";
    // cout << endl;
    // for(auto& e: v[1]) cout << e << " ";
    // cout << endl;


    return 0;
}


Measured memory_bytes: 158976
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int n;

bool ok(int x) {
	if(x == 1) return false;
	int nn = n;
	while(nn % x == 0) nn /= x;
	return nn % x == 1;
}

signed main()
{
	IO_OP;
	
	int ans = 0;
	cin >> n;
	for(int i=1;i*i<=n;i++) {
		if(n % i) continue;
		if(ok(i)) ans++;
		if(i * i != n && ok(n/i)) ans++;
	}
	for(int i=1;i*i <= n-1;i++) {
		if((n-1)%i) continue;
		if(i != 1) ans++;
		if(i * i != (n-1) && (n-1)/i != 1) ans++;
	}
	cout << ans << endl;
}





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


#define MOD 1000000007

int n;
int a[100010];
long long memo[110][100010] = {};

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

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


  for(int i = 0;i <= k;i++){
    memo[n][i] = 1;
  }

  for(int i = n-1;i >= 0;i--){
    for(int j = 0;j <= k;j++){
      /*
      for(int x = 0;x <= a[i];x++){
        if(j-x >= 0){
          memo[i][j] += memo[i+1][j-x];
        }
      }
      */

      int tmp = j-a[i];

      memo[i][j] = memo[i+1][j];

      if(tmp > 0){
        memo[i][j] = (MOD + memo[i][j] - memo[i+1][tmp-1]) % MOD;
        //memo[i][j] -= memo[i+1][tmp-1];
      }
    }
    if(i > 0){
      for(int j = 0;j < k;j++){
        memo[i][j+1] += memo[i][j];
        memo[i][j+1] %= MOD;
      }
    }
  }

  cout << memo[0][k] << endl;

  return 0;
}


Measured memory_bytes: 82176
// {{{ by shik
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

const int N=110;
int n,m,a[N];
void main() {
    R(n,m);
    REP(i,n) R(a[i]);
    sort(a,a+n);
    int ans=0;
    REP(i,n) if ( m>=a[i] ) {
        m-=a[i];
        ans++;
    }
    if ( ans==n && m>0 ) ans--;
    W(ans);
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	
	static Scanner scan;
	
	private static int counter = 0;
	private static int[] array;
	
	public static int[] BubbleSort() {
		for(int i = 0; i < array.length - 1; i++) {
			for(int j = array.length - 1; j >= i + 1; j--) {
				if(array[j] < array[j-1]) {
					swap(j, j-1);
					counter++;
				}
			}
		}
		
		return array;
	}
	
	public static void swap(int i, int j) {
		int tmp = array[i];
		array[i] = array[j];
		array[j] = tmp;
	}
	
	public static void printArray() {
		for(int i = 0; i < array.length - 1; i++) {
			System.out.print(array[i] + " ");
		}
		System.out.println(array[array.length - 1]);
	}
	
	public static void main(String[] args) {
		scan = new Scanner(System.in);
		
		// Get a value of the input array's length
		final int length = scan.nextInt();
		
		// Get a input array
		array = new int[length];
		for(int i = 0; i < length; i++) {
			array[i] = scan.nextInt();
		}
		
		// Carry out the bubble sort
		BubbleSort();
		printArray();
		System.out.println(counter);
	}

}



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

#define N 200123
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    if(fopen("input.in", "r")){
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n, a[8], b[8], c = 0, d = 0;
    cin >> n;
    for(int i = 0 ; i < n ; i++) cin >> a[i];
    for(int i = 0 ; i < n ; i++) cin >> b[i];
    while(next_permutation(a, a+n)) c++;
    while(next_permutation(b, b+n)) d++;
   
    cout << abs(c-d) << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(str(input()))

f = 0

if n % 2 == 0:
    for i in range(0,n//2):
        if s[i] == s[i+n//2]:
            pass
        else:
            f = 1
            break
else:
    f = 1

if f:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
D = list(map(int, sys.stdin.readline().split()))

ans = 0
for i, j in itertools.product(range(N), range(N)):
    if i < j:
        ans += D[i] * D[j]
print(ans)


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

#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 FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int n,x;cin >> n >> x;
   vector<int> m(n);
   int sum = 0;
   rep(i,n){
      cin >> m[i];
      sum += m[i];
   }
   int ans = n;
   x -= sum;
   sort(All(m));
   ans += x / m[0];
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};

struct DisjointSet {
    ps: Vec<Option<usize>>,
    ns: Vec<i64>,
}

impl DisjointSet {
    fn new(n: usize) -> DisjointSet {
        DisjointSet { ps: vec![None; n], ns: vec![1; n] }
    }

    fn unite(&mut self, x: usize, y: usize) {
        let nx = self.find(x);
        let ny = self.find(y);
        if nx == ny {
            return;
        }
        let (a,b) = if self.ns[nx] < self.ns[ny] { (nx,ny) } else { (ny,nx) };
        self.ps[a] = Some(b);
        self.ns[b] += self.ns[a];
    }

    fn find(&mut self, x: usize) -> usize {
        match self.ps[x] {
            Some(y) => {
                let res = self.find(y);
                self.ps[x] = Some(res);
                res
            },
            None => {
                x
            },
        }
    }

    fn same(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }
}

fn main() {
    let xs = read_vec_i64();
    let (n,q) = (xs[0] as usize, xs[1] as usize);
    let mut ds = DisjointSet::new(n);
    for _ in 0..q {
        let ys = read_vec_i64();
        let (com,x,y) = (ys[0], ys[1] as usize, ys[2] as usize);
        if com == 0 {
            ds.unite(x,y);
        }
        else {
            println!("{}", if ds.same(x,y) { 1 } else { 0 });
        }
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}



Measured memory_bytes: 5048