akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;


int main(){
    int n, k;
    int a = 1;
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        if(a + k < 2 * a) a += k;
        else a *= 2;
    }
    cout << a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

int d[6][2] = {{1, 2}, {-1, 3}, {1, -1}, {4, 5}, {5, 2}, {2, 1}};

signed main(){
    string s;
    while(1){
        cin >> s;
        if(s == "#") break;
        int now = 0;
        rep(i, 0, s.size()){
            now = d[now][s[i] - '0'];
            if(now == -1) break;
        }
        cout << (now != 5 ? "No" : "Yes") << endl;
    }
}

Measured memory_bytes: 1180
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,target=1;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  rep(i,n) scanf("%d",&a[i]);
  
  rep(i,n){
    if(a[i]==target){
      target++;
    }else{
      result++;
    }
  }
  if(target==1) result=-1;
  printf("%lld",result);
  return 0;
}

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

int main() {
    int a, b;
    cin>>a >>b;
    if(b==1){
        cout<<0<<endl;
        return 0;
    }
    if(a>=b){
        cout<<1<<endl;
        return 0;
    }
    for(int i=2;i<b;i++){
        if(a*i-(i-1)>=b){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#define mod 1000000007
using namespace std;
long long a[100010],ab[100010],abc[100010],o[100010];
int main(){
	string s;
	cin >> s;
	int i;
	a[0] = 0; ab[0] = 0; abc[0] =0;o[0]=1;
	for(i=0;i<s.size();i++){
		if(s[i]=='A'){
			a[i+1] = (a[i]+o[i])%mod;
			o[i+1] = o[i]%mod;
			ab[i+1] = ab[i]%mod;
			abc[i+1] = abc[i]%mod;
		}
		if(s[i]=='B'){
			ab[i+1] = a[i]+ab[i]%mod;
			o[i+1] = o[i]%mod;
			a[i+1] = a[i]%mod;
			abc[i+1] = abc[i]%mod;
		}
		if(s[i]=='C'){
			abc[i+1] = (ab[i]+abc[i])%mod;
			o[i+1] = o[i]%mod;
			a[i+1] = a[i]%mod;
			ab[i+1] = ab[i]%mod;
		}
		if(s[i]=='?'){
			o[i+1] = 3*o[i]%mod;
			a[i+1] = (3*a[i]+o[i])%mod;
			ab[i+1] = (3*ab[i]+a[i])%mod;
			abc[i+1] = (3*abc[i]+ab[i])%mod;
		}
	}
	for(i=0;i<=s.size();i++){
		//cout << i << " " << o[i] <<" " << a[i] << " " << ab[i] << " " << abc[i] << endl;
	}
	cout << abc[s.size()] << endl;;
}
	

Measured memory_bytes: 3584
n = int(input())
ls_a = list(map(int, input().split()))
ls_b = list(map(int, input().split()))
ls_c = list(map(int, input().split()))

s = ls_b[ls_a[0]-1]

for i in range(1, n):
    s += ls_b[ls_a[i]-1]
    if ls_a[i] == ls_a[i-1] + 1:
        s += ls_c[ls_a[i-1]-1]
print(s)

Measured memory_bytes: 3064
N = int(input())
A = [int(x) for x in input().split()]

def gcd(p,q):
    if q == 0:
        return p
    else:
        return gcd(q,min(p%q,q-p%q))

if N != 1:
    lcm = 1
    for i in range(N-1):
        if i == 0:
            lcm = A[0]*A[1]//gcd(A[0],A[1])
        else:
            lcm = lcm*A[i+1]//gcd(lcm,A[i+1])

    ans = 0
    for i in range(N):
        ans += lcm//A[i]

    print(ans%(10**9+7))

else:
    print(1)

Measured memory_bytes: 76424
#include <iostream>
#include <vector>
using namespace std;
int main(){
	while(true){
		int a;
		vector<int> b;
		cin >> a;
		if(a==-1) break;
		if(a==0){
			cout << 0 << endl;
			continue;
		}
		while(a>0){
			b.push_back(a%4);
			a/=4;
		}
		for(int i=b.size()-1;i>=0;i--){
			cout << b[i];
		}
		cout << endl;
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 998244353;

class mint
{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(::std::int_fast64_t _n):n(_n<0 ? MOD-(-_n)%MOD : _n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    mint operator==(const mint &m) const {return n==m.n;}
    mint operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,s; cin>>n>>s;
    vi a(n);
    rep(i,n) cin>>a[i];
    vector<vector<mint> > dp(n+1, vector<mint>(s+1,0));
    rep(i,n) dp[i][0] = 1;
    rep(i,n)rep(j,s+1){
        dp[i+1][j] += dp[i][j];
        if (j>=a[i]) dp[i+1][j] += dp[i][j-a[i]];
    }
    mint ans=0;
    rep(i,n+1)
        ans+=dp[i][s];
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 70784
while line = gets
  h, w = line.split(' ').map(&:to_i)
  break if h == 0 && w == 0
  odd = (w / 2).times.map{"#."}.join
  odd = odd + "#" if w.odd?
  even = (w / 2).times.map{".#"}.join
  even = even + "." if w.odd?
  (h / 2).times.each do
    puts odd
    puts even
  end
  puts odd if h.odd?
  puts ""
end


Measured memory_bytes: 6880
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	string s;
	cin>>s;
	if(s=="Sunny"){
		cout<<"Cloudy";
	}
	else if(s=="Cloudy"){
		cout<<"Rainy";
	}
	else{
		cout<<"Sunny";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	int a[3],ans=0;
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	for(int i=0;i<2;i++){
	    while(a[i]+2<=a[2]){
	        a[i]+=2;
	        ans++;
	    }
	}
	sort(a,a+3);
	//cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<ans<<endl;
	
	if(a[0]==a[1] && a[0]==a[2])ans+=0;
	else if(a[0]==a[1])ans++;
	else if(a[1]==a[2])ans+=2;
	cout<<ans<<endl;
	
}

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

using namespace std;

long long int H, W;
int N;
int r[3030], c[3030];
vector<pair<int, int> > V;
long long int dp[3030];

long long int MOD = 1000000007;

long long int P[200005], inv_P[200005];

long long int POW(long long int a, long long int k) {
	if (k == 0) {return 1;}
	else if (k == 1) { return a; }

	if (k % 2 == 1) { return (POW(a, k - 1)*a) % MOD; }

	long long int ret = POW(a, k / 2);
	return (ret*ret) % MOD;
}

long long int INV(long long int a) {
	return POW(a, MOD - 2);
}

long long int C(long long int n, long long int m) {
	long long int ret = P[n];
	
	ret *= inv_P[m]; ret %= MOD;
	
	ret *= inv_P[n - m]; ret %= MOD;
	
	return ret;
}

int main(void) {

	cin >> H >> W >> N;

	for (int i = 1; i <= N; i++) {
		cin >> r[i] >> c[i];
		V.push_back(make_pair(r[i], c[i]));
		}
	V.push_back(make_pair(H, W));

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

	//=====================
	P[0] = 1;
	P[1] = 1;
	for (long long int i = 2; i <= 200000; i++) {
		P[i] = (P[i - 1] * i) % MOD;
	}
	for (int i = 0; i <= 200000; i++) {
		inv_P[i] = INV(P[i]);
	}


	//===============

	for (int i = 0; i <= N; i++) {

		int a = V[i].first;
		int b = V[i].second;
		long long int num = 0;
		num = C(a - 1 + b - 1, a - 1);// cout << "num= " << num << endl;

		for (int j = 0; j <= N; j++) {
			int u = V[j].first;
			int v = V[j].second;
			if (u<= a && v <= b) {
				long long int tmp = (C(a - u + b - v, a - u)*dp[j]) % MOD;
				num =num- tmp+MOD;
				num %= MOD;
			}
		}

		dp[i] = num;
	}
	
	cout << dp[N] << endl;


	

	return 0;
}

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

int main()
{
  char n[4];
  cin >> n;
  if(n[0] == '7' || n[1] == '7' || n[2] == '7'){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fst first
#define snd second
#define fore(x,a,b) for(int x=(a), qwerty=(b); x<qwerty; x++)
#define pb push_back
#define mset(a,v) memset((a),(v),sizeof(a))
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const int N=3000;
int n;
double p[N],dp[N][N],EPS=1e-9;

double solve(int i,int j) {
	if(i==n)return (j>n-j);
	if(dp[i][j]>0-EPS)return dp[i][j];
	double r=p[i]*solve(i+1,j+1)+(1-p[i])*solve(i+1,j);
	dp[i][j]=r;
	//cout<<i<<" "<<j<<" : "<<r<<endl;
	return r;
}

int main(){FIN;
	mset(dp,-1);
	cin>>n;
	fore(i,0,n)cin>>p[i];
	cout<<setprecision(15)<<		solve(0,0)<<endl;
}	

Measured memory_bytes: 70784
#include <stdio.h>

int main()
{

 int cards[4][13] = {0}, n, i, j, a;
 char c;

 scanf("%d\n", &n);

 for(i = 0; i < n; i++)
 {
     scanf("%c %d\n", &c, &a);
     if(c == 'S')
     {
         cards[0][a - 1] = 1;
     }
     else if(c == 'H')
     {
         cards[1][a - 1] = 1;
     }
     else if(c == 'C')
     {
         cards[2][a - 1] = 1;
     }
     else if(c == 'D')
     {
         cards[3][a - 1] = 1;
     }
 }

 for(i = 0; i < 4; i++)
 {
     for(j = 0; j < 13; j++)
     {
         if(cards[i][j] == 0)
         {
             if(i == 0)
             {
                 printf("S %d\n", j + 1);
             }
             else if(i == 1)
             {
                 printf("H %d\n", j + 1);
             }
             else if(i == 2)
             {
                 printf("C %d\n", j + 1);
             }
             else if(i == 3)
             {
                 printf("D %d\n", j + 1);
             }
         }
     }
 }

 return 0;

}

Measured memory_bytes: 600
// Problem : S - Digit Sum
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_s
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 10005

//Solution

int n;
string s;
int d;
int dp[N][102][2];

int f(int i, int cur, int p){
    if(i == n){
        if(cur == 0) return 1;
        return 0;
    }
    int &ret = dp[i][cur][p];
    if(~ret) return ret;
    int cap = (p == 1 ? (s[i]-'0') : 9);
    ret = 0;
    for(int k=0;k<=cap;k++){
        if(p == 1 && k == cap) (ret += f(i+1,(cur+k)%d,1)) %= mod;
        else (ret += f(i+1,(cur+k)%d,0)) %= mod;
    }
    return ret;
}

void solve(){
    cin>>s>>d;
    n = sz(s);
    memset(dp,-1,sizeof(dp));
    cout<<(f(0,0,1)-1+mod)%mod<<'\n';
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 20548
#include <cstdlib>
#include <iostream>
#include <string>
#include <valarray>
#include <vector>

using namespace std;

//マクロ
#define REP(i, n) for(int i = 0;i < n;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 999999999

/*
 * 
 */

//ARC061
int main() {
    string s;
    cin >> s;
    long ans = 0;
    int n = s.size() - 1;
    for (int bit = 0; bit < (1<<n); ++bit){
        int start = 0;
        REP(i, n){
            if (bit & (1<<i)){
                ans += stol(s.substr(start, i-start+1));
                start = i+1;
            }
        }
        ans += stol(s.substr(start));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, k = [int(_) for _ in input().split(' ')]
if b + 1 - a < 2 * k:
    for x in range(a, b + 1):
        print(x)
else:
    for x in range(a, a + k):
        print(x)
    for x in range(b + 1 - k ,b + 1):
        print(x)


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

int main()
{
  string a,b;
  cin>>a;
  cin>>b;
  int m = a.length(),n=b.length();
  int ans = INT_MAX;
  for(int i=0;i<m-n+1;i++)
  {
    int mi = 0;
    for(int j=0;j<n;j++)
    {
      if(b[j]!=a[i+j])
      {
        mi++;
      }
    }
    ans = min(mi,ans);
  }
  cout<<ans;
}

Measured memory_bytes: 3600
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;

ll yakusuu(int k){
  ll ans = 0L;
  int i;
  for(i=1; i*i<k; ++i){
    if(k%i==0) {
      ans+=2;
    }
  }
  if(i*i==k) ++ans;

  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  ll ans = 0L;
  int a,b;
  a = 1; b = n-1;

  while(a < b){
    ans += yakusuu(a);
    ans += yakusuu(b);
    ++a; --b;
  }
  if(a==b)ans += yakusuu(a);

  cout << ans << endl;

  return 0;
}


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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


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

    println((abs(a - x) > abs(b - x) ? "B" : "A"));
}

Measured memory_bytes: 3636
//compiledef
#include <bits/stdc++.h>
#define rep(i, n) for(i=0;i<(n);i++)
#define repx(i, n, x) for(i=(x);i<(n);i++)
//c++def
using namespace std;

void countingsort(short *a, short *b, int k, int n){
	int i;
	int j;
	int c[10240];
	rep(i, k+1) c[i] = 0;
	for(j=1; j<=n;j++) c[a[j]]++;

	for(i=1; i<=k;i++) c[i] += c[i-1];

	for(j=n; j>=1;j--){
		b[c[a[j]]] = a[j];
		c[a[j]]--;
	}
}

int main(){
	int n;
	int i;
	cin >> n;
	short a[n+2];
	short b[n+2];
	int max = -1;
	repx(i, n+1, 1){
		scanf("%hd",&a[i]);
		if(max <= a[i]) max = a[i];
	}
	countingsort(a, b, max, n);
	repx(i, n+1, 1){
		if(i!=1) printf(" ");
		printf("%hd", b[i]);
		if(i==n) printf("\n");
	}
}



Measured memory_bytes: 11056
#include <stdio.h>
#include <iostream>

using namespace std;

long long a, b;

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

long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}

int main(void) {
    while(cin >> a >> b) {
        cout << gcd(a, b) << " " << lcm(a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<string.h>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;


int main()
{
    const int i_max = 200000;
    int n, k;
    vector<int> a(i_max, 0);
    cin >> n >> k;
    rep(i, n)
    {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }
    sort(a.begin(), a.end());
    int z_end;
    rep(i, i_max)
    {
        if (a[i] != 0)
        {
            z_end = i;
            break;
        }
    }
    int n_size = i_max - z_end;
    int ans = 0;
    rep(i, n_size - k)
    {
        ans += a[z_end + i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream> 
#include <climits>
#define ll long long
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n, d=0, maxi=0, mini=INT_MAX, jumax=0, jumin=0;
    int diff[100005];
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> diff[i];
        if(maxi<diff[i]){
            maxi=diff[i];
        }
        if(mini>diff[i]){
            mini=diff[i];
        }
    }
    if(maxi==mini){
        if(maxi==n-1 || 2*maxi<=n)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if(maxi==mini+1){
        int freqMin=0, freqMax=0;
        for(int i=1; i<=n; i++){
            if(diff[i]==mini){
                freqMin++;
            }
            else{
                freqMax++;
            }
        }
        if(freqMin+1<=maxi && maxi <= freqMin+freqMax/2)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    for (int i = N; i <= 999; i++) {
        int a = i / 100;
        int ii = i % 100;
        int b = ii / 10;
        int c = ii % 10;
        if (a == b && b == c) {
            cout << i << endl;
            return 0;
        }
    }
}

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

int abs(int i, int j) {
  if (i - j > 0) {
    return i - j;
  } else {
    return j - i;
  }
}
int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  vector<int> cost(N);
  rep(i, N) { cin >> h.at(i); }
  cost.at(1) = abs(h.at(0), h.at(1));
  for (int i = 2; i < N; i++) {
    cost.at(i) = min(cost.at(i - 2) + abs(h.at(i - 2), h.at(i)),
                     cost.at(i - 1) + abs(h.at(i - 1), h.at(i)));
  }
  cout << cost.at(N - 1) << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
int main(){
  int x,n;
  int con=1000,ans=0;
  scanf("%d %d", &x,&n);
  if(n==0){
    printf("%d", x);
  }else{
    int p[n];
    for(int k=0;k<n;k++){
      scanf("%d", &p[k]);
    }
    int count=0,count1=0;
    for(int i=0;i<=101;i++){
      for(int j=0;j<n;j++){
        if((x-i)!=p[j]){
          //printf("%d %d\n", p[j], x-i);
          count++;
        }
        if((x+i)!=p[j]){
          count1++;
        }
      }
      //printf("%d %d\n", count, count1);
      if(count==n||count1==n){
        if(count==n&&count1==n){
          ans = x-i;
          break;
        }
        else if(count==n){
          ans = x-i;
          break;
        }else{
          ans = x + i;
          break;
        }
      }
      count = 0;count1 = 0;
    }
    printf("%d", ans);
  }
  return 0;
}

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


int main(){
	int n;
	scanf("%d", &n);
	
	int arr[n];
	for (int i=0; i<n; i++) scanf("%d", &arr[i]);
	
	sort(arr, arr+n);
	
	long long res=0;
	
	for (int i=0; i<n; i++){
		for (int j=i+1; j<n; j++){
			int comp=arr[i]+arr[j];
			int l=j+1;
			int r=n-1;
			int par=j;
			while(l<=r){
				int mid=(l+r)/2;
				if (arr[mid]<comp){
					par=mid;
					l=mid+1;
				}
				else r=mid-1;
			}
			
			res+=par-j;
			
		}
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 256
# Enter your code here. Read input from STDIN. Print output to STDOUT

import numpy as np
from sys import stdin


def get_result(data):
    N, K = data[0]
    H = sorted(data[1])
    return 0 if N <= K else sum(H[0:(N-K)])

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


Measured memory_bytes: 36356
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    vi cnt(5);
    rep(i, 3) {
        int a, b;
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }
    sort(all(cnt));
    string yes = "YES", no = "NO";
    cout << (cnt == vi{0, 1, 1, 2, 2} ? yes : no) << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<(a==b and b==c?"Yes":"No")<<endl;
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


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


int main() {
  long long L, R;
  long long min_i = 2019, min_j = 2019;
  cin >> L >> R;

  long long ans = 2019;
  if (R - L <= 2020) { 
    for (long long i=L; i < R; i ++) {
      for (long long j=i + 1; j <= R; j ++) {
        // cout << i * j << " " << i << " * " << j << " = " << i * j % 2019 << endl;
        ans = min(i * j % 2019, ans);
      }
    }
  } else {
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {

    string S;

    cin >> S ;

    long ans = 0;

    // ビットの全組み合わせループ
    for (int tmp = 0; tmp < (1 << (S.size() - 1)); tmp++) {

        //ビット表現(0000)
        bitset<10> s(tmp);
        //cout << s << "  -------"<<endl;

        long sum = 0;
        string sum_str;
        for (long i = 0; i < S.size(); i++) {
            sum_str += S[i];
            //cout << sum_str << endl;
            if (s.test(i)) {
                //cout << "sum 1 ! " << sum_str << endl;
                sum += stoll(sum_str.c_str());
                sum_str = "";
            }
        }
        //cout << "sum 2 ! " << sum_str <<  endl;
        sum += stoll(sum_str.c_str());
        //cout << "sum: "<< sum << endl;

        ans += sum;

        //cout << "ans: " << ans << endl;
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

int GCD(int x, int y){
    while (1){
        int t = x;
        if (x < y){
            x = y;
            y = t;
        }

        if (y == 0){
            break;
        }
        x %= y;
    }
    return x;
}

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

    int g = GCD(A, B);

    long v = (long)A * (long)B / (long)g;
    
    cout << v << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    int y, m, d;
    char c1, c2;
    cin >> y >> c1 >> m >> c2 >> d;
    string ans = (m >= 5)
                 ?"TBD"
                 :"Heisei";
    co(ans);
    return 0;
}

Measured memory_bytes: 256
from fractions import Fraction
import math

N = int(input())
TA = [tuple(map(int, input().split())) for _ in range(N)]


"""

・Ti, Ai を i回目の二人の得票数の比
・Pti, Pai をi回目の二人の得票数とすると、

Pti : Pai = Ti : Ai なので、　Pti = M * Ti, Pai = M * Ai (M=1,2,3,...)と表せる。

とあらわせる。ここで、
Pti-1 <= Pti
Pai-1 <= Pai
なので、Mは
M >= Pti-1 / Ti
M >= Pai-1 / Ai
の両方を満たすものになり、得票数を最小に保つにはMもなるべく小さくとる
"""
t,a = 0,0
for i in range(N):
    if i == 0:
        t,a = TA[i][0], TA[i][1]

    else:
        M = math.ceil(max(Fraction(t , TA[i][0]), Fraction(a , TA[i][1])))
        t = M * TA[i][0]
        a = M * TA[i][1]


print(t+a)

Measured memory_bytes: 5472
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    s = list(input()[:-1].decode())
    r = []
    g = []
    b = [0] * n
    len_b = 0
    for i in range(n):
        if s[i] == 'R':
            r.append(i)
        elif s[i] == 'G':
            g.append(i)
        elif s[i] == 'B':
            b[i] = 1
            len_b += 1
    ans = len(r) * len(g) * len_b

    def check(i):
        return 0 <= i < n and b[i] == 1

    for ri in r:
        for gi in g:
            if check(2 * gi - ri):
                ans -= 1
            if check(2 * ri - gi):
                ans -= 1
            if (ri + gi) % 2 == 0 and check((ri + gi) // 2):
                ans -= 1
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

#define PI acos(-1.0)

struct point{
  ll x,y,idx;
  long double arg;
};

ll n;
vector<point> ps;

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

  cin>>n;
  rep(i,n){
    ll x,y;
    cin>>x>>y;
    if(x==0&&y==0)continue;
    ps.push_back((point){x,y,i,atan2(y,x)});
    ps.push_back((point){x,y,i,atan2(y,x)+2.0*PI});
  }
  n=ps.size()/2;

  sort(all(ps),[](const point& a,const point& b){
    if(abs(a.arg-b.arg)<1e-9) return a.idx < b.idx;
    else return a.arg < b.arg;
  });

  long double res=0;
  rep(i,2*n)repl(j,i+1,2*n+1){
    vector<bool> used(n,false);
    bool dame=false;
    ll X=0,Y=0;
    repl(k,i,j){
      if(used[ps[k].idx]){
        dame=true;
        break;
      }
      used[ps[k].idx]=true;
      X+=ps[k].x;
      Y+=ps[k].y;
    }
    if(dame)continue;
    maxch(res,(long double)sqrt((long double)X*X+(long double)Y*Y));
  }
  printf("%.12Lf\n", res);

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
int n;
int a[maxn];
vector<long long> s(maxn,0);
vector<long long> x(maxn,0);
long long ans=0;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		s[i+1]=s[i]+a[i];
		x[i+1]=x[i]^a[i];
	}
	int l=1;
	for(int r=1;r<=n;r++)
	{
		for(;(s[r]-s[l-1])!=(x[r]^x[l-1]);l++);
		ans+=(long long)(r-l+1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4096
import java.util.Scanner;
import java.lang.Math;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double a = Double.parseDouble(scan.next());
		double b = Double.parseDouble(scan.next());
		double c = Double.parseDouble(scan.next());
		c=Math.toRadians(c);
		scan.close();
		System.out.println(String.format("%6f\n%6f\n%6f\n"
				,0.5*a*b*Math.sin(c),a+b+Math.sqrt(a*a+b*b-2*a*b*Math.cos(c)),b*Math.sin(c)));
		}
}

Measured memory_bytes: 17148
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

    vector <ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i*i != N) ret.push_back(N/i);
        }
    }
    //sort(ALL(ret));
    ll best = 0;
    REP(i, ret.size()){
        //cout << ret[i] << " ";
        ll f = N/ret[i] + ret[i];
        if (i==0) {
            best = f;
        } else if (f < best) {
            best = f;
        }
    }
    cout << best-2 << endl;
    return 0;
}



Measured memory_bytes: 384
/*program by mangoyang*/
#include<bits/stdc++.h>
#define inf (0x7f7f7f7f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
    int f = 0, ch = 0; x = 0;
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    if(f) x = -x;
}
char s[3000005];
int main(){
	scanf("%s", s); int n = strlen(s);
	int w; read(w); int tot = w;
	for(int i = 0; i < n; i++){
		if(tot == w) putchar(s[i]), tot = 0;
		tot++;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;


int main(void){
	ios::sync_with_stdio(false);
	int N, A, B;
	cin >> N >> A >> B;
	if (N*A >= B) {
		cout << B;
	}
	else {
		cout << N * A;
	}
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        ll: [u32;n]
    }
    let mut ll = ll;
    ll.sort();
    ll.reverse();
    if ll.iter().skip(1).sum::<u32>() > ll[0] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define ll long long
using namespace std;
int a[100005],sum[100005];
int main() {
	int n; ll ans=0;
	cin>>n;
	rep(i,1,n) {
		cin>>a[i];
		if(a[i]>100000)continue;
		sum[a[i]]++;
	}
	rep(i,1,n) {
		if(sum[i]>=i)ans+=i;
	}
	cout<<n-ans;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;





int main() {
    int n; cin >> n;
    int a=0,b=0,c=0,d=0;
    for(int i = 0;i < n;i++){
        string x; cin >> x;
        if(x == "AC") a++;
        if(x == "WA") b++;
        if(x == "TLE") c++;
        if(x == "RE") d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;;
    cout << "TLE x " << c << endl;;
    cout << "RE x " << d << endl;;
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define pi 3.141592654

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vi> vvi;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    cin >> a >> b;
    int ans = 1;
    ll n = gcd(a, b);
    for (int i = 2; (ll) i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0) n /= i;
            ans++;
        }
    }
    if (n > 1) ans++;
    cout << ans << '\n';
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    vec[i] = num;
  }
  sort(vec.begin(), vec.end());
  if(vec[n / 2] == vec[n / 2 - 1]){
    cout << 0 << endl;
  }else{
    cout << vec[n / 2] - vec[n / 2 - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
using namespace std;
const int maxn=2e5+10;

int n,a[maxn];
long long ans;

void solve(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int l=1,r=1,now=0;l<=n;){
		while(r<=n&&now+a[r]==(now^a[r]))now^=a[r++];
		ans+=r-l,now^=a[l++];
	}
	printf("%lld\n",ans);
}

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

Measured memory_bytes: 1024
class DataSet:
    def __init__(self,x,y):
        self.x = x
        self.y = y

    def swap(self):
        temp = self.y
        self.y = self.x
        self.x = temp

def main():
    data = []
    while 1:
        # ????????????????????????????????????
        n = input().split()
        x = int(n[0])
        y = int(n[1])

        if x == 0 and y == 0:
            break

        data.append(DataSet(x, y))

    length = len(data)
    what_large = length > 3000

    if what_large:
        print("Too Large")
    else:
        for i in range(len(data)):
            d_val = data[i]
            if d_val.x > d_val.y:
                d_val.swap()

            print("{0} {1}".format(d_val.x,d_val.y))

if __name__ == '__main__':
    main()

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i, n)
    {
        cin >> a[i];
        sum += a[i];
    }
    
    int x0 = sum/2;
    for (int i = 1; i < n; i+=2)
        x0 -= a[i];
    
    vector<int> ans(n);
    ans[0] = x0;
    rep(i, n)
    {
        if (i == 0) continue;
        ans[i] = a[i - 1] - ans[i - 1];
    }
    rep(i, n)
        ans[i] *= 2;
    
    rep(i, n)
        cout << ans[i] << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<cstring>
#include<algorithm>

#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define ll long long
using namespace std;

const int M=220,inf=1e8;
const double z=1e-6;

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

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

    if (a * b % 2 == 1 || b * c % 2 == 1 || c * a % 2 == 1)
    cout << "Hom" << endl;
    else cout << "Tem" << endl;

}


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

int main(){
  int x;
  cin >> x;
  if(x<600){
    cout << 8 << endl;
  }else if(x<800){
    cout << 7 << endl;
  }else if(x<1000){
    cout << 6 << endl;
  }else if(x<1200){
    cout << 5 << endl;
  }else if(x<1400){
    cout << 4 << endl;
  }else if(x<1600){
    cout << 3 << endl;
  }else if(x<1800){
    cout << 2 << endl;
  }else if(x<2000){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

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

	double h, max = 0.0, min = 3776.0;
	while (cin >> h)
	{
		if (h > max) max = h;
		if (h < min) min = h;
	}

	cout << max - min << endl;

	return 0;
}

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

void solve() {
	int n; cin >> n;
	vector<pair<int, int> > v(n);
	for (auto &u : v)cin >> u.first >> u.second;
	for (int i = 2; i < n; i++) {
		if (v[i].first == v[i].second && v[i - 1].first == v[i - 1].second && v[i - 2].first == v[i - 2].second) {
			cout << "Yes\n"; return ;
		}
	}
	cout << "No"; return ;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 3608
from collections import Counter, defaultdict
import numpy as np

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

d = Counter(A)
s = sum([k*v for k, v in d.items()])
for _ in range(Q):
  b, c = map(int, input().split())
  if b in d.keys():
    t = d.pop(b)
    if c in d.keys():
      d[c] += t
    else:
      d[c] = t
    s += t*(c-b)
  print(s)

Measured memory_bytes: 38836
import sys
input = sys.stdin.readline

n = int(input())
g = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b, c = [int(x) for x in input().split()]
    g[a - 1].append([c, b - 1])
    g[b - 1].append([c, a - 1])
q, k = [int(x) for x in input().split()]
import heapq
def dijkstra(s):
    # 始点sから各頂点への最短距離
    d = [float('inf')]*n
    d[s] = 0
    # 各頂点が訪問済みかどうか
    used = [False]*n
    used[s] = True
    # 仮の距離を記録するヒープ
    que = []
    for e in g[s]:
        heapq.heappush(que, e)
    while que:
        minedge = heapq.heappop(que)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True
        for e in g[v]:
            if not used[e[1]]:
                heapq.heappush(que, [e[0] + d[v], e[1]])
    return d
d = dijkstra(k - 1)
for _ in range(q):
    x, y = [int(x) for x in input().split()]
    print(d[x - 1] + d[y - 1])


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

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

ll N, K;

struct mint {
  ll x; // typedef long long ll;
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(100005);

mint f2(int x, int y) {
    return comb(x + y - 1, y - 1);
}

mint f(int x, int y) {
    if (x < y) return 0;
    if (x == 0 && y == 0) return 1;
    return f2(x - y, y);
}

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

    for (int i = 1; i <= K; i++) {
        mint blue = f(K, i);
        mint red = 0;
        {
            red += f(N - K, i - 1);
            red += f(N - K, i);
            red += f(N - K, i);
            red += f(N - K, i + 1);
        }

        mint ans = blue * red;
        printf("%lld\n", ans.x);
    }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;

signed main(){
    int n, m; cin >> n >> m;
    vector<int> a(n), b(n+1,0);
    REP(i,n) cin >> a[i];
	sort(all(a));
    RREP(i,n){
        if(i == n-1) b[i] = a[i];
        else b[i] = b[i+1] + a[i];
    }
    auto check = [&](int x){
        int cnt = 0;
        REP(i,n) cnt += a.end()-lower_bound(all(a),x-a[i]);
        return cnt >= m;
    };
    int ok = 0, ng = INF;
    while(ng-ok > 1){
        int mid = (ok+ng)/2;
        if(check(mid)) ok = mid;
        else ng = mid;
    }
    int res = 0;
    int hoge = 0;
    REP(i,n){
        int itr = a.end() - lower_bound(all(a),ok-a[i]);
        res += a[i]*itr + b[n-itr];
        hoge += itr;
    }
    cout << res - (hoge-m) * ok <<'\n';
}

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

int a[20], pos[10];
int n, m, cnt = 0;
int ans = 0, sum = 0;

void dfs(int size, int Sum) {
	if (size == cnt) {
		if ((sum + Sum) % 10 == 0)ans++;
		return;
	}
	rep(i, m) {
		if (pos[size] % 2 == 1)
			dfs(size + 1, Sum + a[i] * 2 % 10 + a[i] * 2 / 10);
		else dfs(size + 1, Sum + a[i]);
	}
}
int main() {
	string id;
	cin >> n >> id >> m;
	rep(i, m)scanf("%d", &a[i]);
	rep(i, n) {
		if (id[i] == '*')pos[cnt++] = n - i - 1;
		else if ((n - i - 1) % 2 == 1)
			sum += (id[i] - '0') * 2 % 10 + (id[i] - '0') * 2 / 10;
		else sum += id[i] - '0';
	}
	dfs(0, 0);
	printf("%d\n", ans);
}

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

int main(){
int N, K;
  cin >> N >> K;
int sum = 0;  
vector<int> vec(N);
  for(int i = 0;i < N;i++){
  cin >> vec.at(i);
  }

  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  for(int i = 0;i < K;i++){
  sum += vec.at(i);
  }
  
  cout << sum << endl;
  return 0;
  
}

Measured memory_bytes: 256