akhauriyash/Code-Regression huggingface dataset:
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <ctype.h>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	char c;
	cin >> c;
	if (isupper(c)) {
		cout << "A" << endl;
	} else {
		cout << "a" << endl;
	}
	return 0;
}


Measured memory_bytes: 3548
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N, M;
  cin >> N >> M;
  vector<tuple<int64, int64, int64, string>> P(M);
  int64 p, w;
  for (int i = 0; i < M; i++) {
    cin >> p >> w;
    get<0>(P[i]) = p;
    get<1>(P[i]) = w;
    get<2>(P[i]) = i;
  }
  sort(P.begin(), P.end(), [](const auto& x, const auto& y) {
    if (get<0>(x) == get<0>(y))
      return get<1>(x) < get<1>(y);
    else
      return get<0>(x) < get<0>(y);
  });

  int64 prev_p = 0;
  int64 rank = 1;
  for (int i = 0; i < M; i++) {
    ostringstream ss;
    if (get<0>(P[i]) != prev_p) {
      rank = 1;
      prev_p = get<0>(P[i]);
    }
    ss << setw(6) << setfill('0') << get<0>(P[i]) << setw(6) << setfill('0')
       << rank;
    string s(ss.str());
    get<3>(P[i]) = s;
    rank++;
  }

  sort(P.begin(), P.end(),
       [](const auto& x, const auto& y) { return get<2>(x) < get<2>(y); });

  for (int i = 0; i < M; i++) {
    cout << get<3>(P[i]) << endl;
  }

  return 0;
}

Measured memory_bytes: 8780
def calc_n_layers(n):
    memo = {}
    def calc(n):
        if n in memo:
            return memo[n]
        if n <= 0:
            return 1
        ret = 3 + calc_n_layers(n-1)*2
        memo[n] = ret
        return ret
    return calc(n)


def n_patties(n):
    memo = {}
    def calc(n):
        if n in memo:
            return memo[n]
        if n <= 0:
            return 1
        ret = n_patties(n-1)*2 + 1
        memo[n] = ret
        return ret
    return calc(n)


def solve(n, x):
    if x <= 0:
        return 0
    if n <= 0:
        return 1
    l = calc_n_layers(n)
    l2 = (l - 3) // 2
    if x-1 <= l2:
        return solve(n-1, x-1)
    else:
        x = x - 1
        ret = n_patties(n-1)
        x = x - l2
        ret += 1
        x = x - 1
        ret += solve(n-1, x)
        return ret


def main():
    N, X = list(map(int, input().split(' ')))
    print(solve(N, X))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n , i , k , p ;
int a[100001] ;
int main() {
  p = 0 ;
  cin >> n >> k ;
  for ( i = 1 ; i <= n ; i ++ ){
    cin >> a[i] ;
    if ( a[i] >= k ) p ++ ;
  }
  cout << p ;
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>

int main()
{
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    printf("%f\n", sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)));
    return 0;
}

Measured memory_bytes: 1080
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut ans = vec![0; n];

    for _ in 0..m {
        let s: usize = read();
        let c: i32 = read();
        if ans[s - 1] == c || ans[s - 1] == 0 {
            ans[s - 1] = c;
        } else {
            ans.clear();
            break;
        }
        if s == 1 && c == 0  && n != 1 {
            ans.clear();
        }
    }
    if ans.is_empty() {
        println!("-1");
    } else {
        if ans[0] == 0  && ans.len() > 1 {
            ans[0] = 1;
        }
        for i in ans {
            print!("{}", i);
        }
    }
    println!("");
}


Measured memory_bytes: 2080
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		// 文字列の入力
		if ( a + b == c + d ) {
          System.out.println("Balanced");
        } else if ( a + b > c + d ) {
          System.out.println("Left");
        } else {
          System.out.println("Right");
        }
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)


void solve(long long N){
    ll ans = N;
    for(ll i = 1; i * i <= N; ++i){
        if(N % i == 0){
            ans = min(ans, (i - 1) + (N / i - 1));
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

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

  int h, n; cin >> h >> n;
  int sum = 0;
  rep(i,n){
    int a; cin >> a;
    sum  += a;
  }
  if(h <= sum) cout << "Yes" << '\n';
  else cout << "No" << '\n';

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
while(true){
int H=sc.nextInt();
int W=sc.nextInt();
if(H==0 && W==0)
break;
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
if((i+j)%2==0)System.out.print("#");
else System.out.print(".");
}System.out.println(); }
System.out.println();}}}

