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

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) os << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,L,Q;
vector<ll> X,A,B;


void input(){
  #ifdef __LOCAL
      fs::path p = __FILE__;
      fs::path input,output;
      input = output = p.parent_path();
      input += string("/input/") + string(p.stem()) + string(".txt");
      output += string("/output/") + string(p.stem()) + string(".txt");
      freopen(input.c_str(), "r", stdin);
      freopen(output.c_str(), "w", stdout);
  #endif

  fast_io();
  cin >> N;
  X = fetch_vec<ll>(N);
  cin >> L >> Q;
  for (int i = 0; i < Q; i++)
  {
    ll a,b;
    cin >> a >> b;
    a--,b--;
    if(a>b) swap(a,b);
    A.push_back(a);
    B.push_back(b);
  }
  

}



int solve(){
  int LogN = floor(log2(N));
  vector<vector<int>> next(LogN+1,vector<int>(N,0));
  for (int j = 0; j < N; j++)
  {
    auto itr = upper_bound(X.begin(),X.end(),L+X[j]);
    itr--;
    next[0][j] = itr-X.begin();
  }
  DBG(next[0])
  for (int k = 0; k < LogN; k++)
  {
    for (int i = 0; i < N; i++)
    {
      next[k+1][i] = next[k][next[k][i]];
    }
  }

  for (int i = 0; i < Q; i++)
  {
    int a=A[i],b=B[i];
    int ans=0;

    // for(;;){
    //   int ng=-1,ok=LogN+1;
    //   while(ok-ng>1){
    //     int mid=(ng+ok)/2;
    //     if(next[mid][a]>=b) ok=mid;
    //     else ng=mid;
    //   }
    //   if(ng==-1){ans+=1; cout << ans << endl; break;}
    //   else{
    //     a = next[ng][a];
    //     ans += (1<<ng);
    //     }
    // }
    for (int i = LogN; i >= 0; i--)
    {
      if(next[i][a]<b){
        a = next[i][a];
        ans+=(1<<i); 
      }
    }
    cout << ++ans << endl;

  }
  


  return 0;
}

int main()
{
  input();
  solve();
  return 0;
}


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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T1, class T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    double a, b, h, m;

    cin >> a >> b >> h >> m;

    double rad = ((h * 30 + m * 0.5) - m * 6) * M_PI / 180.0;

    cout << std::setprecision(50);
    cout << sqrt(a * a + b * b - 2 * a * b * cos(rad)) << endl;
}

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

