akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60,lmod=1e9+7;
const int MAX_N=200005;

int b[MAX_N*2];

int main(){
  int n;
  cin >> n ;
  bool rev; //trueの時逆向き
  int l = MAX_N-1; 
  int r = MAX_N;
  rep(i,n){
    rev = (i%2==1);
    if(!rev){
      scanf("%d",&b[r++]);
    }else{
      scanf("%d",&b[l--]);
    }
  }
  rev = (n%2==1);
  if(!rev){
    rep(i,n-1) printf("%d ",b[l+i+1]);
    printf("%d\n",b[r-1]);
  }else{
    rep(i,n-1) printf("%d ",b[r-i-1]);
    printf("%d\n",b[l+1]);
  }
  return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int digsum(int n) {
  int res = 0;
  int tmp = 0;
  while(n > 0) {
    res += n%10;
    tmp = n;
    n /= 10;
  }
  return tmp;
}

int main() {
  int A, B;
  int ans = 0;

  cin >> A >> B;

  int alw = (int)((double)A*100/8 + 0.9);
  int aup = (int)((double)((A+1)*100/8 + 0.9));
  int blw = (int)((double)B*100/10 + 0.9);
  int bup = (int)((double)((B+1)*100/10 + 0.9));
  // cout << "alw = " << alw << ", aup = " << aup << endl;
  // cout << "blw = " << blw << ", bup = " << bup << endl;

  if(alw == blw){
    ans = alw;
  }else if(alw < blw && aup < blw){
    ans = -1;
  }else if (blw < alw && bup < alw){
    ans = -1;
  }else if(alw < blw && aup > blw){
    ans = blw;
  }else if(blw < alw && bup > alw){
    ans = alw;
  }else if(alw < blw && aup > bup){
    ans = blw;
  }else if(blw < alw && bup > aup){
    ans = alw;
  }else{
    ans = -1;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
/*
* @author:  codancer
* @createTime:  2020-02-16, 20:02:56
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> pii;
int main(){
	int n;
	cin>>n;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		if(a[i]%2==0){
			if((a[i]%3)&&(a[i]%5)){
				cout<<"DENIED"<<endl;
				return 0;
			}
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
using namespace std;
typedef long long LL;
const int N=10010;
template<typename T>inline T chkmax(T A,T B){return A>B?A:B;}
template<typename T>inline T chkmin(T A,T B){return A<B?A:B;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int H,W,n,a[N],C[210][210];
int main()
{
	//file();
	read(H),read(W);
	read(n);
	For(i,1,n)read(a[i]);
	int posx=1,posy=1,flag=1;
	For(i,1,n)
	{
		For(j,1,a[i])
		{
			C[posx][posy]=i;
			posy+=flag;
			if(posy==0)
			{
				posx++;
				flag=1;
				posy=1;
			}
			else
			if(posy==W+1)
			{
				posx++;
				flag=-1;
				posy=W;
			}
		}
	}
	For(i,1,H)
	{
		For(j,1,W)
			printf("%d ",C[i][j]);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main()
{
      char st[1200][100],st1[1200],c;
      int i,j=0,k=0,t=0;
      fgets(st1,1200,stdin);
      for(i=0;st1[i]!='\0';i++)
      {
            //scanf("%s%c",st[i],&c);if(c=='\n')break;//printf("%s\n",st[i]);
            if(st1[i]!=' ')
            {
                  st[j][k]=st1[i];k++;t=0;
            }
            else
            {
                  t++;
                  if(t==1&&k!=0)
                  {
                      st[j][k]='\0';//printf("%s\n",st[j]);
                  j++;k=0;
                  }
            }
      }//if(k!=0)st[j][k]='\0';
      /*for(k=0;k<=j;k++)
      {
            puts(st[i]);
      }*/
      if(k!=0)
      {
            j++;
      }
      int a=-99999,l,f,b=-99999,g,s;
      for(i=0;i<j;i++)
      {f=0;//printf("%s ",st[i]);
      s=strlen(st[i]);
            if(s>b)
            {
                  b=s;g=i;
            }
            for(k=i+1;k<=j;k++)
            {
                  if(strcmp(st[i],st[k])==0)
                  {
                        f++;
                  }
            }if(f>a)
            {
                  a=f;l=i;
            }
      }printf("%s %s\n",st[l],st[g]);
}



Measured memory_bytes: 2144
x, y, a, b, c = list(map(int, input().split()))
ppp = list(map(int, input().split()))
qqq = list(map(int, input().split()))
rrr = list(map(int, input().split()))
ppp.sort(reverse=True)
qqq.sort(reverse=True)
ppqq = ppp[:x] + qqq[:y]
ppqq.extend(rrr)
ppqq.sort(reverse=True)
print(sum(ppqq[:x + y]))


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

int main() {
  string a;
  cin>>a;
  int b=0,c=0;
  for(int i=0;i<a.size();i++){
    if(a[i]=='A'||a[i]=='T'||a[i]=='G'||a[i]=='C')
      c++;
    else
      c=0;
    b=max(b,c);
  }
  cout<<b;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a[10000],b[10000],i;
    for(i=0;i<=10000;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        if(a[i]==0 && b[i]==0)
            break;
    }
    for(i=0;i<=10000;i++)
    {
        if(a[i]==0 && b[i]==0)
            break;
        if(a[i]<=b[i])
        printf("%d %d\n",a[i],b[i]);
        else
            printf("%d %d\n",b[i],a[i]);
    }
    return 0;
    }



Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D,E,F;
  cin >> A >> B >> C >> D >> E >> F;
  
  int f = F/100;
  
  vector<int> AB(31);
  for (int i=0; i<=f; i+=A){
    for (int j=0; j<=f; j+=B){
      if( i + j <= 30) AB.at(i+j) = (i+j) * E;
    }
  }
  
  vector<pair<double, int>> SP;
  vector<int> SG(31);
  for (int i=1; i<31 ; i++) {
    if ( AB.at(i) ) {
      int S = 0;
      for (int j=0; j<=AB.at(i); j+=C) {
        for (int k=0; k<=AB.at(i); k+=D) {
          int s = j + k;
          if( s <= AB.at(i) && i*100 + s <= F ) S = max(S,s);
        }
      }
      SG.at(i) = S;
      double p = (S*100.0) / (i*100.0 + S);
      SP.push_back( make_pair( p, i) );
    }
  }
  sort(SP.begin(),SP.end());
  int I = SP.at( SP.size()-1 ).second;
  int res2 = SG.at(I);
  int res1 = res2 + ( I * 100);

  cout << res1 << " " << res2 << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(long long i=0;i<(n);i++)
#define rep2(i,m,n) for(long long i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back







int main(){


    int a,b,t;
    cin>>a>>b>>t;

    cout<<(t/a)*b<<endl;





}








            






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

bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){
	return (a.second < b.second);
}

int main(){
ll n,a,b,t,i,f=0;
cin>>n>>t;
vector<pair<ll,ll> > p,pp;
while(n--){
	cin>>a>>b;
	p.push_back(make_pair(a,b));
}
sort(p.begin(),p.end(),sortbysec);
for(i=0;i<p.size();i++){
	if(p[i].second <= t){
		f=1;
	//	cout<<"p wla loop"<<endl;
	//	cout<<p[i].first<<" "<<p[i].second<<endl;
		pp.push_back(make_pair(p[i].first,p[i].second));
	}
	else{
		break;
	}
}
if(!f)
cout<<"TLE"<<endl;
else{
	sort(pp.begin(),pp.end());
	//cout<<"answer"<<endl;
	cout<<pp[0].first<<endl;
	//for(i=0;i<pp.size();i++)
	//cout<<pp[i].first<<" "<<pp[i].second<<endl;
}
return 0;
}


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

template <typename T>
class SegmentTree {
	using func_t = function<T(T, T)>;
	const int n;
	const T id;
	func_t merge;
	vector<T> data;
	int size(int n) {
		int res;
		for (res = 1; res < n; res <<= 1);
		return res;
	}
	T sub(int l, int r, int node, int lb, int ub) {
		if (ub <= l || r <= lb) return id;
		if (l <= lb && ub <= r) return data[node];
		return merge(sub(l, r, node * 2, lb, (lb + ub) / 2), sub(l, r, node * 2 + 1, (lb + ub) / 2, ub));
	}
public:
	SegmentTree(int n_, T id_, func_t merge_) :
		n(size(n_)), id(id_), merge(merge_), data(size(n_) * 2, id_) {}
	void Update(int p, T val) {
		p += n;
		data[p] = val;
		while (p >>= 1) data[p] = merge(data[p * 2], data[p * 2 + 1]);
	}
	void Add(int p, T val) {
		p += n;
		data[p] += val;
		while (p >>= 1) data[p] = merge(data[p * 2], data[p * 2 + 1]);
	}
	T Find(int i) {
		return data[i + n];
	}
	T Find(int l, int r) {
		return sub(l, r + 1, 1, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	int n, q, com, x, y;
	cin >> n >> q;
	SegmentTree<int> st(n, INT_MAX, [](int l, int r) { return min(l, r); });
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.Find(x, y));
		}
		else {
			st.Update(x, y);
		}
	}
	return 0;
}

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