Measured memory_bytes: 35180
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(998244353);
const long long INIT=(long long)(2e5+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work
ll fact[INIT]={0};
int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    fact[0]=1;
    FORI(i,1,INIT)
    {
        fact[i]=(fact[i-1]*i)%MOD;
    }
    ll ans=0;
    READV(N);
    READV(M);
    READV(K);
    FORI(i,0,K+1)
    {
        ll ans1=(fact[N-1]*modInverse((fact[N-1-i]*fact[i])%MOD))%MOD;
        ans1=(ans1*M)%MOD;
        ans1=(ans1*power(M-1,N-i-1))%MOD;
        ans+=ans1;
        ans%=MOD;
    }
    cout<<ans<<endl;

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 5368
#include<bits/stdc++.h>
using namespace std;
map<int,int> G;
int n,m;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		int a;cin>>a;
		G[a]++;
	}
	cin>>m;
	for(int i=1;i<=m;i++){
		int a;cin>>a;
		if(!G[a]){puts("NO");return 0;}
		G[a]--;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >>N;
    vector<tuple<string,int,int>>t;
    for(int i=0;i<N;i++){
        string A;
        int B;
        cin >> A>>B;
        B=-B;
        t.push_back(make_tuple(A,B,i+1));
    }
    sort(t.begin(),t.end());
    for(int i=0;i<N;i++){
        cout<<get<2>(t.at(i))<<endl;
    }


}

Measured memory_bytes: 3616
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
const int maxn=200000;
int read()
{
  int x=0,f=1;
  char ch=getchar();
  while((ch<'0')||(ch>'9'))
    {
      if(ch=='-')
        {
          f=-f;
        }
      ch=getchar();
    }
  while((ch>='0')&&(ch<='9'))
    {
      x=x*10+ch-'0';
      ch=getchar();
    }
  return x*f;
}

int n,a[maxn+10],t[maxn+10][23],now[23];
long long ans;

inline int trans(int v,int pos)
{
  int x=1;
  while(v)
    {
      t[pos][x]=v%2;
      ++x;
      v/=2;
    }
  return 0;
}

inline int check(int pos)
{
  for(int i=1; i<=20; ++i)
    {
      if(now[i]&&t[pos][i])
        {
          return 0;
        }
    }
  return 1;
}

int main()
{
  n=read();
  for(int i=1; i<=n; ++i)
    {
      a[i]=read();
      trans(a[i],i);
    }
  int r=1;
  for(int i=1; i<=20; ++i)
    {
      now[i]=t[1][i];
    }
  for(int l=1; l<=n; ++l)
    {
      for(int i=1; i<=20; ++i)
        {
          now[i]^=t[l-1][i];
        }
      while((r<n)&&(check(r+1)))
        {
          ++r;
          for(int i=1; i<=20; ++i)
            {
              now[i]|=t[r][i];
            }
        }
      ans+=r-l+1;
    }
  printf("%lld\n",ans);
  return 0;
}

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

