akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define IC ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll ;
#define pb push_back

using namespace std;
//-------------------------------
const int N = 2e5 + 10 ;
int a ;
//------------------
int main()
{
    string s ;
    cin >> s ;
    for(int i = 0 ; i<s.size() ; i++)
        a += (s[i] - '0')%9 ;
    if(a%9)
        cout << "No" ;
    else
        cout << "Yes" ;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i; i<n; i++){
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  int size=0,ans=0;
  for (int i; i<n; i++){
   if (size<d[i]){
      ans+=1;
      size=d[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define _for(a,b,i) for(int i=a;i<=b;i++)
#define for1(a,b,i) for(int i=a;i<b;i++)
#define O(n) cout<<n;
using namespace std;
ll ma=0x80000000;
ll mi=0x7fffffff;
const ll zfc=0xffffffff;
const ll mod=1e9+7;
int a,b,c,z,zs;
int main()
{
	cin>>a>>b>>c;
	if(a==5)z++;else
	if(a==7)zs++;
	if(b==5)z++;else
	if(b==7)zs++;
	if(c==5)z++;else
	if(c==7)zs++;
	if(z==2&&zs==1)cout<<"YES"<<endl;else cout<<"NO"<<endl;
    return 0;
}


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

int main()
{
	int N, K; cin >> N >> K;
	string S; cin >> S;

	int ans = 0;

	int cnt0 = 0;
	bool flag = false;
	int pos = -1;
	queue<int>poss;
	for (int i = 0; i < N; i++)
	{
		if (flag && S[i] == '1')
		{
			poss.push(i - 1);
			flag = false;
		}
		else if (flag == false && S[i] == '0')
		{
			ans = max(ans, i - 1 - pos);

			if (cnt0 == K)
			{
				pos = poss.front();
				poss.pop();
				cnt0--;
			}

			flag = true;
			cnt0++;
		}
	}
	ans = max(ans, N - 1 - pos);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#define N 100005
using namespace std;
int n,a[N],b[N],aa[N],bb[N],fa[N],cnt,ans;
bool vis[N<<1];
map<int,int>mp;
template<class T>inline void read(T &x) {
	register T s=0,g=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')g=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=(s<<3)+(s<<1)+(ch^48);ch=getchar();}
	x=g?-s:s;
}
int getfa(int k){return fa[k]==k?k:fa[k]=getfa(fa[k]);}
int main() {
	read(n);
	for(register int i=1;i<=n;i=-~i)
		read(a[i]),a[n+1]^=a[i];
	for(register int i=1;i<=n;i=-~i)
		read(b[i]),b[n+1]^=b[i];
	++n;
	memcpy(aa,a,(n+1)<<2),memcpy(bb,b,(n+1)<<2);
	sort(aa+1,aa+n+1);sort(bb+1,bb+n+1);
	for(register int i=1;i<=n;i=-~i) {
		if(aa[i]!=bb[i]) {
			puts("-1");
			return 0;
		}
		if(!mp[aa[i]]) mp[aa[i]]=++cnt;
	}
	for(register int i=1;i<=cnt;i=-~i)
		fa[i]=i;
	for(register int i=1,f1,f2;i<=n;i=-~i) {
		a[i]=mp[a[i]],b[i]=mp[b[i]];
		if(a[i]!=b[i]) {
			ans+=i<n;
			f1=getfa(a[i]),f2=getfa(b[i]);
			if(f1!=f2) {
				fa[f1]=f2;
				vis[f1]=vis[f2]=true;
			}
		}
	}
	if(!ans) {
		puts("0");
		return 0;
	}
	vis[a[n]]=vis[b[n]]=true;
	for(register int i=1;i<=cnt;i=-~i)
		if(vis[i]&&getfa(i)==i) ++ans;
	printf("%d\n",ans-1);
	return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,ans=0;
	cin>>n;
	ll next=0;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		if(next==1&&x!=0){
			next=0;
			x--;
			ans++;
		}
		ans+=x/2;
		x%=2;
		next=x;
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector< vector<int> > A(3, vector<int>(N));
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < N; j++) {
    	cin >> A[i][j];
    }
    sort(A[i].begin(), A[i].end());
  }
  
  vector< vector<long long int> > step(3, vector<long long int>(N));
  
  for (int i = 0; i < 3; i++) {
    int left = 0;
    for (int j = 0; j < N; j++) {
      if (i == 0) {
        if (j == 0) {
        	step[i][j] = 1;
        } else {
          step[i][j] = step[i][j - 1] + 1;
        }
      } else {
        while (left < N - 1 && A[i - 1][left + 1] < A[i][j]) {
          left++;
        }
        if (A[i - 1][left] < A[i][j]) {
          if (j == 0) {
            step[i][j] = step[i - 1][left];
          } else {
            step[i][j] = step[i][j - 1] + step[i - 1][left];
          }
        }
      }
    }
  }
  
  cout << step[2][N - 1] << endl;
  
  return 0;
}


Measured memory_bytes: 4600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> vv;


int main(){
  string s;
  cin >> s;
  int ans = 0;
  rep(i,4){
    if(s[i] == '+') ans++;
    else ans --;
  }
  cout << ans << endl;
}

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

int main() {
 int n,a,b;
 cin >> n >> a >>b;
 if (n>=(a+b)) cout << min(a,b) << " " << 0 << endl;
 else cout << min(a,b) << " " << (a+b)-n << endl; 
}
  



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

using namespace std;

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

template<typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;

#define se second
#define fi first
#define pb push_back

int main() {
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    ll dist = 0;
    for(int i = 0; i <n; i++) {
    	int a;
    	cin>>a;
    	dist += min(a, k-a);
    }
    cout<<dist*2<<endl;
}

Measured memory_bytes: 256
R,G,B,N = map(int,input().split())
cnt = 0
for r in range(N+1):
    for g in range(N+1):
        if  (N - r*R - g*G) >= 0 and  (N - r*R - g*G)%B == 0 :
            cnt +=1
            #print(r,g,(N - r*R - g*G)//B)
print(cnt)

Measured memory_bytes: 68580
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
#define Fill(x, v, y) fill(x, x + v, y);
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const long long INFTY = (1LL<<32);
const double PI = 3.1415926535;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

// 全点対最短経路（全ての二点間の最短路を求める）
// ここから

static const int MAX_V = 100; // Vによって変える
int V; // 頂点数
int d[MAX_V][MAX_V];

void WarshallFloyed(void){
    REP(k, V){
        REP(i, V){
            if(d[i][k] == INFTY) continue;
            REP(j, V){
                if(d[k][j] == INFTY) continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}


signed main(void){
    int E; cin >> V >> E; // E -> 辺の数
    
    REP(i, V) REP(j, V) d[i][j] = ((i == j) ? 0 : INFTY);

    REP(i, E){
        int from, to, dist; cin >> from >> to >> dist;
        d[from][to] = dist;
        // d[to][from] = dist; // 無向グラフの時
    }

    WarshallFloyed();

    bool negative = false;
    REP(i, V) if(d[i][i] < 0) negative = true;

    if(negative){
        cout << "NEGATIVE CYCLE" << endl;
    }else{
        REP(i, V){
            REP(j, V){
                if(j) cout << " ";
                if(d[i][j] == INFTY) cout << "INF";
                else cout << d[i][j];
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

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

typedef long long ll;

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

	if (a > b) {
		swap(a, b);
	}
	if (b > c) {
		swap(b, c);
	}
	if (a > b) {
		swap(a, b);
	}

	int ans = a * b / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
s = input()

import sys
sys.setrecursionlimit(1000000)
list1 = [0]*len(s)


def r_search(start,index,count):
    if s[index] == "L":
        count -= 1 #RLで計算が始まる為
        if count == 0: #LRLの要な場合
            list1[index-1] += 1
            list1[index] += 1
            return index+1
        elif count %2 != 0: #奇数
            list1[index-1] += count//2 + 1 #このへんの+1は元々のRLの分
            list1[index] += count//2 +1 + 1
            return index+1
        else: #偶数
            list1[index-1] += count//2 + 1
            list1[index] += count//2 + 1
            return index+1
    else:
        return r_search(start,index+1,count+1)
        



def l_search(start,index,count): #start-1がL,-2がRで有ることが決まっている
    if index >= len(s) or s[index] == "R":
        if count %2 != 0: #奇数の場合逆側に１多く入る
            list1[start-2] += count//2+1
            list1[start-1] += count//2
            return index
        else:
            list1[start-2] += count//2
            list1[start-1] += count//2
            return index

    else:
        return l_search(start,index+1,count+1)
i = 0
while True:
    if i >= len(s):
        break
    elif s[i] == "R":
        i = r_search(i,i,0)
    else:
        i = l_search(i,i,0)
print(" ".join(map(str,list1)))


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

int findMinWater (vector<int> v) {
  if (v.size() == 0)
    return 0;
  if (v.size() == 1)
    return v[0];
  int minValue = 1000;
  int minIndex = -1;
  for (int i = 0; i < v.size(); i++) {
      if (v[i] < minValue) {
        minValue = v[i];
        minIndex = i;
      }
  }
  for (int i = 0; i < v.size(); i++)
    v[i] -= minValue;
  return minValue + findMinWater(vector<int> (v.begin(), v.begin() + minIndex)) + findMinWater(vector<int> (v.begin() + minIndex + 1, v.end()));
}

int main () {
  vector<int> v;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    v.push_back(temp);
  }
  cout << findMinWater (v);
}

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

namespace ABC139A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string a = Console.ReadLine();
            int x = 0;
            if (s[0] == a[0])
                x += 1;
            if (s[1] == a[1])
                x += 1;
            if (s[2] == a[2])
                x += 1;
            Console.WriteLine(x);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,m = LI()
    e = IR(m)
    f = [0 for i in range(n+1)]
    ans = [None for i in range(n)]
    i = m-1
    while i >= 0:
        if not f[e[i]]:
            f[e[i]] = 1
        else:
            e.pop(i)
        i -= 1
    ans[:len(e)] = e[::-1]
    k = sum(f)
    for i in range(1,n+1):
        if not f[i]:
            ans[k] = i
            k += 1
    for i in ans:
        print(i)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    A()



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

#define lint long long
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        char ch;
        cin >> ch;
        if (ch == 'Y') {
            cout << "Four\n";
            return 0;
        }
    }
    cout << "Three\n";
    return 0;
}


Measured memory_bytes: 256
import math
import itertools

def main():
  n = int(input())
  r0 = int(input())
  minR = r0
  r1 = int(input())
  if minR > r1:
    minR = r1
  maxDiff = r1 - r0

  for _ in range(2,n):
    r = int(input())

    diff = r - minR

    if maxDiff < diff:
      maxDiff = diff

    if minR > r:
      minR = r
  
  print(maxDiff)

if __name__ == '__main__':
  main()


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i=1;i<N;i++){
    int count = 0;
    for (char c='a';c<='z';c++){
      bool left=false;
      bool right=false;
      for (int j=0;j<i;j++){
        if (S.at(j)==c){
          left = true;
        }
      }
      for(int j=i;j<N;j++){
        if (S.at(j)==c){
          right = true;
        }
      }
      if (right && left){
        count += 1;
      }
    }
    ans = max(ans,count);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
   public static void main(String[] args) {
       Scanner s = new Scanner(System.in);
       int n = s.nextInt();
       int scarfs[] = new  int[n];
       int res = 0;
       for(int i = 0; i < n; i++) {
           scarfs[i] = s.nextInt();
           res ^= scarfs[i];
       }
       for(int i =0; i < n ; i++) {
           System.out.println(res^scarfs[i]);
       }
   }
}


Measured memory_bytes: 59896
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<int, int> P;
int N, M;
vector<P> cond[301];
ll dp[301][301][301];
ll solve(int R, int G, int B) {
	if (dp[R][G][B] != -1) return dp[R][G][B];
	ll ret = 0;
	int k = max(R, max(G, B)) + 1;
	if (k == N + 1) return dp[R][G][B] = 1;
	bool ok = 1;
	for (P c : cond[k]) {
		int cnt = 1;
		if (c.first <= G) cnt++;
		if (c.first <= B) cnt++;
		if (cnt != c.second) {
			ok = 0;
			break;
		}
	}
	if (ok) (ret += solve(k, G, B)) %= MOD;
	ok = 1;
	for (P c : cond[k]) {
		int cnt = 1;
		if (c.first <= R) cnt++;
		if (c.first <= B) cnt++;
		if (cnt != c.second) {
			ok = 0;
			break;
		}
	}
	if (ok) (ret += solve(R, k, B)) %= MOD;
	ok = 1;
	for (P c : cond[k]) {
		int cnt = 1;
		if (c.first <= R) cnt++;
		if (c.first <= G) cnt++;
		if (cnt != c.second) {
			ok = 0;
			break;
		}
	}
	if (ok) (ret += solve(R, G, k)) %= MOD;
	return dp[R][G][B] = ret;
}
int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int l, r, x;
		cin >> l >> r >> x;
		cond[r].emplace_back(l, x);
	}
	memset(dp, -1, sizeof(dp));
	cout << solve(0, 0, 0) << endl;
 }

Measured memory_bytes: 213376
/*In this problem we have to find Shortest Path from a given source to all other nodes but edge can contian negative edge
  
  Now , in we can't use dijkstras becuase (EXPLAIN)- 

Thus we use dijkstras algo given below*/


/*  	TO-DO - 
	1. MAKE COMMENTS 
	2. Understand the proof
	3. Record it in problem solved folder
	4. search - why dijkstra doesn't work with negative weights
	5. search - (not only detect but print) shortest path in graph with negative cycle
	6. search - does bellmanford & dijistra work on undirected graph*/

/*	This algo is 

	SOURCE -
    https://www.youtube.com/watch?v=FtN3BYH2Zes     - (understand algo)
	
*/
	

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

#define MAXN 100001

bool relaxAllEdges(int s, vector< pair<int, int> >& edges, long dist[])
{
    int len = edges.size();
    //printf("%d ",len);
    bool ans = 0;
    for(int i = 0 ; i < len ; i++)
    {
        int weight_i = edges[i].second, vertex_i = edges[i].first;
        long new_path = dist[s] + weight_i;
        if(dist[s] < LONG_MAX && new_path < dist[vertex_i])
        {
            dist[vertex_i] = new_path;
            ans = 1;
        }
    }
    return ans;
}

int bellmanFord(int s, vector< pair<int, int> > adj[], int n, long dist[])
{
    int n_cpy = n, relaxed = 1;
    while(n_cpy-- && relaxed)
    {
        relaxed = 0;//this counts the number of nodes "from which even edge is relaxed"
        //this loop is to process each node
        for(int i = s, cnt = 0 ; cnt < n ; i = (i+1) % n, cnt++)
            relaxed += relaxAllEdges(i, adj[i], dist);
    
    }
    
    return (relaxed ? 1 : 0);
}

int main()
{
	int n, s, e1, e2, w, i, num_edge, ans = 0, neg_cycle;
	long dist[MAXN];
	bool vis[MAXN] = {0};
	
	scanf("%d %d %d", &n, &num_edge, &s);
	
	vector< pair<int, int> > graph[n+1];//Adjacency list for storing graph
	for(i = 0 ; i < num_edge ; i++)
	{	
        scanf("%d %d %d",&e1, &e2, &w);
        graph[e1].push_back({e2, w});
	}
    
    //Initial distance is INF
    for(i = 0; i < n ; i++)
        dist[i] = LONG_MAX;
        
    //initalize the que with s and which is ditance 0 to itself
    dist[s] = 0;
    neg_cycle = bellmanFord(s, graph, n, dist);
    
    if(neg_cycle)
    {
        printf("NEGATIVE CYCLE\n");
        return 0;
    }
    for(i = 0 ; i < n ; i++)
	{
		if(dist[i] == LONG_MAX)
			printf("INF\n");
		else
			printf("%ld\n", dist[i]);
	}
}


Measured memory_bytes: 3236
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,X;
LL A[100000];

LL ans = 0;

void solve(){
	for(int i=1;i<=N-2;i++){
		LL sum = A[i-1]+A[i];
		LL diff = max(0LL,(sum-X));
		if(A[i]<diff) diff = A[i];
		ans += diff;
		A[i] -= diff;
	}

	LL sum = A[0]+A[1];
	LL diff = max(0LL,(sum-X));
	if(A[0]<diff) diff = A[0];
	ans += diff;
	A[0] -= diff;

	sum = A[N-2]+A[N-1];
	diff = max(0LL,(sum-X));
	if(A[N-1]<diff) diff = A[N-1];
	ans += diff;
	A[N-1] -= diff;

	// for(int i=0;i<=N-1;i++){
	// 	cout << A[i] << " ";
	// }
	// cout << endl;
}
 
int main(){
    cin >> N >> X;
    for(int i=0;i<N;i++) cin >> A[i];
 
    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  for(int i=0;i<3;i++){
	if(a%10==7){
	cout<<"Yes"<<"\n";
      return(0);
    }
    a=a/10;
  }
  cout<<"No"<<"\n";
  return(0);
}

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

const int MOD = 998244353;

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

    vector<int> a(n);
    map<int, int> cnt;
    for (int i = 0; i < n; i++){
        cin >> a[i];

        if (a[i] != 0)
            cnt[a[i]] += 1;
    }

    for (int i = 0; i < n; i++){
        if (i == 0 && a[i] != 0){
            cout << 0 << '\n';
            return 0;
        }
        if (i != 0 && a[i] == 0){
            cout << 0 << '\n';
            return 0;
        }
    }
    
    long long sum = 1LL, pre = 0LL, last_dis = 0;
    for (auto i: cnt){
        if (i.first != last_dis + 1){
            cout << 0 << '\n';
            return 0;
        }
        if (i.first != 1){
            long long x = 1LL;
            for (int j = 0; j < i.second; j++){
                x = (x * pre) % MOD;
            }
            sum = (sum * x) % MOD;
        }
        pre = i.second;
        last_dis = i.first;
    }

    cout << sum << '\n';

    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned long> ans(N);
    for(auto&& i : ans)cin >> i;
    vector<unsigned long> pts(N + 1);
    for(unsigned long i{0}; i < N; ++i){
        ++pts[i - min(ans[i], i)];
        --pts[min(N, i + ans[i] + 1)];
    }
    for(unsigned long i{0}; i < K; ++i){
        unsigned long changed{0};
        vector<unsigned long> tmp(N);
        partial_sum(begin(pts), end(pts) - 1, begin(tmp));
        for(unsigned long j{0}; j < N; ++j)if(tmp[j] != ans[j]){
            changed = 1;
            --pts[j - min(ans[j], j)];
            ++pts[min(N, j + ans[j] + 1)];
            ans[j] = tmp[j];
            ++pts[j - min(ans[j], j)];
            --pts[min(N, j + ans[j] + 1)];
        }
        if(!changed)break;
    }
    for(const auto& i : ans)cout << i << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 8008
#include <bits/stdc++.h>
using namespace std;
# define fills(x,y) memset(x,y,sizeof x)
# define ALL(v) (v).begin(), (v).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define INF (int)1e9
# define EPS 1e-9
# define rep(i,n) for(int i=0;i<n;++i)
# define REP(i,k,n) for(int i=k;i<=n;++i)
# define mod 1000000007

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef vector<ll> Vl;
typedef vector<Vl> VVl;
typedef vector<string> VS;
typedef vector<Pll> Vll;
typedef map<ll,ll> Mll;
typedef set<ll> SETl;


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

int		main()
{
	
//	cout << __gcd(30, 105) << endl;
//	cout << __gcd(105, 30) << endl;
	
	int K; cin >> K;
	ll res = 0;
	for (int i = 1; i <=K; i++)
	{
		for (int j = 1; j <=K; j++)
		{
			for (int k = 1; k <=K; k++)
			{
				res += __gcd(i, __gcd(j, k));
			}
		}
	}
	cout << res << endl;
	
}



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

int main() {
    int H,W;
    char sq[60][60];
    int bomb[60][60] = {};
    cin >> H >> W;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) cin >> sq[i][j];
    }

     for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (sq[i][j] == '#') {
                if (!(i == 0)) {
                    bomb[i - 1][j]++;
                    if (!(j == 0)) bomb[i - 1][j - 1]++;
                    if (!(j == W - 1)) bomb[i - 1][j + 1]++;
                }
                if (!(i == H - 1)) {
                    bomb[i + 1][j]++;
                    if (!(j == 0)) bomb[i + 1][j - 1]++;
                    if (!(j == W - 1)) bomb[i + 1][j + 1]++;                    
                }
                if (!(j == 0)) bomb[i][j - 1]++; 
                if (!(j == W - 1)) bomb[i][j + 1]++; 
            }

        }
    } 

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (sq[i][j] == '#') cout << '#';
            else cout << bomb[i][j];
        }
        cout << endl;
    }
}

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

