akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<ii> a(n);
  for (auto &i : a) cin >> i.fi >> i.sc;
  sort(all(a));
  int ans = 0;
  for (auto &i : a) {
    int t = min(i.sc, m);
    m -= t;
    ans += i.fi * t;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 1792
const p = (...args) => {
  process.env.NODE_ENV === "test" ? console.log(...args) : ""
}

const solve = (input) => {
  const aa = input.split("\n").map(Number)
  let minRest = 10
  const b = aa.map((a) => {
    if (a % 10 == 0) {
      return a
    }
    minRest = Math.min(a % 10, minRest)
    return Math.ceil(a / 10) * 10
  })
  const all = b.reduce((curr, next) => curr + next, 0)
  return all + minRest - 10
}

if (process.env.NODE_ENV === "test") {
  module.exports = (input) => solve(input.trim())
} else {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(solve(input.trim()))
}


Measured memory_bytes: 7372
#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)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int main() {
	int h[5], cnt[4];
	
	while (cin >> h[0], h[0]) {
		FOR(i, 1, 5) cin >> h[i];
		
		memset(cnt, 0, sizeof(cnt));
		REP(i, 5) cnt[h[i]]++;
		
		int ans[5];
		int win = -1, lose = -1, draw = 0;
		
		int zero = 0;
		FOR(i, 1, 4) if (cnt[i] > 0) draw++;
		if (draw == 1) draw = 3;
		
		if (draw == 3) {
			REP(i, 5) ans[i] = 3;
		}
		else {
			if (cnt[1] > 0 && cnt[2] > 0) win = 1;
			if (cnt[2] > 0 && cnt[3] > 0) win = 2;
			if (cnt[3] > 0 && cnt[1] > 0) win = 3;			
			REP(i, 5) {
				if (h[i] == win) ans[i] = 1;
				else ans[i] = 2;
			}
		}
		
		REP(i, 5) printf("%d\n", ans[i]);
		
	}
	return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}
const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){
      ans *=(n+1-j);
      ans /= j;
      ans %= MOD;} }return ans;}

void solve(){
    int n; cin >> n;
    int a[n];
    for(int i = 0;i < n; ++i) cin >> a[i];
    int q; cin >> q;
    while(q--){
        int k;cin >> k;
        int lleft = 0;
        int lright = n;
        int uleft = 0;
        int uright = n;
        int lower_bound = (lright + lleft)/2;
        int upper_bound = (uright + uleft)/2;
        while(lleft < lright){
            if(a[lower_bound] >= k){
                lright = lower_bound;
            } else {
                lleft = lower_bound + 1;
            }
            lower_bound = (lleft + lright)/2;
        }
        while(uleft < uright){
            if(a[upper_bound] <= k){
                uleft = upper_bound + 1;
            } else {
                uright = upper_bound;
            }
            upper_bound = (uleft + uright)/2;
        }
        cout << lower_bound << " " << upper_bound << endl;
    }
}

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



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

int main() {

 int a,b,c,d,k;
 cin >> a >> b >> c >> d >> k;
 int t = 0;
 t =  c*60 + d - k - a*60 - b;
  cout << t << endl;


}


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

using namespace std;

int main()
{
    int N,s=0;
    cin>>N;
    int a[N+5];
    for(int i=0;i<N;i++)
    {
        cin>>a[i];
        while(a[i]%2==0) {a[i]/=2; s++;}
    }
    cout<<s<<endl;
    return 0;
}


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

int main() {
	int n, s = 0;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		s ^= a[i];
	}
	rep(i, n) {
		cout << (s^a[i]) << ' ';
	}
	cout << endl;
	return 0;
}

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

int main() {
    int M, K;
    cin >> M >> K;
    int N = 1;
    rep(i, 0, M) N *= 2;
    if(N <= K) cout << -1 << endl;
    else if(M == 0) cout << "0 0" << endl;
    else if(M == 1) {
        if(K == 0) cout << "0 0 1 1" << endl;
        else cout << -1 << endl;
    } else {
        rep(i, 0, N) if(i != K) cout << i << " ";
        cout << K << " ";
        rep(i, 0, N) if(N - i - 1 != K) cout << N - i - 1 << " ";
        cout << K << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
N, M = list(map(int, input().split()))

p = [0] * M
S = [''] * M


for i in range(M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])

WAnum = 0
ACnum = 0

WA = [0] * N
AC = [0] * N

for i in range(M):
    num = p[i] - 1
    # 未得点のときだけ影響
    if(AC[num] >= 1):
        continue

    if(S[i] == 'WA'):
        WA[num] += 1

    elif(S[i] == 'AC'):
        AC[num] = 1
        ACnum += 1
        WAnum += WA[num]

print(ACnum, WAnum)

Measured memory_bytes: 14836
#!/usr/bin/python3
 
cmdvar=input()
in_plited=cmdvar.split()

A_age=int(in_plited[0])
B_fee=int(in_plited[1])

if A_age>=13:
    print(B_fee)
elif A_age>=6 and A_age<=12:
    print(int(B_fee/2))
elif A_age <= 5:
    print(0)
else:
    print("error")

Measured memory_bytes: 3060
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif
ll t;
cin>>t;
ll arr[t];

for (int i = 0; i < t; ++i)
{
	cin>>arr[i];
	/* code */
}
int count=0;
int answer=0;
for (int i = 0; i < t-1; ++i)
{
	if (arr[i]>=arr[i+1])
	{
		count++;
		/* code */
	}
	else{
		if(count>answer){
			answer=count;
		}
		count=0;
	}
	if (count>answer)
	{
		/* code */
		answer=count;
	}
	
	/* code */
}
cout<<answer<<endl;


return 0;
}
















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