int main()
{
    string str;

    cin >> str;

    //cout << str[0] << endl;

    if(((str[0] == str[1]) && (str[1] == str[2])) || ((str[1] == str[2]) && (str[2] == str[3])))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//#include"stdc++.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define cases ll t;cin>>t;while(t--)
#define f1(a,n) for(int i=a;i<n;i++)
#define f2(b,n) for(int j=b;j<n;j++)
#define INF 1000000000000009
#define pb push_back
ll ar[100005];
#define MAX 1000005
int main() {
    fast
    ll n,k;
    cin>>n>>k;
    ll dp[100007];
    memset(dp,0,sizeof(dp));
    f1(0,n)
    {
        ll w,v;
        cin>>w>>v;
        for(ll j=k;j>=w;j--)
            dp[j]=max(dp[j],v+dp[j-w]);
    }
    cout<<dp[k];
    return 0;
}



Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    rep(i,h)cin>>s[i];
    vvi dp(h,vi(w,inf));
    dp[0][0]=s[0][0]=='#';
    int dx[]={0,1},dy[]={1,0};
    rep(i,h){
        rep(j,w){
            rep(d,2){
                int y=i+dy[d],x=j+dx[d];
                if(y>=h||x>=w)continue;
                int c=s[i][j]=='.'&&s[y][x]=='#';
                dp[y][x]=min(dp[y][x],dp[i][j]+c);
            }
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<vector<int>> Graph; //隣接行列でグラフを表現

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

    Graph next_town(60, vector<int>(N));

    for (int v = 0; v < N; v++)
    {
        cin >> next_town[0][v];
        next_town[0][v]--;
    }

    for (int d = 0; d + 1 < 60; d++)
    {
        for (int v = 0; v < N; v++)
            next_town[d + 1][v] = next_town[d][next_town[d][v]];
    }
    int v = 0;
    for (int d = 0; d < 60; ++d)
    {
        if (K & (1LL << d))
            v = next_town[d][v];
    }
    cout << v + 1 << endl;
    return 0;
}

Measured memory_bytes: 51032
#include <iostream>
#include <map>
using namespace std;
int main(){
  int n; cin >> n;
  map<long long int, int> D;
  for(int i=0;i<n;i++){
    long long int d; cin >> d;
    D[d]++;
  }
  string ans="YES";
  int m; cin >> m;
  for(int i=0;i<m;i++){
    long long int t; cin >> t;
    D[t]--;
    if(D[t]<0) {
      ans="NO";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int n, y; cin >> n >> y;
    eFOR(i, 0, n)eFOR(j, 0, n - i) {
        if (i * 10000 + j * 5000 + (n - i - j) * 1000 == y) {
            print(i, j, n - i - j);
            return 0;
        }
    }
    print(-1, -1, -1);

    return 0;
}

Measured memory_bytes: 3580
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;
#define int ll
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<pii> vpii;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

namespace IO {

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a);

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a);

    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int bp(int a, int b, int m) {
    if (b == 0) return 1;
    int x = bp(a, b / 2, m);
    x = x * x % m;
    x *= max(1ll, (b % 2) * a);
    return x % m;
}
void solve() {
    int n;
    cin >> n;
    vector<vi> dp(n + 1, vi(n + 1, 0));
    vector<vi> pref(n + 1, vi(n + 1, 0));
    int M = 1e9 + 7;
    dp[0][0] = 1;
    rep(i,0,1){
        pref[i][0] = dp[i][0];
        rep(j, 1, n + 1)pref[i][j] = (pref[i][j - 1] + dp[i][j]) % M;}
    rep(i, 1, n + 1) {
        rep(j, 0, n + 1) {
            if (j >= 3)
            dp[i][j] = pref[i - 1][j - 3];
        }
        pref[i][0] = dp[i][0];
        rep(j, 1, n + 1)pref[i][j] = (pref[i][j - 1] + dp[i][j]) % M;
    }
    int ans = 0;
    rep(i, 0, n + 1) {
        ans = (ans + dp[i][n]) % M;
    }
    put(ans);
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;

    while (q--) solve();
}


Measured memory_bytes: 65588
#include<iostream>

using namespace std;

int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int cnt=0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(x==i*500+j*100+k*50){
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}

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

int ans[27];
int a[27];
int main(){
	int n;
	string s;
	
	memset(ans,50,sizeof(ans));
	cin >> n;
	while(n--){
		cin >> s;
		memset(a,0,sizeof(a));
		for(int i = 0;i < s.size();i++){
			a[s[i]-'a']++;
		}
		for(int i = 0;i < 26;i++){
			ans[i] = min(ans[i],a[i]);
		}
	}
	for(int i = 0;i < 26;i++){
		while(ans[i]){
			cout << char(i+'a');
			ans[i]--;
		}
	}
	cout << "\n";
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

ans = ""
# path1
ans += "R" * dx + "U" * dy 

# path2
ans += "L" * dx + "D" * dy

# path3
ans += "L" + "U" * (dy+1) + "R" * (dx+1) + "D"

# path4
ans += "R" + "D" * (dy+1) + "L" * (dx+1) + "U"

print(ans)

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> rightMin(N + 1, N);
    int a, b;
    set<int> leftSet;
    REP(i, M)
    {
        cin >> a >> b;
        rightMin[a] = min(rightMin[a], b);
        leftSet.insert(a);
    }   
    
    vector<int> leftVec(leftSet.begin(), leftSet.end());
    sort(leftVec.begin(), leftVec.end());
    int ans = 0;
    int left = leftVec[0];
    int right = rightMin[left];
    for (int i = 1; i < leftVec.size(); ++i)
    {
        left = leftVec[i];                
        if (left < right)
        {
            if (rightMin[left] >= right) continue;
            else right = rightMin[left];
        }
        else
        {
            ans++;
            right = rightMin[left];
        }
    }
    ans++;

    cout << ans << endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
  string s, t;
  cin >> s >> t;

  int sLen = s.length();
  int tLen = t.length();

  int **dp = new int *[sLen + 1];
  for (int i = 0; i <= sLen; i++) {
    dp[i] = new int[tLen + 1];
  }

  for (int i = 0; i <= sLen; i++) {
    for (int j = 0; j <= tLen; j++) {
      dp[i][j] = 0;
    }
  }

  for (int i = 1; i <= sLen; i++) {
    for (int j = 1; j <= tLen; j++) {
      if (dp[i - 1][j] > dp[i][j - 1])
        dp[i][j] = dp[i - 1][j];
      else
        dp[i][j] = dp[i][j - 1];

      if (s[i - 1] == t[j - 1] and dp[i - 1][j - 1] + 1 > dp[i][j]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      }
    }
  }

  string ans = "";

  while (sLen > 0 and tLen > 0) {
    if (dp[sLen][tLen] == dp[sLen - 1][tLen])
      sLen--;
    else if (dp[sLen][tLen] == dp[sLen][tLen - 1])
      tLen--;
    else {
      sLen--;
      tLen--;
      ans = s[sLen] + ans;
    }
  }

  cout << ans << endl;
  for (int i = 0; i <= sLen; i++) {
    delete[] dp[i];
  }
  delete[] dp;

  return 0;
}


Measured memory_bytes: 35456
import java.util.Scanner;

public class Main {

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

		int answer=0;
		for(int i=0;i<n;i++) {
			if(onaji(s, n, i)>answer) {
				answer=onaji(s, n, i);
			}
		}

		System.out.print(answer);

	}

	public static int onaji(String s, int n, int a) {
		int kaesu=0;
		for(int i=0;i<a;i++){

			boolean modoru=true;
			for(int j=0;j<i;j++) {
				if(s.charAt(i)==s.charAt(j)) {
					modoru=false;
					break;
				}
			}
			if(modoru) {
				for(int j=a;j<n;j++) {
					if(s.charAt(i)==s.charAt(j)) {
						kaesu++;
						break;
					}
				}
			}
		}

		return kaesu;

	}

}


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

using vi = vector<int>;
using vl = vector<long long int>;
using vii = vector<vector<int>>;
using vll = vector<vector<long long int>>;
#define pb push_back;
#define mp make_pair;

vector<bool>vis;
vii a;

ll powM(ll a,ll b,ll m)
{
    ll ans=1;
    a%=m;
    while(b)
        {
            if(b&1)ans=ans*a%m;
            a=a*a%m;
            b>>=1;
        }
        return ans;
}

void dfs(vii a,ll x)
{
  vis[x]=true;
  for(int i=0;i<a[x].size();i++)
  {
    if(vis[a[x][i]]==false)
    {
      vis[a[x][i]]=true;
      dfs(a,a[x][i]);
    }
  }
  ll cnt=0;
 // for(int i=1;i<=n;i++)if(vis[i]==false)cnt++;
  //  return cnt;
}

int main(){
      ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.precision(2);
cout<<fixed;

int n,x,y;cin>>n>>x>>y;
vector<int>v[n+1];
vector<bool> vis(n+1,0);
vector<int>level(n+1,0);
for(int i=1;i<n;i++)
{
  v[i].push_back(i+1);
  v[i+1].push_back(i);
  
}
v[x].push_back(y);
v[y].push_back(x);

queue<int>q;
q.push(1);
while(!q.empty())
{
  int temp=q.front();
  q.pop();
  vis[temp]=true;
  for(int i=0;i<v[temp].size();i++)
  {
if(vis[v[temp][i]]==false)
{
  vis[v[temp][i]]=true;
  level[v[temp][i]]=level[temp]+1;
  q.push(v[temp][i]);
  }
}

}

map<int,int>m;
for(int i=1;i<n;i++)
{
  for(int j=i+1;j<=n;j++)
  {
    m[abs(level[i]-level[j])]++;
  }
}
//cout<<m[0]<<"\n";

for(int i=1;i<=n-1;i++)cout<<m[i]<<"\n";

return 0;


}
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

using vi = vector<int>;
using vl = vector<long long int>;
using vii = vector<vector<int>>;
using vll = vector<vector<long long int>>;
#define pb push_back;
#define mp make_pair;
ll powM(ll a,ll b,ll m)
{
    ll ans=1;
    a%=m;
    while(b)
        {
            if(b&1)ans=ans*a%m;
            a=a*a%m;
            b>>=1;
        }
        return ans;
}



int main(){
      ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.precision(2);
cout<<fixed;
int n;cin>>n;

set<string>m;
for(int i=0;i<n;i++)
{
  string s;
  cin>>s;
  m.insert(s);
}
cout<<m.size()<<"\n";

return 0;



}


Measured memory_bytes: 19200
//https://cs.stackexchange.com/questions/84426/find-a-node-with-maximum-distance-from-given-node-in-a-tree
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
//#include <ext/rope> //header with rope
//using namespace __gnu_cxx;
//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order tells index pr kon hai..
// order_by_key  tells ki us element se kitne strictly smaller element hai...
#define mod 1000000007
#define INF 1000000000000000000
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Senky_Bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
ll fact[1000007];
ll mdpower(ll a,ll b)
{
    ll res =1;
    while(b)
    {
        if(b&1) res = (res%mod*a%mod)%mod;
        b/=2;
        a = (a%mod*a%mod)%mod;
    }
    return res;
}
void factorial()
{
    fact[0]=1;
    for(int i=1;i<1000007;i++)
        fact[i] = (fact[i-1]%mod*i%mod)%mod;
}
ll inverse(ll a,ll b)
{
    return mdpower(a,b-2);
}
ll power(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1)
            res=(res*a);
        a=(a*a);
        b/=2;
    }
    return res;
}
int main()
{   
    Senky_Bansal
    IIIT_ALLAHABAD
     ll n;
        cin>>n;
        vector<ll>dp(3);
        for(int dy=0;dy<n;dy++)
        {
           vector<ll>new_dp(3,0);
           vector<ll>c(3);
           for(int i=0;i<3;i++)
            cin>>c[i];
        for(int i=0;i<3;i++)
            for(int j=0;j<3;j++)
                if(i!=j)
                new_dp[j]=max(new_dp[j],dp[i]+c[j]);
            dp=new_dp;
        }
        cout<<max({dp[0],dp[1],dp[2]})<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    std::string s;
    std::cin >> s;

    int max = 0;
    int count = 0;
    bool flag = false;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' && flag == false) {
            flag = true;
            count = i;
        }
        if (s[i] == 'Z' && flag == true) {
            int ans = i - count;
            max = ans;
        }
    }

    std::cout << max + 1 << std::endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    if(X == 3 || X == 5 || X == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long N, std::vector<long long> L){
    sort(L.begin(),L.end());

    lli cnt=0;
    REP(a,0,N)REP(b,a+1,N)REP(c,b+1,N){
        if(L[a]<(L[b]+L[c]) && L[b]<(L[c]+L[a]) && L[c]<(L[a]+L[b]))cnt++;
    }
    cout<<cnt<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    func(N, std::move(L));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define FUP(i, a, b) for(int i = a; i <= b; i++)
#define FDOWN(i, a, b) for(int i = a; i >= b; i--)
#define MS(a, b) memset(a, b, sizeof(a))
#define ALL(v) v.begin(), v.end()
#define CIN(a) cin >> a;
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a
#define COUT2(a, b) cout << a << ' ' << b
#define COUT3(a, b, c) cout << a << ' ' << b << ' ' << c
#define ENDL cout << '\n'
int dy[4] = { -1, 1, 0, 0 };
int dx[4] = { 0, 0, 1, -1 };

int R, C, K;
ll arr[3001][3001];
ll dp[3001][3001][4];

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

	MS(arr, 0);
	MS(dp, -1);
	CIN3(R, C, K);
	while (K--)
	{
		int a, b, c;
		CIN3(a, b, c);
		arr[a][b] = c;
	}
	FUP(i, 1, R)
	{
		FUP(j, 1, C)
		{
			dp[i][j][0] = 0;
			FDOWN(k, 3, 1)
			{
				if (dp[i][j][k - 1] != -1) dp[i][j][k] = max(dp[i][j][k], dp[i][j][k - 1] + arr[i][j]);
			}
			if (j != 1)
			{
				FDOWN(k, 3, 1)
				{
					if (dp[i][j - 1][k] != -1) dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k]);
				}
				FDOWN(k, 3, 1)
				{
					if (dp[i][j - 1][k - 1] != -1) dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k - 1] + arr[i][j]);
				}
			}
			if (i != 1)
			{
				FDOWN(k, 3, 1) dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][k]);
				dp[i][j][1] = max(dp[i][j][1], dp[i][j][0] + arr[i][j]);
			}
		}
	}
	ll answer = 0;
	FUP(i, 0, 3)
	{
		answer = max(answer, dp[R][C][i]);
	}
	COUT(answer);

	return 0;
}