int main() {
	int n,m;
	cin>>n>>m;
	int h[n];
	for(int i=0;i<n;i++){cin>>h[i];}
	bool  res[n];memset(res,true,sizeof(res));
	for(int i=0;i<m;i++){
	    int a,b;
	    cin>>a>>b;
	    if(h[a-1]>h[b-1]){res[b-1]=false;}
	    else if(h[a-1]<h[b-1]){res[a-1]=false;}
	    else{res[a-1]=false;res[b-1]=false;}
	}
	int ans=0;
	for(int i=0;i<n;i++){
	    if(res[i]==true){ans++;}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 4080
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
ll x, y;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> x >> y;
    cout << (y % 2 == 0 && y >= x * 2 && y <= x * 4 ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3660
H,W = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))

M = [[0 for _ in range(W)] for _ in range(H)]
C = []
for i in range(len(A)):
    C += [str(i+1)]*A[i]

k = 0
for i in range(H):
    for j in range(W):
        if i%2==0:
            M[i][j] = C[k]
        else:
            M[i][W-1-j] = C[k]
        k += 1

for i in range(H):
    print(" ".join(M[i]))

Measured memory_bytes: 3828
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
int main(){
	string n,tmp;
	getline(cin,n);
	vector<string>ta;
	for(int i=0;i<=n.size();i++){
	if(n[i]==' '||n[i]==','||n[i]=='.'||i==n.size()){
	if(tmp.size()>=3&&tmp.size()<=6)ta.push_back(tmp);
	tmp.clear();
	}
	else tmp.push_back(n[i]);
	}
	for(int i=0;i<ta.size();i++)(i==ta.size()-1)?cout<<ta[i]<<endl:cout<<ta[i]<<" ";
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if (S == U) {
    cout << A - 1 << " " << B << endl;
  }
  else {
    cout << A << " " << B - 1 << endl;
  }
}

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


int main() {
  int L , R , d ; 
  int C = 0 ; 
  
  cin >> L >> R >> d ; 
  
  for(int i = L ; i <= R ; i++){
    if( i % d == 0 ){
      C++ ; 
    }
  }
  cout << C << endl ; 
}

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

int main(){
    int n;
    cin >> n;
    int taro=0;
    int hanako=0;
    for (int i=0; i<n; i++){
        string s1, s2;
        cin >> s1 >> s2;
        if (s1<s2) {hanako+=3;}
        else if (s1==s2) {taro++; hanako++;}
        else {taro+=3;}
    }
    cout << taro << " " << hanako << endl;
}


Measured memory_bytes: 3216
#include <cstdio>
#include <algorithm>
long long s,ans;//s和ans要开long long
int n,a[200003];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    std::sort(a+1,a+1+n);//从小到大排序
    for(int i=2;i<=n;i++){
        s=(s+a[i-1])%1000000007;//求前i-1的前缀和
        ans=(ans+s*a[i])%1000000007;//加上s*a[i]，两个都要取模
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2476
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

ll l, r;

void init()
{
	cin >> l >> r;
}


int main()
{
	init();

	if (r - l >= 2019)
	{
		cout << 0 << endl;
		return 0;
	}

	Vl v;
	for (int i = l; i <= r; ++i)
		v.PB(i % 2019);

	ll ans = linf;
	REP(i, SZ(v) - 1)
		for (int j = i + 1; j < SZ(v); ++j)
			chmin(ans, v[i] * v[j] % 2019);

	cout << ans << endl;
}


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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

int N;
void dfs(string& s, char mx) {
    if (s.size() == N) {
        cout << s << endl;
        return;
    }
    for (char c = 'a'; c <= mx; c++) {
        s.push_back(c);
        dfs(s, (c == mx) ? (mx + 1) : mx);
        s.pop_back();
    }
}

void solve(long long N_) {
    N = N_;
    string s = "";
    dfs(s, 'a');
}

int main() {
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3692
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#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)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
}
const int N = 1e4 + 5;
const int M = 105;
int dp[N][M][2];
int n, m;
string num;
int d;
int add(lli a, lli b) {
	return ((a % mod) + (b % mod)) % mod;
}
lli help(lli idx, lli sum, lli flag) {
	if (idx == n) {

		return sum == 0;
	}
	if (dp[idx][sum][flag] != -1) return dp[idx][sum][flag];
	lli ret = 0;
	if (flag) {
		for (int i = 0; i <= num[idx] - '0'; i++) {
			ret = add(ret, help(idx + 1, (sum + i) % d , i == num[idx] - '0'));
		}
	} else {
		for (int i = 0; i <= 9; i++) {
			ret = add(ret, help(idx + 1, (sum + i) % d , 0));
		}
	}
	return dp[idx][sum][flag] = ret;
}
void solve() {
	memset(dp, -1, sizeof dp);
	cin >> num;
	cin >> d;
	n = num.size();
	cout << ((help(0, 0, 1) % mod - 1 % mod) + mod) % mod << endl;
}
int main()
{
	zanj0();
	solve();
	return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> D(N, 0);
    int ans = 0;
    for (int i = 0; i < N; ++i) cin >> D[i];
    for (int i = 0; i < N - 1; ++i) {
        for (int j = i + 1; j < N; ++j) {
            ans += D[i] * D[j];
        }
    }
    printf("%d\n", ans);
}


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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a.at(i);
  }

  int max = 0;
  rep(i, n-1) {
    int delta = abs(a.at(i+1) - a.at(i));
    if (delta > max) max = delta;
  }
  {
    int delta = abs(a.at(0) + k - a.at(n-1));
    if (delta > max) max = delta;
  }

  cout << k - max << endl;
}

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

#define int long long


#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()



int H,W,mod;
string S[2222];


int A[2222][2222],B[2222][2222],BC[2222][2222],P[2222][2222];

signed  main(){
    cin>>H>>W>>mod;
    rep(i,H)cin>>S[i];


    A[0][0]=0;
    B[0][0]=1;
    BC[0][0]=S[0][0]-'0';
    P[0][0]=1;


    rep(i,H){
      rep(j,W){
        if(i==0&&j==0)continue;
        rep(dx,2){
          int dy=1-dx;
          int ii=i-dy;
          int jj=j-dx;
          if(ii<0||jj<0)continue;
          
          P[i][j]=(P[i][j]+P[ii][jj])%mod;
          if(S[i][j]=='+'){
            A[i][j]=(A[i][j]+A[ii][jj]+BC[ii][jj])%mod;
            B[i][j]=(B[i][j]+P[ii][jj])%mod;            
         }
          else if(S[i][j]=='*'){
            A[i][j]=(A[i][j]+A[ii][jj])%mod;
            B[i][j]=(B[i][j]+BC[ii][jj])%mod;
          }
          else{
            A[i][j]=(A[i][j]+A[ii][jj])%mod;
            B[i][j]=(B[i][j]+B[ii][jj])%mod;
            BC[i][j]=(BC[i][j]+10*BC[ii][jj]+(S[i][j]-'0')*B[ii][jj])%mod;
          }
        }
      }
    }


    cout<<(A[H-1][W-1]+BC[H-1][W-1])%mod<<endl;
}



