akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
template<typename T = int> using V = vector<T>;
template<typename T = int> using P = pair<T, T>;
using Vi = V<int>;
using Vl = V<ll>;
using Vd = V<ld>;
using Vb = V<bool>;
using VVi = V<Vi>;
using VVl = V<Vl>;
using VVb = V<Vb>;
using Pi = P<int>;
using Pl = P<ll>;
using Pd = P<ld>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); } // floor(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); } // ceil(log2(x))
inline int popcount(const ll x) { return __builtin_popcountll(x); }
inline void fail() { cout << -1 << '\n'; exit(0); }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
// const int INF  = 1<<30;
// const ll INFll = 1ll<<60;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


struct UnionFind {
  vector<int> d;
  int m; // number of connected components
  UnionFind(int n = 0) : d(n, -1), m(n) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    --m;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};



int main() {
  ll n, m; cin >> n >> m;

  UnionFind uf(n);

  rep(i, m) {
    int a, b; cin >> a >> b;
    --a, --b;
    uf.unite(a, b);
  }

  int ans = 0;
  rep(i, n) chmax(ans, uf.size(i));
  cout << ans << '\n';
}


Measured memory_bytes: 3972
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using lld = long long int ;
#define mod 1000000007; 

int main(){
    int x;
    cin >> x;
    if(x==0){
        cout << 1;
    }
    if(x==1){
        cout << 0;
    }
    return 0;
    return 0;
}

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

int temp[201];

bool check( int n, int count )
{
    for( int i=0 ; i<n ; i++ )
    {
        int a;
        
        if( 0 == count ) cin >> a;
        else             a = temp[i];
      
        if( (a%2) == 1 ) return false;

        temp[i] = a / 2;
    }

    return true;
}
 
int main() {
    int N;
    cin >> N;
  
    int count = 0 ;
  
    while( true )
    {
        if( false == check( N, count ) ) break;
        else                             count++;
    }
  
    cout << count;
}

Measured memory_bytes: 256
//
// Created by Tetsuya Shiota on 2019-04-13.
//

#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(e, o) for (auto &&e : o)
#ifdef LOCAL
#define pp(x) cerr << __LINE__ << ' ' << #x << " = " << (x) << endl
#define dump(x)                                                                \
  cerr << __LINE__ << ' ' << #x << " : ";                                      \
  FOR(e, x) cerr << e << ' ';                                                  \
  cerr << endl;
#else
#define pp(x)
#define dump(x)
#endif

using namespace std;

using Int = long long;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int, Int>;

template <typename T> void reverse(vector<T> &v) {
  reverse(v.begin(), v.end());
}
template <typename T> void sort(vector<T> &v) { sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T> &v) { sort(v.rbegin(), v.rend()); }
template <typename T> T sum(const vector<T> &v) {
  return accumulate(v.begin(), v.end(), T(0));
}
template <class T> void update_max(T &a, const T &b) { a = max(a, b); }
template <class T> bool update_min(T &a, const T &b) { a = min(a, b); }
vector<pair<char, Int>> merge_cont_char(const string &s) {
  vector<pair<char, Int>> ret;
  if (s.empty())
    return ret;
  ret.push_back(make_pair(s[0], 0));
  FOR(c, s) {
    if (ret.back().first == c)
      ret.back().second++;
    else
      ret.push_back(make_pair(c, 1));
  }
  return ret;
}

struct BoolName : numpunct<char> {
  string t, f;
  BoolName(string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const { return t; }
  string do_falsename() const { return f; }
};

class Solver {
public:
  Solver() {}
  Int N, K, ans = 0;
  string S;
  void input() {
    cin >> N >> K;
    cin >> S;
  }
  void solve() {
    auto merged_S = merge_cont_char(S);

    deque<pair<char, Int>> Q;
    Int need = 0, score = 0;

    FOR(cnt, merged_S) {
      Q.push_back(cnt);
      score += cnt.second;
      if (cnt.first == '0') {
        need++;
      }
      while (need > K) {
        auto f = Q.front();
        Q.pop_front();
        if (f.first == '0')
          need--;
        score -= f.second;
      }
      update_max(ans, score);
    }
  }
  void output() { cout << ans << endl; };
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(15) << boolalpha;
  cout.imbue(locale(cout.getloc(), new BoolName));
#ifdef LOCAL
  while (1) {
    Solver s;
    s.input();
    if (cin.eof())
      break;
    s.solve();
    s.output();
  }
#else
  Solver s;
  s.input();
  s.solve();
  s.output();
#endif
}

Measured memory_bytes: 2736
n = int(input())

count = 0
ans = 0
for i in range(n):
    s = input().split()
    
