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

#define infi            5e9
#define infl            5e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long int
#define rr              read()
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(register int i=0;i<n;i++)
#define pool(i,n)       for(register int i=n-1;i>=0;i--)
#define loop1(i,n)      for(register int i=1;i<=n;i++)
#define pool1(i,n)      for(register int i=n;i>0;i--)

using namespace std;

inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}
inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}
inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}

// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//


int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle//freopen("in.txt", "r", stdin);//#endif
    //freopen("in.txt", "r", stdin);

    ll n=rr,k=rr;

    ll ans = k *  pw((k-1),(n-1));

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, w;
long long sol[100010];

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

    for (int i = 1; i <= n; i++) {
        int weight, value;
        cin >> weight >> value;

        for (int j = w - weight; j >= 0; j--)
            sol[j + weight] = max(sol[j + weight], sol[j] + value);
    }

    cout << sol[w];
    return 0;
}





Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int X, N;
  cin >> X >> N;
  vector<bool> p(300, false);
  rep(i, N)
  {
    int P;
    cin >> P;
    p[P] = true;
  }
  int ans = 0;
  rep(i, 300)
  {
    if (p[i])
      continue;
    if (abs(ans - X) > abs(i - X))
      ans = i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
/*_47*/
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define pll pair<ll,ll>
#define pk pair<pll,ll>
#define endl "\n"
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define pr_vec(v) for(auto __:v) cout<<__<<" ";
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())
const int N = 1e6 + 5;
void solve()
{
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
}

int main()
{




    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    rep1(i, t)
    {
        // cout << "Case #" << i << ": ";
        solve();
        // cout << endl;
    }


}


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

signed main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size()){
        if(s[i] == '1') ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int d = (H2 - H1) * 60;
    if(M1 < M2) {
        d += M2 - M1;
    }
    else {
        d -= 60;
        d += 60 - M1;
        d += M2;
    }

    d -= K;

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

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

int main() {
    int A, P;
    cin >> A >> P;
    cout << (A * 3 + P) / 2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        for(int i = 1; i <= 9; i++) {
        	int s = n / i;
        	int m = n % i;
        	if(m == 0 && s < 10) {
        		System.out.println("Yes");
        		return;
        	}


        }

        System.out.println("No");
        return;
    }
}

Measured memory_bytes: 22228
#include<stdio.h>

int main(void) {
  int n;
  int w[100];
  int i, j;
  int s1, s2;
  int a;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &w[i]);
  }
  s1 = w[0]; s2 = w[n-1];
  for ( i = 1, j = n-2; i <= j; ){
    if ( s1 < s2 ) {
      s1 += w[i++];
    } else if ( s2 < s1 ) {
      s2 += w[j--];
    } else {
      s1 += w[i++];
      s2 += w[j--];
    }
  }
  a = (s1 > s2) ? s1 - s2 : s2 - s1;
  printf("%d\n", a);
  return 0;
}

Measured memory_bytes: 128
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 4e5 + 10;
tuple<string, int, int> a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		string str;
		int s;
		cin >> str >> s;
		a[i] = make_tuple(str, -s, i);
	}
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++)
		cout << get<2>(a[i]) << endl;
	return 0;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

// K個の色が塗られている
// 座標Xが黒であることはわかっている
int K, X;
int main() {
  cin >> K >> X;
  int min_val = max(-1000000, X - K + 1);
  int max_val = min(1000000, X + K - 1);
  for (int i = min_val; i <= max_val; i++) {
    cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 256
package main

import (

	"fmt"

)

func main() {
	v := "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
	var n int
	fmt.Scan(&n)
	var q string
	fmt.Scan(&q)
	a := ""
	for i, _ := range q {
		pos := -1
		for pos = 0; pos < len(v); pos++ {
			if q[i] == v[pos] {
				break
			}
		}
		a += string(v[pos+n])
	}
	fmt.Println(a)
}



Measured memory_bytes: 7552
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    char a;
    cin>>a;
    if(a>='A' && a<='Z'){
        cout<<"A"<<endl;
    }else{
        cout<<"a"<<endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	Yn(n==m);
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  if (a % b == 0) {
    cout << -1 << endl;
  } else {
    cout << a << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#define mod 1000000007
using namespace std;
long long res,ans=1,fac[1000001],invfac[1000001],n,m,cnt[1000001],length;
long long fast_pow(long long a,int b)
{
  if (b==0)
    return 1;
  if (b&1)
    return fast_pow(a*a%mod,b/2)*a%mod;
  else
    return fast_pow(a*a%mod,b/2);
}
long long C(int a,int b)
{
  if (a>b)
    return 0;
  return fac[b]*invfac[b-a]%mod*invfac[a]%mod;
}
int main()
{
   cin>>n>>m;
   int tx=m;
   for (int i=2;i*i<=m;++i)
	if (tx%i==0)
	{
	  ++length;
	  while (tx%i==0)
	    {
	       tx/=i;
	       cnt[length]++;
	    }
	}
   if (tx>1)
     cnt[++length]=1;
   fac[0]=1;
   for (int i=1;i<=1000000;++i)
     fac[i]=fac[i-1]*i%mod;
   invfac[1000000]=fast_pow(fac[1000000],mod-2);
   for (int i=999999;i>=0;--i)
     invfac[i]=invfac[i+1]*(i+1)%mod;
   for (int i=1;i<=length;++i)
     ans=ans*C(n-1,n+cnt[i]-1)%mod;
   cout<<ans<<endl;
   return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int N;
	cin >> N;
	int a[N][3];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	ll dp[N][3];
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < 3; i++) {
		dp[0][i] = a[0][i];
	}
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) {
					continue;
				}
				dp[i][j] = max(dp[i][j], a[i][j] + dp[i - 1][k]);
			}
		}
	}
	cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]});
	
	return 0;
}


