akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

struct UnionFind{
    // par[i] >= 0 --> 親
    // par[i] < 0  --> size
    // rank --> 深さ
    vector<int> par, rank;
    UnionFind(int n){
        par.resize(n,-1);
        rank.resize(n,0);
    }

    int root(int x){
        if(par[x]<0) return x;
        else return par[x]=root(par[x]);
    }

    bool same(int x,int y){
        return root(x) == root(y);
    }

    int size(int x){
        return -par[root(x)];
    }

    void merge(int x,int y){
        x = root(x);
        y = root(y);
        if(x==y) return;
        if(rank[x] < rank[y]) swap(x,y);

        // x <-- y
        par[x]+=par[y]; // fix size
        par[y]=x;
        rank[x]+=(rank[x]==rank[y]);
    }
};

int main(){
    int n,m; cin >> n >> m;
    vector<int> x(m),y(m),z(m);
    UnionFind uf(n);
    rep(i,m){
        cin >> x[i] >> y[i] >> z[i];
        x[i]--; y[i]--;
        z[i] %= 2;
        uf.merge(x[i],y[i]);
    }

    set<int> st;
    rep(i,n){
        st.insert(uf.root(i));
    }
    cout << st.size() << endl;
}


Measured memory_bytes: 9772
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  string s;
  cin >> s;
  int K;
  cin >> K;
  priority_queue<string, vector<string>, greater<string>> que;
  int ssize = s.size();
  int x = min(ssize, K);
  set<string> se;
  for(int k = 1; k <= x; k++){
    for(int i = 0; i+k-1 < s.size(); i++){
      string str = s.substr(i, k);
      if(!se.count(str)){
        que.push(str);
        se.insert(str);
      }
    }
  }
  for(int i = 0; i < K-1; i++){
    que.pop();
  }
  cout << que.top() << endl;

}


Measured memory_bytes: 1792
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int n,k;
vector<string> v;

int c(int nn){

    string s = to_string( nn);

    for(auto i:v){
        if((int)s.find(i) != -1)ret 1;
    }
    return 0;
}
int main(){
    
    cin >> n >> k;
	rep(i,0,k){
	    string d;
	    cin >> d;
	    v.pb(d);
	}

	while(c(n))n++;

	P(n);
	
	return  0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-11;
const int MOD = 1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
 
int n;
double kitai[150000];
vector<int> G[150000];
map<P,double> dp;
 
double dfs(int prev,int now){
	if(G[now].size() == 1) return dp[P(prev,now)] = 0.0;
	if(dp.find(P(prev,now)) != dp.end()) return dp[P(prev,now)];
	if(kitai[now] >= -EPS){
		double sum = ((kitai[now] - 1.0) * (double)G[now].size() - dp[P(now,prev)]) / (double)(G[now].size() - 1);
		return dp[P(prev,now)] = sum + 1.0;
	}
	double sum = 0.0;
	for(int i = 0;i < G[now].size();i++){
		if(G[now][i] == prev) continue;
		if(G[G[now][i]].size() == 1) continue;
		sum += dfs(now,G[now][i]);
	}
	return dp[P(prev,now)] = sum / (double)(G[now].size() - 1) + 1.0;
}
 
signed main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		kitai[i] = -1.0;
	}
	for(int i = 0;i < n - 1;i++){
		int u,v;
		scanf("%lld %lld",&u,&v); u--;v--;
		G[u].pb(v);
		G[v].pb(u);
	}
	for(int i = 0;i < n;i++){
		double sum = 0.0;
		for(int j = 0;j < G[i].size();j++) sum += dfs(i,G[i][j]);
		printf("%.9lf\n",sum / (double)G[i].size() + 1.0);
		kitai[i] = sum / (double)G[i].size() + 1.0;
	}
	return 0;
}

Measured memory_bytes: 39552
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;

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

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    rep(i, 1010){
        if(a<=k*i && k*i<=b){out("OK"); return 0;}
    }

    out("NG");

}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
signed main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    if(s[k-1]=='A')s[k-1]='a';
    if(s[k-1]=='B')s[k-1]='b';
    if(s[k-1]=='C')s[k-1]='c';
    cout<<s;
}


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