int main()
{
  ll k , s;
  cin>>k>>s;
  ll ans =0;
  for(int i=0;i<=k;i++)
  {
      for(int j=0;j<=k;j++)
      {
          if( s - i -j >=0 && s-i-j <= k)
            ans++;
      }
  }
  cout<<ans;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll n, k; cin >> n >> k;
	ll ans = 0;
	if (k == 0) {
		cout << n * n << endl;
		return 0;
	}
	for (ll b = k + 1; b <= n; ++b) {
		ll cnt = n / b;
		ll m = n % b;
		ans += cnt * (b - k);
		if (m) ans += max(0ll, m + 1 - k);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
a = list(map(int,readline().split()))
a.sort(reverse=True)

k = n//2
if n % 2 == 1:
  print(sum(a[:k])*2-a[0]+a[k])
else:
  print(sum(a[:k])*2-a[0])

Measured memory_bytes: 92908
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int ans = true;
    REP(i, n) ans &= a[i] % 2 == 0;
    cout << (ans ? "second" : "first") << endl;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	sum := 0

	var gcd int
	for a := 1; a <= n; a++ {
		for b := a; b <= n; b++ {
			for c := b; c <= n; c++ {
				gcd = clacGcd(a, b, c)
				//fmt.Println(a, b, c, gcd)
				if a == b && b == c {
					sum += gcd
				} else if (a == b && b != c) || (a != b && b == c) {
					sum = sum + gcd*3
				} else {
					sum = sum + gcd*6
				}
				//fmt.Println(sum)
			}
		}
	}

	fmt.Println(sum)
}

func clacGcd(a int, b int, c int) int {
	var gcd int
	var tmp int
	for {
		if a%b != 0 {
			tmp = a % b
			a = b
			b = tmp
		} else {
			break
		}
	}
	for {
		if b%c != 0 {
			tmp = b % c
			b = c
			c = tmp
		} else {
			gcd = c
			break
		}
	}
	return gcd
}


Measured memory_bytes: 1776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F first
#define S second
#define ALL(a) begin(a),end(a)
const int N = 1<<19;
int n,k;
vector<pii> d[N];
void upd(int i,pii p)
{
    d[i].push_back(p);
    sort(ALL(d[i]),greater<pii>());
    d[i].erase(unique(ALL(d[i])),end(d[i]));
    if (d[i].size() > 2)
        d[i].pop_back();
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> k;
    n = 1<<k;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        auto p = pii(a,i);
        upd(i,p);
        if (i) {
            ans = max(ans, d[i][0].F + d[i][1].F);
            cout << ans << '\n';
        }
        for (int j = 1; j < n; j <<= 1)
            if ((i | j) != i)
                for (const auto & x : d[i])
                    upd(i | j, x);
    }
}


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

