akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = [0] * N
from collections import Counter
counter = Counter()
for i in range(N):
    k = "".join(sorted(input().strip()))
    counter[k] += 1

# 4
answer = 0
for k, c in counter.items():
    f = 1
    if c == 1:
        continue
    answer += (c * (c-1)) // 2
print(answer)



Measured memory_bytes: 19012
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=200000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,k,ans,memo[100010];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>k;
    init_fact();
    for(int g=k;g>=1;g--){
        int cnt=modpow(k/g,n)+mod-memo[g];
        cnt%=mod;
        for(int i=1;i*i<=g;i++){
            if(g%i==0){
                memo[i]+=cnt;
                memo[i]%=mod;
                if(i*i!=g){
                    memo[g/i]+=cnt;
                    memo[g/i]%=mod;
                }
            }
        }
        ans+=g*cnt;
        ans%=mod;
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6040
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, ans = 0;
	string str;
	cin >> nn;
	vector<int64> ss(nn, 0);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> str;
		sort(str.begin(), str.end());
		for(int64 jj = 0;jj < 10;jj++)
		{
			ss[ii] += (int64)(pow(26, jj)) * (str[jj] - 'a');
		}
	}
	sort(ss.begin(), ss.end());
	for(int64 ii = 0;ii < nn - 1;ii++)
	{
		for(int64 jj = ii + 1;jj < nn;jj++)
		{
			if(ss[ii] == ss[jj])
			{
				ans++;
			}
			else
			{
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4080
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 10005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int a[N];
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   for(int x=1;x<=100;x++)
   {
       for(int y=1;y<=100;y++)
       {
           for(int z=1;z<=100;z++)
           {

               int val=(x*x + y*y + z*z + x*y + y*z + z*x);
               if(val > 1e4)continue;
               else
                a[val]++;
           }
       }
   }
   for(int i=1;i<=n;i++)
    cout<<a[i]<<endl;
}


Measured memory_bytes: 3688
def solve():
    n = int(input())
    csf = [list(map(int,input().split())) for _ in range(n-1)]
    
    for i in range(n):
        time = 0
        while True:
            if i == n-1:
                print(time)
                break
            if time < csf[i][1]:
                time = csf[i][1] + csf[i][0]
            else:
                if time%csf[i][2] == 0:
                    time += csf[i][0]
                else:
                    time += csf[i][0] + csf[i][2] -  time%csf[i][2]
            i += 1

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9240
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl

//ここから編集する


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

    rep(k,0,N){
        rep(i,0,N){
            rep(j,0,N){
                if(A[i][j] == A[i][k] + A[k][j] && i != k && j != k){
                    B[i][j] = 0;
                }else if(A[i][j] > A[i][k] + A[k][j]){
                    cout << -1 << endl;
                    return 0;
                }

            }
        }
    }

    ll ans = 0;
    rep(i,0,N){
        rep(j,0,N){
            ans += B[i][j];
        }
    }
    ans /= 2;
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <iomanip>

int main(){
	int n,k;
	std::cin >> n >> k;
	int p[n];
	for(int i = 0;i < n;i++){
		std::cin >> p[i];
		p[i]++;
	}
	long long s[n + 1];
	s[0] = 0;
	for(int i = 0;i < n;i++){
		s[i + 1] = s[i] + p[i];
	}
	long long expected[n - k + 1];
	for(int i = 0;i < n - k + 1;i++){
		expected[i] = s[i + k] - s[i];
	}
	std::sort(expected, expected + n - k + 1, std::greater<long long>());
	std::cout << std::setprecision(12) << (long double)expected[0]/2 << std::endl;
  	return 0;
}


Measured memory_bytes: 4096
/* author   : mpily :-()
title : Competing.cpp
time :Sun Mar 22 15:02:46 2020

*/
#include<bits/stdc++.h>
using namespace std;

int main(){
	double L;
	cin>>L;
	L/=3;
	cout<<setprecision(7);
	cout<<fixed;
	cout<<L*L*L<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int i;
    char str[100]={0};
    scanf("%s",str);
    for(i=0;str[i]!='\0';i++){

    }
    for(i=i-1;i>-1;i--){
        printf("%c",str[i]);
    }
    puts("");
    return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,p;
  	cin>>s>>p;
  	int c = 0;
    int len = s.length();
  	for(int i=0;i<len;i++)
    {
		if(s[i]!=p[i]){
          	c++;
        }
    }
  	cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 3788
memo = [int(0) for i in range(87)]
def l(n):
    global memo
    if memo[n]>0:
        return memo[n]
    if n == 0:
        memo[0]=2
        return 2
    elif n == 1:
        memo[1]=1
        return 1
    else:
        memo[n] = l(n-1)+l(n-2)
        return memo[n]
n = int(input())
print(l(n))

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, cnt = 1, res = 0, a;
    cin>>n;
    rep(i, n) {
        cin>>a;
        if(a == cnt) cnt++;
        else res++;
    }
    if(res == n) cout<<-1<<endl;
    else cout<<res<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;

/*
  小さい順: sort(v.begin(), v.end());
  逆順: reverse(v.begin(), v.end());
  vector<pair<ll, ll> > p; ＃ソートした場合、１つ目でソート
  tie(b, a) = p.at(i); #pairを分割
  tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
    string -> int : stoi(S);
  int -> string : to_string(N);
  Sのn文字以降をm文字取り出す : S.substr(n,m)

  int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
  ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/
//126~
//126-e


//a^b(mod 1000000007)",
ll mod_pow(ll a, ll b){
    ll m= 1000000007;
    if(b == 0) return 1;
    if(b % 2 == 0){
        ll d = mod_pow(a,b/2);
        return (d*d)%m;
    }else return a%m*mod_pow(a,b-1)%m;
}

//nCr(mod 100000007),
//O(nlog(mod)),
ll mod_comb(ll n,ll r){
    ll m=1000000007;
    if(r > n) return 0;
    if(n == r || r == 0) return 1;
    ll f1 = 1,f2 = 1;
    for(ll i = n; i >= n-r+1; i--) f1 = f1*i%m;
    for(ll i = r; i >= 1; i--) f2 = f2*i%m;
    return f1*mod_pow(f2,m-2)%m;
}

int main() {

    ll N, count=0, ans=0,S;
    cin >> S;
    ll n=1;
    while(S-3*n>=0){
        count = mod_comb(S-2*n-1,n-1);
        ans += count;
        ans %= 1000000007;
        n++;
    }



    cout << ans << endl;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, q, t;
    string s;
    cin >> n >> s >> q;
    vector<set<int>> a(26);
    rep(i, n)a[s[i]-'a'].insert(i);
    rep(i, q){
        cin >> t;
        if(t == 1){
            int x;
            char c;
            cin >> x >> c;
            a[s[x-1]-'a'].erase(x-1);
            a[c-'a'].insert(x-1);
            s[x-1] = c;
        }
        else{
            int l, r, ans = 0;
            cin >> l >> r;
            rep(j, 26){
                auto it = a[j].lower_bound(l-1);
                if(it != a[j].end() && *it < r)ans++;
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 24196
#include <bits/stdc++.h>
using namespace std;
long long   gcd(long long a,long long b)
{
	if(b==0)return a;
	return gcd(b,a%b);
}
int main()
{
	long long a,b;
	cin>>a>>b;
	cout<<a/gcd(a,b)*b<<endl;

return 0;
}


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

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);
	final int T = stdin.nextInt();

	for ( int i = 1; i <= T; i++ ) {
	    int n = stdin.nextInt();

	    System.out.printf( "Case %d:\n", i );
	    for ( int j = 0; j < 10; j++ ) {
		n = (n * n / 100) % 10000;
		System.out.println(n);
	    }	    
	    
	}	
	
    }
    
}

Measured memory_bytes: 17204
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


int main()
{
  ll W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << Decimal << (W*H/2.0) << ' ';
  if (2*x == W && 2*y == H) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <iomanip>
#include <numeric>
using namespace std;


int main()
{
	string S;
	cin >> S;
	
	vector<int> ans(4, 0);
	for (int i = 0; i < S.size(); i++)
	{
		for (int j = 0; j < S.size(); j++)
		{
			if (j == i)
			{
				continue;
			}

			if (S[i] == S[j])
			{
				ans[i] += 1;
			}
		}
	}

	sort(ans.begin(), ans.end());

	string res = "Yes";
	if (ans[0] != 1)
	{
		res = "No";
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 10000000000000000
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

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;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
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;
}

struct edge { int to, cap, rev; };

vector<edge> g[210];
bool used[210];

void add_edge(int from, int to, int cap) {
	g[from].push_back(edge{ to,cap,(int)g[to].size() });
	g[to].push_back(edge{ from,0,(int)g[from].size() - 1 });
}

int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < (int)g[v].size(); i++) {
		edge &e = g[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				g[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t) {
	int flow = 0;
	while (1) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, INF);
		if (f == 0)return flow;
		flow += f;
	}
}

int x, y, m;

signed main() {
	cin >> x >> y >> m;
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		add_edge(a, x + b, 1);
	}
	for (int i = 0; i < x; i++)add_edge(x + y, i, 1);
	for (int i = 0; i < y; i++)add_edge(x + i, x + y + 1, 1);
	cout << max_flow(x + y, x + y + 1) << endl;
}



Measured memory_bytes: 3692
function main(input) {
  input = input.trim().split("\n");
  const [n, x] = input[0].split(" ").map(n => Number(n));
  const l = input[1].split(" ").map(n => Number(n));
  let result = 1;
  let position = 0;
  for (let i = 0; i < n; i++) {
    position += l[i];
    if (x < position) {
      break;
    }
    result++;
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial
from heapq import heappop, heappush, heappushpop
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    class BigCombination(object):
        __slots__=["mod", "factorial", "inverse"]

        def __init__(self, mod: int=10**9+7, max_n: int=10**6):
            fac, inv=[1], []
            fac_append, inv_append=fac.append, inv.append

            for i in range(1, max_n+1):
                fac_append(fac[-1] * i % mod)

            inv_append(pow(fac[-1], mod-2, mod))

            for i in range(max_n, 0, -1):
                inv_append(inv[-1] * i % mod)

            self.mod, self.factorial, self.inverse=mod, fac, inv[::-1]

        def get_combination(self, n, r):
            if n < r:
                return 0
            return self.factorial[n] * self.inverse[r] * self.inverse[n-r] % self.mod
    N = I()
    A = LI()
    d = dict()
    BC = BigCombination()
    comb = BC.get_combination
    for i, a in enumerate(A):
        if a in d:
            dabu=(i, d[a])
            break
        else:
            d[a] = i
    out = min(dabu) + N - max(dabu)
    for k in range(1, N + 2):
        ans = comb(N + 1, k) - comb(out, k - 1)
        print(ans%mod)
if __name__ == '__main__':
    main()

Measured memory_bytes: 128792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
int main(void){
int x,y,z;
scanf("%d %d %d",&x,&y,&z);

for(int count=0;;count++){
if(count*y+(count+1)*z>x){printf("%d",count-1);return 0;}
}
}

Measured memory_bytes: 128
//13, 10, 2018, 09:07:20 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n, m;

    cin >> n >> m;

    string s, t;

    cin >> s >> t;

    bool ok = true;

    for(ll x = 0LL ; x < n ; x++){
        ll num = x * m;

        if(num % n == 0){
            ll y = num / n;

            if(y < m && s[x] != t[y]){
                ok = false;
                break;
            }
        }
    }

    if(ok){
        ll L = lcm(n, m);
        cout << L << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 640
def Q4(x):
    N = x[0][0]
    edge = x[1:][:]

    # 隣接リストの作成
    adjacent = [0] * N
    for idx in range(N):
        adjacent[idx] = []
    for idx in range(N - 1):
        tmp = edge[idx][:]
        a = int(tmp[0]) - 1
        b = int(tmp[1]) - 1
        adjacent[a].append(b)
        adjacent[b].append(a)

    # 幅優先探索
    def bfs(N, adjacent, V):
        # 木のある頂点Vからの距離を求める
        dist = [0 for i in range(N)]  # 頂点Vからの距離
        isVisit = [False for i in range(N)]  # ある頂点が探索済か
        queue = [V - 1]  # 幅探索用キュー
        isVisit[V - 1] = True

        while queue:
            u = queue.pop()
            for p in adjacent[u]:
                if not isVisit[p]:
                    isVisit[p] = True
                    dist[p] = dist[u] + 1
                    queue.append(p)
        return dist

    Fennec_dist = bfs(N, adjacent, 1)  # フェネック(頂点1スタート)から各頂点の距離
    Snuke_dist = bfs(N, adjacent, N)  # すぬけ(頂点Nスタート)
    Fennec_point, Snuke_point = 0, 0  # 互いに、自分の色を塗れたマスの数

    for idx in range(N):
        if Fennec_dist[idx] <= Snuke_dist[idx]:
            Fennec_point += 1
        else:
            Snuke_point += 1
    if Fennec_point > Snuke_point:
        return 'Fennec'
    else:
        return 'Snuke'

import sys
n = int(input())
l = sys.stdin.readlines()
for idx in range(len(l)):
    l[idx] = l[idx].split()
    l[idx] = list(map(int, l[idx]))
lst = [[n]] + l
print(Q4(lst))

Measured memory_bytes: 51104
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		int[][] adjMatrix = new int[totalVertex][totalVertex];
		//complete the following
		for(int i=0; i<totalVertex; i++){
			LinkedList<Integer> tmp = adjList.get(i);
			for(int j=0; j<tmp.size(); j++){
				adjMatrix[i][tmp.get(j)] = 1;
			}
			for(int k=0; k<totalVertex-1; k++){				
				System.out.print(adjMatrix[i][k] + " ");
			}
			System.out.print(adjMatrix[i][totalVertex-1] + "\n");
		}
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 33248
/**
 * 
 * No.0038	Poker Hand
 * 
 * 
 * @author 	yuichirw <y.iky917@gmail.com>
 * @see		http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=0038&lang=jp
 */
import java.util.*;
import static java.lang.Math.*;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int[] cards;
	
	static boolean read() {
		if(!sc.hasNext()) return false;
		String[] parsed = sc.next().split(",");
		cards = new int[5];
		for(int i = 0; i < 5; i++) {
			cards[i] = Integer.parseInt(parsed[i]);
		}
		return true;
	}
	
	static String solve() {
		
		char[] histgram = new char[14];
		
		for(int i = 0; i < 5; i++) {
			histgram[cards[i]]++;
		}
		
		Arrays.sort(histgram);
		int a,b;
		a = histgram[histgram.length - 1];
		b = histgram[histgram.length - 2];
		if(a == 4) {
			return "four card";
		}
		
		Arrays.sort(cards);
		boolean straight = false; int cnt = 0, c = 0, d = 0;
		for(int i = 0; i < 5; i++) {
			cnt = 0;
			for(int j = 0; j < 4; j++) {
				c = cards[(i+j)%5]; d = cards[(i+j+1)%5];
				if(abs(c-d) != 1 && abs(c-d) != 12) break;
				cnt++;
				if(abs(c-d) == 12 && cnt <= 4) break; 
			}
			if(cnt == 4) {
				straight = true;
				break;
			}
		}

		if(a == 3 && b == 2) {
			return "full house";
		}
		
		if(straight) {
			return "straight";
		}
		
		if(a == 3) {
			return "three card";
		}
		
		if(a == 2 && b == 2) {
			return "two pair";
		}
		
		if(a == 2) {
			return "one pair";
		}
		
		return "null";
	}
	
	public static void main(String[] args) {
		while(read()) {
			System.out.println(solve());
		}
	}
}

Measured memory_bytes: 12000
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	n := scanInt()
	a := make([]int, n)
	for i := range a {
		a[i] = scanInt()
	}
	sort.Ints(a)

	sum := 0
	ans := 0
	for i := 0; i < n-1; i++ {
		ans++
		sum += a[i]
		if sum*2 < a[i+1] {
			ans = 0
		}
	}
	fmt.Println(ans + 1)
}


Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;

const double INF = 1e20;
const int N = 23;
const int M = (1 << 15) + 7;
int n;
double x[N], y[N];
double g[N][N];
double b[M], dp[M];
double a[N];
bool used[N];
double d[N];

double dist(double x, double y)
{
	return sqrt(x * x + y * y);
}

double prim(int mask)
{
	double res = 0;
	for (int i = 0; i < n; i++)
	{
		used[i] = 0;
		d[i] = INF;
	}
	int v = 0;
	while(((mask >> v) & 1) == 0) v++;
	used[v] = 1;
	for (int i = 0; i < n; i++)
		d[i] = g[v][i];
	while(true)
	{
		v = -1;
		for (int i = 0; i < n; i++)
		{
			if (used[i]) continue;
			if (((mask >> i) & 1) == 0) continue;
			if (v == -1 || d[v] > d[i])
				v = i;
		}
		if (v == -1) break;
		used[v] = 1;
		res += d[v];
		for (int i = 0; i < n; i++)
			d[i] = min(d[i], g[v][i]);
	}
	return res;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lf%lf%lf", &x[i], &y[i], &a[i]);
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			g[i][j] = dist(x[i] - x[j], y[i] - y[j]);
	for (int mask = 1; mask < (1 << n); mask++)
	{
		b[mask] = -prim(mask);
//		printf("mask = %d, res = %.4lf\n", mask, -b[mask]);
		int cnt = 0;
		for (int i = 0; i < n; i++)
		{
			if (((mask >> i) & 1) == 0) continue;
			cnt++;
			b[mask] += a[i];
		}
		b[mask] /= cnt;
	}
	dp[0] = INF;
	for (int mask = 1; mask < (1 << n); mask++)
	{
		dp[mask] = 0;
		for (int nmask = mask; nmask > 0; nmask = (nmask - 1) & mask)
			dp[mask] = max(dp[mask], min(b[nmask], dp[mask ^ nmask]));
	}
	printf("%.13lf\n", dp[(1 << n) - 1]);

	return 0;
}

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

int main()
{
    int m;
    cin >> m;
    vector<int> v(m);
    int ans = 0;

    for (int i = 0; i < m; i++) {
        cin >> v[i];
        ans += v[i]-1;
    }

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long ans[500000];
int main(){
  string S;
  cin >> S;

  for(int i = 0; i < S.size() + 1; i++){
    ans[i] = -1;
  }
  for(int i = 0; i < S.size() + 1; i++){
    if(((i == 0) || (S[i - 1] == '>')) &&(i == S.size() || (S[i] == '<'))){
      ans[i] = 0;
    }
  }

  int last_ind = -1;
  for(int i = 0; i < S.size() + 1; i++){
    if(ans[i] == 0){
      for(int j = i - 1; j > last_ind; j--){
        ans[j] = ans[j + 1] + 1;
      }
      if(last_ind > 0){
        ans[last_ind] = max(ans[last_ind], ans[last_ind + 1] + 1);
      }
      for(int j = i + 1; j < S.size() + 1; j++){
        ans[j] = ans[j - 1] + 1;
        if(j == S.size() || S[j] == '>'){
          last_ind = j;
          break;
        }
      }
    }
  }
  cout << accumulate(ans, ans + S.size() + 1, (long long) 0) << endl;
  return 0;
}


Measured memory_bytes: 4740
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,m,k;cin >> n >> m >>k;
    bool check=false;
    rep(i,n+1){
        rep(j,m+1){
            ll res=i*m+j*n-2*i*j;
           //cout << res <<endl;
            if(res==k)check=true;
        }
    }
    if(check)cout <<"Yes" <<endl;
    else cout <<"No" <<endl;
}

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

using namespace std;

using int_type = int64_t;

#define FOR(i, n) for (int_type i = 0; i < n; ++i)

int_type gcd(int_type a, int_type b) {
    return b == 0 ? a : gcd(b, a % b);
}
int_type lcm(int_type a, int_type b) {
    return (a * b) / gcd(a, b);
}

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

    int_type A, B;
    cin >> A >> B;
    cout << 6 - (A + B);

    return 0;
}