int main(){
    int n;
    cin >> n;
    vl a(n);
    rep(i, n) cin >> a[i];
    ll ans = 1e18;
    vl sum(n+1);
    rep(i, n) sum[i+1] = sum[i] + a[i];
    rep(i, n-1) {
        ans = min(ans, abs(sum[i+1]-(sum[n]-sum[i+1])));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n, e;
	int[] a;

	void run(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			a=new int[n];
			for(int i=0; i<n; i++){
				a[i]=sc.nextInt();
			}
			e=sc.nextInt();
			solve();
		}
	}

	void solve(){
		int left=0, right=n-1;
		int pleft=left, pright=right;
		for(int i=1;; i++){
			int mid=(left+right)/2;
			if(a[mid]==e){
				println(""+i);
				break;
			}
			// debug(i, "", left, right, mid);
			if(a[mid]<e){
				left=mid+1;
			}else if(a[mid]>e){
				right=mid-1;
			}

			if(left==pleft&&right==pright){
				println(""+(i-1));
				break;
			}
			pleft=left;
			pright=right;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001
#define MOD 1000000007

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int cnt = 0;
    while(a >= b){
        b *= 2;
        cnt++;
    }
    while(b >= c){
        c *= 2;
        cnt++;
    }
    if(cnt <= k) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>

using namespace std;

typedef long long ll;

int A, B;
int main() {
	scanf("%d %d", &A, &B);
	if ((A * B) % 2) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

ll N, K, T;
vector<ll> A;
vector<ll> S;
ll memo[1000][2];

void init()
{
	cin >> N >> K;
	ll t = 1;
	while (t * 2 < K) {
		t *= 2;
		T++;
	}
	S.RS(100, 0);
	rep(i, N) {
		ll a;
		cin >> a;
		A.PB(a);
		rep(i, 100) {
			S[i] += !(a & 1);
			a /= 2;
		}
	}
	rep(i, 1000) {
		memo[i][0] = -1;
		memo[i][1] = -1;
	}
}


ll dfs(ll t, ll b)
{
	if (t < 0) return 0;
	if (memo[t][b] != -1) return memo[t][b];
	ll res = 0;
	ll x = 1LL << t;
	if (b && (x & K) == 0) return memo[t][b] = (N - S[t]) * x + dfs(t-1, b);
	res = S[t] * x + dfs(t-1, b);
	res = max(res, (N - S[t]) * x + dfs(t-1, 0));
	return memo[t][b] = res;
}

void solve()
{
	cout << dfs(50, 1) << endl;
}




Measured memory_bytes: 1528
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;

int n;

char wcz[nax];

int tab[nax];

int main()
{
	scanf("%s", wcz+1);
	n=strlen(wcz+1);
	n++;
	for (int i=1; i<=n; i++)
		tab[i]=1;
	for (int i=1; i<n; i++)
	{
		if (wcz[i]=='<')
			tab[i+1]=max(tab[i+1], tab[i]+1);
	}
	for (int i=n-1; i; i--)
	{
		if (wcz[i]=='>')
			tab[i]=max(tab[i], tab[i+1]+1);
	}
	ll wyn=0;
	for (int i=1; i<=n; i++)
		wyn+=tab[i];
	printf("%lld\n", wyn-n);
	return 0;
}


Measured memory_bytes: 4608
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	String s = sc.next();
      	int count = 0;
      
      	for(int i = 0;i < n;i++){
          if(s.charAt(i) == 'R') count++;
        }
 		
      	if(count > n/2) System.out.println("Yes");
      	else System.out.println("No");
        
	}
}


Measured memory_bytes: 35536
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
  
#define int long long int 
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

double EPS = 1e-9; 
int INF = 1000000005; 
long long INFF = 1000000000000000005LL;
const int mod = 1e9 + 7; 

//#define CI cpp_int
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define deb(...) cout << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define size(v) (int)v.size() 
#define endl "\n"
#define SINT int32_t
#define UMO unordered_map
#define USO unordered_set
#define UB(v, n) upper_bound(ALL(v), n)
#define LB(v, n) lower_bound(ALL(v), n)
#define to_bin(b, n) bitset<b>(n) // Provide binary representation of a Number
#define setBits(n) popcount(n) // count Set Bits in a Number
#define MX *max_element
#define MN *min_element
#define TC int t; cin >> t; while (t--) 
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + ((n >> 4) & 0xF0F0F0F)) * 0x1010101) >> 24;
}

