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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll n,X;cin >>n>>X;
   vector<ll>x(n);
   vector<ll>d(n);
    for (int i = 0; i < n; ++i) {
        cin >>x[i];
        d[i]=abs(X-x[i]);
    }
    ll g=0;
    for (int i = 0; i < n; ++i) {
        g=__gcd(g,d[i]);
    }
    cout <<g<<endl;
   return 0;
}

Measured memory_bytes: 1792
n = int(input())
# 小数以下桁数、2の倍数、5の倍数
num = {}
for i in range(n):
    a = input()
    if "." in a:
        temp = a.index(".")
        a1 = len(a) - temp - 1
        a = int(a[:temp] + a[temp + 1:])
    else:
        a1 = 0
        a = int(a)
    a_ = a
    a2 = 0
    for i in range(18):
        if a % 2 == 0:
            a2 += 1
            a //= 2
        else:
            break
    a3 = 0
    for i in range(18):
        if a_ % 5 == 0:
            a3 += 1
            a_ //= 5
        else:
            break
    num.setdefault((a1, a2, a3), 0)
    num[(a1, a2, a3)] += 1
num2 = []
for i, j in num.items():
    num2.append([i, j])
ans = 0
for i in range(len(num2)):
    for j in range(i, len(num2)):
        if i == j:
            temp = num2[i]
            if temp[0][0] <= min(temp[0][1], temp[0][2]):
                ans += temp[1] * (temp[1] - 1) // 2
        else:
            temp = num2[i]
            temp2 = num2[j]
            if temp[0][0] + temp2[0][0] <= min(temp[0][1] + temp2[0][1], temp[0][2] + temp2[0][2]):
                ans += temp[1] * temp2[1]
print(ans)

Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  for(int i = 0; i < M; i++) {
    cin >> a.at(i) >> b.at(i);
  }

  int city = 0;
  for(city = 0; city < N; city++) {
    int count  = 0;
    for(int i = 0; i < M; i++) {
      if(a.at(i) == city + 1) {
        count++;
      }
      if(b.at(i) == city + 1) {
        count++;
      }
    }
    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#define INF 1000000000
#define LM 55555
using namespace::std;


long long mc,pc,p[100001],m[100001],n, bc, now, C, H, W, X[100000],K, Y, ans, r, l, numcon, N, M;
string S,s,a[101],b[101],c[101];
bool h,k[101];
int main() {
	cin >> N>>K;

	cout << (N-1)*(K-1) << endl;

	return 0;

}




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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> a(n);
  std::cin >> a;

  int64_t p = 0, p_c = 0, m = 0, m_c = 0;

  for (int64_t i = 0; i < n; i++) {
    if (i % 2 == 0) {
      p += a[i];
      if (p <= 0) {
        p_c += -p + 1;
        p = 1;
      }
      m += a[i];
      if (0 <= m) {
        m_c += m + 1;
        m = -1;
      }
    } else {
      p += a[i];
      if (0 <= p) {
        p_c += p + 1;
        p = -1;
      }
      m += a[i];
      if (m <= 0) {
        m_c += -m + 1;
        m = 1;
      }
    }
  }

  std::cout << std::min(p_c, m_c) << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>
#include <complex>

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

struct Edge {
    int id;
    int to;
};

constexpr int MAX_N = 50;
constexpr int MAX_M = 20;

vector<Edge> tree[MAX_N];

int64 enumerateAffectedEdges(int u, int par, int goal) {
    int64 res = 0;
    for (const Edge& e: tree[u]) {
        if (e.to == par) continue;
        if (e.to == goal) {
            res |= (1LL << e.id);
        } else {
            int64 subres = enumerateAffectedEdges(e.to, u, goal);
            res |= subres;
            if (subres > 0) res |= (1LL << e.id);
        }
    }
    return res;
}

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

    int n;
    cin >> n;

    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        tree[a].push_back((Edge){ i, b });
        tree[b].push_back((Edge){ i, a });
    }

    int m;
    cin >> m;

    vector<int64> affected_edges(m);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        affected_edges[i] = enumerateAffectedEdges(u, -1, v);
    }

    int64 ans = 0;
    for (int mask = 0; mask < (1 << m); mask++) {
        int cnt = 0;
        int64 union_affected_edges = 0;
        for (int i = 0; i < m; i++) {
            if ((mask >> i) & 1) {
                cnt++;
                union_affected_edges |= affected_edges[i];
            }
        }
        int white = 0;
        for (int i = 0; i < n - 1; i++) {
            if ((union_affected_edges >> i) & 1) {
                white++;
            }
        }
        if (cnt % 2 == 1) {
            ans -= (1LL << (n - 1 - white));
        } else {
            ans += (1LL << (n - 1 - white));
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string a,b,c;
	cin>>n>>a>>b>>c;
	int summ=0;
	for(int i=0;i<n;i++){
		if(a[i]!=b[i]&&a[i]!=c[i]&&b[i]!=c[i])
		   summ+=2;
		else if(a[i]==b[i]&&b[i]==c[i])
		   summ+=0;
		else
		   summ++;
	}
	cout<<summ<<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int d=sc.nextInt();
    int[] c=new int[26];
    int[] wc=new int[27];
    for(int i=0;i<26;i++){
      c[i]=sc.nextInt();
      wc[i+1]=wc[i]+c[i];
    }
    Random rd=new Random();
    for(int i=0;i<d;i++){
      int r=rd.nextInt(wc[26]);
      for(int j=1;j<=26;j++){
        if(r<wc[j]){
          System.out.println(j);
          break;
        }
      }
    }
  }
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll N;
    cin >> N;
    vector<string> S;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        S.pb(s);
    }
    asort(S);
    queue<string> que;
    ll maxcnt = 0;
    ll cnt = 1;
    string now = S[0];
    for (int i = 1; i < N; i++) {
        if(now == S[i]){
            cnt++;
        } else {
            if(maxcnt < cnt){
                while(!que.empty()) que.pop();
                maxcnt = cnt;
                que.push(now);
            } else if(maxcnt == cnt){
                que.push(now);
            }
            cnt = 1;
            now = S[i];
        }
    }
    if(maxcnt < cnt){
        while(!que.empty()) que.pop();
        maxcnt = cnt;
        que.push(now);
    } else if(maxcnt == cnt){
        que.push(now);
    }
    int size = que.size();
    for (int i = 0; i < size; i++) {
        cout << que.front() << endl;
        que.pop();
    }
}

