akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793


int main(){
  int N;
  cin >> N;
  int adp[N], bdp[N], cdp[N];
  int a[N], b[N], c[N];
  rep(i, N){
    cin >> a[i] >> b[i] >> c[i];
  }
  adp[0] = a[0]; bdp[0] = b[0]; cdp[0] = c[0];
  for(int i=1; i<N; i++){
    adp[i] = max(bdp[i-1] + a[i], cdp[i-1] + a[i]);
    bdp[i] = max(adp[i-1] + b[i], cdp[i-1] + b[i]);
    cdp[i] = max(adp[i-1] + c[i], bdp[i-1] + c[i]);
  }
  cout << max({adp[N-1], bdp[N-1], cdp[N-1]}) << endl;
 
    
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using p = pair<int,int>;

long long n;
bool memo[100000005] = {0};
bool dp[100000005] = {0};
vector<p> a;

bool asc(const p &l,const p &r){
    int cntl = 0,cntr = 0;
    for(int i = 0;i < n;++i) {
        cntl += (l.fi >> i) & 1;
        cntr += (r.fi >> i) & 1;
    }
    if(cntl != cntr)return cntl < cntr;
    return l.fi < r.fi;
}


long long solve();

int main(){
    cin >> n;
    a.resize((1LL << n));
    for(int i = 0;i < (1LL << n);++i){
        cin >> a[i].se;
        a[i].fi = i;
        memo[i] = a[i].se;
    }
    cout << solve() << endl;
    return 0;
}

long long solve(){
    sort(a.begin(),a.end(),asc);
    long long ans = 0;
    for(int i = 0;i < n;++i){
        for(int bit = 0; bit < (1LL << n);++bit){
            if(!((bit >> i) & 1))
                dp[bit + (1 << i)] |= memo[bit];
        }
    }
    for(int i = 0;i < (1LL << n);++i){
        if(dp[a[i].fi] && !a[i].se)return -1;
        if(a[i].se && !dp[a[i].fi])++ans;
    }
    return ans;
}


Measured memory_bytes: 13164
#include <stdio.h>

int main(){

int e,i,j,k,x,y,z,m,min ;


for(;;){
scanf("%d",&e);
if(e==0){
break;
}
min=e;
 
for(j=0;j<=1000;j++){
for(k=0;k<=100;k++){

if(e-(j*j+k*k*k)>=0){
x=e-(j*j+k*k*k);
y=j;
z=k;
m=x+y+z;
}
//printf("%d\n",m);

if(m<=min){
min=m;
} 	
}
}
printf("%d\n",min);
}
return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(void){
  ll a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  if(a<b){
    if(a+t*v>=b+t*w)cout << "YES";
    else cout << "NO";
  }
  if(a>=b){
    if(a-t*v<=b-t*w)cout << "YES";
    else cout << "NO";
  }
  cout << endl;
}

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

int main(){
  int n;
  cin >> n;
  int odd = n - n/2;
  double ans = (double)odd / (double)n;
  
  cout << setprecision(12) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using namespace atcoder;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int n, m;
    cin >> n >> m;
    scc_graph g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        g.add_edge(a, b);
    }
    auto ans = g.scc();
    cout << ans.size() << '\n';
    rep(i, ans.size()) {
        cout << ans[i].size() << ' ';
        rep(j, ans[i].size()) cout << ans[i][j] << (j == ans[i].size() - 1 ? '\n' : ' ');
    }
}


Measured memory_bytes: 40120
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a[7];
    int t=9;
    int k=0;
    a[0]=0;
    for(int i=1;i<=5;i++){
        cin>>a[i];
        if(a[i]%10!=0&&a[i]%10<=t){
            t=a[i]%10;
            k=i;
        }
    }
    int sum=0;
    for(int i=1;i<=5;i++){
        if(i==k) continue;
        if(a[i]%10==0) sum+=a[i];
        else sum+=(a[i]+10-a[i]%10);
    }
    sum+=a[k];
    cout<<sum<<endl;
    return 0;
}


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