void Panda() {
    int n;
    cin >> n;
    int cnt = 0;
   for(int i = 1; i <= n; i++) {
        if(size(to_string(i)) % 2) cnt++;
   }
   cout << cnt << endl;
}
  
int32_t main() 
{ 
    FAST;

   
    
    Panda();

    return 0; 
} 

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

int main() {
	string S;
	int now,ans = 100000;
	cin >> S;
	for(int i = 0; i < S.length() - 2; i++){
		now = stoi(S.substr(i,3));
		if(abs(now - 753) <= ans){
			ans = abs(now - 753);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a, a + n);
    
    int ali = 0, bob = 0;
    int i = n-1;
    while (true) {
        ali += a[i--];
        if (i < 0) break;
        bob += a[i--];
        if (i < 0) break;
    }
    cout << (ali - bob) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll n;
    string s;
    cin >> n >> s;
    ll numb = 0;
    ll numw = 0;

    rep(i, n){
        if(s[i] == '.') numw++;
        else numb++;
    }

    ll m;
    m = INF;
    ll b = 0;
    ll w = numw;
    m = min(m, w+b);
    rep(i, n){
        if(s[i] == '.') w--;
        else b++;
        m = min(m, w+b);
    }

    cout << m;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;

    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }

    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

void solve(std::string S_A, std::string S_B, std::string S_C)
{
    char c = S_A[0];
    S_A = S_A.substr(1);
    while (true)
    {
        switch (c)
        {
        case 'a':
            if (S_A.size() == 0)
            {
                cout << "A" << endl;
                return;
            }
            c = S_A[0];
            S_A = S_A.substr(1);
            break;
        case 'b':
            if (S_B.size() == 0)
            {
                cout << "B" << endl;
                return;
            }
            c = S_B[0];
            S_B = S_B.substr(1);
            break;
        case 'c':
            if (S_C.size() == 0)
            {
                cout << "C" << endl;
                return;
            }
            c = S_C[0];
            S_C = S_C.substr(1);
            break;
        default:
            break;
        }
    }

    if (S_A.size() == 0)
    {
        cout << "A" << endl;
    }
    else if (S_B.size() == 0)
    {
        cout << "B" << endl;
    }
    else
    {
        cout << "C" << endl;
    }
}

int main()
{
    std::string S_A;
    std::cin >> S_A;
    std::string S_B;
    std::cin >> S_B;
    std::string S_C;
    std::cin >> S_C;
    solve(S_A, S_B, S_C);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

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

  int l=1,r;
  if(m%2==0) r = m;
  else r = 1 + m;
  while(l < r) {
    cout << l << " " << r << endl;
    l++;r--;
  }
  if(m%2==0) l = m+1;
  else l = m+2;
  r = 2*m+1;
  while(l < r) {
    cout << l << " " << r << endl;
    l++;r--;
  } 

  return 0;
}


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

using pii = pair<int, int>;

int main() {
    int m; cin >> m;
    vector<int> x(m), y(m);
    for(int i = 0; i < m; ++i) {
        cin >> x[i] >> y[i];
    }

    auto slope = [&] (int i, int j) {
        if(x[i] == x[j]) return make_pair(0, 1);
        if(y[i] == y[j]) return make_pair(1, 0);
        if(x[i] > x[j]) swap(i, j);
        const int g = __gcd(abs(y[j] - y[i]), x[j] - x[i]);
        return make_pair((y[j] - y[i]) / g, (x[j] - x[i]) / g);
    };

    vector<pii> as;
    function<int(int)> solve = [&] (int S) {
        int res = 0;
        if(S == (1 << m) - 1) {
            map<pii, int> cnt;
            for(auto& p : as) cnt[p] += 1;
            for(auto& p : cnt) {
                res += p.second * (p.second - 1) / 2;
            }
            return res;
        }
        int i = 0;
        while(S & (1 << i)) i++;
        for(int j = i + 1; j < m; ++j) {
            if(S & (1 << j)) continue;
            as.push_back(slope(i, j));
            res = max(res, solve(S | (1 << j) | (1 << i)));
            as.pop_back();
        }
        return res;
    };

    cout << solve(0) << endl;
}



Measured memory_bytes: 3088
#include<iostream>
int p[1<<17],n,s,i;
int main(){p[1]=1;for(i=2;i*i<1<<17;i++)if(!p[i])for(s=2;i*s<1<<17;s++)p[i*s]++;for(;std::cin>>n,n;){for(i=2,s=0;n;i++)if(!p[i])s+=i,n--;std::cout<<s<<"\n";}}

Measured memory_bytes: 0
import java.io.PrintWriter
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val r = nextInt()
  	println(3*r*r)
  	return
}