Measured memory_bytes: 7096
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

typedef pair<int, int> P;

int N, M, R;
int r[8];
bool rF[8];
int a, b, c;
lli d[200][200];
deque<int> rt;
lli cost = INF;
//bool f[200][200];
//vector< P > rs[8];

int main(){
	cin.tie(0);
	std::ios::sync_with_stdio(false);
	cin >> N >> M >> R;
	for(int i = 0; i < R; i++){
		cin >> r[i];
		r[i]--;
	}
	/*
	for(int i = 0; i < R-1; i++){
		for(int j = i+1; j < R; j++){
			f[r[i]][r[j]] = true;
			f[r[j]][r[i]] = true;
		}
	}
	*/
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(i == j) d[i][j] = 0;
			else	d[i][j] = INF;
		}
	}
	for(int i = 0; i < M; i++){
		cin >> a >> b >> c;
		d[a-1][b-1] = c;
		d[b-1][a-1] = c;
	}

	for(int k = 0; k < N; k++){
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				d[i][j] = min( d[i][j] , d[i][k] + d[k][j]);
			}
		}
	}

	for(int i = 0; i < R; i++){
		for(int j = 0; j < R; j++){
			dbug(r[i]);dbug(r[j]);
			dbug(d[r[i]][r[j]]);
			dbugln;
		}
	}

	/*
	int frm, to;
	lli minC;
	bool fob;
	rt.push_back(0);
	rF[0] = true;
	for(int i = 0; i < R-1; i++){
		minC=INF;
		frm = rt.front();
		dbug(frm);
		for(int j = 0; j < R; j++){
			if(rF[j]) continue;
			if(r[j] == r[frm]) continue;
			if(minC > d[r[frm]][r[j]]){
				to = j;
				fob = true;
				minC = d[r[frm]][r[j]];
			}
		}

		if(rt.size() > 1){
			frm = rt.back();
			dbug(frm);
			for(int j = 0; j < R; j++){
				if(rF[j]) continue;
				if(r[j] == r[frm]) continue;
				if(minC > d[r[frm]][r[j]]){
					to = j;
					fob = false;
					minC = d[r[frm]][r[j]];
				}
			}
		}
		dbug(fob);
		dbug(to);
		dbug(minC);
		dbugln;
		if(fob) rt.push_front(to);
		else rt.push_back(to);
		rF[to] = true;
		cost += minC;
	}
	*/

	lli buff;
	vector<int> perm(R);
	int ita = 0;
	for(auto& i : perm){
		i = ita;
		ita++;
	}
	do{
		buff = 0;
		for(int i = 0; i < R-1; i++){
			buff += d[r[perm[i]]][r[perm[i+1]]];
			dbug(r[perm[i]]);dbug(r[perm[i+1]]);
			dbug(buff);dbugln;
		}
		cost = min(cost, buff);
		dbug(cost);dbugln;dbugln;
	}while( next_permutation( perm.begin(), perm.end() ) );

	cout << cost;

	return 0;
}


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

