akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  string s;
  cin>>s;
  vi x(n);
  rep(i,n) x[i] = s[i]-'A';
  vvi to(n);
  vvi d(n,vi(2));
  rep(i,m) {
    int a,b;
    scanf("%d%d",&a,&b);
    --a; --b;
    to[b].pb(a);
    d[a][x[b]]++;
    to[a].pb(b);
    d[b][x[a]]++;
  }
  queue<int> q;
  vi used(n);
  rep(i,n) {
    if (d[i][0] && d[i][1]) continue;
    q.push(i);
    used[i] = 1;
  }
  while (sz(q)) {
    int v = q.front(); q.pop();
    for (int u : to[v]) {
      d[u][x[v]]--;
      if (d[u][x[v]] == 0 && !used[u]) {
        q.push(u);
        used[u] = 1;
      }
    }
  }
  rep(i,n) {
    if (used[i]) continue;
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}






















Measured memory_bytes: 22532
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const double EPS = 1e-10;

const int v=10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    int d[v][v];
    for(int i=0;i<v;i++)for(int j=0;j<v;j++){
        if(i==j)d[i][j]=0;
        else d[i][j]=INF;
    }
    int c[v][v];
    for(int i=0;i<v;i++)for(int j=0;j<v;j++){
        cin>>c[i][j];
        d[i][j]=min(d[i][j],c[i][j]);
    }
    for(int k=0;k<v;k++){
        for(int i=0;i<v;i++){
            for(int j=0;j<v;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    int ans=0;
    for(int i=0,a;i<h;i++)for(int j=0;j<w;j++){
        cin>>a;
        if(a==-1)continue;
        ans+=d[a][1];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
using ll = long long;
using ld = long double;
const int mxn = 505;
bool exist[mxn][mxn];
int dist[mxn][mxn], N;

void bfs(int row, int col) {
	vector<int> d{-1, 1};
	queue<pair<int, int> > Queue;
	Queue.push(make_pair(row, col));
	while(!Queue.empty()) {
		int r = Queue.front().first, c = Queue.front().second;
		Queue.pop();
		for(int drow: d) {
			int new_row = r+drow;
			if(new_row>=1 and new_row<=N) {
				int ndist = dist[r][c];
				if(exist[r][c]) ndist++;
				if(ndist<dist[new_row][c]) {
					dist[new_row][c] = ndist;
					Queue.push(make_pair(new_row, c));
				}
			}
		}
		for(int dcol:d) {
			int new_col = c+dcol;
			if(new_col>=1 and new_col<=N) {
				int ndist = dist[r][c];
				if(exist[r][c]) ndist++;
				if(ndist<dist[r][new_col]) {
					dist[r][new_col] = ndist;
					Queue.push(make_pair(r, new_col));
				}
			}
		}
	}
}

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

	cin>>N;
	for(int i=1; i<=N; i++)
		for(int j=1; j<=N; j++) exist[i][j] = true;

	vector<int> order;
	for(int i=1; i<=N*N; i++) {
		int x; cin>>x;
		order.push_back(x);
	}

	for(int i=1; i<=N; i++)
		for(int j=1; j<=N; j++) {
			dist[i][j] = min(min(i-1, j-1), min(N-i, N-j));
		}

	int ans = 0;
	for(auto x:order) {
		int row = (x%N==0)? x/N:x/N+1;
		int col = (x%N==0)? N:x%N;
		ans+=dist[row][col];
		exist[row][col] = false;
		bfs(row, col);
	}

	cout << ans << '\n';
	return 0;

}

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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

ll max(ll a, ll b)
{
	return (a>b)? a: b;
}
bool v[1000000000];

int main()
{
	ll n, w;
	cin >> n >> w;
	ll wt[n], v[n];
	for(int i=0;i<n;i++)
		cin >> wt[i] >> v[i];
	ll pos[n+1][w+1];
	memset(pos, 0, sizeof(pos));
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			if(j - wt[i-1] >=0) pos[i][j] = max(pos[i-1][j-wt[i-1]] + v[i-1], pos[i][j]);
			pos[i][j] = max(pos[i][j], pos[i-1][j]);
			//debug(i, j, pos[i][j]);
		}
	}
	ll m = 0;
	for(int i=w;i>=0;i--)
	{
		m = max(m, pos[n][i]);
	}
	cout << m << "\n";

	return 0;
}

Measured memory_bytes: 79104
x, n = map(int, input().split())
p = list(map(int, input().split()))
l = [i for i in range(0, 102)]
z = list(set(p)^set(l))
y = []
for i in z:
    y.append(abs(x-i))
z2 = sorted(y)
ans1 = x-z2[0]
ans2 = x+z2[0]
m = min(ans1, ans2)
M = max(ans1, ans2)
if m in z:
    print(m)
else:
    print(M)

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define SET(A,VAL) memset(A, VAL, sizeof(A))
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int MAX = 1e6+8;
const int sz = 1e5+5;
void f_io(){
    IOS;
}
int32_t main(){
    f_io();
    int t = 1;
    //cin>>t;
    while(t--){
        int n,m; cin >> n >> m;
        int fans = min(n,m/2);
        n -= fans; m -= fans*2;
        if(!n && m >= 4) fans += m/4;
        cout << fans << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string S; std::cin >> S;

  int ans = 0;
  char s = S[0];
  for(int i=1; i<sz(S); i++) {
    if ( s != S[i] ) {
      ans++; s = S[i];
    }
  }
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP priority_queue
#define heap(T) priority_queue<T,vector<T>,greater<T> >
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
const int BufferSize=1<<25;
char buffer[BufferSize],*Bufferhead,*Buffertail;
int Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T> inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){c=Getchar();rev|=c=='-';if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	x=rev?-x:x;
	return 1;
}
template<class T>inline void print(T x,const char c){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[10];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------------head--------------------------------------

const int inf=0x3f3f3f3f;
const int N=100005,M=100005,mod=1e9+7;
inline void ch(int &x,int y){x=(x+y)%mod;}
inline int exp(int x,int y,int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,dp[2][33];

int main(){
	scanf("%d",&n);
	clr(dp,0x3f);
	dp[0][0]=0;
	for(int i=1;i<=n;i++){
		int x,maxx=0;scanf("%d",&x);
		while((1<<maxx)<x) maxx++;
		int L=maxx,R=maxx;
		if((1<<maxx)!=x) L--;
		//printf("%d %d\n",L,R);
		for(int j=0;j<=30;j++)
			dp[i&1][j]=inf;
		for(int j=0;j<=30;j++){
			gmin(dp[i&1][R],dp[i-1&1][j]+maxx-min(L,j));
			gmin(dp[i&1][L],dp[i-1&1][j]+maxx-min(R,j));
		}
	}
	int ans=inf;
	for(int i=0;i<=30;i++)
		gmin(ans,dp[n&1][i]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  ll H,W; cin >> H >> W;
  if(H==1 || W==1){cout << 1 << endl;}
  else{cout << (ll)(H*W+1)/2 << endl;}

  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define MAXN 4000009
#define MAXM 4000009
#define MOD 1000000007
#define INF 1000000009
#define FOR(x,n) for(int x=0; x<n; x++)
#define FOR1e(x,n) for(int x=1; x<=n; x++)
typedef pair<int, int> ii;
typedef long long ll;

const double PI = acos(-1.0);
int x[109], y[109];

int main() {
	int n;
	scanf("%d", &n);
	FOR(i, n) scanf("%d %d", &x[i], &y[i]);
	FOR(i, n) {
		double st1 = 0, en1 = PI, st2 = -PI, en2 = 0;
		
		for (int j = 0; j < n; j++) {
			if (i == j) continue;
			double dx = x[j]-x[i], dy = y[j]-y[i];

			if (dx == 0) {
				if (dy > 0) { st1 = max(st1, PI); }
				else st2 = max(st2, 0.0);
			} else if (dy == 0) {
				if (dx > 0) { st1 = max(st1, PI/2); en2 = min(en2, -PI/2); }
				else { en1 = min(en1, PI/2); st2 = max(st2, -PI/2); }
			} else {
				double factor = dx/dy; // y <= / >= -factor*x
				if (factor > 0 && dy < 0) { // >=
					double angle = PI-atan(factor);
					////cout << "Angle " << angle << endl;
					en1 = min(en1, angle);
					st2 = max(st2, angle - PI);
				}
				if (factor > 0 && dy > 0) { // >=
					double angle = PI-atan(factor);
					//cout << "Angle " << angle << endl;
					en2 = min(en2, angle-PI);
					st1 = max(st1,  angle);
				}
				if (factor < 0 && dy < 0) { // >=
					double angle = atan(-factor);
					//cout << "Angle " << angle << endl;
					st1 = max(st1, angle);
					en2 = min(en2, angle - PI);
				}
				if (factor < 0 && dy > 0) { // >=
					double angle = atan(-factor);
					//cout << "Angle " << angle << endl;
					st2 = max(st2, angle-PI);
					en1 = min(en1,  angle);
				}
			}
		//	cout << i << "  " << j << endl;
		//	cout << st1 << "  " << en1 << endl;
		//	cout << st2 << "  " << en2 << endl;
		//	cout << "------" << endl;
		}

		printf("%.10lf\n", max((en1-st1)/(2*PI), 0.0) + max((en2-st2)/(2*PI), 0.0));
	}
	return 0;
}

Measured memory_bytes: 256
n, *a = map(int, open(0).read().split())
# 状態1: iとi+1が1違う
# 状態2: iとi+1が同じ
# これ以外のiとi+1の関係があったら構築できない

# 状態1ではi+1を作る過程でiも作れる。
# 状態2ではi+1を作った後にiを作る必要がある。
# 後ろから見てa[i] - 1 == a[i - 1]となってる数を数えなければおｋ

# check
if a[0] != 0:
	print(-1)
	exit()
for i in range(n - 1):
	if a[i + 1] - a[i] > 1:
		print(-1)
		exit()

# count
i = n - 1
ans = 0
while i > 0:
	ans += a[i]
	while i > 0 and a[i] - 1 == a[i - 1]:
		i -= 1
	i -= 1
print(ans)


Measured memory_bytes: 31808
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<ll> x(X), y(Y), z(Z), xy, xyz;
	for(int i = 0; i < X; i ++){
		cin >> x[i];
	}
	for(int i = 0; i < Y; i ++){
		cin >> y[i];
	}
	for(int i = 0; i < Z; i ++){
		cin >> z[i];
	}
	for(int i = 0; i < X; i ++){
		for(int j = 0; j < Y; j ++){
			xy.pb(x[i] + y[j]);
		}
	}
	sort(all(xy), greater<ll>());
	for(int i = 0; i < min((int)xy.size(), K); i ++){
		for(int j = 0; j < Z; j ++){
			xyz.pb(xy[i] + z[j]);
		}
	}
	sort(all(xyz), greater<ll>());
	for(int i = 0; i < K; i ++){
		cout << xyz[i] << endl;
	}

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

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

  if (a+b+c >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
  
  return 0;
}

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

typedef long long lli;
typedef complex<lli> point;

lli dot(point a,point b){
	return (a*conj(b)).real();
}

lli cross(point a,point b){
	return (a*conj(b)).imag();
}

int main(void){
	lli x,y;
	int q;
	cin>>q;
	while(q--){
		cin>>x>>y;
		point p0(x,y);
		cin>>x>>y;
		point p1(x,y);
		cin>>x>>y;
		point p2(x,y);
		cin>>x>>y;
		point p3(x,y);
		point l1=p1-p0;
		point l2=p3-p2;
		if(cross(l1,l2)==0)cout<<"2"<<endl;
		else if(dot(l1,l2)==0)cout<<"1"<<endl;
		else cout<<"0"<<endl;
	}
	return 0;
}

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

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(double.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];
            Console.WriteLine(a <= 2 * b ? 0 : a - 2 * b);
        }
    }
}


Measured memory_bytes: 28092
// This file is a "Hello, world!" in C# language by Mono for wandbox.
using System;

namespace Wandbox
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[2]);
            if(str[1] == "+")
                Console.WriteLine(a + b);
            else
                Console.WriteLine(a - b);
        }
    }
}