// 入力取得
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 31704
// finish date: 2018/10/08

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>>
        vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;

struct hxy {
    int h, x, y;

    bool operator<(const hxy &another) const {
        //メンバ変数であるnum1で比較した結果を
        //この構造体の比較とする
        return h < another.h;
    }
};

int main() {
    int N;
    cin >> N;
    vector<hxy> p(N);
    rep(i, N) {
        int in1, in2, in3;
        cin >> in1 >> in2 >> in3;
        p[i].h = in3;
        p[i].x = in1;
        p[i].y = in2;
    }
    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    rep(x, 101) {
        rep(y, 101) {
            int H = p[0].h + abs(x - p[0].x) + abs(y - p[0].y);
            FOR(i, 1, N) {
                int check = p[i].h + abs(x - p[i].x) + abs(y - p[i].y);
                if (!((p[i].h == 0 && check >= H) || (p[i].h != 0 && check == H))) break;
                if (i == N - 1) {
                    cout << x << " " << y << " " << H << endl;
                    return 0;
                }
            }
        }
    }


    return 0;
}



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

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

    sorted_li = sorted(li, reverse=True)

    if sorted_li[m-1] < sum(li)/(4*m):
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias SugarWater = Tuple!(long, "swater", long, "sugar");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto s = sread();
    auto cost_right = new long[](s.length);
    auto cost_left = new long[](s.length);
    auto iter = iota(0, s.length);
    long count;
    foreach (i; iter)
    {
        if (s[i] == 'L')
            cost_left[i] = ++count;
        else
        {
            count = 0;
        }
    }
    count = 0;
    foreach_reverse (i; iter)
    {
        if (s[i] == 'R')
            cost_right[i] = ++count;
        else
        {
            count = 0;
        }
    }
    auto ans = new long[](s.length);
    foreach (i; iter)
    {
        if (s[i] == 'R')
        {
            if (cost_right[i] % 2)
                ans[i + cost_right[i] - 1]++;
            else
                ans[i + cost_right[i]]++;
        }
        else
        {
            if (cost_left[i] % 2)
                ans[i - cost_left[i] + 1]++;
            else
                ans[i - cost_left[i]]++;
        }
    }

    formatwrite(ans);
    // cost_left.writeln();
    // cost_right.writeln();
}

void formatwrite(T)(T a)
{
    foreach (i, e; a)
    {
        if (i != a.length - 1)
            e.write(" ");
        else
            e.writeln();
    }
}

Measured memory_bytes: 4632
import math
a,b,c=map(int,input().split())
s=a/2*b*math.sin(math.radians(c))
l=a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(c)))
h=b*math.sin(math.radians(c))
print('{:.5f}\n{:.5f}\n{:.5f}'.format(s,l,h))


Measured memory_bytes: 5712
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,d;
	while(scanf("%d%d",&n,&d)!=EOF){
		d=d*2+1;
		int ans=n/d;
		if(n%d) ans++;
		printf("%d\n",ans);
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())

e, w = 0, 0
for si in s:
    if si == 'E':
        e += 1
    else:
        w += 1

