akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define MAX 1000000000000000
int n,c,val[105],cost[105],dp[100005];
int knapsack()
{
	for(int i=0;i<=n;i++)
	{
		for(int j=100000;j>=0;j--)
		{
			if(j==0)
			dp[j]=0;
			else if(i==0)
			dp[j]=MAX;
			else if(j>=val[i])
			dp[j]=min(dp[j],dp[j-val[i]]+cost[i]);
			else
			dp[j]=dp[j];
		}
	}
	int m=0;
	for(int j=0;j<=100000;j++)
	if(dp[j]<=c)
	m=j;
	return m;
}
signed main()
{
	int i;
	cin>>n>>c;
	for(i=1;i<=n;i++)
	cin>>cost[i]>>val[i];
	cout<<knapsack()<<"\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int A, B;
  cin>>A>>B;

  if(1 <= A && A <= 9 && 1 <= B && B <= 9) cout<<A * B<<endl;
  else cout<<-1<<endl;

  return 0;
}


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

int main() {
	string s; int q;
	cin >> s >> q;
	int t, f; char c;
	deque < char > dq;
	bool reversed = false;
	for (char c : s) {
		dq.push_back (c);
	}
	while (q--) {
		cin >> t;
		if (t == 1) {
			reversed = !reversed;
		} else {
			cin >> f >> c;
			bool rev = reversed ^ (f == 2);
			if (rev) {
				dq.push_back (c);
			} else {
				dq.push_front (c);
			}
		}
	}
	s = "";
	if (reversed) {
		while (!dq.empty()) {
			s += dq.back(); dq.pop_back();
		}
	} else {
		while (!dq.empty()) {
			s += dq.front(); dq.pop_front();
		}
	}
	cout << s << endl;
	return 0;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
int vis[N] = {0};
bool viss[N] = {0};

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

int main()
{
  ll n ,m;
  std::cin >> n>>m;
  cout<<(fxor(n-1)^fxor(m))<<endl;
  return 0;
}


Measured memory_bytes: 12416
import math
import itertools
def distance(p1, p2):
    return math.sqrt((p1[0]-p2[0])**2 + (p1[1] - p2[1])**2)
n = int(input())
adj = {}
for i in range(1, n+1):
    x, y = map(int, input().split())
    adj[i] = (x, y)
dd = {}
ans = 0
for i in range(1, n):
    for j in range(i+1, n+1):
        dist = distance(adj[i], adj[j])
        ans += dist
print(format((2 * ans) / n, '.10f'))

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int n;
    cin>>n;
    bool flag = false;
    FOR(i,1,10) {
        if (n % i == 0 && n / i < 10)
            flag = true;
    }
    Yes(flag);

    return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

bool calc(int n, int y) {
    for (int a = 0; a <= 2000; a++) {
        int x = y - 1000 * n - 9000 * a;
        if (x < 0) return false;

        if (x % 4000 == 0) {
            int b = x / 4000;
            int c = n - a - b;
            if (c >= 0) {
                writeln(a, " ", b, " ", c);
                return true;
            }
        }
    }
    return false;
}

void main() {
    auto ny = readints;
    int n = ny[0], y = ny[1];

    bool found = calc(n, y);
    if (!found) writeln("-1 -1 -1");
}


Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  int r;
  cin >> r;
 
  cout << r*r << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}

map<int,int> f(map<int,int> a,map<int,int> b){
  map<int,int> res;
  for(P ma:a){
    for(P mb:b){
      
      res[ma.F+mb.F]+=ma.S*mb.S;
    }
  }

  return res;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,v;
  cin>>n>>v;
  map<int,int> mpa,mpb,mpc,mpd;
  rep(i,n){
    int a;
    cin>>a;
    mpa[a]++;
  }
  rep(i,n){
    int a;
    cin>>a;
    mpb[a]++;
  }
  rep(i,n){
    int a;
    cin>>a;
    mpc[a]++;
  }
  rep(i,n){
    int a;
    cin>>a;
    mpd[a]++;
  }

  auto mpab=f(mpa,mpb);
  auto mpcd=f(mpc,mpd);

  int ans=0;
  for(auto m:mpab){
    //cout<<m.F<<' '<<m.S<<endl;
    if(mpcd.find(v-m.F)==mpcd.end()) continue;
    ans+=m.S*mpcd[v-m.F];
  }

  cout<<ans<<endl;

}