/*
����s�� t(s���t�ɂ�������)������������true��Ԃ��B
*/
bool is_palindrome(string s) {
	/*
	rbegin()�Arend()�͋t���ɂ����l��Ԃ��B
	��js = {10,2,5};
	t(s.rbegin(), s.rend());
	t = {5,2,10};
	*/
	string t(s.rbegin(), s.rend());
	return s == t;
}

int main() {
	string s;
	cin >> s;
	int n = s.size();
	/*
	if���ŁA���ׂĂ̕����񂪓��������A0�`(n-1)/2�܂ł����������A(n+1)/2�`�Ō�܂ł����������𒲂ׂĂ���B
	substr�́A������͈̔͂��w��ł���B
	��jsubstr(1,5);
	*/
	if (is_palindrome(s) && is_palindrome(s.substr(0, (n - 1) / 2)) && is_palindrome(s.substr((n + 1) / 2))) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}


Measured memory_bytes: 256
def solve():
  n=int(input())
  l=0
  r=n-1
  print(l,flush=True)
  lt=input()
  if lt=='Vacant':
    return
  print(r,flush=True)
  rt=input()
  if rt=='Vacant':
    return
  while 1:
    center=(l+r)//2
    print(center,flush=True)
    ct=input()
    if ct=='Vacant':
      return
    if (center-l)%2==0:
      if lt!=ct:
        r=center
        rt=ct
      else:
        l=center
        lt=ct
    else:
      if lt==ct:
        r=center
        rt=ct
      else:
        l=center
        lt=ct