    if s[0]==s[1]:
        count += 1
    else:
        count = 0
        
    if count ==3:
        print('Yes')
        exit(0)

else:
    print('No')

Measured memory_bytes: 9016
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main(){
  long a,c;
  cin >> a;
  set<long> b;
  for(int i=0;i<a;i++){
    cin >> c;
    b.insert(c);
  }
  if(b.size() == a)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	LLi n, ans=0;
	vector<LLi> v;

	cin>> n;
	v.resize(n);

	for(int i=1;i<=n;i++){
		for(int j=1;j*i<=n;j++){
			v[i*j]++;
		}
	}

	for(LLi i=1;i<=n;i++){
		ans+=i*v[i];
	}

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

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

const int N = 50010;
int dp[N]; // dp[i] i円支払う時の最小のコインの枚数

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

    int n, m;
    cin >> n >> m;
    vector<int> C(m);
    for(int i = 0; i < m; i++){
        cin >> C[i];
    }

    for(int i = 0; i < N; i++){
        dp[i] = 1e9;
    }

    dp[0] = 0;

    for(int i = 0; i <= n; i++){
        for(int j = 0; j < m; j++){
            if(i - C[j] < 0) continue;
            dp[i] = min(dp[i], dp[i - C[j]] + 1);
        }
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 3408
<?php
$a = trim(fgets(STDIN));
for($i = 0;$i<$a;$i++){
$moti[]=trim(fgets(STDIN));
}
sort($moti);
$ans = 1;
for($I=0;$I<$a-1;$I++){
if($moti[$I]<$moti[$I+1]){
++$ans;
}
}
echo $ans;

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int b=0,n,ans=0;
	string a;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]=='I')
		{
			b++;
		}
		else
		{
			b--;
		}
		ans=max(ans,b);
	}
	cout<<ans;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var S = ReadLine();
        var w = new int[N + 1];
        for (int i = 0; i < N; i++)
        {
            w[i + 1] = w[i] + (S[i] == 'W' ? 0 : 1);
        }
        var ans = 100000000;
        for (int i = 0; i < N; i++)
        {
            var l = i - w[i];
            var r = w[N] - w[i + 1];
            ans = Math.Min(ans, l + r);
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 13280
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int n,i,a[60],b[60],s=0;
  cin >> n;
  for (i=0;i<n;i++){
    cin >> a[i];
    b[i]=a[i];
  }
  sort(b,b+n);
  for (i=0;i<n;i++) if (a[i]!=b[i]) s++;
  if (s<=2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
    double x1,y1,x2,y2;
    cin >> x1 >> y1;
    cin >> x2 >> y2;
    double d = pow(x1-x2,2) + pow(y1-y2, 2);
    cout << fixed << setprecision(5) <<sqrt(d);
    cout << endl;
    
}



Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)

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

int main(){
  int n;cin>>n;
  int mn;
  if(n<10)mn=n;
  else mn=9+n/10;
  int num[10][10];
  rep(i,10){
    rep(j,10){
      num[i][j]=0;
    }
  }
  for(int i=1;i<=n;i++){
    string s;
    s = to_string(i);
    int a,b;
    a = s[0]-'0';
    b = s[s.length()-1]-'0';
    num[b][a]++;
  }
  
  ll cnt=0;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      cnt += num[i][j]*num[j][i];
      
    }
  }
  
  cout<<cnt<<endl;
  return 0;
}

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

int main()
{
  int n;
  cin>>n;
  int x=n/1000;
  //int r=x%1000
  int p=n-1000*x;
  int ans=0;
  if(p>0)
    ans=1000-p;
  cout<<ans<<endl;
  return 0;
}


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

int main() {
    int n,rmin,drmax,i,r;
    cin>>n;
    cin>>rmin>>r;
    drmax=r-rmin;
    if(r<rmin)rmin=r;
    for(i=2;i<n;i++){
        cin>>r;
        if(r<rmin)rmin=r;
        else if(drmax<r-rmin)drmax=r-rmin;
    }
    cout<<drmax<<endl;
    return 0;
}


Measured memory_bytes: 3120
import scipy.fftpack as f;input();m=200003;t=[0]*m;a=[0]*2*m;s=0
for i in range(m):t[pow(2,i,m)]=i
for i in map(int,input().split()):
	if i:a[t[i]]+=1;s-=i*i%m