int main(){
  int r, c, tmp;
  cin >> r; cin >> c;
  vector<vector<int>> col_sum(r+1, vector<int>(c+1));
  for(int row = 0; row < r; row++){
    for(int col = 0; col < c; col++){
      cin >> tmp;
      col_sum[row][col] = tmp;
      col_sum[r][col] += tmp;
      col_sum[row][c] += tmp;
      col_sum[r][c] += tmp;
    }
  }
  for(int row = 0; row < r+1; row++){
    for(int col = 0; col < c; col++){
      cout << col_sum[row][col] << " ";
    }
    cout << col_sum[row][c] << endl;
  }
  return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
int n;
vector<string>v;
void dfs(string s,char c)
{
	if(s.size()==n)
	{
		v.push_back(s);
		return;
	}
	for(int i='a';i<=c+1;i++)
	{
		char nw=i;
		string ss=s+nw;
		dfs(ss,max(nw,c));
	}
}
int main()
{
	cin>>n;
	dfs("a",'a');
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		cout<<v[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 7796
if __name__ == '__main__':
    MOD = 10 ** 9 + 7
    N, K = map(int, input().split())

    acmN = [0]
    for n in range(N+1):
        if n == 0:
            acmN.append(0)
        else:
            acmN.append(n + acmN[n])

    if N+1 == K:
        print(1)
    else:
        ans = 0
        for k in range(K, N+2):
            ans += ((acmN[-1] - acmN[-k-1]) - (acmN[k]) + 1) % MOD

        print(ans % MOD)


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll H, W, N;
ll ans[10];
vector< pair<ll, ll> > black;   // 黒く塗られたところ
map< pair<ll, ll>, ll > sq;         // black に影響を受ける左上 (i, j) の 3 * 3 領域

int main()
{
    cin >> H >> W >> N;
    ZERO(ans);
    REP(i, N) {
        ll a, b;
        scanf("%lld %lld", &a, &b);
        a--; b--;
        black.push_back( make_pair(a, b) );
        for(ll i = -2; i < 1; ++i) {
            for(ll j = -2; j < 1; ++j) {
                if(a + i >= 0 && b + j >= 0 &&
                   a + i < H - 2 && b + j < W - 2) {
                    sq[ make_pair(a + i, b + j) ]++;
                    //printf("a: %lld b: %lld  sq[%lld, %lld]: %lld -> %lld\n",
                    //        a, b, a+i, b+j, sq[ make_pair(a + i, b + j) ]-1,
                    //        sq[ make_pair(a + i, b + j) ]);
                }
            }
        }
    }
    for(auto tmp : sq) {
        ans[tmp.second]++;
    }
    ans[0] = (W - 2) * (H - 2);
    for(int i = 1; i < 10; ++i) {
        ans[0] -= ans[i];
    }
    REP(i, 10) {
        printf("%lld\n", ans[i]);
    }

    return 0;
}


Measured memory_bytes: 58096
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const ll MOD=1e9+7;
const int INF=1<<30;


using namespace std;

ll dat[100005];
ll cnt[105][100005];
ll summ[105][100005];

int main(){
	//ios::sync_with_stdio(false);cin.tie(NULL);	cout.tie(NULL);
	int in,n;
	cin>>in>>n;
	rep(i,in,1){
		cin>>dat[i];
	}
	for(int i=in;i>=1;i--){
		if(i==in){
			repp(j,0,n,1){
				if(j<=dat[i]){
					cnt[i][j]=1;
				}
				if(j==0)summ[i][j]=cnt[i][j]%MOD;
				else summ[i][j]=(summ[i][j-1]+cnt[i][j])%MOD;
			}
		}
		else{
			repp(j,0,n,1){
				if(j<=dat[i]){
					cnt[i][j]=summ[i+1][j];
				}
				else{
					cnt[i][j]=MOD+summ[i+1][j]-summ[i+1][j-dat[i]-1];
					cnt[i][j]%=MOD;
				}
				if(j==0)summ[i][j]=cnt[i][j]%MOD;
				else summ[i][j]=(summ[i][j-1]+cnt[i][j])%MOD;
			}
		}
	}
	cout<<cnt[1][n]%MOD<<endl;
	return 0;
}


Measured memory_bytes: 159232
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#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 zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#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 vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define gcd(m,n)        __gcd(m,n)
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz               size()
#define inc(i,x,y)      for(int i=x;i<=y;i++)
#define dec(i,x,y)      for(int i=x;i>=y;i--)



#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif

void fast()
{
	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);
//#endif
}

//////////////////////////////code//////////////////////////////
int lower(vector<int>&a,int key,int low,int high)
{
    int ans=-1;
    while(low<=high)
    {
        int mid = (low+high)/2;
        if(a[mid]>=key)
        {
            ans=mid;
            high=mid-1;
        }
         else
          low=mid+1;
    }
    return ans;
}
int upper(vector<int>&a,int key,int low,int high)
{
    int ans=-1;
    while(low<=high)
    {
        int mid = (low+high)/2;
        if(a[mid]<=key)
        {
            ans=mid;
           low=mid+1;
        }
        else
         high=mid-1;
    }
    return ans;
}
int32_t main()
{
  fast();
  int n;cin>>n;

 vi arr(n+1);
 for(int i=1;i<=n;i++) cin>>arr[i];

 vi a(n+1),b(n+1);

 for(int i=1;i<=n;i++)
 {
     a[i]=i-arr[i];
     b[i]=i+arr[i];
 }

 sort(a.begin()+1,a.begin()+n+1);
 sort(b.begin()+1,b.begin()+n+1);
//show(a,0,a.sz-1);
//show(b,0,b.sz-1);
 int ans=0;
 for(int i=1;i<=n;i++)
 {
     int x = lower(b,a[i],1,b.sz-1);
     int y = upper(b,a[i],1,b.sz-1);

     if(y!=-1 && x!=-1)
        ans+=(y-x+1);
 }

 cout<<ans<< "\n";




}


Measured memory_bytes: 7940
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x) -> int:
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y) -> None:
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x) -> int:
        return -self.parents[self.find(x)]

    def same(self, x, y) -> bool:
        return self.find(x) == self.find(y)

    def members(self, x) -> list:
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self) -> list:
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self) -> int:
        return len(self.roots())

    def all_group_members(self) -> dict:
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
a=UnionFind(n)
for i in range(m):
    b,c=map(int,input().split())
    a.union(b-1,c-1)