Measured memory_bytes: 16004
def solve():
    N,x=map(int,input().split())
    a=list(map(int,input().split()))
    a=sorted(a)
    ans = 0
    for i,ai in enumerate(a):
        x -= ai
        if x == 0:
            return i + 1
        elif x < 0:
            return i
    return N - 1

print(solve())


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007


int main() {
	string s;
	cin>>s;
	bool ch=true;
	if(s.size()%2!=0){
		cout << "No";
		return 0;
	}
	for(ll i=0;i<s.size();i+=2){
		string k;
		k+=s[i];
		k+=s[i+1];
		//cout << k<<endl;
		if("hi"!=k){
			ch=false;
		}
	}
	cout << (ch?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,m; cin>>n>>m;
	map<int,int> y;
	rep(i,n){
		int x; cin>>x; y[x]+=1;
	}
	VI cnt(m,0), p(m,0);
	for(auto it: y){
		int x,k; tie(x,k)=it;
		cnt[x%m]+=k;
		p[x%m]+=k/2*2;
	}
	int ans=0;
	rep(i,m){
		int j=(m-i)%m;
		if(i==j){
			ans+=cnt[i]/2;
		}else if(i<j){
			int k=min(cnt[i],cnt[j]);
			ans+=k;
			ans+=min(cnt[i]-k,p[i])/2;
			ans+=min(cnt[j]-k,p[j])/2;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5760
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static Reader;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var n = NextLong;
        var k = NextLong;
        var a = Enumerable.Range(0,  (int)n).Select(_ => NextLong).OrderBy(x => x).ToArray();
        var Valid = -(long)1e18 + 1;
        var Invalid = (long)1e18 + 1;
        //小さい数の個数
        while (Invalid - Valid > 1)
        {
            var target = (Valid + Invalid) / 2;
            var res = 0L;
            //res = Enumerable.Range(0, a.Length).Sum(ind => Count(ind, mid));
            for (int ind = 0; ind < a.Length; ind++)
            {
                int valid, invalid;
                //負
                if (a[ind] < 0) { valid = a.Length; invalid = ind; }
                //正
                else{ invalid = a.Length; valid = ind; }

                while (Abs(valid - invalid) > 1)
                {
                    var mid = (valid + invalid) / 2;
                    if (a[ind] * a[mid] <= target) valid = mid;
                    else invalid = mid;
                }
                if (a[ind] < 0) res += a.Length - valid;
                else res += valid - ind;
            }
            if (res < k) Valid = target;
            else Invalid = target;
        }
        Console.WriteLine(Invalid);
    }
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }

    public static long NextLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0; int sign = 1; while (Buffer[ptr] < 45) Move();
            if (Buffer[ptr] == 45) { Move(); sign = -1; }
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res * sign;
        }
    }
}