Measured memory_bytes: 355444
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int lodging_all, lodging_first, price_first, price_second;
    cin >> lodging_all >> lodging_first >> price_first >> price_second;
  int price_all;
  if (lodging_all >= lodging_first){
    int lodging_second = lodging_all - lodging_first;
    price_all = lodging_first * price_first + lodging_second * price_second;
  }
  else {
    price_all = lodging_all * price_first;
  }
  cout << price_all << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

    if(A+B>C+D){
        cout << "Left";
    }else if(A+B==C+D){
        cout << "Balanced";
    }else{
        cout << "Right";
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

// https://atcoder.jp/contests/abc172/tasks/abc172_b

class Main {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static String S, T;
    static int result = 0;

    public static void main(String[] args) throws Exception {
        S = br.readLine();
        T = br.readLine();
        
        for(int i = 0; i < S.length(); i++){
            char s = S.charAt(i);
            char t = T.charAt(i);
           if(s != t){
                result++;
           }
        }
        System.out.println(result);
    }

}

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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


N, M = readnums()

'''
N:M = 1:2が理想
N + x: M -2x = 1:2
2N+2x = M-2x
M-2N=4x
'''

if M >= N * 2:
    x = (M - 2 * N) // 4
    print(N + x)
else:
    print(M // 2)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int a,b; cin>>a>>b;
	int h=a+b;
	if(!(h&1)) cout<<(h/2);
	else cout<<"IMPOSSIBLE";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <stdio.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;
int cti(char c) {
  switch (c) {
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default: return -1;
  }
}
int main(void) {
    int A, B,L;
    string S;
    char str[100];
    cin>>A>>B>>S;
    L = (int)S.size();
    if((int)S.size()!=(A+B+1)){
      cout<<"No"<<endl;
      return 0;
    }
    S.copy(str,L);

    for(int i=0;i<L;i++){
      if((i==A)&&(str[i] != '-')){
        cout<<"No"<<endl;
        return 0;
      }
      if((i!=A)&&(cti(str[i])==-1)){
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

int main() {
	int H, W;
	cin >> H >> W;
	map<int, int>s;
	multiset<int>values;

	for (int i = 0; i < W; ++i) {
		s[i] = i;
	}
	for (int i = 0; i < W; ++i) {
		values.insert(0);
	}
	for (int i = 0; i < H; ++i) {
		int l, r;
		cin >> l >> r;
		l--;
		auto it = s.lower_bound(l);
		int mr = -1;
		while (it != s.end() && it->first <= r) {
			mr = max(mr, it->second);
			int x = it->first - it->second;
			values.erase(values.find(x));
			s.erase(it++);
		}
		if ((-1 != mr) && (r < W)) {
			values.insert(r - mr);
			s[r] = mr;
		}
		if (0 == values.size()) {
			cout << -1 <<endl;
		}
		else {
			cout << *values.begin() + (i + 1) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 22360
def read_data():
  n=input()
  x=[]
  for i in range(10):
    x.append(map(int,raw_input().split()))
  return n, x
 
def is_area3(x,y):
  if x>7 or y>5: return False
  for dx in [0,1,2,1,0]:
    A = P[y][x-dx:x+dx+1]
    if A.count(0)>0: return False
    y += 1
  return True
       
def is_area2(x,y):
  if x>7 or y>7: return False
  for dy in [0,1,2]:
    A = P[y+dy][x:x+3]
    if A.count(0)>0: return False
  return True
 
def is_area1(x,y):
  if x>8 or y>7: return False
  for dx in [0, 1, 0]:
    A = P[y][x-dx:x+dx+1]
    if A.count(0)>0: return False
    y += 1
  return True
 
def ink(x,y,s,m):
  global P
  dx = [0,1,-1,0,0,1,1,-1,-1,2,-2,0,0]
  dy = [0,0,-0,1,-1,1,-1,1,-1,0,0,2,-2]
  for i in range([5,9,13][s-1]):
    P[y+dy[i]][x+dx[i]]+=m
  return
 
drops, P = read_data()
M=[]
i=-1
step =3
while i<99:
  i+=1
  y = i / 10
  x = i % 10
  if P[y][x]==0: continue
 
  if step==3:
    while is_area3(x,y):
      M.append([x,y,3])
      ink(x,y+2,3,-1)
    if P[y][x]==0:
      step = 3
      continue
    else: step = 2
 
  if step==2:
    while is_area2(x,y):
      M.append([x,y,2])
      ink(x+1,y+1,2,-1)
    if P[y][x]==0:
      step = 3
      continue
    else: step = 1
 
  if step==1:
    while is_area1(x,y):
      M.append([x,y,1])
      ink(x,y+1,1,-1)
    if P[y][x]==0:
      step = 3
      continue
    else: step = 0
 
  dx=0
  dy=1
  if step==0 and len(M)>0:
    x,y,tmp = M.pop()
    if tmp==3: dy=2
    elif tmp==2: dx=1
    ink(x+dx,y+dy,tmp,1)
    i = y*10+x-1
    step = tmp-1
  else: break
if drops <=12 and len(M)==drops:
  for x,y,s in M:
    dx=0
    dy=1
    if s==3: dy=2
    elif s==2: dx=1
    print x+dx,y+dy,s

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

int main() {
    int t;
    vector<int> p;
    REP(i,3){
        cin >> t;
        p.push_back(t);
    }
    sort(p.begin(),p.end());
    cout << p[0]+p[1] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long Y = sc.nextLong();
		sc.close();
		long t = X;
		int cnt = 0;
		while(t <= Y) {
			t *= 2;
			cnt++;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 22100
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  int N;
  string S, T;
  string answer = "";
  cin >> N;
  cin >> S >> T;
  
  for(int i=0;i<N;i++){
    //cout << S[i] << endl;
    answer = answer + S[i] + T[i];
  }
  
  cout << answer << endl;
  
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def f(n):
    v = 0
    for i in range(60):
        if 1 << i & n:
            v += (-2)**i
    return v

# @mt
def slv(N):
    v = N
    for i in range(60):
        b = 1 if 1 << i & v > 0 else 0
        if b and i % 2 != 0:
            v += 1 << (i+1)

    return v


def main():
    N = read_int()
    print(bin(slv(N))[2:])



if __name__ == '__main__':
    main()


Measured memory_bytes: 7240
class dset:
    def __init__(self,n):
        self.par = [-1]*n

    def size(self,n):
        return -self.par[self.root(n)]

    def root(self,n):
        if self.par[n]<0:
            return n
        else:
            self.par[n] = self.root(self.par[n])
            return self.par[n]

    def same(self, a, b):
        return self.root(a) == self.root(b)

    def __link__(self,a,b):
        if a == b:
            return 
        
        if self.size(a) < self.size(b):
            a,b = b,a
        
        self.par[a] += self.par[b]
        self.par[b] = a

    def unite(self,a,b):
        self.__link__(
            self.root(a)
            ,self.root(b)
            )


def main():
    n, m = map(int, input().split() ) 


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

    ds = dset(n)

    ans = [0]*m
    ans[-1] = n*(n-1)//2
    for i in range(m-1,0,-1):
        ans[i-1] = ans[i]

        a,b = ins[i]
        a-=1
        b-=1

#        print(ins[i])
       # print( (ds.root(a),ds.root(b)) ) 
        if not ds.same(a,b):
            x = ds.size(a)
            y = ds.size(b)
            #print((x,y))
            ans[i-1] -= x*y
            ds.unite(a,b)

    for e in ans:
        print(e)

if __name__ == '__main__':
    main()

Measured memory_bytes: 34612
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]

x, y = map(int, input().split())

flag_x = 0
flag_y = 0

if x in A:
    flag_x = 1
elif x in B:
    flag_x = 2

if y in A:
    flag_y = 1
elif y in B:
    flag_y = 2
    
print('Yes' if flag_x == flag_y else 'No')


Measured memory_bytes: 38256
let rec repl () =
  let s = read_line () in
  if s = "0" then ()
  else begin
    let sum = ref 0 in
    String.iter (fun c -> sum := !sum + (Char.code c) - (Char.code '0')) s;
    Printf.printf "%d\n" !sum;
    repl ()
  end

let () =
  try repl () with End_of_file -> ()

Measured memory_bytes: 2296
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int num = 0;
int vis[55][55];
int h, w;
string s[55];

void dfs(int x, int y){
	if(vis[x][y]) return;
	vis[x][y] = 1;
	num++;
	if((x + 1) < h && s[x + 1][y] == '#') dfs(x + 1, y);
	if((y + 1) < w && s[x][y + 1] == '#') dfs(x, y + 1);
	if((x - 1) >= 0 && s[x - 1][y] == '#') dfs(x - 1, y);
	if((y - 1) >= 0 && s[x][y - 1] == '#') dfs(x, y - 1);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> h >> w;
	int cnt = 0;
	rep(i, h) cin >> s[i];
	rep(i, h) rep(j, w) cnt += (s[i][j] == '#');
	int tot = 0;
	rep(i, h) rep(j, w) if(s[i][j] == '#' && !vis[i][j]){
		dfs(i, j);
		if(num > 1) tot += num;
		else{
			cout << "No" << endl;
			return 0;
		}
		num = 0;
	}
	cout << "Yes" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 512
#include <iostream>
#define INT_MAX 1000000
#include <cstring>
#include <unordered_map>
#include <vector>
using namespace std;

int main()
{
  int n, w;
  cin >> n >> w;
  vector<int> val(n, 0);
  vector<int> weights(n, 0);
  vector<vector<long>> map(n+1, vector<long>(w+1, 0L));
  for(int i=0; i<n; i++)
    cin >> weights[i] >> val[i];
  for(int i=1; i<n+1; i++)
  {
    for(int j=1; j<w+1; j++)
    {
      if (weights[i-1] <= j)
      	map[i][j] = max(val[i-1]+map[i-1][j-weights[i-1]], map[i-1][j]);
      else
        map[i][j] =  map[i-1][j];
    }
  }
  cout<<map[n][w];
  return 0;
}

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


int main(){


    int x, a, b;

    char k;


    cin >> x >> a >> b;


    if( abs( a - x ) > abs( b - x ) ) k = 'B';

    else k = 'A';


    cout << k << endl;


    return 0;

    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int n, x, t;
	cin >> n >> x >> t;	
	cout << (n+x-1)/x*t << endl;

}





Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	if (a[a.size()-1]=='2'||a[a.size()-1]=='4'||a[a.size()-1]=='5'||a[a.size()-1]=='7'||a[a.size()-1]=='9')
		cout<<"hon";
	else if (a[a.size()-1]=='0'||a[a.size()-1]=='1'||a[a.size()-1]=='6'||a[a.size()-1]=='8')
		cout<<"pon";
	else
		cout<<"bon";
	return 0;
}


Measured memory_bytes: 3568
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */

#include <bits/stdc++.h>
//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class ACantWaitForHoliday {
    const vector<string> DAYS = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
public:
    void solve(std::istream &in, std::ostream &out) {
        string S;
        in >> S;
        int res = 7 - (find(DAYS.begin(), DAYS.end(), S) - DAYS.begin());
        out << res << "\n";
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    ACantWaitForHoliday solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import sys
s = raw_input()
t = raw_input()

ls = len(s)
lt = len(t)
if ls < lt :
	print 'UNRESTORABLE'
	sys.exit()

for i in range(ls-lt,-1,-1):
	count = 0
	for j in range(lt):
		if s[i+j] == '?' or s[i+j] == t[j]:
			count += 1
		else :
			break
	if count == lt:

		print s[:i].replace('?','a')+t+s[i+lt:].replace('?','a')
		sys.exit()

print 'UNRESTORABLE'


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k;
int a[N];
ll ans;

int main() {
    cin >> n >> k;
    m = n;
    ans = LLONG_MAX;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (m == n && a[i] >= 0) {
            m = i;
        }
    }
    for (int i = 0; i <= min(k, m); ++i) {
        if (m + k - i - 1 >= n) continue;
        ll lv = 0;
        ll rv = 0;
        if (i)
            lv = -a[m - i];
        if (k - i)
            rv = a[m + k - i - 1];
        // cout << i << ' ' << lv << ' ' << rv << endl;
        ans = min(ans, min(lv, rv) * 2 + max(lv, rv));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3940