print(a.group_count()-1)

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

int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int a,b;
	cin>>a>>b;
	
	if(b==1){
		cout<<0;
		return 0;
	}
	if(a==2){
		cout<<b-1;
		return 0;
	}
	if(a>=b){
		cout<<1;
		return 0;
	}
	int count=0;
	while(b>0){
		b-=a-1;
		count++;
		if(b<=a){
			count++;
			cout<<count;
			return 0;
		}
	}
	cout<<count;
	return 0;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

bool cmp(pair<ll, ll> a, pair<ll, ll> b) {
    return (b.ff + b.ss > a.ff + a.ss);
}

int main() {


    zoom;
    ll n, i, j;
    cin>>n;
    vector<pair<ll, ll> >A(n);
    for(i = 0; i < n; i += 1)
        cin>>A[i].ff>>A[i].ss;
    sort(A.begin(), A.end(), cmp);
    vector<vector<ll> > dp(n, vector<ll>());
    dp[0].pb(0);
    dp[0].pb(A[0].ss);
    for(i = 1; i < n; i += 1) {
        dp[i].pb(0);
        for(j = 1; j <= i; j += 1) {
            ll temp1 = dp[i - 1][j];
            ll temp2 = -1;
            if(dp[i - 1][j - 1] != -1 && dp[i - 1][j - 1] <= A[i].ff)
                temp2 = dp[i - 1][j - 1] + A[i].ss;            
            if((temp1 == -1 && temp2 == - 1))
                dp[i].pb(-1);
            else if(temp1 == -1)
                dp[i].pb(temp2);
            else if(temp2 == -1)
                dp[i].pb(temp1);
            else
                dp[i].pb(min(temp1, temp2));
        }
        if(dp[i - 1][j - 1] != -1 && dp[i - 1][j - 1] <= A[i].ff)
            dp[i].pb(dp[i - 1][j - 1] + A[i].ss);
        else
            dp[i].pb(-1); 
    }
    ll ans = -1;
    for(i = n - 1; i >= 0; i -= 1) {
        for(j = i + 1; j >= 1; j -= 1) {
            if(dp[i][j] != -1)
            ans = max(ans, j); 
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 113408
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
  	if(s[i] == '7'){
  		cout << "Yes" << endl;
  		return 0;
	  }
  }
   cout << "No" << endl;
}

Measured memory_bytes: 3620
#python3
import collections as col
n=int(input())
a=[input() for i in range(n)]

b=col.defaultdict(int)
for i in a:
  b[''.join(sorted(i))]+=1

#c = [''.join(sorted(a)) for _ in range(n)]

sum1=0
for i in b.values():
  sum1+=i*(i-1)//2
print(sum1)







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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, h;
	cin>>n>>h;
	int a = 0;
	vector<int> b(n);
	for(int i = 0; i < n; i++){
		int x; cin>>x>>b[i];
		a = max(a, x);
	}
	sort(b.rbegin(), b.rend());
	ll ans = h;
	ll sum = 0;
	for(int i = 0; i < n; i++){
		sum += b[i];
		ll req = max(0LL, h - sum);
		ans = min(ans, i + 1 + (req + a - 1)/a);
	}
	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,ans=0;
    cin >> n;
    vll a(n);
    rep(i,n) cin >> a[i];
    if(a[0]!=0){
        cout << -1 << endl;
        return 0;
    }
    for(ll i=1;i<n;i++){
        if(a[i]-a[i-1]>1){
            cout << -1 << endl;
            return 0;
        }
        if(a[i]>a[i-1]) ans++;
        else if(a[i]==a[i-1] || a[i]<a[i-1]) ans+=a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
D,N=map(int,input().split())
if D==0:
	if N==100:
		print(101)
	else:
		print(N)
elif D==1:
	if N==100:
		print(101*100)
	else:
		print(N*100)
	
elif D==2:
	if N==100:
		print(101*100*100)
	else:
		print(N*100*100)

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

// ====================================================================
template <int MOD_> struct modnum {
    static constexpr int MOD = MOD_;
    static_assert(MOD_ > 0, "MOD must be positive"); 
private:
    using ll = long long;
    int v;
    static int minv(int a, int m) {
        a %= m;
        assert(a);
        return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
    }

public:
    modnum() : v(0) {}
    modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
    explicit operator int() const { return v; }
    friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
    friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }
    friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
    friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; } 
    modnum inv() const {
        modnum res;
        res.v = minv(v, MOD);
        return res;
    }
    friend modnum inv(const modnum& m) { return m.inv(); }
    modnum neg() const {
        modnum res;
        res.v = v ? MOD-v : 0;
        return res;
    }
    friend modnum neg(const modnum& m) { return m.neg(); }
    modnum operator- () const {
        return neg();
    }
    modnum operator+ () const {
        return modnum(*this);
    }
    modnum& operator ++ () {
        v ++;
        if (v == MOD) v = 0;
        return *this;
    }
    modnum& operator -- () {
        if (v == 0) v = MOD;
        v --;
        return *this;
    }
    modnum& operator += (const modnum& o) {
        v += o.v;
        if (v >= MOD) v -= MOD;
        return *this;
    }
    modnum& operator -= (const modnum& o) {
        v -= o.v;
        if (v < 0) v += MOD;
        return *this;
    }
    modnum& operator *= (const modnum& o) {
        v = int(ll(v) * ll(o.v) % MOD);
        return *this;
    }
    modnum& operator /= (const modnum& o) {
        return *this *= o.inv();
    }

    friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
    friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
    friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
    friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
    friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
    friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using Mint = modnum<1000000007>;
// ====================================================================

signed main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    int n;
    std::cin >> n;

    std::vector<int> a(n + 1);
    std::vector<Mint> sum(n + 1);

    for (int i = 1; i <= n; i++) {
        std::cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }

    Mint ans = 0;

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

    std::cout << ans;

    return 0;
}