// Mono references:
//   http://www.mono-project.com/

// C# language references:
//   https://msdn.microsoft.com/library/618ayhy6.aspx

Measured memory_bytes: 13140
import sys

def main():
    # [int(i) for i in sys.stdin.readline().strip().split()]
    s = sys.stdin.readline().strip()
    set(s)
    if len(set(s)) == 2:
        ret = 'Yes'
        for i in s:
            if s.count(i) != 2:
                ret = 'No'
    else:
        ret = 'No'
    return ret
print(main())

Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <limits.h>
#include <map>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

int main() {
    int n;
    cin>>n;
    if(n%10==7||(n/10)%10==7||n/100==7) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

int main(void)
{
    int d, g;
    cin >> d >> g;
    vector<ll> kazu(d), bonus(d);
    rep(i, 0, d) cin >> kazu[i] >> bonus[i];
    ll ans = INF;
    rep(i, 0, 1 << d)
    {
        vector<ll> tmp;
        vector<ll> num = kazu;
        rep(j, 0, d) if (i >> j & 1) tmp.push_back(j);
        int score = 0;
        ll qst = 0;
        for (auto j : tmp)
            score += 100 * (j + 1) * kazu[j] + bonus[j], qst += kazu[j], num[j] = 0;
        while (score < g)
        {
            int idx;
            rep(j, 0, d)
            {
                if (num[d - 1 - j] > 0)
                {
                    idx = d - 1 - j;
                    break;
                }
            }
            score += 100 * (idx + 1), qst++, num[idx]--;
            if (MX(num) == 0)
                break;
        }
        ans = min(ans, qst);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

int main()
{
    /* input */
    char str[200001];
    char result[200001];
    scanf( "%s", str );

    /* process */
    int length = std::strlen(str);
    if ( str[0] == '?' ) {
        result[0] = 'D';
    } else {
        result[0] = str[0];
    }
    if ( str[length-1] == '?' ) {
        result[length-1] = 'D';
    } else {
        result[length-1] = str[length-1];
    }
    result[length] = '\0';
    for ( int i=1; i<length-1; i++ ) {
        if ( str[i] == '?' ) {
            result[i] = 'D';
        } else {
            result[i] = str[i];
        }
    }

    /* output */
    printf( "%s\n", result );

    return 0;
}


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

int main() {
	int n;	string s;	cin >> n >> s;
  	ll r = 0, g = 0, b = 0;

//  	cout << b << endl;

  	rep(i,n){
    	if(s.at(i) == 'R') r++;
    	if(s.at(i) == 'G') g++;
    	if(s.at(i) == 'B') b++;
    }
  	
  	ll u = r*g*b;
//  	cout << u << endl;
  	ll cnt = 0;	
  	for(int i = 0; i < n; i++){
    	for(int j = i+1; j < n; j++){
          	if (s.at(i) == s.at(j)) continue;
        	int k = 2*j - i;
          	if(k >= n  || s.at(j) == s.at(k) || s.at(i) == s.at(k)) continue;
          	cnt++;
        }
    }
  	cout << (ll)u - cnt << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N,ans=0;
  cin>>N;
  vector<int>A(N),B(N),C(N-1);
  REP(i,N)cin>>A[i];
  REP(i,N){
    int b;
    cin>>b;
    ans+=b;
  }
  REP(i,N-1)cin>>C[i];

  REP(i,N-1){
    if(A[i]+1==A[i+1]){
      ans+=C[A[i]-1];
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 100000007
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)
#define ll long long
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
ll i,j;
ll h,w,k;
ll count(vector<vector<char>> &v, int r, int c)
{
	ll f = 0;
	for ( i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			if ((r & (1 << i)) && (c & (1 << j)) && v[i][j] == '#')
				f++;
	return f;
}
int main()
{IOS;
int t;
t=1;
while(t--)
{ll c=0;
    cin >>h>> w >> k;
	vector<vector<char>> v(h, vector<char>(w, 0));
	for (i = 0; i < h; i++)
		{for ( j = 0; j < w; j++)
			cin >> v[i][j];
        }
	for (int i1 = 0; i1 < (1 << h); i1++)
		for (int j1 = 0; j1 < (1 << w); j1++)
			if (count(v, i1, j1) == k)
				c++;
	cout << c;
}
return 0;}



Measured memory_bytes: 3632
#include<iostream>
#include<array>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
    
    array<int, 3> a;
    int cost = 0;

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

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

    for(int i = 0; i < 3 - 1; i++){
        cost += abs(a[i + 1] - a[i]);
    }

    cout << cost << endl;
    
    return 0;
}

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

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

    if ( s == "Sunny" ) {
        cout << "Cloudy" << endl;
    }
    else if ( s == "Cloudy" ) {
        cout << "Rainy" << endl;
    }
    else if ( s == "Rainy" ) {
        cout << "Sunny" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,m;
  cin>>n>>m;
  int a=n+m;
  if(a>=24) a-=24;
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define M 100005
#define N -1

struct Node{ int p, l, r;};
struct Node t[M];
int n, H, d[M];

int Depth(int u){
  int x = 0;
  for(; t[u].p != N ;x++) u = t[u].p;
  return x;
}

void print(int u){
  int i, c;
  printf("node %d: ", u);
  printf("parent = %d, ", t[u].p);
  printf("depth = %d, ", d[u]);

  if ( t[u].p == N ) printf("root, ");
  else if ( t[u].l == N ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0, c = t[u].l; c != N; i++, c = t[c].r){
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

main(){
  int i, j, s, v, c, l;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) t[i].p = t[i].l = t[i].r = N;

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &s);
    for ( j = 0; j < s; j++ ){
      scanf("%d", &c);
      if ( j == 0 ) t[v].l = c;
      else t[l].r = c;
      l = c;
      t[c].p = v;
    }
  }

  H = 0;
  for ( i = 0; i < n; i++ ){
    d[i] = Depth(i);
    if ( d[i] > H ) H = d[i];
  }

  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}



Measured memory_bytes: 3292
N = int(input())
S = {}

for i in range(N):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 0

S = sorted(S.items(), key=lambda x: (-x[1], x[0]))
n = S[0][1]
for s in S:
    if s[1] != n:
        break
    print(s[0])


Measured memory_bytes: 112600
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long i64;
typedef pair<i64,i64> P;

int Lower(vector<i64>& a, vector<int>& index ,int l,int r,i64 key)
{
    while(r - l > 1)
    {
        int m = (l + r) / 2;
        if(a[index[m]] >= key)
        {
            r = m;
        }
        else
        {
            l = m;
        }
    }
    return r;
}

vector<int> LIS(vector<i64>& a)
{
    if(a.size() == 0) return vector<int>();

    vector<int> tail;
    vector<int> rev(a.size(),-1);
    tail.push_back(0);

    for(int i = 1;i < a.size();i++)
    {
        if(a[i] < a[tail[0]])
        {
            tail[0] = i;
        }
        else if(a[i] > a[tail.back()])
        {
            tail.push_back(i);
        }
        else
        {
            tail[Lower(a,tail,-1,tail.size() - 1,a[i])] = i;           
        }
    }

    return tail;
}

#include <iostream>

int main()
{
    int n;
    cin >> n;
    vector<i64> a;
 
    for(int i = 1;i <= n;i++)
    {
        int t;
        cin >> t;
        a.push_back(t);
    }

    cout << LIS(a).size() << endl;
}




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

int main()
{
	std::string taro, hanako;
	int n;
	int p1=0, p2=0;
	std::cin >> n;
	for (int i=0; i<n; i++) {
		std::cin >> taro >> hanako;
		int comp = taro.compare(hanako);
		if (comp > 0) p1 += 3;
		else if (comp < 0) p2 += 3;
		else { p1++; p2++; }
	}
	std::cout << p1 << " " << p2 << std::endl;
		
	return 0;
}




Measured memory_bytes: 3212
#include <stdio.h>
#include <stdlib.h>
 
#define MAX  14
#define MAX2 12
 
char paper[MAX+1][MAX+1];
 
int main()
{
    int x, y, size;
    int cnt, max, d;
 
    for (x = 0; x < MAX; x++) for (y = 0; y < MAX; y++) paper[x][y] = 0;
 
    while (scanf("%d,%d,%d", &x, &y, &size) == 3) {
        x += 2, y += 2;
        if (size >= 3) {
            paper[x - 2][y]++;
            paper[x + 2][y]++;
            paper[x]    [y - 2]++;
            paper[x]    [y + 2]++;
        }
        if (size >= 2) {
            paper[x - 1][y - 1]++;
            paper[x - 1][y + 1]++;
            paper[x + 1][y - 1]++;
            paper[x + 1][y + 1]++;
        }
        paper[x]    [y]++;
        paper[x - 1][y]++;
        paper[x + 1][y]++;
        paper[x]    [y - 1]++;
        paper[x]    [y + 1]++;
    }
    cnt = 0, max = 0;
    for (x = 2; x < MAX2; x++) for (y = 2; y < MAX2; y++) {
        d = paper[x][y];
        if (d == 0) cnt++;
        if (d > max) max = d;
    }
    printf("%d\n%d\n", cnt, max);
    return 0;
}


Measured memory_bytes: 2100
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = Array(n) { sc.nextLong() }.toMutableList()
    val m = (n + 1) / 2
    val left = Array(m + 1) { 0L }
    val right = Array(m + 1) { 0L }
    for (i in 0 until m) {
        left[i + 1] = left[i] + a[2 * i]
    }
    for (i in m - 1 downTo 0) {
        right[i] = right[i + 1] + if (n % 2 == 1 && i == m - 1) a[n - 1] else a[2 * i + 1]
    }
    if (n % 2 == 0) {
        var max = Long.MIN_VALUE
        for (i in 0..m) {
            val v = left[i] + right[i]
            max = Math.max(max, v)
        }
        println(max)
    } else {
        a.add(a.last())
        val maxL = Array(m + 1) { 0L }
        val maxR = Array(m + 1) { 0L }
        for (i in 0 until m) {
            maxL[i + 1] = Math.max(maxL[i] + a[2 * i + 1], left[i + 1])
        }
        for (i in m - 1 downTo 0) {
            maxR[i] = maxR[i + 1] + a[2 * i]
        }
        var max = Long.MIN_VALUE
        for (i in 0 until m) {
            val v = maxL[i] + maxR[i + 1]
            max = Math.max(max, v)
        }
        println(max)
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 69356
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,w,wei[105]={},val[105]={},dp[105][105][350]={},W,ans=0;
  cin >> n >> w;
  for(int i=0; i<n; i++) {
    cin >> wei[i] >> val[i];
  }
  W=wei[0];
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      for(int k=0; k<350; k++) {
        dp[i][j][k]=-1;
      }
    }
  }
  dp[0][0][0]=0;
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      for(int k=0; k<350; k++) {
        if(dp[i][j][k]!=-1) {
          dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k]);
          ll next=k+wei[i]-W;
          dp[i+1][j+1][next]=max(dp[i+1][j+1][next],dp[i][j][k]+val[i]);
          if(next+(j+1)*W<=w) {
            ans=max(ans,dp[i+1][j+1][next]);
          }
        }
      }
    }
  }
  cout << ans << endl;
}