pri_e, pri_w= 0, 0
cnt_max = 0
for i in range(n):
    cnt = 0
    if s[i] == 'W':
        w -= 1
    
    cnt += pri_e
    cnt += w
    cnt_max = max(cnt, cnt_max)
    if s[i] == 'E':
        e -= 1
        pri_e += 1

print(n - (cnt_max+1))

Measured memory_bytes: 6044
#include <iostream>
#include <cstdio>
#include <vector>
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define fastio() ios::sync_with_stdio(0),cin.tie(0)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 0x3c3c3c3c;
const ll infl = 0x3c3c3c3c3c3c3c3c;

int N;
int A[100003];
int cnt[100003];
int main() {
	fastio();
	cin >> N;
	for(int i = 0 ; i < N; i++) {
		cin >> A[i];
		cnt[A[i]]++;
	}
	int ans = 0;
	for(int i = 1 ; i < 100000; i++){
		ans = max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
/**
  * @file pd.cpp
  * @brief atcoder

  *

  * @author yao
  * @date 2018-10-06
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#define ft frist
#define sd second
#define INF ((int)1e9)
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#endif //DBG

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

int main()
{
    int n,m,ans=1;
    scanf("%d%d",&n,&m);
    for(int i=1;i*i<=m;++i)
    {
        if(m%i) continue;
        int ii = m/i;
        if(i>=n) ans = std::max(ans,ii);
        if(ii>=n) ans = std::max(ans,i);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
ll n,a[100005],x;
cin>>n>>x;
rep(i,0,n-1)cin>>a[i];
ll ans=0;
rep(i,1,n-1)
{
	ll kk=max(0ll,a[i]+a[i-1]-x);
	a[i]-=kk;
	if(a[i]<0)a[i]=0;
	ans+=kk;
}
ol(ans);
return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s1, s2, ans = "";
    cin >> s1 >> s2;
    int i2 = 0;
    for(int i = 0; i < s1.size(); i++) {
        ans += s1[i];
        if (i2 < s2.size())
            ans += s2[i2++];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    ll n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

struct BSTNode {
	int data;
	BSTNode *left;
	BSTNode *right;
};

BSTNode* getnode(int data);
BSTNode* Insert(BSTNode *root, int data);
void PreOrder(BSTNode *root);
void InOrder(BSTNode *root);
void Visit(BSTNode *root);
bool Search(BSTNode *root, int data);


int main() {
	
	BSTNode *root = NULL;
	
	int n;
	string s;
	int data;
	
	while(cin >> n) {
		
		for(int i=0;i<n;i++) {
			
			cin >> s;
			
			if(s[0] == 'i') {
				
				cin >> data;
				root = Insert(root, data);
			
		}
			else if (s[0] == 'f') {
				
				bool check = false;
				cin >> data;
				
				check = Search(root, data);
				
				if(check)
					cout << "yes\n";
					
				else
					cout << "no\n";
				
				
			}
			else {
				
				InOrder(root);
				cout << "\n";
				PreOrder(root);	
				cout << "\n";
					
			}
				
			
		}
		
	}
	
	return 0;
}

BSTNode* getnode(int data) {
	
	BSTNode *newnode = new BSTNode;
	
	newnode -> data = data;
	newnode -> left = NULL;
	newnode -> right = NULL;
	
	return newnode;
}

BSTNode* Insert(BSTNode *root, int data) {
	
	if(root == NULL)
		root = getnode(data);
		
	else if(data < root -> data )
		root -> left = Insert(root -> left, data);
		
	else
		root -> right = Insert(root -> right, data);
	
	return root;
	
}

void PreOrder(BSTNode *root) {
	
	if (root != NULL) {
      Visit(root); 
      PreOrder(root -> left);   
      PreOrder(root -> right);
      
   }

}

void InOrder(BSTNode *root) {
	
	if (root != NULL) {
		
      InOrder(root -> left);   
      Visit(root);
      InOrder( root -> right);
      
   }

}

void Visit(BSTNode *root) {
	cout << " " << root->data;
}

bool Search(BSTNode *root, int data) {
	
	if(root == NULL)
		return false;
		
	else if(root -> data == data)
		return true;
		
	else if(root -> data > data)
		return Search(root -> left, data);
		
	else
		return Search(root -> right, data);
	
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    ll N,K;
    cin >>N>>K;

    ll ans,ansb=0;
    if(K%2){
        //all K
        ans=N/K;
    }else{
        //all K or all K/2
        ans=N/K;
        ansb=N/(K/2)-ans;
    }
    ans=ans*ans*ans;
    ans+=ansb*ansb*ansb;

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

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;
vector<int> A;
vector<vector<int> > k;

void init()
{
	cin >> N;
	CINV(A, N);
	sort(all(A));
	k.resize(2);
}

void mk(int x, int a)
{
	rep(i, N) {
		k[a].PB(x);
		x = -x;
	}
	k[a].back() /= 2;
	k[a].front() /= 2;
	sort(all(k[a]));
}

ll culc(int a)
{
	ll res = 0;
	rep(i, N) {
		res += k[a][i] * A[i];
	}
	return res;
}


void solve()
{
	mk(2, 0);
	mk(-2, 1);
	cout << max(culc(0), culc(1)) << endl;
}




Measured memory_bytes: 1784
n=int(input())
rest=[]
for i in range(1,n+1):
    city,p=input().split()
    p=int(p)
    rest.append((i,city,p))

rest=sorted(rest,key=lambda x: x[2],reverse=True)
rest=sorted(rest,key=lambda x: x[1])

for a,b,c in rest:
    print(a)

Measured memory_bytes: 3060
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

T,X=get_f
puts T/X

Measured memory_bytes: 3836
fun main(args:Array<String>?): Unit {
    while(true){
        val (x, y, z) = readLine()!!.trim().split(' ').map(String::toInt)
        if (x == 0 && y == 0 && z == 0) return
        val roulette = readLine()!!.trim().split(' ').map(String::toInt)
        val cells = Array(y){ Event.None as Event}
        repeat(z){
            val (n, e, a) = readLine()!!.trim().split(' ').map(String::toInt)
            cells[n] = when(e){
                1 -> Event.Move(a)
                2 -> Event.Gain(a)
                3 -> Event.Loss(a)
                else -> TODO()
            }
        }
        println(solve(cells, roulette).toInt())
    }
}
fun solve(cells: Array<Event>, roulette: List<Int>): Double {
    val memo = Array(cells.size){DoubleArray(it * 100 + 1){-1.0}}
    fun sub(position: Int, money: Int, event: Boolean = true): Double {
        if (position !in cells.indices) return money.toDouble()
        if (!event) return roulette.map{sub(position + it, money)}.sum() / roulette.size
        if (memo[position][money] < 0){
            val cell = cells[position]
            memo[position][money] = when(cell){
                is Event.Move -> sub(position + cell.step, money, false)
                is Event.Gain -> roulette.map{sub(position + it, money + cell.value)}.sum() / roulette.size
                is Event.Loss -> if (cell.value > money) roulette.map{sub(position + it, 0)}.sum() / roulette.size else roulette.map{sub(position + it, money - cell.value)}.sum() / roulette.size
                Event.None -> roulette.map{sub(position + it, money)}.sum() / roulette.size
            }
        }
        return memo[position][money]
    }
    return sub(0, 0)
}
sealed class Event {
    data class Move(val step: Int): Event()
    data class Gain(val value: Int): Event()
    data class Loss(val value: Int): Event()
    object None: Event()
}


Measured memory_bytes: 101272
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())
c = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    p = -1
    for j in range(w):
        if s[i][j] == ".":
            if p == -1:
                c[i][j] = -1
            else:
                p += 1
                c[i][j] = p
        else:
            p = 0
            c[i][j] = p
for i in c:
    print(" ".join(map(str, i)))


Measured memory_bytes: 5680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[102];
int main() {
	ll n;
	cin>>n;
	double sum=0;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sum/=n;
	double sum1=abs(double(a[0])-sum);
	ll ans=0;
	for(ll i=1;i<n;i++){
		double now=abs(double(a[i])-sum);
		if(now<sum1){
			sum1=now;
			ans=i;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        if (a==c){
            System.out.println(0);
        }else {
            System.out.println(1);
        }

    }
}

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

vector<int> can(100001,-1);

int solve(int x){
    if(can[x] != -1) return can[x];
    else{
        if(x == 0) return can[x] = 0;
        else if(x<100) return can[x] = 0;
        else if(100 <= x && x <= 105) return can[x] = 1;
        else{
            for(int i=0;i<6;i++){
                if(can[x-100-i] == 1) return can[x] = 1;
            }
            return can[x] = 0;
        }
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int x;
    cin >> x;
    for(int i=0;i<100001;i++){
        solve(i);
    }
    cout << can[x] << endl;
    return 0;
}


Measured memory_bytes: 640
N, K = map(int, input().split())
ab = [[0, 0] for _ in range(N)]
for i in range(N):
    a, b = map(int, input().split())
    ab[i][0] = a
    ab[i][1] = b

ab = sorted(ab)

#print(ab)
tmp = 0

for i in ab:
    tmp += i[1]
    if tmp >= K:
        ans = i[0]
        break

print(ans)

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

#define mod 1000000007
#define ll long long


int main()
{
   ios::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.tie(nullptr);
   int n;
   cin>>n;
   string s;
   cin>>s;
   int ans=n;
   int cnt=0;
   for(int i=1;i<n;i++){
       if(s[i]=='E')cnt++;
   }
   ans=min(ans,cnt);
   for(int i=1;i<n;i++){
       if(s[i]=='E')cnt--;
       if(s[i-1]=='W')cnt++;
       ans=min(ans,cnt);
   }
   cout<<ans;
}


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

int main() {
  int N,Ans=0;
  cin>>N;
  vector<int> vec(N);
  
  rep(i,N){cin >> vec.at(i);}
  
  rep(i,N-1){
   for (int j = i+1; j < N; j++){
     Ans+=vec.at(i)*vec.at(j);
   }
  }
  cout<<Ans<<endl;
}

Measured memory_bytes: 3632
n = int(input())
w = []
for i in range(n):
    w.append(input())
ans = "Yes"
flag = 0
for i in w:
    if w.count(i) != 1:
        flag= 1
        ans = "No"
        break

if flag == 0:
    for i in range(n-1):
        if w[i][len(w[i])-1:len(w[i])] != w[i+1][0:1]:
            ans = "No"
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<vector>
#include<iostream>
#include<algorithm>
#define pb push_back
#define lowbit(x) ((x)&(-(x)))
using namespace std;
char s[200010];
int n, c[200010], a[200010];
long long ans;
vector < int > p[26];
bool check() {
	int cnt = 0;
	for (int i = 0; i < 26; ++i)
		cnt += p[i].size() & 1;
	return cnt < 2;
}
void add(int p, int x) {
	for (; p <= n; p += lowbit(p)) c[p] += x;
}
int sum(int p) {
	int res = 0;
	for (; p; p -= lowbit(p)) res += c[p];
	return res;
}
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for (int i = 1; i <= n; ++i) p[s[i]-'a'].pb(i);
	if (!check()) return puts("-1"), 0;
	for (int i, sz, x = 0; x < 26; ++x) {
		for (i = 0; i < (sz = p[x].size()); ++i)
			a[p[x][i]] = p[x][sz-1-i];
	}
//	for (int i = 1; i <= n; ++i)
//		ans += sum(a[i]), add(a[i]);
	for (int i = 1; i <= n; ++i) add(i, 1);
	for (int i = 1; i <= n; ++i) {
		ans += sum(n) - sum(a[i]);
		add(a[i], -1);
	}
	printf("%lld\n", ans / 2);
	return 0;	
}


Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
	int n,i;
	int num[3];
	scanf("%d",&n);
	for(i=0;n>0;i++)
	{
		num[i]=n%10;
		n/=10;
	}
	for(i=0;i<3;i++)
	{
		int temp;
		temp=num[i];
		if(temp==9)
		{
			printf("Yes");
			break;
		}
	}
	if(i==3)
		printf("No");
}

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

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

  if(a*b >= c*d) {
    cout << a*b << endl;
  }
  else {
    cout << c*d << endl;
  }
  return 0;
}


Measured memory_bytes: 256