int main(){
    int H, W; cin >> H >> W;
    vector<string> A(H);
    unordered_map<char, int> mp;
    rep(i, 0, H) cin >> A[i];
    rep(i, 0, H) rep(j, 0, W) mp[A[i][j]]++;
    bool flag = true;

    if(H % 2 == 0 && W % 2 == 0){
        for(auto e: mp){
            if(e.second % 4 != 0){
                flag = false;
                break;
            }
        }
    }
    else if(H % 2 == 1 && W % 2 == 1){
        int S = 0, D = 0, Q = 0;
        for(auto e: mp){
            if(e.second % 4 == 0){
            }else if(e.second % 4 == 1){
                S += 1;
            }else if(e.second % 4 == 2){
                D += 1;
            }else{
                S++;
                D++;
            }
        }
        if(S > 1 || (H / 2 + W / 2) < D){
            flag = false;
        }
    }else if(H % 2 == 0 && W % 2 == 1){
        int S = 0, D = 0, Q = 0;
        for(auto e: mp){
            if(e.second % 4 == 0){
            }else if(e.second % 4 == 1){
                S += 1;
            }else if(e.second % 4 == 2){
                D += 1;
            }else{
                S++;
                D++;
            }
        }
        if(S > 0 || H / 2 < D){
            flag = false;
        }
    }else{
        int S = 0, D = 0, Q = 0;
        for(auto e: mp){
            if(e.second % 4 == 0){
            }else if(e.second % 4 == 1){
                S += 1;
            }else if(e.second % 4 == 2){
                D += 1;
            }else{
                S++;
                D++;
            }
        }
        if(S > 0 || W / 2 < D){
            flag = false;
        }
    }
    if(flag) puts("Yes");
    else puts("No");


}

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

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

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



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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
   int ans = X;
  for (int i = 0; i < N; i++) {
    int days = 0;
    for (int j = 0; j < D; j++) {
      days = j * A[i] + 1;
      if (D >= days) ans++;
      else break; 
    }  
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
import bisect
N = int(input())
A = sorted([int(i) for i in input().split()])
B = [int(i) for i in input().split()]
C = sorted([int(i) for i in input().split()])


ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (N-bisect.bisect_right(C, b))
print(ans)


Measured memory_bytes: 24224
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  rep(i,n){
    double xa,ya,ra,xb,yb,rb;
    cin>>xa>>ya>>ra>>xb>>yb>>rb;
    double dist=hypot(abs(xa-xb),abs(ya-yb));
    if(dist>ra+rb)cout<<0<<endl;
    else if(dist+rb<ra)cout<<2<<endl;
    else if(dist+ra<rb)cout<<-2<<endl;
    else cout<<1<<endl;
  }
}

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

l = []

c = 0
d = 0

for i in range(n):
	a = str(input())
	l.append(a)
  
for i in range(n-1):
	if l[i][-1] == l[i+1][0]:
		c += 1

for i in range(n):
	if l.count(l[i]) != 1:
		d += 1

if c == n-1 and d == 0:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ;
  cin >> n ;
  vector<int> a(3*n);
  for (int i= 0 ;i< 3*n ;i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());  
  int count = 0;
  long ans = 0;
  for( int i = 3*n - 2 ; ; i -= 2){
    count += 1;
    ans += a.at(i);
    if( count == n){
      break;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector < int >p(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}

	int wrongIndex = -1;
	for (int i = 0; i < N; i++) {
		if (p[i] != i + 1) {
			if (wrongIndex == -1) {
				wrongIndex = i;
			} else {
				if (p[wrongIndex] != i + 1) {
					cout << "NO" << endl;
					return 0;
				}
			}
		}
	}
	cout << "YES" << endl;
	return 0;
}


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

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

using namespace std;
typedef long long int ll;
const int INF = 100000000;

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

    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  string W;
  cin >> W;

  int counter = 0;
  while (1) {
    string s;
    cin >> s;

    if (s == "END_OF_TEXT") { break; }

    // 大文字小文字を区別しないように、小文字に寄せる
    for (int i = 0; i < (int)s.size(); i++) {
      char c = s.at(i);
      if (isalpha(c) && isupper(c)) {
        s.at(i) = tolower(c);
      }
    }

    if (s == W) { counter++; }
  }
  cout << counter << endl;
  return 0;
}



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

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        } else {
            while (x) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3076
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
l1=defaultdict(int)
l2=defaultdict(int)
ans=0
for i,h in enumerate(a):
  l1[i+1-h]+=1
  l2[i+1+h]+=1
for k,v in l2.items():
  ans+=v*l1[k]
print(ans)

Measured memory_bytes: 73608
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);++i)
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans = 0;
    ans = n % 1000;
    if(ans  != 0) ans = 1000-ans;
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int a,b; cin >> a >> b;
    cout<<max({a+b,a-b,a*b})<<endl;
}

Measured memory_bytes: 3600
import functools
@functools.lru_cache(maxsize=None)

def main():
    from collections import deque
    import sys;input=sys.stdin.readline

    h,w=map(int,input().split())
    grid=[["#"]*(w+2)]+[list("#"+input()+"#")for x in range(h)]+[["#"]*(w+2)]

    stack=deque()
    for y in range(1,h+1):
        for x in range(1,w+1):
            if grid[y][x]=="#":
                #grid[y][x]=0
                stack.append((y,x))

    for i in range(h*w):
        tmp=deque()
        while stack:
            my,mx=stack.pop()
            for y,x in ([0,1],[1,0],[-1,0],[0,-1]):
                if grid[my+y][mx+x]==".":
                    #grid[my+y][mx+x]=i+1
                    grid[my+y][mx+x]="#"
                    tmp.append([my+y,mx+x])
        stack=tmp
        if not tmp:
            print(i)
            break