Measured memory_bytes: 30464
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int INF = numeric_limits<int>::max() / 2;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
	bool f = false;
	for(int i = 0; i < n; i++){
		char a;
		cin >> a;
		if(a == 'Y'){
			f = true;
		}
	}
	cout << (f?"Four":"Three") << endl;
	return 0;
}

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

int main() {
    int n, temp, ans = -1;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> temp;
        a.at(i) = temp - 1;
    }
    temp = 0;
    rep(i, n) {
        if(temp == 1) {
            ans = i;
            break;
        }
        temp = a.at(temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_5-D: The Number of Inversions

#include <cstdio>
#include <cstring>

static void print_long(const unsigned long n) {
  std::printf("%lu\n", n);
}

static unsigned long inversion_count = 0ul;

static void merge(int* const ss, const unsigned int n) {
  auto n1 = n/2, n2 = n-n1;
  int tmp[n1];
  std::memcpy(tmp, ss, sizeof(tmp));
  auto ss1 = tmp, ss2 = ss+n1;
  auto i = 0u, i1 = 0u, i2 = 0u;
  while (i1 < n1 && i2 < n2) {
    if (ss1[i1] < ss2[i2]) {
      ss[i++] = ss1[i1++];
    } else {
      inversion_count += n1 - i1;
      ss[i++] = ss2[i2++];
    }
  }
  while (i1 < n1) {
    ss[i++] = ss1[i1++];
  }
  while (i2 < n2) {
    ss[i++] = ss2[i2++];
  }
}

void merge_sort(int* const ss, const unsigned int n) {
  if (n > 1) {
    auto n1 = n/2, n2 = n-n1;
    auto ss1 = ss, ss2 = ss+n1;
    merge_sort(ss1, n1); // ss[0..n/2-1] is sorted
    merge_sort(ss2, n2); // ss[n/2..n-1] is sorted
    merge(ss, n);
  }
}

int main(void) {
  unsigned int n;
  std::scanf("%d", &n);
  int ss[n];
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%d", &ss[i]);
  }

  merge_sort(ss, n);

  print_long(inversion_count);

  return 0;
}

// eof

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    bool p = 0;
    for (int i = 0; i < 10; i++){

        for (int j = 0; j < 10; j++){
            if (i * j == n){
                p = 1;
                break;
            }
        }
    }
    if (p)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
    return 0;
}


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