int main(){
    int h,w;
    int x,y;
    cin >> w >> h >> x >> y;
    double menseki = w * (double)h /2;
    int ans = 0;
    if(w % 2 == 0 && w/2 == x && h%2 == 0 && h/2 == y) ans = 1;
    printf("%.10f %d\n",menseki,ans);
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll d,t,s;
    cin>>d>>t>>s;
    if(d<=t*s)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int min = sc.nextInt();
		int cnt = 1;
		
		for(int i=1;i<n;i++) {
			int p = sc.nextInt();
			if(p<=min) {
				cnt++;
			}
			if(p<min)
				min = p;
		}
		
		System.out.println(cnt);

	}

}


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

using namespace std;

int main()
{
   char a[3] = {0};

    cin >> a[0]; cin >> a[1]; cin >> a[2];

    // 5/7/5へ変形できるか？
    auto five_c= 0;
    auto seven_c= 0;
    for (auto i: a) {
        if (i == '5') five_c++;
        if (i == '7') seven_c++;
    }
    if (five_c == 2 && seven_c == 1) cout << "YES";
    else cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int n,a=0; cin>>n;
  for(int i=1; i<=n; i++){
    int c=0;
    for(int j=1; j<=i; j+=2) if(i%j==0) c++;
    if(c==8) a++; 
  }
  cout<<a;
}

Measured memory_bytes: 3588
# 1 "o.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "o.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "o.cpp" 2

long long n;
vvi adj;
long long dp[21][1<<21];

long long solve(long long idx, long long k){
    if(idx == n)
        return 1;
    long long &res = dp[idx][k];
    if(res == -1){
        res = 0;
        for(long long j:adj[idx]){
            long long m = 1<<j;
            if(k & m)
                res = mod(res + solve(idx+1, k ^ m));
        }
    }
    return res;
}


int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    cin >> n;
    adj.resize(n);
    for(long long i=0; i<n; ++i){
        for(long long j=0; j<n; ++j){
            long long a;
            cin >> a;
            if(a)
                adj[i].push_back(j);
        }
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(0, (1<<n)-1) << "\n";
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}