#define dv(i) for (int c=0; c<(int)(i).size(); c++) cout<<(i)[c]<<(c==(int)(i).size()-1?"\n":" ")
#define da(i) for (int c=0; c<(int)(sizeof((i))/sizeof((i)[0])); c++) cout<<(i)[c]<<(c==(int)(sizeof((i))/sizeof((i)[0]))-1?"\n":" ")
#define ds(i) for (auto f: i) cout<<f<<"\n";
#define dm(i) for (auto f: i) cout<<f.first<<" "<<f.second<<"\n"
#define F0R(i,a,b) for (int i=a; i<(b); i++)
#define FOR(i,a) for (int i=0; i<(a); i++)
#define F0Rd(i,a,b) for (int i=(b)-1; i>=a; i--)
#define FORd(i,a) for (int i=(a)-1; i>=0; i--)

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define sz(x) (int) x.size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define alp(i) i,i + sizeof(i) / sizeof(i[0])
#define memp(i,x) std::memset(i, x, sizeof i)
#define fils(i,x) std::fill(all(i), x)
#define filp(i,x) std::fill(alp(i), x)
#define dr4 {0, 1, 0, -1}
#define dc4 {1, 0, -1, 0}
#define dr8 {-1, -1, -1, 0, 1, 1, 1, 0}
#define dc8 {-1, 0, 1, 1, 1, 0, -1, -1}
#define inBounds(a,b,c,d) (a >= 0 && a < c && b >= 0 && b < d)

string rem(string s) {if(s[s.size()-1]=='\r')s.erase(s.size()-1);return s;}
vector<string> split(string s, char delim) {replace(s.begin(),s.end(),delim,' ');stringstream ss(s); string buf;vector<string> v;while (ss>>buf) v.push_back(buf);return v;}

const int MOD = 1000000007;
const double EPS = 1e-6;

#ifndef KMPC
    const int MAXN = -1;
#else
    const int MAXN = -1;
#endif

inline vi ints(int x) { vi A(x); FOR(i,x) cin >> A[i]; return A; }
inline vl lls(int x) { vl A(x); FOR(i,x) cin >> A[i]; return A; }
inline vs strs(int x) { vs A(x); FOR(i,x) cin >> A[i]; return A; }

const ld pie = 4 * atan((ld) 1);

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    ld A, B, H, M; cin >> A >> B >> H >> M;

    ld mpos = M / 60 * 360;
    ld hpos = (H / 12 + M / 60 / 12) * 360;

    // cout << hpos << ' ' << mpos << '\n';

    ld dist = min(abs(hpos - mpos), abs(min(hpos, mpos) + 360 - max(hpos, mpos)));

    // cout << dist << '\n';

    ld ans = A * A + B * B - 2 * A * B * cos(pie / 180 * dist);

    cout << fixed << setprecision(15) << sqrt(ans) << '\n';
 
    return 0;
}

Measured memory_bytes: 4192
import java.util.*;

class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int[] t = new int[ N ];
		int[] x = new int[ N ];
		int[] y = new int[ N ];
		
		for(int i = 0 ; i < N ; i++){
			t[i] = sc.nextInt();
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		
		boolean result = true;
		for(int i = 0; i < N ; i++){
			if( !canReach( t[i] , x[i] ,y[i] ) ||  !isEven( t[i] , x[i] ,y[i] )){
				result = false;
				break;
			}
		}
		System.out.println(result ? "Yes" : "No");
	}
	
	static boolean canReach(int t , int x , int y){
		
		if(x < 0 ){ x = x * (-1);}
		if(y < 0 ){ y = y * (-1);}
		
		return  t >= (x + y);
		
	}
	
	static boolean isEven(int t , int x , int y){
		
		return (t % 2) == ( (x + y ) % 2);
	}
	
}

Measured memory_bytes: 89264
input_count =input()

input_count = list(input_count)
count = 0
count2 = 0
for i in range(len(input_count)):
  if input_count[i] == 'R':
    count2 += 1
  else:
    count2 = 0
  if count2 >= count:
    count =count2
print(count)    
    
  

Measured memory_bytes: 9104
N=int(input())

name=[input().split() for i in range(N)]
score=[]

#print(name)

name2=sorted(name,key=lambda x:(x[0],-int(x[1])))
#name=sorted(name,key=lambda x:x[1], reverse=True)
#print(name2)

for i in range(N):
    for j,city in enumerate(name):
        if name2[i]==city:
            print(j+1)

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;