if __name__ == '__main__':
    main()



Measured memory_bytes: 130908
K,N = map(int,input().split())
far_list = []
location =list(map(int,input().split())) 


for i in range(N):
    if i ==0:
        far = location[-1]-location[0]
    else:
        far = K - location[i] + location[i-1]
    far_list.append(far)


print(min(far_list))

Measured memory_bytes: 86140
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int a,b,c,k;
	cin >> a >> b >> c >> k;
	if(a>=k){
		cout << k << "\n";
		return 0;
	}
	else{
		if(b>=k-a){
			cout << a << "\n";
			return 0;
		}
		else{
			cout << a-(k-a-b) << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct Edge { int to, cost; };

template<class T, class Edge> V<T> dijkstra(const VV<Edge>& g, int s = 0) {
  V<T> dist(g.size(), numeric_limits<T>::max());
  using P = pair<T, int>;
  priority_queue< P, V<P>, greater<P> > pque;
  pque.emplace(dist[s] = 0, s);
  while (!pque.empty()) {
    T d; int v;
    tie(d, v) = pque.top(); pque.pop();
    if (d > dist[v]) continue;
    for (const auto& e : g[v]) if (dist[v] + e.cost < dist[e.to]) {
      pque.emplace(dist[e.to] = dist[v] + e.cost, e.to);
    } 
  }
  return dist;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int w, h; cin >> w >> h;
    if (!w) break;
    VV<> s(h, V<>(w)); for (auto&& v : s) for (auto&& e : v) cin >> e;
    V<> c(4); for (auto&& e : c) cin >> e;
    V<> di{0, 1, 0, -1}, dj{1, 0, -1, 0};
    auto in = [&](int i, int j) -> bool { return 0 <= i and i < h and 0 <= j and j < w; };
    auto _ = [&](int i, int j) -> int { return i * w + j; };
    VV<Edge> g(4 * h * w);
    for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) for (int k = 0; k < 4; ++k) {
      for (int x = 0; x < 4; ++x) {
        int ni = i + di[k + x & 3], nj = j + dj[k + x & 3];
        if (!in(ni, nj)) continue;
        g[_(i, j) << 2 | k].emplace_back(Edge{_(ni, nj) << 2 | k + x & 3, x != s[i][j] ? c[x] : 0});
      }
    }
    auto d = dijkstra<int>(g, 0);
    int res = 1e9;
    for (int k = 0; k < 4; ++k) res = min(res, d[_(h - 1, w - 1) << 2 | k]);
    cout << res << '\n';
  }
}


Measured memory_bytes: 3232
n, m = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
x = [[int(i) for i in input().split()] for j in range(m)]

par = [i for i in range(0, n+1)]

def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x]

def unite(x, y):
    x = root(x)
    y = root(y)
    if x != y:
        par[x] = y

for i in x:
    a, b = i
    unite(a, b)

ans = 0
for i, p_ in enumerate(p):
    if root(i+1) == root(p_):
        ans += 1

print(ans)

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

int main(){
    ll n, a, b; cin >> n >> a >> b;
    if(b < a){cout << 0 << endl; return 0;}
    if(n ==1 && a != b){cout << 0 << endl; return 0;}
    else if(n == 1){cout << 1 << endl; return 0;}
    cout << (n*b - (b-a)) - (n*a + (b-a)) + 1 << endl;
}

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

using namespace std;

typedef long long ll;

int main() {
	ll n , a , b;
	ios::sync_with_stdio(0);
	cin >> n >> a >> b;
	if((b - a ) % 2 == 0) {
		cout << (b - a) / 2 << "\n";
	}
	else {
		cout << min(a + (b - a - 1) / 2 , n - b + (b - a - 1) / 2 + 1 ) << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String X = sc.next();
		String Y = sc.next();
		int ans = X.compareTo(Y);
		if(ans == 0) System.out.println("=");
		else System.out.println(ans < 0 ? "<" : ">");
	}
}

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

using namespace std;

//#define _FILES
#define PB push_back
#define MP make_pair

typedef long long ll;
typedef pair<int,int> pii;