int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,x,y; cin >> n >> x >> y;
    x--, y--;

    map<int, int> count;
    for (int i = 0; i < n; ++i) {
        vector<bool> visited(n, false);
        queue<int> q;
        q.push(i);
        
        int level = 0;
        while (!q.empty()) {
            queue<int> nq;
            while (!q.empty()) {
                int node = q.front(); q.pop();
                if (visited[node]) continue;

                visited[node] = true;
                count[level]++;
                if (node > 0 && !visited[node-1]) nq.push(node-1);
                if (node < n - 1 && !visited[node+1]) nq.push(node+1);
                if (node == x) nq.push(y);
                if (node == y) nq.push(x);
            }
            q = nq;
            ++level;
        }
        
    }

    for (int i = 1; i < n; ++i) cout << count[i] / 2 << '\n';

    return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll n,a,b,ans=0;
    scanf("%lld%lld%lld",&n,&a,&b);
    ll x[n];
    rep(i,0,n){
        scanf("%lld",&x[i]);
    }
    rep(i,1,n){
        if((x[i]-x[i-1]) * a <b ){
            ans+=(x[i]-x[i-1]) * a;
        }else{
            ans+=b;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

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

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

int main() {
    int a, b; cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}


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

int main() {
  int r;
  cin >> r;
  cout << r*r << endl;
  return 0;
}

Measured memory_bytes: 256
n,d,x = gets.split.map(&:to_i)
if d <= 1
  puts x
else
  pa = gets.split.map(&:to_i)
  (d-1).times do
    pb = gets.split.map(&:to_i)
    dp = Array.new(10**5+1, 0)
    
    for i in 0...n
      for j in 0..x-pa[i]
        dp[j + pa[i]] = [dp[j + pa[i]], dp[j] + pb[i]].max
      end
    end
    
    y = x
    for i in 0..x
      y = [y, dp[i] + x-i].max
    end
    x = y

    pa = pb
  end
  puts x
end

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

using namespace std;

/**templates**/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;

#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sf(x) scanf("%lf",&x)
#define ss(x) scanf(" %s",x)
#define sc(x) scanf(" %c",&x)
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define aa first
#define bb second
#define sz(x) (ll)(x).size()
#define cas printf("Case %lld: ",++t)
#define casline printf("Case %lld:\n",++t)
//#define cas cout<<"Case "<<++t<<": "
//#define casline cout<<"Case "<<++t<<":"<<endl;
#define distance(x1,y1,x2,y2)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
#define endl "\n"
#define bug cout<<"bugggggggggggg "<<endl;
#define fast ios_base::sync_with_stdio(0);cin.tie(nullptr); ///no printf/scanf

const ll mod = 1000000007;
const ll inf = 1LL<<62;
const ll mx = 100005;
const double eps = 1e-10;

ll dx[10]={1,0,-1,0};
ll dy[10]={0,-1,0,1};

ll power(ll a,ll b)
{
    if(b==0)return 1;
    ll x=power(a,b/2);
    x=x*x;
    if(b%2)x=x*a;
    return x;
}
/**
double cosine_rule(double a,double b,double c)
{
    double res=(a*a+b*b-c*c)/(2*a*b);
    res=acos(res);
    return res;
}
*/
ll dp[105][mx],n,w,tt;
ll cost[105],weight[105];
ll vis[105][mx];
ll solve(ll pos,ll v)
{
    if(pos==(n+1))return 0;
    ll &ret=dp[pos][v];
    ll &ck=vis[pos][v];
    if(ck==tt)return ret;
    ck=tt;
    ret=0;
    ll niye=0,naniye=0;
    if(v+weight[pos]<=w)niye=cost[pos]+solve(pos+1,v+weight[pos]);
    naniye=solve(pos+1,v);
    return ret=max(niye,naniye);
}
int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    fast; ///no printf/scanf
    ll tst,a,b,c,k,m,res=0,ans=0,t=0;
    sl(n),sl(w);
    for(ll i=1;i<=n;i++)
    {
        sl(weight[i]),sl(cost[i]);
    }
    tt++;
    res=solve(1,0);
    printf("%lld\n",res);


    return 0;
}


Measured memory_bytes: 157952
#include <iostream>
#include <queue>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;


#define REP(i,a,n) for(i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)

bool used[30];
int x[30], y[30], r[30], c[30], over[30];
int n;
char dp[1<<24];

int sqr(int x){ return x*x; }

int solve(int S){
  int i,j, res = 0;

  if( dp[S] != -1 ) return (int)dp[S];
  
  rep(i,n) if( !used[i] && ((S&over[i]) == over[i]) ){
    REP(j,i+1,n) if( !used[j] && c[i] == c[j] && ((S&over[j]) == over[j]) ){
      used[i] = used[j] = true;
      //printf("(%d,%d), S=%d\n",i,j,S|(1<<i)|(1<<j));
      res = max(res, solve(S|(1<<i)|(1<<j)) + 2);
      used[i] = used[j] = false;
    }
  }
  return dp[S] = res;
}

int main(){
  int i,j;
  
  while( scanf("%d",&n), n ){
    memset(used, false, sizeof(used));
    rep(i,1<<n) dp[i] = -1;
    rep(i,n) scanf("%d %d %d %d",x+i,y+i,r+i,c+i);

    rep(i,n){
      int S = 0;
      rep(j,i){
        if( sqr(x[i] - x[j]) + sqr(y[i] - y[j]) < sqr(r[i]) + 2*r[i]*r[j] + sqr(r[j]) ){
          S |= 1<<j;
        }
      }
      over[i] = S;
    }

    printf("%d\n",solve(0));
  }
  
  return 0;
}

Measured memory_bytes: 16000
#include<stdio.h>
int main(void) {

  int W,H,x,y,r;
  
  scanf("%d %d %d %d %d\n",&W, &H, &x, &y, &r);

  if(y<=0 || x<=0 || y>=H || x>=W) {
    printf("No\n");
  }else {
    if(x <= y) {
      if(x >= r) {
        printf("Yes\n");
      }else {
        printf("No\n");
      }
    }else if(x > y) {
      if(y >= r) {
        printf("Yes\n");
      }else {
        printf("No\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e5 + 7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L


int main() {
    int n;
    cin >> n;
    long long k;
    cin >> k;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        x--;
        a[i] = x;
    }
    vector<int> visited(n, -1);
    queue<int> Q;
    Q.push(0);
    int cnt = 0;
    vector<int> visited1(n, -1);
    int cnt1 = 0;
    int start = 0;
    while (!Q.empty()) {
        int u = Q.front();
        Q.pop();
        if (visited[u] >= 0) {
            queue<int> Q1;
            Q1.push(u);
            start = u;
            while (!Q1.empty()) {
                int u1 = Q1.front();
                Q1.pop();
                if (visited1[u1] >= 0) {
                    break;
                }
                visited1[u1] = a[u1];
                Q1.push(a[u1]);
                cnt1++;
            }
            break;
        }
        visited[u] = a[u];
        Q.push(a[u]);
        cnt++;
    }
    int ans = 0;
    cnt++;
    if (k > cnt) {
        ans = visited[start];
        k -= cnt;
        k %= cnt1;
        for (int i = 0; i < k; i++) {
            ans = visited[start];
            start = visited[start];
        }
    }
    else {
        start = 0;
        k--;
        for (int i = 0; i < k; i++) {
            ans = visited[start];
            start = visited[start];
        }
    }
    
    

    cout << visited[ans]+1;
    return 0;
}

Measured memory_bytes: 5608
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<=n;i++)
#define unrep(i,n) for(int i = n;i>0;i++)
using namespace std;
int n,q,S[100000],T[50000];
int ans = 0;
int MyBinarySearch(int a){
  int left = 0;
  int right = q;
  while (left<right){
    int mid = (left + right)/2;
    if(T[mid]<a){
      left = mid+1;;
    }else if(T[mid]>a){
      right = mid;
    }else{
      ans++;
      break;
    }
  }
}

int main(){
  cin >>n;
  rep(i,n)cin >>S[i];
  cin >>q;
  rep(i,q)cin >>T[i];
  sort(S,S+n);
  sort(T,T+q);
  int oldnum = -1;
  rep(i,n){
    if(oldnum != S[i])MyBinarySearch(S[i]);
    oldnum = S[i];
  }
  cout << ans <<endl;
}



Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int y, m, d;
   char a, b;
   cin >> y >> a >> m >> b >> d;
   
   if(m <= 4){
       cout << "Heisei" << endl;
   }else{
       cout << "TBD" << endl;
   }
   return 0;
}

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

using namespace std;

int main(){
    int a;
    int b=0,c;
    scanf("%d",&a);
    for(int i=1;;i*=10){
    	b+=(a%(i*10))/i;
    	if(a/i==0)break;
	}
    if(a%b==0)printf("Yes\n");
    else printf("No\n");
    return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

#include <climits>

using namespace std;


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

	if (a < 10 && b < 10)cout << a * b << endl;
	else cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 3460
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int a[3][3];
int s[30];
int t[30];
int main(){
	for(int i=0;i<3;i++)for(int j=0;j<3;j++){
		scanf("%d",&a[i][j]);
	}
	for(int i=-100;i<=200;i++){
		s[0]=i;
		for(int i=0;i<3;i++){
			t[i]=a[0][i]-s[0];
		}
		for(int i=1;i<3;i++)s[i]=s[0]+a[i][0]-a[0][0];
		bool ok=true;
		for(int i=0;i<3;i++)for(int j=0;j<3;j++)if(a[i][j]!=s[i]+t[j])ok=false;
			if(ok){printf("Yes\n");return 0;}
	}printf("No\n");
}

Measured memory_bytes: 128
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var a=Arr.shift();
   if(a=="0")break;
   var xy=[];
   for(var i=0;i<a;i++)xy.push(Arr.shift());
   var b=Arr.shift();
   var news=[];
   for(var i=0;i<b;i++)news.push(Arr.shift());
   var X=10;
   var Y=10;
   var XY=[];
   news.forEach(function(v){
      var arr=v.split(" ");
      for(var i=0;i<(arr[1]-0);i++){
         if(arr[0]=="N")Y++;
         if(arr[0]=="E")X++;
         if(arr[0]=="W")X--;
         if(arr[0]=="S")Y--;
         XY.push(X+" "+Y);
      }
   });
   var flag=xy.every(function(v){return (XY.indexOf(v)!=-1);});
   console.log(flag?"Yes":"No");
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;


int main() {
   int n;
  cin>>n;
   vin p(n);
  rep(i,n) cin>>p[i];
  //////////
  int ans=0;
  for(int i=1;i<=n-2;i++){
    if(p[i]>p[i-1] &&p[i]<p[i+1]) ans++;
    else if(p[i]<p[i-1] &&p[i]>p[i+1]) ans++;
  }
  cout<<ans<<endl;
}

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

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

  ll N; cin >> N;
  ll INF = 1e15;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  vector<vector<ll>> dp(2, vector<ll>(2, -INF));

  dp[0][0] = 0;
  dp[1][1] = A[0];
  for (ll i = 1; i < N; i++) {
    vector<vector<ll>> dp2(2, vector<ll>(2, -INF));
    if (N & 1) {
      if (i & 1) {
        dp2[0][0] = max(dp[0][0], dp[0][1]);
        dp2[1][0] = max(dp[1][0], dp[1][1]);
        dp2[1][1] = dp[0][0] + A[i];
      } else {
        dp2[0][0] = max(dp[1][0], dp[1][1]);
        dp2[0][1] = dp[0][0] + A[i];
        dp2[1][1] = dp[1][0] + A[i];
      }
    } else {
      if (i & 1) {
        dp2[0][0] = max(dp[1][0], dp[1][1]);
        dp2[0][1] = dp[0][0] + A[i];
      } else {
        dp2[0][0] = max(dp[0][0], dp[0][1]);
        dp2[1][1] = dp[0][0] + A[i];
      }
    }
    dp = dp2;
  }

  cout << max(dp[0][0], dp[0][1]) << '\n';
  return 0;
}

Measured memory_bytes: 4752
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long

ll count(ll a) {
  ll ret = 0;
  for (ll i = 1; i < a; i++) ret += i;
  return ret;
}

int main() {
  ll N;
  int64_t ans = 0;
  cin >> N;
  string s;
  map<string,ll> mp;
  for (ll i = 0; i < N; i++) {
    cin >> s;
    sort(s.begin(), s.end());
    mp[s] += 1;
  }
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    ll a = itr->second;
    if (a > 1) ans += count(a);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10;
ll arr[N];
int main() {
	ll n;
	cin >> n;
	ll x = 0;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		x ^= arr[i];
	}
	for (int i = 1; i <= n; i++)
		cout << (arr[i]^x) << " ";

	return 0;
}

Measured memory_bytes: 5120
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
int N, X[200010];
int T[200010];
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N){
        cin>>X[i];
        T[i] = X[i];
    }

    sort(X, X+N);
    int midInd = N/2;

    REP(i,0,N){
        if(T[i] < X[midInd]){
            cout<<X[min(N-1, midInd)]<<endl;
        }else{
            cout<<X[max(0, midInd-1)]<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 10000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	ll a, b;
	cin >> a >> b;
	
	ll mx = gcd(a, b);
	ll count = 0;
	for(ll i = 2; i*i <= mx; ++i){
		if(mx % i != 0) continue;
		count++;
		while(mx % i == 0){
			mx /= i;
		}
	}
    if (mx != 1) count++;
	cout << count + 1 << endl;
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var dict = new Dictionary<string, int>();
            string s;
            while ((s = Console.ReadLine()) != null)
            {
                var a = s.Split(' ').ToArray();
                foreach (var v in a)
                {
                    if (dict.ContainsKey(v))
                    {
                        var val = dict[v];
                        dict.Remove(v);
                        dict.Add(v, ++val);
                    }
                    else
                    {
                        dict.Add(v, 1);
                    }
                }
            }
            int sl = 0;
            var list = dict.Keys;
            var resVal = "";
            string resKey = "";
            foreach (var v in list)
            {
                if (v.Length > resVal.Length) { resVal = v; }
                if (dict[v] > sl) { sl = dict[v]; resKey = v; }
            }
            Console.WriteLine("{0} {1}", resKey, resVal);
        }
    }
}

Measured memory_bytes: 5732
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2018/7/21 20:19
# @Version : 1.1
# @Author  : Jade
# @File    : acm.py
# @Software: PyCharm
#
a,b,c = map(int,input().split(' '))
print(max(a,b,c) - min(a,b,c))

Measured memory_bytes: 38256
n = int(input())
v_list = list(map(int, input().split()))

v_list_sorted = sorted(v_list)

for i in range(n - 1):
    top = v_list_sorted.pop(0)
    v_list_sorted[0] = (v_list_sorted[0] + top) / 2

print(v_list_sorted[0])

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

 int main() {
   int N;
   cin >> N;

   vector<int> C(N), S(N), F(N);

   rep(i, 0, N - 1) cin >> C.at(i + 1) >> S.at(i + 1) >> F.at(i + 1);

   rep(i, 1, N) {
     int x = 0;
     rep(j, i, N) {
       x = ceil(max(x, S.at(j)) * 1.0 / F.at(j))* F.at(j) + C.at(j);
     }
     cout << x << endl;
   }
   cout << 0 << endl;
 }


Measured memory_bytes: 256
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
i8 = np.int64
i4 = np.int32


def main():
    stdin = open('/dev/stdin')
    pin = np.fromstring(stdin.read(), i8, sep=' ')
    N = pin[0]
    M = pin[1]
    L = pin[2]
    ABC = pin[3: M * 3 + 3].reshape((-1, 3))
    A = ABC[:, 0] - 1
    B = ABC[:, 1] - 1
    C = ABC[:, 2]
    Q = pin[M * 3 + 3]
    st = (pin[M * 3 + 4: 2 * Q + M * 3 + 4] - 1).reshape((-1, 2))
    s = st[:, 0]
    t = st[:, 1]

    graph = csr_matrix((C, (A, B)), shape=(N, N))
    dist = np.array(floyd_warshall(graph, directed=False))
    dist[dist > L + 0.5] = 0
    dist[dist > 0] = 1
    min_dist = np.array(floyd_warshall(dist))
    min_dist[min_dist == np.inf] = 0

    min_dist = (min_dist + .5).astype(int)
    x = min_dist[s, t] - 1
    print('\n'.join(x.astype(str).tolist()))


if __name__ == '__main__':
    main()


Measured memory_bytes: 32884
from collections import deque
N=int(input())
A=list(map(int,input().split()))
A.sort()
A=deque(A)
L=deque([])
for i in range(N):
    if len(A)>=3:
        a=A.popleft()
        b=A.pop()
        if (b-a)-A[0] >= A[-1]-(a-b):
            A.append(b-a)
            L.append([b,a])
        else:
            A.appendleft(a-b)
            L.append([a,b])
    elif len(A)==2:
        a = A.popleft()
        b = A.pop()
        A.append(b-a)
        L.append([b,a])
        break
    else:
        break
print(A[0])
for j in L:
    print(j[0],j[1],sep=' ')


Measured memory_bytes: 72220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=44;
#define MP make_pair
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
    int x=0,f=0;char ch=getchar();
    while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
    while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
    return f?-x:x;
}
int n,a[maxn][maxn];
char s[maxn];
ll f[maxn][maxn][maxn],fs[maxn][maxn][maxn],ans;
int main(){
	n=read()*2;
	FOR(i,1,n){
		scanf("%s",s+1);
		FOR(j,1,n) a[i][j]=s[j]-'0';
	}
	if(n==2) return printf("%d\n",a[1][2]),0;
	FOR(i,2,n){
		f[i][i][i]=1;
		FOR(j,2,n) if(a[i][j]) fs[i][j][i]+=f[i][i][i];
	}
	FOR(len,3,n-1) if(len%2==1) FOR(l,2,n-len+1){
		int r=l+len-1;
		FOR(i,l,r) FOR(j,2,n) if(a[i][j]) fs[l][j][r]-=f[l][i][r];
		FOR(p,l,r) FOR(q,p+1,r){
			ll s=0;
			FOR(k,q,r) s+=fs[l][k][p]*f[q][k][r];
			FOR(i,p+1,q-1) f[l][i][r]+=s*f[p+1][i][q-1];
		}
		FOR(i,l,r) FOR(j,2,n) if(a[i][j]) fs[l][j][r]+=f[l][i][r];
	}
	FOR(i,2,n) if(a[1][i]) ans+=f[2][i][n];
	printf("%lld\n",ans);
}
// fk

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      Dice dice3a = new Dice(br.readLine().split(" "));
      Dice dice3b = new Dice(br.readLine().split(" "));
      String result = "No";

      dice3a.setFrontPosition(dice3a.getFrontSide());
      dice3b.setFrontPosition(dice3a.getFrontSide());

      for(int i=0; i<4; i++)  {
        for(int j=0; j<4; j++) {
          if( dice3a.equals(dice3b) ) {
            result = "Yes";
            break;
          }
          else dice3b.rotate("W");
        }
        if( dice3a.equals(dice3b)) break;
        dice3b.rotate("N");
      }
      System.out.println(result);
    }
  }
}