int main(int argc, char *argv[]) {
    string s;
    cin >> s;
    vector<int> v(s.size() + 1, 0);
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '<') {
            v[i + 1] = max(v[i] + 1, v[i + 1]);
        }
    }    
    for (int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == '>') {
            v[i] = max(v[i], v[i + 1] + 1);
        }
    }
    long long int res = accumulate(v.begin(), v.end(), (long long int)0);
    cout << res << endl;
}



Measured memory_bytes: 2820
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))

total=[]
for i in range(n):
    ans=0
    for j in range(n):
        if j<i:
            ans+=a1[j]
        elif j==i:
            ans+=a1[j]+a2[j]
        else:
            ans+=a2[j]
    total.append(ans)

print(max(total))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define rep(i, n) for (int i = 0; i <(n); ++i)
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;



int Input[100100];

int main() {
  int N, M; cin >> N >> M;
  vector<pair<int, int>> key;
  
  rep(i, M) {
    int a, b; cin >> a >> b;
    int s = 0;
    rep(j, b) {
      int c; cin >> c;
      c--;
      s |= 1 << c;
    }
    key.emplace_back(s, a);
  }

  // rep(i, M) {
  //   cout << key[i].first << " " << key[i].second << endl;
  // }
  
  vector<int> dp(1 << N, INF);
  dp[0] = 0;
  rep(s, 1 << N) {
    rep(i, M) {
      int t = s | key[i].first;
      int cost = dp[s] + key[i].second;
      dp[t] = min(dp[t], cost);
    }
  }

  int ans = dp.back();
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int P[100001];
int K[100001];

int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}

bool Unite(int A, int B) {
	int a = Find(A);
	int b = Find(B);
	if (a == b) return false;
	if (P[a] > P[b]) swap(a, b);
	P[a] += P[b];
	P[b] = a;
	K[a] += K[b];
	return true;
}

int Size(int A) {
	return -P[Find(A)];
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();

	vector<int> XY[100001];
	rep(i, N) {
		int x = getint(), y = getint();
		XY[x].pb(y);
	}

	rep1(i, 100000) P[i] = -1;

	rep1(i, 100000) {
		if (XY[i].size()) {
			for (int j = 0; j < (int)XY[i].size() - 1; j++) {
				Unite(XY[i][j], XY[i][j + 1]);
			}
			K[Find(XY[i][0])]++;
		}
	}

	ll kotae = 0;
	rep1(i, 100000) {
		if (Find(i) == i) {
			kotae += 1ll * K[i] * Size(i);
		}
	}
	co(kotae - N);

	Would you please return 0;
}

Measured memory_bytes: 5120
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int r = 0;
	int x = 0;
	int z = 0;
	int n;
	cin >> n;
	for (int i = 0; i <= n; i++) {
		x += i;
		z = i;
		if (x >= n)break;
	}
	r = x - n;
	for (int i = 1; i <= z; i++) {
		if (r == i)continue;
		cout << i << endl;
	}

	return 0;


}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  if (a == 1) a += 13;
  if (b == 1) b += 13;
  cout << (a > b ? "Alice" : (b > a) ? "Bob" : "Draw") << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXWH=100050;
int p[MAXWH], q[MAXWH];
vector<PII> vec;

