akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

int main() {
    int A[3][3], N, b;
    rep(i, 3) rep(j, 3) cin >> A[i][j];
    cin >> N;
   vector<vector<bool>> c(3, vector<bool>(3, false));
    rep(i, N) {
        cin >> b;
        rep(j, 3) rep(k, 3) if (A[j][k] == b) c[j][k] = true;
    }
    string ans = "No\n";
    if (c[0][0] && c[1][1] && c[2][2]) ans = "Yes\n";
    if (c[0][2] && c[1][1] && c[2][0]) ans = "Yes\n";
    rep(i, 3) {
        if (c[i][0] && c[i][1] && c[i][2]) ans = "Yes\n";
        if (c[0][i] && c[1][i] && c[2][i]) ans = "Yes\n";
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<long long> a(n,0);
	vector<long long> b(n,INT_MAX);

	for (int i=0; i<n-1; i++)
		cin >> b[i];

	for (int i=0; i<=n-1; i++){
		if (i == 0)
			a[i] = b[i];
		else if (i == n)
			a[i] = b[n-1];
		else
			a[i] = min(b[i-1],b[i]);
	}

	long long sum = 0;
	for (int i=0; i<n; i++)
		sum += a[i];

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import math
sys.setrecursionlimit(10000)

mod = 10**9 + 7

n, m = map(int, input().split())
cnt = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    cnt[a - 1] += 1
    cnt[b - 1] += 1
for i in range(n):
    print(cnt[i])


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

using namespace std;

int main(){
	int n;
	cin >> n;
	
	vector<int> a;
	int men = 1000000, bol = -1000000;
	int mp = -1, bp = -1;
	for(int i = 0;i < n;i++){
		int ai;
		cin >> ai;
		a.push_back(ai);
		
		if(men > ai){
			men = ai;
			mp = i;
		}
		if(bol < ai){
			bol = ai;
			bp = i;
		}
	}
	
	vector<pair<int, int> > hist;
	
	bool tf;
	if(bol > 0 && men > 0) tf = true;
	else if(bol < 0 && men < 0) tf = false;
	else tf = (bol+men > 0);
	
	if(tf){
		for(int i = 0;i < n;i++){
			if(a[i] < 0){
				hist.push_back(pair<int, int>(bp, i));
				a[i] += a[bp];
			}
		}
		
		for(int i = 1;i < n;i++){
			if(a[i-1] > a[i]){
				hist.push_back(pair<int, int>(i-1, i));
				a[i] += a[i-1];
			}
		}
	}else{
		for(int i = 0;i < n;i++){
			if(a[i] > 0){
				hist.push_back(pair<int, int>(mp, i));
				a[i] += a[mp];
			}
		}
		
		for(int i = n-2;i >= 0;i--){
			if(a[i+1] < a[i]){
				hist.push_back(pair<int, int>(i+1, i));
				a[i] += a[i+1];
			}
		}
	}
	
	cout << hist.size() << endl;
	for(int i = 0;i < hist.size();i++){
		cout << hist[i].first+1 << " " << hist[i].second+1 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
a = [ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 ] ;

x = int( input().strip() ) ;
print ( a[x-1] ) ;

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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl "\n"

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
	while(x!=parent[x]){
		parent[x] = parent[parent[x]];
		x = parent[x];
	}
	return x;
}

void sunion(int x,int y){
	int rx = root(x);
	int ry = root(y);
	if(rx != ry){
		if(Size[rx] > Size[ry]){
			parent[ry] = parent[rx];
			Size[rx] += Size[ry];
		}
		else{
			parent[rx] = parent[ry];
			Size[ry] += Size[rx];
		}
	}
}
*/



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc=1;
	//cin >> tc;
	const int N = 1000;
	int lp[N+1];
	vector<int> pr;

	for (int i=2; i<=N; ++i) {
		if (lp[i] == 0) {
			lp[i] = i;
			pr.push_back (i);
		}
		for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
			lp[i * pr[j]] = pr[j];
	}
	while(tc--){
		int n;
		cin >> n;
		int a[n];
		for (int i=0;i<n;i++) cin >> a[i];
		map <int,int> c;
		for (auto x : a) {
			int t = x;
			for (int j=0;j<(int)pr.size() && pr[j]*pr[j]<=t;j++) {
				if (t%pr[j] == 0) c[pr[j]]++;
				while (t%pr[j] == 0) t /= pr[j];
			}
			if (t != 1) c[t]++;
		}
		bool ok=true;
		for (auto x : c) {
			if (x.second >= 2) {
				ok = false;
				break;
			}
		}
		
		if (ok) cout << "pairwise coprime\n";
		else {
			int g=a[0];
			for (int i=0;i<n;i++) g = __gcd(g,a[i]);
			if (g == 1) cout << "setwise coprime\n";
			else cout << "not coprime\n";
		}
	}
	return 0;
}


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

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

    vector<int> a(n);
    int sum = 0, prev = 0;
    bool flg = true;
    for (auto i = 0; i < n; i++) {
        cin >> a[i];
    }

    uint64_t ans = UINT64_MAX, count;
    int tmp;
    for (auto i = 0; i < 2; i++) {
        bool plus = (i % 2 == 0);
        sum = 0;
        count = 0;
        for (auto j = 0; j < n; j++) {
            if ((plus and sum + a[j] > 0) or (not plus and sum + a[j] < 0)) tmp = a[j];
            else {
                if (plus) tmp = 1 - sum; // sum + a[i] <= 0
                else tmp = -1 - sum; // sum + a[i] >= 0
                count += abs(tmp - a[j]);
            }
            sum += tmp;
//            cout << "a[" << j << "]=" << a[j] << ", plus=" << plus << ", sum=" << sum
//                 << ", tmp=" << tmp << ", count=" << count << endl;
            plus = not plus;
        }
        if(ans > count) ans = count;
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
    string s; cin >> s;
    if(s.size()< 26){
        set<char> st;
        for(char i = 'a'; i<='z'; ++i)
            st.insert(i);
        for(char c : s)
            st.erase(c);
        char mn = 'z';
        for(char c : st)
            mn = min(mn,c);
        cout << s << mn << endl;
    } else if(s=="zyxwvutsrqponmlkjihgfedcba"){
        cout << "-1" << endl;
    } else {
        string cs = s;
        next_permutation(cs.begin(),cs.end());
        for(int i = 0; i < s.size(); ++i)
            if(cs[i]==s[i])
                cout << cs[i];
            else{
                cout << cs[i];
                break;
            }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math
N,D=map(int,input().split())
d=[None]*N
for i in range(N):
  d[i]=list(map(int,input().split()))

ans=0
for i in range(N-1):
  for j in range(i+1,N):
    sum=0
    for p in range(D):
      sum=sum+(d[i][p]-d[j][p])**2
    if (math.sqrt(sum)).is_integer():
      ans=ans+1
print(ans)

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

using namespace std;
#define _rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define _rev(i, a, b) for (ll i = (a); i >= (b); --i)
#define _for(i, a, b) for (ll i = (a); i < (b); ++i)
#define _rof(i, a, b) for (ll i = (a); i > (b); --i)
#define oo 1e18
#define ll long long
#define db long double
#define eps 1e-9
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define pi acos(-1.0)
#define endl "\n"
#define lowbit(x) x &(-x)
const ll mod = 998244353;
const ll maxn = 1e5 + 10;
ll n, m;
vector<pii> G[maxn];
ll d[maxn];
void dij(ll s = 1) {
	priority_queue<pii> q;
	fill(d, d + 1 + n, oo);
	d[s] = 0;
	q.push(make_pair(0, s));

	while (!q.empty())
	{
		ll cur = q.top().second;
		ll dis = -q.top().first;
		q.pop();

		_for(i, 0, G[cur].size()) {
			ll to = G[cur][i].first, c = G[cur][i].second;
			if (d[to] > d[cur] + c) {
				d[to] = d[cur] + c;
				q.push(make_pair(-d[to], to));
			}
		}
	}

}
vector<ll> a(maxn), b(maxn), k(maxn);
signed main() {

	ll  x, y;
	cin >> n >> x >> y;

	_rep(i, 1, n - 1) {
		ll u = i, v = i + 1;
		G[u].push_back(make_pair(v, 1));
		G[v].push_back(make_pair(u, 1));
	}
	G[x].push_back(make_pair(y, 1)), G[y].push_back(make_pair(x, 1));
	ll cnt = 0;
	_rep(i, 1, n) {
		dij(i);
		_rep(j, 1, n) {
			k[d[j]]++;
		}
	}
	_rep(i, 1, n - 1) {
		cout << k[i] / 2 << endl;
	}


}

Measured memory_bytes: 5120
import java.util.*;
import static java.lang.System.*;

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(in);
    int N = sc.nextInt();
    int A[] = new int[N];
    for(int i=0; i<N; i++) A[i] = sc.nextInt();
    int i = N - 1;
    while(i >= 0){
      out.print(A[i] + " ");
      i -= 2;
    }
    if(N % 2 == 0) i = 0;
    else i = 1;
    while(i < N){
      out.print(A[i] + " ");
      i += 2;
    }
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

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

int main(){
  
  ll n,W;
  cin >> n >> W;
  
  ll*w = new ll[n];
  ll*v = new ll[n];
  
  for( ll i=0 ; i<n ; i++ ){
  	cin >> w[i] >> v[i];
  }
  
  ll** dp = new ll*[2];
  
  for( ll i=0; i<2 ; i++ ){
  	dp[i] = new ll[W+1];
  	for(ll j=0 ; j<W+1 ; j++)
  		dp[i][j] = 0;
  }
  
  bool flag = true;
  
  for(ll i=1 ; i<=n ; i++){
  	for(ll j=0 ; j<=W ; j++){
  		
  		int val1;
  		int val2;
  		if(flag){
  			val1 = 1;
  			val2 = 0;
  		}
  		if(!flag){
  			val1 = 0;
  			val2 = 1;
  		}
  		
  		if(w[i-1] <= j){
  			dp[val1][j] = max( dp[val2][j], dp[val2][j-w[i-1]] + v[i-1] );
  		}else{
  			dp[val1][j] = dp[val2][j];
  		}	
  	}
  	flag=!flag;
  }
  
  if(flag){
  	cout << dp[0][W] << endl;
  }else{
  	cout << dp[1][W] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 5220
#include <iostream>
using namespace std;
int main(){
	long long a,b,min1(999999999);
	cin>>a>>b;
	for(long long i=a;i<b;i++){
		for(long long j=i+1;j<=b;j++){
			if((i*j)%2019<min1) min1=(i*j)%2019;
			if(!min1) break;
		}
		if(!min1) break;
	}
	cout<<min1;
}

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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define MOD 1000000007
#define PI 3.14159265359
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
const int MAX = 10000007; 
  
int factor[MAX] = { 0 }; 
  
void generatePrimeFactors() 
{ 
    factor[1] = 1; 
  
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
  
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 

    for (int i = 3; i * i < MAX; i++) { 

        if (factor[i] == i) { 
             
            for (int j = i * i; j < MAX; j += i) { 
                
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
} 
  
ll calculateNoOFactors(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    ll ans = 1; 
  
 
    int dup = factor[n]; 
  
  
    int c = 1; 
  
  
    int j = n / factor[n]; 
  

    while (j != 1) { 
    
        if (factor[j] == dup) 
            c += 1; 
  
        else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
  
        j = j / factor[j]; 
    } 
 
    ans = ans * (c + 1); 
  
    return ans; 
} 
void test()
{
	generatePrimeFactors();

	int n;
	ll ans=0;
	cin>>n;

	for(int i=1;i<=n;i++)
	{
	    ans+=i*calculateNoOFactors(i);
	    //cout<<ans<<endl;
	}

	cout<<ans<<endl;
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

//cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

Measured memory_bytes: 42660
use std::io;

fn main() {
    let n = read_one::<usize>();
    let ans = (n as f64 / 2f64).ceil() as usize - 1;
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define PI 3.141592653589793
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

double a, b, x;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> a >> b >> x;

  double ans = 0.0;
  if (a * a * b <= 2 * x) {
    double h = (b - (x / (a * a))) * 2;
    ans = atan2(h, a) * 180.0 / PI;
  } else {
    double w = x / (a * b) * 2;
    ans = atan2(b, w) * 180.0 / PI;
  }

  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    
    long long int n,r,result;
    cin>>n >>r;
    if(n<=9){
        result=r+(100*(10-n));
    }else{
        result=r;
    }

    
    cout<<result<<endl;
    return 0;
}


Measured memory_bytes: 888
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#ifndef JHELPER_EXAMPLE_PROJECT_DEFINITION_HPP
#define JHELPER_EXAMPLE_PROJECT_DEFINITION_HPP

#include <bits/stdc++.h>

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

#endif //JHELPER_EXAMPLE_PROJECT_DEFINITION_HPP


class BFizzBuzzSum {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll N;
        in >> N;
        ll ans = 0;
        for (int i = 1; i <= N; ++i) {
            if (i % 3 == 0 || i % 5 == 0) continue;
            ans += i;
        }
        out << ans << '\n';
    }
};


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

	BFizzBuzzSum solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;

#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define sz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define vec vector
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);


void solve(){
	int n, k;
	ll ans, c[30];
	vec<bool> v;
	string s;
	
	ans = 0;
	cin >> n >> k;
	cin >> c[18] >> c[15] >> c[17];
	cin >> s;
	v.rs(n);
	
	rep(i,n){
		if(i<k || s[i-k] != s[i] || v[i-k] == 0){
			ans += c[s[i] - 'a'];
			v[i] = 1;
		}
	}
	cout << ans << '\n';
}

int main(){
	int t = 1;
	
	while(t--){
		solve();
	}
}




Measured memory_bytes: 512
def solve():

    N = int(input())

    wlist = [input() for i in range(N)]
    s = set(wlist)

    if len(wlist) != len(s):
        print("No")
        exit()
    else:
        last = wlist[0][-1]
        for i in range(1, N):
            ini = wlist[i][0]
            if last != ini:
                print("No")
                exit()
            last = wlist[i][-1]

    print("Yes")


if __name__ == "__main__":
    solve()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n; i++)
#define all(v) (v).begin(), (v).end()
#define decimal fixed << setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;

template< int mod >
struct ModInt
{
  int x;

  ModInt() : x(0) {}

  ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p)
  {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p)
  {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p)
  {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p)
  {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const
  {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return ModInt(u);
  }

  friend ostream &operator<<(ostream &os, const ModInt< mod > &p)
  {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt< mod > &a)
  {
    long long x;
    is >> x;
    a = ModInt< mod >(x);
    return (is);
  }

};

const int mod = 1e9 + 7;
using modint = ModInt< mod >;


int main(){
    int n;
    cin >> n;
    vector<int> c(1);
    cin >> c[0];
    rep1(i, n){
        int x;
        cin >> x;
        if(x != c[c.size()-1]) c.push_back(x);
    }
    vector<modint> mk(200010, 0);
    modint ans = 1;
    rep(i, c.size()){
        ans += mk[c[i]];
        mk[c[i]] = ans;
    }
    cout << ans << endl;



}


Measured memory_bytes: 1908
#define _GLIBCXX_DEBUG

#include"bits/stdc++.h"
using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//bitsearch
#define BITSEARCH(bit, n) for (int bit = 0; bit < (1<<n); ++bit)
#define isOne(bit, i) bit & (1<<i)


//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back

template<typename T>
std::vector<T> slice(std::vector<T> const &v, int m, int n)
{
    auto first = v.cbegin() + m;
    auto last = v.cbegin() + n + 1;

    std::vector<T> vec(first, last);
    return vec;
}

#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//comparision
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//pair
#define fir first
#define sec second
#define mp make_pair

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(long long a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T = int>
void print(vec<T> v){ cout << v << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//maths
int factorial(int k){ int sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; } return sum; }
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

void Main() {
    //code here
    int a = gi, b = gi, c = gi;
    print(max(0, c-(a-b)));
}


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 998244353;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int n;
pii R[mn];
vector <pii> stck = {{0, inf}};
int par[mn]; // parent of each node
vector <int> child[mn];
int dp[mn];
void dfs(int u) {
    dp[u] = 1;
    for (int v: child[u]) {
        dfs(v);
        dp[u] = (dp[u] * (dp[v] + 1))%mod;
    }
}
// main solution goes here:
void execute(int test_number)
{
    cin>>n;
    for (int i=1; i<=n; i++) {
        cin>>R[i].XX>>R[i].YY;
        R[i].YY += R[i].XX;
    }
    sort(R+1, R+n+1);
    for (int i=1; i<=n; i++) {
        while (stck.back().YY <= R[i].XX) stck.pop_back();
        par[i] = stck.back().XX;
        stck.push_back({i, R[i].YY});
    }
    for (int i=1; i<=n; i++) child[par[i]].push_back(i);

    dfs(0);
    cout<<dp[0];

}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

Measured memory_bytes: 36016
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=3e5+7;
const int mod=1e9+7;
int sum[maxn],a[maxn],c[maxn];
main()
{
    int n;
    cin>>n;
    sum[0ll]=0ll;
    int tmp=0ll;
    sum[n+1ll]=0ll;
    for(int i=1ll;i<=n;++i)
    {
        cin>>a[i];
        sum[i]=sum[i]^a[i];
        tmp+=a[i];
        tmp%=mod;
    }
    int ans=0ll;
    for(int k=0ll;k<=60;k++)
    {
        c[0ll]=1ll,c[1ll]=0ll;
        for(int i=1ll;i<=n;++i)
        {
            int v=(sum[i]&(1ll<<k))?1ll:0ll;
            ans=(ans+((1ll<<(k))%mod*c[v^1ll])%mod)%mod;
            c[v]++;
        }
    }
    cout<<((ans-tmp+mod)%mod)<<endl;
    return 0ll;
}


Measured memory_bytes: 5248
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for y in range(H):
        if y == 0 or y == H - 1:
            print('#' * W)
        else:
            print('#' + '.' * (W - 2) + '#')
    print()


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define f(i,a,b) for(int i=a; i<b; i++)
using namespace std;

int main()
{
    IOS
    int n, flag = 0;
    cin>>n;
    f(i, 1, 10)
    {
    	if(n%i == 0 && n/i <= 9 && n/i > 0) flag++;
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define ll long long 
const int MAX=1e5+5;
int a[MAX],b[MAX],c[MAX];
int n,m,k;
void inti()
{
	for(int i=0;i<=n;i++)
	a[i]=i,b[i]=1;
}
int finds(int x)
{
return a[x]==x?x:a[x]=finds(a[x]);
}
void Union(int x,int y)
{
	int fx=finds(x),fy=finds(y);
	if(fx!=fy)
	a[fy]=fx,b[fx]+=b[fy];
}

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m>>k;
	inti();
	int x,y;
	while(m--)
	{
		cin>>x>>y;
		c[x]++;c[y]++;
		Union(x,y);
	}
	while(k--)
	{
		cin>>x>>y;
		if(finds(x)==finds(y))
		{
			c[x]++;c[y]++;
		}
	}
	for(int i=1;i<=n;i++)
	cout<<b[finds(i)]-c[i]-1<<" ";
}


Measured memory_bytes: 2688
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;

int main() {
	stack<int> S;
	int a, b, x;
	string s;

	while (cin >> s) {
		if (s[0] == '+') {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a + b);
		}
		else if (s[0] == '-') {
			b = S.top(); S.pop();
			a = S.top(); S.pop();
			S.push(a - b);
		}
		else if (s[0] == '*') {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a * b);
		}
		else {
			S.push(atoi(s.c_str()));
		}
	}

	cout << S.top() << endl;

	return 0;
}


Measured memory_bytes: 3216
from collections import deque


def main():
    n = int(input())
    tree = AdjacentListGraph([Vertex() for _ in range(n)])
    for _ in range(n - 1):
        a, b, c = map(int, input().split())
        tree.add_edge(a - 1, b - 1, c)
        tree.add_edge(b - 1, a - 1, c)
    q, k = map(int, input().split())
    distances = distances_from(tree, k - 1)
    # print(distances)
    answers = []
    for _ in range(q):
        x, y = map(int, input().split())
        answers.append(distances[x - 1] + distances[y - 1])
    print("\n".join(map(str, answers)))


def distances_from(
    graph: "Graph", from_: int, break_if=lambda node: False
) -> "List[int]":
    distances = [None for _ in range(graph.size)]
    distances[from_] = 0
    queue = deque([from_])
    while queue:
        node = queue.popleft()
        if break_if(node):
            break
        curDist = distances[node]
        for edge in graph.edges_from(node):
            if distances[edge.to] is not None:
                continue
            delta = edge.weight if edge.weight else 0
            distances[edge.to] = curDist + delta
            queue.append(edge.to)
    return distances


class Vertex:
    def __init__(self, data=None):
        self.data = data
        self.edges = []

    def add_edge(self, to, weight=None):
        self.edges.append(Edge(to, weight))

    def remove_edge(self, to: int) -> bool:
        for i, edge in enumerate(self.edges):
            if edge.to == to:
                del self.edges[i]
                return True
        return False


class Edge:
    def __init__(self, to, weight=None):
        self.to = to
        self.weight = weight


class AdjacentListGraph:
    def __init__(self, vertices):
        self.vertices = vertices
        self.size = len(vertices)

    def get_weight(self, from_: int, to: int):
        for edge in self.vertices[from_].edges:
            if edge.to == to:
                return edge.weight
        return None

    def edges_from(self, from_: int):
        return self.vertices[from_].edges

    def add_edge(self, from_: int, to: int, weight=None) -> bool:
        return self.vertices[from_].add_edge(to, weight)

    def remove_edge(self, from_: int, to: int) -> bool:
        return self.vertices[from_].remove_edge(to)

    def is_adjacent(self, from_: int, to: int) -> bool:
        return to in {edge.to for edge in self.edges_from(from_)}


if __name__ == "__main__":
    main()


Measured memory_bytes: 92796
using System;
using System.IO;
using System.Collections.Generic;

namespace NTL1E
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            int x, y; //long行かない？
            MathX.GcdEx(ss.Next(Int), ss.Next(Int), out x, out y);
            sw.WriteLine(x + " " + y);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, int> Int = int.Parse;
    }

    public static partial class MathX
    {
        public static int GcdEx(int a, int b, out int x, out int y)
        {
            if (b == 0)
            {
                x = 1;
                y = 0;
                return a;
            }

            int tx, ty;
            var gcd = GcdEx(b, a % b, out tx, out ty);

            x = ty;
            y = tx - ty * (a / b);
            return gcd;
        }
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }
    }
}


Measured memory_bytes: 10456
from heapq import heappush, heappop
N,M = map(int, input().split())
A = {}
prefs = []
years = []
for i in range(M):
    p,y = input().split()
    prefs.append(p)
    years.append(y)
    if p not in A:
        A[p] = [int(y)]
    else:
        heappush(A[p], int(y))
res = {}
for k,v in A.items():
    for i in range(len(v)):
        res[k+str(heappop(v))] = str(i+1)
for p,y in zip(prefs, years):
    print(p.zfill(6) + res[p+y].zfill(6))


Measured memory_bytes: 60704
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N, A, B = list(map(int, input().split()))
sum_all = 0

for n in range(1, N+1):
    sum = 0
    n_ = n
    while n_ > 0:
        sum += n_ % 10
        n_ //= 10
    if A <= sum <= B:
        sum_all += n
print(sum_all)


Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<double> p(n);
    rep(i,n) cin>>p[i];
    double dp[n+10][n+10];
    rep(i,n+10) rep(j,n+10) dp[i][j]=0;
    dp[0][0]=1;
    for(int k=0;k<n;k++){
        for(int i=0;i<=k;i++){
            int j=k-i;
            dp[i+1][j]+=dp[i][j]*p[k];
            dp[i][j+1]+=dp[i][j]*(1-p[k]);
        }
    }
    double ans=0;
    rep(i,n+1){
        int j=n-i;
        if(i>j){
        ans+=dp[i][j];
        }
    }
    cout<<ans<<endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++){
  	cin >> d.at(i);
  }
  map<int, int> backet;
  for(int i = 0; i < N; i++){
  	if(!backet.count(d.at(i))) backet[d.at(i)] = 1;
    else backet.at(d.at(i)) += 1;
  }
  int total = 0;
  for(int i =1; i <= 100; i++){
  	if(backet.count(i)) total++;
  }
  cout << total << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    vector<int> a(n);
    ll i,j;
    ll ev=0,od=0;
    ll iti=0;
    for(i=0;i<n;i++){
        cin >> a.at(i);
        if(a.at(i)%2==1)od++;
        if(a.at(i)%2==0)ev++;
    }
    ll count;
    count = pow(3,n);
    ll odds;
    odds=pow(2,ev);
    cout << count - odds<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pdd pair<double, double>
#define V vector<int>
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define db(x) cout << #x << "=" << (x) << endl
#define db2(x, y) cout << #x << "=" << (x) << " " << #y << "=" << (y) << endl
#define db3(x, y, z) cout << #x << "=" << (x) << " " << #y << "=" << (y) << " " << #z << "=" << (z) << endl

using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 7;
const double eps = 1e-9;

int main()
{
    #ifdef AFei
    freopen("in.txt", "r", stdin);
    #endif

    int N, K;
    cin >> N >> K;
    int ans = 0;
    for(int x, i = 0; i < N; ++ i)
    {
        cin >> x;
        ans += x >= K;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.next();
			String t = scanner.next();

			int result = 0;
			for (int i = 0; i < s.length(); i++) {
				if (s.charAt(i) == t.charAt(i)) {
					result++;
				}
			}

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

Measured memory_bytes: 21588
/*
 * URL 		: https://atcoder.jp/contests/dp/tasks/dp_e
 * DATE		: 27th Jan, 2019
 */

//___________________________________________________________________________________________________________
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;

#define rep(i,a,b)  for(int i=a; i<b; i++)
#define req(i,a,b)  for(int i=b-1; i>=a; i--)
#define trv(it,s)   for(auto it=s.begin(); it!=s.end(); it++)
#define trs(it,s)   for(auto &it : s)

#define endl        '\n'
#define pb          push_back
#define F           first
#define S           second
#define ll          long long
#define pii         pair<int,int>
#define vpii        vector<pii>
#define vi          vector<ll>
#define vii         vector<vector<ll>>
#define mi          map<int,int>
#define umap        unordered_map
#define uset        unordered_set
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define fil(a,x)    memset(a,x,sizeof(a))
#define num1(x)     __builtin_popcount(x)

#define db(a)       cout<<"---DEBUG : "<<a<<"\n"
#define wa(x)       cout << (#x) << " -------- " << (x) << endl
#define line1	    printf("---------------------------------------\n")
#define line2	    printf("_______________________________________\n")

#define MOD         1000000007 
#define PI          2 * acos(0.0)

//#define int 		long long
//#define printf      //

//___________________________________________________________________________________________________________
void pmap(auto l){
	trv(itt,l) printf("%d %d\n", itt->fi, itt->se);
	line1;
}

void pvi(vector<int> pvec, string name="") {
	if(name != "") cout<<"Output of "<<name<<" : ";
	for(int i=0;i<pvec.size();i++) cout<<pvec[i]<<" ";
	cout<<endl;
}

int gcd(int n,int m) {return m==0?n:gcd(m,n%m);}

int o(ll a) {return a%MOD;}

ll mpow(ll base, ll power){
	if(power==0) return 1;
	if(power==1) return base;
	ll exp = mpow(base,power/2);
	exp = exp*exp;
	if(power%2==1) exp = exp * base;
	return exp;
}
//___________________________________________________________________________________________________________

void solve();

int32_t main() {

//	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int notc = 1; 
//	cin>>notc;

	while(notc--) {
		solve();
		//printf("========================================================\n");
	}
}
//___________________________________________________________________________________________________________


int n,w;
vpii v;
vii dp;

void solve() {

	cin>>n>>w;

	rep(i,0,n){
		int w,val;
		cin>>w>>val;
		v.pb({w,val});
	}

	int cst=0;
	rep(i,0,n) cst += v[i].S;

	n++;
	cst++;

	rep(i,0,n){
		vi r(cst,0);
		dp.pb(r);
	}

	rep(i,0,cst) dp[0][i] = 1e18;
	dp[0][0] = 0;

	rep(i,1,n){
		rep(j,0,cst){
			dp[i][j] = dp[i-1][j];
			if(j >= v[i-1].S) dp[i][j] = min( dp[i][j], dp[i-1][j-v[i-1].S] + v[i-1].F);
		}
	}		


	ll mx = 0;

	// rep(i,0,n){
	// 	rep(j,0,cst){
	// 		cout << dp[i][j] << "\t";
	// 	}
	// cout << endl;
	// }



	req(j,0,cst){
		rep(i,0,n){
			if(dp[i][j] <= w){
				// wa(i);
				// wa(j);
				cout << j << endl;
				return;
			}
		}
	}



}

Measured memory_bytes: 79984
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)*}
    };
}

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

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

pub fn is_integer(f: f64) -> bool {
    f - f.floor() == 0.0
}

fn main() {
    input! {
       n: i64 
    }
    for i in (0..n+1).rev() {
        let x = (i as f64).sqrt();
        if is_integer(x) {
            println!("{}", i);
            return;
        }
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
long long sum;
int mn=1e9+7,c=0;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a;
		cin>>a;
		if(a<0)c^=1,mn=min(mn,-a);
		else mn=min(mn,a);
		sum+=abs(a);
	}
	cout<<sum-2*(c?mn:0)<<"\n";
	return 0;
}

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

int main(void) {
  int A, B, C;
  cin >> A >> B >> C;

  for (int i = 1; ; i++) {
    if (i * A % B == C) {
      cout << "YES" << endl;
      return 0;
    }
    if (i == B + 1) {
      cout << "NO" << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
a=gets.chomp.to_i
b=0
c=[]
d=1
while b==0
  if a%2!=0
     (1..a).each do |x|
       if a%x==0
         c.push(x)
       end
     end
    if c.length==2
      b+=1
    else a+=1
    end
  elsif a==2
    b+=1
  else a+=1
  end 
  c=[]
end
puts a

Measured memory_bytes: 1788
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

red = [[i, "r"] for i in p]
green = [[i, "g"] for i in q]
white = [[i, "w"] for i in r]

total = sorted(red + green + white)[::-1]

ans = 0
cnt = 0
r_cnt = 0
g_cnt = 0
for t in total:
    if t[1] == "r" and r_cnt == X:
        continue
    if t[1] == "g" and g_cnt == Y:
        continue
    ans += t[0]
    if t[1] == "r":
        r_cnt += 1
    elif t[1] == "g":
        g_cnt += 1
    cnt += 1
    if cnt == X + Y:
        break

print(ans)

Measured memory_bytes: 129104
using System;
using System.Linq;

class A {
  static void Main(string[] Args) {
    int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    Array.Sort(nums);
    bool b_1 = nums[0] == nums[1];
    bool b_2 = nums[1] == nums[2];
    if ((b_1 && !b_2) || (!b_1 && b_2)) {
      Console.WriteLine("Yes");
    }
    else
    {
      Console.WriteLine("No");
    }
  }
}


Measured memory_bytes: 13268
N,M = map(int,input().split())
L = []
for i in range(N):
  L.append(list(map(int,input().split())))
L.sort()
s = 0
yen = 0
for j in range(N):
  if s + L[j][1] < M:
    s += L[j][1]
    yen += L[j][0]*L[j][1]
  else:
    yen += L[j][0]*(M-s)
    break
print(yen)

Measured memory_bytes: 27760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

	ll a,b,c;
	cin >> a >> b >> c;
	vector<ll> aa(10);
	aa[a]++;
	aa[b]++;
	aa[c]++;
	rep(i,10){
		if(aa[i]==2){
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

const int MAX_CAT = 100005;

using namespace std;

int cnt [MAX_CAT];

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

  int minc = MAX_CAT, maxc = -1;
  for (int i = 0; i < catc; i++) {
    int colc;
    cin >> colc;

    cnt[colc]++;

    minc = min(minc, colc);
    maxc = max(maxc, colc);
  }

  if (!(minc == maxc - 1 ||
        minc == maxc)) {
    cout << "No" << endl;
  } else if (minc == maxc &&
             maxc == catc - 1) {
    cout << "Yes" << endl;
  } else if (minc == maxc) {
    if (catc >= 2 * maxc) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    if (catc - cnt[minc] >= 2 * (maxc - cnt[minc]) &&
        maxc > cnt[minc]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int n,k,count=0,max,i;
  scanf("%d%d",&n,&k);
  char s[n+1];
  scanf("%s",s);
  for(i=0;i<n;i++)
    if(s[i]==s[i+1])
      count++;
  max=count+2*k;
  if(n>max)
    printf("%d\n",max);
  else
    printf("%d\n",n-1);
  return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<vector<int>> Graph;

int main() {

	string s;
	cin >> s;

	bool flag = true;

	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D')
				flag = false;
		}
		else {
			if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D')
				flag = false;
		}
	}

	if (flag)
		cout << "Yes";
	else
		cout << "No";
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        boolean[] b = new boolean[n];
        int i = 0;
        int cnt = 0;

        for ( ; !b[i] && i != 1; ++cnt) {
            b[i] = true;
            i = a[i];
        }

        if (i == 1) {
            System.out.println(cnt);
        } else {
            System.out.println(-1);
        }
    }
}

Measured memory_bytes: 50988
import itertools
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
permu_list = itertools.permutations(range(N))
ans=0
c = 0
for p in permu_list:
  c += 1
  for i in range(N-1):
    ans += ((A[p[i]][0]-A[p[i+1]][0])**2+(A[p[i]][1]-A[p[i+1]][1])**2)**0.5
print(ans/c)

Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
	int main() {
		int n;
		std::cin >> n;
		std::vector<int> l(n);
		int sum = 0;
		for (int i = 0;i < n;++i) {
			std::cin >> l[i];
			sum += l[i];
		}
		int a = *std::max_element(l.begin(), l.end());
		sum -= a;
		if (a < sum) {
			std::cout << "Yes" << std::endl;
		}
		else {
			std::cout << "No" << std::endl;
		}
		return 0;
	}

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

public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < m; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int s = sc.nextInt();
                s--;
                a[s] |= 1<<i;
            }
        }
        int p = 0;
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt();
            p |= x<<i;
        }
        int ans = 0;
        for (int s = 0; s < (1<<n); s++) {
            int t = 0;
            for (int i = 0; i < n; i++) {
                if ((s>>i & 1) != 0) {
                    t ^= a[i];
                }
            }
            if (t == p) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844