class Dice {
  private int[] side;

  public Dice( int[] ia ) {
    side = Arrays.copyOf(ia, ia.length);
  }
  public Dice( String[] s ) {
    side = new int[s.length];
    for ( int i=0; i < 6; i++)
      side[i] = Integer.parseInt(s[i]);
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof Dice)) return false;
    Dice r = (Dice) o;

    if(
      (side[0] == r.side[0]) &&
      (side[1] == r.side[1]) &&
      (side[2] == r.side[2]) &&
      (side[3] == r.side[3]) &&
      (side[4] == r.side[4]) &&
      (side[5] == r.side[5])
      ) return true;
    else return false;
  }

  public int getUpperSide() {
    return side[0];
  }
  public int getLowerSide() {
    return side[5];
  }
  public int getFrontSide() {
    return side[1];
  }
  public int getBackSide() {
    return side[4];
  }
  public int getRightSide() {
    return side[2];
  }
  public int getLeftSide() {
    return side[3];
  }

  public void setFrontPosition(int n) {
    for(int i=0; i < 3; i++){
      if(getUpperSide() != n) rotate("N");
    }
    for(int i=0; i < 3; i++){
      if(getUpperSide() != n) rotate("W");
    }
    rotate("S");
  }

  public int doRotate(String s) {
    for ( int i=0; i < s.length(); i++ ) {
      rotate(s.substring(i, i+1));
    }
    return side[0];
  }

  public void rotate(String o) {
    switch(o) {
      case "N" :
        rotateN();
        break;
      case "S" :
        rotateS();
        break;
      case "W" :
        rotateW();
        break;
      case "E":
        rotateE();
        break;
      default :
    }
  }

  private void rotateN() {
    int tmp = side[0];
    side[0] = side[1]; side[1] = side[5]; side[5] = side[4];
    side[4] = tmp;
  }
  private void rotateS() {
    int tmp = side[0];
    side[0] = side[4]; side[4] = side[5]; side[5] = side[1];
    side[1] = tmp;
  }
  private void rotateW() {
    int tmp = side[0];
    side[0] = side[2]; side[2] = side[5]; side[5] = side[3];
    side[3] = tmp;
  }
  private void rotateE() {
    int tmp = side[0];
    side[0] = side[3]; side[3] = side[5]; side[5] = side[2];
    side[2] = tmp;
  }
}