Measured memory_bytes: 26568
#include <stdio.h>

int main(void) {
  int i, j, n, m, q, l, r, a, b;
  scanf("%d%d%d", &n, &m, &q);
  int cnt[n][n];
  for(i = 0; i < n; ++i) for(j = 0; j < n; ++j) cnt[i][j] = 0;
  for(i = 0; i < m; ++i) {
    scanf("%d%d", &l, &r);
    r--;
    for(j = 0; j < l; ++j) cnt[j][r]++;
  }
  for(i = 0; i < n; ++i) for(j = 1; j < n; ++j) cnt[i][j] += cnt[i][j - 1];
  for(i = 0; i < q; ++i) {
    scanf("%d%d", &a, &b);
    printf("%d\n", cnt[--a][--b]);
  }
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 29;
int n;
int a[200002]; 
int main() {
	cin >> n;
	rep(i, n) cin >> a[i];
	int perm = 1;
	rep(i, n) {
		if (a[i] == perm) perm++;
	}
	if (perm == 1) cout << -1 << endl;
	else cout << n - perm + 1<< endl;
	return 0;
}

Measured memory_bytes: 1024
import Control.Monad
import Data.List
f n s
 |null s=n
 |null (init s)=n
 |s!!0=='A'&&s!!1=='B'=f(n+1)(drop 1 s)
 |otherwise=f(n)(drop 1 s)
main=do
 n<-readLn :: IO Int
 ss<-replicateM n getLine
 let sr=sum$map(f 0)ss
     sa=sum$map(\x->if head x=='B' &&last x/='A'then 1 else 0)ss
     sb=sum$map(\x->if last x=='A' &&head x/='B'then 1 else 0)ss
     ab=sum$map(\x->if head x=='B' &&last x=='A'then 1 else 0)ss
     sq=if sa==0&&sb==0&&ab==0 then min sa sb else if sa==0&&sb==0 then ab-1 else if sa==0||sb==0 then ab else ab+1+(min (sa-1) (sb-1))
 print$sr+sq

Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int n, x;
	while (true) {
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		int res = 0;
		FOR(i, 1, n + 1) FOR(j, i + 1, n + 1) FOR(k, j + 1, n + 1) {
			if (i + j + k == x) ++res;
		}
		cout << res << endl;
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define intt long long
using namespace std;
int i , j;
int main ()
{
    intt n,ans = 0;
    cin >> n;
    for ( i = 1 ; i <= n ; i++ )
    {
        int x;
        cin >> x;
        ans += x;
    }
    cout << ans-n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
   
        int i,j,k,m,n;
        int cnt=0,ans=0,cnt1=0,ans1=0;
        char a[110],b[110];
        cin>>n;
        for(i=1; i<=n; i++)
            cin>>a[i];
        for(i=1; i<=n; i++)
            cin>>b[i];
        j=1;
        for(i=1; i<=n; i++)
        {
            for(; j<=n;)
            {
                if(a[i]==b[j])
                {
                    j++;
                    cnt++;
                    break;
                }
                else
                {
                    j=1;
                    cnt=0;
                    break;
                }
            }
        }
        j=n;
        for(i=n; i>=1; i--)
        {
            for(; j>=1;)
            {
                if(a[i]==b[j])
                {
                    j--;
                    ans++;
                    break;
                }
                else
                {
                    j=n;
                    ans=0;
                    break;
                }
            }
        }
        j=1;
        for(i=1; i<=n; i++)
        {
            for(; j<=n;)
            {
                if(a[j]==b[i])
                {
                    j++;
                    cnt1++;
                    break;
                }
                else
                {
                    j=1;
                    cnt1=0;
                    break;
                }
            }
        }
        j=n;
        for(i=n; i>=1; i--)
        {
            for(; j>=1;)
            {
                if(a[j]==b[i])
                {
                    j--;
                    ans1++;
                    break;
                }
                else
                {
                    j=n;
                    ans1=0;
                    break;
                }
            }
        }
        cout<<min(min(min(2*n-cnt,2*n-ans),2*n-cnt1),2*n-ans1)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        d: usize,
        x: [[i32; d]; n]
    };

    let x: Vec<Vec<i32>> = x;
    let mut count = 0;

    for i in 0..n - 1 {
        for j in i + 1..n {
            let mut sum: i32 = 0;

            for (x1, x2) in x[i].iter().zip(x[j].iter()) {
                let d = (x1 - x2).pow(2);
                sum += d;
            }

            let result = (sum as f64).sqrt();

            let result_int = result as i32;

            if result == result_int as f64 {
                count += 1;
            }
        }
    }

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


Measured memory_bytes: 2172
def input_int():
    return map(int, input().split())

def input_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=input_int()



dicts={}
dicts["JPY"]=0
dicts["BTC"]=0

for i in range(N):
    x, u = input().split()
    dicts[u] += float(x)

sums = dicts["JPY"] + dicts["BTC"] * 380000.0

print(sums)

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;
ll dp[10][20];//dp[i][j]代表以i开头的j位数有多少个lunlun 
ll sum[20], pos;
ll k;
void dfs(ll num, ll lst) {
	if (num > pos) return;
	if (num == 1) {
		for (ll i = 1; i < 10; i++) {
			if (k > dp[i][pos - num + 1]) {
				k -= dp[i][pos - num + 1];
			} else {
				cout << i;
				dfs(num + 1, i);
				break;
			}
		}
	} else {
		for (ll i = lst - 1; i <= lst + 1; i++) {
			if (i < 0 || i > 9) continue;
			if (k > dp[i][pos - num + 1]) {
				k -= dp[i][pos - num + 1];
			} else {
				cout << i;
				dfs(num + 1, i);
				break;
			}
		}
	}
}
int main() {
	cin >> k;
	for (ll i = 0; i < 10; i++) {
		dp[i][1] = 1;
	}
	sum[1] = 9;
	for (ll j = 2; j <= 10; j++) {
		for (ll i = 0; i < 10; i++) {
			if (i != 0 && i != 9) {
				dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1] + dp[i + 1][j - 1];
			} else if (i != 0) {
				dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1];
			} else if (i != 9) {
				dp[i][j] = dp[i][j - 1] + dp[i + 1][j - 1];
			}
			if (i != 0) sum[j] += dp[i][j];
		}
	}
	for (ll i = 1; i <= 20; i++) {
		if (k > sum[i]) {
			k -= sum[i];
		} else {
			pos = i;
			break;
		}
	}
	dfs(1, 0);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define nnm(x, y) (((y) + (x) % (y)) % (y))
template<typename T> inline T gcd(T x, T y) { if(x < y) swap(x, y); T mod = x % y; if(mod == 0) return y; return gcd(y, mod); }
template<typename T> inline T lmc(T x, T y) { return x / gcd(x, y) * y; }

int main(int argc, char* argv[])
{
	ll K, A, B;
	scanf("%lld%lld%lld", &K, &A, &B);
	if (A >= K) printf("1\n");
	else if (A > B) printf("%lld\n", 2 * ((K - A) % (A - B) == 0 ? (K - A) / (A - B) : (K - A) / (A - B) + 1 ) + 1);
	else printf("-1\n");

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {
    
    int n;
    scanf("%d", &n);

    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0) {
            printf(" %d", i);
        } else {
            int check = i;
            while (check) {
                if (check % 10 == 3) {
                    printf(" %d", i);
                    break;
                }
                check /= 10;
            }
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2056
#include<cstdio>
#include<algorithm>
using namespace std;
int a[5];
int main()
{
    for(int i=1;i<=3;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+4);
    printf("%d\n",a[1]+a[2]);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int n,i,j,min,b,c=0;
  scanf("%d",&n);
  if(n<0||n>100)return 0;
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]<0||a[i]>100)return 0;
  }
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(a[j]<a[min])min=j;
    }
    if(a[i]==a[min]);
    else{b=a[i];
    a[i]=a[min];
    a[min]=b;
    c++;}
  }
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d\n",a[i]);
    else printf("%d ",a[i]);
    }
  printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 2084
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const ll INF = 10e16;
const int maxN = 200010;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1000000007;