Measured memory_bytes: 504
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t dir[4];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	for (size_t i = 0; i < 3; i++)
	{
		int a, b;
		in >> a >> b; --a; --b;
		dir[a]++;
		dir[b]++;
	}
	std::sort(dir, dir + 4);
	if (dir[0] == 1 && dir[1] == 1 && dir[2] == 2) {
		out << "YES" << endl;
	}
	else {
		out << "NO" << endl;
	}

	return 0;
}
#endif


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

int main(){
  int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int a1=h1*60+m1;
  int a2=h2*60+m2;
  cout << a2-a1-k << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)

int main(){
    
    // 1. 入力情報.
    LL A, V, B, W, T;
    scanf("%lld %lld %lld %lld %lld", &A, &V, &B, &W, &T);
    
    // 2. 捕まるかチェック.
    bool ok = false;
    LL xDiff = abs(A - B);
    if(V > W){
        LL vDiff = V - W;
        if(vDiff * T >= xDiff) ok = true;
    }
    
    // 3. 出力.
    printf("%s\n", ok ? "YES" : "NO");
    return 0;
    
}

Measured memory_bytes: 3756
#include<cstdio>
    #include<iostream>
    #include <string>
    #include<algorithm>
    using namespace std;

    int main()
    {
        int a[10] = {};
        
        for(int i=0;i<5;i++)
        {
            cin >> a[i];
        }
        int b, num=0;
        cin >> b;
        
        for(int k=0;k<5;k++)
        {
            for(int j=0;j<5;j++)
            {
                if(a[k] > a[j])
                {
                    if(a[k] - a[j] <= b)
                    {
                        num++;
                    }
                    else
                    {
                        num = 0;
                    }
                }
                else if(a[j] > a[k])
                {
                    if(a[j] - a[k] <= b)
                    {
                        num++;
                    }
                    else
                    {
                        num = 0;
                    }
                }
                else
                {
                    if(b>=0)
                    {
                        num++;
                    }
                    else
                    {
                        num =0;
                    }
                }
            }
        }
        if(num == 25)
        {
            cout << "Yay!";
        }
        else
        {
            cout << ":(";
        }
    }