solve()

Measured memory_bytes: 3660
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define int long long
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数定義や変数宣言







//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



int n,k;

cin>>n>>k;
vector<int > a(n+10,0); //その人がお菓子を持っている個数
int d;
REP(i,k){

	cin>>d;

	int who;

	FOR(j,1,d){cin>>who;a[who]+=1;}

}
int cnt=0;
FOR(i,1,n){

	if (a[i]==0)
{
	cnt++;
}
}

cout<<cnt<<endl;






return 0;

}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k)
		return 0;
	if (n < 0 || k < 0)
		return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool isprime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
void solve()
{
	int n;
	cin>>n;
	vector<int>prime;
	FOR(i,1,55555){
		if(isprime(i))prime.push_back(i);
	}
	int len=prime.size();
	int cnt=0;
	vector<int>ans;
	rep(i,len){
		if(prime[i]%5==1)ans.push_back(prime[i]);
	}
	rep(i,n){
		cout<<ans[i];
		if(i==n-1)cout<<endl;else cout<<" ";
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().strip().split()))
count = 0
for i in range(n):
    for j in range(n-1,i,-1):
        if a[j] < a[j-1]:
            a[j],a[j-1] = a[j-1],a[j]
            count += 1
print(' '.join(map(str,a)))
print(count)