for i,j in enumerate(f.ifft(f.fft(a)**2)):s+=int(round(j.real))*pow(2,i,m)
print(s//2)

Measured memory_bytes: 144176
# C - Skip

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

N, X = map(int, input().split())
x = list(int(x) for x in input().split())
x.append(X)
x.sort()
stnd = x[0]
for i in range(N+1):
    x[i] -= stnd

ans = gcd(x[0], x[1])
for i in range(1, N):
    ans = gcd(ans, gcd(x[i], x[i+1]))
print(ans)

Measured memory_bytes: 14252
#include <stdio.h>
int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	if (a * b == 15) {
		printf("*\n");
	} else if (a + b == 15) {
		printf("+\n");
	} else {
		printf("x\n");
	}
	return 0;
}

Measured memory_bytes: 128
S=list(input())
line=[]
A=["A","C","G","T"]
num_list=[]
flag=False
for s in S:
    if s in A:
        line.append(s)
        flag=True
    elif flag:
        num_list.append(len(line))
        line=[]
        flag=False
num_list.append(len(line))
if len(num_list)==0:print(0)
else:
    print(max(num_list))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long i,j,k,a,b,c=0,d=0,n,m,t;
cin>>a>>b>>c>>d;
n=min(a,b);
m=min(c,d);
cout<<n+m;
return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for(ll i=init;i<(n);i++)

int main() {
    int n;
    cin >> n;
    vector<int> L(n);
    repi(i, n, 0) {
        cin >> L[i];
    }
//    L.push_back(INF);
    sort(L.begin(), L.end());
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int k = distance(L.begin(),lower_bound(L.begin(),L.end(),L[i] + L[j]));

            ans += max(k - (j + 1),0);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll N;
ll A[100010], L[100010], R[100010];

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

int main()
{
  scanf( "%lld", &N );
  rep( i, N )
    scanf( "%lld", A+i );

  rep( i, N )
    L[i+1] = gcd( L[i], A[i] );
  for( int i = N-1; i >= 0; --i )
    R[i-1] = gcd( R[i], A[i] );  

  ll ans = 0;

  rep( i, N )
    ans = std::max( ans, gcd( L[i], R[i] ) );

  printf( "%lld\n", ans );

  return 0;
}

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

using namespace std;

char s[5];

int main() {
	scanf("%s", s);
	int test = (int)s[0] + s[1] + (int)s[2];
	if (test == 195 || test == 198) printf("No\n");
	else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
void solve(){
    ll n,b,c;cin>>n;
    ll arr[n];
    map<ll,ll>m;
    ll ans = 0;
    for(int i=0;i<n;i++){cin>>arr[i];ans+=arr[i];m[arr[i]]++;}
    ll q;cin>>q;
    for(int i=0;i<q;i++){
        cin>>b>>c;
        ans+=m[b]*(c-b);
        m[c]+=m[b];
        m[b]=0;
        cout<<ans<<"\n";
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int count = 0;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        if (x < A || B <= x) count++;
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;

int main(){
	int a, b;
	cin >> a >> b;
	int ans = a + b;
	ans = max(ans,a-b);
	ans = max(ans, a*b);
	cout << ans << endl;
	return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1


#ifndef ONLINE_JUDGE
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); \
						 istream_iterator<string> _it(_ss); \
						 err(_it, args); }
#else
#define error(args...)		42
#endif


void err(istream_iterator<string> it) { cerr << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "; ";
	err(++it, args...);
}


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
#endif
}

int ceil2(int a, int b){
    int c = a / b;
    if (c * b < a) c++;
    return c;
}

const int MXDIG = 10002; 
int mem[MXDIG][2][105];

// string a;
// int d;


int digitdp(int pos, string &b, bool tight, int cur_sum, int d)
{
	if(pos == b.length())
		return cur_sum % d == 0;

	if(mem[pos][tight][cur_sum] != -1)
		return mem[pos][tight][cur_sum];


	int dig = b[pos] - '0';
	// error(pos, tight, cur_sum);

	int k = tight == 1 ? dig : 9;

	int ret = 0;

	for (int i = 0; i <= k; ++i)
	{
		bool newtight = (tight && i == dig);

		ret += digitdp(pos + 1, b, newtight, (cur_sum + i)%d, d);
		ret %= mod;
	}

	mem[pos][tight][(cur_sum)%d] = ret%mod;

	return ret%mod;
}

void init()
{
	for (int i = 0; i < MXDIG; ++i)
	{
		for (int j = 0; j < 2; ++j)
		{
			for (int k = 0; k < 105; ++k)
			{
				mem[i][j][k] = -1;
			}
		}
	}	
}

int32_t main()
{
	c_p_c();

	string a;

	int d;

	cin>>a>>d;

	init();

	digitdp(0, a, 1, 0, d);

	cout << (mem[0][1][0]-1 + mod) % mod;
	// cout << "\nend";


	return 0;
}

Measured memory_bytes: 21120
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <unordered_set>

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> S(h);
  for (int i = 0; i < h; i++) { cin >> S[i];}

  for (int i = 0; i < h; i++) {
    cout << S[i] << endl;
    cout << S[i] << endl;
  }
}


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

int main()
{
	ll int  n,m,i;
	double s=0;
	cin>>n>>m;
	double a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		s+=a[i];
		
	}
	sort(a,a+n,greater<ll int>());
	if (a[m-1]>=s/(4.0*m))
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;



}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	long long int a,b;
	long long int n,x,y;
	int i,j,k;
	long long int s=0;
	cin>>n>>x;
	s=n;
	y=n-x;
	if(y<x)swap(x,y);
	while(x!=0){
		a=y/x;
		s+=a*x*2;
		y%=x;
		swap(x,y);
	}
	s-=y;
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A[200001];
int main()
{
    map <int,int> mp;

    int i, n;
    cin >> n;
    for(i = 0; i < (n-1); i++)
    {
        cin >> A[i];
        mp[A[i]]++;
    }
    for(i = 1; i <= n; i++)
    {
         cout << mp[i] << endl;
    }


}