Measured memory_bytes: 128544
N,M = gets.strip.split.map(&:to_i)
high = gets.strip.split.map(&:to_i)

ary = Array.new(N,1) #個数が先
M.times do #こうしてM行を1行ずつ読んでいく
  x,y = gets.strip.split.map(&:to_i)
  #予選決勝砲（脱落車を弾いていく）
  if high[x-1] > high[y-1] then
    ary[y-1] = 0
  elsif high[x-1] < high[y-1] then
    ary[x-1] = 0
  else
    ary[x-1] = 0
    ary[y-1] = 0
  end
end
#小さい方だけをどんどん潰していけばOK、大きい方はいじらない
#最後まで１のままだった奴が合格
puts ary.sum

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

int main() {
  int n;
  cin>>n;
  vector<string>s(n);
  for(int i=0;i<n;i++) cin>>s[i];
  sort(s.begin(),s.end());
  int big=1;
  int kari=1;
  string r=s[0];
  int i=1;
  while(i<n){
    if(r==s[i]) {
      kari++;
      if(i==n-1) big=max(big,kari);
    }
    else{
      big=max(big,kari);
      kari=1;
      r=s[i];
    }
    i++;
  }
  i=1;
  kari=1;
  r=s[0];
  while(i<n){
    if(r==s[i]){
      kari++;
      if(i==n-1){
        if(kari==big) cout<<r<<endl;
      }
    }
    else{
      if(kari==big){
        cout<<r<<endl;
      }
      if(i==n-1 && big==1) cout<<s[i]<<endl;
      r=s[i];
      kari=1;
    }
    i++;
  }
  if(n==1) cout<<s[0]<<endl;
}

Measured memory_bytes: 14208
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
 