typedef long long ll;
const int INF = 1e9;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	if (n >= 30){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
	return 0;
}

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

using namespace std;
const int INF=1e9;

int main(){
  int n, m, a[1009], b[1009], c[1009][15];
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    for(int j=0;j<b[i];j++)cin >> c[i][j], c[i][j]--;
  }
  int dp[5000];
  for(int i=0;i<1<<n;i++)dp[i]=INF;
  dp[0] = 0;
  for(int i=0;i<m;i++){
    int key = 0;
    for(int j=0;j<b[i];j++)key |= (1<<c[i][j]);
    for(int j=0;j<1<<n;j++){
      int next = j | key;
      dp[next] = min(dp[next], dp[j] + a[i]);
    }
  }
  cout << (dp[(1<<n)-1]==INF?-1:dp[(1<<n)-1]) << endl;
}



Measured memory_bytes: 3632
mod = 10**9+7
n = int(input())
def nth_bit(d):
    return (n>>d)&1

dp = [[0,0,0] for _ in range(61)]
dp[-1][0] = 1
for d in range(59,-1,-1):
    for s in range(3):
        for k in range(3):
            s2 = min(2,2*s+nth_bit(d)-k)
            if s2>=0:
                dp[d][s2] += dp[d+1][s]
ans = sum(dp[0])%mod
print(ans)