ll x,y,z;

int main()
{
	cin>>x;
	cin>>y;
	if(x == 1 || y==1)
	{
		z = 1;
		cout<<z<<endl;
		return 0;
	}
	if(x%2 == 0)
	{
		z = x*y / 2;
	}
	else
	{
		z = (x/2) * y;
		z += (y%2==0)?y/2:y/2+1;
	}
	cout<<z<<endl;
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

ll a[60], b[60], c[60], d[60];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> a[i] >> b[i];
	for (int i = 0; i < M; i++) cin >> c[i] >> d[i];
	ll min = 0;
	int p = 0;
	for (int i = 0; i < N; i++) {
		min = mod;
		for (int j = 0; j < M; j++) {
			if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < min) {
				min = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				p = j;
			}
		}
		cout << p + 1 << endl;
	}
}


Measured memory_bytes: 256
use proconio::*;

fn dfs(s: &[usize], a: &mut [usize]) -> Option<Vec<usize>> {
    if s.is_empty() {
        return Some(vec![]);
    }
    let op = s[0];
    let s = &s[1..];
    let mut x = op.trailing_zeros() as usize;
    let mut y = (op ^ (1 << x)).trailing_zeros() as usize;
    if a[x] < a[y] {
        std::mem::swap(&mut x, &mut y);
    }
    if a[x] == 0 {
        return None;
    }
    if a[x] == a[y] {
        for &(x, y) in [(x, y), (y, x)].iter() {
            a[x] -= 1;
            a[y] += 1;
            if let Some(mut ans) = dfs(s, a) {
                ans.push(y);
                return Some(ans);
            }
            a[x] += 1;
            a[y] -= 1;
        }
    } else {
        a[x] -= 1;
        a[y] += 1;
        if let Some(mut ans) = dfs(s, a) {
            ans.push(y);
            return Some(ans);
        }
        a[x] += 1;
        a[y] -= 1;
    }
    None
}