Measured memory_bytes: 24396
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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


int main(int argc, char**argv){
    string s;
    cin >> s;

    bool check = false;
    for (int i = 1; i < s.size(); i++){
        if (s[i] == s[i-1]) check = true;
    }
    if (check) cout << "Bad" << endl;
    else cout << "Good" << endl;

}





















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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	int n; cin >> n;


	vector <int> a(n);

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

	int cnt = 0;

	for(int i = 0; i < n; i++){
		if(a[i] != i + 1){
			cnt++;
		}
	}


	cout << (cnt > 2 ? "NO" : "YES") << endl;

	
	return 0;
}

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

int main(){

    long long a,b,k;
    cin>>a>>b>>k;
    if(k<=a) cout<<a-k<<" "<<b<<endl;
    else if(k<=a+b) cout<<0<<" "<<b-(k-a)<<endl;
    else cout<<0<<" "<<0<<endl;

    return 0;
}

Measured memory_bytes: 256
import sys

#input_file = open(sys.argv[1], "r")

#for line in input_file:
for line in sys.stdin:
    nums = map(int, line.split(' '))
    nums.sort(lambda x, y: cmp(y, x))
#    print ' '.join(map((lambda x: str(x)), nums))
    print ' '.join(map(str, nums))

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

vector<int> v[100001];