Measured memory_bytes: 145764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

    	int H = 0;
    	int W = 0;

    	Scanner sc= new Scanner(System.in);

    	while( true ) {
    		H = sc.nextInt();
    		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 % 2 ) == ( j % 2 ) ) {
    					System.out.print( '#' );
       				}else {
    					System.out.print( '.' );
       				}
    			}
    			System.out.print( "\n" );
    		}
    		System.out.print( "\n" );
    	}
    	sc.close();
    }
}


Measured memory_bytes: 40404
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;


int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    ll n;
    cin >> n;
    ll cnt = 0;
    REP1(i,n){
        if(((i%3)==0)or((i%5)==0)) ;
        else cnt+=i;

        //cout << i << cnt << endl;
    }

cout << cnt << endl;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
int main(){
  char w[11],t[1001];
  int i,j,count=0;
  scanf("%s",w);
  int lenw =strlen(w);
  for(i=0;i<lenw;i++){
    if(w[i]>='A' && w[i]<='Z')w[i]+='a'-'A';
  }
  while(scanf("%s",t)){
    if(strcmp(t,"END_OF_TEXT")==0)break;
    int lent =strlen(t);
    for(j=0;j<lent;j++){
      if(t[j]>='A' && t[j]<='Z')t[j]+='a'-'A';
    }
    if(strcmp(w,t)==0)count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
#include <math.h>

typedef long long ll;
typedef unsigned long long ull;

#define vi std::vector<int>
#define vl std::vector<ll>
#define floop(n) for(int i = 0; i < n; ++i)
#define print(x) std::cout << x << std::endl;

const ll INF = 1e18;

int main()
{
    ll X, K, D;
    std::cin >> X >> K >> D;

    ll div = abs(X) / D;
    if(div >= K)
    {
        if(X >= 0)
            X -= (K*D);
        else
            X += (K*D);
        print(abs(X));
    }

    else
    {
        if(X >= 0)
            X -= (div*D);
        else
            X += (div*D);
        K -= div;

        if(K % 2 == 0)
        {
            print((X < 0 ? abs(X) : X));
        }
        else
        {
            print((X < 0 ? abs(X+D) : abs(X-D)));
        }
    }
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

typedef unsigned long long ull;

int n;

#define TUPLE(a,b,c,d) (a | (b<<16) | ((ull)c<<32) | ((ull)d<<48))
#define UNPACK(t,a,b,c,d) int a=((t)&65535),b=(((t)>>16)&65535),c=(((t)>>32)&65535),d=(((t)>>48)&65535)

ull normalize(int a,int b,int c,int d){
  ull r = TUPLE(a,b,c,d);
  REP(_,3){
    swap(a,b);
    swap(b,c);
    swap(c,d);
    CHMIN(r,TUPLE(a,b,c,d));
  }
  return r;
}
ull normalize(ull s){
  UNPACK(s,a,b,c,d);
  return normalize(a,b,c,d);
}
void debunpack(string po,ull s){
  UNPACK(s,a,b,c,d);
  printf("%s%5d%5d%5d%5d\n",po.c_str(),a,b,c,d);
}

int main(){
  // cube, [count,multiply]
  map<ull,pii> mp;
  scanf("%d",&n);
  REP(i,n){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    set<ull> S;
    S.insert(TUPLE(a,b,c,d));
    REP(_,3){
      swap(a,b);
      swap(b,c);
      swap(c,d);
      S.insert(TUPLE(a,b,c,d));
    }
    ull s = *S.begin();
    mp[s].first += 1;
    mp[s].second = 4/S.size();
  }
  ull ans = 0;
  for(auto& _s1:mp){
    ull s1 = _s1.first;
    ull u = _s1.second.first;
    _s1.second.first--;
    UNPACK(s1,a,b,c,d);
    for(auto& _s2:mp){
      ull s2 = _s2.first;
      ull v = u * _s2.second.first;
      _s2.second.first--;
      UNPACK(s2,h,g,f,e);
      REP(_,4){
        ull add = v;
        ull s3 = normalize(b,a,e,f);
        ull s4 = normalize(c,b,f,g);
        ull s5 = normalize(d,c,g,h);
        ull s6 = normalize(a,d,h,e);
        bool ok = mp.count(s3) && mp.count(s4) && mp.count(s5) && mp.count(s6);
        if(ok){
          add *= mp[s3].first * mp[s3].second;  mp[s3].first--;
          add *= mp[s4].first * mp[s4].second;  mp[s4].first--;
          add *= mp[s5].first * mp[s5].second;  mp[s5].first--;
          add *= mp[s6].first * mp[s6].second;  mp[s6].first--;
        }else{
          add = 0;
        }
        ans += add;
        if(ok){
          mp[s3].first++;
          mp[s4].first++;
          mp[s5].first++;
          mp[s6].first++;
        }
        swap(e,f);
        swap(f,g);
        swap(g,h);
      }
      _s2.second.first++;
    }
    _s1.second.first++;
  }
  printf("%llu\n",ans/6);
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1000000007;

struct mint
{
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

mint fact(ll n)
{
  if (n < 0)
    return mint(0);
  mint ret = 1;
  for (ll i = 1; i <= n; ++i)
    ret *= mint(i);
  return ret;
}
mint invfact(ll n)
{
  if (n < 0)
    return mint(0);
  mint ret = 1;
  for (ll i = 1; i <= n; ++i)
    ret *= mint(i).inv();
  return ret;
}
mint nCk(ll n, ll k)
{
  if (n < k || n < 0 || k < 0)
    return mint(0);
  return fact(n) * invfact(n - k) * invfact(k);
}

int main()
{
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  ll red = N - K;
  mint pre = 0;
  for (ll i = 1; i <= K; ++i)
  {
    cout << nCk(N - K + 1, i) * nCk(K - 1, i - 1) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::vec::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed 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 readChars(size: usize) -> Vec<char> {
    let mut s0: String = read();
    let mut s = Vec::new();
    for _ in 0..size {
        s.push(s0.pop().expect(""));
    }
    s.reverse();
    s
}

use std::cmp::*;

fn main() {
    let n: i32 = read();

    if n < 1000 {
        println!("ABC");
    }
    else {
        println!("ABD");
    }
}


Measured memory_bytes: 4352
S = input()
cnt = [0]*2019
cnt[0] = 1
n = 0
t = 1
for i in reversed(S):
    n += int(i)*t
    n %= 2019
    cnt[n] += 1
    t *= 10
    t %= 2019
print(sum(i*(i-1)//2 for i in cnt))

Measured memory_bytes: 9320
#include <bits/stdc++.h>
using namespace std;
     
const int MAX_N = 100000;
int n;
int a[MAX_N];

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

int gcdArray(int begin, int end) {
    if (end - begin == 1) {
        return gcd(a[begin], a[end]);
    }
    return gcd(a[begin], gcdArray(begin + 1, end));
}

void solve() {
    cout << gcdArray(0, n - 1) << endl;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    solve();
}

Measured memory_bytes: 2304
#include <stdio.h>

int main (void) {
    char s[1200];

    scanf ("%[^\n]", s);

    for (int i=0; s[i] != '\0'; i++) {
        if (s[i] >= 'a' && s[i] <= 'z') {
            s[i] += 'A' - 'a';
        } else if (s[i] >= 'A' && s[i] <= 'Z') {
            s[i] -= 'A' - 'a';
        } else continue;
    }

    printf ("%s\n", s);

    return 0;
}


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

#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ll,ll> pll;

ll n;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    ll ans = 0;
    for (ll i = 2; i*i <= n; i++)
    {
        if (n % i != 0)
            continue;
        ll pow = 0;
        while (n % i == 0)
        {
            n /= i;
            pow++;
        }
        // cout << i << " ^ " << pow << '\n';
        for (ll j = 1; pow >= j; j++)
        {
            pow -= j;
            ans++;
        }
    }
    if (n > 1)
        ans++;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>

using namespace std;

int gcd(int a, int b) {
	if (a > b) {
		swap(a, b);
	}

	if (a == 0) {
		return b;
	}

	return gcd(b%a, a);
}

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


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

	int g = a[0];
	for (int i = 1; i < n; i++) {
		g = gcd(g, a[i]);
	}
	
	cout << g << endl;
}

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

int main() {
  int N,i; cin >>N >>i;
  cout <<N-i+1 <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using Pdi = pair<double, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    string T; cin >> T;
    int N = SZ(T);
    REP(i, N) if(T[i] == '?') T[i] = 'D';
    Out(T);

    /*int ans = 0;
    REP(i, N) if(T[i] == 'D') ans++;
    REP(i, N - 1) if(T[i] == 'P' && T[i + 1] == 'D') ans++;
    Out(ans);*/

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x.at(i) >> y.at(i);
    }

    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        p.at(i) = i;
    }

    double sum = 0;
    do {
        for (int i = 0; i < n - 1; i++) {
            double a = x.at(p.at(i)) - x.at(p.at(i + 1)), b = y.at(p.at(i)) - y.at(p.at(i + 1));
            sum += sqrt(a * a + b * b);
        }
    } while (next_permutation(p.begin(), p.end()));

    for (int i = 2; i <= n; i++) {
        sum /= i;
    }
    printf("%.10f\n", sum);
}

Measured memory_bytes: 256
package main
import "fmt"
 
/*
i 的遍历顺序从最高位到最低位
T(i, prefix_remainder, isEqual) 表示第 i 位、
更高位的数字和 mod D 为 prefix_remainder、
状态为 isEqual(true 表示前缀与 K 的相应前缀相等，false < K 的相应前缀) 的方案数
则 T(hi, 0, true) 为最终答案，其中 hi = K 的最高位对应的 i，
比如：98765，则最高位 i = 5
 
状态转移：
T(i, prefix_remainder, isEqual) = 
Sum{ 
	T(i-1, prefix_remainder + d_i, isEqual && d_i == d[i])
	0 <= d_i <= 9 if !isEqual = false or d[i] if isEqual
}
其中，d_i 表示在 i 位上的数字选择，d[i] 表示 K 在 i 位上的数字
 
边界条件：
T(0, any, any) = 1，遍历到 0 意味着个位数字都已经确定完了
 
下面的具体实现与上述推导不符
*/
 
const MAXL = 1e5+5
const MAXD = 105
const MOD = 1e9+7
 
var n int
var D int
var d [MAXL]int
var T [MAXL][MAXD]int
 
func solve(i int, prefix int, isEqual bool) int {
	if i == n {
      	if prefix == 0 {
        	return 1
      	} else {
        	return 0
      	}
	}
	if !isEqual && T[i][prefix] >= 0 {
		return T[i][prefix]
	}
	maxD := 9
	if isEqual {
		maxD = d[i]
	}
	var sum int64
	for digit := 0; digit <= maxD; digit++ {
      	sum += int64(solve(i+1, (prefix+digit) % D, isEqual && digit == maxD))
	}
	sum %= MOD
	if !isEqual {
      	T[i][prefix] = int(sum)
	}
  	return int(sum)
}
 
func main() {
	var K string
	fmt.Scanln(&K)
	fmt.Scanln(&D)
	n = len(K)
	for i := 0; i < n; i++ {
      	d[i] = int(K[i] - '0')
	}
	for i := 0; i < n; i++ {
		for j := 0; j < D; j++ {
			T[i][j] = -1
		}
	}
	
    fmt.Println((solve(0, 0, true) - 1 + MOD) % MOD) // minus 1 for 0
}

Measured memory_bytes: 12004
#include<cstdio>
int main()
{
	int a,b,n;
	scanf("%d%d",&a,&b);
	n=a+b;
	if((n%3 == 0 || a%3 == 0 || b%3 == 0) && n != 0)
	{
		printf("Possible\n");
	}
	else
	{
		printf("Impossible\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std ;



int a[9] ;
int d[9] ;
int x[9] ;
int y[9] ;
int c[9][9] ;
int main(){
	int N ;
	cin >> N ;
	for( int i = 0; i < N ; i++ ){
		cin >> x[i] >> y[i] ;
	}
	a[0] = 1 ;
	for( int i = 1  ; i <= 8 ; i++  ){
		a[i] = i* a[i-1] ;
	}

	float Ans  = 0 ;
	for( int i = 0 ; i < N ; i++ ){
		for( int j = i ; j < N ; j++ ){
			Ans += sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
		}
	}
	printf("%f\n",(Ans*2*a[N-1])/ a[N]); 


	return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
using mat = vector<vector<ll>>;

inline void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];

template<class Abel, class OP>
class BIT {
  private:
    int n;
    std::vector<Abel> dat;
    OP op;
    Abel e;

  public:
    BIT(int n , OP op, Abel e = 0) : n(n), op(op), e(e){
		dat.resize(n + 1);
		for(int i = 0;i <= n;++i){
			dat[i] = e;
		}
    }
	void add(int k, Abel val){
		while(k <= n){
			dat[k] = op(val, dat[k]);
			k += k & -k;
		}
	}
	Abel acum(int k){
		Abel sum = e;
		while(k > 0){
			sum = op(sum, dat[k]);
			k -= k & -k;
		}
		return sum;
	}
};

signed main(){
	IOS();
	ll n;
	cin >> n;
	vector<ll> a(n), b;
	for (int i = 0;i < n;++i) {
		cin >> a[i];
	}
	b = a;
	sort(b.begin(), b.end());
	b.erase(unique(b.begin(), b.end()), b.end());
	BIT<ll, function<ll(ll, ll)>> bit(n, [](ll a, ll b){return a + b;}, 0);
	map<ll, ll> mp;
	for (int i = 0;i < b.size();++i) {
		mp[b[i]] = i + 1;
	}
	
	ll cnt = 0;
	for (int i = 0;i < n;++i) {
		ll num = mp[a[i]];
		cnt += i - bit.acum(num);
		bit.add(num, 1ll);
	}
	cout << cnt << endl;
	return 0;	
}


Measured memory_bytes: 19960
#include <stdio.h>

int main(){
	double a,b,c,d,e,f,A;
	double x,y;
	double AA[2][2];

	for(;scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) == 6;){
		A = a*e-b*d;
		AA[0][0] = e/A;
		AA[0][1] = -b/A;
		AA[1][0] = -d/A;
		AA[1][1] = a/A;
		x = c*AA[0][0]+f*AA[0][1];
		y = c*AA[1][0]+f*AA[1][1];
		printf("%.3f %.3f\n",x,y);
	}

	return 0;
}

Measured memory_bytes: 652
import heapq
n = int(input())
a = list(map(int,input().split()))

FN = []
SN = []
for i in range(n):
    FN.append(a[i])
for i in range(2*n,3*n):
    SN.append(-a[i])
heapq.heapify(FN)
heapq.heapify(SN)


sumFN = [0]*(n+1)
sumSN = [0]*(n+1)
sumFN[0] = sum(FN)
sumSN[n] = -sum(SN)

for i in range(1,n+1):
    k = 0
    k += a[n-1+i]
    heapq.heappush(FN,a[n-1+i])
    k -= heapq.heappop(FN)
    sumFN[i] = sumFN[i-1]+k

for i in range(n-1,-1,-1):
    k = 0
    k += a[n+i]
    heapq.heappush(SN,-a[n+i])
    k -= -heapq.heappop(SN)
    sumSN[i] = sumSN[i+1]+k

res = sumFN[0]-sumSN[0]
for i in range(n+1):
    res = max(res,sumFN[i]-sumSN[i])
print(res)


Measured memory_bytes: 37212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    int n;
    cin >> n;
    map<string, int> c;
    int mx = 0;
    rep(i, n) {
        string s;
        cin >> s;
        c[s]++;
        chmax(mx, c[s]);
    }
    for(auto s : c)
        if(s.second == mx) cout << s.first << endl;
}

Measured memory_bytes: 25216
<?php
$n = (int)trim(fgets(STDIN));
$s = trim(fgets(STDIN));
$map = [];


$csum = [
	0 => [],
	1 => [],
	2 => [],
	3 => [],
	4 => [],
	5 => [],
	6 => [],
	7 => [],
	8 => [],
	9 => [],
];

for ($i=0; $i < $n; $i++) { 
	$char = $s[$i];
	foreach ($csum as $num => &$array) {
		if ($i === 0) {
			$array[$i] = 0;
		}else{
			$array[$i] = $array[$i-1];
		}
	}
	$csum[$char][$i] += 1;
}

// $sum = 0;
//2文字目固定
for ($i=1; $i < $n-1; $i++) { 
	//1文字目の選択肢
	foreach ($csum as $num1 => $array1) {
		//3文字目の選択肢
		foreach ($csum as $num2 => $array2) {
			if (isset($map[$num1][$s[$i]][$num2])) {
				continue;
			}

			if ($array1[$i-1] > 0 && $array2[$n-1] - $array2[$i] > 0) {
				// $sum += $array1[$i-1] * ($array2[$n-1] - $array2[$i]);
				$map[$num1][$s[$i]][$num2] = 1;
			}
		}
	}
}
$sum = 0;
foreach ($map as $first => $seconds) {
	foreach ($seconds as $second => $thirds) {
		$sum += count($thirds);
	}
}
// var_dump($map);
echo $sum;

//1文字目
// for ($i=0; $i < $n-2; $i++) { 
// 	//2文字目
// 	for ($j=$i+1; $j < $n-1; $j++) { 
// 		// 1-2桁目の組み合わせが出現済みならスキップ
// 		if (isset($map[$s[$i] . $s[$j]])) {
// 			continue;
// 		}
// 		//3文字目の選択肢はいくつあるか？
// 		$selectable = 0;
// 		foreach ($csum as $num => $array) {
// 			if ($array[$n] - $array[$j] > 0) {
// 				$selectable += 1;
// 			}
// 		}
// 		$map[$s[$i] . $s[$j]] = $selectable;
// 	}
// }
// //ksort($map);
// //var_dump($map);
// $sum = 0;
// foreach ($map as $k => $v) {
// 	$sum += $v;
// }
// echo $sum;



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

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int x,a,b;
int main() {
	cin>>x>>a>>b;
	if(abs(x-a)>abs(x-b))cout<<"B"<<endl;
	else cout<<"A"<<endl;
	return 0;
}


Measured memory_bytes: 256
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n,c,k = readline() |> split |> parseMap
	count = 0
	lmt = 0
	cap = 0
	t = Array{Int}(n)
	for i in 1:n
		t[i] = readline() |> parseInt
	end
	t = sort(t)
	for i in 1:n
		if t[i]>lmt || cap >= c
			count += 1
			lmt = t[i]+k
			cap = 0
		end
		cap += 1
	end
	println(count)
end
main()

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

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;

  int ans = a * b;

  if (ans % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
  
}

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

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)

//repetition
//------------------------------------------
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T> ostream & operator<<(ostream& os, vector<T> const& v){
        for(auto it=v.begin(); it!=v.end(); ++it){
            os << *it << (it+1==v.end() ? "" : ",");
        }
        return os;
    }
}

//clear memory
#define clr(a) memset((a), 0 ,sizeof(a))
 
int lcm(int a,int b){
   return a*b/__gcd(a,b);
}
 
bool prime_number(int n){
   if(n==0||n==1) return false;
   vb a(n+1);
   fill(all(a),true);
   loop(i,2,n/2+1){
      if(!a[i]) continue;
      for(int j=2;i*j<=n;j++){
         a[i*j]=false;
      }
   }
   return a[n];
}

int main(){
   int a,b;
   while(cin>> a >> b){
      cout << __gcd(a,b) << endl;
   }
}

Measured memory_bytes: 1160
s = input()
t = input()
enco = {}
enco2 = {}
for i in range(len(s)):
  if t[i] not in enco:
    enco[t[i]] = s[i]
  else:
    if enco[t[i]] != s[i]:
      print("No")
      exit()
  if s[i] not in enco2:
    enco2[s[i]] = t[i]
  else:
    if enco2[s[i]] != t[i]:
      print("No")
      exit()
print("Yes")

Measured memory_bytes: 3760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1_7_B
{
    class Program
    {
        static void Main(string[] args)
        {
            //1からnまでの数の中から重複なしで3つを選び、それらの合計がxとなる組み合わせの数を求める
            //n,xがともに0：入力終了
            ////////////////////////////////////////////////////////////////////////////////////////

            while (true)
            {
                int count = 0;                  //組み合わせの数をカウントする変数
                string[] str = Console.ReadLine().Split(' ');
                int n = int.Parse(str[0]);
                int x = int.Parse(str[1]);

                int a;
                int b;
                int c;

                if (n == 0 && x == 0)
                {
                    break;
                }

                else
                {
                    for (a = 1; a <= n; a++)
                    {
                        for (b = a + 1; b <= n; b++)
                        {
                            for (c = b + 1; c <= n; c++)
                            {
                                if (a != b && b != c && c != a && a + b + c == x)
                                {
                                    count++;
                                }
                            }
                        }
                    }

                }
                Console.WriteLine((count).ToString());
            }

        }
    }
}





Measured memory_bytes: 15932
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<string.h>
#include<limits.h>
#define int long long
using namespace std;

int mincost[1000][1000];
signed main() {
	int a, b; scanf("%lld%lld", &a, &b);
	for (int c = 0; c < a; c++) {
		for (int d = 0; d < a; d++) {
			mincost[c][d] = LLONG_MAX;
		}
		mincost[c][c] = 0;
	}
	for (int c = 0; c < b; c++) {
		int d, e, f; scanf("%lld%lld%lld", &d, &e, &f);
		mincost[d - 1][e - 1] = -f;
	}
	for (int x = 0; x < a; x++) {
		for (int y = 0; y < a; y++) {
			for (int z = 0; z < a; z++) {
				if (mincost[y][x] != LLONG_MAX&& mincost[x][z] != LLONG_MAX) {
					mincost[y][z] = min(mincost[y][z], mincost[y][x] + mincost[x][z]);
				}
			}
		}
	}
	for (int i = 0; i < a; i++) {
		if (mincost[i][i] < 0 &&mincost[0][i]!=LLONG_MAX&& mincost[i][a - 1] != LLONG_MAX) {
			puts("inf");
			return 0;
		}
	}
	printf("%lld\n", -mincost[0][a - 1]);
}

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

int main() {
  int a,b;

  cin >> a >> b;

  if (a - 2 * b > 0) {
    cout << a - 2 * b;
  } else {
    cout << 0;
  }

  return 0;
 }


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

#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int maxn = 3e5 + 100;
const ll inf = 1e18;
ll a[maxn], dp[maxn], pd[maxn];

int main () {
	ios::sync_with_stdio(false);
	memset (dp, -63, sizeof dp);
	memset (pd, 63, sizeof dp);
	int n;
	cin >> n;
	for (int i = 0; i < 3 * n; i++)
		cin >> a[i];
	ll sum = 0;
	multiset <int> s;
	for (int i = 0; i < 3 * n; i++) {
		sum += a[i];
		s.insert (a[i]);
		if (s.size() > n) {
			sum -= *s.begin();
			s.erase (s.begin());
		}
		if (s.size() == n) {
			dp[i] = sum;
		}
	}
	s.clear();
	sum = 0;
	for (int i = 3 * n - 1; i >= 0; i--) {
		sum += a[i];
		s.insert (-a[i]);
		if (s.size() > n) {
			sum -= -(*s.begin());
			s.erase (s.begin());
		}
		if (s.size() == n) {
			pd[i] = sum;
		}
	}
	ll ans = -inf;
	for (int i = 0; i < 3 * n; i++)
		ans = max (ans, dp[i] - pd[i + 1]);
	cout << ans << endl;
}


Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  int s=3;
  rep(i,n){
    s=1+s*2;
  }

  cout<<s-1<<endl;


}

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

using namespace std;

static const int MAX = 1000;
static const int VMAX = 10000;

static int n, A[MAX], s;
static int B[MAX], T[VMAX + 1];

static int solve()
{
    int ans = 0;
    
    bool V[MAX];
    for (int i = 0; i < n; i++) {
        B[i] = A[i];
        V[i] = false;
    }
    
    sort(B, B + n);
    
    for (int i = 0; i < n; i++) {
        T[B[i]] = i;
    }
    
    for (int i = 0; i < n; i++) {
        if (V[i])
            continue;
        int cur = i;
        int S = 0;
        int m = VMAX;
        int count = 0;
        while (true) {
            V[cur] = true;
            count++;
            int v = A[cur];
            m = min(m, v);
            S += v;
            cur = T[v];
            if (V[cur])
                break;
        }
        ans += min(S + (count - 2) * m, m + S + (count + 1) * s);
    }
    
    return ans;
}

int main()
{
    cin >> n;
    s = VMAX;
    
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        s = min(s, A[i]);
    }
    
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 3180
#include <stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHETE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

void dijkstra() {
	int d[MAX], color[MAX];
	int i, v;

	for ( i = 0; i < n; i++) {
		d[i] = INFTY;
		color[i] = WHETE;
	}

	d[0] = 0;
	color[0] = GRAY;
	while ( 1 ) {
		int u = -1;
		int minv = INFTY;
		for ( i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if ( u == -1) break;
		color[u] = BLACK;
		for ( v = 0; v < n;v++) {
			if (color[v] != BLACK && M[u][v] != INFTY) {
				if (d[v] > d[u] + M[u][v]) {
					d[v] = d[u] + M[u][v];
					color[v] = GRAY;
				}
			}
		}
	}
	for ( i = 0; i < n; i++) {
		printf("%d %d\n", i, d[i] == INFTY ? -1: d[i]);
	}
}

int main() {
	int i, j;
	int k, c, u, v;

	scanf("%d",&n);
	for ( i = 0; i < n; i++) {
		for ( j = 0; j < n; j++) {
			M[i][j] = INFTY;
		}
	}

	for ( i = 0; i < n; i++) {
		scanf("%d%d", &u, &k);
		for ( j = 0; j < k; j++) {
			scanf("%d%d", &v, &c);
			M[u][v] = c;
		}
	}

	dijkstra();

	return 0;
}


Measured memory_bytes: 2084
n, m, x, y = map(int, input().split())
xn = [int(num) for num in input().split()]
yn = [int(num) for num in input().split()]

xn.append(x)
yn.append(y)
xn.sort(reverse=True)
yn.sort()
if xn[0] < yn[0]:
  print("No War")
else :
  print("War")


Measured memory_bytes: 9156
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")
    };
}

use std::cmp::max;

fn main() {
    input!{
        n: usize,
        a: usize,
        b: usize,
        v: [usize; n]
    }
    let mut c: Vec<usize> = vec![0; 3];
    for i in 0..n {
        if v[i] > b {
            c[2] += 1;
        } else if v[i] > a {
            c[1] += 1;
        } else {
            c[0] += 1;
        }
    }
    println!("{}", *c.iter().min().unwrap());
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <limits>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    string s, t;
    cin >> s;
    cin >> t;

    if (s.length() + 1 == t.length())
    {
        for (ll i = 0; i < s.length(); i++)
        {
            if (s[i] != t[i])
            {
                printf("No");
                return 0;
            }
        }

        printf("Yes");
        return 0;
    }

    printf("No");
}


Measured memory_bytes: 3688