akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim()
{
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for (int i = 0; i < n; i++)
    {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while(true)
    {
        minv = INFTY;
        u = -1;
        for (int i = 0; i < n; i++)
        {
            if (color[i] != BLACK && d[i] < minv)
            {
                minv = d[i];
                u = i;
            }
        }
        if (u == -1) break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++)
        {
            if (color[v] != BLACK && M[u][v] != INFTY)
            {
                if ( M[u][v] < d[v])
                {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int s = 0;
    for (int i = 0; i < n; i++)
    {
        if (p[i] != -1)
        {
            s += M[i][p[i]];
        }
    }
    return s;
}

int main()
{
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            int e;
            cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }

    cout << prim() << endl;

    return 0;
}


Measured memory_bytes: 3112
x,y = [int(x) for x in input().split()]

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if x == y or (x in a and y in a) or (x in b and y in b):
    print("Yes")
else:
    print("No")

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

bool solve(ll i,ll M,ll N){
    if(i <=M/N) return true;
    else return false;
}

int main(){
    ll N,M,i;
    cin>>N>>M;
    ll ans=-1;
    for(i=1;i<=sqrt(M);i++){
        if(M%i==0){
            if(solve(i,M,N)) ans=max(ans,i);
            if(solve(M/i,M,N)) ans=max(ans,M/i);
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;


int main(){

  int n;cin>>n;
  string s;cin>>s;
  int ans=0;
  rep(i,0,n-2){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;
  }

  out(ans);

  return 0;
}

Measured memory_bytes: 256
# require "prime"
# x = gets.chomp.to_i
# x.downto (1) do |i|
#     ans = i.prime_division
#     size = ans.size
#     count = 0
#     me = ans[0]
#     ans.each do |j|
#         if me == j && ans[0][1] != 1
#             count += 1
#         end
#     end
#     if count == size
#         puts i
#         break
#     end
# end
require "prime"
#p 961.prime_division
x = gets.chomp.to_i
x.downto (1) do |i|
    ans = i.prime_division
    #p ans
    size = ans.map(&:to_s).size
    count = 0
    if size == 1 && ans[0][1] != 1 && x >= 4
        puts i
        break
    elsif size >= 2 
        count = 0
        me = ans[0][1] 
        ans.each do |i|
            if me == i[1] && me != 1 
                count += 1
            end
        end
        if count == size
            puts i
            break
        end
    elsif x < 4
        puts "1"
        break
    end
    # if i >= 962 && i <= 999
    #     puts "961"
    #     exit
    # end
    # ans.each do |j|
    #     if j[1] != 1
    #         count += 1
    #     end
    # end
    # if count == size
    #     puts i
    #     exit
    # end
end


Measured memory_bytes: 14352
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        String moji = scanner.next();
        if(moji.equals("z")){
            System.out.println("a");
        }else{
            System.out.println((char)( moji.charAt(0)+ 1));
        }
    }
}


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

for i in range(k):
    if i%2==0:
        if a%2!=0:
            a-=1
        b += int(a/2)
        a -= int(a/2)
    else:
        if b%2!=0:
            b-=1
        a += int(b/2)
        b -= int(b/2)
print(a,b)

Measured memory_bytes: 3064
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    int n,m,sum=0;
    cin>>n>>m;
    for(int i=0;i<m;i++ )
    {
        int p;
        cin>>p;
        sum+=p;
    }
    if(n-sum<0)
        cout<<-1;
    else
        cout<<n-sum;
}
int main()
{
    go();
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  for(int i = 1; i < 1000; i++)
  {
    int heighta = ((i + 1) * i) / 2;
    int heightb = ((i + 2) * (i + 1)) / 2;
    if(heighta - a == heightb - b)
    {
      cout << heighta - a << endl;
      break;
    }
  }
  return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define here(s)      cout<<s<<endl;
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


typedef long long ll;

ll dp[10004];
ll h,n;
ll a[10004],b[10004];
ll fun()
{
    fr(i,1,h+1)
    {
        dp[i]=1000000000;
    }
    fr(i,1,h+1)
    {
        fr(j,0,n)
        {
            if(i-a[j]>=0)
            dp[i]=min(dp[i],dp[i-a[j]]+b[j]);
            else
            dp[i]=min(dp[i],0+b[j]);
          //  cout<<dp[i]<<" "<<i<<endl;
        }
    }
    return dp[h];
}


int main()
{
    run;

    cin>>h>>n;
   // ll a[n],b[n];
    fr(i,0,n)
    {
        cin>>a[i]>>b[i];
    }
   // vector<pair<ll,ll> > v;
   
    cout<<fun();




    return 0;
}


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

int main(void) {
  long long int N;
  cin >> N;
  vector<long long int> A(N, 0);
  vector<long long int> Num(N + 1, 0);
  for (long long int i = 0; i < N; i++) {
    cin >> A[i];
    Num[A[i]]++;
  }

  long long combination_count = 0;
  for (long long int i = 0; i < N + 1; i++) {
    combination_count += (Num[i] * (Num[i] - 1)) / 2;
  }

  for (long long int i = 0; i < N; i++) {
    cout << combination_count - Num[A[i]] + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <math.h>


int main(void)
{
	int pr[50050];
	int prime[5200];
	int i;
	int j;
	int k;
	int m;
	
	for(i = 1; i <= 50050; i++){
		pr[i] = 1;
	}
	
	pr[0] = 0;
	pr[1] = 0;
	
	for(i = 0;i < (int)(sqrt(50050)); i++){
		if(pr[i] == 1){
			for(j = 2; j <= (int)(50050 / i); j++){
				pr[i * j] = 0;
			}
		}
	}
	
	k = -1;
	for(i = 0; i < 50050; i++){
		if(pr[i] == 1){
			k++;
			prime[k] = i;
		}
	}
	
	while(scanf("%d", &m) != EOF){
		for(k = 0; k < 5200; k++){
			if(m == prime[k]){
				printf("%d %d\n", prime[k - 1], prime[k + 1]);
				break;
			}
			else{
				if(prime[k] < m && m < prime[k + 1]){
					printf("%d %d\n",prime[k], prime[k + 1]);
					break;
				}
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
n, k = gets.split.map(&:to_i)

# n+1個からk個以上を選んだ和
# k個
# (10^100+a) + (10^100+b) + ... = k*10^100 + (a + b + ...)
# k+1個
# (10^100+a) + (10^100+b) + ... = (k+1)*10^100 + (a + b + ...)
# -> k個とk+1個だと絶対に和は被らない
# a,b,...の部分で、0+1+4+5 = 0+2+3+5のような被りはある。
#
# 0+1+2+...+(k-2)+(k-1)
#       ...
# 0+1+2+...+(k-2)+  n   n-(k-1)+1=n-k+2通り
# 0+1+2+...+(k-1)+  n
#       ...
# 0+1+2+...+(n-1)+  n   (n-1)-(k-1)+1=n-k+1通り
#       ...
# 1+(n-k+2)+...+(n-1)+n
#       ...
# (n-k+1)+.......+  n   (n-k+1)-1+1 = n-k+1通り
#
# 0+1+2+3
# 0+1+2+4
# 0+1+2+5
# 0+1+2+6 6-4+2=4
# 0+1+3+6
# 0+1+4+6
# 0+1+5+6 6-4+1=3
# 0+2+5+6
# 0+3+5+6
# 0+4+5+6 6-4+1=3
# 1+4+5+6
# 2+4+5+6
# 3+4+5+6 6-4+1=3
# 
# n-k+2 + (n-k+1)(k-1)

total = 0
(k..(n+1)).each do |i|
  total += (n-i+2) + (n-i+1)*(i-1)
end

puts total % (10**9+7)


Measured memory_bytes: 14420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long inf = 1LL<<60;

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

    if(s==1e9){
        for(int i=0;i<k;i++){
            cout << s << " ";
        }
        for(int i=0;i<n-k;i++){
            cout << 1 << " ";
        }
    }
    else {
        rep(i,k) cout << s << " ";
        rep(i,n-k) cout << s+1 << " ";
    }
}

Measured memory_bytes: 1280
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx2")
#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 pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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

	int N, M;
	cin >> N >> M;

	int H[100001];
	rep1(i, N) cin >> H[i];

	vector<int> E[100001];
	rep(i, M) {
		int a, b;
		cin >> a >> b;

		E[a].pb(b);
		E[b].pb(a);

	}

	int kotae = 0;
	rep1(i, N) {
		int OK = 1;
		rep(j, E[i].size()) {
			if (H[i] <= H[E[i][j]]) OK = 0;
		}
		if (OK) kotae++;
	}

	co(kotae);

	Would you please return 0;
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#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 BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

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

	int MOD = 10007;

	int N;
	string S;
	cin >> N;
	cin >> S;

	map<char, int> m;
	m['J'] = 0;
	m['O'] = 1;
	m['I'] = 2;

	vector<vector<LL>> dp(N + 10, vector<LL>(1 << 3, 0));
	FOR(b, 0, 1 << 3) {
	    if (b & (1 << m[S[0]]) and b & (1 << m['J'])) {
            dp[0][b] = 1;
        }
	}

	FOR(i, 0, N) {
	    FOR(j, 0, 1 << 3) {
            FOR(b, 0, 1 << 3) {
                if ((j & b) == 0) {
                    continue;
                }

                if (b & (1 << m[S[i + 1]])) {
                    (dp[i + 1][b] += dp[i][j]) %= MOD;
                }
            }
        }
	}

	LL ans = 0;
	FOR(b, 0, dp[0].size()) {
        (ans += dp[N - 1][b]) %= MOD;
    }
	print(ans);

	return 0;
}


Measured memory_bytes: 3308
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
 
using namespace std;

long long gcd(long long x,long long y)
{
	return y==0 ? x : gcd(y,x%y);
}

int main()
{

	string s;
	while(cin>>s,s!="#"){
		vector<string> v;

		for(int i=0;i<s.size();){
			if(s[i]=='n'){v.push_back("n"); i+=5;}
			else {v.push_back("w"); i+=4;}
		}

		reverse(v.begin(),v.end());

		double a;
		if(v[0]=="n") a=0.0;
		else a=90.0;

		for(int i=1;i<v.size();i++){
			if(v[i]=="n"){
				a-=90.0/(1<<i);
			}else{
				a+=90.0/(1<<i);
			}
		}

		long long aa=a*(1<<(v.size()-1));
		long long bb=1<<(v.size()-1);
		long long c=gcd(aa,bb);
		aa/=c; bb/=c;

		cout<<aa;
		if(bb!=1) cout<<"/"<<bb;
		cout<<endl;

	}

	return 0;
}

Measured memory_bytes: 1200
import java.util.Arrays;
import java.util.Scanner;

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

        long size = 0;
        int last = 0;
        for (int i = 0; i < n - 1; i++) {
            size += a[i];
            if (2 * size < a[i + 1]) {
                last = i + 1;
            }
        }
        System.out.println(n - last);
    }
}

Measured memory_bytes: 51696
program train;
var 
    a, b, c, d : longint;
begin
    read(a, b, c, d);
    while (a > 0) and (c > 0) do begin
        c := c - b;
       if c > 0
            then a := a - d;
        end;
    if a <= 0 
        then write('No')
        else write('Yes');
end.    

Measured memory_bytes: 1384
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e18+1;

int main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans=0;
    rep(i,10){
        rep(j,10){
            rep(k,10){
                ll cnt=0;
                vector<ll> a={i,j,k};
                rep(i,n){
                    if((s[i]-'0'==a[cnt])) cnt++;
                    if(cnt==3) break;
                }
                if(cnt==3){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    
} 

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

using namespace std;

void topologicalSort(int id, vector<vector<int>>& adj, vector<bool>& visited,
                     stack<int>& st) {
  visited[id] = true;
  for (int i = 0; i < adj[id].size(); ++i) {
    int nextId = adj[id][i];
    if (visited[nextId]) continue;
    topologicalSort(nextId, adj, visited, st);
  }
  st.push(id);
}

int main() {
  int N;
  int M;
  cin >> N >> M;
  vector<vector<int>> edges(M);
  for (int i = 0; i < M; ++i) edges[i].resize(2);
  for (int i = 0; i < M; ++i) cin >> edges[i][0] >> edges[i][1];
  vector<vector<int>> adj(N);
  for (int i = 0; i < M; ++i) {
    adj[edges[i][0] - 1].push_back(edges[i][1] - 1);
  }

  vector<bool> visited(N, false);
  stack<int> st;
  for (int i = 0; i < N; ++i) {
    if (visited[i]) continue;
    topologicalSort(i, adj, visited, st);
  }
  vector<int> sortedId;
  while (!st.empty()) {
    sortedId.push_back(st.top());
    st.pop();
  }
  vector<int> level(N, 0);
  int maxLevel = 0;
  for (auto id : sortedId) {
    for (auto out : adj[id]) {
      level[out] = max(level[out], level[id] + 1);
      maxLevel = max(level[out], maxLevel);
    }
  }
  cout << maxLevel;
}


Measured memory_bytes: 15148
#include <iostream>
#include <string>
int main() {
  int a[9];
  for(int i=0; i<9; i++) std::cin >> a[i];
  std::string ans ="No";
  if(a[1]-a[0] == a[4]-a[3] && a[2]-a[1] == a[5]-a[4]
  && a[4]-a[3] == a[7]-a[6] && a[5]-a[4] == a[8]-a[7])
  ans = "Yes";

  std::cout << ans+'\n';
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll x,y,a,b,c,A,ans;
vector<ll> v,u,r;
int main(void){
    cin>>x>>y>>a>>b>>c;
    for(int i=0;i<a;i++){
        cin>>A;
        v.push_back(A);
    }
    for(int i=0;i<b;i++){
        cin>>A;
        u.push_back(A);
    }
    for(int i=0;i<c;i++){
        cin>>A;
        r.push_back(A);
    }
    sort(v.begin(),v.end());
    sort(u.begin(),u.end());
    reverse(v.begin(),v.end());
    reverse(u.begin(),u.end());
    for(int i=0;i<x;i++){
        r.push_back(v[i]);
    }
    for(int i=0;i<y;i++){
        r.push_back(u[i]);
    }
    sort(r.begin(),r.end());
    reverse(r.begin(),r.end());
    for(int i=0;i<x+y;i++){
        ans+=r[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8048
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 100000;
int ls[maxn + 10];
int main()
{
	int n,c,k;
	scanf("%d%d%d",&n,&c,&k);
	for(int i = 1;i <= n;++i)
	{
		scanf("%d",&ls[i]);
	}
	sort(ls + 1,ls + 1 + n);
	int bus = ls[1] + k;
	int ans = 1;
	int peo = 1;
	for(int i = 2;i <= n;++i)
	{
		if(ls[i] > bus || peo >= c)
		{
			bus = ls[i] + k;
			++ans;
			peo = 0;
		}
		++peo;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>


using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	vector<int> p(n), q(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		q[i] = p[i];
	}
	bool ans = true;
	sort(q.begin(), q.end());
	int c = 0, a, b, m;
	
	for (int i = 0; i < n; i++) {
		if (p[i] == q[i]) c++;
	}
	if (c == n) {
		cout << "YES" << endl;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		if (p[i] != q[i]) {
			m = i;
			a = i;
			break;
		}
	}
	for (int i = m+1; i < n; i++) {
		if (p[i] != q[i]) {
			b = i;
			break;
		}
		else continue;
	}
	swap(p[a], p[b]);
	for (int i = 0; i < n; i++) {
		if (p[i] != q[i])ans = false;
	}
	if (ans) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

int main(){
	int cnt=0, x, n, i, j;
	bool flg;
	double rootx;
	int rootintx;
	cin>>n;
	for(i=0;i<n;i++){
		flg = true;
		cin>>x;
		if(x==2){
			cnt++;
			continue;
		}
		if(x<2 || !(x%2)){
			continue;
		}
		rootx = sqrt(x);
		rootx = ceil(rootx);
		rootintx = int(rootx);
		for(j=2;j<=rootintx;j++){
			if(!(x%j)){
				flg=false;
				break;
			}
		}
		if(flg)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#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
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;

int main(){
int N; cin >> N;
vector<int> A(N);
rep(i,N) cin >> A[i];
int cnt = 0;
rep(i,N){
	if(A[i] == A[i+1]){
		continue;
	}
	else if(A[i] > A[i+1]){
		while(A[i] >= A[i+1]){
			i++;
		}
		cnt++;
	}
	else{
		while(A[i] <= A[i+1]){
			i++;
		}
		cnt++;
	}
}
cout << cnt << endl;
}

Measured memory_bytes: 640
n, m = map(int, input().split())
apple = []
if m == 0:
    if n == 1:
        print(0)
    elif n == 2:
        print(10)
    else:
        print(100)
else:
    for _ in range(m):
        apple.append(list(map(int, input().split())))
    count = 0
    orange = [1] + [0]*(n-1)
    a = "a"
    for i in apple:
        for j in apple:
            if i[0] == j[0] and i[1] != j[1]:
                count = 1
                break
            else:
                orange[i[0] - 1] = i[1]
    if count == 1:
        print("-1")
    else:
        if len(orange) >= 2 and orange[0] == 0:
            print("-1")
        else:
            for i in orange:
                a += str(i)
            print(int(a[1:]))


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

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	bool d = false;
	rep(i, 0, s.length()-1) {
		if (s[i] == s[i+1])
			d = true;
	}
	cout << (d ? "Bad" : "Good") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
 #define PI 3.141592653
using namespace std;

int A[101];

void solve(){
	int n,k; cin>>n>>k;
	string s; cin>>s;
	int m=1;
	int ans=0;

	for(int i=0; i<n-1; i++){
		if(s[i] == s[i+1]){
			ans++;
		}
		else m++;
	}
	int q = (m/2 - 1 + m%2);
	ans += min(q,k)*2;
	if(k>q){
		ans += 1-m%2;
	}
	cout<<ans;


}


int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(12);
	int t =1; //cin>>t;
	for(int i=1; i<=t; i++){
		solve();
		cout<<"\n";
	}
	return 0;

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=3e6+5,M=1e7+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("color.in","r",stdin);
	freopen("data.out","w",stdout);
}
int head[N],cnt=1,a[N],b[N],vis[N],d[N],n,ans[N];
struct edge{int t,ne;}e[N];
void adde(int a,int b){
	d[a]++;d[b]++;
	e[++cnt]=(edge){b,head[a]};head[a]=cnt;
	e[++cnt]=(edge){a,head[b]};head[b]=cnt;
}
void dfs(int x){
	for(int&k=head[x];k;k=e[k].ne)if(!vis[k>>1]){
		vis[k>>1]=1;int v=e[k].t;
		dfs(v);
		if(v+n==x)ans[v]=-1;else
		if(x+n==v)ans[x]=1;
	}
}
int main(){int rta=0,rtb=0;
	read(n);rep(i,1,n)read(a[i]);rep(i,1,n)read(b[i]);
	rep(i,1,n)if(a[i]!=-1)adde(i,a[i]);else rta=i;
	rep(i,1,n)if(b[i]!=-1)adde(i+n,b[i]+n);else rtb=i+n;
	int rt=n+n+1;
	adde(rt,rta);adde(rt,rtb);
	rep(i,1,n)if(d[i]%2!=d[i+n]%2)return puts("IMPOSSIBLE"),0;
	puts("POSSIBLE");
	rep(i,1,n)if(d[i]&1)adde(i,i+n);
	dfs(rt);
	rep(i,1,n)printf("%d ",ans[i]);
}

Measured memory_bytes: 30336
n, k = gets.split.map(&:to_i)
t = gets.split.map(&:to_i)

i = 1
h = Hash.new
a = []
x = []
y = []
while true do
  index = h[i]
  if index.nil?
    h[i] = a.length
    a << i
    i = t[i - 1]
  else
    x = a[0, index]
    y = a[index, a.length - index]
    break
  end
end

if x.length > k
  p x[k]
else
  z = (k - x.length) % y.length
  p y[z]
end


Measured memory_bytes: 37992
#include <map>
#include <queue>
#include <algorithm>
#include <string>
#include <iostream>

using namespace std;

map<string, int> dp;
int MOVE[4] = {-1, 1, -4, 4};

bool check(int x){ return 0 <= x && x < 8; }

void bfs(){
	string s = "01234567";
	dp[s] = 0;
	queue<string> q;
	q.push(s);
	while(!q.empty()){
		string now = q.front();
		q.pop();
		int z = 0;
		for(int i = 1; i < 8; ++i){
			if(now[i] == '0'){
				z = i;
				break;
			}
		}
		
		for(int i = 0; i < 4; ++i){
			string next = now;
			int n = z + MOVE[i];
			if(check(n) && !(i == 0 && z == 4) && !(i == 1 && z == 3)){
				swap(next[n], next[z]);
				if(dp.count(next) == 0){
					q.push(next);
					dp[next] = dp[now] + 1;
				}
			}
		}
	}
}

int main(){
	bfs();
	string line;
	while(getline(cin, line)){
		line.erase(remove(line.begin(), line.end(), ' '), line.end());
		cout << dp[line] << endl;
	}
}


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

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

    //good luck kittu!
    ll a, b, k; cin>>a>>b>>k;
    if(k<=a) cout<<a-k<<" "<<b<<"\n";
    else if(k>a && k<=a+b) cout<<0<<" "<<b-k+a<<"\n";
    else cout<<"0 0\n";
    return 0;
}

Measured memory_bytes: 256
// たなこふ先生の input マクロ (´･_･`)
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s : usize,
    }

    let mut ans = 1;
    let mut s = s;
    let mut exist = vec![false; 1000001];

    while ! exist[s] {
        exist[s] = true;
        if s % 2 == 0 {
            s /= 2;
        } else {
            s = s * 3 + 1;
        }
        ans += 1;
    }

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int H,W,dp[2][1<<16],I;
string s[128];
bool B(int x,int i){return (x>>i)&1;}
int bc(int x){return x==0?0:__builtin_popcount(x);}
int main(){
	cin>>H>>W;
	rep(i,H) cin>>s[i];
	rep(b,1<<W) dp[0][b]=-1;
	dp[0][0]=0;
	rep(i,H){
		rep(j,W){
			rep(b,1<<W) dp[1-I][b]=-1;
			rep(b,1<<W){
				if(dp[I][b]<0) continue;
				//put
				int x=bc(b&((1<<j)-1));
				if(x<s[i].size()){
					int pl=0;
					if(i>0&&B(b,j)&&s[i-1][s[i-1].size()+x-bc(b)]==s[i][x]) pl+=2;//tate
					if(j>0&&B(b,j-1)&&s[i][x]==s[i][x-1]) pl+=2;//yoko
					chmax(dp[1-I][b|(1<<j)],dp[I][b]+pl);
				}
				//dont put
				chmax(dp[1-I][b&(~(1<<j))],dp[I][b]);
			}
			I=1-I;
		}
		rep(b,1<<W) if(bc(b)!=s[i].size()) dp[I][b]=-1;
	}
	int ans=0;
	rep(i,1<<W) chmax(ans,dp[I][i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 3712
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int h,w,i,j;
  char snuke[26][27][6];
  scanf("%d%d",&h,&w);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf("%s",snuke[i][j]);
      if(strcmp(snuke[i][j],"snuke")==0){
        printf("%c%d",j+65,i+1);
        exit(0);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<list>
#include<algorithm>
using namespace std;

int main()
{
  int q, x;
  char com[20];
  list<int> v;
  scanf("%d", &q);
  for (int i = 0; i < q; i++){
    scanf("%s", com);
    if (com[0] == 'i') {
      scanf("%d", &x);
      v.push_front(x);
    } else if (com[6] == 'L') {
      v.pop_back(); 
    } else if (com[6] == 'F') {
      v.pop_front();
    } else if (com[0] == 'd') {
      scanf("%d", &x);
      for (list<int>::iterator it = v.begin(); it != v.end(); it++){
	if (*it == x){
	  v.erase(it);
	  break;
	}
      }
    }
  }

  int i = 0;
  for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
    if (i++) printf(" ");
    printf("%d", *it);
  }
  printf("\n");
 
  return 0;
}



Measured memory_bytes: 33936
#include <iostream>

using namespace std;

int main(){
    int n, x;

    while(true){
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        int count = 0;
        for(int i=1; i<=n-2; i++){
            for(int j=i+1; j<=n-1; j++){
                for(int k = j+1; k<=n; k++){
                    if(x == i + j + k) count++;
                }                
            }
        }
        cout << count << endl;
    }

    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define lli long long int
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define se second;
#define fi first;
#define endl '\n';
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define REP(i,n) for (int i = 1; i <= n; i++)
template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
typedef long long ll;
typedef vector<vector<ll> > matrix;
const ll MOD = 1000000007;
const int K = 9;
const lli mod = 1e9 + 7;
const lli INF = 1e9 + 7;
const lli N=2*1e5;
lli visit[400001];
map<lli,vector<lli> >g;
map<string,lli>pi,m1,m2;
lli var1,var2,var3,var4,var5,var6;
vector<lli>v1,v2,v3,v4;
lli X[10][10];
lli w[N],v[N];
lli n,m,l,t,r,q,p,k,x,y,W;
lli ans=0,ans1=0,ans2=0,ans3=0;
lli dp[101][N],cp[N][5];
int main(){
  _
  cin>>n>>W;
  for(lli i=1;i<=n;i++){
    cin>>w[i]>>v[i];
    dp[0][i]=0;
    dp[i][0]=0;
  }
  for(lli i=1;i<=n;i++){
    for(lli j=1;j<=W;j++){
      if(w[i]<=j){
        dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
      }
      else{
        dp[i][j]=dp[i-1][j];
      }
    }
  }
  cout<<dp[n][W]<<endl;
}


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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if ((s[0] == s.back()) ^ (s.length() % 2)) {
        cout << "First";
    } else {
        cout << "Second";
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define DOW(i,b,a) for (int i = (b); i >= (a); i--)
#define pb(a) push_back(a)
#define ALL(a) (a).begin(),(a).end()
#define fi first
#define se second

template<typename T>
void print_array(T* arr, int num) {
   FOR(i, 0, num) cout << arr[i] << ' ';
   cout << endl;
}

template<typename T> 
void print_vector(vector<T> vec) {
   FOR(i,0,vec.size()) cout << vec[i] << ' ';
   cout << endl;
}

int n;
ll arr[60];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
   // freopen("test.txt", "r", stdin);
	cin >> n;
	FOR(i,0,n) cin >> arr[i];
	ll ans = 0;
	while (1) {
		int chk = 1;
		FOR(i,0,n) {
			ll cur = arr[i] / n;
			ans += cur;
			if (cur > 0) chk = 0;
			arr[i] = arr[i] % n;
			FOR(j,0,n) if (j != i) arr[j] += cur;
		}
		if (chk) break;
	}
	cout << ans;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

typedef complex<ld> Point;

const ld eps = 1e-9, pi = acos(-1.0);

namespace std {
  bool operator<(const Point &lhs, const Point &rhs) {
    if (lhs.real() < rhs.real() - eps) return true;
    if (lhs.real() > rhs.real() + eps) return false;
    return lhs.imag() < rhs.imag();
  }
}

bool eq(ld a, ld b) {
  return (abs(a - b) < eps);
}

ld dot(Point a, Point b) {
  return real(conj(a) * b);
}

ld cross(Point a, Point b) {
  return imag(conj(a) * b);
}

class Line {
public:
  Point a, b;
  Line () : a(Point(0, 0)), b(Point(0, 0)) {}
  Line (Point a, Point b) : a(a), b(b) {}
};

int ccw (Point a, Point b, Point c) {
  b -= a; c -= a;
  if (cross(b, c) > eps) return 1;
  if (cross(b, c) < -eps) return -1;
  if (dot(b, c) < 0) return 2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}

bool isis_ss(Line s, Line t) {
  return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
    ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

bool isis_sp (Line s, Point p) {
  return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}

Point proj (Line l, Point p) {
  ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + t * (l.a - l.b);
}

ld dist_sp (Line s, Point p) {
  Point r = proj(s, p);
  return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}

ld dist_ss (Line s, Line t) {
  if (isis_ss(s, t)) return 0;
  return min({dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b)});
}

int main(){
  int N, M, L;
  while(cin >> N >> M >> L && N) {
    M--;
    L--;
    vector<vector<Point>> star(N, vector<Point> (5));
    REP(i,N) {
      ld x, y, a, r;
      cin >> x >> y >> a >> r;
      a *= pi / 180;
      REP(j,5){
        star[i][j] = Point(x, y) + r * exp(Point(0,1) * (a + pi / 2 + j * 2 * pi / 5));
      }
    }

    vector<vector<ld>> d(N, vector<ld> (N, 0));
    REP(i,N)REP(j,N){
      ld tmp = INF;
      REP(k,5)REP(l,5){
        Line l1(star[i][k], star[i][(k + 2) % 5]);
        Line l2(star[j][l], star[j][(l + 2) % 5]);
        tmp = min(tmp, dist_ss(l1, l2));
      }
      d[i][j] = tmp;
    }

    REP(k,N)REP(i,N)REP(j,N) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    cout << fixed << setprecision(10) << d[M][L] << endl;
  }
  return 0;
}

Measured memory_bytes: 3664
#include<iostream>

using namespace std;

typedef long long ll;

const ll MAX = (1<<31)-1;

bool invalid(ll n){

  for(ll x = 1; 2*x*x <= n; x++)
    if((n-x)%(2*x+1) == 0)
      return false;

  return true;
}

int main(){

  ll ans = 0;
  ll n;
  cin >> n;
  for(int i = 0; i < n; i++){
    ll area;
    cin >> area;

    if(invalid(area)) ans++;

  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long n =sc.nextLong();
		int f = (int)Math.floor((double)500*sc.nextDouble());
		long temp = n*f;
		temp/=(long)500;
		System.out.println(temp);
	}
}


Measured memory_bytes: 37436
n, m = map(int, input().split())
q_list = [3] * n
p_count = 0
c_count = 0
#各問いについて[問題番号, WA数, ACしたかどうか]のリストを作る
for i in range(n):
    q_list[i] = [i, 0, False]

for j in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == 'WA':
        q_list[p][1] += 1
    elif s == 'AC' and q_list[p][2] == False:
        p_count += q_list[p][1]
        c_count += 1
        q_list[p][2] = True

print('{} {}'.format(c_count, p_count))

Measured memory_bytes: 16372
//GRL_2A
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define INF (1<<29)
 
static const int MAX=10000;

class DisjointSet{
 public:
  vector<int> rank,p;
   
  DisjointSet(){}
   
  DisjointSet(int size){
   rank.resize(size,0);
   p.resize(size,0);
   for(int i=0;i<size;i++) makeSet(i);
  }
 
  void makeSet(int x){
   p[x]=x;
   rank[x]=0;
  }
 
  bool same(int x,int y){
   return findSet(x)==findSet(y);
  }
 
  void unite(int x,int y){
   link(findSet(x),findSet(y));
  }
 
  void link(int x,int y){
   if(rank[x]>rank[y]){
    p[y]=x;
   }else{
    p[x]=y;
    if(rank[x]==rank[y]){
     rank[y]++;
    }
   }
  }
 
 
  int findSet(int x){
   if(x!=p[x]){
    p[x]=findSet(p[x]);
   }
   return p[x];
  }
};
 
class Edge{
public:
 int source,target,cost;
 Edge(int source=0,int target=0,int cost=0): source(source),target(target),cost(cost){}
 bool operator < (const Edge &e) const{
  return cost <e.cost;
 }
};

int kruskal(int N,vector<Edge> edges){
 int totalCost=0;
 sort(edges.begin(),edges.end());
 DisjointSet dset=DisjointSet(N+1);
 for(int i=0;i<N;i++) dset.makeSet(i);
 int source,target;
 for(int i=0;i<edges.size();i++){
  Edge e=edges[i];
  if(!dset.same(e.source,e.target)){
   totalCost+=e.cost;
   dset.unite(e.source,e.target);
  }
 }
 return totalCost;
}

int main(){
 int N,M,cost;
 int source,target;
 cin>>N>>M;
 vector<Edge> edges;
 for(int i=0;i<M;i++){
  cin>>source>>target>>cost;
  edges.push_back(Edge(source,target,cost));
 }
 
 cout<<kruskal(N,edges)<<endl;
 return 0;
}

Measured memory_bytes: 3616
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int a = sc.nextInt(), b = sc.nextInt();
		System.out.println(Math.max(0, a - 2 * b));
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
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(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    lint K;
    scanf("%lld", &K);
    int n = 1;
    while((lint)n*(n+1)/2 < K) ++n;
    K = (lint)n*(n+1)/2 - K;
    int L = n;
    while(L && K >= L){
        K -= L;
        --L;
    }
    rep(i, n-L) printf("%s", "()");
    rep(i, L-K) printf("%c", ')');
    printf("%c", '(');
    rep(i, K) printf("%c", ')');
    rep(i, L-1) printf("%c", '(');
    printf("\n");
}


Measured memory_bytes: 3156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;

int main() {
	ll dp[35] = {};
	dp[0] = 1;
	REP(i, 30) {
		dp[i+1] += dp[i];
		dp[i+2] += dp[i];
		dp[i+3] += dp[i];
	}
	int n;
	while(cin >> n, n)
		cout << dp[n] / 3650 + 1 << endl;
	return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
    #include <string.h>
    #include <math.h>

    int isPrime(int x);

    int main(void)
    {
        int i,ans = 0;
        int n,a;

        scanf("%d",&n);
                
        for(i=0;i<n;i++){
            scanf("%d",&a);
            if(isPrime(a) == 1){ans = ans+1;}
        }
        
        printf("%d\n",ans);

        return 0;
    }

    int isPrime(int x){
        int i;
        if(x == 2){return 1;}
        else if( (x < 2) || (x % 2 == 0) ){return 0;}
        
        i = 3;
        while(i <= sqrt(x) ){
            if(x % i == 0){return 0;}
            i = i + 2;
        }
        return 1;
    }



Measured memory_bytes: 2040
N,M = map(int,input().split())
H = list(map(int,input().split()))

data = [[] for i in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    A -= 1
    B -= 1
    data[A].append(B)
    data[B].append(A)

ans = 0

for i in range(N):
    det = 1
    for x in data[i]:
        if H[i] <= H[x]:
            det = 0
            break
    ans += det

print(ans)

Measured memory_bytes: 92856
import sys
def main():
    input = sys.stdin.readline

    dic = set()
    n = int(input())
    ans = []
    for a in range(n):
        s = input()
        if "\n" in s:
            s = s[:-1]
        if s[0] == "i":
            dic.add(s[7:])
        else:
            ans.append("yes" if s[5:] in dic else "no")
    print("\n".join(ans))

if __name__ == "__main__":
    main()


Measured memory_bytes: 37348
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;

int main(void)
{
	int N; cin >> N;
	vector<int> sub(N, 0);
	rep(i, 1, N) {
		int a; cin >> a;
		sub[a - 1]++;
	}
	rep(i, 0, N)cout << sub[i] << endl;

	return 0;
}


Measured memory_bytes: 4048
n = int(input())
a = [int(i) for i in input().split()]
fuck = dict()
for i in range(1, n + 1):
    fuck[i] = []

for i in range(2, n + 1):
    fuck[a[i - 2]].append(i)


for i in range(1, n + 1):
    print(len(fuck[i]))

Measured memory_bytes: 129000
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

vector<bool> era(1000010, true);
void makePrimeTable(int n)
{
	era[0] = false; era[1] = false;
	for (int i = 2; i <= n; i++)
	{
		if (era[i]) { for (int j = i * 2; j <= n; j += i) { era[j] = 0; } }
	}
}
int main()
{
	makePrimeTable(1000000);
	while (1)
	{
		int n = 0; cin >> n;
		if (n == 0) { break; }
		int num = 0;
		for (int i = n + 1; i < 2 * n; i++)
		{
			if (era[i]){ num += 1; }
		}
		if (n == 1) { num += 1; }
		printf("%d\n", num);
	}
}

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

int main() {
  int64_t N;
  cin >> N;
  int64_t cnt = 0;
  for (int i = 1; i < 100; i++){
    int64_t base = pow(5, i) * 2;
    if (N < base){
      break;
    }
    else {
      cnt += N / base;
    }
  }
  if (N % 2 == 1){
    cout << 0 << endl;
  }
  else {
    cout << cnt << endl;
  }
}


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

int main() {
  int N; cin >> N;
  vector<int> vx(N), vy(N), vh(N);
  int si = -1;
  for (int i = 0; i < N; i++) {
    cin >> vx[i] >> vy[i] >> vh[i];
    if (vh[i] > 0) si = i;
  }
  
  int resx = -1, resy = -1, resh = -1;
  for (int Cx = 0; Cx <= 100; Cx++) {
    for (int Cy = 0; Cy <= 100; Cy++) {
      int h = vh[si] + abs(Cx-vx[si]) + abs(Cy-vy[si]);
      bool ok = true;
      
      for (int i = 0; i < N; i++) {
        if (vh[i]>0 && h-vh[i]!=abs(Cx-vx[i])+abs(Cy-vy[i])) {
          ok = false;
        }
        if (vh[i]==0 && h>abs(Cx-vx[i])+abs(Cy-vy[i])) {
          ok = false;
        }
      }
      if (ok) resx = Cx, resy = Cy, resh = h;
    }
  }
  cout << resx << " " << resy << " " << resh << endl;
  return 0;
}

Measured memory_bytes: 256
A, B, C = map(int, input().split())
count = 0
while not A == B == C:
	A, B, C = sorted([A, B, C])
	if C - A > 1:
		A += 2
		count += 1
	else:
		A += 1
		B += 1
		count += 1
print(count)

Measured memory_bytes: 2940
def main():
  n = int(raw_input())
  vote_a, vote_b = 1, 1

  for i in xrange(n):
    a, b = [int(x) for x in raw_input().split()]
    mult = max(1+(vote_a-1)/a, 1 + (vote_b-1)/b)
    vote_a, vote_b = mult*a, mult*b

  print(vote_a+vote_b)


main()

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  
  bool can = false;
  int i = 0;
  while (!can) {
    i++;
    if (a*i % b == c) {
      can = true;
      break;
    }
    if (i == a*b) break;
  }
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256