int main() {
	int W, H;
	scanf("%d%d",&W,&H);
	for(int i=0;i<W;i++) scanf("%d",p+i);
	for(int i=0;i<H;i++) scanf("%d",q+i);
	for(int i=0;i<W;i++) vec.PB(MP(p[i], 0));
	for(int i=0;i<H;i++) vec.PB(MP(q[i], 1));
	sort(ALL(vec));
	ll ans=0;
	for(PII t:vec) {
		debug("(%d,%d)  %lld-- (%d,%d)\n",t.F,t.S,ans,W,H);
		if(t.S==0) {
			ans+=1ll*(H+1)*t.F;
			W--;
		}
		else {
			ans+=1ll*(W+1)*t.F;
			H--;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3316
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e3 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}

int n;
int val[maxn];

void solve()
{
	sa(n);
	int minn=INF,maxx=-INF;
	repp(i,1,n)
	{
		sa(val[i]);
		minn=min(minn,val[i]);
		maxx=max(maxx,val[i]);
	}
	int res = INF;
	for(int i=minn;i<=maxx;i++)
	{
		int ans=0;
		for(int j=1;j<=n;j++)
		{
			ans+=(val[j]-i)*(val[j]-i);
		}
		res=min(res,ans);
	}
	cout<<res<<endl;
}

int main()
{
    solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  int n,x;
  cin >> n >> x;
  int m[110];
  int sum=0,mi=100000;
  for(int i=0; i<n; i++){
    cin >> m[i];
    sum+=m[i];
    mi=min(mi,m[i]);
  }
  
  cout << (x-sum)/mi+n<< endl;
  
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
import java.io.InputStream;
import java.io.IOException;


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

    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] heights = new int[n + 1];
    int[] dp = new int[n + 1];
    for(int i = 1; i <= n; i++){
      heights[i] = sc.nextInt();
      dp[i] = Integer.MAX_VALUE;
    }
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = Math.abs(heights[2] - heights[1]);
    for (int i = 3; i <= n; i++) {
        for (int j = i - k; j < i; j++) {
            if (j >= 1) {
                dp[i] = Math.min(dp[i], dp[j] + Math.abs(heights[i] - heights[j]));
            }
        }
    }
    System.out.println(dp[n]);
  }
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;

      public InputReader(InputStream stream) {
          this.stream = stream;
      }

      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }

      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }

      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }

      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }

      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }

      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

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

int main(){
  int N , M ; 
  cin >> N >> M ; 
  vector<int> A(M) , B(M) ; 
  vector<int> T(N) ; 
  
  for(int i = 0 ; i < M ; i++){
    cin >> A.at(i) >> B.at(i) ; 
    
  }
  
  for(int i = 0 ; i < M ; i++){
    T.at((A.at(i)-1))++ ; 
    T.at((B.at(i)-1))++ ;
  }
  
  
  for(int i = 0 ; i < N ; i++){
    cout << T.at(i) << endl ; 
  }
  
}

Measured memory_bytes: 3588
import sys
line = sys.stdin.readline()
n = []
while line:
 num = map(int,line.split())
 if num[0]==0 and num[1] == 0:
 	break;
 else:
 	if num[0] > num[1]:
 		tmp = num[0]
 		num[0] = num[1]
 		num[1] = tmp
 	s = str(num[0])+" "+str(num[1])
 	n.append(s)
 line = sys.stdin.readline()
for i in n:
 print i

Measured memory_bytes: 4300
n = int(input())
b = list(map(int, input().split()))
procedure = [-1] * n
tmp_n = n
for m in range(n-1, -1, -1):
    for i in range(tmp_n-1, -1, -1):
        if b[i] == i+1:
            procedure[m] = i + 1
            del b[i]
            tmp_n -= 1
            break
    else:
        print(-1)
        exit()
for i in range(n):
    print(procedure[i])


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	ll ans = (100*(n-m) + 1900*m) * pow(2,m);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    int N,M,X,b=0,a=0;
    cin>>N>>M>>X;
    vector<int> A(M+1,0);

    rep(i,M){
        int p;
        cin>>p;
        if(p<=X)b++;
        else a++;
    }

    cout<<min(a,b)<<endl;


    return 0;
}