Measured memory_bytes: 62332
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      l: usize,
      n: usize,
      xs: [usize; n],
    }
    let mut xs = xs;
    let mut sx = vec![0; n+1];
    let mut sy = vec![0; n+1];
    let mut ys: Vec<usize> = xs.iter().map(|v| l - *v).collect();
    ys.reverse();

    for i in 0..n {
        sx[i+1] = sx[i] + xs[i];
        sy[i+1] = sy[i] + ys[i];
    }
    // debug!(sx, sy);

    let mut ans = 0;
    for i in 0..n {
        let mut d = 0;
        let nx = (n-i-1)/2;
        let ny = (n-i)/2;

        d += sx[i+1+nx] - sx[i];
        d += sy[ny];
        d *= 2;

        if (n-i-1)%2==0 {
            d -= xs[i+nx];
        } else {
            d -= ys[ny-1];
        }
        ans = max(ans, d);
    }

    std::mem::swap(&mut xs, &mut ys);
    std::mem::swap(&mut sx, &mut sy);

    for i in 0..n {
        let mut d = 0;
        let nx = (n-i-1)/2;
        let ny = (n-i)/2;

        d += sx[i+1+nx] - sx[i];
        d += sy[ny];
        d *= 2;

        if (n-i-1)%2==0 {
            d -= xs[i+nx];
        } else {
            d -= ys[ny-1];
        }
        ans = max(ans, d);
    }
    println!("{}", ans);
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
const int maxn = 15;
#define INF 0xfffff
int d[maxn][maxn];
int V, ans_num, ans_dis;
void init(){
    ans_dis = INF;
    for(int i = 0; i < maxn; i++){
        fill(d[i], d[i] + maxn, INF);
        d[i][i] = 0;
    }
}
void Floyd(){
    for(int k = 0; k <= V; k++)
        for(int i = 0; i <= V; i++)
            for(int j = 0; j <= V; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
//                printf("d[%d][%d] = %d\n",i,j,d[i][j]);
            }
}
void solve(){
    Floyd();
    for(int i = 0; i <= V; i++){
        int sum_dis = 0;
        for(int j = 0; j <= V; j++)
            sum_dis += d[i][j];
        if(sum_dis < ans_dis){
            ans_dis = sum_dis;
            ans_num = i;
        }
    }
}
int main(){_
    int n;
    while(~scanf("%d",&n)){
        if(!n) break;
        V = 0;
        init();
        for(int i = 0; i < n; i++){
            int x, y, val;
            scanf("%d%d%d",&x, &y, &val);
            d[x][y] = d[y][x] = val;
//            printf("--d[%d][%d] = %d\n",x, y, d[x][y]);
            V = max(V, max(x, y));
        }
        solve();
        printf("%d %d\n",ans_num, ans_dis);
    }

    return 0;
}



Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n, m;
  cin >> n >> m;
  
  ll res = pow(100, n);
  if(m<100)
    res=res*m;
  else if(m==100)
    res=res*101;
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
using namespace std;
typedef long long ll;
bool x[110], y[110];
int main() {
	ll n;
	int x=1;
	cin >> n;
	string s = {};
	while (1) {
		if (n % 2) {
			n -= x;
			s = "1" + s;
		}
		else s = "0" + s;
		x *= -1;
		n /= 2;
		if (n == 0) {
			cout << s << endl;
			system("PAUSE");
			return 0;
		}
	}

	system("PAUSE");
	return 0;
}


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