int main()
{
    ios_base::sync_with_stdio(false);

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    int n;
    cin >> n;
    int odd = 0;
    int cnt = 0;
    for (int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        if (x&1)
        {
            ++odd;
        }
        else if (!(x%4))
        {
            ++cnt;
        }
    }
    if (cnt >= odd)
    {
        cout << "Yes" << endl;
    }
    else if (cnt + 1 == odd )
    {
        if (cnt + odd == n)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = sum(A) - 2 * sum(A[i] for i in range(1, N, 2))
    ans = [str(x)]
    for i in range(N - 1):
        x = 2 * A[i] - x
        ans.append(str(x))
    print(' '.join(ans))


main()


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

struct node {
	int k;
	node *p, *l, *r;
};
node *r, *NIL;

void insert(node *u) {
	node *p = NIL, *c = r;
	while (c != NIL) {
		p = c;
		if (u->k < c->k)
			c = c->l;
		else
			c = c->r;
	}
	u->p = p;
	if (p == NIL)
		r = u;
	else if (u->k < p->k)
		p->l = u;
	else
		p->r = u;
}

void inparse(node *u) {
	if (u == NIL)
		return;
	inparse(u->l);
	cout << " " << u->k;
	inparse(u->r);
}

void preparse(node *u) {
	if (u == NIL)
		return;
	cout << " " << u->k;
	preparse(u->l);
	preparse(u->r);
}

void print() {
	inparse(r);
	cout << endl;
	preparse(r);
	cout << endl;
}

node* find(int k, node *u) {
	if (u == NIL)
		return NIL;
	else if (k == u->k)
		return u;
	else if (k < u->k)
		return find(k, u->l);
	else if (k > u->k)
		return find(k, u->r);
}

void del(node*);
void del(int);

void del(int k) {
	node *u = find(k, r);
	del(u);
}

node* getsuccessor(node *u) {
	node *ans = u->r;
	while (ans->l != NIL)
		ans = ans->l;
	return ans;
}

void del(node *u) {
	if (u->l == NIL && u->r == NIL) {
		if (u->p->l == u)
			u->p->l = NIL;
		else if (u->p->r == u)
			u->p->r = NIL;
	} else if (u->l != NIL && u->r != NIL) {
		node *y = getsuccessor(u);
		u->k = y->k;
		del(y);
	} else if (u->l != NIL) {
		if (u->p->l == u) {
			u->p->l = u->l;
			u->l->p = u->p;
		} else if (u->p->r == u) {
			u->p->r = u->l;
			u->l->p = u->p;
		}
	} else if (u->r != NIL) {
		if (u->p->l == u) {
			u->p->l = u->r;
			u->r->p = u->p;
		} else if (u->p->r == u) {
			u->p->r = u->r;
			u->r->p = u->p;
		}
	}
}

int main() {
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		string cmd;
		cin >> cmd;
		if (cmd[0] == 'i') {
			node *u = (node*) malloc(sizeof(node));
			int k;
			cin >> k;
			u->k = k;
			u->l = NIL;
			u->r = NIL;
			insert(u);
		} else if (cmd[0] == 'f') {
			int k;
			cin >> k;
			cout << (find(k, r) != NIL ? "yes" : "no") << endl;
		} else if (cmd[0] == 'p') {
			print();
		} else if (cmd[0] == 'd') {
			int k;
			cin >> k;
			del(k);
		}
	}
	return 0;
}



Measured memory_bytes: 21816
let _ =
    let _ = read_line () in
    let (hd::tl) = List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) in
    let (sum::spls) = List.fold_left (fun (h::t) x -> (h+x)::h::t) [hd] tl in
    print_int (List.fold_left (fun m x -> min (abs (x*2-sum)) m) max_int spls)

Measured memory_bytes: 28032
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
	// your code goes here
	int n;
	cin>>n;
	int sum=0;
	int q=n/500;
	n=n-q*500;
	sum+=q*1000;
	int q2=n/5;
	sum+=q2*5;
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

char s[8005];

int a[10000];
int b[10000];
int c[10000];
int d[10000];

int dp[2][8002][16002];