//a=97,z=122



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    vint C(N), S(N), F(N);
    for (int i = 0; i < N - 1; i++)
    {
        cin >> C[i] >> S[i] >> F[i];
    }
    for (int i = 0; i < N - 1; i++)
    {
        int ans = S[i];
        for (int pos = i; pos < N - 1; pos++)
        {
            int b = F[pos] - ans % F[pos];
            if (ans % F[pos] == 0)
                b = 0;
            int k = max((S[pos] - ans - b + F[pos] - 1) / F[pos], 0);
            ans += b + k * F[pos];
            ans += C[pos];
        }
        cout << ans << " ";
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
HW = [int(i) for i in input().split(' ')]
H = HW[0]
W = HW[1]

if H % 2 == 0:
    if W == 1:
        print(1)
    else:
        print(int((H/2*W)))
else:
    vertical = (H+1) / 2
    if W % 2 == 0:
        if H == 1:
          print(1)
        else:
          ho = W / 2
          print(int(vertical * ho + (vertical-1) * ho))
    else:
        if H == 1:
          print(1)
        else:
          if W == 1:
            print(1)
          else:
            ho = (W+1) / 2
            print(int(vertical * ho + (vertical-1) * (ho-1)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int A, B, C, D;

int main(void){
    
    scanf("%d %d %d %d", &A, &B, &C, &D);
    printf("%d\n", min({A + C, A + D, B + C, B + D}));
    
    return 0;
}


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

int main() {
    int N; string S;
    cin >> N >> S;
    long long r = 0, g = 0, b = 0;
    for (auto c : S) {
        if (c == 'R') ++r;
        else if (c == 'G') ++g;
        else ++b;
    }
    long long all = r * g * b;
    long long sub = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (S[i] == S[j]) continue;
            int k = j*2-i;
            if (k >= N || S[k] == S[i] || S[k] == S[j]) continue;
            ++sub;
        }
    }
    cout << all - sub << endl;
}

Measured memory_bytes: 3592
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

int64_t GreatestCommonDivisor(const int64_t a, const int64_t b) {
  // GCD. O(log(min(a, b))). 最大公約数.
  int64_t result = -1LL;
  if (a < 0) {
    std::cerr << "ERROR: GreatestCommonDivisor(): a is out of range: " << a
              << std::endl;
    throw 1;
  } else if (b < 0LL) {
    std::cerr << "ERROR: GreatestCommonDivisor(): b is out of range: " << b
              << std::endl;
    throw 1;
  } else if (a == 0LL) {
    result = b;
  } else if (b == 0LL) {
    result = a;
  } else {
    const int64_t new_a = std::min(a, b);
    const int64_t new_b = std::max(a, b) % new_a;  // Euclidean Algorithm
    result = GreatestCommonDivisor(new_a, new_b);
  }
  return result;
}

std::vector<std::pair<int64_t, int64_t>> FactorizeIntoPrimeFactors(
    const int64_t N) {
  std::vector<std::pair<int64_t, int64_t>> result;
  if (N <= 0LL || N == 1LL) {
    return result;
  }
  int64_t remaining = N;
  for (int64_t i = 2LL; i * i <= remaining; ++i) {
    int64_t count = 0LL;
    while (remaining % i == 0LL) {
      ++count;
      remaining /= i;
    }
    if (count > 0LL) {
      result.push_back(std::pair<int64_t, int64_t>(i, count));
    }
  }
  if (remaining > 1) {
    result.push_back(std::pair<int64_t, int64_t>(remaining, 1));
  }
  return result;
}

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

  int64_t N;
  cin >> N;
  vector<int64_t> A(N);
  int64_t setwise = 0;
  set<int64_t> factors;
  bool is_pairwise = true;
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i];
    if (setwise == 0) {
      setwise = A[i];
    } else {
      setwise = GreatestCommonDivisor(setwise, A[i]);
    }
    vector<Pair> ff = FactorizeIntoPrimeFactors(A[i]);
    for (auto a : ff) {
      if (factors.find(a.first) == factors.end()) {
        factors.insert(a.first);
      } else {
        is_pairwise = false;
      }
    }
  }
  if (is_pairwise) {
    cout << "pairwise coprime" << endl;
  } else if (setwise <= 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}


Measured memory_bytes: 14716
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int yono = 0;
                if(n >= 165) yono++;
                if(n >= 105) yono++;
                if(n >= 195) yono++;
                if(n >= 135) yono++;
                if(n >= 189) yono++;
                sc.close();
                System.out.println(yono);
        }
}

Measured memory_bytes: 35616
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    int ma = N, mi = 1;
    for(int i=1; i<N; i++) {
        if(A[i-1] >= A[i]) mi++;
    }
    cout << mi << endl << ma << endl;
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> h(n+1);
  
  h[0] = 0;
  int i,j;
  for(i = 1;i < n + 1; i++){
    cin >> h[i];
  }
  int ans = 0;
  for(i = 0; i < 101;i++){
    ans++;
    for(j = 1;j < n+1;j++){
      if(h[n + 1 -j] == 0){
        if(h[n - j] != 0){
          ans++;
        }
        if(j == 1){
          ans--;
        }
      }else{
        h[n + 1 -j] = h[n + 1 -j] - 1;
      }
    }
  }
  cout << ans << endl;
  
  
  
}