Measured memory_bytes: 3108
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		int[][] cards = new int[4][13];
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				cards[i][j] = 0;
			}	
		}
		
		String x = "";
		try {
			x = in.readLine();
			int num = Integer.parseInt(x);
			
			for (int i = 0; i < num; i++) {
				x = in.readLine();
				String[] card = x.split(" ");

				int number = (Integer.parseInt(card[1]) - 1);
				switch (card[0].charAt(0)) {
				case 'S' :
					cards[0][number] = 1;
					break;
				case 'H' :
					cards[1][number] = 1;
					break;
				case 'C' :
					cards[2][number] = 1;
					break;
				case 'D' :
					cards[3][number] = 1;
					break;
				}
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				if (cards[i][j] == 0) {
					switch (i) {
					case 0 :
						System.out.println("S " + (j + 1));
						break;
					case 1 :
						System.out.println("H " + (j + 1));
						break;
					case 2 :
						System.out.println("C " + (j + 1));
						break;
					case 3 :
						System.out.println("D " + (j + 1));
						break;
					}
				}
			}	
		}
	}
}

Measured memory_bytes: 24388
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)

struct unionfind{
	vector<int> data;
	vector<int> size;
	unionfind(int n){
		for(int i=0;i<n;i++){
			data.push_back(i);
			size.push_back(1);
		}
	}
	