Measured memory_bytes: 7644
import math
a,b,c = map(int, input().split())
d = math.radians(c)
print(0.5 * a * b * (math.sin(d)))
e = math.sqrt(a*a + b*b - 2*a*b*(math.cos(d)))
print(a+b+e)
print(b * (math.sin(d)))


Measured memory_bytes: 5716
import Data.List
main=do
 n<-readLn;a<-map read.words<$>getLine
 (putStr.concat)(g n a (f n (sort a)))
  where f n a = [a!!((quot n 2)-1),a!!(quot n 2)]::[Int]
        g 0 _ _ = []
        g n (h:a) [l,r] =(if h<r then[(show r)++"\n"]else[(show l)++"\n"])++(g(n-1)a[l,r])

Measured memory_bytes: 102140
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
const int N=2000,MOD=924844033;

int n,m;
int fac[N+3],inv[N+3],f[2*N+3][N+3];

int QPow(int A,int B){
    int res=1;
    while(B){
        if(B&1) res=int((ll)res*A%MOD);
        A=int((ll)A*A%MOD);
        B>>=1;
    }
    return res;
}
int EC(int A,int B){return int((ll)fac[B]*inv[A]%MOD*inv[B-A]%MOD);}
int main(){
    scanf("%d%d",&n,&m);
    fac[0]=1;for(int i=1;i<=n+1;i++) fac[i]=int((ll)fac[i-1]*i%MOD);
    inv[n+1]=QPow(fac[n+1],MOD-2);for(int i=n;i>=0;i--) inv[i]=int((ll)inv[i+1]*(i+1)%MOD);
    if(m==0){
        int ans=0;
        for(int i=0;i<=n;i++)
            if(i&1) ans=int((ans-(ll)fac[n]*inv[i]%MOD+MOD)%MOD);
            else ans=int((ans+(ll)fac[n]*inv[i]%MOD)%MOD);
        printf("%d\n",ans);
        return 0;
    }
    f[0][0]=1;
    for(int i=1;i<=n && i<=m;i++){
        int len=(n-i)/m;
        for(int k=0;k<=(len+1)/2;k++){
            int val=EC(k,len-k+1);
            for(int j=k;j<=n;j++)
                f[(i<<1)-1][j]=int((f[(i<<1)-1][j]+(ll)f[(i<<1)-2][j-k]*val%MOD)%MOD);
        }
        for(int k=0;k<=(len+1)/2;k++){
            int val=EC(k,len-k+1);
            for(int j=k;j<=n;j++)
                f[(i<<1)][j]=int((f[(i<<1)][j]+(ll)f[(i<<1)-1][j-k]*val%MOD)%MOD);
        }
    }
    int ans=0,ed=min(n,m)<<1;
    for(int i=0;i<=n;i++){
        // printf("%d -> %d\n",i,f[ed][i]);
        if(i&1) ans=int(ans-(ll)f[ed][i]*fac[n-i]%MOD+MOD)%MOD;
        else ans=int(ans+(ll)f[ed][i]*fac[n-i]%MOD)%MOD;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 31488
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a==5&&b==5&&c==7)||(a==7&&b==5&&c==5)||(a==5&&b==7&&c==5)){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 1644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;


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

    long n, count = 0; cin >> n;
    string s[n];
    for (long i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(s, s + n);
    for (long i = 0; i < n; i++) {
        if (s[i] != s[i + 1]) {
            count++;
        }
    }
    cout << count;
    return 0;
}

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

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

	pair<long long, long long> ab[n];
	for (int i = 0; i < n; ++i) {
		cin >> ab[i].first >> ab[i].second;
	}

	sort(ab, ab + n);
	
	long long dp[t] = { 0 };
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		ans = max(ans, dp[t - 1] + ab[i].second);
		for (int j = t - 1; j >= ab[i].first; --j) {
			dp[j] = max(dp[j], dp[j - ab[i].first] + ab[i].second);
		}
	}

	cout << ans;
	
	return 0;
}
	

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