#[fastout]
fn run() {
    input! {
        n: usize,
        mut a: [usize; 3],
        s: [String; n],
    }
    let s = s
        .into_iter()
        .map(|s| match s.as_str() {
            "AB" => 3,
            "BC" => 6,
            "AC" => 5,
            _ => unreachable!(),
        })
        .collect::<Vec<_>>();
    if let Some(ans) = dfs(&s, &mut a) {
        println!("Yes");
        let op = "ABC".chars().collect::<Vec<_>>();
        for a in ans.iter().rev() {
            println!("{}", op[*a]);
        }
    } else {
        println!("No");
    }
}

fn main() {
    run();
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

// clang-format off
template<typename T>
bool chmax(T& a, const T& b) {if (a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a, const T& b) {if (a>b){a=b;return true;}return false;}
// clang-format on

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec v(n);
    init(v);
    vec l(n);
    vec r(n);

    l[0] = v[0];
    For(i, 1, n - 1) l[i] = max(l[i - 1], v[i]);
    r[n - 1] = v[n - 1];
    Forr(i, n - 2, 0) r[i] = max(r[i + 1], v[i]);

    print(r[1]);
    For(i, 1, n - 2) print(max(l[i - 1], r[i + 1]));

    print(l[n - 2]);

    return 0;
}


Measured memory_bytes: 6272
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		List<Integer> list = new ArrayList<>();
		for(int i=a; i<=b; i++){
			if(i < a + k || i > b - k){
				list.add(i);
			}
		}
		list.stream().distinct().forEach(System.out::println);
	}
}


Measured memory_bytes: 36368
import std;

void main() {
  int n;
  string s;
  scan(n);
  scan(s);
  auto w = new int[](n + 1);
  auto b = new int[](n + 1);
  foreach (i; 1 .. n + 1) {
    b[i] = b[i-1] + (s[i-1]=='#');
  }
  foreach_reverse (i; 0 .. n) {
    w[i] = w[i+1] + (s[i]=='.');
  }
  auto ans = 1_000_000_000;
  foreach (i; 0 .. n + 1) {
    chmin(ans, b[i] + w[i]);
  }
  writeln(ans);
}

long[] factor(int x) {
  long[] res;
  for (int i = 2; i*i <= x; i++) {
    while (x % i == 0) {
      x /= i;
      res ~= i;
    }
    
  }
  if (x > 1) res ~= x;
  return res;
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}
 
void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
 
bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}
 
bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}
 
void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}

