akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <iomanip>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <cassert>
#include <stack>
#include <climits>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#include <functional>
#include <cfloat>
#include <numeric>

template<typename T = long long int, class Monoid_plus = std::plus<T>, T zero = 0>
class BinaryIndexedTree {
	std::vector<T> vec;
	Monoid_plus plus;
public:
	BinaryIndexedTree(const int _size) : vec(_size, zero), plus{ Monoid_plus() } {};
	BinaryIndexedTree(const int _size, const Monoid_plus& _plus) : vec(_size, zero), plus{ _plus }{};
	BinaryIndexedTree(const std::vector<T>& initial, const Monoid_plus& _plus = Monoid_plus()) : vec(initial), plus{ _plus }{
		for (auto i = 0; i < vec.size(); ++i) {
			const auto pos = i + (~i & (i + 1));
			if (pos < initial.size())
				vec[pos] += vec[i];
		}
	};
	BinaryIndexedTree(std::vector<T>&& initial, const Monoid_plus& _plus = Monoid_plus()) : vec(std::move(initial)), plus{ _plus }{
		for (auto i = 0; i < vec.size(); ++i) {
			const auto pos = i + (~i & (i + 1));
			if (pos < initial.size())
				vec[pos] += vec[i];
		}
	};
	void increase(int position, const T value) {
		while (position < vec.size()) {
			vec[position] = plus(vec[position], value);
			position += (position + 1) & ~position;
		}
	}
	T accumulate(int position) const {
		T result = zero;
		while (position >= 0) {
			result = plus(vec[position], result);
			position -= (position + 1) & ~position;
		}
		return result;
	}
	int size() const { return vec.size(); }
};
int main() {
	int n, q; std::cin >> n >> q;
	std::vector<long long int> nums(n);
	for (auto& x : nums) std::cin >> x;
	BinaryIndexedTree<> bit(nums);
	for (auto i = 0; i < q; ++i) {
		int t, l, r; std::cin >> t >> l >> r;
		if (t == 0) {
			bit.increase(l, r);
		}
		else if (t == 1) {
			std::cout << bit.accumulate(r - 1) - bit.accumulate(l - 1) << '\n';
		}
		else {
			throw 0;
		}
	}
}


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

int main() {
  int N, A;
  cin >> N;
  string ans = "APPROVED";
  while (cin >> A) if (A % 2 == 0) if (A % 3 && A % 5) ans = "DENIED";
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int k[60],a[60][60];
int cnt[60];
int ans=0;
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++)cnt[i]=0;
    for(int i=0;i<n;i++){
        cin>>k[i];
        for(int j=0;j<k[i];j++){
            cin>>a[i][j];
            cnt[a[i][j]]++;
        }
    }
    for(int i=1;i<=m;i++){
        if(cnt[i]==n)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n=3
a=[[0]*n for ii in range(n)]
for ii in range(n):
  a[ii][:]=map(int,input().split())
m=int(input())
b=[0]*m
for ii in range(m):
  b[ii]=int(input())
#print(a)
c=[[1 if jj in b else 0 for jj in ii] for ii in a]
#print(c)
for ii in range(n):
  if sum(c[ii])==3:
    print("Yes")
    exit()
  if sum([c[jj][ii] for jj in range(n)])==3:
    print("Yes")
    exit()
if sum([c[jj][jj] for jj in range(n)])==3:
  print("Yes")
  exit()
if sum([c[jj][n-1-jj] for jj in range(n)])==3:
  print("Yes")
  exit()
print("No")
    

Measured memory_bytes: 3064
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>

using namespace std;

#define MAX 30001
#define ll long long int



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s,c,start="",end="";
    int q,t,f,cumT=0;
    cin>>s>>q;
    for (int i = 0; i < q; ++i)
    {
        cin>>t;
        if(t==1)cumT++;
        else
        {
            cin>>f>>c;
            if(cumT%2==0)
            {
                if(f==1) start=c+start;
                else end+=c;
            }
            else
            {
                if(f==1) end+=c;
                else start=c+start;
            }
        }
    }
    s=start+s+end;
    if(cumT%2==1) reverse(s.begin(),s.end());
    cout<<s;
}