int main(){
  ll N,X;
  cin>>N>>X;
  VL A(N);
  rep(i,N) cin>>A[i];
  ll ans=0;
  if(A[0]>X){
    ans+=A[0]-X;
    A[0]=X;
  }
  rep(i,N-1){
    if(A[i+1]+A[i]>X){
      ans+=A[i+1]+A[i]-X;
      A[i+1]-=A[i+1]+A[i]-X;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
typedef long long ll;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

int n,m;
vector<vector<ll>> dp;
signed main () {
    scanf("%d %d",&n,&m);
    dp.assign(n,vector<ll>(n,INF));
    for(int i= 0;i<n;i++)dp[i][i] = 0;
    REP(i,m){
        ll a,b,c;scanf("%lld %lld %lld",&a,&b,&c);
        dp[a][b] = c;
    }
    REP(k,n){
        REP(i,n){
            REP(j,n){
                if(dp[i][k] != INF && dp[k][j] != INF){
                    dp[i][j]=min(dp[i][j], dp[i][k] + dp[k][j]);
                }
            }
        }
    }

    REP(i,n){
        if(dp[i][i] < 0 ){
            printf("NEGATIVE CYCLE\n");
            return 0; 
        }
    }
    REP(i,n){
        REP(j,n){
            if(dp[i][j]==INF){
                printf("INF");
            } else {
                printf("%lld",dp[i][j]);
            }
            if(j!=n-1){
                printf(" ");
            } else {
                printf("\n");
            }
        }
    }
}


Measured memory_bytes: 3340
#include<stdio.h>

int main(void){
    int time;
    int h,m,s;

    scanf("%d",&time);
    h=time/3600;
    m=(time-h*3600)/60;
    s=time-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2080
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;
using i64=long long int;

int main() {
    int n;
    cin >> n;
    int h, w;
    cin >> h;
    cin >> w;

    cout << (n-h+1)*(n-w+1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define NUM 100
using namespace std;

int p[NUM];
int result[NUM][NUM];

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

    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            int tmp;
            cin >> tmp;
            result[u - 1][tmp - 1] = 1;
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (j)
                cout << ' ';
            cout << result[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

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

int main() {
    string S;
    cin >> S;

    reverse(S.begin(), S.end());

    map<ll, ll> table;

    ll sum = 0;
    ll x = 1;
    ll ans = 0;
    for (ll i = 0; i < S.size(); i++) {
        // cout << "sum: " << sum << endl;
        ++table[sum];
        ll d = S[i] - '0';
        sum = (sum + x * d) % 2019;
        ans += table[sum];
        x = (x * 10L) % 2019;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3356
#include <bits/stdc++.h>
#define MAX 100005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);
#define fi(a,b,c) for(int i=a;i<b;i=i+c)
#define fj(a,b,c) for(int j=a;j<b;j+=c)
using namespace std;
 
ll gcd(ll n1,ll n2) {
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent) {
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
ll max(ll a,ll b,ll c) {
	return max(a,max(b,c));
}
int max(int a,int b,int c) {
	return max(a,max(b,c));
}

int main()
{
	int s,w;
	sd(s);sd(w);
	if(w>=s){
		printf("unsafe");
	}else{
		printf("safe");
	}
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
#define INF "{"
using namespace std;
typedef pair<string,int> P;

vector<string> e[41][41];
int n,a,s,g;
string cal(){
  priority_queue<P,vector<P>,greater<P> > q;
  bool used[40][400]={};
  q.push(P("",s));
  while(!q.empty()){
    string sm=q.top().first;
    int p=q.top().second;
    q.pop();
    if(p==g){
      if(sm.size()>250) return "NO";
      return sm;
    }
    if(sm.size()>=400||used[p][sm.size()])continue;
    used[p][sm.size()]=1;
    for(int i=0;i<n;i++)
      for(int j=0;j<e[p][i].size();j++)
	q.push(P(sm+e[p][i][j],i));
  }
  return "NO";
}

int main(){
  while(cin>>n>>a>>s>>g,n){
    string st;
    for(int i=0;i<40;i++)
      for(int j=0;j<40;j++)e[i][j].clear();
    for(int i=0,x,y;i<a;i++){
      cin>>x>>y>>st;
      e[x][y].push_back(st);
    }
    cout<<cal()<<endl;
  }
  return 0;
}

Measured memory_bytes: 25296
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {
      var n = readLine.split(" ")
      while( n(1) != "?" ) {
        n(1) match {
          case "+" => println(n(0).toInt + n(2).toInt)
          case "-" => println(n(0).toInt - n(2).toInt)
          case "/" => println(n(0).toInt / n(2).toInt)
          case "*" => println(n(0).toInt * n(2).toInt)
        }
        n = readLine.split(" ")
      }
  }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k, m = 0;
  string s;
  cin >> n >> k >> s;
  vector<int> r(1);
  for(int i = 1; i < n; i++)
    if(s[i - 1] != s[i]) r.push_back(i);
  r.push_back(n);
  for(int i = 0; i < r.size() - 1; i++) {
    if(s[r[i]] == '0')
      m = max(m, r[min(i + k * 2, (int)r.size() - 1)] - r[i]);
    else
      m = max(m, r[min(i + k * 2 + 1, (int)r.size() - 1)] - r[i]);
  }
  cout << m << '\n';
}

Measured memory_bytes: 1020
#include <stdio.h>

int main()
{
	int A, B;
	scanf("%d %d", &A, &B);
	if (A + B >= A - B && A + B >= A * B) printf("%d\n", A + B);
	else if (A - B >= A + B && A - B >= A * B) printf("%d\n", A - B);
	else printf("%d\n", A * B);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1732
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
      	String s = sc.next();
        String t = sc.next();
      	char ss[] = s.toCharArray();
    	char ts[] = t.toCharArray();
      	char trs[] = new char[t.length()];
      
      	Arrays.sort(ss);
      	Arrays.sort(ts);
      	
      	for(int i = 0;i < t.length();i++) trs[i] = ts[t.length()-1-i];
      
      	s = new String(ss);
      	t = new String(trs);
          
      	if(s.compareTo(t) < 0) System.out.println("Yes");
      	else System.out.println("No");
      
	}
}

Measured memory_bytes: 35684
import sys
input = sys.stdin.readline
def f():
  n=int(input())
  l=tuple(tuple(map(int,input().split())) for i in range(n-1))
  for i in range(n):
    now=0
    for a,s,d in l[i:]:
      if now<=s:now=s+a
      else:now=-(-now//d)*d+a
    print(now)
if __name__=="__main__":
  f()


Measured memory_bytes: 3188
#include <stdio.h>
int main(void)
{
    int W,H,x,y,r;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    if(x-r>=0 && y-r>=0 && x+r<=W && y+r<=H){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 584
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;



int main(){

	int n,r,k,to,table[101][101],num_of_packet,start,goal,t_limit,memo[101][101],P[101],D[101],num,min,min_index,current;

	for(int i=1; i < 101; i++){
		for(int k=1; k < 101; k++){
			table[i][k] = 0;
			memo[i][k] = 0;
		}
	}

	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%d %d",&r,&k);
		for(int p=0;p < k; p++){
			scanf("%d",&to);
			table[r][to] = 1;
		}
	}

	scanf("%d",&num_of_packet);

	bool FLG;

	for(int i=0; i < num_of_packet; i++){
		scanf("%d %d %d",&start,&goal,&t_limit);

		FLG = false;

		if(t_limit <= 1){
			printf("NA\n");
			continue;
		}

		if(memo[start][goal] != 0){
			if(memo[start][goal] <=  t_limit){
				printf("%d\n",memo[start][goal]);
			}else{
				printf("NA\n");
			}
			continue;
		}

		for(int index=1; index <= n; index++){
			P[index] = 0;
			D[index] = 1000000000;
		}

		P[start] = 1;
		num = 1;

		for(int index = 1; index <= n; index++){
			if(index != start && table[start][index] == 1){
				D[index] = 1;
			}
		}

		if(FLG)continue;

		while(num < n){
			min = 1000000000;
			for(int index=1;index <= n; index++){
				if(P[index] == 0 && D[index] < min){
					min = D[index];
					min_index =index;
				}
			}

			if(min == 1000000000)break;

			P[min_index] = 1;
			current = min_index;
			num++;
			for(int i=1; i <= n; i++){
				if(table[current][i] == 1){
					D[i] = (D[i] <= (D[current]+1))?D[i]:(D[current]+1);
				}
			}

		}

		if(D[goal] >= t_limit){
			printf("NA\n");
		}else{
			memo[start][goal] = D[goal]+1;
			printf("%d\n",D[goal]+1);
		}

	}

    return 0;
}

Measured memory_bytes: 2756
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	long ans;
	foreach (c; S)
	{
		if (c == '+')
			++ans;
		else
			--ans;
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}


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

int main(int argc, char const *argv[])
{
	int n,m;
	char c;
	int ans=0;
	cin >> n >> m;
	for (int i = 0; i < n*m; ++i)
	{
		cin >> c;
		if(c=='#') ans++;
	}
	if(ans==n+m-1) printf("Possible\n");
	else printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int box[5];
	int i,j;
	
	for(i=0;i<5;i++)	cin>>box[i];
	for(i=0;i<4;i++){
		for(j=i+1;j<5;j++){
			if(box[i]<box[j])	swap(box[i],box[j]);
		}
	}
	for(i=0;i<5;i++){
		if(i)	cout<<" ";
		cout<<box[i];
	}
	cout<<endl;
	return 0;
}


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


int main()
{
  string tanm , fanm;
  int num , tcount = 0 , fcount = 0;

  cin >> num;

  for( int i = 0; i < num; i++ )
    {
      cin >> tanm >> fanm;
      if( tanm > fanm )
	tcount += 3;
      else if( tanm < fanm )
	fcount += 3;
      else{ 
	tcount++;
	fcount++;
      }
    }
  cout << tcount << " " << fcount << endl;
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll N=2e5+5;
const ll MOD=1e9+7;
const ld pi=3.14159265359;
const ll INF=(1LL<<60);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll n,m;

int main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>m;
	if(n>=2&&m>=2){
		cout<<(n-2)*(m-2)<<"\n";
	}else if(n>=2||m>=2){
		cout<<n*m-2<<"\n";
	}else{
		cout<<1<<"\n";
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int X = sc.nextInt();
   int A = sc.nextInt();
   int B = sc.nextInt();
   
   int n = (X-A)/B;
   System.out.println(X-A-B*n);
 }
}

Measured memory_bytes: 21844
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");
//    	Scanner sc = new Scanner(file);

    	Scanner sc = new Scanner(System.in);

    	long A = sc.nextLong();
    	long B = sc.nextLong();
    	long K = sc.nextLong();

    	if(A>=K) {
    		System.out.println((A-K)+" "+B);
    	} else {
    		if(A+B>=K) {
    			System.out.println("0 "+(A+B-K));
    		} else {
    			System.out.println("0 0");
    		}
    	}

    }

}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.util.Comparator.comparingLong;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  private class Participant {
    private long height, power;

    private Participant(long height, long power) {
      this.height = height;
      this.power = power;
    }
  }

  public void solve() {
    int n = in.ni();
    Participant[] participants = new Participant[n];
    for (int i = 0; i < n; i++) {
      participants[i] = new Participant(in.nl(), in.nl());
    }
    Arrays.sort(participants, comparingLong(x -> x.height + x.power));
    long[][] dp = new long[2][n + 1];
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j <= n; j++) {
        dp[i][j] = Long.MAX_VALUE;
      }
    }
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dp[0][j] <= participants[i].height) {
          dp[1][j + 1] = Math.min(dp[1][j + 1], dp[0][j] + participants[i].power);
        }
        dp[1][j] = Math.min(dp[1][j], dp[0][j]);
      }
      dp[1][n] = Math.min(dp[0][n], dp[1][n]);

      long[] tmp = dp[0];
      Arrays.fill(tmp, Long.MAX_VALUE);
      dp[0] = dp[1];
      dp[1] = tmp;
    }
    for (int i = n; i >= 0; i--) {
      if (dp[0][i] != Long.MAX_VALUE) {
        out.println(i);
        return;
      }
    }
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// どういうDPか
// dp[i][j] := sのi文字目までとtのj文字目までのLCSの最大の長さ

// 計算方法
// 1-indexにすると良い
// dp[0][j] = dp[i][0] = 0
// dp[i][j] = max(dp[i-1][j], dp[i][j-1])
// if s_i == t_j -> dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1)

// どういう順番
// 復元
// 斜めの線をたどっていく

ll dp[3100][3100];

int main() {
    string s, t;
    cin >> s >> t;

    int n = s.size(), m = t.size();
    for (int i=1; i<=n; ++i) {
        for (int j=1; j<=m; ++j) {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if (s[i-1] == t[j-1]) dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
        }
    }

    string rewsna = "";
    while (n > 0 and m > 0) {
        if (s[n-1] == t[m-1]) {
            rewsna += s[n-1];
            n--;
            m--;
        }
        else {
            if (dp[n-1][m] > dp[n][m-1]) {
                n--;
            }
            else {
                m--;
            }
        }
    }

    reverse(rewsna.begin(), rewsna.end());
    cout << rewsna << endl;
}


Measured memory_bytes: 74112
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;


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

	cin >> N;
	vector<pair<int, int>>v;
	for (int i = 2; i <= N; i += 2) {
		v.push_back({ i,1 });
	}
	for (int i = 2; i <= N; i += 3) {
		for (int j = 2 + ((i + 1) & 1); j <= N; j += 2) {
			v.push_back({ i,j });
		}
	}
	if (N % 3 == 1) {
		for (int j = 2 + ((N + 1) & 1); j <= N; j += 2) {
			v.push_back({ N,j });
		}
	}
	cout << v.size() << endl;
	for (auto i : v) {
		cout << i.first-1 << " " << i.second-1 << endl;
	}
}

Measured memory_bytes: 2928
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    print(3 * int(input())**2)


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 28908
#include<cstdio>
#include<cstring>

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

using namespace std;

int main(){
	for(int n,h;scanf("%d%d",&n,&h),n||h;){
		int cnt=n*n*n;
		bool xy[500][500]={},xz[500][500]={},yz[500][500]={};
		rep(i,h){
			char s[3];
			int a,b;	scanf("%s%d%d",s,&a,&b);
			a--,b--;

			cnt-=n;
			if(strcmp(s,"xy")==0){
				rep(z,n) if(xz[a][z]||yz[b][z]) cnt++;
				xy[a][b]=true;
			}
			else if(strcmp(s,"xz")==0){
				rep(y,n) if(xy[a][y]||yz[y][b]) cnt++;
				xz[a][b]=true;
			}
			else{
				rep(x,n) if(xy[x][a]||xz[x][b]) cnt++;
				yz[a][b]=true;
			}
		}
		printf("%d\n",cnt);
	}

	return 0;
}

Measured memory_bytes: 0
n = int(input())
s = input()
ls = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N",
      "O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in s:
    if ls.index(i)+n > len(ls)-1:
        print(ls[ls.index(i)+n-len(ls)],end="")
    else:
        print(ls[ls.index(i)+n],end="")

Measured memory_bytes: 4468
a = input()
b = input()
c = input()
cnta = 0
cntb = 0
cntc = 0
now = "a"
while True:
  if now == "a":
    try:
      now = a[cnta]
    except IndexError:
      print("A")
      exit()
    cnta += 1
  elif now == "b":
    try:
      now = b[cntb]
    except IndexError:
      print("B")
      exit()
    cntb += 1
  else:
    try:
      now = c[cntc]
    except IndexError:
      print("C")
      exit()
    cntc += 1

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

int main() {
  int N;
  cin >> N;
  int ans=0;
  for(int i=0; i<N; i++) {
    int d1, d2;
    cin >> d1 >> d2;
    if(d1==d2) ans+=1;
    else ans=0;
    if(ans==3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

int main () {
  int N;
  cin >> N;
  int now_h = 0, maxmove = 0, move = 0;
  for(int i = 0; i < N; i++) {
    long next_h;
    cin >> next_h;
    if(now_h >= next_h) {
      move++;
    }else{
      move = 0;
    }
    if(maxmove < move) {
      maxmove = move;
    }
    now_h = next_h;
  }
  cout << maxmove << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	long long int a,b,bai[1000]={},yaku[1000]={},kai[1000]={},e,f=0,g,bosu,j=0,m,n;
	while(scanf("%lld %lld",&a,&b)!=EOF){
		kai[j]=1;
		if(a==0&&b==0)break;
		if(a>b){
		m=a;
		n=b;}else{m=b;n=a;}
		while(m%n!=0){
			g=n;
			n=m%n;
			m=g;
			kai[j]++;
		}
		yaku[j]=n;
		bosu=a*b;
		bai[j]=bosu/yaku[j];
		j++;
	}
	for(e=0;e<j;e++){
		printf("%lld %lld\n",yaku[e],kai[e]);
	}
	return 0;
}

Measured memory_bytes: 612
import java.util.*;
import java.util.function.*;

/** 0-indexed */
class BinaryIndexedTree<T>{
	/**
	 * a+0=a
	 * a+(b+c)=(a+b)+c
	 */
	public static class Monoid<T,R> implements BiFunction<T,T,R>{
		T identity;

		BiFunction<T,T,R> f;
		public Monoid(T identity,BiFunction<T,T,R> f){
			this.identity=identity;
			this.f=f;
		}
		@Override
		public R apply(T t,T u){
			return f.apply(t,u);
		}
	}

	private final T[] array;

	private final Monoid<T,T> merger;

	@SuppressWarnings("unchecked")
	public BinaryIndexedTree(int size,Monoid<T,T> merger){
		this.merger=merger;
		this.array=(T[])new Object[size+1];
		Arrays.fill(array,merger.identity);
	}

	void merge(int p,T value){
		++p;
		for(final int n=array.length;p<n;p+=Integer.lowestOneBit(p))
			array[p]=merger.apply(array[p],value);
	}

	T query(int p){
		T s=merger.identity;
		for(++p;p>0;p^=Integer.lowestOneBit(p))
			s=merger.apply(s,array[p]);
		return s;
	}
}

public class Main{
	public static void main(String[] $){
		final Scanner s=new Scanner(System.in);
		final int n=s.nextInt();

		BinaryIndexedTree<Integer>bit=new BinaryIndexedTree<>(
				n,new BinaryIndexedTree.Monoid<>(0,Integer::sum));

		for(int q=s.nextInt();q>0;--q) {
			if(s.nextByte()==0) {
				bit.merge(s.nextInt()-1,s.nextInt());
			}else {
				int i=s.nextInt()-1;
				int j=s.nextInt()-1;
				System.out.println(bit.query(j)-bit.query(i-1));
			}
		}
	}
}



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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  ll n; cin >> n;
  ll ans=INF_LL;
  for(ll i = 1;i*i<=n;i++){
    ll j;
    if(n%i==0)
      j = n/i;
    ans = min(ans,i+j-2);
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3684
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
  int R[MAX], n;

  cin >> n;
  for(int i = 0; i < n; i++) cin >> R[i];

  int maxv = -1000000000;
  int minv = R[0];
  
  for(int i = 1; i < n; i++){
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
    }
  
  cout << maxv << endl;
  
  return 0;
  }

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  int M; cin >> M;
  ll sum = 0, dig = 0;
  rep(i,M) {
    ll d, c; cin >> d >> c;
    sum += d*c;
    dig += c;
  }
  ll result = (sum-1)/9 + (dig-1);
  cout << result << endl;
  return 0;
}

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

int main(){
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> sum(N + 1, 0);
  for(int i = 1; i < N; i++){
    if(S.at(i - 1) == 'A' && S.at(i) == 'C'){
      sum.at(i + 1) = sum.at(i) + 1;
    }
    else{
      sum.at(i + 1) = sum.at(i);
    }
  }
  vector<int> results(Q);
  for(int i = 0; i < Q; i++){
    int l, r;
    cin >> l >> r;
    results.at(i) = sum.at(r) - sum.at(l);
  }
  for(int i = 0; i < Q; i++){
    cout << results.at(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int p,q,r;
    cin >> p >> q >> r;
    if (p > q) swap(p,q);
    if (q > r) swap(q,r);
    cout << p + q << endl;
}

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

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

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

	vector<double> v(n);
	for(int i=0; i<n; i++) cin>>v[i];

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

	double ans = v[0];
	for(int i=1; i<n; i++) ans = (ans + v[i])/2.;
	cout<< ans <<endl;
}

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

int main() {
  int n, p;
  scanf("%d %d", &n, &p);
  string s;
  cin >> s;

  long long ans = 0;
  if (p == 2 || p == 5) {
    for (int i = 0; i < n; i++)
      if ((s[i] - '0') % p == 0)
        ans += i + 1;
  }
  else {
    vector<int> r(n);
    unordered_map<int, int> m;
    m[0] = 1;
    int t = 1;
    for (int i = 0; i < n; i++) {
      if (i)
        r[i] = ((s[n - i - 1] - '0') * t + r[i - 1]) % p;
      else
        r[i] = (s[n - i - 1] - '0') % p;
      
      ans += m[r[i]];
      m[r[i]]++;
      
      t = t * 10 % p;
    }
  }
  printf("%lld\n", ans);

  return 0;
}


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

int main (){
int x,flg; 
cin >> x;
if (x == 2){
    cout << 2 << endl;
return 0;
}
while(1){
    flg = 1;
    if(x % 2 == 0){
        x++;
        continue;
    }
       
    for (int i = 3; i < x; i+= 2)
    {
        if(x % i == 0){
            flg = 0;
            break;
        }
    }
    if(flg)
        break;
    x++;
}
cout << x << endl;
return 0;
}

Measured memory_bytes: 256
from collections import deque
N = int(input())
A = list(map(int,input().split()))
Query = deque()
A.sort(reverse=True)
Query.append([A[0],A[1]])
Query.append([A[0],A[1]])
Answer = A[0]
for i in range(2,N):
    query = Query.popleft()
    Answer += min(query)
    Query.append([max(query),A[i]])
    Query.append([min(query),A[i]])
print(Answer)

Measured memory_bytes: 35684
from collections import defaultdict

N, M = [int(el) for el in input().split()]

hts = [int(el) for el in input().split()]
heights = {}
mh = {}
for i, val in enumerate(hts, start=1):
    heights[i] = val
    mh[i] = 0

for _ in range(M):
    s, d = [int(el) for el in input().split()]
    mh[s] = max(mh[s], heights[d])
    mh[d] = max(mh[d], heights[s])

ans = 0
for i in range(1, N + 1):
    if heights[i] > mh[i]:
        ans += 1

print(ans)

Measured memory_bytes: 30428
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int n,k,s;
ll ans;

void rec(int div,int used,int sum){
	if(sum==s&&div==k){
		ans++;
		return;
	}
	if(sum>s||div==k)return;
	range(i,used+1,n-k+div+1+1){
		rec(div+1,i,sum+i);
	}
}

void solve(){
	ans=0;
	rec(0,0,0);
	cout<<ans<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(cin>>n>>k>>s,n)solve();
}


Measured memory_bytes: 3120
#include <iostream>     // std::cout
#include <algorithm>    // std::make_heap, std::pop_heap, std::push_heap, std::sort_heap
#include <vector>       // std::vector
//#include <stdio.h>

using namespace std;

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int N, x;
  cin >> N;
  
  vector<int> jumpHeights;
  vector<int> jumpCost(N, 0);
  
  for(int i = 0; i < N; i++) {
	  cin >> x;
	  jumpHeights.push_back(x);
  }

  
  for(int i = 1; i<N;i++) {
	if (i -2 < 0) {
		jumpCost[i] = abs(jumpHeights[i] - jumpHeights[i -1]);
	} else {
		int pre1jump = abs(jumpHeights[i] - jumpHeights[i -1]) + jumpCost[i-1];
		int pre2jump = abs(jumpHeights[i] - jumpHeights[i -2]) + jumpCost[i-2];
		jumpCost[i] = min(pre1jump,pre2jump);
	}
  }
  cout << jumpCost[N - 1] << "\n";
  

  return 0;
}

Measured memory_bytes: 1276
from fractions import gcd
a,b,k=map(int,input().split())

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

    # divisors.sort()
    return divisors

C=make_divisors(gcd(a,b))
C.sort()
#print(C)
print(C[-k])


Measured memory_bytes: 64364
#include <bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin >> s;
	if (s == "SUN")
	{
		cout << 7 << endl;
	} else if (s == "MON") {
		cout << 6 << endl;
	} else if (s == "TUE") {
		cout << 5 << endl;
	} else if (s == "WED") {
		cout << 4 << endl;
	} else if (s == "THU") {
		cout << 3 << endl;
	} else if (s == "FRI") {
		cout << 2 << endl;
	} else if (s == "SAT") {
		cout << 1 << endl;
	} 
	return 0;
}

Measured memory_bytes: 256
n = int(raw_input())
strings = [raw_input() for _ in xrange(n)]
hashes = {}
for s in strings:
  h = ''.join(sorted(s))
  hashes[h] = hashes.get(h, 0) + 1
total = 0
for c in hashes.itervalues():
  total += c * (c-1)
print total/2 # not sure why I need to /2

Measured memory_bytes: 21604
#include <stdlib.h>
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

struct Node {
	int key;
	Node* p;
	Node* l;
	Node* r;
};

Node* root;
Node* NIL;

void insert(int z) {

	Node* y = NIL;
	Node* x = root;

	Node* zn = (Node *) malloc(sizeof(Node));
	zn->key = z;
	zn->l = NIL;
	zn->r = NIL;

	while (x != NIL) {
		y = x;
		if (zn->key < x->key)
			x = x->l;
		else
			x = x->r;
	}

	if (y == NIL)
		root = zn;
	else if (zn->key < y->key)
		y->l = zn;
	else
		y->r = zn;

}

Node* find(int k) {

	Node* n = root;

	if (n->key == k)
		return n;

	while (n != NIL) {
		if (n->key == k) {
			return n;
		} else if (k < n->key) {
			n = n->l;
		} else if (n->key < k) {
			n = n->r;
		}
	}
	return NIL;
}

void deleteNode(int k) {

}

void printInOrder(Node* n) {
	if (n == NIL)
		return;

	printInOrder(n->l);
	cout << " " << n->key;
	printInOrder(n->r);
}

void printPreOrder(Node* n) {
	if (n == NIL)
		return;
	cout << " " << n->key;
	printPreOrder(n->l);
	printPreOrder(n->r);
}

int main() {

	int n;
	scanf("%d", &n);

	string s;
	int k;
	for (int i = 0; i < n; ++i) {
		cin >> s;
		if (s == "insert") {
			scanf("%d", &k);
			insert(k);
		} else if (s == "find") {
			scanf("%d", &k);
			if (find(k) != NIL)
				cout << "yes" << endl;
			else
				cout << "no" << endl;
		} else if (s == "delete") {
			scanf("%d", &k);
			deleteNode(k);
		} else {
			printInOrder(root);
			cout << endl;
			printPreOrder(root);
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 21904
#include <stdio.h>
#include <stdlib.h>

typedef struct list *Node;
typedef Node List;
struct list{
    int num;
    Node next;
};

List insertinFront(List L,int x);
Node newNode(int x);
void freeList(List L);

int main(){
    int N,i = 1;
    scanf("%d",&N);
    int sum = 0;
    while(sum < N){
        sum+=i;
        if(sum<N) i++;
    }
    
    List L = NULL; //empty list
    sum = N;
    while(sum != 0){
        if(sum < 0) printf("You broke something\n");
        if(sum - i >= 0){
            L = insertinFront(L,i);
            sum -= i;
        }
        i--;
    }
    
    Node curr = L;
    while(curr != NULL){
        printf("%d\n",curr->num);
        curr = curr->next;
    }
    return 0;
}

List insertinFront(List L, int x){
    Node new = newNode(x);
    new->next= L;
    return new;
}

Node newNode(int x){
    Node new = malloc(sizeof(struct list));
    new->num = x;
    new->next= NULL;
    return new;
}

void freeList(List L){
    if(L->next != NULL) freeList(L->next);
}
//will need to use queues instead of printing
//min max for 100 should be 16 instead of 22

Measured memory_bytes: 384
(n,m) = [int(i) for i in input().split()]

A = []
for nc in range(n):
    A.append([int(i) for i in input().split()])

b = []
for mc in range(m):
    b.append(int(input()))

product = []
for nc in range(n):
    total = 0
    for mc in range(m):
        total += A[nc][mc] * b[mc]

    product.append(total)

[print(p) for p in product]

Measured memory_bytes: 7020