using namespace std;

long long a, b, nr;

bool Pal(long long x)
{
    int y=0, cx=x;
    while (x)
    {
        y=y*10+x%10;
        x/=10;
    }
    if (y==cx)
        return 1;
    else
        return 0;
}

int main()
{
    cin>>a>>b;
    for (long long i=a; i<=b; i++)
    {
        if (Pal(i))
        {
            nr++;
        }
    }
    cout<<nr;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int N, R;
  scanf("%d %d",&N,&R);
  int T;
  if(N>=10){
    printf("%d",R);    
  }
  else{
    T=R+100*(10-N);
      printf("%d",T);
  }

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
const int N=1e5+5;
int n;
LL c;
LL x[N],v[N],a[N],b[N];
int main()
{
    cin>>n>>c;
    for(int i=1;i<=n;i++)
    {
        cin>>x[i]>>v[i];
    }
    x[n+1]=c;
    for(int i=1;i<=n;i++)
    {
        a[i]=a[i-1]+v[i]-(x[i]-x[i-1]);
        b[n-i+1]=b[n-i+2]+v[n-i+1]-(x[n-i+2]-x[n-i+1]);
    }
    for(int i=2;i<=n;i++)
    {
        a[i]=max(a[i],a[i-1]);
        b[n-i+1]=max(b[n-i+1],b[n-i+2]);
    }
    LL ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans,a[i]);
        ans=max(ans,b[i]);
        ans=max(ans,a[i]-x[i]+b[i+1]);
        ans=max(ans,b[i]-(c-x[i])+a[i-1]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vi a(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  vector<vector<int>> yakusuu(200001);
  for(int i=1;i<=200000;++i) {
    for(int j=1;j*j<=i;++j) {
      if(i%j == 0) {
        yakusuu[i].push_back(j);
        if(j*j != i) yakusuu[i].push_back(i/j);
      }
    }
  }
  int sz = 200000;
  vector<vector<double>> dp(n, vector<double>(sz + 1, 1));
  for(int i=1;i<=sz;++i) {
    dp[n-1][i] = abs(a[n-1] - i) / (double)a[n-1];
  }
  for(int i=n-1;i>=1;--i) {
    for(int j=1;j<=sz;++j) {
      if(abs(dp[i][j] - 1) < eps) continue;
      for(int k=0;k<(int)(yakusuu[j].size());++k) {
        dp[i-1][yakusuu[j][k]] = min(dp[i-1][yakusuu[j][k]], max(dp[i][j], abs(a[i-1] - yakusuu[j][k]) / (double)a[i-1]));
      }
    }
  }
  double ans = 1;
  for(int i=1;i<=sz;++i) {
    ans = min(ans, dp[0][i]);
  }
  cout << ans << endl;
}



Measured memory_bytes: 55272
use std::io::stdin;
use std::collections::HashMap;

#[allow(dead_code)]
fn input_ints() -> Vec<u64> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.split_whitespace().map(|s| s.parse().unwrap()).collect(),
        Err(_) => panic!("err"),
    }
}