using namespace std;

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

    for(int i = 0; i + 1 < S.size(); i++)
    {
        if(S[i] == S[i + 1])
        {
            cout << i + 1 << " " << i + 2;
            return 0;
        }

        if(i + 2 < S.size() && S[i] == S[i + 2])
        {
            cout << i + 1 << " " << i + 3;
            return 0;
        }
    }

    cout << "-1 -1";
    return 0;
}


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

int main()
{
ll a , b , c ;
cin >> a >> b >> c ;
if(b+c>a)cout << b+c-a << endl;
else cout << 0 << endl;


return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;


int main(){
   char ch[3] = {'r', 's', 'p'};
   int N, K, R, S, P;
   cin >> N >> K >> R >> S >> P;
   int poi[3] = {P, R, S};

   string T;
   cin >> T;

   int Get[N];

   int ans = 0;
   for(int i=0;i<N;i++){
      for(int j=0;j<3;j++){
        if(T[i]==ch[j]){
          Get[i] = poi[j];
          ans += Get[i]; 
        }
      }
   }
   //cout << ans <<endl; 
    
  bool flag[N];
  for(int i=0;i<N;i++) flag[i] = false;

  for(int i=0;i<N-K;i++){
    if(T[i]==T[i+K] && flag[i]==false){
      ans -= Get[i+K];
      flag[i+K] = true;
    }
  }

   cout << ans <<endl;
  

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  int N;
  cin >> N;
  
  int p[N];
  int m = 0;
  int l;
  for(int i = 0; i < N; i++){
    cin >> l;
    if (l != (i+1)){
      m++;
    }
    if(m > 2){
      break;
    }
  }
  if (m > 2 || m == 1){
   cout << "NO" << endl;
  } else {
   cout << "YES" << endl; 
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<queue>
#include<vector>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int count=s.size();
	while(count!=0)
	{
		string x,y;
		if(s.size()-count!=0)
		{
			x=s.substr(count,s.size()-count);
			y=s.substr(0,count);
			x+=y;
			if(x==t)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
			count--;
		}
		else 
		{
			if(s==t)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
			count--;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int t,n,a,b,s;
	while(cin >> t,t){
		cin >> n;
		s = 0;
		for(int i = 0;i < n;++i){
			cin >> a >> b;
			s += (b - a);
		}
		if(t <= s) cout << "OK" << endl;
		else cout << t - s << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while (a >= b) {
		b *= 2;
		k--;
	}
	while (b >= c) {
		c *= 2;
		k--;
	}
	if (k < 0) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}	
}


Measured memory_bytes: 3572
#include <vector>
#include <cstdio>
using namespace std;
typedef pair<int,int>pii;
main(){
	int n,x,i;
	for(;scanf("%d%d",&n,&x),n;printf("%d\n",x)){
		vector<pii>v;
		v.push_back(make_pair(x,1));
		for(i=1;i<n;i++){
			pii p=v.back();v.pop_back();
			scanf("%d",&x);
			if(x==p.first)v.push_back(make_pair(x,p.second+1));
			else if(i&1){
					pii q=make_pair(0,0);
					if(v.size())q=v.back(),v.pop_back();
					v.push_back(make_pair(x,q.second+p.second+1));
			}else{
				v.push_back(p),v.push_back(make_pair(x,1));
			}
		}
		for(x=i=0;i<v.size();i++){
			if(!v[i].first)x+=v[i].second;
		}
	}
}

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

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  int a[n]={};
  for (int i = 0; i < n-1; i++) {
    for (int j = 1; j<n;j++) {
      if (i<=x && j<=x || i>=y && j>=y) {
        a[j-i]++;
      }
      else if (i<=x&&j>x&&j<y) {
        int s = min(j-i, x-i+1+y-j);
        a[s]++;
      }
      else if (i<=x&&j>=y) {
        a[x-i+1+j-y]++;
      }
      else if (i>x&&i<y&&j>x&&j<y) {
        int s = min(j-i, i-x+1+y-j);
        a[s]++;
      }
      else {
        int s = min(j-i, i-x+1+j-y);
        a[s]++;
      }
    }
  }
  for (int i = 1; i<n; i++) {
    cout << a[i] <<endl;
  }
}

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

int main(void)
{
	int count= 1, from, to;
	int box[100001]= {}, check[100001]= {};
	int boxnum, action;

	check[0]= 1;
	cin>>boxnum>>action;

	for(int i= 0; i < action; i++)
	{
		cin>>from>>to;
		if(check[from-1] == 1)
		{
			if(box[from-1] == 0)
			{
				check[from-1]= 0;
				count--;
			}

			if(check[to-1] != 1)
				count++;

			check[to-1]= 1;
		}

		box[from-1]--;
		box[to-1]++;
	}

	cout<<count<<endl;
}

Measured memory_bytes: 1024
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <array>
#include <bitset>
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
#include <iomanip>//setfill/setw
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <list>
#include <queue>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <tuple>
#include <utility>//pair
#include <valarray>
#include <vector>

#define PRIME 1000000007

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<ull, int> puli;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pllll;
typedef pair<ull, ull> pulul;
typedef pair<double, double> pdd;
typedef tuple<int, int, int> ti3;
typedef tuple<int, int, int, int> ti4;

const bool debug = false;

int main(void) {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if (n > k)
	{
		cout << (x*k + (n-k)*y) << endl;
	} else {
		cout << (x*n) << endl;
	}
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 int n,a[100006],dp[100006];
 int cal( int x){ 
  if(x==n-1)return 0;
  //if(x>n)return ; 
  if(dp[x]!=-1)return dp[x];
  return dp[x]=min( cal(x+1)+abs(a[x]-a[x+1]) , cal(x+2)+abs(a[x]-a[x+2])  );
} 
int main()
{
  cin>>n;
  for(int i=0;i<n;i++){ 
      cin>>a[i];
  } 
  if(n==2){ 
      cout<<abs(a[1]-a[0]);
      return 0;
  }  
  memset(dp,-1,sizeof dp);
  cout<<cal(0)<<endl;  
 
    
    
 
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

class bipartite_matching {
public:
    int n;
    std::vector<std::vector<int>> g;
    std::vector<int> match;

    bipartite_matching(int n_) : n(n_), g(n_), match(n_), used(n_) {}

    void add_edge(int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int maximum_matching(void) {
        int res = 0;
        fill(begin(match), end(match), -1);
        for (int v = 0; v < n; ++v) {
            if (match[v] == -1) {
                fill(begin(used), end(used), false);
                if (dfs(v)) res++;
            }
        }
        return res;
    }

private:
    std::vector<int> used;
    bool dfs(int v) {
        used[v] = true;
        for (int u : g[v]) {
            int w = match[u];
            if (w == -1 || (!used[w] && dfs(w))) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }
};


int main () {
    int n;
    while (cin >> n) {
        vector<int> t(n + 1), x(n + 1), y(n + 1);
        rep(i, n) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
        bool ok = true;
        rep(i, n) {
            int dx = abs(x[i] - x[i + 1]);
            int dy = abs(y[i] - y[i + 1]);
            int d = dx + dy;
            int dt = t[i + 1] - t[i];
            if (d % 2 == dt % 2 && d <= dt);
            else ok = false;
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll lcm(ll a, ll b)
{
    return a / __gcd(a, b) * b;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> v;
    for (int i = 0; i < n; ++i)
    {
        ll x;
        cin >> x;
        v.push_back(x);
    }
    for (int i = 1; i < n; ++i)
        v[0] = lcm(v[0], v[i]);
    cout << v[0];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	long a,b;
  cin>>a>>b;
  cout<<a*b<<"\n";
}

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

R = [()] * N
B = [()] * N

for i in range(N):
    a, b = map(int, input().split())
    R[i] = (a,b)

for i in range(N):
    a, b = map(int, input().split())
    B[i] = (a, b)

B = sorted(B)

ans = 0
for a, b in B:
    d = -1
    mem = -1
    for i in range(len(R)):
        if R[i][0] < a and R[i][1] < b:
            if mem <= R[i][1]:
                d = i
                mem = R[i][1]
    if d != -1:
        R.pop(d)
        ans += 1


print(ans)





Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int a,b,c;cin>>a>>b>>c;
    cout<<c<<' '<<a<<' '<<b;
}

Measured memory_bytes: 256