akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if(k <= a){
        ans = k;
    }
    else {
        if(k <= a+b){
            ans = a;
        }
        else {
            ans = a - (k-a-b);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
s = input()
left = 0
right = len(s) - 1
x_left = 0
x_right = 0
if len(s) >= 2:
    while (left <= right):
        if s[left] == s[right]:
            left += 1
            right -= 1
        elif s[left] == "x":
            x_left += 1
            left += 1
        elif s[right] == "x":
            x_right += 1
            right -= 1
        else:
            print(-1)
            exit()
    print(x_left + x_right)
else:
    print(0)

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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi; ///VECTOR<VECTOR<INT>NAME>NAME 2
typedef vector<vl> vvl;///LONG LONG
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;///VECTOR WITH PAIR
typedef vector<pll> vll;
typedef double dl;

#define endl "\n"
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define over return 0;

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


///--------> YOUR JOURNEY STARTS HERE <-------



int main(){

double d,t,s;
cin>>d>>t>>s;

if((d/s)<=t){

cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}

over
}


Measured memory_bytes: 3676
import math
a, b = map(int, input().split())
tmp_a = math.ceil(a / 0.08)
tmp_b = int(b / 0.1)
if a % 2 == 0:
    set_a = set([i for i in range(tmp_a, tmp_a+13)])
else:
    set_a = set([i for i in range(tmp_a, tmp_a+12)])
set_b = set([i for i in range(tmp_b, tmp_b+10)])
if len(set_a & set_b) == 0:
    print(-1)
else:
    print(min(set_a & set_b))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;

const int N = 1e5 + 10;
int n;
ll h[N], dp[N];

int main() {

	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", h + i);
	for(int i = 1; i <= n; i++) {
		if(i > 1) dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		if(i > 2) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define ll long long

int main(){
  int n,ans=0;
  string a,b,c;
  cin>>n>>a>>b>>c;
  for(int i=0;i<n;++i){
    char A=a[i],B=b[i],C=c[i];
    if(A==B && B==C)continue;
    else if(A==B || B==C || C==A)++ans;
    else ans+=2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	int n;
	string s[110];
	set<string> u;
	cin>>n;
	REP(i,n){
		cin>>s[i];
	}
	REP(i,n){
		if(u.find(s[i])!=u.end()){
			cout<<"No"<<endl;
			return 0;
		}
		if(i>0 && s[i-1].back()!=s[i].front()){
			cout<<"No"<<endl;
			return 0;
		}
		u.insert(s[i]);
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;

/*************************************************************************/

int solve(int n, VB a, VB b) {
    FOR(_,1,2) {
        FOR(i,0,n-1) {
            b.pb(b[i]);
        }
    }
    
    VI firstLeft(3*n,-1), firstRight(3*n,-1);
    
    FOR(i,0,3*n-1) {
        if (b[i]) {
            firstLeft[i] = i;
        } else if (i > 0) {
            firstLeft[i] = firstLeft[i-1];
        }
    }
    
    FORD(i,3*n-1,0) {
        if (b[i]) {
            firstRight[i] = i;
        } else if (i < 3*n-1) {
            firstRight[i] = firstRight[i+1];
        }
    }
    
    int ans = INF;
    
    FOR(shift,0,2*n-1) {
        int here = shift;
        VI pos;
        
        FOR(i,0,n-1) if (a[i] != b[i + shift]) {
            pos.pb(i);
            here++;
        }
        
        if (!pos.empty() && firstRight[0] == -1) {
            continue;
        }
        
        multiset <int> valRight;
        multiset <pii> valLeftRight;
        
        for (int i : pos) {
            int left = i + n - firstLeft[i + n];
            int right = firstRight[i + n] - (i + shift + n);
            
            if (right > 0) {
                valLeftRight.insert({left, right});
                valRight.insert(right);
            }
        }
        
        FOR(left,0,n-1) {
            while (!valLeftRight.empty() && valLeftRight.begin()->st == left) {
                valRight.erase(valRight.find(valLeftRight.begin()->nd));
                valLeftRight.erase(valLeftRight.begin());
            }
            
            int right = (valRight.empty() ? 0 : *valRight.rbegin());
            int total = here + 2 * (left + right);
            
            ans = min(ans, total);
        }
    }
    
    return ans;
}

/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    string sa, sb;
    cin >> sa >> sb;
    
    int n = SIZE(sa);
    
    VB a(n), b(n);
    FOR(i,0,n-1) {
        a[i] = sa[i] == '1';
        b[i] = sb[i] == '1';
    }

    int ans = INF;
    FOR(_,0,1) {
        ans = min(ans, solve(n, a, b));

        reverse(a.begin(), a.end());
        reverse(b.begin(), b.end());
    }
    
    if (ans == INF) ans = -1;
    cout << ans;
    
    return 0;
}

/*************************************************************************/


Measured memory_bytes: 568
from collections import deque

N, K = map(int, input().split())
P = list(map(int, input().split()))

maxQ = deque([])
minQ = deque([])

for i in range(K):
    while maxQ:
        if P[maxQ[-1]] <= P[i]:
            maxQ.pop()
        else:
            break
    maxQ.append(i)
    if maxQ[0] == i - K:
        maxQ.popleft()

    while minQ:
        if P[minQ[-1]] >= P[i]:
            minQ.pop()
        else:
            break
    minQ.append(i)
    if minQ[0] == i - K:
        minQ.popleft()

ans = 1
hasSame = False
seq = 1
for i in range(1, K):
    if P[i - 1] < P[i]:
        seq += 1
    else:
        seq = 1
if seq >= K:
    hasSame = True

for left in range(N - K):
    right = left + K

    if P[right - 1] < P[right]:
        seq += 1
    else:
        seq = 1

    while maxQ:
        if P[maxQ[-1]] <= P[right]:
            maxQ.pop()
        else:
            break
    maxQ.append(right)
    if maxQ[0] == right - K:
        maxQ.popleft()

    if left == minQ[0] and right == maxQ[0]:
        pass
    else:
        if seq < K:
            ans += 1
        else:
            if not hasSame:
                hasSame = True
                ans += 1

    while minQ:
        if P[minQ[-1]] >= P[right]:
            minQ.pop()
        else:
            break
    minQ.append(right)
    if minQ[0] == right - K:
        minQ.popleft()

print(ans)

Measured memory_bytes: 25128
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		try{

			Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();

			if (a+b>c+d){
				System.out.println("Left");
			}else if(a+b<c+d){
				System.out.println("Right");
			}else{
				System.out.println("Balanced");
			}

		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	
}

Measured memory_bytes: 24020
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
using namespace std;

int main()
{
    int k,x;
    cin >> k >> x;
    int ans;
    int scope;
    scope = (k-1)*2+1;
    ans = x-k+1;
    for (int i = 0; i < scope; i++)
    {
        cout << ans+i << " ";
    }
    cout << endl;
    
}

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

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

    std::vector<std::vector<int>> g(N + 1);
    for (int i = 0; i < M; i++) {
        int A, B;
        std::cin >> A >> B;
        g[A].push_back(B);
        g[B].push_back(A);
    }

    std::vector<int> check(N + 1);
    std::queue<int> que;
    que.push(1);
    while (!que.empty()) {
        int u = que.front();
        que.pop();
        for (int v: g[u]) {
            if (check[v] > 0) continue;
            check[v] = u;
            que.push(v);
        }
    }

    std::cout << "Yes\n";
    for (int i = 2; i <= N; i++) {
        std::cout << check[i] << "\n";
    }
}

Measured memory_bytes: 10168
// A - Fairness

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, d, e, f, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> a >> b >> c >> k;
  h = k;

  s = to_string(ans);
  if (s.size() >= 18)
  {
    cout << "Unfair" << endl;
  }
  else if (h % 2 == 0)
  {
    ans = a - b;
    cout << ans << endl;
  }
  else
  {
    ans = b - a;
    cout << ans << endl;
  }
  // cout << s.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,div,i;
    bool possible=false;
    cin>>n;
    for(i=1;i<=9;i++){
        if(n%i==0){
            div=n/i;
            if(div<=9){
                possible=true;
                break;
            }
        }
    }
    if(possible)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
a = list(map(int, input().split()))

ans = a[1] + 2*(a[0]//2 + a[4]//2 + a[3]//2)
if a[0]>0 and a[3]>0 and a[4]>0:
  ans = max(ans, a[1] + 2*((a[0]-1)//2 + (a[3]-1)//2 + (a[4]-1)//2) + 3)
  
print(ans)

Measured memory_bytes: 3064
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
  int l;
  string S;
  cin >> S;
  l = S.length();
  S.replace(1, l - 2, to_string(l - 2));
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include <algorithm>
#include <cctype>
#include <cstdio>

using namespace std;

int main(void){
    // Your code here!
    string a,b,c;
    cin >>a>>b>>c;
    
    string str=a.substr(0,1)+b.substr(0,1)+c.substr(0,1);
    transform(str.begin(), str.end(), str.begin(), ::toupper);
    cout <<str<<endl;
    
    return 0;
    
}


Measured memory_bytes: 256
import math
(a, b, C) = [int(i) for i in input().split()]
radC = math.radians(C)
h = b * math.sin(radC)
S = (a * h) / 2
L = a + b + math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(radC))
print('{0:.4f}\n{1:.4f}\n{2:.4f}'.format(S,L,h))

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

const int maxn = 200000+100;
int LB[maxn];
int RW[maxn];
int main()
{
#ifdef fuckoj
    freopen("C.in","r",stdin);
#endif
	ios::sync_with_stdio(false);
	int N;string str;
	cin>>N>>str;
	for(int i=0;i<N;++i)
	{
	    if(str[i]=='#') LB[i]=1;
	    if(str[i]=='.') RW[i]=1;
	}
	for(int i=1;i<N;++i)    LB[i]+=LB[i-1];
	for(int i=N-2;i>=0;--i) RW[i]+=RW[i+1];
	int ans=min(N-RW[0],RW[0]);
	for(int i=0;i<N;++i)
	{
	    ans= min (ans, LB[i] + RW[i]-1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2196
#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;
#define ll  long long
#define PI  acos(-1)
#define pb  push_back
#define ins insert
#define INF 5000000000000000007 //1e18+7
#define mk  make_pair
#define ff  first
#define ss  second
#define endl "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a) (ll)a.size()
#define double long double
#define coud(a,b) cout << fixed << setprecision((b)) << (a)
#define mset(x,y)  memset(x,y,sizeof(x))
#define all(x)   (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bp(n)  __builtin_popcountll(n)
#define mxt(a)  *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define trav(a, x)    for(auto &a : x)

const double eps=1e-7;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int d8x[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int d8y[8]={+1, 0, -1, +1, -1, +1, 0, -1};
int d4x[4]={1, 0, 0, -1};
int d4y[4]={0, -1, 1, 0};
ll power(ll x,ll y){ll ans=1;x=x;while(y>0){if(y&1)ans=(ans*x);y=y>>1;x=(x*x);}return ans;}
ll sqr(ll x) { return x * x;}

template <typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template <class T> inline void chmax(T &x,T y){ x = max((x), (y));}
template <class T> inline void chmin(T &x,T y){ x = min((x), (y));}
template <class T> T abs(T x) { return x>0 ? x : -x;}
template <typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0) { if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
typedef pair<int,int>  pii;
typedef pair<ll,ll>  pll;
typedef vector<pll>  vpll;
typedef vector<pii>  vpii;
typedef vector<ll>   vll;
typedef vector<int>  vii;
#define minpq priority_queue<T,vector<T>,greater<T> >;
// #define T int
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
//*X.find_by_order(k) returns the kth largest element (0-based).
//X.order_of_key(val) returns the no. of values less than val.
ll ncr(ll n,ll r) {ll ans=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){ans*=(n-i);ans/=(i+1);}return ans;}
const int MOD = 1000000007;   
const int N = 200100;

// 🎲
ll n,m, u, v;
ll par[N], ans;
    int root(int v){
      return par[v]<0?v:(par[v] = root(par[v]));
    }
    void merge(int x,int y)
    { 
      if((x = root(x)) == (y = root(y)))  return;
      if(par[y]<par[x]) swap(x, y);
      par[x]+=par[y];
      par[y]=x;
    }
int32_t main() {
  cin.sync_with_stdio(0);cin.tie(0);
  cin.exceptions(cin.failbit);
  
  cin >> n >> m;
  mset(par,-1);
  for (int i=1; i<=m; ++i) {
    cin >> u >> v;
    merge(u,v);
  }
  for (int i=1; i<=n; ++i ){
    if(par[i] < 0) {
      chmax(ans,-1*par[i]);
    }
  }
  cout << ans;
  return 0; 
}

/* 
    stuff you shoulds look for
    * int overflow,array bounds.
    * special cases (n=1?).
    * N,MOD value.
*/

Measured memory_bytes: 5220
#include<iostream>
#include<math.h>

using namespace std;

int main()
{
  int a, b;
  char op;
  cin >> a >> op >> b;
  while(op!='?'){
    switch(op){
    case '+':
      cout << a+b;
      break;
    case '-':
      cout << a-b;
      break;
    case '*':
      cout << a*b;
      break;
    case '/':
      cout << a/b;
      break;
    }
    cout << endl;
    cin >> a >> op >> b;
  }
  return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, b, n) for (int i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

void solve(ll N, vector<ll> A) {
  sort(A.begin(), A.end());

  if (N % 2) {
    if (A[0] != 0) {
      cout << 0 << endl;
      return;
    }
    FOR(i, 1, N) {
      if (A[i] == 2 * ((i - 1) / 2 + 1))
      continue;
    cout << 0 << endl;
    return;
    }
  } else {
    FOR(i, 0, N) {
      if (A[i] == 2 * (i / 2 + 1) - 1)
      continue;
    cout << 0 << endl;
    return;
    }    
  }
  
  ll ans(1);
  ll n = (N % 2) ? (N - 1) / 2 : N / 2;
  REP(i, n) {
    ans *= 2;
    ans %= MOD;
  }
  cout << ans << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) {
    cin >> A[i];
  }

  solve(N, move(A));

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    double R,G,B,N;cin>>R>>G>>B>>N;
    int ans=0;
    double a=0;
    for (int i = 0; i <= N; i++)
    {
        /* code */
        for (int j = 0; j <= N; j++)
        {
            /* code */
           a=(N-R*i-G*j)/B;
          
            if (fmod(a,1.0)==0.0&&a>=0.0)
            {
                /* code */
                ans++;
            }
            
        }
        
    }
    
    
    cout<<ans<<endl;
    }

Measured memory_bytes: 256
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }


int N;
char S[101], T[101];
int ans;

int same(int d) {
	for (int i = 0; i < N - d; i++) {
		if (S[i + d] != T[i]) {
			return 0;
		}
	}
	return 1;
}

int main() {
	scanf("%d", &N);
	scanf("%s%s", S, T);

	int d = 0;
	for (d = 0; d < N; d++) {
		if (same(d)) {
			break;
		}
	}

	ans = N + d;
	printf("%d\n", ans);

#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 128
from collections import defaultdict
N,M = map(int,input().split())
A = list(map(int,input().split()))
A[0] %= M
for i in range(N-1):
    A[i+1] += A[i]
    A[i+1] %= M
d = defaultdict(lambda:0)
d[0] = 1
ans = 0
for i in range(N):
    ans += d[A[i]]
    d[A[i]] += 1
print(ans)

Measured memory_bytes: 14920
#include <stdio.h>

int main(void){
  int i,j,n,m,cn;
  char c,s[5]={'S','H','C','D','\0'};
  static int card[4][13];
  scanf("%d\n",&n);

  for(i=0;i<n;i++){
    scanf("%c %d\n",&c,&m);
    for(j=0;j<4;j++)
      if(s[j]==c)
        card[j][m-1]=1;
  }
  
  for(i=0;i<4;i++)
    for(j=0;j<13;j++)
      if(card[i][j]==0)
        printf("%c %d\n",s[i],j+1);

  return 0;
}
    


Measured memory_bytes: 2056
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, count = 0;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p.at(i);
	}
	for (int i = 1; i < n - 1; i++) {
		if (p.at(i) < p.at(i - 1)) {
			if (p.at(i) > p.at(i + 1)) {
				count++;
			}
		}
		else if (p.at(i) > p.at(i - 1)) {
			if (p.at(i) < p.at(i + 1)) {
				count++;
			}
		}
	}
	cout << count << endl;
}

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

using namespace std;

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

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

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

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

    int n, a[3];
    int l[10];

    bool used[10];
    fill(used, used + 10, false);

    cin >> n >> a[0] >> a[1] >> a[2];
    REP(i, n)
    cin >> l[i];

    int res = INT_MAX;

    for (int i = 0; i < pow(4, n); i++)
    {
        int num[3];

        REP(j, 3)
        num[j] = 0;

        int t[10];

        int k = i;

        REP(j, n)
        {
            if (k % 4 < 3)
                num[k % 4]++;

            t[j] = k % 4;

            k /= 4;
        }

        bool ok = true;
        REP(j, 3)
        if (!num[j])
            ok = false;

        if (!ok)
            continue;

        int sum = 0;

        REP(j, 3)
        {
            int s = 0;

            int c = 0;

            REP(k, n)
            {
                if (t[k] == j)
                    s += l[k], c++;
            }

            sum += (c - 1) * 10;

            sum += abs(a[j] - s);
        }

        res = min(res, sum);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main (){
	int n;
	scanf("%d", &n);
	char s[10001];
	scanf("%s", s);
	for(int i = 0; s[i] != '\0';i++){
		if(s[i]+n > 'Z'){
			printf("%c", s[i]+n-26);
		}else{
			printf("%c", s[i]+n);
		}
	}
	puts("");
	return 0;
}

Measured memory_bytes: 1668
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    int n, m;
    cin >> n >> m;
    auto v = vector<pair<int, int>>();
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        v.PB(MP(a, b));
    }
    sort(ALL(v), [](const auto &a, const auto &b) {
        return a.F < b.F;
    });
    auto s = set<int>();
    int ans = 0;
    int currentMin = 0;
    for (auto p : v) {
        auto a = p.F;
        auto b = p.S;
        if (a >= currentMin) {
            ans++;
            currentMin = b;
        } else {
            currentMin = min(b, currentMin);
        }
    }
    PUTS(ans);
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const int INF = 1001001001;
const double PI = 3.141592653589793238;

vec<int> l(2005, INF);

// int binary_search(int key) {
//     int left = 0, right = (int)l.size() - 1; // 配列 a の左端と右端
//     while (right >= left) {
//         int mid = left + (right - left) / 2; // 区間の真ん中
//         if (l[mid] <= key && l[mid+1] > key) return mid;
//         else if (l[mid] > key) right = mid - 1;
//         else if (l[mid] < key) left = mid + 1;
//     }
//     return -1;
// }

int main(){
    int n;
    cin >> n;
    vec<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    // rep(i, n) cout << l[i] << " ";
    // cout << endl;
    int ans = 0;
    for(int i=0; i<n; i++) for(int j=i+1; j<n; j++) {
        int apb = l[i] + l[j];
        //binary_search(apb);
        // cout << apb << " " << binary_search(apb) << endl;
        for (int k=j+1; k<n; k++) {
            if (l[k]>=apb) break;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long
const int mod=1e9+7;
const int inf=1e9;
#define N 200005
int n,a[N],b[N],c[N];
bool vis[N];
int fyy[N],val=0;
std::vector<int> same,diff;
int main(){
	std::ios::sync_with_stdio(0);
	std::cin>>n;
	rep(i,1,n) std::cin>>a[i],++fyy[a[i]];
	rep(i,1,n) std::cin>>b[i],++fyy[b[i]];
	std::sort(b+1,b+n+1,std::greater<int>());
	rep(i,1,n) if(fyy[i]>n) return puts("No"),0;
	rep(i,1,n){
		if(a[i]==b[i]) same.push_back(i),val=a[i];
	}
	rep(i,1,n) if(a[i]!=val&&b[i]!=val) diff.push_back(i);
	rep(i,0,same.size()-1) std::swap(b[same[i]],b[diff[i]]);
	std::cout<<"Yes\n";
	rep(i,1,n) std::cout<<b[i]<<' '; std::cout<<'\n';
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef long double ld;

//ある値がvector内の要素に含まれているか否か判定する
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance(vec.begin(), itr);
  if (index != vec.size()) { // 発見できたとき
    return 1;
  } else { // 発見できなかったとき
    return 0;
  }
}

struct edge_t {
  int dest;
  int weight;
};

struct vertex_t {
  vector<edge_t> edges;
  vector<int> weight;

  // for dijkstra
  bool done; // confirm or not
  int cost;  // now cost
  int from;

  bool operator<(const vertex_t &another) const { // priority --> min
    return another.cost < cost;                   // order(cost)
  }

  bool operator>(const vertex_t &another) const { // priority --> min
    return another.cost > cost;                   // order(cost)
  }

  bool operator==(const vertex_t &another) const {
    return another.cost == cost; // order(cost)
  }

  vertex_t() {
    cost = INF;
    done = false;
  }
};

int bellman_ford(vector<vertex_t> &graph, int size, int start) {
  int i, j, k, count = 0;
  bool flag = false;
  graph[start].cost = 0;
  REP(i, size) {
    REP(j, size) {
      vertex_t cur = graph[j];
      for (edge_t edge : cur.edges) {
        if (cur.cost + edge.weight < graph[edge.dest].cost) {
          if (i == size - 1)
            flag = true;
          graph[edge.dest].cost = cur.cost + edge.weight;
        }
      }
    }
  }
  if (flag) {
    return 1;
  } else {
    return 0;
  }
}

class tree_t {
  public:
  bool is_leaf;
  tree_t *right;
  tree_t *left;

  tree_t() {
    is_leaf = false;
    right = NULL;
    left = NULL;
  }
};

vector<string> splitstr(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch : s) {
    if (ch == delim) {
      if (!item.empty())
        elems.push_back(item);
      item.clear();
    } else {
      item += ch;
    }
  }
  if (!item.empty())
    elems.push_back(item);
  return elems;
}

unsigned getDigitNum(unsigned num) {
  unsigned digit = 0;
  while (num != 0) {
    num /= 10;
    digit++;
  }
  return digit;
}

////////////////////////// let's code! /////////////////////////////

int i, j, k;

///// variables frequent to use /////

int main() {
  int A, B;

  cin >> A >> B;

  int a, b, c;

  a = A + B;
  b = A - B;
  c = A * B;

  if (a > b) {
    if (c > a) {
      cout << c;
    } else {
      cout << a;
    }
  } else {
    if (c > b) {
      cout << c;
    } else {
      cout << b;
    }
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

mod = 10 ** 6 + 3
U = 10 ** 6 + 2

fact = [1] * (U + 10)
for i in range(1, U + 10):
    fact[i] = fact[i - 1] * i % mod


def GCD(x, y):
    if y == 0:
        return x
    return GCD(y, x % y)


def msol(x, d, n):
    if x == 0:
        return 0

    if d == 0:
        return pow(x, n, mod)

    if d == 1:
        if x + n - 1 >= mod:
            return 0
        res = fact[x+n-1]*pow(fact[x-1], mod-2, mod) % mod
        return res

    inv = pow(d, mod-2, mod)
    y = x * inv % mod
    C = pow(d, n, mod)
    if y + n - 1 >= mod or y == 0:
        return 0
    res = fact[y+n-1]*pow(fact[y-1], mod-2, mod) % mod
    res = res * C % mod
    return res


Q = int(input())
for _ in range(Q):
    x, d, n = map(int, input().split())
    print(msol(x, d, n))

Measured memory_bytes: 45256
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

const int N = 1e5;
int a[N+5];

int main()

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

    int n, ans = 0;

    cin >> n;

    int arr[n+1];

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

        cin >> arr[i];
    }

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

        if (arr[i] == i) {

            ans++;
            i++;
        }
    }

    cout << ans;

    return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	string S;
	cin >> S;
	bool a=S.at(0)=='R';
	bool b=S.at(1)=='R';
	bool c=S.at(2)=='R';

	if( a and b and c ){
		cout << 3 << endl;
	}
	else if( (a and b) or (b and c) ){
		cout << 2 << endl;
	}
	else if( a or b or c ){
		cout << 1 << endl;
	}
	else{
		cout << 0 << endl;
	}

}


Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int int_vector_find(std::vector<int> vec, int num) {
	auto itr = std::find(vec.begin(), vec.end(), num);
	int index = std::distance(vec.begin(), itr);

	if (index != vec.size()) {
		return 1;
	}
	else {
		return 0;
	}
}

int n;
LL h[100010], dp[100010];

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

	for (int i = 1; i <= n; ++i) {
		std::cin >> h[i];
		dp[i] = 1000000000;
	}
	dp[1] = 0;
	for (int i = 2; i <= n; ++i) {
		if (i == 2) {
			dp[i] = dp[i - 1] + std::abs(h[i - 1] - h[i]);
		}
		else {
			dp[i] = std::min(dp[i - 1] + std::abs(h[i - 1] - h[i]), dp[i - 2] + std::abs(h[i - 2] - h[i]));
		}
	}
	std::cout << dp[n] << std::endl;
}

Measured memory_bytes: 1792
s = input()
MOD = 10**9+7

o = 1
a = 0
b = 0
c = 0

for i in s:
    if i == "A":
        a += o
    elif i == "B":
        b += a
    elif i == "C":
        c += b
    else:
        o, a, b, c = o*3, o+a*3, a+b*3, b+c*3

    o %= MOD
    a %= MOD
    b %= MOD
    c %= MOD

print(c)

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int X, Y; cin >> X >> Y;
  int result = X%Y ? X : -1;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

ll G[2], S[2], B[2], ans;

inline void bkt(ll cur) {
    ll szg = 0, szb = 0, szs = 0;

    if(G[1] < G[0]) szg = cur / G[1];
    if(S[1] < S[0]) szs = cur / S[1];
    if(B[1] < B[0]) szb = cur / B[1];

    ans = max(ans, cur + szg * (G[0] - G[1]));
    ans = max(ans, cur + szs * (S[0] - S[1]));
    ans = max(ans, cur + szb * (B[0] - B[1]));

    if(szg && szs) {
        for(ll g = 0; g <= szg; g++) {
            ll s = (cur - g * G[1]) / S[1];
            ans = max(ans, cur + g * (G[0] - G[1]) + s * (S[0] - S[1]));
        }
    }
    if(szg && szb) {
        for(ll g = 0; g <= szg; g++) {
            ll b = (cur - g * G[1]) / B[1];
            ans = max(ans, cur + g * (G[0] - G[1]) + b * (B[0] - B[1]));
        }
    }
    if(szs && szb) {
        for(ll s = 0; s <= szs; s++) {
            ll b = (cur - s * S[1]) / B[1];
            ans = max(ans, cur + s * (S[0] - S[1]) + b * (B[0] - B[1]));
        }
    }
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    ll i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;

    for(i = 0; i < 2; i++) {
        cin >> G[i] >> S[i] >> B[i];
    }

    ans = n;

    if((S[0] <= S[1] && B[0] <= B[1] && G[0] <= G[1]) || (S[0] >= S[1] && B[0] >= B[1] && G[0] >= G[1])) {
        for(ll p = 0; p < 2; p++) {
            for(ll a = 0; a <= n / G[p]; a++) {
                for(ll b = 0; b <= (n - a * G[p]) / S[p]; b++) {
                    ll c = 0;
                    if(B[p] < B[p ^ 1]) {
                        c = (n - a * G[p] - b * S[p]) / B[p];
                    }

                    ans = max(ans, n + a * (G[p ^ 1] - G[p]) + b * (S[p ^ 1] - S[p]) + c * (B[p ^ 1] - B[p]));
                }
            }
        }

        cout << ans;
        return 0;
    }


    ll szg = 0, szb = 0, szs = 0;
    if(G[0] < G[1]) szg = n / G[0];
    if(S[0] < S[1]) szs = n / S[0];
    if(B[0] < B[1]) szb = n / B[0];

    ll mx = n;
    for(ll g = 0; g <= szg; g++) {
        for(ll s = 0; s <= szs && g * G[0] * s * S[0] <= n; s++) {
            for(ll b = 0; b <= szb && g * G[0] + s * S[0] + b * B[0] <= n; b++) {
                mx = max(mx, n + g * (G[1] - G[0]) + s * (S[1] - S[0]) + b * (B[1] - B[0]));
            }
        }
    }

    bkt(mx);

    cout << ans;

    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a;
	int b;
	cin>>a>>b;
	if(a<b){cout<<"a < b"<<endl;}
	if(a>b){cout<<"a > b"<<endl;}
	else if(a==b){cout<<"a == b"<<endl;}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y)
{
  return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y)
{
  return x * y / gcd(x, y);
}
bool is_prime(int x)
{
  for (int i = 2; i * i <= x; i++)
  {
    if (x % i == 0)
      return 0;
  }
  return true;
}
vector<bool> prime_table(int n)
{
  vector<bool> prime(n + 1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= n; i++)
  {
    if (!prime[i])
      continue;
    for (int j = i * i; j <= n; j++)
      prime[j] = 0;
  }
  return prime;
}
map<int, int> prime_factor(int n)
{
  map<int, int> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n]++;
  return res;
}
ll modpow(ll a, ll n, ll mod)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll modinv(ll a, ll mod)
{
  return modpow(a, mod - 2, mod);
}

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

  if(n<10){
    cout<<r+(100*(10-n))<<endl;
  }else{
    cout<<r<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n;
double sum;
signed main() {
	cin >> n;
	rep(i, n) {
		double a; cin >> a;
		sum += 1. / a;
	}
	printf("%.12lf\n", 1./sum);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int main(){
	int x,y,s=0;
	cin>>x>>y;
	for(int i=1,a;i<=y;i++)cin>>a,s+=a;
	if(s>=x)puts("Yes");
	else puts("No");
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    V<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];

    sort(ALL(d));

    int ans = 0;
    for(int i = 1; i <= 100000; i++){
        auto ite = lower_bound(ALL(d), i);
        int l = ite - d.begin();
        if(l == n - l) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b,int c){
	while(a!=0 && b!=0){
		if(a>b) swap(a,b);
		b=b%a;
	}
	int re;
	if(a==0) re=b;
	else re=a;
	while(re!=0 && c!=0){
		if(re>c) swap(re,c);
		c=c%re;
	}
	if(c!=0) re=c;
	return re;
}
int main(){
	int k,s=0;
	cin>>k;
	for(int i=1;i<=k;i++)
		for(int j=1;j<=k;j++)
			for(int m=1;m<=k;m++){
				s+=gcd(i,j,m);
			}
	cout<<s;
	return 0;
}

Measured memory_bytes: 3624
#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);
  }
  int answer = 0;
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      answer += d.at(i) * d.at(j);
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
Scanf.scanf "%d %d %d" (fun n x m ->
    let a = Array.make (m + 2) 0 in
    let flag = Array.make (m + 2) (-1) in
    a.(0) <- x;
    flag.(x) <- 0;
    let rec loop i prev =
        let c = (prev * prev) mod m in
        if flag.(c) >= 0 then flag.(c), i else (
            a.(i) <- c;
            flag.(c) <- i;
            loop (i + 1) c
        )
    in
    let pre, j = loop 1 x in
    let len = j - pre in

    Printf.printf "%d\n" @@
        if n <= j then (
            let rec loop i acc =
                if i = n then acc else
                    loop (i + 1) (acc + a.(i))
            in
            loop 0 0
        ) else (
            let presum =
                let rec loop i acc =
                    if i = pre then acc else
                        loop (i + 1) (acc + a.(i))
                in
                loop 0 0
            in
            let loopsum =
                let rec loop i acc =
                    if i = j then acc else
                        loop (i + 1) (acc + a.(i))
                in
                loop pre 0
            in
            let postsum =
                let lim = ((n - pre) mod len) + pre in
                let rec loop i acc =
                    if i = lim then acc else
                        loop (i + 1) (acc + a.(i))
                in
                loop pre 0
            in
            presum + loopsum * ((n - pre) / len) + postsum
        )
)

Measured memory_bytes: 5404
#include <algorithm>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#ifdef __APPLE__
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif

const int N = (int)1e6 + 123;
const int MOD = (int)1e9 + 7;
const int inf = (int)5e8;
const long long infll = (long long)1e17;


map<int, vector<int>> indeces;

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; ++i) {
        indeces[s[i]].push_back(i);
    }
    long long ans = n * 1ll * (n - 1) / 2;
    for (auto i : indeces) {
        int cnt = i.second.size();
        ans -= cnt * 1ll * (cnt - 1) / 2;
    }
    printf("%lld\n", ans + 1);
}


int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 2172
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long mod = 1000000007;
		long count = 1;
		boolean[] num = new boolean[n+1];
		Arrays.fill(num, true);
		num[0] = false;
		num[1] = false;
		double m = Math.sqrt(n);
		for (int i = 2; i <= m; i++) {
			for (int j = i*2; j <= n; j+=i) {
				num[j] = false;
			}
		}
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i <= n; i++) {
			if (num[i]) {
				map.put(i, 0);
			}
		}
		
		for (int i = 2; i <= n; i++) {
			int N = i;
			for (Integer p : map.keySet()) {
				while (N%p == 0) {
					map.put(p, map.get(p)+1);
					N/=p;
				}
			}
		}
		for (Integer p : map.keySet()) {
			count = (count*(map.get(p)+1))%mod;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define MAX 100008
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
#define forn(a,b,c) for(int a=b;a<c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
int n,h[MAX],ans = 0,dp[MAX];
int jump(int idx)
{
    if(idx >= n - 1)
        return 0;
    if(dp[idx] != -1)
        return dp[idx];
    if(idx == n - 2)
        return dp[n - 2] = abs(h[n - 1] - h[n - 2]);
    return dp[idx] = min(abs(h[idx + 1] - h[idx]) + jump(idx + 1), abs(h[idx + 2] - h[idx]) + jump(idx + 2));
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    forn(i,0,n)
        cin >> h[i];
    memset(dp, -1, sizeof(dp));
    ans = jump(0);
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560