akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

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

    vector<vector<ll>> adjList(n);
    
    // vector<int>a(m, 0);
    REP(i, m){
        ll first, second = 0;
        cin >> first >> second;
        adjList[first-1].push_back(second-1);
        adjList[second-1].push_back(first-1);
    }

    // vector<ll> depth(n, INF);
    vector<ll> prev(n, 0);
    vector<bool> visited(n, false);
    // depth[0] = 0;

    queue<ll> q;
    q.push(0);
    while (!q.empty()){
        ll front = q.front();
        q.pop();

        for (auto i : adjList[front]){
            if (!visited[i]){
                q.push(i);
                prev[i] = front+1;
                visited[i] = true;
            }
        }
    }
    cout << "Yes" << endl;
    FOR(i, 1, n){
        cout << prev[i] << endl;
    }
}


Measured memory_bytes: 12888
// Problem : A - Circle Pond
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"
#define lb "lower_bound"
#define ub "upper_bound"
#define bs "binary_search"

int dif(int a,int b){if(a > b)return a - b;else return b - a;}
int min(int a,int b){if(a > b)return b;else return a;}
int max(int a,int b){if(a > b)return a;else return b;}
int gcd(int a,int b){if(a == 0)return b;else return (a%b,b);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int r;
    cin>>r;
    cout<<2*M_PI*r;
	return 0;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 0X3F3F3F3F;
const ll N = 1e5+7;
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS() std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

int main()
{
	IOS();
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	for(int i=0; i<n; i++)
		cout<<s[i]<<t[i];
	cout<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    int N, L, i, sum=0, min=1000, min2;

    cin >> N >> L;

    for(i=1; i<=N; i++){
        sum += L+i-1;

        if(abs(L+i-1) < min){
            min = abs(L+i-1);
            min2 = L+i-1;
        }
    }

    cout << sum-min2 << endl;

    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
from functools import reduce


def lcm(x, y):
    return (x * y) // gcd(x, y)

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

l = reduce(lcm, A)

ans = 0
for a in A:
    ans += l // a

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


Measured memory_bytes: 6100
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define SIZE 4005

int max(int aa, int bb);

int main(void) {
    int a_len,b_len,itr,itrA,itrB,dp[SIZE][SIZE],tmp,piv_x,piv_y,piv_ans=0,ans_len;
    char a_str[SIZE],b_str[SIZE], ans[SIZE];
    memset(ans, '\0', sizeof(ans));
    scanf("%s %s",a_str,b_str);
    //配列の長さを取得
    a_len = strlen(a_str);
    b_len = strlen(b_str);
    //初期化
    for(itr = 0;itr <= a_len; itr++){
        dp[itr][0] = 0;
    }
    for(itr = 0;itr <= b_len; itr++){
        dp[0][itr] = 0;
    }
    /*
    dpの計算
    三通りあるので、それらの最大値を取る
    */
    for(itrA = 1;itrA <= a_len; itrA++){
        for(itrB = 1;itrB <= b_len; itrB++){
            dp[itrA][itrB] = max(dp[itrA][itrB-1],dp[itrA-1][itrB]);
            if(a_str[itrA-1]==b_str[itrB-1]){
                tmp = dp[itrA-1][itrB-1] + 1;
                dp[itrA][itrB] = max(dp[itrA][itrB],tmp);
            }
        }
    }
    //右下から探索を始める
    piv_x = a_len;
    piv_y = b_len;
    
    while(piv_x != 0 && piv_y != 0){
        if(dp[piv_x][piv_y] == dp[piv_x-1][piv_y]){
            piv_x--;
        }
        else if(dp[piv_x][piv_y] == dp[piv_x][piv_y-1]){
            piv_y--;
        }
        else{
            //左上なのでansに追加
            ans[piv_ans] = a_str[piv_x-1];
            piv_ans++;
            piv_y--;
        }
    }
    ans_len = strlen(ans);
    //反転しながら出力
    for(itr = ans_len-1;itr >= 0; itr--){
        printf("%c",ans[itr]);
    }
    printf("\n");
    
    return 0;
}
//maxを計算する関数
int max(int aa, int bb) {
    if (aa > bb)
        return aa;
    else
        return bb;
}


Measured memory_bytes: 48896
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	bool flag = false;
	FOR(i, 0, n+1) {
		FOR(j, 0, m+1) {
			int temp = i * m + j * n - i * j * 2;
			flag = flag || (temp == k);

		}
	}
	if (flag) {
		put("Yes");
	}
	else {
		put("No");
	}
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  char b;
  cin>>b;
  if(b=='A')
  {
    cout<<"T";
  }
  if(b=='T')
  {
    cout<<"A";
  }
  if(b=='G')
  {
    cout<<"C";
  }
  if(b=='C')
  {
    cout<<"G";
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
//cerr
using namespace std;
set<string>s;
map<string, long long>m;
signed main() {
	int n; cin >> n; int p = 0;
	for0(pu, n) {
		string st; cin >> st;
		m[st]++; p = max(p, m[st]);
		s.insert(st);
	}
	for (string st : s)if (m[st] == p)cout << st << endl;
}

Measured memory_bytes: 34560
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 

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

    ll q;
    cin>>q;
    rep(_,q){
        ll a,b;
        cin>>a>>b;
        ll n=a*b-1;
        if(a==b){
            cout<<(a-1)*2<<endl;
            continue;
        }
        ll left=1,right=2000000010;
        while(right-left>1){
            ll mid=(left+right)/2;
            ll c=(mid+1)/2*(mid+1-(mid+1)/2);
            if(c>n) right=mid;
            else left=mid;
        }
        cout<<left-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
 
int main() {
  string a;
  cin>>a;
  if(a.size()%2==1){
    cout<<"No";
    return 0;
  }
  for(int i=0;i<a.size();i++){
    if(i%2==0&&a.at(i)=='h');
    else if(i%2==1&&a.at(i)=='i');
    else{
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string S;cin >> S;
  sort(all(S));
  YesNo(S[0] == 'a' && S[1] == 'b' && S[2] == 'c');
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const ll INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}

vi A;
ll n;

ll memo[100'050];

ll dp(ll at) {
    if(at >= n-1) return 0;
    if(memo[at] != -1) return memo[at];
    return memo[at] = min(dp(at+1)+abs(A[at]-A[at+1]), dp(at+2)+(abs(A[at]-A[at+2])));
}

int main() {
    cin.sync_with_stdio(false);
    memset(memo,-1,sizeof(memo));
    cin >> n;
    A = vi(n+5,INF);
    rep(i,0,n) cin >> A[i];
    cout << dp(0) << endl;
    return 0;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		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;
	}
	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;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

mint f(int n){
	if(n == 0) return 1;
	mint x = f(n/2);
	x *= x;
	if(n%2 == 1) x *= 2;
	return x;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<int, int> mp;
	rep(i,n){
		int a;
		cin >> a;
		mp[a]++;
	}
	int b = 0;
	mint ans = 0;
	if(n%2 == 1){
		bool ok = true;
		for(auto p : mp){
			if(p.first == 0){
				if(p.second != 1) ok = false;
			}
			else{
				if(p.second != 2) ok = false;
				if(p.first != b + 2) ok = false;
				b = p.first;
			}
		}
		if(ok) ans = f(n/2);
	}
	else{
		b = -1;
		bool ok = true;
		for(auto p : mp){
			if(p.second != 2) ok = false;
			if(p.first != b + 2) ok = false;
			b = p.first;
		}
		if(ok) ans = f(n/2);
	}
	cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define int long long
using namespace std;
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; }

const double pi=acos(-1);
const double EPS=1e-8;
bool check(double a,double b,double x,double y){
    y*=(pi/180);
    // cout<<y<<endl;
    double S=a*b-0.5*a*a*tan(y);
    double V;
    if(a*tan(y)<=b){
        V=(b-0.5*a*tan(y))*a*a;
    }else{
        V=0.5*b*b/tan(y)*a;
    }
    return V>=x;
}

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

    double a,b,x; cin>>a>>b>>x;
    double ok=0,ng=90;
    for(int i=0;i<1000;i++){
        double mid=(ok+ng)/2;
        if(check(a,b,x,mid)) ok=mid;
        else ng=mid;
        // cout<<ok<<' '<<ng<<endl;
    }
    // cout<<pi<<endl;
    cout<<fixed<<setprecision(10)<<ok<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <math.h>
#include <algorithm>

using namespace std;

int length;

int main(){
    string s;
    string ans;
    bool tf = false;
    char t;
    cin >> s;
    cin >> ans;
    
    length = s.size();

    for(int i = 0; i < length; i++){
        if(s == ans) tf = true;
        t = s[length - 1];
        s.pop_back();
        s.insert(s.begin(), t);
    }

    if(tf) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
using System;

namespace CADDi_2018_for_Beginners
{
    class Class1
    {
        public static void Main()
        {
            string n = Console.ReadLine();

            int result = 0;

            int value = int.Parse(n);

            int n1 = (value % 10); value /= 10; // 1桁目を取り出す
            int n2 = (value % 10); value /= 10; // 2桁目を取り出す
            int n3 = (value % 10); value /= 10; // 3桁目を取り出す
            int n4 = (value % 10); value /= 10;　// 4桁目を取り出す

            if(n1 == 2)
            {
                result += 1;
            }
            if (n2 == 2)
            {
                result += 1;
            }
            if (n3 == 2)
            {
                result += 1;
            }
            if (n4 == 2)
            {
                result += 1;
            }

            // output
            Console.WriteLine(result);
            Console.ReadLine();
        } 


    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define IMAX -1000000000

#define ll long long

using namespace std;
int main()
{
  ll n,k;
  cin>>n>>k;
  
  ll a[n];

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

  sort(a,a+n);

  bool b[k+1];

  for(int i=0;i<k+1;i++)
    b[i]=false;

  for(int i=0;i<k+1;i++)
  {
    bool rslt=true;
    for(int j=0;j<n;j++)
    {
      int x=i-a[j];
      
      if(x>=0 && x<k+1)
      {
        rslt= rslt & b[x];
      }
    }
    b[i]=!rslt;
  }

  if(b[k])
      cout<<"First";
  else
      cout<<"Second";

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 53;
ll n,a[N],maxa,mina,maxai,minai;
vector<pair<ll,ll> > v;

int main(){
	cin>>n;
	FOR(i,0,n){
		cin>>a[i+1];
	}
	maxa=mina=a[1];
	maxai=minai=1;
	FOR(i,2,n+1){
		if(maxa<a[i]){
			maxa=a[i];
			maxai=i;
		}
		if(mina>a[i]){
			mina=a[i];
			minai=i;
		}
	}
	if(maxa>0&&mina<0){
		ll k;
		if(abs(maxa)>=abs(mina))k=maxai;
		else k=minai;
		FOR(i,1,n+1){
			if(i!=k){
				v.push_back(make_pair(k,i));
				a[i]+=a[k];
			}
		}
		if(k==minai){//all nega
			for(ll i=n;i>=2;i--){
				if(a[i]<a[i-1]){
					v.push_back(make_pair(i,i-1));
					a[i-1]+=a[i];
				}
			}
		}else{
			FOR(i,1,n){
				if(a[i]>a[i+1]){
					v.push_back(make_pair(i,i+1));
					a[i+1]+=a[i];
				}
			}
		}
	}else if(maxa<=0){
		for(ll i=n;i>=2;i--){
			if(a[i]<a[i-1]){
				v.push_back(make_pair(i,i-1));
				a[i-1]+=a[i];
			}
		}
	}else{
		FOR(i,1,n){
			if(a[i]>a[i+1]){
				v.push_back(make_pair(i,i+1));
				a[i+1]+=a[i];
			}
		}
	}
	cout<<v.size()<<endl;
	FOR(i,0,v.size()){
		cout<<v[i].first<<" "<<v[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//`7MM"""Mq.  `7MM"""YMM `YMM'   `MM'   db      `7MM"""Yb.
 // MM   `MM.   MM    `7   VMA   ,V    ;MM:       MM    `Yb.
  //MM   ,M9    MM   d      VMA ,V    ,V^MM.      MM     `Mb
  //MMmmdM9     MMmmMM       VMMP    ,M  `MM      MM      MM
  //MM  YM.     MM   Y  ,     MM     AbmmmqMA     MM     ,MP
  //MM   `Mb.   MM     ,M     MM    A'     VML    MM    ,dP'
//.JMML. .JMM..JMMmmmmMMM   .JMML..AMA.   .AMMA..JMMmmmdP'


//Hey can you give me dji spark -.-????


//░░░░░░░░░░░░░░░░░░░░░░█████████
//░░███████░░░░░░░░░░███▒▒▒▒▒▒▒▒███
//░░█▒▒▒▒▒▒█░░░░░░░███▒▒▒▒▒▒▒▒▒▒▒▒▒███
//░░░█▒▒▒▒▒▒█░░░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██
//░░░░█▒▒▒▒▒█░░░██▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒███
//░░░░░█▒▒▒█░░░█▒▒▒▒▒▒████▒▒▒▒████▒▒▒▒▒▒██
//░░░█████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██
//░░░█▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒██
//░██▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒██▒▒▒▒▒▒▒▒▒▒██▒▒▒▒██
//██▒▒▒███████████▒▒▒▒▒██▒▒▒▒▒▒▒▒██▒▒▒▒▒██
//█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒████████▒▒▒▒▒▒▒██
//██▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██
//░█▒▒▒███████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██
//░██▒▒▒▒▒▒▒▒▒▒████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█
//░░████████████░░░█████████████████

 //NO Thanks(-.-)

#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;

int main()
{
    long long int a,b,c,d,e,f,i=1,j,k=1,p=0;
    cin>>a>>b;
    if(b<=a){
    while(a--)
    {
        cout<<b;
    } }
    else
    {
        while(b--)
    {
        cout<<a;
    }
    }

}


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

struct max_min
{
    int64_t max = 0;
    int64_t min = 0;
};

const int64_t cc = pow( 10, 9 ) + 7;
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first < another.first;
}


int main()
{
    std::string word = "aa";
    std::string w = "No";
    int64_t a,b,c,d,e,f;
 
    std::vector< std::pair< int64_t, int64_t > > list;
    std::cin>> word;

    for( int i = 0; i < word.size() - 1; i+=2 )
    {
        if( word[i] == 'h'
            && word[i+1] == 'i' )
        {
            w = "Yes";
        }
        else
        {
            w = "No";
            break;
        }
    }

    if( word.size() % 2 == 1 )
    {
        w = "No";
    }

    std::cout<< w;
}


Measured memory_bytes: 256
'''Author- Akshit Monga'''
list=[0 for i in range(10**4+1)]
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            var=x**2 +y**2 +z**2 +x*y +y*z +z*x
            if var<=10**4:
                list[var]+=1
            
n=int(input())
for i in range(1,n+1):
    print(list[i])

Measured memory_bytes: 69436
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  string s;
  cin >> s;
  auto v = split(s);
  print(v, " ");
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var X = parseInt(input[0].split(" ")[1]);
  bans=new Array(50);
  all=new Array(50);
  bans[0]=1;
  all[0]=1;
  var ans = 0;
  for(i=1;i<=50;i++){
    bans[i]=bans[i-1]*2+1;
    all[i]=all[i-1]*2+3;
  }
  var full=all[N];
  var bs=bans[N];
  var flag=0;
  if(X%2==0){
    X=all[N]-X;
    flag=1;
  }
  while(X>0&&full>0){

    if(X>(full-1)/2){
      X=X-(full-1)/2-1;
      ans=ans+(bs-1)/2+1;
      full=(full-1)/2-1;
      bs=(bs-1)/2
    }else{
      X=X-1;
      full=(full-1)/2-1;
      bs=(bs-1)/2
    }
  }
  if(flag==1){
    ans=bans[N]-ans;
  }
  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21956
#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;
typedef pair<int, int> P;

signed main(){
	int n;
	cin >> n;
	int now = 100000;
	rep(i, 0, n){
		now += now / 20;
		now = (now + 999) / 1000;
		now *= 1000;
	}
	cout << now << endl;
}

Measured memory_bytes: 3112
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,m = inpm()
    h = inpl()
    g = [[] for _ in range(n)]
    for _ in range(m):
        a,b = inpm()
        a -= 1
        b -= 1
        g[a].append(b)
        g[b].append(a)
    ans = 0
    for i in range(n):
        flag = 1
        for j in range(len(g[i])):
            if h[i] <= h[g[i][j]]:
                flag = 0
        if flag:
            ans += 1
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 31072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<double,double> PDD;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const double eps = 1e-10;

double dis(PDD x, PDD y){
  return sqrt((x.first - y.first)*(x.first - y.first) + (x.second - y.second)*(x.second - y.second));
}

bool allin(vector<PDD> &v, PDD center, double r){
  for(PDD & p:v) if(dis(p,center) > r + eps) return false;
  return true;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<PDD> v(N);
  rep(i,N)cin >> v[i].first >> v[i].second;
  auto f = [&](double R){
    bool sat = false;
    rep(i,N-1)repp(j,i+1,N){
      if(dis(v[i],v[j]) > 2*R+eps) return false;
      double x = v[i].first - v[j].first;
      double y = v[i].second - v[j].second;
      double a = (x*x + y*y)/2.0;
      PDD p;

      p.first = (x*a + y* sqrt((x*x+y*y)*R*R - a*a))/(x*x+y*y) + v[j].first;
      p.second = (y*a - x* sqrt((x*x+y*y)*R*R - a*a))/(x*x+y*y) + v[j].second;

      bool s = true;
      rep(k,N) if(dis(v[k],p) > R+eps) s = false;
      if(s) sat = true;

      p.first = (x*a - y* sqrt((x*x+y*y)*R*R - a*a))/(x*x+y*y) + v[j].first;
      p.second = (y*a + x* sqrt((x*x+y*y)*R*R - a*a))/(x*x+y*y) + v[j].second;

      s = true;
      rep(k,N) if(dis(v[k],p) > R+eps) s = false;
      if(s) sat = true;

      if(sat) return true;
    }
    return false;
  };
  double l = 0, r = 1000;
  while(r-l > eps){
    double m = (l+r)/2.0;
    if(f(m)) r = m;
    else l = m;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int k;
  	string s;
  	cin>>k>>s;
  	if(s.length()<=k)
      cout<<s;
  	else{
      cout<<(s.substr(0,k)).append("...");
    }
	return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int top_dig(int n) {
    int res;
    while(n != 0) {
        res = n % 10;
        n /= 10;
    }
    return res;
}



int main() {

    int N; cin >> N;
    int cnt[10][10];
    rep(i,10) {
        rep(j,10) cnt[i][j] = 0;
    }
    for (int i = 1; i <= N; ++i) {
        ++cnt[top_dig(i)][i%10];
    }
    
    ll ans = 0;
    rep(i,10) {
        for (int j = i + 1; j < 10; ++j) {
            ans += cnt[i][j] * cnt[j][i] * 2;
        }
    }
    rep(i,10) {
        ans += pow(cnt[i][i], 2);
    }
    out(ans);

    return 0;
}









Measured memory_bytes: 256
from itertools import permutations

n=int(input())
l=[list(map(int,input().split())) for i in range(n)]

d=[]
for i in permutations(l):
    t_d=0
    for j in range(len(i)-1):
        t_d+=((i[j][0]-i[j+1][0])**2+(i[j][1]-i[j+1][1])**2)**0.5
    d.append(t_d)
print(sum(d)/len(d))

Measured memory_bytes: 4504
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, s, N) for(ll i{N - 1}; i > s - 1; i--)
#define iikae auto&
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

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

  if(A % 4 == 2) A = 1;
  else if(A % 4 == 0) A = 0;
  else if(A % 4 == 1) A = A - 1;
  if(B % 4 == 1) B = 1;
  else if(B % 4 == 2) B = B + 1;
  else if(B % 4 == 3) B = 0;
  cout << (A ^ B) << rt;
}


/*
ヘ＿＿／￣￣￣＼
＼ﾉ　 (･)　ヽ_＿)
　＼_ノ　　　丿
　　(ﾉー、　 |
　　　 ノ　　ヽ
　　　/　　｜ |
　　 /　　(_ノ
　　|/＼　　/
　　　　)　/
　　　 (＿ﾉ
 */

Measured memory_bytes: 256
import numpy as np
Flg = "No"
A = [[0]*3 for i in range(3)]
for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())    
N = int(input())
b = [0]*N
for j in range(N):
    b[j] = int(input())

for i in range(3):
    for j in range(3):
        for k in range(N):
            if(A[i][j] == b[k]):
                A[i][j] = "*"
A_T = np.array(A).T
                
for i in range(3):
    if(A[i][0] == A[i][1] == A[i][2] == "*"):
        Flg = "Yes"        
        break
    if(A_T[i][0] == A_T[i][1] == A_T[i][2] == "*"):
        Flg = "Yes"
        break

if(A[0][0] == A[1][1] == A[2][2] == "*"):
    Flg = "Yes"

if(A[0][2] == A[1][1] == A[2][0] == "*"):
    Flg = "Yes"

print(Flg)

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ld a;
	ld b;
	cin>>a>>b;
	ull ans=a*b;
	cout<<ans<<endl;	


    return 0;
}




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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  ll all=0;
  rep(i,n){
    all=all^a[i];
  }
  rep(i,n){
    ll ans=all^a[i];
  cout<<ans<<" ";
  }
}


Measured memory_bytes: 4848
using System;
using System.Collections;
using System.Linq;
using System.Collections.Generic;

namespace bucon1
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] a = Console.ReadLine().Split(' ');
            int b = int.Parse(a[0]);
            int c = int.Parse(a[1]);
            int ans;

            var an = new List<int>(){
                b + c,b - c, b * c
            };

            ans = an.Max();
            
            Console.WriteLine(ans);
        }
    }
}


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

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  
  string slime;
  while(S.size()>0){
    char s=S.at(0);
    int count=0;
    for(int i=0;i<S.size() && S.at(i)==s;++i){
      ++count;
    }
    slime=slime+s;
    S.erase(0,count);
  }
  cout<<slime.size()<<endl;
}

Measured memory_bytes: 696
#include<stdio.h>
int main(){
  int a,b,w,n,i;
  char c;
  scanf("%d",&w);
  int data[w];
  for(i=0;i<w;i++){
    data[i]=i+1;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%c%d",&a,&c,&b);
    int temp;
    temp=data[a-1];
    data[a-1]=data[b-1];
    data[b-1]=temp;
  }
  for(i=0;i<w;i++){
    printf("%d\n",data[i]);
  }
  return(0);
}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using SS = stringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + ( p ), ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

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

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

VS solve( const VS &board, const int oe )
{
	const int H = SZ( board ), W = SZ( board[0] );
	VS res( H, string( W, '.' ) );

	REP( i, H )
	{
		REP( j, W )
		{
			if ( j == ( oe ? W - 1 : 0 ) || ( i % 2 == oe && j != ( oe ? 0 : W - 1 ) ) || board[i][j] == '#' )
			{
				res[i][j] = '#';
			}
		}
	}

	return move( res );
}

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

	int H, W;
	cin >> H >> W;

	VS board( H );
	cin >> board;

	const VS res1 = solve( board, 0 ), res2 = solve( board, 1 );

	copy( ALL( res1 ), ostream_iterator< string >( cout, "\n" ) );
	cout << '\n';
	copy( ALL( res2 ), ostream_iterator< string >( cout, "\n" ) );
	cout << flush;

	return 0;
}


Measured memory_bytes: 1536
// ITP1_7_B:   How many ways?
// 2017.7.28
 
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int n, x, max;
    int a, b, c;
    int ans;
 
    while (1) {
        scanf("%d%d", &n, &x);
        if (n == 0 && x == 0) break;
 
        ans = 0;
        max = x; if (max > n) max = n;
        for (a = 1; a <= max; a++) {
            for (b = a + 1; b <= max; b++) {
                c = x - a - b;
                if (c > b && c <= n) ans++;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

typedef pair<ll,ll> P;
typedef pair<string,bool> V;
int cnt=0;
map<V,int> has; vector<V> tov;
vector<pair<int,int>> g[4020];
bool pal(const string& s){
   rep(i,0,s.size())if(s[i]!=s[s.size()-i-1])return false;
   return true;
}

int main(){
   int n; cin>>n;
   vector<string> S(n); vector<int> a(n);
   rep(i,0,n){
      cin>>S[i]>>a[i];
   }
   has[{"",0}]=cnt++;
   tov.push_back({"",0});
   has[{"",1}]=cnt++;
   tov.push_back({"",1});
   rep(i,0,n)rep(j,1,S[i].size()+1){
      string s=S[i];
      string t=s;
      t=s.substr(S[i].size()-j,j);
      has[{t,0}]=cnt++;
      tov.push_back({t,0});
      t=s.substr(0,j);
      reverse(ALL(t));
      has[{t,1}]=cnt++;
      tov.push_back({t,1});
   }
   rep(i,0,cnt)rep(j,0,n){
      string s=tov[i].first;
      string t=S[j];
      if(!tov[i].second)reverse(ALL(t));
      int x=min(s.size(),t.size());
      reverse(ALL(s)); reverse(ALL(t));
      rep(k,0,x){
         if(s.back()!=t.back())goto fail;
         s.pop_back(); t.pop_back();
      }
      if(t.empty()){
         reverse(ALL(s));
         g[i].push_back({has[{s,tov[i].second}],a[j]});
      }
      else{
         reverse(ALL(t));
         g[i].push_back({has[{t,!tov[i].second}],a[j]});
      }
      fail:;
   }
   vector<ll> dist(cnt,INF);
   priority_queue<P,vector<P>,greater<P>> pq;
   rep(i,0,n){
      string s=S[i];
      dist[has[{s,0}]]=a[i];
      pq.push({a[i],has[{s,0}]});
      reverse(ALL(s));
      dist[has[{s,1}]]=a[i];
      pq.push({a[i],has[{s,1}]});
   }
   while(!pq.empty()){
      auto [d,id]=pq.top(); pq.pop();
      if(pal(tov[id].first)){
         cout<<d<<endl;
         return 0;
      }
      if(dist[id]<d)continue;
      for(auto [nxt,nd]:g[id]){
         if(chmin(dist[nxt],d+nd)){
            pq.push({dist[nxt],nxt});
         }
      }
   }
   cout<<-1<<endl;
   return 0;
}

Measured memory_bytes: 4076
odd = set(['R','U','D'])
even = set(['L','U','D'])
s = input()
ans = 'Yes'
for i,v in enumerate(s):
  if i % 2 != 0 and v not in even:
    ans = 'No'
    break
  elif i % 2 == 0 and v not in odd:
    ans = 'No'
    break

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <sstream>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define ull unsigned long long int
#define ll long long
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
ll MD=1000000007;
ll md=998244353;
const ll INF=1e18L+5;
ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}//put b as bmod(md-1) if md is prime}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll pow_2(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }

    return res;
}
bool isPrime(ll a)
{
    for(ll i=3; (i*i)<=a; i+=2)
    {
        if( (a%i)==0 )
            return false;
    }
    if( ( a!=2 ) && ( (a%2)==0 ) )
        return false;
    if( a==1 )
        return false;

    return true;
}
string decToBinary(int n)
{
    // Size of an integer is assumed to be 32 bits
    string s="";
    for (int i = 31; i >= 0; i--) {
        int k = n >> i;
        if (k & 1)
            //cout << "1";
            s=s+"1";
        else
            //cout << "0";
            s=s+"0";
    }
    return s;
}
int decimalToBinary(int N)
{

    // To store the binary number
    ull B_Number = 0;
    int cnt = 0;
    while (N != 0) {
        int rem = N % 2;
        ull c = pow(10, cnt);
        B_Number += rem * c;
        N /= 2;

        // Count used to store exponent value
        cnt++;
    }

    return B_Number;
}
string toString(ull num)
{
    std::string number;
    std::stringstream strstream;
    strstream << num;
    strstream >> number;
    return number;
}
const double PI = acos(-1);
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int arr[n];
    fo(i,0,n-1)cin>>arr[i];
    sort(arr,arr+n);
    char dp[n][k+1];
    for(int i=0;i<n;i++)
    {
        dp[i][0]='J';
    }
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {   int counter=0;
            for(int l=0;l<=i;l++)
            {
                if(j-arr[l]>=0 && dp[i][j-arr[l]]=='J'){counter++;break;}
            }
            if(counter>0)dp[i][j]='T';
            else dp[i][j]='J';
        }
    }
    //cout<<dp[n-1][k]<<endl;
    if(dp[n-1][k]=='T')cout<<"First"<<endl;
    else cout<<"Second"<<endl;
return 0;}




Measured memory_bytes: 13384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const long double pi = 3.141592653589793;



int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    map<ll, ll> M;
    set<ll> X;
    rep(i, N){
        cin>>A[i];
        X.insert(A[i]);
        M[A[i]]++;
    }
    ll Ans=0;
    while(!(X.empty())){
      	//cout<<"!";
        auto K=X.begin();
        X.erase(K);
        ll Y=M[*K];
        if(M[*K]-*K<0){
            Ans+=M[*K];
        }
        else{
            Ans+=M[*K]-*K;
        }
      	//cout<<Ans<<endl;
    }
    cout<<Ans<<endl;

}
     

Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef tuple<int,int,char,LL,string>T_MIX;
T_MIX box[100000];
int main(void){
	int n;
	int i;
	cin>>n;
	for(i=0;i<n;i++)	cin>>get<0>(box[i])>>get<1>(box[i])>>get<2>(box[i])>>get<3>(box[i])>>get<4>(box[i]);
	sort(box,box+n);
	for(i=0;i<n;i++)	cout<<get<0>(box[i])<<" "<<get<1>(box[i])<<" "<<get<2>(box[i])<<" "<<get<3>(box[i])<<" "<<get<4>(box[i])<<endl;
	return 0;
}


Measured memory_bytes: 12472
#include<stdio.h>
int main(){
  int N;
  scanf("%d",&N);
  int sum = 0;
  int n = N;
  while(n > 0){
    sum += n % 10; //1の位を取得して，位を下げる
    n /= 10;  
  }
  if(N % sum == 0) printf("Yes\n");
  else printf("No\n");
}

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

bool p[1000100];

void erato(){
  fill(p, p + 1000100, true);
  p[0] = p[1] = false;

  for(int i = 2; i * i <= 1000100; i++){
    if(!p[i]) continue;
    for(int j = i + i; j < 1000100; j += i){
      p[j] = false;
    }
  }
}

int main(){
  erato();

  int a, d, n;

  while(cin >> a >> d >> n, a || d || n){
    while(true){
      if(p[a]){
        n--;
      }
      if(n == 0){
        break;
      }
      a += d;
    }

    cout << a << endl;
  }
}

Measured memory_bytes: 2136
use List::Util qw/first reduce/;
my $input = <STDIN>;
chomp($input);
my ($x, $y) = split(' ', $input);
my @groupe = (
    [qw/1 3 5 7 8 10 12/],
    [qw/4 6 9 11/],
    [qw/2/],
);
sub group_id {
    my ($v) = @_;
    return (first {reduce {$a || $b == $v} 0, @{$groupe[$_]}} (0..$#groupe));
}
print (group_id($x) == group_id($y) ? 'Yes' : 'No');


Measured memory_bytes: 640
A, B = map(int, input().split())
# A, B = 6, 6


def calc_maximum_coins(A, B):
    if A > B:
        s, t, result = A - 1, B, A
    else:
        s, t, result = A, B - 1, B

    return result + max(s, t)


print(calc_maximum_coins(A, B))

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

int main() {
  string s;
  cin>>s;
  if(s.at(0)=='S' && s.at(1)=='S' && s.at(2)=='S')
    cout<<0<<endl;
  else if(s.at(1)=='S')
    cout<<1<<endl;
  else if(s.at(0)=='R' && s.at(2)=='R')
    cout<<3<<endl;
  else if(s.at(0)=='S' && s.at(2)=='S')
    cout<<1<<endl;
  else if(s.at(0)=='R'&&s.at(1)=='R')
    cout<<2<<endl;
  else
    cout<<2<<endl;
}



Measured memory_bytes: 3640
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    S = [list(input()) for _ in range(H)]

    for h in range(H):
        for w in range(W):
            if S[h][w] == "#":
                for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1)):
                    next_h, next_w = h + dh, w + dw
                    if next_h < 0 or next_h >= H or next_w < 0 or next_w >= W:
                        continue
                    elif S[next_h][next_w] == "#":
                        break
                else:
                    print("No")
                    exit()

    print("Yes")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll n; cin >> n;
    vll a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<ll>());
    ll m = a[0];
    ll p = m/2;
    ll min = 1000000000000;
    ll ans = 0;
    for(int i=1; i<n; i++){
        if(abs(p-a[i]) < min){
            min = abs(p-a[i]);
            ans = a[i];
        }
    }
    cout << m << " " << ans;
}

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

int main(){
  int n,ans,i,tmp;
  cin >> n;
  int a[n];
  ans =0;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  tmp=0;
  for(i=1;i<n;i++){
    if(a[i]<=a[i-1])tmp+=1;
    else{
      ans=max(ans,tmp);
      tmp=0;
    }
  }
  ans=max(ans,tmp);
  cout << ans;
}

Measured memory_bytes: 640