Measured memory_bytes: 13768
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Atcoder_Answer
{
    class Program
    {
        const int mod = 1000000007;

        static void Main(string[] args)
        {
            WriteLine("x".Multi(ReadLine().Length));
        }

    }

    public static class Extension
    {
        #region 拡張:bool
        #region キャスト関連
        public static int ToInt(this bool Bool)
        {
            if (Bool) return 1;
            else return 0;
        }

        public static string ToString(this bool Bool, string TrueStr, string FalseStr)
        {
            if (Bool) return TrueStr;
            else return FalseStr;
        }
        #endregion
        #endregion

        #region 拡張:int
        #region キャスト関連
        public static char ToAlphaBets(this int Base) => (char)Base;
        #endregion
        #endregion

        #region 拡張:char
        #region 変換関連
        public static char NextAlpha(this char Char) => (char)((Char) + 1); //次の文字を取得
        #endregion
        #endregion

        #region 拡張:int[]
        public static long Sum(this int[] Array)
        {
            int Ret = 0;
            for (int loop = 0; loop < Array.Length; loop++) Ret += Array[loop];
            return Ret;
        }
        #endregion

        #region 拡張: string
        public static string Multi(this string THIS, int Value) 
        {
            string RetValue = "";

            for (int loop = 0; loop < Value; loop++) RetValue += THIS;

            return RetValue;
        }
        #endregion
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
    }
    ll P = 1, ans = 0;
    rep(i, N) {
        if (A[i] < P) {
            continue;
        }
        if (A[i] == P) {
            P++;
            continue;
        }
        ans += (A[i] - 1) / P;
        if (P == 1) P++;
        //cout << i << " " << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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

#[allow(non_snake_case)]
fn main() {
    input!{
        A: usize,
        P: usize,
    };

    println!("{}", (A * 3 + P )/2);

}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define LL long long
#define PB push_back
#define POP pop_back()
#define PII pair<int,int>
#define FI first
#define SE second
#define ULL unsigned long long
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;
const int maxn=1<<17;
const int N=1e5+10,M=N<<2;
int n,m;
int vis[N];
int a[N];
int main()
{
    memset(a,-1,sizeof(a));
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        if(a[x]>=0&&a[x]!=y){
            printf("-1");
            return 0;
        }
        a[x]=y;
    }
    if(n==1){
        if(a[1]==-1)a[1]=0;
        printf("%d",a[1]);
        return 0;
    }
    if(a[1]==0){
        printf("-1");
        return 0;
    }
    for(int i=1;i<=n;i++){
        if(a[i]==-1){
            if(i!=1)a[i]=0;
            else a[i]=1;
        }
        printf("%d",a[i]);
    }
    return 0;
}
/*
4 4
0000
0110
0110
0011
*/


Measured memory_bytes: 640
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,K = II()
S = str(input())

count = 0
ans = 0
for i in range(1,len(S)):
    if S[i]!=S[i-1]:
        count += 1
    else:
        ans += 1
count += 1

n = (count-1)//2
if count%2==0:
    if n+1<=K:
        ans += 2*n+1
    else:
        ans += 2*K
else:
    if n<=K:
        ans += 2*n
    else:
        ans += 2*K

print(ans)

Measured memory_bytes: 39408
n = int(input())
p = list(map(int,input().split()))
ans = 0

for i in range(n-2):
  if max(p[i], p[i+1], p[i+2]) != p[i+1] and min(p[i], p[i+1], p[i+2]) != p[i+1]:
    ans = ans + 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ll diff = (h2 - h1) * 60 + (m2 - m1);
    cout << max(0LL, diff - k) << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;
int main() {
	int N = 0; 
	int timet = 0; 
	int currentprice = 0; 
	int currenttime = 0;
	int lowestp = 100000000; 
	int possible = 0;
	int i = 0; 
	cin>>N>>timet;
	for(i=1;i<=N;i++)
	{
		cin>>currentprice;
		cin>>currenttime;
		if(currenttime<=timet)
		{
			if(currentprice<lowestp)
			{
				lowestp = currentprice;
				possible = 1;
			}
		}
	}
	if(possible==0)
	{
		cout<<"TLE";
		return 0;
	}
	cout<<lowestp;

	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> vi; 
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int mod = 1e9+7;
const int maxn = 2e5+10;
const int inf = 0x3f3f3f3f;
ll qpow(ll a,int b) {
    ll ans=1;
    while(b) {
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
ll jc[maxn],inv[maxn];
void cinit(int n) {
	jc[0]=inv[0]=1;
	rep(i,1,n) jc[i]=jc[i-1]*i%mod;
	inv[n]=qpow(jc[n],mod-2);
	per(i,n-1,1) inv[i]=inv[i+1]*(i+1)%mod;
}
ll C(int n,int m,int p=mod) { return m>n?0:jc[n]*inv[m]%p*inv[n-m]%p; }
int main()
{
    ios::sync_with_stdio(false);cin.tie(nullptr);
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    ll ans=0;
    cinit(maxn-1);
    rep(i,1,h-a) {
        ll now=C(b+i-2,i-1);
        now=now*C(h+w-b-i-1,w-b-1)%mod;
        ans=(ans+now)%mod;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 6816
import sys

input = sys.stdin.readline

def query(i):
    '''
    a[0] + a[1] + … + a[i-1] を求める
    O(logN)
    '''
    res = 0
    while i > 0:
        res += BIT[i]
        i -= i & -i
    
    return res


def update(i, x):
    '''
    a[i-1]にxを加算
    O(logN)
    '''
    while i <= n:
        BIT[i] += x
        i += i & -i


n, q = map(int, input().split())
c = list(map(int, input().split()))
query_ = [list(map(int, input().split())) + [i] for i in range(q)]

query_.sort(key=lambda x: x[1])

res = [0] * q
pos = [-1] * n
BIT = [0] * (n+1)
p = 0
for l, r, idx in query_:
    for i in range(p, r):
        if pos[c[i]-1] != -1:
            update(pos[c[i]-1]+1, -1)
        update(i+1, 1)
        pos[c[i]-1] = i
    
    res[idx] = query(r) - query(l-1)
    p = r

for v in res:
    print(v)

Measured memory_bytes: 230620
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=A.index(1)

def inv(a,K,A):
    count=0
    count+=-(-a//(K-1))
    a=(K-1)*count
    count+=-(-(len(A)-1-a)//(K-1))
    return count


print(min(inv(a,K,A),inv(a,K,A[::-1])))


Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> P;

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string S; cin >> S;
    int ans1 = 0, ans2 = 0;
    for(int i=0;i<S.size();i++){
        if(i%2){
            if(S[i]=='0') ans1++;
            else ans2++;
        }
        else{
            if(S[i]=='1') ans1++;
            else ans2++;
        }
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, std::vector<long long> A)
{
    map<ll, ll> cnt;
    ll ans = 0;
    cnt[A[0]]++;
    for (int i = 1; i < N; i++)
    {
        A[i] = A[i] + A[i - 1];
        cnt[A[i]]++;
    }

    for (auto &&i : cnt)
    {
        if (i.first == 0)
        {
            ans += i.second;
        }

        ans += i.second * (i.second - 1) / 2;
    }
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

const ll MOD = 1000 * 1000 *1000 + 7 ;
inline void chadd(ll &a, const ll b) { a = (a + b) % MOD;}
inline ll add(const ll a, const ll b){ return (a + b) %  MOD;}
inline void chsub(ll &a, const ll b) { a = (a - b + MOD) % MOD;}
inline ll sub(const ll a, const ll b){ return (a - b + MOD) % MOD; }
inline void chmul(ll &a, const ll b) { a = (a * b) %  MOD;}
inline ll mul(const ll a, const ll b){ return (a * b) %  MOD;}

const int MOD_TABLE_SIZE = 3 * 1000 * 1000 + 10;
ll b25[MOD_TABLE_SIZE];
ll b26[MOD_TABLE_SIZE];
ll inv[MOD_TABLE_SIZE];
ll fac[MOD_TABLE_SIZE];
ll facinv[MOD_TABLE_SIZE];

void mod_table_init() {
  inv[1] = 1;
  for(int i = 2; i < MOD_TABLE_SIZE; i++) {
    inv[i] = MOD - (MOD / i) * inv[(int)MOD % i] % MOD;
  }
  fac[0] = facinv[0] = 1;
  b25[0] = b26[0] = 1;
  for(int i = 1; i < MOD_TABLE_SIZE; i++) {
    fac[i] = (fac[i-1] * (ll)i) % MOD;
    facinv[i] = (facinv[i-1] * inv[i]) % MOD;
    b26[i] = mul(b26[i-1], 26);
    b25[i] = mul(b25[i-1], 25);
  }
}

inline ll P(int a, int b) {
  if(a<b) return 0LL;
  return fac[a] *  facinv[a-b] % MOD;
}

inline ll C(int a, int b) {
  if(a<b) return 0LL;
  return (fac[a] * facinv[b] % MOD) * facinv[a-b] % MOD;
}

inline ll H(int a, int b) {
  return C(a+b-1,b);
}

int main() {
  mod_table_init();
  int K; cin>>K;
  string S; cin>>S;
  ll ans = 0;
  for(int i = 0; i <= K; i++) {
    int k = K-i;
    ll tmp = C(k + S.length() - 1, S.length() - 1);
    chmul(tmp, b26[i]);
    chmul(tmp, b25[k]);
    //    cout << i << " " << k << " " << b26[i] << " " << b25[k] << " " << tmp << endl;
    chadd(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 121720
#include <iostream>
#include <set>

int main() {
  using ull = unsigned long long;
  ull N,M;
  std::cin >> N >> M;
  std::set<ull> a;
  for(ull m=0;m<M;m++){
    long long at;
    std::cin >> at;
    a.insert(at);
  }
  ull p1 = 1;
  ull p2 = 0;
  ull count_all=0;
  for(ull i=1;i<=N;i++){
    if(a.count(i)>0)
      count_all = 0;
    else
      count_all = (p1 + p2)%1000000007;
    p2 = p1;
    p1 = count_all;
  }
  std::cout << (count_all%1000000007) <<std::endl;
  return 0;
}


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

const int N = 1000000 + 7, mod = 1e9 + 7;

int a[N], f[N];


int POW(int a, int b) {
    int res = 1;
    for(int i = b; i >= 1; i >>= 1) {
        if(i & 1LL) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

int32_t main() {
        int n, g = 0; cin >> n;
        for(int i = 1; i <= n; i++) {
            cin >> a[i];
            g = __gcd(a[i], g);
        }
        //cout << g << endl;
        for(int i = 1; i <= n; i++) {
            a[i] /= g;
            int x = a[i];
            for(int j = 2; j * j <= a[i]; j++) {
                int cnt = 0;
                while(x % j == 0) ++cnt, x /= j;
                f[j] = max(f[j], cnt);

            }
            if(x > 1) f[x] = max(1LL, f[x]);
        }
        int ans = 1;

        for(int i = 1; i < N; i++) {
          //  if(f[i]) cout << j << " " << f[j] << endl;
            for(int j = 1; j <= f[i]; j++)
                ans = (ans * i) % mod;
        }
       // cout << ans << endl;
        int sum = 0;

        for(int i = 1; i <= n; i++) {
            sum = (sum + (ans * POW(a[i], mod - 2)) % mod) % mod;
        }

        cout << sum << endl;


}



Measured memory_bytes: 8192
#include <stdio.h>
#define NUM 201

int  cards[NUM];

void setup_cards(int n) {
    int i;
    for(i = 1; i <= n * 2; i++ ) {
        cards[i] = i;
    }
}

void cut(int n, int k) {
    int i, j;
    int array1[NUM], array2[NUM], arraycp[NUM];
    for(i = 1; i <= k; i++ ) {
        array1[i] = cards[i];
    }
    for(--i, j = n * 2; i > 0; i--, j--) {
        arraycp[j] = array1[i];
    }
    for(i = k + 1; i <= n * 2; i++ ) {
        array2[i] = cards[i];
    }
    for(i = k + 1, j = 1; i <= n * 2; i++ , j++ ) {
        arraycp[j] = array2[i];
    }
    for(i = 0; i <= n * 2; i++ ) {
        cards[i] = arraycp[i];
    }
}

void riffle(int n) {
    int i, j;
    int array1[NUM], array2[NUM];
    for(i = 1; i <= n; i++ ) {
        array1[i] = cards[i];
    }
    for(i = n + 1, j = 1; i <= n * 2; i++, j++ ) {
        array2[j] = cards[i];
    }
    for(i = 1; i <= n; i++ ) {
        cards[i * 2 - 1] = array1[i];
        cards[i * 2] = array2[i];
    }
}

int main(void) {
    int n, k, m, i, l;
    scanf("%d%d",&n, &m);
    setup_cards(n);
    for(l = 0; l < m; l++ ) {
        scanf("%d",&k);
        if(k) {
            cut(n, k);
        } else {
            riffle(n);
        }
    }
    for(i = 1; i <= n * 2; i++ ) {
        printf("%d\n",cards[i]);
    }
    return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
const int maxn=2e5+5;
int cnt[maxn];


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

 int n;
cin>>n;
int a;
 for(int i=2;i<=n;i++){
       cin>>a;
       cnt[a]++;
 }

 for(int i=1;i<=n;i++){
   cout<<cnt[i]<<endl;
 }
  return 0;
}


Measured memory_bytes: 4368
//==========//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;//<key,value>


int main() {
int a,b,n;
cin>>a>>b;
for (n= 0; n < 10000; ++n) {


int za=n*8/100;
int zb=n*10/100;

if(a==za&&b==zb){
cout<<n<<endl;
return 0;
}
}
cout<<-1<<endl;
return 0;
}







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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod (int)1e9+7
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'

struct custom_hash {    // anti-hack for unordered_map. To declare: unordered_map<long long, int, custom_hash> safe_map;
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//

void solve()
{
    int n;
    cin >> n;
    cout<<1-n;

}


int main()
{
	fastio;
    int T;
    // cin>>T;
    // while(T--)
        solve();
	return 0;
}

Measured memory_bytes: 3648
while true do
    begin
        littlenum = 0.000001
        a1, b1, c1, a2, b2, c2 = gets.split(" ").map(&:to_f)
        printf("%.3f %.3f\n", (b2 * c1 - b1 * c2) / (a1 * b2 - b1 * a2) + littlenum, (a1 * c2 - c1 * a2) / (a1 * b2 - b1 * a2) + littlenum)
    rescue
        break
    end
end

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

int main(){
        int a,b;
        cin >> a;
        cin >> b;
        if (a > b){
                cout << "a > b" << endl;
        }else if (a < b){
                cout << "a < b" << endl;
        }else if(a == b){
                cout << "a == b" << endl;
        }
        return 0;
}

Measured memory_bytes: 1156
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B, C, D);

// ===

const MOD: i32 = 1000000007;

fn main() {
    let (n, x, y, z): (usize, usize, usize, usize) = read();

    let mut dp: Vec<Vec<i32>> = vec![vec![0; 1<<18]; 2];
    dp[0][0] = 1;

    let mask = (1<<17)-1;
    let cmask = 1<<17;
    let okmask = (1<<(x+y+z-1))|(1<<(y+z-1))|(1<<(z-1));

    for i in 0..n {
        let fr = i % 2;
        let to = 1 - fr;
        for ptn in 0..(1<<18) {
            dp[to][ptn] = 0;
        }

        for ptn in 0..(1<<18) {
            let base = dp[fr][ptn];
            if base == 0 {
                continue
            }
            for x in 1..11 {
                let tptn = ((ptn<<x|1<<(x-1))&mask);
                let ok = ptn&cmask >= 1 || tptn&okmask == okmask;
                let tptn = tptn | if ok { cmask } else { 0 };

                dp[to][tptn] += base;
                if dp[to][tptn] >= MOD {
                    dp[to][tptn] -= MOD;
                }
            }
        }
    }

    let mut sum: i64 = 0;
    for ptn in 0..(1<<18) {
        if ptn & cmask >= 1 {
            sum += dp[n%2][ptn] as i64;
        }
    }
    println!("{}", sum % MOD as i64);
}

Measured memory_bytes: 6396
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <stack>
#include <string>
#include <map>

using namespace std;

int main()
{
	int A, B, K;
	cin >> A >> B >> K;
	int ctr = 0;
	for (int i = min(A, B); i >0 ;i--) {
		if (A%i == 0 && B%i == 0)
			ctr++;
		if (ctr == K) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}


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

int main()
{
    int h,w;
    cin>>h>>w;
    int startx,starty;
    cin>>startx>>starty;
    int endx,endy;
    cin>>endx>>endy;
    int board[h+3][w+3];
    int visit[h+3][w+3];
    for(int i=1;i<=h;i++)
    {
        string s;
        cin>>s;
        for(int j=1;j<=w;j++)
        {
          
            board[i][j] = (s[j-1]=='.');
            //cout<<board[i][j]<<" ";
            visit[i][j]=0;
        }
        //cout<<"\n";
    }
    int dx[4] = {0,0,-1,1};
    int dy[4] = {-1,1,0,0};
   deque <pair<pair<int,int>,int>> q;
   bool p=false;
    q.push_back(make_pair(make_pair(startx,starty),0));
    while(!q.empty())
    {
       pair<pair<int,int>,int> top = q.front();
       pair<int,int> first = top.first;
       int magic = top.second;
       int x= first.first;
       int y = first.second;
       q.pop_front();
       
       if(visit[x][y]==1) continue;
       if(x==endx && y==endy)
       {
           cout<<magic<<endl;
           p=true;
          break;
       }
       visit[x][y]= 1;
       for(int i=0;i<4;i++)
       {
           int x1= x+dx[i]; 
           int y1 = y+dy[i];
           
           if(x1>=1 && y1>=1 && x1<=h && y1<=w && visit[x1][y1]==0 && board[x1][y1])
           {
               q.push_front(make_pair(make_pair(x1,y1),magic));
              
           }
       }
       for(int i=-2;i<=2;i++)
       {
           for(int j=-2;j<=2;j++)
           {
              
                  int x1= x+i; 
                  int y1 = y+j;
           
                 if(x1>=1 && y1>=1 && x1<=h && y1<=w && visit[x1][y1]==0 && board[x1][y1])
                  {
                     q.push_back(make_pair(make_pair(x1,y1),magic+1));
                    // cout<<x1<<" "<<y1<<endl;
                  }
           
           }
       }
       
    }
    if(p==false)
    cout<<"-1"<<endl;

    return 0;
}


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

using namespace std;

int main() {
    int A, B, K;
    cin >> A >> B >> K;

    vector<int> divisors;

    for (int i = 1; i <= min(A, B); i++) {
        bool canDivideA = !(A % i);
        bool canDivideB = !(B % i);
        if (canDivideA && canDivideB) {
            divisors.push_back(i);
        }
    }

    // 降順に並べる
    sort(divisors.begin(), divisors.end(), greater<int>());

    int res = divisors.at(K - 1);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()

using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;


signed main(){
    string s,t;  cin >> s >> t;
    int a,b; cin >> a >> b;
    string u; cin >> u;
    if(u==s) a--;
    if(u==t) b--;
    cout << max(0,a) << " " << max(0,b) << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if( abs(a-b)<=d && abs(b-c) <= d || abs(a-c)<=d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}




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

using namespace std;

int main() {
  int n;
  cin >> n;
  double ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (i % 2 == 1) ans++;
  }
  printf("%.8f\n", ans / n);
  return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
int n, u, k, v, t, d[100][2]; vector<int> g[100];
void rec(int pos) {
	d[pos][0] = ++t;
	for(int i = 0; i < g[pos].size(); i++) {
		if(!d[g[pos][i]][0]) rec(g[pos][i]);
	}
	d[pos][1] = ++t;
}
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> u >> k;
		for(int j = 0; j < k; j++) cin >> v, g[u - 1].push_back(v - 1);
	}
	for(int i = 0; i < n; i++) {
		if(!d[i][0]) rec(i);
	}
	for(int i = 0; i < n; i++) cout << i + 1 << ' ' << d[i][0] << ' ' << d[i][1] << endl;
}

Measured memory_bytes: 3136
import sys
import bisect
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline

def main():
    a,b = map(int,read().split())
    if a > 0:
        print("Positive")
    elif b < 0:
        if (b - a)%2 == 1:
            print("Positive")
        else:
            print("Negative")
    else:
        print("Zero")
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060