int main() {
  int n,m,k;
  cin >> n >> m >> k;
  int ans=0,a[n];
  memset(a,-1,sizeof(a));
  for(int j=1; j<=k; j++) {
    bool f=0;
    int z,x,y;
    cin >> z >> x >> y;
    x--,y--;
    if(z==1) {
      v[x].push_back(y);
      v[y].push_back(x);
      if(a[x]>=0&&a[y]>=0&&a[x]!=a[y]) f=1;
      queue<int> que;
      que.push(x);
      que.push(y);
      while(!que.empty()) {
        int s=que.front();que.pop();
        if(a[s]==-1) continue;
        for(int i=0; i<v[s].size(); i++) {
          int t=v[s][i];
          if(a[t]==-1) {
            a[t]=a[s];
            que.push(t);
          } else if(a[t]!=a[s]) f=1;
        }
      } 
    } else {
      if(a[x]!=-1 && a[x]!=y) f=1;
      a[x]=y;
      queue<int> que;
      que.push(x);
      while(!que.empty()) {
        int s=que.front();que.pop();
        for(int i=0; i<v[s].size(); i++) {
          int t=v[s][i];
          if(a[t]==-1) {
            a[t]=a[s];
            que.push(t);
          } else if(a[t]!=a[s]) f=1;
        }
      }
    }
    if(f && !ans) ans=j;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main() {
  int h,w,n;
  cin>>h>>w>>n;
  if(w>h)swap(w,h);
  int ans=ceil((double)n/h);
  cout<<ans<<endl;
  
  
  


  return 0;
}


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

vector<int> a[nmax];
int h[nmax];
int main(){
    int n,m,x,y,rez=0,ok;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    for(int i=1;i<=m;i++){
        cin>>x>>y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    for(int i=1;i<=n;i++){
        ok=1;
        for(auto el:a[i]){
            if(h[el]>=h[i])
            ok=0;
        }
        if(ok==1) { rez++;}
    }
    cout<<rez;
}

Measured memory_bytes: 9160
import java.util.ArrayList;
import java.util.Scanner;

class Main {
    static Scanner sc;

    private static void nextArr(int[] h) {
        for(int i = 0; i < h.length; i++) h[i] = sc.nextInt();
    }

    private static int nextInt() {
        return sc.nextInt();
    }

    private static void print(Object... vals) {
        for(int i = 0; i < vals.length; i++) {
            if (i != vals.length - 1) {
                System.out.print(vals[i] + ",");
            } else {
                System.out.print(vals[i]);
            }
        }
        System.out.println();
    }

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Vertex[] tree = new Vertex[n];
        for(int i = 0; i < n; i++) tree[i] = new Vertex(i);
        for(int i = 0; i < m; i++) {
            int v1 = sc.nextInt();
            int v2 = sc.nextInt();
            tree[v1 - 1].addEdge(tree[v2 - 1]);
        }
        int ans = Integer.MIN_VALUE;
        for(int i = 0; i < n; i++) {
            ans = Math.max(ans, tree[i].getMax());
        }
        print(ans);
    }

    static class Vertex {
        int id;
        ArrayList<Vertex> edges;
        int max;

        public Vertex(int id) {
            this.id = id;
            this.edges = new ArrayList<Vertex>();
            this.max = Integer.MIN_VALUE;
        }

        public void addEdge(Vertex other) {
            this.edges.add(other);
        }

        public int getMax() {
            if(this.max != Integer.MIN_VALUE) return this.max;
            if(this.edges.size() == 0) {
                this.max = 0;
                return this.max;
            }
            for(Vertex other: this.edges) {
                this.max = Math.max(this.max, other.getMax() + 1);
            }
            return this.max;
        }

    }
}


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

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

    int a,b;
    // 引数の受け取り
    //
    cin >> a >> b;
    
     cout << (a-b < 0 ? 0 : (a-b)) << endl;

    // 出力
    return 0;
}



Measured memory_bytes: 256
// Problem : E - Coprime
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Delete the dynamically allocated memory

#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<int>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)

#define MAXN   1000001 
  
// stores smallest prime factor for every number 
int spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
vector<int> getFactorization(int x) 
{ 
    vector<int> ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    vector<int> ret1;
    set<int> s;
    for(unsigned int i=0;i<ret.size();i++){
    	if(s.find(ret[i])==s.end()){
    		s.insert(ret[i]);
    		ret1.pb(ret[i]);
    	}
    }
    return ret1; 
} 
  
// driver program for above function 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	sieve(); 
	int n;
	cin>>n;
	mk(a,n,int)
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	mk(p,n,vr)
	for(int i=0;i<n;i++){
		p[i]=getFactorization(a[i]);
	}
	set<int> s;
	bool f=true;
	for(int i=0;i<n;i++){
		for(unsigned int j=0;j<p[i].size();j++){
			if(s.find(p[i][j])==s.end()){
				s.insert(p[i][j]);
			}else{
				// cout<<i<<" "<<j<<"\n";
				f=false;
				break;
			}
		}
		if(!f){
			break;
		}
	}
	if(f){
		cout<<"pairwise coprime"<<"\n";
	}else{
		int g=a[0];
		for(int i=1;i<n;i++){
			g=__gcd(g,a[i]);
		}
		if(g==1){
			cout<<"setwise coprime"<<"\n";
		}else{
			cout<<"not coprime"<<"\n";
		}
	}
	delete[] a;
	return 0;
	}