Measured memory_bytes: 5556
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		for(int i = 0; i < N; i++) {
			X = Math.max(X, sc.nextInt());
		}
		for(int i = 0; i < M; i++) {
			Y = Math.min(Y, sc.nextInt());
		}
		if(X < Y) {
			System.out.println("No War");
		}else {
			System.out.println("War");
		}
	}
}


Measured memory_bytes: 27340
n = int(input())
s = []
t = []
for _ in range(n):
    i = int(input())
    s.append(i)
    if i % 10 != 0:
        t.append(i)

if sum(s) % 10 != 0:
    print(sum(s))
else:
    print(sum(s) - min(t)) if len(t) != 0 else print(0)


Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,sum1[1000][1000],sum2[1000][100],flag;
char s[1000][1000];
int main(){
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++){
                scanf("%s",s[i]);
                for(int k=1;k<=m;k++)
                if(s[i][k-1]=='#'){
                for(int j=1;j<=m;j++)
                        sum1[i][j]++;
                for(int j=1;j<=n;j++)
                        sum2[j][k]++;
                }
        }
        for(int i=1;i<=n;i++){
                flag=0;
                for(int j=1;j<=m;j++)
                        if(sum1[i][j]&&sum2[i][j])
                                printf("%c",s[i][j-1]),flag=1;
                if(flag) printf("\n");
        }
}



Measured memory_bytes: 768
#include <iostream>
#include <string>

using namespace std;