Measured memory_bytes: 256
N,K=map(int,input().split())
s=list(input())

S=[]
F="2"
cnt=0
for i in range(N):
    if F=="0":
        if s[i]=="0":
            cnt-=1
        else:
            S.append(cnt)
            F="1"
            cnt=1
    elif F=="1":
        if s[i]=="1":
            cnt+=1
        else:
            S.append(cnt)
            F="0"
            cnt=-1
    else:
        if s[i]=="0":
            F="0"
            cnt=-1
        else:
            F="1"
            cnt=1
S.append(cnt)
if S[0]<0:
    S=[0]+S+[0]
else:
    S=S+[0]

if S[0]>=0:
    if len(S)<=(2*K+1):
        ans=0
        for i in range(len(S)):
            ans+=abs(S[i])
        print(ans)
        #exit()
    else:
        ans=0
        SUM=0
        for i in range(2*K+1):
            SUM+=abs(S[i])
            ans=SUM
        #print(ans)
        for i in range(1,len(S)):
            if (2*i+2*K)>(len(S)-1):
                #print("A")
                break
            else:
                #print("B")
                SUM=SUM+abs(S[2*i+2*K-1])+abs(S[2*i+2*K])-abs(S[2*i-1])-abs(S[2*i-2])
                if SUM>ans:
                    ans=SUM
        print(ans)
        #exit()
#print(S)