	int find(int x){
		if(data[x]==x)return x;
		return data[x]=find(data[x]);
	}
	
	bool unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return false;
		data[x]=y;
		size[y]+=size[x];
		return true;
	}
	
	bool check(int x,int y){
		return (find(x)==find(y));
	}
	
	int get_size(int x){
		int X = find(x);
		return size[X];
	}
};


int main(){
	int N;
	cin>>N;
	vector<vector<int>> x(100010,vector<int>(0)),y(100010,vector<int>(0));
	vector<pair<int,int>> V(N);
	
	unionfind uf(N);
	
	for(int i=0;i<N;i++){
		int a,b;
		cin>>V[i].first>>V[i].second;
		V[i].first--;V[i].second--;
		
		if(x[V[i].first].size()!=0){
			uf.unite(i,x[V[i].first][0]);
		}
		if(y[V[i].second].size()!=0){
			uf.unite(i,y[V[i].second][0]);
		}
		
		x[V[i].first].push_back(i);
		y[V[i].second].push_back(i);
	}
	
	vector<vector<int>> P(100010,vector<int>(0));
	
	for(int i=0;i<N;i++){
		P[uf.find(i)].push_back(i);
	}
	
	long long ans = 0;
	
	for(int i=0;i<N;i++){
		set<int> xx,yy;
		for(int j=0;j<P[i].size();j++){
			xx.insert(V[P[i][j]].first);
			yy.insert(V[P[i][j]].second);
		}
		long long a = (long long)xx.size()*yy.size();
		if(a==0)continue;
		ans = (long long)ans + a - P[i].size();
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 17136
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a=a+b;
    c=c+d;
    if(a>c)
    {
        cout<<"Left";
    }
    else if(a==c)
        cout<<"Balanced";
    else
        cout<<"Right";
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

const int maxn=1e6+10;

bool bk[maxn];

int num[maxn];

int main()
{
//	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int n;
	
	scanf("%d",&n);
	
	int maxx=-1;
	
	for(int i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
		
		if(num[i]>maxx)
			maxx=num[i];
	}
	
	sort(num,num+n);
	
	int cnt=0;
	
	for(int i=0;i<n;i++)
	{
		if(bk[num[i]]==false)
		{
			if(num[i]!=num[i+1])
				cnt++;
			
			int now=num[i];
			
			while(now<=maxx)
			{
				bk[now]=true;
				now+=num[i];
			}
			
		}
	}
	
	printf("%d\n",cnt);
	
	return 0;
}

Measured memory_bytes: 5352
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define st first
#define nd second

using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set =
	tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
#define shandom_ruffle random_shuffle
 
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;

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

	ll n, a, b;
	cin >> n >> a >> b;

	if (a % 2 == b % 2) {
		cout << abs(a - b) / 2 << "\n";
	} else {
		ll opt1 = 0, opt2 = 0;
		const ll nafter = abs(a - b) / 2;
		opt1 = (min(a, b) - 1) + 1 + nafter;
		opt2 = (n - max(a, b)) + 1 + nafter;
		cout << min(opt1, opt2) << "\n";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int H,N;
  cin>>H>>N;
 
  for(int i=0;i<N;i++){
 int A;
    cin>>A;
    H-=A;
    if(0>=H){
    cout<<"Yes"<<endl;
      return 0;
    }
    
    
  }
  cout<<"No"<<endl;
  return 0;

}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<cstring>
using namespace std;
int a[4];
int main(){
    int n,m,flag=0,flag1=0;
    memset(a,0,sizeof(a));
    cin>>n>>m;
    if(n==1&&m==0){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<m;i++){
        int s,c;
        cin>>s>>c;
        if(s==1)
            flag1=1;
        if(a[s]==0){
            a[s]=c;
        }
        else{
            if(c!=a[s])
                flag=1;
        }
    }
    if(a[1]==0&&flag1==1&&n!=1){
        flag=1;
    }
    else if(a[1]==0&&n!=1){
        a[1]=1;
    }
    if(flag==1)
        cout<<-1<<endl;
    else{
    for(int i=1;i<=n;i++)
        cout<<a[i];
    cout<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
#include <functional>
 
using namespace std;
typedef long long ll;
const ll INF = 1e18;

# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
# define pb push_back
 
ll K, N;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> K >> N;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
    }
    
    ll sumMigi = 0;
    ll sumHidari = 0;
    ll maxDiff = 0;
    ll diff = 0;
    // 右回り
    rep(i, N) {
        if (i==N-1) {
            diff = K-A[i] + A[0];
        } else {
            diff = A[i+1] - A[i];
        }
        sumMigi += diff;
        if (maxDiff<diff) {
            maxDiff = diff;
        }
    }
    sumMigi -= maxDiff;

    reverse(all(A));
    
    rep(i, N) {
        if (i==N-1) {
            diff = A[i] + K-A[0];
        } else {
            diff = A[i] - A[i+1];
        }
        sumHidari += diff;
        if (maxDiff<diff) {
            maxDiff = diff;
        }
    }
    sumHidari -= maxDiff;
        
    cout << min(sumMigi, sumHidari) << endl;
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll temp=0;
    if(b||a)
    temp=n/(a+b);
    ll ans=0;
    ans=temp*a;
    if(a)
    ans=ans+min(n%(a+b),a);
    cout<<ans;
}



Measured memory_bytes: 3596
#include <vector>
#include <iostream>
#include <iomanip>
#include <map>
#include <string.h>
#include <cstring>
#include <queue>
#include <limits>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <cmath>
#include <stdio.h>
#include <set>
#include <cstdio>
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define FOR(i, a) for(int i = 0; i < (a); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int N = 55;
int x;
int main() {
    while (cin >> x) {
        cout << 24 * 2 - x << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,m;
bool f[200010];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		if(a==1 || a==n)
		{
			if(f[b])
			{
				printf("POSSIBLE");
				return 0;
			}
			f[b]=true;
		}
		if(b==1 || b==n)
		{
			if(f[a])
			{
				printf("POSSIBLE");
				return 0;
			}
			f[a]=true;
		}
	}
	printf("IMPOSSIBLE");
	return 0;
} 

Measured memory_bytes: 384
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long K = lread();
    auto A = aryread();
    long eval(long x)
    {
        foreach (i; 0 .. K)
            x = x - (x % A[i]);
        return x;
    }

    long a = () {
        long ok = 0;
        long ng = long.max / 2;
        while (1 < ng - ok)
        {
            long m = (ok + ng) / 2;
            if (eval(m) < 2)
                ok = m;
            else
                ng = m;
        }
        return ng;
    }();
    long b = () {
        long ok = 0;
        long ng = long.max / 2;
        while (1 < ng - ok)
        {
            long m = (ok + ng) / 2;
            if (eval(m) <= 2)
                ok = m;
            else
                ng = m;
        }
        return ok;
    }();
    if (b < a)
    {
        writeln(-1);
        return;
    }
    writefln("%s %s", a, b);
}


Measured memory_bytes: 4516
program making_palindrome
  implicit none
  integer(8), parameter :: inf = 1e18
  integer :: n, i
  character(20) :: s(50, 2) = ''
  integer(8) :: c(50) = 0, m(50, 21, 2) = 0, x = inf
  logical :: u(50, 21, 2) = .false.
  read(*,*) n
  do i = 1, n
    read(*,*) s(i, 1), c(i)
    s(i, 2) = reverse(s(i, 1)(1:len_trim(s(i, 1))))
  end do
  do i = 1, n
    x = min(x, solve(i, 1, 1) + c(i))
  end do
  write(*,'(i0)') merge(x, -1_8, x < inf)
contains
  function reverse(s) result(res)
    character(*), intent(in) :: s
    character(len_trim(s)) :: res
    integer :: n, i
    n = len_trim(s)
    do i = 1, n
      res(i:i) = s(n - i + 1:n - i + 1)
    end do
  end
  recursive integer(8) function solve(i, j, k) result(res)
    integer, intent(in) :: i, j, k
    integer :: l, r, t
    logical :: f
    res = m(i, j, k)
    if (u(i, j, k)) return
    u(i, j, k) = .true.
    m(i, j, k) = inf
    l = j
    r = len_trim(s(i, k))
    f = .true.
    do while (l < r)
      if (s(i, k)(l:l) /= s(i, k)(r:r)) then
        f = .false.
        exit
      end if
      l = l + 1
      r = r - 1
    end do
    if (f) then
      m(i, j, k) = 0
      res = 0
      return
    end if
    do t = 1, n
      l = j
      r = 1
      do while (l <= len_trim(s(i, k)) .and. r <= len_trim(s(t, 3 - k)))
        if (s(i, k)(l:l) /= s(t, 3 - k)(r:r)) exit
        l = l + 1
        r = r + 1
      end do
      if (l == len_trim(s(i, k)) + 1) then
        m(i, j, k) = min(m(i, j, k), solve(t, r, 3 - k) + c(t))
      end if
      if (r == len_trim(s(t, 3 - k)) + 1) then
        m(i, j, k) = min(m(i, j, k), solve(i, l, k) + c(t))
      end if
    end do
    res = m(i, j, k)
  end
end program making_palindrome

Measured memory_bytes: 2932
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;

int main(){
  double h,w,x,y;
  cin>>w>>h>>x>>y;
  cout<<w*h/2.0<<" "<<(w==x*2&&h==y*2)<<endl;
  return 0;
}


Measured memory_bytes: 256