int main(){
while(1){
string moji;
string mojihi;
string mojimi;
cin >> moji;
int l;
l=moji.size();
if(moji=="-") {
break;
}
int a,i;
cin >>a;
for(i=0; i<a; i++){
int b;
cin >>b;
mojihi = moji.substr(0,b);
mojimi = moji.substr(b,l-b);
moji= mojimi+mojihi;
}
cout<<moji<<endl;
}
    return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 k, n, a[202020];
void solve(){
	cin >> k >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	i64 ma = 0;
	for(int i = 0; i < n; i++){
		chmax(ma, (a[i]-a[(i-1+n)%n] + k)%k);
	}
	cout << k-ma << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,k;
ll h[100005];

int main(void){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%lld",&h[i]);
    }
    sort(h,h+n);
    ll ans=h[k-1]-h[0];
    for(int i=0;i<=n-k;i++){
        ans=min(ans,h[i+k-1]-h[i]);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int l,r,d; cin >> l >> r >> d;
    cout << r/d-(l-1)/d << endl;
}


Measured memory_bytes: 3596
N, K, S = map(int, input().split())

if S == 10**9:
    Ans = [S for _ in range(K)] + [1 for _ in range(N-K)]
else:
    Ans = [S for _ in range(K)] + [S+1 for _ in range(N-K)]
for ans in Ans:
    print(ans, end=' ')

Measured memory_bytes: 52896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
const int max_n=2500;
ll fac[max_n], finv[max_n], inv[max_n];
// テーブルを作る前処理 O(max_n)
void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < max_n; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv [mod%i] *  (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
// 二項係数計算 O(1)
long long modcom(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main() {
  init();
  int n,k;cin>>n>>k;
  rep(i,k)cout<<modcom(n-k+1,i+1)*modcom(k-1,i)%mod<<endl;
}


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

template <typename _tp> inline void read(_tp&x) {
	char ch=getchar(),ob=0;x=0;
	while(ch!='-'&&!isdigit(ch))ch=getchar();if(ch=='-')ob=1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();if(ob)x=-x;
}

const int N = 201000;
char str[N];
int f[26][N], n;
int nxt[N], t;

ll calc(int*a, ll p) {
	if(p <= n) return a[p];
	if(p <= (n<<1)) return a[n] + a[p-n];
	ll t0 = n, t1 = n + t;
	ll r0 = a[n], r1 = a[n] + a[t];
	while(t0 + t1 <= p) {
		t0 += t1, r0 += r1;
		swap(t0, t1), swap(r0, r1);
	}
	return r1 + calc(a, p - t1);
}

bool fac;

ll work(int*a, ll p) {
	if(p <= n) return a[p];
	if(p <= (n<<1)) return a[n] + a[p-n];
	if(fac) {
		p -= n;
		return a[n] + (p/t) * a[t] + a[p%t];
	}
	return calc(a, p);
}

int main() {
	scanf("%s", str+1);
	n = strlen(str+1) >> 1;
	for(int i=0;i<26;++i) {
		int*arr = f[i];
		for(int j=1;j<=n;++j)
			arr[j] = arr[j-1] + (str[j] == (i+'a'));
	}
	
	for(int i=2,k=0;i<=n;++i) {
		while(k and str[k+1] != str[i]) k = nxt[k];
		if(str[k+1] == str[i]) ++k;
		nxt[i] = k;
	}
	
	t = n - nxt[n];
	fac = (n%t == 0);
	
	ll l, r; scanf("%lld%lld",&l,&r);
	for(int i=0;i<26;++i)
		printf("%lld ", work(f[i], r) - work(f[i], l-1));
	putchar(10);
	return 0;
}

Measured memory_bytes: 20352
#include <iostream>
using namespace std;
void uruu(int, bool&);

int main() {
	int a, b;
	bool not_first = false;

	while (true) {
		cin >> a >> b;
		if (a == 0 && b == 0) break;
		bool flag = true;
		
		
		if (not_first)cout << endl;

		for (int i = a;i <= b;i++) {
			uruu(i, flag);
		}
		if (flag)cout << "NA" << endl;
		not_first = true;
	}

	return 0;
}

void uruu(int year, bool& flag) {
	if (year % 400 == 0) {
		cout << year << endl;
		flag = false;
		return;
	}
	else if (year % 100 == 0) {
		return;
	}
	else if (year % 4 == 0) {
		cout << year << endl;
		flag = false;
		return;
	}
	else {
		return;
	}
}

Measured memory_bytes: 1160
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, A);
    ll N = A.size();
    vector<set<ll>> S(26, {N});
    REP(i, N)
    {
        S[A[i] - 'a'].insert(i);
    }
    vector<tuple<ll, char, ll>> dp(N + 2, {INF, '-', N});
    dp[N] = {1, '-', N};
    dp[N + 1] = {0, '-', N};
    for (ll i = N - 1; i >= 0; --i)
    {
        REP(j, 26)
        {
            ll k = *S[j].lower_bound(i);
            tuple<ll, char, ll> p = {get<0>(dp[k + 1]) + 1, 'a' + j, k + 1};
            CH(min, dp[i], p);
        }
    }
    string ans;
    for (ll i = 0; i < N;)
    {
        auto [_, c, k] = dp[i];
        ans.push_back(c);
        i = k;
    }
    OUT(ans);
}

Measured memory_bytes: 17612
# include<iostream>
# include<queue>
# include<stack>
# include<algorithm>
# include<cmath> 
# include<cstring>
# include<map>
using namespace std;
const int INF =pow(10,9)+7;
int a[1000000];

struct P{
	int x,y;
};
bool cmp(P a,P b)
{
	 return 1;
}

void update(int a,int b,int k,int l,int r)
{
	 
}

int main ()
{
	 int t=1;
	 //cin>>t;
	 while(t>0)
	 {
	 	  t--;
	      int n;
	      cin>>n;
	      bool ok =true;
	      map<int,int> mp;
	      for(int i=0;i<n;i++)
	      {
	      	   int x;
	      	   cin>>x;
	      	   if(mp[x]==1)
	      	   ok =false;
	      	   mp[x]=1;
		  }
		  if(ok)
		  cout<<"YES"<<endl;
		  else
		  cout<<"NO"<<endl;
	 }
    	
	return 0;
}

Measured memory_bytes: 9600
S = input()

a = 0
for i in range(3):
    if S[i] == "R":
        a += 1

ans = 0
if a == 0:
    ans = 0
elif a == 1:
    ans = 1
elif a == 2:
    if S[1] == "R":
        ans = 2
    else:
        ans = 1
else:
    ans = 3

print(ans)

Measured memory_bytes: 9112
import java.util.Scanner;

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



		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String s = sc.next();
		switch(s) {
		case "SUN":
			System.out.println("7");
			break;
		case "MON":
			System.out.println("6");
			break;
		case "TUE":
			System.out.println("5");
			break;
		case "WED":
			System.out.println("4");
			break;
		case "THU":
			System.out.println("3");
			break;
		case "FRI":
			System.out.println("2");
			break;
		case "SAT":
			System.out.println("1");
			break;
		}

	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 21204
#include <iostream>
#include <cstdio>

using namespace std;

#define INF 1 << 16

int main() {
	int cost[20][20]; fill(&cost[0][0], &cost[0][0]+20*20, INF);

	int n; cin >> n;
	int m; cin >> m;

	for (int i = 0; i < m; ++i) {
		int a, b, c, d; scanf("%d,%d,%d,%d\n", &a, &b, &c, &d); --a, --b;
		cost[a][b] = c;
		cost[b][a] = d;
	}

	int s, g, reward, price; scanf("%d,%d,%d,%d\n", &s, &g, &reward, &price); --s, --g;

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			for (int k = 0; k < n; ++k)
				if (cost[j][i] + cost[i][k] < cost[j][k])
					cost[j][k] = cost[j][i] + cost[i][k];

	cout << (reward - price - cost[s][g] - cost[g][s]) << endl;

	
}

Measured memory_bytes: 1244
#include <iostream>
#include <map>
#include <algorithm>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

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

    unordered_map<string, int> hash;

    rep(i, n) {
        string tmp;
        cin >> tmp;
        sort(tmp.begin(), tmp.end());
        hash[tmp]++;
    }

    long long ans = 0;
    for (auto& p : hash) {
        int s = p.second;
        ans += (long long) s*(s-1)/2;
    }

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


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

long long dp[1010][1010] = {};
const long long mod = 1e9 + 7;

int main(){
    int H, W;
    string a;
    vector<string> Grid;

    cin >> H >> W;
    Grid.push_back(string(W+2, '#'));
    for(int h=0;h<H;h++){
        cin >> a;
        Grid.push_back('#' + a + '#');
    }
    Grid.push_back(string(W+2, '#'));

    dp[1][1] = 1;
    for(int h=1;h<=H;h++){
        for(int w=1;w<=W;w++){
            if(h!=1 || w!= 1){
                if(Grid[h-1][w] == '.'){
                    dp[h][w] += dp[h-1][w];
                }
                if(Grid[h][w-1] == '.'){
                    dp[h][w] += dp[h][w-1];
                }
                dp[h][w] = dp[h][w] % mod;
            }
        }
    }

    cout << dp[H][W] << "\n";
    return 0;
}

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

int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    
    if ((r<=x)&(x<=W-r)&(r<=y)&(y<=H-r)){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3084
from math import ceil,floor

W,H = map(int,input().split())

def S(H,W):
	res = []
	for i in range(1,H):
		S1 = i*W
		S2 = (H-i)*ceil(W/2)
		S3 = (H-i)*floor(W/2)
		res.append(max(S1,S2,S3)-min(S1,S2,S3))
	for i in range(1,H):
		S1 = i*W
		S2 = W*ceil((H-i)/2)
		S3 = W*floor((H-i)/2)
		res.append(max(S1,S2,S3)-min(S1,S2,S3))
	return(min(res))

print(min(S(H,W),S(W,H)))

Measured memory_bytes: 11032
#include <iostream>
using namespace std;
int f(int x){
    int ans=0;
    while(x%2==0){
        x/=2;
        ans++;
    }
    return ans;
}
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        ans+=f(a);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
 
class Program
{
    static void Main()
    {
        const int divisor = 1000000007;
        int n = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split(' ')
                                .Select(elem => int.Parse(elem))
                                .OrderByDescending(elem => elem)
                                .ToArray();
        bool flag = true;
        int num = n - 1;
        for (int i = 0; i < A.Length; i++)
        {
            if(A[i] != num) {flag = false; break;}
            if(i % 2 != 0) num -= 2;
        }
        long numOfPattern = 0;
        if (flag)
        {
            numOfPattern = 1;
            for (int i = 0; i < n / 2; i++)
            {
                numOfPattern = numOfPattern * 2 % divisor;
            }
        }
        Console.WriteLine(numOfPattern);
    }
}


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

using namespace std;

#define endl "\n"
#define lln long long int
#define IOS ios::sync_with_stdio(0);cin.tie(0);

int isit(int a,int b,int c){
    if(a+b<=c || b+c<=a || a+c<=b) return 0;
    return 1;
}

int main(){
    IOS;

    int n;
    cin >> n;
    vector<int> real(n);
    for(int i=0;i<n;i++) cin >> real[i];
    sort(real.begin(),real.end());
    int c = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(real[i] == real[j]) continue;
            for(int k=j+1;k<n;k++){
                if(real[j] == real[k]) continue;
                if(isit(real[i],real[j],real[k])) c++;
            }
        }
    }
    cout << c << endl;
    return 0;    
}

Measured memory_bytes: 3652