int main(){

	int x,y;

	scanf("%s",s);

	scanf("%d %d",&x,&y);


	int len=strlen(s);

	int i,j;

	int dir=0;
	int cnt1=0;
	int cnt2=0;
	int t1=0;
	int t2=0;
	int dir2=1;
	for(i=0;i<len;i++){
		if(s[i]=='T'){dir2*=-1;}
		else{
			if(dir2==1){
				t1++;
			}
			else{
				t2++;
			}
		}
	}

	for(i=0;i<len;i++){
		if(s[i]=='F'&&dir==0){
			a[cnt1]++;
			if(s[0]=='T'){
				d[cnt1]++;
			}
			else{
				if(cnt1!=0){
					d[cnt1]++;
				}
			}
		}
		else if(s[i]=='F'&&dir==1){
			b[cnt2]++;
			c[cnt2]++;
		}
		else{
			if(dir==0){
				cnt1++;
			}
			else{
				cnt2++;
			}
			dir=1-dir;
		}
	}

	dp[0][0][a[0]+8000]=1;

	for(i=1;i<=cnt1;i++){
		for(j=0;j<16002;j++){
			if(dp[0][i-1][j]>0){
				if(j+a[i]<16002){
				dp[0][i][j+a[i]]=1;
				}
				if(j-d[i]>=0){
				dp[0][i][j-d[i]]=1;
				}
			}
		}
	}

	dp[1][0][b[0]+8000]=1;
	dp[1][0][-c[0]+8000]=1;

	for(i=1;i<=cnt2;i++){
		for(j=0;j<16002;j++){
			if(dp[1][i-1][j]>0){
				if(j+b[i]<16002){
				dp[1][i][j+b[i]]=1;
				}
				if(j-c[i]>=0){
				dp[1][i][j-c[i]]=1;
				}
			}
		}
	}

	if(dp[0][cnt1][x+8000]>0&&dp[1][cnt2][y+8000]>0){
	printf("Yes\n");
	}
	else{
	printf("No\n");
	}

	return 0;
}

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

using namespace std;

int n;
vector<int> a;
vector<long long> dp[2];

long long dfs(bool neg, int now){
    if(now == n - 1) return neg ? a[now] : -a[now];
    if(dp[neg][now] != -(1ll << 60)){
        return dp[neg][now];
    }
    long long res;
    if(neg){
        res = max(a[now] + dfs(true, now + 1), -a[now] + dfs(false, now + 1));
    }else{
        res = max(a[now] + dfs(false, now + 1), -a[now] + dfs(true, now + 1));
    }
    return dp[neg][now] = res;
}

int main(){
    cin >> n;
    a.resize(n);
    dp[0].resize(n, -(1ll << 60));
    dp[1].resize(n, -(1ll << 60));
    for(auto&& i : a){
        cin >> i;
    }
    cout << dfs(true, 0) << "\n";
}

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

int main() {
  long long N;
  cin >> N;
  long long count =0;
  for(int i=1; i<=sqrt(N); i++){
    long long syou = N/i;
    if(N%i==0 && syou>2 && i<syou-1)count += syou-1;
  }
  
  cout << count << endl;
  
}

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