Measured memory_bytes: 79632
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)

double dt[102][102];
double dp[102][102];
int n;

double dfs(int d,int v){
	if(abs(dp[d][v]+1)>1e-6)return dp[d][v];
	if(d == 0) return 1.0;
	double r=-1;
	for(int i = 0 ; i < n ; i++){
		r = max(r,dfs(d-1,i) * dt[i][v]);
	}

	return dp[d][v] = r;
}

int main(void){
	int m;
	while(cin>>n>>m,n+m){

		rep(i,n)
			rep(j,n)cin>>dt[i][j];
		rep(i,102)rep(j,102)dp[i][j] = -1;
		
		//rep(i,n)rep(j,n)cout<<dt[i][j]<<(j==n-1?'\n':' ');


		double r = 0;
		rep(i,n){
			r = max(r,dfs(m-1,i));
		}
		printf("%.2f\n",r+1/2*(1/10)*2);
	}
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int h,w;
    string s[1010];
    cin >> h >> w;
    for (int i = 0;i < h;++i) cin >> s[i];
    int mn = 1000000,mx = 0,ans;
    for (int i = 0;i < h;++i) {
        for (int j = 0;j < w;++j) if (s[i][j] == 'B') {
            mn = min(mn,i+j);
            mx = max(mx,i+j);
        }
    }
    ans = mx-mn;
    mn = 1000000,mx = 0,ans;
    for (int i = 0;i < h;++i) {
        for (int j = w-1;j >= 0;--j) if (s[i][j] == 'B') {
            mn = min(mn,i+w-1-j);
            mx = max(mx,i+w-1-j);
        }
    }
    ans = max(ans,mx-mn);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3928