Measured memory_bytes: 4788
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<long> A(N);
  vector<long> B(N);
  vector<int> k(N);
  for(int i=0; i<N; i++){
    cin >> A[i] >> B[i];
    k[i]=i;
  }
  sort(k.begin(), k.end(), [&A](long l, long r)->bool {
    return A[l]<A[r];
  });
  long r = 0;
  long c = 0;
  for(int &i: k){
    if(B[i]<M-c){
      r += A[i]*B[i];
      c += B[i];
    }else{
      r += A[i]*(M-c);
      c += M-c;
      break;
    }
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

string a,b,ans;



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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

// int cans(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

//-----------------------------------------


int main(){
  int N;
  int ans = 0;
  cin >> N;
  string s;
  cin >> s;
  rep(i,N-2){
    if(s.substr(i,3) == "ABC") ans++;
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n,k; cin >> n >> k;

    vector<vector<int> > nck(4001,vector<int>(4001));
    for(int i = 1;i < 4001;i ++){
        nck.at(i).at(0) = 1;
    }
    nck.at(1).at(1) = 1;
    nck.at(0).at(0) = 1;
    for(int i = 2;i < 4001;i ++){
        for(int j = 1;j < 4001;j ++){
            nck.at(i).at(j) = nck.at(i-1).at(j) + nck.at(i-1).at(j-1);
            nck.at(i).at(j) %= 1000000007;
        }
    }

    for(int i = 1;i < k+1;i ++){
        if(i > n-k+1){
            cout << 0 << endl;
            continue;
        }
        int ikobunkatsu = nck.at(k-1).at(i-1) % 1000000007;
        int ikoinsert = nck.at(n-k+1).at(i) % 1000000007;
        cout << ikobunkatsu * ikoinsert % 1000000007 << endl;
    }
}

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 2e6 + 1;
const ll INF = 1e18 + 9;
const int B = 1e9 + 7;

int main() {
    #ifdef black
    //freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    int n, a, b;
    cin >> n >> a >> b;
    cout << ((b - a - 1) % 2 == 0 ? "Borys\n" : "Alice\n");

    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();//N体
		int[] monster = new int[N];
		for(int i=0; i<N; i++) {
			monster[i] = sc.nextInt();
		}
		int gcd = Arrays.stream(monster)
				.mapToObj(BigInteger::valueOf)
	            .reduce(BigInteger::gcd)
	            .orElse(BigInteger.ZERO)
	            .intValue();
		System.out.println(gcd);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 44968
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v){os << " [" << i++ << "]" << x; if (i % 5 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 5 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::ostringstream oss;

  ll N;
  std::cin >> N;

  //std::string ans = "ABC" + std::to_string(N);
  oss << "ABC" << N;
  std::string ans = oss.str();
  print(ans);
  return 0;
}


Measured memory_bytes: 256
// Last Change: 09/11/2019 18:59:27.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

const int VACANT = 0, MALE = 1, FEMALE = 2;

int getState(int pos) {
  string res;
  cout << pos << endl;
  cin >> res;
  if (res == "Vacant") {
    return VACANT;
  } else if (res == "Male") {
    return MALE;
  } else {
    return FEMALE;
  }
}

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

  int zeroState = getState(0);
  if (zeroState == VACANT) {
    return 0;
  }

  int cnt = 0;
  for (int first = 0, dist = N, state = -5; state != VACANT;) {
    if (cnt >= 20) {
      return 1;
    }

    int half = dist / 2;
    int mid = first + half;

    state = getState(mid);
    cnt++;

    if ((state == zeroState and mid % 2 == 1)
        or (state != zeroState and mid % 2 == 0)) {
      //左側
      dist = half;
    } else {
      //右側
      first = mid + 1;
      dist -= half + 1;
    }
  }
}


Measured memory_bytes: 852
s=input()
t=input()
n=len(s)
m=len(t)
ans=100000000
for i in range(n-m+1):
    tmp=0
    for x,y in zip(t,s[i:i+m]):
        if x!=y:
            tmp+=1
    ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 8800
#include <iostream>
#include <string>
#include <cassert>
using namespace std;

int p,q,r;
int pos;

int parse(string &s) {
    if(s[pos] == '(') {
        pos++;
        int k = parse(s),res;
        if(s[pos] == '+') {
            pos++;
            int l = parse(s);
            if(k == 2 || l == 2) res = 2;
            else if(k == 0 && l == 0) res = 0;
            else res = 1;
        }else if(s[pos] == '*') {
            pos++;
            int l = parse(s);
            if(k == 0 || l == 0) res = 0;
            else if(k == 2 && l == 2) res = 2;
            else res = 1;
        }
        assert(s[pos] == ')');
        pos++;
        return res;
    }
    if(s[pos] == '-') {
        pos++;
        int k = parse(s);
        if(k == 0) return 2;
        else if(k == 1) return 1;
        else return 0;
    }

    if(s[pos] == 'P') {
        pos++;
        return p;
    }
    if(s[pos] == 'Q') {
        pos++;
        return q;
    }
    if(s[pos] == 'R') {
        pos++;
        return r;
    }
    if(s[pos] == '0' || s[pos] == '1' || s[pos] == '2') {
        int l = s[pos] - '0';
        pos++;
        return l;
    }

    assert(false);
}

int main() {
    string s;
    while(cin>>s) {
        if(s == ".") break;

        int ans = 0;
        for(int i=0; i<=2; ++i)
            for(int j=0; j<=2; ++j)
                for(int k=0; k<=2; ++k) {
                    p=i,q=j,r=k;
                    pos = 0;
                    if(parse(s) == 2) ans++;
                }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 0
#include <stdio.h>
#define min(a,b) (a<b)?(a):(b)
#define max(a,b) (a>b)?(a):(b)

long long gcd(long long a,long long b) {
	long long A=max(a,b),B=min(a,b);
	return A%B?gcd(A%B,B):B;
}
long long lcm(long long a,long long b) {
	return a*b/gcd(a,b);
}

int main(void) {
	long long a,b;
	while(scanf("%lld %lld",&a,&b)!=EOF) {
		printf("%lld %lld\n",gcd(a,b),lcm(a,b));
	}
    return 0;
}

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

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

string str;
int ans;

class dice{
public:
	int con[6];
	int n[6];
	
	void res(){
		rep(i, 6) n[i] = con[i];
	}

	void E(){
		int t = n[0];
		n[0] = n[3];
		n[3] = n[5];
		n[5] = n[2];
		n[2] = t;
	}
	void W(){
		int t = n[0];
		n[0] = n[2];
		n[2] = n[5];
		n[5] = n[3];
		n[3] = t;
	}
	void S(){
		int t = n[0];
		n[0] = n[4];
		n[4] = n[5];
		n[5] = n[1];
		n[1] = t;
	}
	void N(){
		int t = n[0];
		n[0] = n[1];
		n[1] = n[5];
		n[5] = n[4];
		n[4] = t;
	}
	void spin(){
		int t = n[1];
		n[1] = n[2];
		n[2] = n[4];
		n[4] = n[3];
		n[3] = t;
	}
};


int main(){
	dice d;
	rep(i, 6){
		cin >> d.con[i];
		d.n[i] = d.con[i];
	}
	int q;
	cin >> q;
	rep(i, q){
		int a, b;
		cin >> a >> b;
		d.res();
		rep(i, 4){
			d.W();
			if (d.n[0] == a){
				goto endcheck;
			}
		}
		rep(i, 4){
			d.S();
			if (d.n[0] == a){
				goto endcheck;
			}
		}
	endcheck:
		while (d.n[1] != b){
			d.spin();
		}
		cout << d.n[2] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 110
#define INF 1e9
#define F first
#define S second
typedef pair<int,int> pii;
typedef pair<pii,int> State;
 
struct Edge{
  int to,cost;
  Edge(){}
  Edge(int to,int cost) : to(to),cost(cost) {}
};
 
int N,M,L,K,A,H;
bool l[MAX];
vector<Edge> G[MAX];
 
void init(){
  for(int i = 0 ; i < MAX ; i++){
    l[i] = false;
    G[i].clear();
  }
}
 
int dijkstra(){
  priority_queue<State,vector<State>,greater<State> > Q;
  Q.push(State(pii(0,A),M));
  
  int Time[MAX][MAX];
  fill(Time[0],Time[0]+MAX*MAX,INF);
  Time[A][M] = 0;
 
  while(!Q.empty()){
    State s = Q.top(); Q.pop();
    int v = s.F.S, m = s.S;
    if(Time[v][m] < s.F.F) continue;

    if(v == H){
      return Time[H][m];
    }

    if(l[v]){
      for(int i = 1 ; i <= M-m ; i++){
        if(Time[v][m] + i < Time[v][m+i]){
          Time[v][m+i] = Time[v][m] + i;
          Q.push(State(pii(Time[v][m+i],v),m+i));
        }
      }
    }
 
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      Edge e = G[v][i];
      if(m - e.cost >= 0){
        if(Time[v][m] + e.cost < Time[e.to][m-e.cost]){
          Time[e.to][m-e.cost] = Time[v][m] + e.cost;
          Q.push(State(pii(Time[e.to][m-e.cost],e.to),m-e.cost));
        }
      }
    }
  }
  return INF;
}
 
int main(){
  int a,b,c;
  while(cin >> N >> M >> L >> K >> A >> H, N){
    init();
    for(int i = 0 ; i < L ; i++){
      cin >> a;
      l[a] = true;
    }
    for(int i = 0 ; i < K ; i++){
      cin >> a >> b >> c;
      G[a].push_back(Edge(b,c));
      G[b].push_back(Edge(a,c));
    }
    int res = dijkstra();
    if(res == INF){
      cout << "Help!" << endl;
    }else{
      cout << res << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1476
a = sorted(list(map(int, input().split())))
even = []
No = []
for i in range(3):
    if a[i] % 2 == 0:
        even.append(a[i])
    else: No.append(a[i])

if len(even) == 0 or len(even) == 3:
    ans = (a[1] - a[0])//2 + a[2]-a[1]
elif len(even) == 1:
    ans = 1
    a = sorted(even+ [No[0]+1, No[1]+1])
    ans += (a[1]-a[0])//2 + a[2]-a[1]
elif len(even) == 2:
    ans = 1
    a = sorted(No + [even[0]+ 1, even[1]+1])
    ans += (a[1]-a[0])//2 + a[2]-a[1]
print(ans)

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

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

  if (y % 1000 != 0)
    cout << "-1 -1 -1" << endl;
  else {
    y /= 1000;
    int m = y - n;

    for (int a = m / 9; a > m / 9 - 4; a--) {
      int b = (m - 9 * a) / 4;
      int c = n - a - b;
      if ((9 * a + 4 * b == m) && (a + b + c == n) && (a >= 0) && (b >= 0) &&
          (c >= 0)) {
        cout << a << ' ' << b << ' ' << c << endl;
        break;
      }
      if (a == m / 9 - 3)
        cout << "-1 -1 -1" << endl;
    }
  }
}


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

int main() {
    int N, M;
    while (cin >> N >> M, N || M) {
        int a, b, c;
        int sub = M - N;
        c = sub / 1000;
        sub %= 1000;
        b = sub / 500;
        sub %= 500;
        a = sub / 100;

        cout << a << ' ' << b << ' ' << c << endl;
    }

    return 0;
}

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

const int mx = 2e5+5;
vector<int> v[mx];

main()
{
	int n;
	cin>>n;
	for(int i=2;i<=n;i++)
	{
		int x;
		cin>>x;
		v[x].push_back(i);
	}
	for(int i=1;i<=n;i++) cout<<v[i].size()<<"\n";
}

Measured memory_bytes: 14572
import java.util.*;

public class Main {
	public static void main(String[] args) {
		new Main().AOJ0554();
	}
	Scanner sc = new Scanner(System.in);
	
	void AOJ0554(){
		int input = 0;
		for(int i = 0; i < 4 ; i++){
			input += sc.nextInt();
		}
		
		System.out.printf("%d\n%d\n",input/60,input%60);
		
	}
	
}

Measured memory_bytes: 12000
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long h=sc.nextLong();
		long w=sc.nextLong();
		if(h==1 || w==1){
			System.out.println(1);
		}else{
			System.out.println((h*w+1)/2);
		}
	}
}


Measured memory_bytes: 21972
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
void main() {
    int A, B;
    readf("%d %d\n", &A, &B);
    A = (A+11)%13;
    B = (B+11)%13;
    writeln(A>B?"Alice":A<B?"Bob":"Draw");
}

// ----------------------------------------------

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
    template fold(fun...) if (fun.length >= 1) {
        auto fold(R, S...)(R r, S seed) {
            static if (S.length < 2) {
                return reduce!fun(seed, r);
            } else {
                return reduce!fun(tuple(seed), r);
            }
        }
    }
}

// minElement/maxElement was added in D 2.072.0
static if (__VERSION__ < 2072) {
    auto minElement(alias map, Range)(Range r)
    if (isInputRange!Range && !isInfinite!Range)
    {
        alias mapFun = unaryFun!map;
        auto element = r.front;
        auto minimum = mapFun(element);
        r.popFront;
        foreach(a; r) {
            auto b = mapFun(a);
            if (b < minimum) {
                element = a;
                minimum = b;
            }
        }
        return element;
    }
    auto maxElement(alias map, Range)(Range r)
    if (isInputRange!Range && !isInfinite!Range)
    {
        alias mapFun = unaryFun!map;
        auto element = r.front;
        auto maximum = mapFun(element);
        r.popFront;
        foreach(a; r) {
            auto b = mapFun(a);
            if (b > maximum) {
                element = a;
                maximum = b;
            }
        }
        return element;
    }
}


Measured memory_bytes: 256