int main(){
    int N;
    cin >> N;
    vector <int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    if(N == 1 && a[0] == 1){
        cout << 0 << endl;
        return 0;
    }
    if(N == 1 && a[0] != 1){
        cout << 1 << endl;
        return 0;
    }
    sort(a.begin() , a.end());
    a.push_back('a');
    int erase = 0 , much = 1;
    for(int i = 0; i < N; i++){
        if(a[i] == a[i + 1]){
            much++;
        }
        else{
            if(much > a[i]){
                erase += much - a[i];
            }
            else if(much < a[i]){
                erase += much;
            }
            much = 1;
        }
    }
    cout << erase << endl;
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define ll long long
#define N 500005
using namespace std;
int n,f[N],g[N],nxt[N]; char s[N];
void get(char s[],int a[]){
	int k=0; memset(nxt,0,sizeof(nxt));
	rep (i,2,n){
		while (k && s[k+1]!=s[i]) k=nxt[k];
		if (s[k+1]==s[i]) nxt[i]=++k; else nxt[i]=k;
	}
	rep (i,1,n) if (!nxt[i] || i%(i-nxt[i])!=0) a[i]=1;
}
int main(){
	scanf("%s",s+1); n=strlen(s+1);
	get(s,f);
	reverse(s+1,s+1+n);
	get(s,g);
	if (f[n]){ printf("1\n1\n"); exit(0); }
	int cut=0;
	rep (i,1,n) if (f[i] && g[n-i]) cut++;
	if (!cut) printf("%d\n1\n",n); else printf("2\n%d\n",cut);
	return 0;
}

Measured memory_bytes: 6528
#include<cstdio> // printf??¨???????????¨???
int main(){
	int x,i=0;
	while(true){ //????????????
	i++;	//i ?????????????¢??????????
	scanf("%d",&x);	//%d?????´??°???a?????????&????????????
	if(x) printf("Case %d: %d\n",i,x); // \n????????????
	else break;

	}
return 0;
}

Measured memory_bytes: 2572
using System;
namespace HelloWorld
{
    class Program
    {
        static void Main()
        {
            const int MIN = -1000000000;
            string line;
            while ((line = Console.In.ReadLine()) != "0")
            {
                var n = int.Parse(line);
                int alpha = 0;
                int beta = MIN;
                for (int i = 0; i < n; ++i)
                {
                    var a = int.Parse(Console.In.ReadLine());
                    var gamma = Math.Max(alpha + a, a);
                    beta = Math.Max(beta, gamma);
                    alpha = gamma;
                }
                Console.Out.WriteLine(beta);
            }
        }
    }
}



Measured memory_bytes: 13828
// I - Coins
#include <bits/stdc++.h>
using namespace std;
using dl = double;

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

	vector<dl> P(N+1); for(int i=1; i<=N; i++) cin>>P[i];

	vector<dl> dp(N+2);
	dp[1] = 1.;
	for(int lv=1; lv<=N; lv++){
		dl f = P[lv], b = 1.-f;
		for(int i=lv+1; i>=1; i--) dp[i] = b*dp[i] + f*dp[i-1];
	}

	int C = (N+1)/2;//ceil
	dl a = 0; for(int i=N+1; i>C; i--) a += dp[i];
	printf("%.10g\n",a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;

int main() {
    // input, ready
    string S,T;
    cin >> S >> T;

    // resolve
    int cnt=0;
    for (auto c: S) {
        if (c != T[cnt]) {
            cout << "No" << endl;
            return 0;
        }
        cnt++;
    }

    // output
    ll ans = 0;
    cout << "Yes" << endl;

    // cout << fixed << setprecision(10) << middle << endl;

    return 0;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 998244353;
const int MN = 200010;

ll dp[MN][2][3][3];

int main() {
	string s;
	cin >> s;
	int n = s.size();

	bool one = 1;
	rep(i, n-1) if (s[i] != s[i+1]) one = 0;

	if (one) {
		cout << "1\n";
		return 0;
	}

	if (n >= 4) {
		rep(i, 3) dp[1][0][i][i] = 1;

		for (int i = 2; i <= n; ++i) {
			rep(f, 2) {
				rep(j, 3) {
					rep(la, 3) {
						if (dp[i-1][f][la] == 0) continue;
						rep(k, 3) {
							dp[i][f | (la == k)][(j+k)%3][k] += dp[i-1][f][j][la];
							dp[i][f | (la == k)][(j+k)%3][k] %= MOD;
						}
					}
				}
			}
		}

		int m = 0;
		rep(i, n) {
			m = (m + s[i]) % 3;
		}

		ll ret = (dp[n][1][m][0] + dp[n][1][m][1] + dp[n][1][m][2]) % MOD;
		bool f = 0;
		rep(i, n-1) f |= (s[i] == s[i+1]);
		if (!f) ret = (ret + 1) % MOD;
		cout << ret << endl;
	} else {
		set<string> vis;

		queue<string> que;
		que.push(s);

		while (!que.empty()) {
			string t = que.front(); que.pop();
			if (vis.count(t)) continue;
			vis.insert(t);

			rep(i, n-1) {
				if (t[i] != t[i+1]) {
					string nx = t;
					for (char c = 'a'; c <= 'c'; ++c) {
						if (c != t[i] && c != t[i+1]) {
							nx[i] = nx[i+1] = c;
							if (!vis.count(nx)) {
								que.push(nx);
							}
						}
					}
				}
			}
		}
		cout << vis.size() << endl;
	}

	return 0;
}

Measured memory_bytes: 28676
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t;
    ld ans=0;
    ld x;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>x;
        ans+=1/x;
    }
    ans=1/ans;
    cout<<setprecision(8)<<fixed<<ans;
}

Measured memory_bytes: 3780
#include<iostream>
#include<cstdio>
#include<queue>
#define pii pair<int,int>
#define piii pair<pii,int>
using namespace std;
int cnt,n,root,sz,a[201010];
int mi[804040][2],fir[201010],nxt[402020],to[402020];
pii num[201010];
priority_queue<piii,vector<piii>,greater<piii> > q;
void add(int x,int y)
{
	nxt[++cnt]=fir[x];fir[x]=cnt;to[cnt]=y;
}
int mmin(int x,int y){ return a[x]<a[y]?x:y;}
void build(int nd,int l,int r)
{
	if(l==r)
	{
		mi[nd][l&1]=l;
		mi[nd][l&1^1]=0;
		return ;
	}
	int mid=(l+r)/2;
	build(nd<<1,l,mid);
	build(nd<<1|1,mid+1,r);
	mi[nd][0]=mmin(mi[nd<<1][0],mi[nd<<1|1][0]);
	mi[nd][1]=mmin(mi[nd<<1][1],mi[nd<<1|1][1]);
}
int query(int nd,int l,int r,int ql,int qr,int d)
{
	if(l>qr||r<ql) return 0;
	if(l>=ql&&r<=qr) return mi[nd][d];
	int mid=(l+r)/2;
	return mmin(query(nd<<1,l,mid,ql,qr,d),query(nd<<1|1,mid+1,r,ql,qr,d));
}
void solve(int &k,int l,int r)
{
	if(l>=r) return ;
	int d=(l&1);
	int k1=query(1,1,n,l,r,d),k2=query(1,1,n,k1+1,r,d^1),ch=0;
//	cout<<l<<" "<<r<<" "<<k1<<" "<<k2<<endl;
	num[k=++sz]=make_pair(a[k1],a[k2]);
	solve(ch,l,k1-1);if(ch) add(k,ch),ch=0;
	solve(ch,k1+1,k2-1);if(ch) add(k,ch),ch=0;
	solve(ch,k2+1,r);if(ch) add(k,ch),ch=0;
}
void print()
{
	q.push(make_pair(num[root],root));
	while(!q.empty())
	{
		int x=q.top().second;q.pop();
		printf("%d %d ",num[x].first,num[x].second);
		for(int i=fir[x];i;i=nxt[i])
		q.push(make_pair(num[to[i]],to[i]));
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);a[0]=0x3f3f3f3f;
	build(1,1,n);
	solve(root,1,n);
	print();
	return 0;
}

Measured memory_bytes: 19456
my_max=0
my_sec=0
cnt=0
n=int(input())
a=[0]*n
r_n =range(n)
for i in r_n:
  a[i]=int(input())
  if my_max<a[i]:
    my_max=a[i]
  elif my_sec<a[i]:
    my_sec=a[i]
    
for i in r_n:
  if my_max==a[i]:
    cnt+=1
    
for i in r_n:
  if my_sec!=0:
    if my_max!=a[i]:
      print(my_max)
    elif cnt>1:
      print(my_max)
    else:
      print(my_sec)
  else:
    print(my_max)
  
  
 

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N;
int a[220000];
bool x[220000];
int dp[110][110];
bool judge() {
    if (x[N - 1] == x[N] || x[N] == x[N + 1])return x[N];
    int l, r;
    for (l = N - 1; l > 1; l--)if (x[l] == x[l - 1])break;
    for (r = N + 1; r < 2 * N - 1; r++)if (x[r] == x[r + 1])break;
    if (N - l < r - N)return x[l];
    return x[r];
}
signed main() {
    cin >> N;
    for (int i = 1; i <= 2 * N - 1; i++)cin >> a[i];
    // 解の存在範囲を初期化
    int lb = 0, ub = 2 * N - 1;

    // 解の存在範囲が1より大きい間、繰り返す
    while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        for (int i = 1; i <= 2 * N - 1; i++)x[i] = a[i] <= mid;

        if (judge()) {
            // midが条件を満たせば、解の存在範囲は(lb, mid]
            ub = mid;
        } else {
            // midが条件を満たさなければ、解の存在範囲は(mid, ub]
            lb = mid;
        }
    }

    // この時点で、lb + 1 = ubとなっている
    cout << ub << endl;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int K = read();
  print(K % 2 == 0 ? K / 2 * K / 2 : K / 2 * (K / 2 + 1));
}


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