#[allow(unused_variables)]
fn solve() {
    let l = input_ints();
    let n = l[0] as usize;
    let arr = input_ints();

    let mut long = 0;
    let mut short = 0;

    let mut seen = HashMap::<u64, u64>::new();

    for i in arr {
        if let Some(n) = seen.get(&i) {
            if long < i {
                short = long;
                long = i;
            } else if (long == i && *n == 3) || (short < i && *n == 1) {
                short = i;
            }
        }

        let occurence = seen.entry(i).or_insert(0);
        *occurence += 1;
    }

    println!("{}", long * short);
}

fn main() {
    solve();
}


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

typedef long long ll;
#define REP(i, n, m) for(int i = n; i < m; i++)
#define REPR(i, n, m) for(int i = n; i >= m; i--)
#define LREP(i, n, m) for(ll i = n; i < m; i++)
#define LREPR(i, n, m) for(ll i = n; i >= m; i--)

#define P pair<int, int >


const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;



//---functions---//
int gcd(int a, int b){
    if(a < b) swap(a, b);
    return b?gcd(b, a%b):a;
}

int s2i(string num){stringstream ss; ss << num << flush; int n; ss >> n; return n;}
string i2s(int n){stringstream ss; ss << n << flush; return ss.str();}

bool firstCompare(const P& firstElof, const P& secondElof){
    return firstElof.first < secondElof.first;
}
bool secondCompare(const P& firstElof, const P& secondElof){
    return firstElof.second < secondElof.second;
}
//---------------//