Measured memory_bytes: 51852
/**
 *   @FileName	f.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.01 01:02:16
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

constexpr int MOD = 998244353;
struct mint {
private:
    long long x;
public:
    mint(long long x = 0) :x((MOD+x)%MOD) {}
    mint(std::string &s) {
        long long z = 0;
        for (int i = 0; i < s.size(); i++) {
            z *= 10;
            z += s[i] - '0';
            z %= MOD;
        }
        this->x = z;
    }
    mint& operator+=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint& operator/=(const mint &a) {
        long long n = MOD - 2;
        mint u = 1, b = a;
        while (n > 0) {
            if (n & 1) {
                u *= b;
            }
            b *= b;
            n >>= 1;
        }
        return *this *= u;
    }
    mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint &a) const {
        mint res(*this);
        return res /= a;
    }
    friend std::ostream& operator<<(std::ostream &os, const mint &n) {
        return os << n.x;
    }
    bool operator==(const mint &a) const {
        return this->x == a.x;
    }
};
//pow
template<typename T, typename U>
T pow(T k, U n, T unity = 1) {
    while (n > 0) {
        if (n & 1) {
            unity *= k;
        }
        k *= k;
        n >>= 1;
    }
    return unity;
}
int main() {
    int n,s;cin >> n >> s;
    vector<vector<mint>> dp(n + 1,vector<mint>(s + 1,0));
    dp[0][0] = pow(mint(2),n);
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        for (int j = 0; j < s + 1; j++) {
            dp[i + 1][j] += dp[i][j];
            if (j - a >= 0) dp[i + 1][j] += dp[i][j - a] / 2;
        }
    }
    cout << dp[n][s] << endl;
    return 0;
}

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

int main(){
  int N, X[100];
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> X[i];
  }
  int ans = 100000000;
  for(int p = 0; p < 100; p++){
    int cost = 0;
    for(int i = 0; i < N; i++){
      cost = cost + (X[i] - p) * (X[i] - p);
    }
    if(ans > cost) ans = cost;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define gcd(x,y) __gcd(x,y)
#define fi first
#define se second
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline ll abs(A &a) { return (a < 0 ? -a : a); }
using namespace std;
const ll inf=(1LL<<62);
const ll MOD=(1e9)+7;
const ll mod=998244353;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  double d, t, s;
  cin >> d >> t >> s;

  double a = d / s;
  if (a <= t) {
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}
 

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

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

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}
#define PI 3.14
int main()
{
	fast;
	ll r;
	cin >> r;
	printf("%f",2*PI*r);
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> p;
 
#define MOD 1000000007

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll N;
    cin >> N;

    string X;
    cin >> X;

    ll mod = 0;

    for(ll i = 0; i < N; i++) {
        if(X[i] == '1') mod++;
    }

    ll mod1 = mod + 1LL;
    ll mod2 = mod - 1LL;

    ll c1 = 0;
    ll c2 = 0;

    for(ll i = 0; i < N; i++) {
        if(X[N - i - 1LL] == '0') continue;
        c1 += modpow(2LL, i, mod1) % mod1;
        c1 %= mod1;
        if(mod2 <= 0) continue;
        c2 += modpow(2LL, i, mod2) % mod2;
        c2 %= mod2;
    }

    for(ll i = 0; i < N; i++) {
        if(X[i] == '0') {
            ll c = c1;
            c += modpow(2LL, N - i - 1LL, mod1) % mod1;
            c %= mod1;
            ll count = 1LL;
            while(c > 0) {
                ll x = __builtin_popcountll(c);
                c %= x;
                count++;
            }
            cout << count << endl;
        } else {
            if(mod2 <= 0) {
                cout << 0 << endl;
                continue;
            }
            ll c = c2;
            c -= modpow(2LL, N - i - 1LL, mod2) % mod2;
            while(c < 0) {
                c += mod2;
            }
            c %= mod2;
            ll count = 1LL;
            while(c > 0) {
                ll x = __builtin_popcountll(c);
                c %= x;
                count++;
            }
            cout << count << endl;
        }
    }
}

Measured memory_bytes: 3764
#include <iostream>

using namespace std;

int main(void)
{
    int N, D, X, i, j, A[101], ans=0;

    cin >> N >> D >> X;

    for(i=1; i<=N; i++){
        j = 0;

        cin >> A[i];

        while(A[i]*j+1 <= D){
            j++;

            ans++;
        }
    }

    cout << ans+X << endl;

    return 0;
}

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

public class Main{

    private static int[] group1 = {1,3,5,7,8,10,12};
    private static int[] group2 = {4,6,9,11};
    private static int[] group3 = {2};

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] str = line.split(" ");

        int x = Integer.parseInt(str[0]);
        int y = Integer.parseInt(str[1]);

        int x_group = Classification(x);
        int y_group = Classification(y);

        if(x_group == y_group){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }


    private static int Classification(int num){
        if(num==1||num==3||num==5||num==7||num==8||num==10||num==12){
            return 1;
        }
        else if(num==4||num==6||num==9||num==11){
            return 2;
        }
        else{
            return 3;
        }
    }
}


Measured memory_bytes: 20308
#include <cmath>
#include <iostream>
using namespace std;
int main() {
	int N, L;
	cin >> N >> L;
	int opt = (1 << 30), sum = 0;
	for (int i = 0; i < N; ++i) {
		int p = L + i;
		if (abs(opt) > abs(p)) {
			opt = p;
		}
		sum += p;
	}
	cout << sum - opt << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main()
{
  unsigned short *A,*B;

  int C[VMAX+ 1];
  int n,i,j;
  scanf("%d",&n);

  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  for(i=0;i<=VMAX;i++) C[i]=0;

  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];

  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 9624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
typedef unsigned long long ull;
const int inf=103974182;
using namespace std;
int n,m;
vector <pii> vec[100005];
ll d[100005];
bool visit[100005];

void print()
{
	for(int i=0;i<n;i++)
	{
		cout<<d[i]<<' ';
	}
}

void dfs(int x)
{
	visit[x]=true;
	if(d[x]==1LL*inf*inf) d[x]=0;
	for(int i=0;i<vec[x].size();i++)
	{
		if(d[vec[x][i].first]==1LL*inf*inf)
		{
			d[vec[x][i].first]=d[x]+vec[x][i].second;
			dfs(vec[x][i].first);
		}
		else
		{
			if(d[vec[x][i].first]!=d[x]+vec[x][i].second) over("No");
		}
	}
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>m;
	int x,y,z;
	for(int i=0;i<100005;i++)
	{
		d[i]=1LL*inf*inf;
	}
	for(int i=0;i<m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		x--;
		y--;
		vec[x].push_back(mp(y,z));
		vec[y].push_back(mp(x,-z));
	}
	for(int i=0;i<n;i++)
	{
		if(!visit[i]) dfs(i);
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 12416
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

int main(){
    string n;
    cin >> n;
    string ans = (n[0] == '9' || n[1] == '9')? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.array, std.string, std.conv;

void main() {
    long a,b,k;
    readf("%d %d %d\n",&a,&b,&k);

    foreach (i; 0..k) {
        if (i % 2 == 0) {
            if (a & 1) {
                a--;
            }
            b += a/2;
            a /= 2;
        }
        else {
            if (b & 1) {
                b--;
            }
            a += b/2;
            b /= 2;
        }
    }
    writeln(a, " ", b);
}

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

ll sum(int n);

void go(){
	int n;cin>>n;
	string s;cin>>s;
	map<char, int> cnt;
	for(char ch : s) {
		cnt[ch]++;
		if(cnt[ch]==sz(s)){
			cout << 1;
			return;
		}
	}
	string non_adj="";
	for(int i=0;i<sz(s)-1;i++){
		while(s[i]==s[i+1]){
			i++;
		}
		non_adj+=s[i];
	}
	if(non_adj.back()!=s.back()){
		non_adj+=s.back();
	}
	
	cout << sz(non_adj);
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
#define int long long
using namespace std;
int read( ){
	int x=0,y=1;char ch=' ';
	for(;(ch!='-' && (ch>'9' || ch<'0'));ch=getchar( ));
	if(ch=='-')y=-1,ch=getchar( );
	for(;ch>='0' && ch<='9';ch=getchar( ))x=x*10+ch-48;
	return x*y;
}
const int inf=0x3f3f3f3f;
int n;
signed main( ){
	int x,y,z,k;
	n=read( );
	printf("%lld\n",n*(n-1)/2);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int input1 = scan.nextInt();
        int input2 = scan.nextInt();
        int input3 = scan.nextInt();

        int result = input2 / input1;
        if ( result <= input3 ) {
            System.out.println( (int)Math.floor(result) );
        }
        else {
            System.out.println( input3 );
        }
        scan.close();
    }
}

Measured memory_bytes: 22740
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = ri(), ri()
print(a + (b-a)*2)

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

using namespace std;

const int NSDirection[4] = { 1,2,6,5 };
const int EWDirection[4] = { 1,4,6,3 };
const int RLDirection[4] = { 3,5,4,2 };
int Dice[] = { 0,1,2,3,4,5,6 };

void change(int p1, int p2, int p3, int p4) {
	int tmp;

	tmp = Dice[p1];
	Dice[p1] = Dice[p2];
	Dice[p2] = Dice[p3];
	Dice[p3] = Dice[p4];
	Dice[p4] = tmp;
}

int main() {
	int n, sum;
	string dir;
	
	while (cin >> n, n) {
		sum = 1;
		for (int i = 0; i < n; ++i) {
			cin >> dir;
			switch (dir[0]) {
				case 'N':change(1, 2, 6, 5); break;
				case 'S':change(1, 5, 6, 2); break;
				case 'E':change(1, 4, 6, 3); break;
				case 'W':change(1, 3, 6, 4); break;
				case 'R':change(3, 5, 4, 2); break;
				case 'L':change(3, 2, 4, 5); break;
				default:break;
			}
			sum += Dice[1];
		}
		cout << sum << endl;
		for (int i = 0; i < 7; ++i) {
			Dice[i] = i;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,x,y,res,s,t;
    cin>>n>>k>>x>>y;
    if(n>k)
    {
        res=n-k;
        t=k*x;
        s=res*y;
        printf("%d\n",t+s);

    }
    else
        printf("%d\n",n*x);
    return 0;
}


Measured memory_bytes: 256
import sys

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


def make_divisors(n):
    divisors = []
    for i in range(1, int(pow(n, 0.5)) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    return divisors


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

    ma = m // n
    div = make_divisors(m)
    res = 1
    for d in div:
        if d <= ma:
            res = d
        else:
            break

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    int i = 0;
    int len = 0;
    char ret;
    while(i < n){
        int tmp = 1;
        char prev = ' ';
        while(i < n && s[i] != prev){
            prev = s[i];
            if(s[i] == 'e')
                i += 3;
            else
                i += 7;
            ++ tmp;
        }

        if(tmp > len){
            len = tmp;
            ret = prev;
        }
    }

    if(ret == 'e')
        cout << "egg" << endl;
    else
        cout << "chicken" << endl;

    return 0;
}

Measured memory_bytes: 1192