int main() {
	string s, t;
	cin >> s >> t;
	long long slen = s.size(), tlen = t.size();
	set<char> ss, tt;
	rep(i, s.size()) ss.insert(s[i]);
	rep(i, t.size()) tt.insert(t[i]);
	bool ok = true;
	long long ans = 0;
	for (auto itr = tt.begin(); itr != tt.end(); itr++) {
		if (ok && ss.find(*itr) == ss.end()) ok = false;
	}

	if (ok) {
		long long aa =0;
		int current = s.find_first_of(t[0], 0);
		int next = 0;
		for (int i = 1; i < tlen; i++) {
			next = s.find_first_of(t[i], current + 1);
			if (next == string::npos) {
				aa++;
				current = 0;
				next = s.find_first_of(t[i], current);
			}
			current = next;
		}

		ans = slen * aa + current + 1;
	}

	if (ok) cout << ans << endl;
	else cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func gcd(num1, num2 int) int {
	if num2 == 0 {
		return num1
	}
	num3 := num1 % num2
	return gcd(num2, num3)
}

func lcm(num1, num2 int) int {
	if num1%num2 != 0 {
		num3 := gcd(num1, num2)
		for i := 1; ; i++ {
			check := num3 * i
			if check%num1 == 0 && check%num2 == 0 {
				return check
			}
		}
	} else {
		return num1
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		row := strings.Fields(scanner.Text())
		nums := []int{}

		for _, v := range row {
			num, _ := strconv.Atoi(v)
			nums = append(nums, num)
		}
		fmt.Println(gcd(nums[0], nums[1]), lcm(nums[0], nums[1]))
	}
}



Measured memory_bytes: 1068
a = input()
k = int(input())


n1 = 10**19
for i in range(2,10):
    if str(i) in a:
        temp = a.find(str(i))
        if temp < n1:
            n1 = temp
            num = i

if k <= n1:
    print(1)
else:
    print(num)





Measured memory_bytes: 2940