ll A, B;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    cin >> A >> B;
    ll max_len = 0;
    ll tmp = B;
    while(tmp > 1){
        max_len += 1;
        tmp /= 2;
    }

    ll ans = 0;
    ll a, b;
    ll div, mod;
    B += 1; 
    LREP(i, 0, max_len + 1){
        a = 0;
        b = 0;
        div = A / (1L << (i + 1));
        a = div * (1L << i);
        mod = A % (1L << (i + 1));
        if(mod > (1L << i)){
            a += mod - (1L << i);
        }
        div = B / (1L << (i + 1));
        b = div * (1L << i);
        mod = B % (1L << (i + 1));
        if(mod > (1L << i)){
            b += mod - (1L << i);
        }
        if((b - a) % 2 == 1){
            ans += (1L << i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a, b, c = 0;
	cin >> a;
	cin >> b;
	(a < b) ? (c = c + b , b--) : (c = c + a , a--);
	(a < b) ? (c = c + b , b--) : (c = c + a , a--);
	cout << c << "\n";
}

Measured memory_bytes: 256
import math                                        

n = list(raw_input())
      
cnt = 0                                            
k = 0                                              
g = 0                                              
for i in n:
    i = int(i)                                     
    if cnt % 2 == 0 and i == 0:                    
        g += 1                                     
    elif cnt % 2 != 0 and i == 0:
        k += 1                                     
    cnt += 1                                       
   
k2 = int(math.floor((len(n)/2.0))-k)               
g2 = int(math.ceil((len(n)/2.0))-g)                

a1 = k2 + g                                        
a2 = k + g2                                        

print min(a1,a2)                                   
#print k,g, int(math.floor((len(n)/2.0))-k), int(math.ceil((len(n)/2.0))-g) 

Measured memory_bytes: 3460