Measured memory_bytes: 1316
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

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

  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k <= a) {
    cout << k << endl;
  } else if (k <= a + b) {
    cout << a << endl;
  } else {
    cout << a - (k - a - b) << endl;
  }
  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  string s;
  cin >> s;
  int d = unique(ALL(s)) - s.begin();
  cout << d-1 << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        
        List<Integer>[] list = new List[d+1];
        for (int i = 0; i < d+1; i++) {
            list[i] = new ArrayList<Integer>();
        }
        
        for (int i = 0; i < n; i++) {
            int day = sc.nextInt();
            int value = sc.nextInt();
            if (day > d) continue;
            
            list[day].add(value);
        }
        
        PriorityQueue<Integer> que = new PriorityQueue<>(Collections.reverseOrder()); // 降順で
        
        long ans = 0;
        for (int i = 1; i <= d; i++) {
            if (list[i].size() != 0) {
                for (Integer num : list[i]) {
                    que.add(num);
                }
            }
            if (que.isEmpty()) continue;
            ans += (long)que.poll();
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 96952
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll ara[2000];
ll fact(ll n,ll r)
{
ll ret;
    if(n<r){return 0;}
    else{
        ret=(n%2==0)?((n/2)*(n-1)):n*(n-1)/2;
    }
return ret;
}
int main()
{
    ll i,j,n,k,ts=1,sd,nm;
    ll nsx,nsy,ndx,ndy;
    ll T;
    scanf("%lld\n",&T);
    string str;
    char ara[11],vh;
    memset(ara,0,sizeof(ara));
    vector<ll>v;
    vector<string> vc;
    map<string,ll>m;
    for(i=1;i<=T;i++){
        //getline(cin,str);
        scanf("%s",ara);
        scanf("%c",&vh);
        int in=0;
        /*for(j=0;j<str.size();j++){
            in=in+str[j];
        }*/
        sort(ara,ara+10);
        str=ara;

        if(m[str]==0){vc.push_back(str); }m[str]++;
        //ara[in]++;
        //cout<<in<<'\n'<<str<<'\n';

    }
    ll cnt=0;
    for(i=0;i<vc.size();i++){

        cnt=cnt+fact(m[vc[i] ],2);

    }
    printf("%lld\n",cnt);
 


    return 0;
}

Measured memory_bytes: 12020
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 1e5 + 211;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


long double a, b;
	

main () {
	cin >> a >> b;
	cout << (int)(a * b);
}





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

bool isPrime(ll n){
   for(ll i=2;i<sqrt(n);i++){
      if(n%i==0)
         return false;
   }
   return true;
}

int main(){
   ll n;
   cin>>n;
   if(n%2==0&&n!=2)
      n+=1;

   while(!isPrime(n)){
      n+=2;
   }
   cout<<n;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s;
    cin >> s;

    for (int i = s.size() / 2 - 1; i >= 1; i--)
    {
        if (s.substr(0, i) == s.substr(i, i))
        {
            cout << i * 2 << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
"""
各山のgrundy数がわかればよい

基本的にループする
"""

N = int(input())

ans = 0

for i in range(N):

    A,K = map(int,input().split())

    

    while True:

        if A % K == 0:
            ans ^= A // K
            break

        elif A == K-1:
            ans ^= 0
            break

        else:

            if A // K != (A - A//K -1) // K:
                A = A - A // K - 1
            else:
                A -= (A - (A // K) * K) // (A // K+1) * (A//K+1)

    

if ans == 0:
    print ("Aoki")
else:
    print ("Takahashi")


Measured memory_bytes: 41736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), c = in.nextInt(), k = in.nextInt();
			int[] a = in.nextIntArray(n);
			Arrays.sort(a);

			int cap = 0;
			int time = a[0] + k;
			int ans = 1;

			for (int i = 0; i < n; i++) {
				if (cap < c && a[i] <= time) {
					cap++;
				} else {
					ans++;
					cap = 1;
					time = a[i] + k;
				}
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

#define ll long long
#define ar array

const int MOD=2019;
int n, ss[200001];
string s;

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

	cin >> s, n=s.size();
	ss[n]=0;
	int mult=1;
	for (int i=n-1; ~i; --i) {
		ss[i]=(ss[i+1]+(s[i]-'0')*mult)%MOD;
		mult=mult*10%MOD;
	}
	map<int, int> oc;
	for (int i=0; i<=n; ++i) oc[ss[i]]++;
	ll ans=0;
	for (auto x : oc) ans+=1ll*x.second*(x.second-1)/2;
	cout << ans;
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 4532
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

long long int INF = 1000000000000LL;
#define MAX_V 120000

struct edge{
  long long int to, cost;
};

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

vector<edge> G[MAX_V];
long long int d[MAX_V];

void shortest_path(int s, int V){
  priority_queue<P, vector<P>, greater<P> > que;
  for(int i = 0; i < V; i++){
    d[i] = INF;
  }
  d[s] = 0;
  que.push(P(0, s));

  while(!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.second;
    if(d[v] < p.first){
      continue;
    }
    for(int i = 0; i < G[v].size(); i++){
      edge e = G[v][i];
      if(d[e.to] > e.cost + d[v]){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main(){
  int V, E, s;
  cin >> V >> E >> s;

  for(int i = 0; i < E; i++){
    int u, v, cost;
    edge e;
    cin >> u >> v >> cost;
    e.cost = cost;
    e.to = v;
    G[u].push_back(e);
  }

  shortest_path(s, V);

  for(int i = 0; i < V; i++){
    if(d[i] == INF){
      cout << "INF" << endl;
    }else{
      cout << d[i] << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 19856
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits>
using namespace std;

template<typename Type> class RangeMin {
private:
	int size_;
	std::vector<Type> dat;
public:
	RangeMin() : size_(0), dat(std::vector<Type>()) {};
	RangeMin(int size__) {
		for (size_ = 1; size_ < size__; ) size_ <<= 1;
		dat.resize(size_ << 1, std::numeric_limits<Type>::max());
	}
	template<class T>
	RangeMin(T begin_, T end_) {
		int n = end_ - begin_;
		for (size_ = 1; size_ < n; size_ <<= 1); dat.resize(size_ << 1, std::numeric_limits<Type>::max());
		for (int i = 0; i < n; i++) dat[i + size_] = *(begin_ + i);
		for (int i = size_ - 1; i > 0; i--) dat[i] = std::min(dat[i << 1], dat[(i << 1) + 1]);
	}
	inline unsigned size() { return size_; }
	inline void update(int i, Type x) {
		i += size_; dat[i] = x;
		while (i > 1) {
			i >>= 1;
			dat[i] = std::min(dat[i << 1], dat[i << 1 | 1]);
		}
	}
	inline Type query(int l, int r) {
		Type ret = std::numeric_limits<Type>::max();
		l += size_; r += size_;
		while (l != r) {
			if (l & 1) ret = std::min(ret, dat[l++]); l >>= 1;
			if (r & 1) ret = std::min(ret, dat[--r]); r >>= 1;
		}
		return ret;
	}
};

long long N, H[1 << 18], A[1 << 18], dp[1 << 18];
RangeMin<long long>X;

int main() {
	cin >> N; X = RangeMin<long long>(N + 2);
	for (int i = 1; i <= N; i++) cin >> H[i];
	for (int i = 1; i <= N; i++) cin >> A[i];

	X.update(0, 0);
	for (int i = 1; i <= N; i++) {
		long long E = -X.query(0, H[i]);
		dp[i] = E + A[i];
		X.update(H[i], -dp[i]);
	}
	long long maxn = 0;
	for (int i = 0; i <= N; i++) maxn = max(maxn, dp[i]);
	cout << maxn << endl;
	return 0;
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int N;

  int k[100001];

  while(1){
    
    cin>>N;

    if(N==0){
      break;
    }

    int cnt=0;
    
    for(int i=0;i<N;i++){
      cin>>k[i];

      if(k[i]>=2){
	cnt++;
      }
    }

    if(cnt==0){
      cout<<"NA"<<endl;
      continue;
    }else{

      cnt=0;
      for(int i=0;i<N;i++){
	if(k[i]>=1){
	  cnt++;
	}
      }

      cout<<cnt+1<<endl;
    }
  }
      


    
	  
  return 0;

}



Measured memory_bytes: 3184
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll h,w,K;
    cin>>h>>w>>K;
    ll res2=0;
    VV vec(h,V(w));
    rep(i,h){
        string s;
        cin>>s;
        rep(j,w){
            if(s[j]=='#'){
                vec[i][j]=1;
            }
        }
    }
    rep(i,(1<<(h+w))){
      //  cout<<i<<endl;
        VV temp=vec;
        rep(j,h+w){
            if(i&(1<<j)){
                if(j>=h){
                    ll width=j-h;
                  //  cout<<width<<endl;
                   // cout<<width<<endl;
                    rep(k,h){
                        temp[k][width]=0;
                    }
                }else{
                    rep(k,w){
                        temp[j][k]=0;
                    }
                }
            }
        }
        ll res=0;
        rep(j,h){
            rep(k,w){
                res+=temp[j][k];
            }
        }
        if(res==K){
            res2++;
        }
    }
    cout<<res2<<endl;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, std::vector<std::vector<long long>> D){
    rep(i,0,N-2) {
        bool test = true;
        rep(j,0,3) {
            if (D[i+j][0] != D[i+j][1]) {
                test = false;
                break;
            }
        }
        if (test) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<std::vector<long long>> D(N, std::vector<long long>(2));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < 2 ; j++){
            scanf("%lld",&D[i][j]);
        }
    }
    solve(N, std::move(D));
    return 0;
}


Measured memory_bytes: 3696
#include <iostream>

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

struct Node {
  int parent;
  int left;
  int right;
};

Node t[100000];
int d[1000000];

void setDepth(int i, int depth) {
  d[i] = depth;
  if (t[i].left != -1)
    setDepth(t[i].left, depth + 1);
  if (t[i].right != -1)
    setDepth(t[i].right, depth);
}

void printChildren(int i) {
  std::cout << "[";

  int c = t[i].left;
  while (c != -1) {
    std::cout << c;
    c = t[c].right;
    if (c == -1) {
      break;
    } else {
      std::cout << ", ";
    }
  }
  std::cout << "]\n";
}

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

  rep(i, n) t[i] = Node{-1, -1, -1};

  int id, k, c, l;
  rep(i, n) {
    std::cin >> id >> k;
    rep(j, k) {
      std::cin >> c;
      if (j == 0)
        t[id].left = c;
      else
        t[l].right = c;
      l = c;
      t[c].parent = id;
    }
  }

  int root;
  rep(i, n) {
    if (t[i].parent == -1)
      root = i;
  }

  setDepth(root, 0);

  rep(i, n) {
    std::string type;
    if (t[i].parent == -1)
      type = "root";
    else if (t[i].left == -1)
      type = "leaf";
    else
      type = "internal node";

    printf("node %d: parent = %d, depth = %d, %s, ", i, t[i].parent, d[i],
           type.c_str());
    // std::cout << '\n';
    printChildren(i);
  }

  return 0;
}



Measured memory_bytes: 4812
N, K = map( int, input().split())
T = [(0,0)]*N
for i in range(N):
    t, d = map( int, input().split())
    T[i] = (d,t)
T.sort( key= None, reverse = True)
C = T[:K]
AC = T[K:]
kiso = 0
s = 0
S = [0]*(N+1)
for i in range(K):
    d, t = T[i]
    kiso += d
    if S[t] == 0:
        S[t] = 1
        s += 1
    else:
        S[t] += 1
ans = kiso + s**2
C.sort()
r = 0
 
for i in range(K):
    d, t = C[i]
    if S[t] >= 2:
        while r < N-K:
            if S[ AC[r][1]] == 0:
                S[t] -= 1
                S[ AC[r][1]] += 1
                s += 1
                kiso -= d
                kiso += AC[r][0]
                r += 1
                break
            r += 1
    ans = max( ans, kiso + s**2)
print( ans)

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

#define ff              first
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ss              second
#define int             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 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());


const int N = 3e5, M = N;
//=======================


void solve() {
  int i, j, n, m;
  cin>>n;
  vector<pair<int,int>> d(n);
  int count=0;
  int flag=0;
  fo(i,n){
    cin>>d[i].first>>d[i].second;
    if(d[i].first==d[i].second){
        count++;
        if(count>=3){
            flag=1;
        }
    }
    else{
        count=0;
    }
    
  }
  if(flag){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

int32_t main()
{
  FIO;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  
  solve();
  return 0;
}


Measured memory_bytes: 3660
import math

N, K = map(int, input().strip().split())

A_list = list(map(int, input().strip().split()))
F_list = list(map(int, input().strip().split()))

A_list.sort()
F_list.sort()
F_list.reverse()

def check(score):
	k = K
	for a, f in zip(A_list, F_list):
		if a * f > score:
			t = math.floor(score / f)
			k -= a - t
			if k < 0:
				return False
	return True

score_min = 0
score_max = (10 ** 6) * (10 ** 6) * (10 ** 5)
while score_min < score_max:
	score = (score_max + score_min) // 2
	if check(score):
		score_max = score
	else:
		score_min = score + 1

print(score_min)


Measured memory_bytes: 121164
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var arr = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();

            arr.Sort();
            var tempList = new List<double>();
            tempList.Add(arr[0]);

            for (int i = 1; i < arr.Count(); i++)
            {
                tempList.Add((tempList.Last() + arr[i]) / 2);
            }
            

            Console.WriteLine(tempList.Last());
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int main()
{
    int H, W;
    cin >> H >> W;
    char picture[H+2][W+2];
    memset(picture, '#', sizeof(picture));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> picture[i+1][j+1];
        }
    }
    for(int i=0; i<H+2; i++){
        for(int j=0; j<W+2; j++){
            cout << picture[i][j];
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    string s;
    cin>>s;
    string t;
    cin>>t;

    int cnt = 0;
    rep(i,0,s.length())
    {
        if ( s[i] == t[i] )
        {
            cnt++;
        }
    }

    cout<<cnt<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



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

int main() {
	int c,road;
	int temp;
	cin>>c>>road;
	int input=2*road;
	int connect[c+1]={0};
	for(int i=0;i<input;i++){
		cin>>temp;
		connect[temp]++;
	}
	for(int i=1;i<=c;i++){
		cout<<connect[i]<<endl;
	}

	return 0;
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, M;
int s[5], c[5];
signed main() {
    cin >> N >> M;
    rep(i, M) {
        cin >> s[i] >> c[i];
        s[i]--;
    }
    int st = 1;
    rep(i, N - 1) { st *= 10; }
    for (int i = (st == 1 ? 0 : st); i < st * 10; i++) {
        string x = to_string(i);
        dump(x);
        rep(j, M) {
            if (x[s[j]] != c[j] + '0') { goto nene; }
        }
        fin(x);
        nene:;
    }
    fin(-1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define int long long
#define ff first
#define ss second
#define pi pair<int,int>


int32_t main() {
	boost;
	int n , q;
	cin >> n >> q;
	vector< int > g[n + 1];
	for(int i = 1, u, v; i < n; i++) {
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int ans[n + 1] = {0};

	while(q--) {
		int p, x;
		cin >> p >> x;
		ans[p] += x;
	}

	function < void (int , int) >  dfs = [&](int u, int p) {
		ans[u] += ans[p];
		for(int &v : g[u]) {
			if(v == p)
				continue;
			dfs(v,u);
		}
	};

	dfs(1,0);

	for(int  i = 1; i <= n; i++)
		cout << ans[i] << ' ';
	cout << endl;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	int a, b; cin >> a >> b;
	if (a <= 8 && b <= 8) cout << "Yay!" << endl;
	else cout << ":(" << endl;
}

Measured memory_bytes: 256
a = input()
b = input()
if len(a) > len(b):
    print("GREATER")
elif len(b) > len(a):
    print("LESS")
else:
    for i in range(len(a)):
        if a[i] == b[i]:
            continue
        if int(a[i]) > int(b[i]):
            print("GREATER")
            exit()
        else:
            print("LESS")
            exit()
    else:
        print("EQUAL")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll n,m;
   cin >> n >> m;
   if(n==1 || m==1)
   {
       int r = n*m;
       if(r>=2)cout << r-2 << endl;
       else cout << 1 << endl;
   }
   else
   {
       ll val = (n-2)*(m-2) ;
       //ll r = (n*2)+((m-2)*2);
       cout << val<< endl;
   }
}



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

int main() {
  ll N, x; cin >> N >> x;
  if (x == 1 || x == 2*N-1) {
    cout << "No" << endl; return 0;
  }
  vector<ll> v;
  for (ll i = 2; i <= 2*N-2; i++) {
    if (i == x) {continue;}
    else {v.push_back(i);}
  }
  ll a[2*N-1];
  a[N-2] = 2*N-1;
  a[N-1] = x;
  a[N] = 1;
  for (ll i = 0; i < N-2; i++) {
    a[i] = v[i];
  }
  for (ll i = N+1; i < 2*N-1; i++) {
    a[i] = v[i-3];
  }
  cout << "Yes" << endl;
  for (ll i = 0; i < 2*N-1; i++) {
    cout << a[i] << endl;
  }
}

Measured memory_bytes: 4720
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

struct Info{
	Info(){
		point = 0;
	}
	char name[11];
	int point;
};

struct Data{
	Data(){
		index = 0;
	}
	int table[35],index;
};

int N;

bool strCmp(char* base, char* comp){
	int length1 = 0,length2 = 0;
	for(int i=0;base[i] != '\0'; i++)length1++;
	for(int i=0;comp[i] != '\0'; i++)length2++;
	if(length1 != length2)return false;

	for(int i=0;base[i] != '\0'; i++){
		if(base[i] != comp[i])return false;
	}
	return true;
}

void strcpy(char* to,char* str){
	for(int i=0;str[i] != '\0';i++){
		to[i] = str[i];
		to[i+1] = '\0';
	}
}

int strCmp2(char* left,char* right){
	int i;

	if(strCmp(left,right))return 3;

	for(i=0;left[i] != '\0' && right[i] != '\0'; i++){
		if(left[i] != right[i]){
			if(left[i] < right[i])return 1;
			else{
				return 2;
			}
		}
	}
	if(left[i] == '\0')return 1;
	else{
		return 2;
	}
}

void func(){
	Info info[N],work;
	Data data[31];

	int num,tmp;

	for(int i = 0; i < N; i++){
		scanf("%s %d",info[i].name,&num);
		for(int k = 0; k < num; k++){
			scanf("%d",&tmp);
			data[tmp].table[data[tmp].index++] = i;
		}
	}

	for(int i = 0; i <= 30; i++){
		tmp = N - (data[i].index-1);
		for(int k = 0; k < data[i].index;k++){
			info[data[i].table[k]].point += tmp;
		}
	}

	for(int i = 1; i <= N-1; i++){
		for(int k = N-1; k >= i; k--){
			if((info[k].point < info[k-1].point) || (info[k].point == info[k-1].point && strCmp2(info[k].name,info[k-1].name) == 1)){
				strcpy(work.name,info[k-1].name);
				work.point = info[k-1].point;
				strcpy(info[k-1].name,info[k].name);
				info[k-1].point = info[k].point;
				strcpy(info[k].name,work.name);
				info[k].point = work.point;
			}
		}
	}

	printf("%d %s\n",info[0].point,info[0].name);

}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 2720
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)



// BFSによる(隣接リスト)2部グラフ判定
#define MAX_E (100000)
#define MAX_V (100000)
int V, E; // V:頂点数、E:辺数
vector<int> G[MAX_V]; // 隣接リストでグラフを保持
int color[MAX_V];

bool bfs(int v) {

	// キューを用意して、初期探索点をセット
	queue <int> que;
	color[v] = 1;
	que.push(v);

	while (!que.empty()) { // BFSループ
		// ★★　この中で迂闊に break しないこと

		// キューの先頭のセルを取得
		int from = que.front(); que.pop();

		// 取得したセルに対する処理

		// そのセルからつながるセルに処理を移行
		for (int i = 0; i < G[from].size(); i++) {
			int to = G[from][i];

			if (color[to] == 0) {
				color[to] = -1 * color[from]; // 2色塗分け
				que.push(to);
			}
			else if(color[to] == color[from]) { // 2色塗分けに失敗
				return false;
			}
		}
	}
	return true;
}

int main() {

	cin >> V >> E;

	for (int i = 0; i < E; i++) {
		int u, v;
		cin >> u >> v;
		G[u - 1].push_back(v - 1);
		G[v - 1].push_back(u - 1); // 無向グラフ
	}

	fill(color, color + V, 0);

	// 2部グラフか否か
	bool BipartiteGraph = true;

	for (int i = 0; i < V; i++) {
		if (color[i] == 0) {
			if (!bfs(i)) BipartiteGraph = false;
		}
	}

	long long ans = 0;
	if (BipartiteGraph) {
		int one_count = 0;
		for (int i = 0; i < V; i++) {
			if (color[i] == 1) one_count++;
		}
		ans = (long long)(one_count) * (long long)(V - one_count) - (long long)(E);
	}
	else {
		ans = (long long)(V) * (long long)(V - 1) / 2 - (long long)(E);
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 6272
#include<iostream>

// calculate times in one program

int main(){
	int a,b;
	char op;
	
	while(1){
		std::cin >> a >> op >> b;
		if(op=='?') break;
		
		if(op=='+')std::cout << a + b <<"\n";
		else if(op=='-')std::cout << a - b <<"\n";
		else if(op=='*')std::cout << a * b <<"\n";
		else if(op=='/'&&b!=0)std::cout << a / b <<"\n";
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
  ll ans = 0;
  string s,t;cin>>s>>t;
  rep(i,s.size()){
    if(s[i] != t[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3772
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int numN = scan.nextInt();

		List<Double> numA = new ArrayList<>();

		for (int i = 0; i < numN; i++) {
			numA.add(1.0 / scan.nextDouble());
		}

		double sum = 0.0;

		for (double num: numA) {
			sum += num;
		}

		System.out.println(1.0 / sum);
	}
}


Measured memory_bytes: 23252
N = int(input()) # 1~100ドル

CAKE = 4
DONUTS = 7

ans = "No"
for i in range(N//CAKE + 1):
  for j in range(N//DONUTS + 1):
    total = CAKE*i + DONUTS*j
    if total == N:
      ans = "Yes"
      break

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <bitset>
using namespace std;
int main() {
	long long n, m;
	long long ans;
	cin >> n >> m;
	if (n == 1 && m == 1) {
		cout << "1" << endl;
		return 0;
	}
	else if (n == 1) {
		cout << m - 2 << endl;
		return 0;
	}
	else if (m == 1) {
		cout << n - 2 << endl;
		return 0;
	}
	else {
		ans = (n - 2) * (m - 2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll a[20][20];
	ll dp[(1<<16)];
	ll all[(1<<16)];
	scan(N);
	rep(i,N){
		rep(j,N){
			scan(a[i][j]);
		}
	}
	int twoNth=(1<<N);
	rep(bit,twoNth){
		ll pt=0;
		rep(i,N-1){
			for(int j=i+1;j<N;j++){
				if(1&(bit>>i)&(bit>>j)){
					pt+=a[i][j];
				}
			}
		}
		all[bit]=pt;
	}
	rep(bit,twoNth){
		dp[bit]=all[bit];
		int onenum=0;
		int nowbit=bit;
		while(nowbit){
			onenum+=(nowbit&1);
			nowbit>>=1;
		}
		int twopartial=(1<<onenum);
		rep(partialbit,twopartial){
			int nowpartial=partialbit;
			rep(keta,N){
				if(((bit>>keta)&1)==0){
					nowpartial=((nowpartial>>keta)<<(keta+1))+nowpartial%(1<<keta);
				}
			}
			dp[bit]=max(dp[bit],dp[bit-nowpartial]+dp[nowpartial]);
		}
	}
	/*rep(bit,twoNth){
		int now=bit;
		rep(i,N){
			printf("%d",now&1);
			now>>=1;
		}
		printf("  all:%lld dp:%lld\n",all[bit],dp[bit]);
	}*/
	prin(dp[twoNth-1]);
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef pair<long,long> PL;
typedef map<long,long> ML;
typedef vector<long> VL;
#define INF (int)(1e9)
#define MAXX 999999
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
/*--------------------------------------------*/

int main(){
    int n,m;cin>>n>>m;
    vector<PL> p(n);
    rep(i,n){cin>>p[i].first>>p[i].second;}
    sort(ALL(p));
    //rep(i,n)cout<<p[i].first<<"oooooo"<<p[i].second<<endl;
    int rest=m;
    ll sum=0;
    int now=0;
    while(rest>0){
        if(rest-p[now].second>0){
            sum+=p[now].first*p[now].second;
            rest-=p[now].second;now++;
        }else{
            sum+=p[now].first*rest;
            rest=0;
        }
    }
    cout<<sum<<endl;
}




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

import sys
sys.setrecursionlimit(10**9)
H = H + [10**9]
dp = [-1] * N

def dfs(pos):
  global N, H, dp

  if pos >= N:
    return 10**9
  if pos == N - 1:
    return 0
  if dp[pos] != -1:
    return dp[pos]

  step1 = dfs(pos+1) + abs(H[pos+1] - H[pos])
  step2 = dfs(pos+2) + abs(H[pos+2] - H[pos])
  dp[pos] = min(step1, step2)
  #print(pos, step1, step2)

  return(dp[pos])

ans = dfs(0)
#print(dp)
print(ans)

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

int main()
{
	cout << setprecision(10);
	cin >> n ;
	int d[n];
	rep(i,n) cin >> d[i];
	ll ans = 0;
	rep(i,n-1){
		for(int j = i+1 ; j < n ; j++){
			ans += d[i] * d[j] ;
		}
	}
	cout << ans<< endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
void solve()
{
  int n;
    cin>>n;
  double dp[n+1][n+1];
  double prob[n];
    for(int i=0;i<n;i++)
        cin>>prob[i];
  
  dp[0][0]=1;
  for(int i=1;i<=n;i++)
  {
    dp[i][0]=(1-prob[i-1])*dp[i-1][0];
    dp[0][i]=0;
  }
  
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
       dp[i][j]=prob[i-1]*(dp[i-1][j-1]);
       dp[i][j]+=(1-prob[i-1])*(dp[i-1][j]);
       
    }
  double ans=0;
  for(int i=n/2+1;i<=n;i++)
    ans+=dp[n][i];
  printf("%.9lf\n", ans);
 
 
 
}
 
int32_t main()
{
    
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 74056
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#N = int(input())
S = list(str(input()))
S.sort()
Q = "abcdefghijklmnopqrstuvwxyz"
#print (S)

index = 0
if S[0] == Q[0] :
  index += 1
else :
  print ("a")
  exit()

for i in range(1, len(S)) :
  if index == 26 :
    print ("None")
    exit()
  
  if S[i] == Q[index] :
    index += 1
  else :
    if S[i] == S[i-1] :
      continue
    print (Q[index])
    exit()


if index != 26 :
  print (Q[index])
else :
  print ("None")
    
    
    




Measured memory_bytes: 49392
n, m = map(int, input().split())
h = list(map(int, input().split()))
t = [set() for _ in range(n)]

for _ in range(m):
    a,b = map(int, input().split())
    t[a-1].add(b-1)
    t[b-1].add(a-1)

ans = 0
for i in range(n):
    now_t = h[i]
    if t[i]:
        if all([now_t > h[tall] for tall in t[i]]):
            ans += 1
    else:
        ans += 1
print(ans)

Measured memory_bytes: 45188
#include<cstdio>
int main() {
	int c[3][3], i, j, a[3], b[3];
	bool flag;
	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			scanf("%d", &c[i][j]);
		}
	}
	for (a[0] = 0; a[0] <= c[0][0]; a[0]++) {
		flag = true;
		for (j = 0; j < 3; j++) {
			b[j] = c[0][j] - a[0];
			if (b[j] < 0)flag = false;
		}
		for (i = 1; i < 3; i++) {
			a[i] = c[i][0] - b[0];
			if (a[i] < 0)flag = false;
		}
		for (i = 1; i < 3; i++) {
			for (j = 1; j < 3; j++) {
				if (a[i] + b[j] != c[i][j])flag = false;
			}
		}
		if (flag) {
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <string>

int main() {
  std::string s;
  std::cin >> s;

  int first = s.find('A');
  std::reverse(s.begin(), s.end());
  int second =  s.size() - s.find('Z');
  int AtoZ = second - first;
  std::cout << AtoZ << std::endl;

  return 0;
}


Measured memory_bytes: 640