akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

const int MAX_N = 105, MAX_W = 10000;
int v[MAX_N], w[MAX_N], dp[MAX_N][MAX_W + 5];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int N, W;
   cin >> N >> W;
   rep(i, 0, N) cin >> v[i] >> w[i];
   rep(i, 0, N) rep(j, 0, W + 1) {
      if (j >= w[i])
         dp[i + 1][j] = max(dp[i + 1][j - w[i]] + v[i], dp[i][j]);
      else
         dp[i + 1][j] = dp[i][j];
   }
   cout << dp[N][W] << endl;
   return 0;
}


Measured memory_bytes: 7140
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
using namespace std;
int array1[105]={0};
bool dp[105][105][10],decide[105][105][10];
bool sec_dp(int l,int r,int c){
  //[l,r)
  if(decide[l][r][c]) return dp[l][r][c];
  decide[l][r][c]=true;
  if(r-l==2){
    if(c==0){
      return dp[l][r][c]=(array1[l]==array1[l+1]);
    }
    else return dp[l][r][c]=(array1[l]==c&&array1[l+1]==c);
  }
  if(r-l==1){
    return dp[l][r][c]=(c==array1[l]);
  }
  for(int i=l+1;i<r;i++){
    if(c==0){
      for(int j=0;j<10;j++){
        bool b1=sec_dp(l,i,0);
        bool b2=sec_dp(l,i,j);
        bool b3=sec_dp(i,r,0);
        bool b4=sec_dp(i,r,j);
      //  if(l==0&&r==4&&i==1&&j==1) cout<<(b1?"Y":"N")<<(b2?"Y":"N")<<(b3?"Y":"N")<<(b4?"Y":"N")<<endl;
      //  if(l==1&&r==4&&i==3&&j==1) cout<<(b1?"Y!":"N!")<<(b2?"Y":"N")<<(b3?"Y":"N")<<(b4?"Y":"N")<<endl;
        if((b1&&b3)||(b2&&b4)) {
      //    cout<<"ina"<<l<<" "<<r<<" "<<i<<" "<<c<<" "<<j<<endl;
          return dp[l][r][c]=true;
        }
      }
    }
    else{
      bool b1=sec_dp(l,i,0);
      bool b2=sec_dp(l,i,c);
      bool b3=sec_dp(i,r,0);
      bool b4=sec_dp(i,r,c);
      if((b2&&b4)||(b1&&b4)||(b2&&b3)){
  //      cout<<"yoc"<<l<<" "<<r<<" "<<i<<" "<<c<<endl;
        return dp[l][r][c]=true;
      }
    }
  }
  return dp[l][r][c]=false;
}
int main(){
  //while(1){
    int n;
    cin>>n;
    if(n==0) return 0;
    for(int i=0;i<105;i++){
      array1[i]=0;
      for(int j=0;j<105;j++){
        for(int k=0;k<10;k++){
          dp[i][j][k]=false;
          decide[i][j][k]=false;
        }
      }
    }
    for(int i=0;i<n;i++) cin>>array1[i];
    cout<<(sec_dp(0,n,0)?"yes":"no")<<endl;
//  }
}



Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
int main()
{
	boost
	ll n,k;
	cin>>n>>k;
	string str;
	cin>>str;
	ll ans1=0,ans0=0,count1=0,count0=0;
	ll zero=0;
	ll one=0;
	for(ll i=0; i<str.size(); i++)
	{
		if(str[i]=='L')
		{
			zero++;
			if(one>0)
			{
				ans1+=one;
				count1++;
			}
			one=0;
		}
		else
		{
			one++;
			if(zero>0)
			{
				ans0+=zero;
				count0++;
			}
			zero=0;
		}
	}
	if(one>0)
	{
		ans1+=one;
		count1++;
	}
	if(zero>0)
	{
		ans0+=zero;
		count0++;
	}
	cout<<min(ans1+ans0-count1-count0+min(count1,k)+min(count0,k),n-1)<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[200010];
    rep(i, N) cin >> A[i];
    sort(A, A + N);
    rep(i, N - 1) {
        if(A[i] == A[i + 1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
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;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool f = 1;
    while(a > 0 && c > 0) {
        if(f) {
            c -= b;
        } else {
            a -= d;
        }
        f = !f;
    }
    if(a <= 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3652
#include<stdio.h>

int main(){
   int N;
   int A[1001];

   scanf("%d",&N);

   for(int i = 0;i<N;i++){
      scanf("%d",&A[i]);
      if(A[i]%2==0&&(A[i]%5!=0&&A[i]%3!=0)){
         printf("DENIED");
         return 0;
      }
   }
   printf("APPROVED");

   return 0;
}


Measured memory_bytes: 1716
<?php
 
function input($func = null) {
    if ($func === null) {
        return trim(fgets(STDIN));
    } else {
        return $func(trim(fgets(STDIN)));
    }
}
function input_array($func = null) {
    if ($func === null) {
        return explode(' ', input());
    } else {
        return array_map(function($v) use ($func) {
            return $func($v);
        }, explode(' ', input()));
    }
}

$n = input('intval');
$ls = input_array('intval');
rsort($ls);

if ($ls[0] * 2 < array_sum($ls)) {
    echo "Yes\n";
} else {
    echo "No\n";
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >>N >>K;
  long long ans=0, temp=1;
  for(int i=0; i<3; i++){
    temp*=N/K;
  }
  ans=temp;
  if(K%2==0){
    temp=1;
    for(int i=0; i<3; i++){
      temp*=(N/(K/2)-N/K);
    }
    ans+=temp;
  }
  cout <<ans <<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

N, C, K = ln()

T = []
for i in xrange(N):
    T.append(n())

T.sort()

bus = 0
last = T[0]
count = 1
for t in T[1:]:
    if t - last > K or count == C:
        bus += 1
        last = t
        count = 1
    else:
        count += 1
bus += 1

print bus


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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;

#define onEdge(i, j) (i == 0 || i == n-1 || j == 0 || j == n-1)
#define inBound(i, j) !(i < 0 || i > n-1 || j < 0 || j > n-1)

vector<pair<int,int>> order;
vector<vector<int>> dist;
vector<vector<bool>> seats;
vector<vector<bool>> inq;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {-1, 0, 1, 0};
int n;

void updDist(int x1, int y1){
	vector<pair<int,int>> q;
	q.push_back({x1, y1});
	inq[x1][y1] = 1;
	for (int i = 0; i < q.size(); i++){
		auto u = q[i];
		int x = u.first; int y = u.second;
		inq[x][y] = 0;
		int newDist = dist[x][y] + seats[x][y];
		for (int d = 0; d < 4; d++){
			int x2, y2;
			x2 = x + dx[d];
			y2 = y + dy[d];
			if (inBound(x2,y2)){
				if (newDist < dist[x2][y2]){
					dist[x2][y2] = newDist;
					if (!inq[x2][y2]){
						inq[x2][y2] = 1;
						q.push_back({x2, y2});
					}
				}
			}
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin>>n;
	order.resize(n*n);
	seats.assign(n, vector<bool>(n, 1));
	dist.assign(n, vector<int>(n, INF));
	inq.assign(n, vector<bool>(n, 0));
	for (auto &it: order){
		int a;
		cin>>a;
		a--;
		int x = a/n;
		int y = a%n;
		it.first = x; it.second = y;
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			// if (onEdge(i, j)){
			// 	dist[i][j] = 0;
			// 	updDist(i, j);
			// }
			dist[i][j] = min(min(i, j), min(n - 1 - i, n - 1 - j));
			// cout<<dist[i][j];
		}
		// cout<<'\n';
	}
	int ans = 0;
	for (auto u: order){
		ans += dist[u.first][u.second];
		seats[u.first][u.second] = 0;
		updDist(u.first, u.second);
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 10212
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int h,w,n,x,cnt1=1,cnt2,f=1;
int s[105][105];
int main()
{
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		for(int j=1;j<=x;j++){
			cnt2+=f;if(cnt2==w+1||cnt2==0) cnt1++,cnt2=(cnt2==w+1)?w:1,f=-f;
			s[cnt1][cnt2]=i;
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<w;j++) cout<<s[i][j]<<" ";cout<<s[i][w]<<endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N; cin >> N;
    int ans = 0;
    for(int i = 0; i < N; i++){
        int odd_hantei = i + 1;
        int tmp; cin >> tmp;
        if(odd_hantei % 2 == 1){
            if(tmp % 2 == 1){
                ans ++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve()
{
	/*--------------------------*/

	int N; cin >> N;
	vector<double> v(N); rep(i, N) cin >> v[i];
	while (sz(v) > 1) {
		sort(rall(v));
		double f = v.back();
		v.pop_back();
		double s = v.back();
		v.pop_back();
		v.push_back((f + s) / 2);
	}
	cout << v.front() << endl;

	/*--------------------------*/
}

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

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;
const ll mod=1000000007;
ll a[50];
ll newa[50];
ll yz[50];
ll my_pow(ll ds,ll cf)
{
    ll sum=1;
    while(cf>0)
    {
        if(cf%2==1)
            sum=(sum*ds)%mod;
        ds=(ds*ds)%mod;
        cf/=2;
    }
    return sum;
}
ll ny(ll ds)
{
    return my_pow(ds,mod-2);
}
int main()
{
    ll n,m;
    scanf("%lld %lld",&n,&m);
    if(m==1)
    {
        printf("1\n");
        return 0;
    }
    int len=0;
    for(int i=2;i*i<=m;i++)
    {
        while(m%i==0)
        {
            yz[len++]=i;
            m/=i;
        }
    }
    if(m!=1)
        yz[len++]=m;
    a[0]=1;
  //  printf("%lld\n",(((100000*99999)%mod)*ny(2))%mod);
    for(int l=0;l<=len;l++)
    {
       //    printf("%d\n",yz[l]);
        //   for(int k=0;k<=len;k++)
        // printf("%d-%d ",k,a[k]);
      //   printf("\n");
        if((l!=0 && yz[l]!=yz[l-1]) || l==len)
        {
            for(int i=1;i<=len;i++)
            {
                a[0]=(a[0]+a[i])%mod;
                a[i]=0;
            }
            if(l==len)
                break;
        }
        for(ll i=1;i<=len;i++)
        {
            newa[i]=(a[i]*i)%mod;
            newa[i]=(newa[i]+(a[i-1]*(n-i+1))%mod)%mod;
            newa[i]=(newa[i]*ny(i))%mod;
        }
        for(int i=0;i<=len;i++)
        {
            a[i]=newa[i];
            newa[i]=0;
        }
    }
    printf("%lld\n",a[0]%mod);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	int diff = a - b;
	if (diff >= c) cout << 0 << '\n';
	else cout << c - diff << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define fi              first
#define se              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
const int N=2e5+5;
		
		
int main()
{
	 FIO;
	 
	int n;
	cin>>n;
	n=n%10;
	if(n==3)
	{
		cout<<"bon";
	}
	else if((n==0)||(n==1)||(n==6)||(n==8))
	{
		cout<<"pon";
	}
	else
	{
		cout<<"hon";
	}
				
			
			 
}


Measured memory_bytes: 3596
h,w=gets.split.map(&:to_i)
s=[]
h.times do |i|
  s[i] = gets.chomp
end
h.times do |i|
  w.times do |j|
    if s[i][j]=="#"
      unless (i>0&&s[i-1][j]=="#")||(j>0&&s[i][j-1]=="#")||(i<h-1&&s[i+1][j]=="#")||(j<w-1&&s[i][j+1]=="#")
        puts "No"
        exit
      end
    end
  end
end
puts "Yes"
exit

Measured memory_bytes: 1788
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int n;
    int A[100000];
    int res=0;
    int cnt=0;

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

    sort(A,A+n);

    for(int i=0;i<n;i++){
        if(A[i]==A[i+1]){
            cnt +=1;
            continue;
        }
        else{
            if(cnt%2==0){
                res +=1;
            }
            cnt=0;
        }
    }
    printf("%d",res);

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
void solve(ll crnt,int use,int &ans,int n){
   if(crnt>n)return;
   if(use == 0b111)ans++;
   solve(crnt*10+7,use | 0b100,ans,n);
   solve(crnt*10+5,use | 0b010,ans,n);
   solve(crnt*10+3,use | 0b001,ans,n);

}
int main(void){
   int n;
   cin>>n;
   int ans=0;
   solve(0,0,ans,n);
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_cols<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let total = read::<u32>();
    let n_1yen = read::<u32>();

    let remain = total % 500;

    if remain > n_1yen {
        println!("No");
    } else {
        println!("Yes");
    }
}

Measured memory_bytes: 4352
#include<iostream>
#define repr(i,n) for(int i=1;i<=n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long 
using namespace std;

int main()
{
	int n,x,res=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(i%2==1&&x%2==1)res++;
	}
	cout<<res<<"\n";
	return 0;
 } 

Measured memory_bytes: 3164
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <mutex>
using namespace std;

const double INF = 1e9;

int n, m, s, g;

// [n][prev][v];
double dp[32][32][32];

struct edge {
	int to, c;
	double length;

	edge(int to, int c, double l) :to(to), c(c), length(l){
	}
	
};

vector<edge> G[32];

struct state {
	int n, prev, v;
	double time;

	state(int n, int prev, int v, double time) :n(n), prev(prev),v(v), time(time){
	}
	bool operator > (const state& s) const {
		return time > s.time;
	}
};

void solve(){
	priority_queue<state, vector<state>, greater<state>> q;
	q.push(state(s, -1, 1, 0.0));
	while(!q.empty()) {
		state s = q.top();
		q.pop();
		if(s.prev != -1 && dp[s.n][s.prev][s.v] <= s.time) continue;

		if(s.n == g && s.v == 1) {
			cout << s.time << endl;
			return;
		}

		if(s.prev != -1)
			dp[s.n][s.prev][s.v] = s.time;

		int dv[] = { 0, 1, -1 };
		for(int i = 0; i < G[s.n].size(); i++) {
			for(int j = 0; j < ((s.prev == -1) ? 1 : 3); j++) {
				int nv = s.v + dv[j];
				if(nv > 0 && nv <= G[s.n][i].c && G[s.n][i].to != s.prev 
					&& s.time + G[s.n][i].length / nv < dp[G[s.n][i].to][s.n][nv])
					q.push(state(G[s.n][i].to, s.n, nv, s.time + G[s.n][i].length / nv));
			}
		}
	}

	cout << "unreachable" << endl;
}

int main(){
	while(cin >> n >> m , n | m) {
		cin >> s >> g;

		for(int i = 0; i < 32; i++) {
			G[i].clear();
		}
		for(int i = 0; i < m; i++) {
			int x, y, c;
			double d;
			cin >> x >> y >> d >> c;
			G[x].push_back(edge(y, c, d));
			G[y].push_back(edge(x, c, d));
		}

		for(int i = 0; i < 31; i++) {
			for(int j = 0; j < 31; j++) {
				for(int k = 0; k < 31; k++) {
					dp[i][j][k] = INF;
				}
			}
		}

		solve();
	}

}

Measured memory_bytes: 14084
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

struct box
{
    string s;
    int val,i;
};
bool cmp(box &l,box &r)
{
    if(l.s<r.s)
        return 1;
    if(l.s>r.s)
        return 0;
    if(l.val>r.val)
        return 1;
    return 0;

}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    vector<box>v;
    for(int i=1; i<=n; i++)
    {
        string s;
        int a;
        cin>>s>>a;
        box t;
        t.s=s;
        t.val=a;
        t.i=i;
        v.push_back(t);
    }
    sort(all(v),cmp);
    for(auto it:v)
    {
        cout<<it.i<<endl;
    }

    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,s;
    cin >> n >> s;
    vl x(n),p(n);
    vector<pll> l,r;
    rep(i,n){
        cin >> x[i] >> p[i];
        if(x[i] < s){
            l.pb(pll(x[i],p[i]));
        }else{
            r.pb(pll(x[i],p[i]));
        }
    }
    sort(all(l),greater<pll>());
    sort(all(r));
    int ch = -1;
    ll ans = 0;
    while(len(l) && len(r)){
        if(l.back().se >= r.back().se){
            if(ch < 0 || ch == 1){
                ans += r.back().fi-l.back().fi;
                ch = 0;
            }
            l.back().se += r.back().se;
            r.pop_back();
        }else{
            if(ch < 0 || ch == 0){
                ans += r.back().fi-l.back().fi;
                ch = 1;
            }
            r.back().se += l.back().se;
            l.pop_back();
        }
    }
    if(len(l)){
        cout << ans + s - l.back().fi << "\n";
    }else{
        cout << ans + r.back().fi - s << "\n";
    }
    return 0;
}


Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
namespace {
  template <typename T> inline void read(T &x) {
    x = 0; T f = 1;char s = getchar();
    for(; !isdigit(s); s = getchar()) if(s == '-') f = -1;
    for(;  isdigit(s); s = getchar()) x = (x << 3) + (x << 1) + (s ^ 48);
    x *= f;
  }
}
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _for(n,m,i) for (register int i = (n); i < (m); ++i)
#define _rep(n,m,i) for (register int i = (n); i <= (m); ++i)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define lowbit(x) x & (-x)
#define pii pair<int,int>
#define fi first
#define se second
const int N = 30000 + 5;
char s[N];
vector<int> v[10];
int main() {
  int n;
  read(n);scanf("%s", s);
  for(int i = 0; s[i]; i++) {
    v[s[i] - '0'].push_back(i);
  }
  int cnt = 0;
  _rep(0, 9, i) {
    if(!v[i].size()) continue;
    int st = v[i][0];
    _rep(0, 9, j) {
      auto el = upper_bound(v[j].begin(), v[j].end(), st);
      if(el == v[j].end()) continue;
      int El = *el;
      _rep(0, 9, k) {
        auto ed = upper_bound(v[k].begin(), v[k].end(), El);
        if(ed != v[k].end()) cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 512
//056
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int w,a,b;
    cin >> w >> a >>b;
    cout << max(0, max(b-(a+w), a-(b+w))) << endl;
}

Measured memory_bytes: 256
n=int(input())
x=[float(i) for i in input().split()]
y=[float(i) for i in input().split()]
dis=[abs(i-j) for i,j in zip(x,y)]
print(sum(dis))
print((sum([i**2 for i in dis]))**0.5)
print((sum([i**3 for i in dis]))**(1/3))
print(max(dis))



Measured memory_bytes: 5668
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=5e2,inf=1e9;
int V[N+10][N+10];
int main(){
	int n=read(),m=read(),h=read(),w=read();
	int v=3999,mv=-(h*w-1)*v-1,sum=0;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			sum+=V[i][j]=(i%h==0&&j%w==0)?mv:v;
	if (sum<0)	printf("No\n");
	else{
		printf("Yes\n");
		for (int i=1;i<=n;i++){
			for (int j=1;j<=m;j++)	printf("%d ",V[i][j]);
			putchar('\n');
		}
	}
	return 0;
}

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

using namespace std;
const int mx = 1e5+5, MOD = 1e9+7;

vector <int> vec[mx];
pair <long long, long long> dp[mx];

void dfs(int u, int p){

    for(auto v : vec[u]){
        if(v!=p) dfs(v, u);
    }
    dp[u].first = 1;
    dp[u].second = 1;
    for(auto v : vec[u]){
        if(v!=p){
            dp[u].first*=(dp[v].first+dp[v].second);
            dp[u].first%=MOD;
            dp[u].second*=dp[v].first;
            dp[u].second%=MOD;
        }
    }
}

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

    for(int i=1; i<n; i++){
        int a, b;
        scanf("%d %d",&a,&b);
        vec[a].push_back(b);
        vec[b].push_back(a);
    }

    dfs(1, 0);
    printf("%lld\n",(dp[1].first+dp[1].second)%MOD);
    return 0;
}


Measured memory_bytes: 14208
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		log.Fatal(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	sc.Split(bufio.ScanWords)

	n := getInt()
	m := getInt()
	for i := 0; i < m; i++ {
		n -= getInt()
	}
	if n >= 0 {
		out(n)
	} else {
		out(-1)
	}

}


Measured memory_bytes: 1856
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int sum = 0;
		for(int i = 1; i <= n; i++) {
			String str = String.valueOf(i);
			String strArr[] = str.split("");
			int sum1 = 0;
			for(int j = 0; j < strArr.length; j++) {
				int intStrArr = Integer.parseInt(strArr[j]);
				sum1 += intStrArr;
			}
			if(a <= sum1 & sum1 <= b) {
				sum += i;
			}
		}
		
		System.out.println(sum);
	}
	
}

Measured memory_bytes: 36692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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; }

const long long INF = 1LL << 60;

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

  cout << (30 <= x ? "Yes" : "No") << endl;

  return 0;
}


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

using namespace std;

const int maxn = 2e5+10, m = 1e9+7;

typedef long long ll;

ll factorial[maxn];

ll exp(ll b, ll p){

    ll resp = 1;

    b = b % m;

    while(p > 0){
        if(p & 1){
            resp = (resp * b)%m;
        }
        p = p >> 1;
        b = (b * b)%m;
    }

    return resp;
}

ll inverse(ll x){
    return exp(x, m-2);
}

ll ncr(ll n, ll k) {
    return factorial[n] * inverse(factorial[k]) % m * inverse(factorial[n - k]) % m;
}

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

    factorial[0] = 1;
    for (int i = 1; i < maxn; i++) {
        factorial[i] = (factorial[i - 1] * i) % m;
    }

    ll n, k;

    cin >> n >> k;

    k = min(n, k);

    ll ans = 0;

    for(int i=k; i>=0; i--){
        ans = (ans + ((ncr(n, i)%m)*(ncr(n-1, n-i-1)%m))%m)%m;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int dist[N];
int in_deg[N];
bool vis[N];
vector<int> g[N];

void dfs(int x) {
    vis[x] = 1;
    for (int y: g[x]) {
        dist[y] = max(dist[y], dist[x] + 1);
        in_deg[y]--;
        if (!vis[y] and in_deg[y] == 0) {
            dfs(y);
        }
    }
}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        g[x].pb(y);
        in_deg[y]++;
    }

    for (int i = 1; i <= n; i++) {
        if (!vis[i] and in_deg[i] == 0) {
            dfs(i);
        }
    }

    cout << *max_element(dist + 1, dist + n + 1) << "\n";
    return 0;
}


Measured memory_bytes: 10496
#https://atcoder.jp/contests/abc072/tasks/arc082_a

n = int(input())
l = list(map(int, input().split()))
allx = [0 for _ in range(-1, 10**5+1)]

for value in l:
    allx[value+2] += 1
    allx[value+1] += 1
    allx[value] += 1

print(max(allx))


Measured memory_bytes: 13964
import sys, math
from functools import lru_cache
from itertools import accumulate
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

A, B = mi()

if A == B:
    print('Draw')
elif A == 1:
    print('Alice')
elif B == 1:
    print('Bob')
else:
    if A > B:
        print('Alice')
    else:
        print('Bob')

Measured memory_bytes: 9488
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main() {
  int n;
  while(cin >> n, n) {
    char t[n]; 
    int p[n][3];
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < 3; j++) {
        p[i][j] = 0;
      }
    }

    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        if(j == 0) cin >> t[i];
        else {
          int x; cin >> x;
          p[i][x]++;
        }
      }
    }
    
    for(int i = 0; i < n; i++) {
      int wm = -1, lm = 1000, pos;
      for(int j = 0; j < n; j++) {
        if(p[j][0] >= wm) {
          if(p[j][0] == wm && p[j][1] >= lm) continue;
          wm = p[j][0], lm = p[j][1], pos = j;
        }
      }
      printf("%c\n",t[pos]);
      p[pos][0] = -1, p[pos][1] = 1000;
    } 
  }
}

Measured memory_bytes: 1136
//g++  5.4.0

#include <bits/stdc++.h>
using namespace std;

const long long inf=1e18;

int main()
{       ios_base::sync_with_stdio(0);
        cin.tie(0);
        // freopen("input.txt","r",stdin) ;
        // freopen("output.txt","w",stdout );
        long n,W;
        cin>>n>>W;
        long v[n],w[n];

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

        long long dp[2][100007]; int mx=0; dp[0][0]=0; dp[1][0]=0;

        for(int i=1;i<100007;i++)
        {   dp[0][i]=inf; dp[1][i]=inf;   }

        for(int j=0;j<n;j++)
        {
            for(int i=1;i<100007;i++)
            {
                if(j%2==0){
                    if(i>=v[j] ) { if(dp[1][i-v[j] ] !=inf ) dp[0][i]=min( min(dp[1][i],dp[0][i]),dp[1][i-v[j]]+w[j] ); }

                                            {dp[0][i]=min(dp[0][i],dp[1][i]) ; }
                                            if(dp[0][i]!=inf && dp[0][i]<=W ) mx=max(i,mx);
                }
                else{
                    if(i>=v[j] ) { if(dp[0][i-v[j] ] !=inf ) dp[1][i]=min(min(dp[0][i],dp[1][i]),dp[0][i-v[j]]+w[j] ); }

                                            { dp[1][i]=min(dp[1][i],dp[0][i]) ; }
                                            if(dp[1][i]!=inf && dp[1][i]<=W ) mx=max(i,mx);
                }

            }
        }

        cout<<mx<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define MAXN 100005
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n,d;
    cin>>n>>d;
    ll res=0;
    for (int i = 0; i < n; ++i)
    {
        
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d)++res;
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 3648
// AOJ 0559: JOI Flag
// 2018.1.26 bal4u

#include <stdio.h>
#include <string.h>

#define M 100000
char map[23][23];
int dp[2][1048576][2];

int main()
{
	int m, n, r, c, k, k1, k2, kk, t1, t2, lim, ans;
	char buf[10], cc;

	fgets(buf, 10, stdin);
	sscanf(buf, "%d%d", &m, &n);
	for (r = 0; r < m; r++) fgets(map[r], 23, stdin);
	ans = 0, lim = 1 << n;

	dp[0][0][0] = 1, k1 = 1, k2 = 0;
	for (r = m-1; r >= 0; r--) for (c = 0; c < n; c++) {
		k1 = k2, k2 = !k2;
		memset(dp[k2], 0, sizeof(dp[k2]));
		cc = map[r][c];
		if (cc == '?') ans = 3*ans % M;
		for (k = 0; k < lim; k++) {
			kk = k & ~(1<<c);
			t1 = dp[k1][k][0], t2 = dp[k1][k][1];
			if (cc == '?' || cc == 'I')
				dp[k2][kk|(1<<c)][0] = (dp[k2][kk|(1<<c)][0] + t1 + t2) % M;
			if (cc == '?' || cc == 'O') {
				ans += t2; if (ans >= M) ans -= M;
				dp[k2][kk][0] = (dp[k2][kk][0] + t1) % M;
			}
			if (cc == '?' || cc == 'J')
				dp[k2][kk][c<n-1&&((k>>c)&1)] = (dp[k2][kk][c<n-1&&((k>>c)&1)]+t1+t2) % M;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 18184
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
const int INF = 1e9;
const int MAXN = 1e5+10;

int n, m;
vector<int> G[MAXN];
ll A[MAXN];
bool chk[MAXN];
vector<int> gr[MAXN];
int gcnt=0;

void dfs(int cur) {
	gr[gcnt].push_back(A[cur]);
	chk[cur] = true;
	for (auto nxt: G[cur]) {
		if(chk[nxt]) continue;
		dfs(nxt);
	}
}

int main() {
	scanf("%d %d", &n, &m);
	
	for (int i = 0; i < n; i++)
		scanf("%d", &A[i]);

	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}

	for (int i = 0; i < n; i++) {
		if(chk[i]) continue;
		
		dfs(i);
		sort(gr[gcnt].begin(), gr[gcnt].end());
		gcnt++;
	}

	if (gcnt == 1) {
		puts("0");
		return 0;
	}

	// 필요한 간선의 개수 = gr.size()-1
	if ((gcnt - 1)*2 > n) {
		puts("Impossible");
		return 0;
	}

	
	vector<int> cand;
	ll ans = 0;
	for (int i = 0; i < gcnt; i++) {
		ans += gr[i][0];
		for (int j = 1; j < gr[i].size(); j++)
			cand.push_back(gr[i][j]);
	}

	sort(cand.begin(), cand.end());
	int rem = gcnt - 2;
	while(rem--)
		ans += cand[rem];
	
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 10232
import math

A,B,H,M = map(int,input().split())


Ar = 360 * (H/12) + M/60*30
Br = 360 * M/60

#print(Ar)
#print(Br)

#短針
if Ar < 90:
  Ax = A * math.sin(math.radians(Ar))
  Ay = A * math.cos(math.radians(Ar))
elif Ar >= 90 and Ar < 180:
  Ar = Ar - 90
  Ax = A * math.cos(math.radians(Ar))
  Ay = -1 * A * math.sin(math.radians(Ar))
elif Ar < 270:
  Ar = Ar - 180
  Ax = -1 * A * math.sin(math.radians(Ar))
  Ay = -1 * A * math.cos(math.radians(Ar))  
else:
  Ar = Ar - 270
  Ax = -1 * A * math.cos(math.radians(Ar))
  Ay = A * math.sin(math.radians(Ar))

#長針
if Br < 90:
  Bx = B * math.sin(math.radians(Br))
  By = B * math.cos(math.radians(Br))
elif Br >= 90 and Br < 180:
  Br = Br - 90
  Bx = B * math.cos(math.radians(Br))
  By = -1 * B * math.sin(math.radians(Br))
elif Br < 270:
  Br = Br - 180
  Bx = -1 * B * math.sin(math.radians(Br))
  By = -1 * B * math.cos(math.radians(Br))  
else:
  Br = Br - 270
  Bx = -1 * B * math.cos(math.radians(Br))
  By = B * math.sin(math.radians(Br))  

X = abs(Bx-Ax)
Y = abs(By-Ay)  

#Ans = math.sqrt(X**2 + Y**2)
Ans = ((X**2) + (Y**2))**0.5
print(Ans)

Measured memory_bytes: 62860
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int ans=0;
    rep(i, n){
        if(h[i] >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3772
import java.util.Scanner;
public class Main{
	void main() {
		try(Scanner sc=new Scanner(System.in)){
			for(;;) {
				int x=sc.nextInt();
				int y=sc.nextInt();
				if(x==0&&y==0)break;
				System.out.println(Math.min(x, y)+" "+Math.max(x,y));
			}
		}
	}
	public static void main(String[]args) {
		new Main().main();
	}
}



Measured memory_bytes: 36172
#include<stdio.h>
int main()
{   int a,b,c;
int N[10]={0};
scanf("%d%d%d",&a,&b,&c);
N[a]++;
N[b]++;
N[c]++;
if(N[5]==2&&N[7]==1)printf("YES\n");
else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define input_i(x) scanf("%d", &x)
#define input_lli(x) scanf("%lld", &x)
#define input_s(x) scanf("%s", x)

#define BUFSIZE 1001

int main(int argc, char const *argv[]) {
    int N, i;
    input_i(N);
    int B[N];
    for(i= 0; i < N - 1; i++) {
        input_i(B[i]);
    }
    B[N - 1]= B[N - 2];
    int ans= 0;
    ans+= B[0];
    for(i= 1; i < N - 1; i++) {
        int min= (B[i] < B[i - 1]) ? B[i] : B[i - 1];
        ans+= min;
    }
    ans+= B[N - 1];

    printf("%d\n", ans);

    return 0;
}


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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int i=0;
    for(;;){
        if(i%2==0){
            c-=b;
            if(c<=0){
                cout<<"Yes"<<endl;
                break;
            }
        }
        else{
            a-=d;
            if(a<=0){
                cout<<"No"<<endl;
                break;
            }
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define REP1(i,n) for(long long i=1;i<=(n);i++)
#define REP2D(i,j,h,w) for(long long i=0;i<(h);i++) for(long long j=0;j<(w);j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=(h);i++) for(long long j=1;j<=(w);j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) ((a).begin()),((a).end())
#define RANGE(a) (a),((a)+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl

#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << (a) << endl
#define DBSTART if(1){
#define DBEND }
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#else
#define DBPRT(a) if(0){}
#define DBSTART if(0){
#define DBEND }
#define PRTLST(arr,num) if(0){}
#define PRTLST2(arr2,d1,d2) if(0){}
#define PRTLST2D(arr2,d1,d2) if(0){}
#endif

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 100000
//---------------------

char c;

int main(){
	cin >> c;
	PRT((char)(c+1));
	return 0;
}









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

int main(){
  int N,ans=100000000,count=0;
  cin >> N;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    while(a%2==0){
      a /=2;
      count++;
    }
    ans = min(ans,count);
    count = 0;
  }
  cout << ans << endl;
}  

Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        if(N==3) {
        		System.out.println(2);
        		System.out.println("1 3");
        		System.out.println("2 3");	        	
	        } else if(N==4) {
        		System.out.println(4);
        		System.out.println("1 2");
        		System.out.println("1 3");
        		System.out.println("2 4");	        	
        		System.out.println("3 4");	        	
	        } else if(N%2==0) {
        		System.out.println(2*N);
	        	for(int i=1;i<N/2;i++) {
	        		int k=(i+1);
	        		System.out.println(i + " " + k);
	        		System.out.println(i + " " + (N-k+1));
	        		System.out.println((N-i+1) + " " + k);
	        		System.out.println((N-i+1) + " " + (N-k+1));
	        	}
        		System.out.println(N/2 + " " + 1);
        		System.out.println(N/2 + " " + + N);
        		System.out.println(N/2+1 + " " + 1);
        		System.out.println(N/2+1 + " " + N);
	        	
	        } else {
        		System.out.println(2*N-2);
	        	for(int i=1;i<N/2;i++) {
	        		int k=(i+1);
	        		System.out.println(i + " " + k);
	        		System.out.println(i + " " + (N-k));
	        		System.out.println((N-i) + " " + k);
	        		System.out.println((N-i) + " " + (N-k));
	        	}
        		System.out.println(N/2 + " " + N);
        		System.out.println(N/2+1 + " " + N);
        		System.out.println(1 + " " + N);
        		System.out.println(N-1 + " " + N);
	        }
	        
	    }
	}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dv[70000], dp[70000],am[20][20];
int n;
ll cv(int n) {
	if(n == 0) {return 0;}
	if (dv[n] != -1) {return dv[n];}
	if(n&(-n) == n) {return dv[n] = 0;}
	int lso = n&(-n);
	int ki = n-lso;
	ll ov = cv(ki);
	int li = 0;
	lso >>=1;
	while(lso > 0) {li++;lso>>=1;}
	int ctr = 0;
	while(ki > 0) {
		if(ki&1) {ov+=am[li][ctr];}
		ki >>=1;ctr++;
	}
	return dv[n] = ov;
}
ll ds(int v) {
	if(v == 0) {return 0;}
	if(dp[v] != -1) {return dp[v];}
	//printf("%d\n",v);
	ll val = -1LL<<45;
	int vc[20];
	int cr=0;
	int i=v;
	while(i > 0) {
		val = max(val,cv(i)+ds(v-i));
		//printf("i %d\n",i);
		i--;
		i = i&v;
	}
	/*
	for(int i=1;i<(1<<cr);i++) {
		int ri = 0;
		val = max(val,cv(i)+ds(v-i));
		//printf("%lld\n",cv(i));
	}
	*/
	return dp[v] = val;
}
int main() {
	memset(dp,-1,sizeof(dp));
	memset(dv,-1,sizeof(dv));
	scanf("%d ",&n);
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			int t;
			scanf("%d ",&t);
			am[i][j] = t;
		}
	}
	printf("%lld\n",ds((1<<n)-1));
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
const int INF_INT = 2147483647;
const long long INF_LONG = 9223372036854775807;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


void dfs (vector<vector<int>> &ki, vector<ll> &cnt, vector<int> &chckd, int idx, int x) {
  if (chckd[idx] == 1) return;
  else chckd[idx] = 1;
  cnt[idx] += x;
  for (int y : ki[idx]) dfs(ki, cnt, chckd, y, cnt[idx]);
  return;
}
     
int main() {
  int n, q;
  cin >> n >> q;
  vector<vector<int>> ki(n, vector<int>(0));
  vector<ll> cnt(n, 0);
  vector<int> chckd(n, 0);
  
  rep (i, n - 1) {
    int a, b;
    cin >> a >> b;
    ki[a - 1].push_back(b - 1);
    ki[b - 1].push_back(a - 1);
  }
  rep (i, q) {
    int p, x;
    cin >> p >> x;
    cnt[p - 1] += x;
  }

  dfs(ki, cnt, chckd, 0, 0);
  
  rep(i, n) printf("%lld ", cnt[i]);
  cout << endl;
}

Measured memory_bytes: 28160
for e in iter(input,'0'):
 R=[set()for _ in[0]*-~int(e)]
 for _ in[0]*int(input()):
  a,b=map(int,input().split())
  R[a]|={b}
  if a-1:R[b]|={a}
 for m in set(R[1]):
  R[1]|=R[m]
 print(len(R[1]))


Measured memory_bytes: 6772