akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Integer;

public class Main {

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

		String line = br.readLine();
		String[] strArray1 = line.split(" ");
		int[] array1 = new int[3];

		for (int i = 0; i < 3; i++) {
			array1[i] = Integer.parseInt(strArray1[i]);
		}

		line = br.readLine();
		int k = Integer.parseInt(line);

		int max = 0;
		int n = 0;
		int sum = 0;

		for (int i = 0; i < 3; i++) {
			if (max < array1[i]) {
				max = array1[i];
				n = i;
			}
		}

		for (int i = 0; i < 3; i++) {
			if (i != n) {
				sum += array1[i];
			}
		}

		for (int i = 0; i < k; i++) {
			max *= 2;
		}

		System.out.println(max+sum);
	}
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

ll n, m, q;
int main(){
  cin >>n;
  m=(-n+1)%1000+999;
  cout << m <<endl;
}

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

// // #define n = 0

// void dp(int n){
//     vector<vector<long long> > note( vector<long long>(n, 0));
// }

// int main(){
//     int n, m, k;
//     cin >> n >> m >> k;
//     vector<long long> a(n+1, 1e9+1), b(m+1, 1e9+1);
//     for(int i=0; i<n; i++){
//         cin >> a[i];
//     }
//     for(int i=0; i<m; i++){
//         cin >> b[i];
//     }
//     int ans = 0;
//     int i=0, j=0;
//     while(k>0){
//         if((k-a[i] < 0 && k-b[j]<0) || (i==n && j==m)){
//             break;
//         }
//         // else if(i<n || j<m){
//         while(a[i]<b[j] && i<n && (k-a[i] >= 0 || k-b[j] >= 0)){
//             k -= a[i];
//             i++;
//             ans++;
//         }
//         while(a[i]>=b[j] && j<m && (k-a[i] >= 0 || k-b[j] >= 0)){
//             k -= b[j];
//             j++;
//             ans++;
//         }
//         // }
//         // ans++;
//     }
//     cout << ans << endl;
//     return 0;

// }


int main(){
    int n,m,k;
    cin >> n >> m >> k;
    long long a[n];
    long long b[m];
    long long sum=0;
    int aindex = -2;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if (aindex == -2 && sum + a[i]<=k){
            sum+= a[i];
        }else if(aindex == -2){
            aindex = i-1;
        }
    }
    if(aindex==-2){
        aindex = n-1;
    }

    int bindex = -2;
    for(int i=0;i<m;i++){
        cin >> b[i];
        if (bindex == -2 && sum + b[i]<=k){
            sum+= b[i];
        }else if(bindex == -2){
            bindex = i-1;
        }
    }
    if(bindex==-2){
        bindex = m-1;
    }

    int ans = aindex + bindex + 2;
    int now = aindex + bindex + 2;

    bindex++;

    for (int i=aindex; i>=0; i--){
        sum -= a[i];
        now -= 1;
        while(sum + b[bindex] <= k){
            sum += b[bindex];
            bindex++;
            now++;
            if(bindex==m){
                break;
            }
        }
        ans = max(ans, now);
        if(bindex==m){
            break;
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 6724
#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(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n,m;
    cin >>n >>m;
    vector<int> ct(n);
    rep(i,m)
    {
        int a,b;
        cin >>a >>b;
        ++ct[a-1];
        ++ct[b-1];
    }
    rep(i,n) printf("%d\n", ct[i]);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
public static void main(String[]args){
	Scanner sc = new Scanner(System.in);
	String s=sc.next(); 
	char[] a=s.toCharArray();
	for(int i=a.length-1; i>=0; i-- )
	System.out.print(a[i]);
	System.out.println();
}
}

Measured memory_bytes: 17128
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
//型定義などミスると、死ぬほどエラー出ることがわかった
bool compare_dp(const pair<int,int> x,const pair<int,int> y){
  return x.first > y.first;
}

int count_attacking(int N,int M){
  int D,P;
  vector<pair<int,int>> dp;
  
  for(int i=0;i<N;i++){
    cin >> D >> P;
    dp.push_back(make_pair(P,D));
  }
  sort(dp.begin(),dp.end(),compare_dp);
  vector<pair<int,int>>::iterator i;
  for(i=dp.begin();i<dp.end();i++){
    if(M-(*i).second>=0){
      M-=(*i).second;
    }else{
      (*i).second-=M;
      break;
    }
  }
  int C=0;
  for(;i<dp.end();i++){
    C+=((*i).first)*((*i).second);
  }
  return C;
}

int main(){
  int n,m;
  vector<int> c;
  while(cin >> n >> m && n!=0){
    c.push_back(count_attacking(n,m));
  }
  for(auto i=c.begin();i<c.end();i++){
    cout << *i << endl;
  }
}



Measured memory_bytes: 3288
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;

using ll=long long;
using R=double;

// Combination Table
ll C[51][51]; // C[n][k] -> nCk

void comb_table(int N){
for(int i=0;i<=N;++i){
for(int j=0;j<=i;++j){
if(j==0 or j==i){
C[i][j]=1LL;
}else{
C[i][j]=(C[i-1][j-1]+C[i-1][j]);
}
}
}
}

int main(void){
int N,A,B;
cin >> N >> A >> B;


const int NMAX=50;
ll v[NMAX];

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

comb_table(N);
sort(v,v+N);
reverse(v,v+N);

R max_average=0.0;
for(int i=0;i<A;++i){
max_average+=v[i];
}
max_average/=A;

int a_th_val_num=0,a_th_val_pos=0;
for(int i=0;i<N;++i){
if(v[i]==v[A-1]){
a_th_val_num++;
if(i<A){
a_th_val_pos++;
}
}
}

ll cnt=0LL;
if(a_th_val_pos==A){
for(a_th_val_pos=A;a_th_val_pos<=B;++a_th_val_pos){
cnt+=C[a_th_val_num][a_th_val_pos];
}
}else{
cnt+=C[a_th_val_num][a_th_val_pos];
}

cout.precision(20);
cout << fixed << max_average << endl;
cout << cnt << endl;

return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    VI a(n+1);
    LL sum=0;
    REP(i,n+1) {
        cin >> a[i];
        sum+=a[i];
    }
    LL p=1, ans=0;
    for ( int i=0; i<=n; i++ ) {
        ans+=p;
        if ( p<a[i] ) {
            cout << -1 << '\n';
            return 0;
        }
        p-=a[i];
        sum-=a[i];
        p<<=1;
        chmin(p,sum);
    }
    cout << ans << '\n';
    return 0;
}




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

int main(void){
 int N,A[2][105],get,maxget,i,j;
 char str[1000],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  for(i=0;i<2;i++){
    fgets(str,sizeof(str),stdin);
    p=strtok(str," \n");
    A[i][0]=atoi(p);
    for(j=1;j<N;j++){
      p=strtok(NULL," \n");
      A[i][j]=atoi(p);
    }
  }
  
  for(i=0,maxget=0;i<N;i++){
   for(j=0,get=0;j<=i;j++){
     get+=A[0][j];
   }
   for(j=i;j<N;j++){
     get+=A[1][j]; 
   }
   if(get>maxget){
    maxget=get; 
   }
    
  }
    
  printf("%d\n",maxget);
  
  return 0;
}

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

int heap[2000001];
int last_idx;


void maxHeapify(int node_idx){
    
    int tmp;
    int largest = node_idx;
    int left_child_idx = 2 * node_idx;
    int right_child_idx = 2 * node_idx + 1;
    
    
    if ( left_child_idx <= last_idx && heap[left_child_idx] > heap[node_idx]) {
        largest = left_child_idx;
    }else{
        largest = node_idx;
    }
    if ( right_child_idx <= last_idx && heap[right_child_idx] > heap[largest]) {
        largest = right_child_idx;
    }
    
    if (largest != node_idx) {
        tmp = heap[largest];
        heap[largest] = heap[node_idx];
        heap[node_idx] = tmp;
        
        maxHeapify(largest);
    }
}


void hIncreaseKey(int inserted_num ){
    int i = last_idx;
    int tmp;
    
    while( i > 1 && heap[i/2] < heap[i]){
        tmp = heap[i];
        heap[i] = heap[i/2];
        heap[i/2] = tmp;
        i = i/2;
    }
    
}

void insert(int inserted_num){
    last_idx++;
    heap[last_idx] = inserted_num;
    hIncreaseKey(inserted_num);
}

void extract(){
    printf("%d\n", heap[1]);
    heap[1] = heap[last_idx--];
    maxHeapify(1);
}


int main( ){
    
    int operand;
    char operator[20];
    
    while (1) {
        scanf("%s", operator);
        
        if (strcmp(operator, "insert") == 0) {
            scanf("%d", &operand);
            insert(operand);
        }
        else if(strcmp(operator, "extract") == 0){
            extract();
        }
        else{
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 4696
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int i=3,c[i];
  while(i){
    cin >> c[i-1];
    --i;
  }
  sort(c,c+3);
  cout << c[0]+c[1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ld = long double;
const ld eps = 1e-9;

int N;

bool check(const vector<pair<ld, ld>>&cs, const ld amid) {
	map<ld, int>mp;
	for (auto c : cs) {
		const ld r = c.second;
		const ld x = c.first;
		if (r > amid) {
			ld dis = sqrt(r*r - amid*amid);
			mp[x - dis]++;
			mp[x + dis]--;
		}
	}
	ld pre = -1;
	int num = 0;
	ld len = 0;
	bool preok = false;
	for (auto m : mp) {
		num += m.second;
		if (num) {
			if (!preok) {
				pre = m.first;
			}
		}
		else {
			if (preok) {
				len = max(len, m.first - pre);
			}
		}
		preok = num;
	}
	return amid*2 < len;
}
int main() { 
	while (1) {
		cin >> N;
		if (!N)break;
		vector<pair<ld, ld>>cs;
		for (int i = 0; i < N; ++i) {
			int x, r; cin >> x >> r;
			cs.push_back(make_pair(x, r));
		}
		ld amin = 0;
		ld amax = 1e6;
		int atime = 40;
		while (atime--) {
			ld amid = (amin + amax) / 2;
			if (check(cs, amid)) {
				amin = amid;
			}
			else {
				amax = amid;
			}
		}
		cout << setprecision(22) << fixed << amin*2 << endl;
	}
	
	return 0;
}

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

void solve(int n) {
  int ans = 0;
  int high = 0;
  int c = n;
  while(c < 600) {
    high = c * c;
    ans += high * n;
    c += n;
  }
  cout << ans << endl;
}

int main(void) {

  int n;
  while(cin >> n) {
    solve(n);
  }
  return 0;
}

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

int main(){
  int n,ans=0,b,c;
  cin>>n>>b;
  c=b;
  ans+=b;
  
  REP(i,n-2){
    cin>>c;
    ans+=min(b,c);
    b=c;
  }
  ans+=c;
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())    # 参加者
D, X = map(int, input().split())    # day, 余ったチョコの個数
sum_c = 0           # 参加者が食べたチョコの合計
for i in range(N):
    tmp = int(input())
    sum_c += int(D / tmp)
    if D%tmp != 0:
        sum_c += 1

print(sum_c + X)


Measured memory_bytes: 2940
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    N, W = map(int, input().split())
    B = [list(map(int, input().split())) for _ in range(N)]
    dp = [[0] * (W + 1) for _ in range(N + 1)]
    for i in range(N):
        w = B[i][0]
        v = B[i][1]
        for j in range(W + 1):
            if j >= w:
                dp[i + 1][j] = max(dp[i][j - w] + v, dp[i][j])
            else:
                dp[i + 1][j] = dp[i][j]
    print(dp[-1][-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 118128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 
int n,m;
vector<bool> v(10e6,true);
vl dp(10e6);

signed main(){
	cin>>n>>m;
	rep(i,0,m){
		int a; cin>>a;
		v[a]=false;
	}
	dp[0]=1;
	rep(i,1,n+10){
		ll cnt=0;
		if(v[i-1]) cnt+=dp[i-1];
		if(i>1){
			if(v[i-2]) cnt+=dp[i-2];
		}
		dp[i]=cnt%MOD;
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 79616
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a = a[::-1]
b = b[::-1]
count = 0

for i in range(n):
  if a[i] >= b[i]:
    count += b[i]
  else:
    count += a[i]
    b[i] -= a[i]
    if a[i+1] >= b[i]:
      count += b[i]
      a[i+1] -= b[i]
    else:
      count += a[i+1]
      a[i+1] = 0
      
print(count)

Measured memory_bytes: 82788
#include <iostream>

int main()
{
    int w, a, b;
    std::cin >> w >> a >> b;

    int d;
    if (a + w < b)
    {
        // 一つ目を基準として2つ目は右にある
        d = b - (a + w);
    }
    else if (a > b + w)
    {
        // 一つ目を基準として2つ目は左にある
        d = a - (b + w);
    }
    else
    {
        // 連結
        d = 0;
    }
    std::cout << d << std::endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int N, Q, L, R;
int ans = 0;
string S;
void solve() {
    cin >> N >> Q;
    cin >> S;
    vector<int> t(N);
    for (int i = 0; i < N; i++) {
        string tmp;
        tmp = S.substr(i, 2);
        if (tmp == "AC") {
            t[i + 1] = t[i] + 1;
        } else {
            t[i + 1] = t[i];
        }
    }
    for (int i = 0; i < Q; i++) {
        cin >> L >> R;
        cout << t[R - 1] - t[L - 1] << endl;
    }
    return;
}
//逆元を求める関数
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;
}
int main(int args, char* argv[]) {
    solve();
}

Measured memory_bytes: 1408
import java.io.*;
import java.util.*;
public class Main {
	static List<Integer> adj[];
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
	
		int[][] dp = new int[n+1][2];
		//int n = Integer.parseInt(str.nextToken());
		// 0 is black 1 is white
		adj = new ArrayList[n+1];
		for(int i =1; i <= n; i++) adj[i] = new ArrayList();
		for(int i =0 ; i <n-1; i++)
		{
			StringTokenizer str = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(str.nextToken());
			int b = Integer.parseInt(str.nextToken());
			adj[a].add(b);
			adj[b].add(a);
			
			
		}
		pair ans = dfs(1,-1);
		System.out.println((ans.getFirst()+ans.getSecond())%1000000007);
		
		
		
	}
	
	static pair dfs(int a, int parent)
	{
		long all_white = 1;
		long smthg_black = 0;
		for(int b: adj[a])
		{
			if(b != parent)
			{
				pair p = dfs(b, a);
				long memo = all_white;
				all_white = mul(all_white, p.getSecond());
				smthg_black =( mul(memo, p.getFirst()) + mul(smthg_black,p.getFirst() + p.getSecond()))%1000000007;
			}
		}
		return new pair(all_white, (all_white + smthg_black)%1000000007);
	}
	static long mul(long a, long l)
	{
		return (a*l)%1000000007;
	}

}
class pair
{
	long a, b;
	public pair(long a, long b)
	{
		this.a = a;
		this.b = b;
	}
	public long getFirst()
	{
		return this.a;
	}
	public long getSecond()
	{
		return this.b;
	}
}


Measured memory_bytes: 73156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define inf 10000000000000000


int main()
{    
 

	#ifdef APNA_IO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
		    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

ll n;
cin>>n;
ll a[100001];
for(ll i=0;i<=100000;i++)
{
	a[i]=1234567890;
}
a[0]=0;
ll w,m;
cin>>w; 
pll b[n+1];
for(ll i=1;i<=n;i++)
{
	cin>>b[i].ff>>b[i].ss;
}

for(ll i=1;i<=n;i++)
{	
	for(ll j=100000;j>=0;j--)
	{		

		if(a[j]!=1234567890)
		{	
			if(b[i].ss+j<100001)
			{
				m = min(b[i].ff+a[j],a[j+b[i].ss]);
				a[j+b[i].ss] = m;
			}
		}
	}
}

	ll d=0;
	for(ll i=1;i<=100000;i++)
	{
		if(a[i]<=w)
		{
			d=i;
		}

	}
	cout<<d<<endl;

}





Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using o_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define M 1000010

int main(){
	IOS;
	ll r,d,x;cin>>r>>d>>x;
	rep(i,0,10){
		x=r*x-d;
		cout<<x<<"\n";
	}
	return 0;
}



Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
X=int(input())

count=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50==X:
                count+=1
                
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    double r;
    cin >> r;
    double ans = r * 2 * M_PI;
    printf("%.16f\n", ans);
}

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

int main() {
    int n, k; cin >> n >> k;
    double sum = 0;
    rep(i, n) {
        int l = i + 1;
        double p = 1;
        while(l < k) {
            l *= 2;
            p *= 0.5;
        }
        sum += 1.0 / n * p;
    }
    printf("%.10lf\n", sum);
    return 0;
}


Measured memory_bytes: 256
// ABC143B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int>d(N);
	for (int i = 0; i < N; i++)
	{
		cin >> d.at(i);
	}
	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		for (int j = i+1; j < N; j++)
		{
			ans += d.at(i) * d.at(j);
		}
	}
	cout << ans<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000;
bool detect_negative_cycles_2(vector<vector<pair<int, int>>> &E){
	int V = E.size();
	vector<long long> d(V, 0);
	for (int i = 0; i < V; i++){
		bool update = false;
		for (int j = 0; j < V; j++){
			for (int k = 0; k < E[j].size(); k++){
				int c = E[j][k].first;
				int v = E[j][k].second;
				if (d[v] > d[j] + c && d[j] != INF){
					d[v] = d[j] + c;
					update = true;
					if (i == V - 1){
						return true;
					}
				}
			}
		}
		if (!update){
			break;
		}
	}
	return false;
}
vector<vector<long long>> warshall_floyd(vector<vector<pair<int, int>>> &E){
  int V = E.size();
  vector<vector<long long>> d(V, vector<long long>(V, INF));
  for (int i = 0; i < V; i++){
    d[i][i] = 0;
  }
  for (int i = 0; i < V; i++){
    for (int j = 0; j < E[i].size(); j++){
      d[i][E[i][j].second] = E[i][j].first;
    }
  }
  for (int k = 0; k < V; k++){
    for (int i = 0; i < V; i++){
      for (int j = 0; j < V; j++){
        if (d[i][k] != INF && d[k][j] != INF){
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
      }
    }
  }
  return d;
}
int main(){
  int V, E;
  cin >> V >> E;
  vector<vector<pair<int, int>>> e(V);
  for (int i = 0; i < E; i++){
    int s, t, d;
    cin >> s >> t >> d;
    e[s].push_back(make_pair(d, t));
  }
  if (detect_negative_cycles_2(e)){
    cout << "NEGATIVE CYCLE" << endl;
  } else {
    vector<vector<long long>> d = warshall_floyd(e);
    for (int i = 0; i < V; i++){
      for (int j = 0; j < V; j++){
        if (d[i][j] == INF){
          cout << "INF";
        } else {
          cout << d[i][j];
        }
        if (j < V - 1){
          cout << ' ';
        }
      }
      cout << endl;
    }
  }
}


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

using namespace std;

const int maxn = 3010;
double p[maxn], dp[maxn][maxn];
int n;

int main()
{
    ios::sync_with_stdio(false);
    cout << setprecision(9) << fixed;
    cin >> n;

    for (int i = 1; i <= n; i++)
        cin >> p[i];
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 0; j <= i; j++)
        {
            dp[i][j] = dp[i - 1][j] * (1 - p[i]);
            if (j)
                dp[i][j] += dp[i - 1][j - 1] * p[i];
        }

    double ans = 0;
    for (int i = n - n / 2; i <= n; i++)
        ans += dp[n][i];
    cout << ans;

    return 0;
}


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<s64, int>;

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

    s64 h, w, k;
    cin >> h >> w >> k;

    int si, sj, ti, tj;
    cin >> si >> sj >> ti >> tj;
    --si, --sj, --ti, --tj;
    vector< string > field(h);
    rep (i, h) cin >> field[i];

    const s64 inf = 1e18;
    vector< vector< bool > > reached(h, vector< bool >(w, false));
    vs64 d(h * w, inf);
    auto id = [&](int i, int j) { return i * w + j; };

    queue<int> q;
    q.push(id(si, sj));
    d[id(si, sj)] = 0;
    reached[si][sj] = true;
    int dy[] = {-1, 0, 1, 0};
    int dx[] = {0, -1, 0, 1};
    while (!q.empty())
    {
        int from = q.front(); q.pop();
        int fi = from / w;
        int fj = from % w;
        rep (i, 4)
        {
            rep (j, k)
            {
                s64 ni = fi + dy[i] * (j + 1);
                s64 nj = fj + dx[i] * (j + 1);
                if (!(IN(0, h, ni) && IN(0, w, nj))) break;
                int to = id(ni, nj);
                if (d[to] < d[from] + 1 || field[ni][nj] == '@') break;
                if (d[to] != inf) continue;
                reached[ni][nj] = true;
                d[to] = d[from] + 1;
                q.push(to);
            }
        }
    }

    s64 ans = d[id(ti, tj)];
    if (!reached[ti][tj]) cout << "-1\n";
    else cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 12868
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let s: String = scan(tokens);
    let s = s.as_bytes();
    if s[0] == s[1] || s[1] == s[2] || s[2] == s[3] {
        println!("Bad");
    } else {
        println!("Good");
    }
}


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

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

    int ans = x + y / 2;

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


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

int main() {
  string s;
  cin >> s;
  
  vector<char> alphabet(26);
  alphabet = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
  
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < alphabet.size(); j++) {
      if (s.at(i) == alphabet.at(j)) {
        alphabet.at(j) = '0';
        break;
      }
    }
  }
  
  bool a = true;
  
  for (int k = 0; k < alphabet.size(); k++) {
    if (alphabet.at(k) != '0') {
      cout << alphabet.at(k) << endl;
      a = false;
      break;
    }
  }
  
  if (a == true) {
    cout << "None" << endl;
  }
  
}

Measured memory_bytes: 512
import java.util.*

fun main(args : Array<String>) {
    var (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val A = readLine()!!.split(" ").map { it.toLong() }.toLongArray()
    val maxHeap = PriorityQueue<Long>()

    A.forEach {
        maxHeap.add(it * -1)
    }


    while (M > 0) {
        val max = maxHeap.poll() * -1
        maxHeap.add( max / 2 * -1)
        M--
    }

    var sum =0L
    while (!maxHeap.isEmpty()) {
        sum += maxHeap.poll() * -1
    }

    println(sum)
}

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="77675555555555555555555555555555555555555455555555555555555555555555555555555555555555555555555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);

		//W???????????????
		int W = sc.nextInt();
		//H???????????????
		int H = sc.nextInt();
		//x???????????????
		int x = sc.nextInt();
		//y???????????????
		int y = sc.nextInt();
		//r???????????????
		int r = sc.nextInt();

		//??????????????¢????????¨?????????????????????
		if((x + r) <= W && (y + r) <= H && 0 <= (x - r) &&  0 <= (y -  r)){
				System.out.println("Yes");
			}
			else{
				System.out.println("No");
			}

	}
}

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

#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int mod     = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(16); cerr << fixed << setprecision(16); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int Q = input();

  priority_queue< int64 > lhs;
  priority_queue< int64, vector< int64 >, greater< int64 > > rhs;
  int64 lhs_sum = 0, rhs_sum = 0, b_sum = 0;

  range(i, 0, Q) {
    int com;
    cin >> com;

    if (com == 1) {
      int64 a = input(), b = input();
      b_sum += b;

      lhs.push(a);
      lhs_sum += a;

      if (lhs.size() == rhs.size() + 2) {
        lhs_sum -= lhs.top();
        rhs_sum += lhs.top();

        rhs.push(lhs.top());
        lhs.pop();
      }

      if (!rhs.empty() && lhs.top() > rhs.top()) {
        lhs_sum += rhs.top() - lhs.top();
        rhs_sum += lhs.top() - rhs.top();

        lhs.push(rhs.top()); rhs.pop();
        rhs.push(lhs.top()); lhs.pop();
      }
    }
    else {
      cout << lhs.top() << " " << (int64)lhs.size() * lhs.top() - lhs_sum + rhs_sum - (int64)rhs.size() * lhs.top() + b_sum << endl;
    }

  }
}

signed main(int argc, char *argv[]) {
  solver();
}



Measured memory_bytes: 3828
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define PII pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define PB push_back
#define db long double
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int mod=1e6+3;
int Pow(int x,int y) {
	int res=1;
	while(y) {
		if(y&1) res=res*(ll)x%mod;
		x=x*(ll)x%mod,y>>=1;
	}
	return res;
}
int fac[(mod+3)*2];
int main() {
	fac[0]=1;
	for(int i=1;i<=mod*2;++i) fac[i]=fac[i-1]*(ll)i%mod;
	int q,x,d,n; rd(q);
	while(q--) {
		rd(x),rd(d),rd(n);
		if(d==0) printf("%d\n",Pow(x,n));
		else if(x==0||n>mod) printf("0\n");
		else {
			int tmp=x*(ll)Pow(d,mod-2)%mod;
			int ans=fac[tmp+n-1]*(ll)Pow(fac[tmp-1],mod-2)%mod*Pow(d,n)%mod;
			printf("%d\n",ans);
		}
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	long long g = gcd(a, b);
	return a / g * b;
}

int main() {
	int w, a, b; cin >> w >> a >> b;
	bool okay = false;
	if (abs(a - b) <= w)okay = true;

	if (okay == true) {
		cout << '0' << endl;
	}
	else {
		cout << abs(a - b) - w << endl;
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define LL long long
using namespace std;
const int M=1e6+7;
int read(){
	int ans=0,f=1,c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar();}
	return ans*f; 
}
int n,k,num[M],ans,mx;
bool f;
int gcd(int x,int y){
	while(y){
		int p=x%y;
		x=y;
		y=p;
	}
	return x;
}
int main()
{
	n=read(); k=read();
	for(int i=1;i<=n;i++){
		num[i]=read();
		mx=max(mx,num[i]);
		if(num[i]==k) f=1;
	}
	if(f){printf("POSSIBLE\n"); return 0;}
	if(mx<k){printf("IMPOSSIBLE\n"); return 0;}
	ans=gcd(num[1],num[2]);
	for(int i=3;i<=n;i++) ans=gcd(ans,num[i]);
	if(k%ans==0) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 512
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

ans=1
zero=False
for a in A:
    if a==0:
        zero=True
        break

if zero:
    print(0)
else:
    over=False
    for a in A:
        ans*=a
        if ans>1e18:
            print(-1)
            over=True
            break
    if not over:
        print(ans)

Measured memory_bytes: 20040
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 1e6+1;
 
typedef int ll;
typedef long double ld;  

void test_case()
{
    ll n,i,j;
    cin >> n;
    vector<ll> v(n);
    ll vis[N] = {0};
    f(i,0,n)
    {
        cin >> v[i];
        vis[v[i]]++;
    }
    sort(all(v));
    if(vis[1])
    {
        if(vis[1] > 1)
            cout << 0 << '\n';
        else
            cout << 1 << '\n';
        return ;
    }
    bool done[N] = {0};
    f(i,0,n)
    {
        if(vis[v[i]] > 1)
            done[v[i]] = 1;
        ll curr = 2*v[i];
        while(curr <= v[n-1])
        {
            done[curr] = 1;
            curr += v[i];
        }
    }
    ll ans = 0;
    f(i,0,n)
    {
        if(!done[v[i]])
            ans++;
    }
    cout << ans << '\n';

}
 
int32_t main()
{
    IOS(); 
    
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 8932
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int c[10][10];
int a[201][201];

int cost[10], minCost[10];
bool done[10];

bool canUpdate() {
	REP(i, 10) {
		if (done[i] != true) return true;
	}
	return false;
}

int main() {
	int H, W;
	cin >> H >> W;
	REP(i, 10) REP(j, 10) cin >> c[i][j];
	REP(i, H) REP(j, W) cin >> a[i][j];

	// ダイクストラ法
	REP(num, 10) {
		// 初期化
		REP(i, 10) {
			cost[i] = mod;
			done[i] = false;
		}
		cost[num] = 0;

		while (canUpdate()) {
			int min_ix, min_num = mod;

			// 未探索の中でコスト最小のノードを探索
			REP(i, 10) {
				if (cost[i] < min_num && done[i] == false) {
					min_num = cost[i];
					min_ix = i;
				}
			}

			// コストが小さくなれば更新
			REP(i, 10) {
				if (done[i] != true) {
					int cost_dash = cost[min_ix] + c[min_ix][i];
					if (cost[i] > cost_dash) cost[i] = cost_dash;
				}
			}
			done[min_ix] = true;
		}
		minCost[num] = cost[1];
		//cout << cost[1] << endl;
	}

	ll ans = 0;
	REP(i, H) {
		REP(j, W) {
			int wallNum = a[i][j];
			if(wallNum!=-1){
				ans += minCost[wallNum];
			}
		}
	}
	cout << ans;
	system("pause");
	return 0;
}

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

int main(){
    bool flg = true;
    string str;
    cin >> str;
    if(
        str.length() == 6 &&
        str[2] == str[3] &&
        str[4] == str[5]
    )
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	String S;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		S = next();
		String[] s = {"SUN","MON","TUE","WED","THU","FRI","SAT"};

		for(int i=0;i<s.length;i++) {
			if(S.equals(s[i])) {
				out.println(7-i);
				break;
			}
		}
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

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

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n),b(n),c(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    ll sa = 0;
    ll sb = 0;
    rep(i,n){
        sa += a[i];
        sb += b[i];
        c[i] = a[i]-b[i];
    }
    if(sb>sa){
        cout << -1 << endl;
        return 0;
    }
    sort(c.begin(),c.end());
    int x = 0;
    int y = n-1;
    if(c[0]>=0){
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    while(c[x]<0){
        if(c[y]>=-c[x]){
            c[y] += c[x];
            c[x] = 0;
            x++;
            ans++;
        }else{
            c[x] += c[y];
            c[y] = 0;
            y--;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}


template<int SZ>
class HLDecomp {
private:
  int n;
  void dfs(const int root){
    stack<pair<int,bool> > st;
    par[root] = -1;
    dep[root] = 0;
    st.push({root,false});
    while(!st.empty()){
      int v = st.top().first;
      bool &b = st.top().second;
      if(!b){
        // initial visit of v
        b = true;
        for(int u : tree[v]) if(u != par[v]){
          par[u] = v;
          dep[u] = dep[v] + 1;
          // st.push({u, false});
          st.push(mp(u, false));
        }
      }
      else {
        // second visit
        st.pop();
        int cur_max = 0;
        for(int u : tree[v]) if(u != par[v]){
          sub_sz[v] += sub_sz[u];
          if(sub_sz[u] > cur_max){
            cur_max = sub_sz[u];
            heavy_child[v] = u;
          }
        }
      }
    }
  }
  void bfs(const int root){
    int cnt = 0;
    queue<int> q;
    q.push(root);
    while(!q.empty()){
      int h = q.front(); q.pop();
      for(int i=h; i!=-1; i = heavy_child[i]){
        vid[i] = cnt++;
        vid2idx[vid[i]] = i;
        chain_head[i] = h;
        for(int to : tree[i]) if(to!=par[i] && to!=heavy_child[i]) q.push(to);
      }
    }
  }
public:
  vector<int> tree[SZ];
  int par[SZ], dep[SZ], sub_sz[SZ], heavy_child[SZ], vid[SZ], vid2idx[SZ], chain_head[SZ];
  HLDecomp(const int _n) : n(_n) {
    assert(n<=SZ);
    fill(sub_sz, sub_sz+n, 1);
    fill(heavy_child, heavy_child+n, -1);
  }
  void add_edge(const int u, const int v){
    tree[u].push_back(v);
    tree[v].push_back(u);
  }
  void build(const int root = 0){
    dfs(root);
    bfs(root);
  }

  int lca(int u, int v) const {
    while(1){
      if(vid[u] > vid[v]) swap(u,v);
      if(chain_head[u] == chain_head[v]) return u;
      v = par[chain_head[v]];
    }
  }
  int distance(const int u, const int v) const {
    return dep[u] + dep[v] - 2*dep[lca(u,v)];
  }
};


int main(){
  int n;
  cin>>n;
  HLDecomp<100000> hl(n);
  rep(i,n){
    int k;
    cin>>k;
    rep(j,k){
      int d;
      cin>>d;
      hl.add_edge(i,d);
    }
  }
  hl.build();

  int q;
  cin>>q;
  rep(i,q){
    int a,b;
    cin>>a>>b;
    cout << hl.lca(a,b) << "\n";
  }

  return 0;
}



Measured memory_bytes: 11692
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn = 100000 + 10;
 
inline int rd() {
  int x = 0; char ch = getchar();
  while(ch < '0' || ch > '9') ch = getchar();
  do{
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }while(ch >= '0' && ch <= '9');
  return x;
}
 
int n, m, cnt, h[maxn], sum = 0, flag, kx[maxn], val[maxn];
 
struct enode{
  int v, n;
  enode() {}
  enode(int _v, int _n):v(_v), n(_n) {}
}e[maxn << 1];
 
inline void addedge(int u, int v) { cnt ++; e[cnt] = enode(v,h[u]); h[u] = cnt; }
 
int dep[maxn], vis[maxn], Sx, Tx, st[maxn];
void dfs(int u, int fa) {
  dep[u] = dep[fa] ^ 1;
  vis[u] = 1;
  for(int i = h[u];~ i;i = e[i].n) {
    int v = e[i].v;
    if(v == fa) continue;
    if(vis[v]) Sx = u, Tx = v, flag = (dep[u] == dep[v]);
    else dfs(v,u);
  }
}
 
void solve(int u, int fa) {
  for(int i = h[u];~ i;i = e[i].n) {
    int v = e[i].v;
    if(v == fa) continue;
    if((u == Sx && v == Tx) || (u == Tx && v == Sx)) continue;
    solve(v,u);
    val[u] += val[v];
    kx[u] += kx[v];
    }
}
 
int main() {
  n = rd(); m = rd();
  cnt = 0;
  memset(h,-1,sizeof(h));
  for(int i = 1;i <= m;i ++) {
    int u, v;
    u = rd(); v = rd();
    addedge(u,v);
    addedge(v,u);
  }
  flag = 0;
  dep[0] = 0;
  dfs(1,0);
  int ans = 0;
  for(int i = 1;i <= n;i ++) {
    if(dep[i]) val[i] = 1;
    else val[i] = -1;
    sum += val[i];
  }
  if(m == n - 1) {
    if(sum) {
      puts("-1");
      return 0;
      }
  }
  else {
    if(flag) {
      if(sum & 1) {
        puts("-1");
        return 0;
        }
        val[Sx] -= sum / 2;
        val[Tx] -= sum / 2;
        ans += abs(sum) / 2;
      }
      else {
        if(sum) {
          puts("-1");
          return 0;
        }
        kx[Sx] = 1;
        kx[Tx] = -1;
    }
  }
  solve(1,0);
  int top;
  st[top = 1] = 0;
  for(int i = 1;i <= n;i ++) {
    if(!kx[i]) ans += abs(val[i]);
    else st[++ top] = - val[i];
    }
    sort(st + 1,st + top + 1);
    int k = st[(top + 1) >> 1];
    for(int i = 1;i <= top;i ++) {
      ans += abs(st[i] - k);
    }
    printf("%d\n", ans);
  return 0;
}

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

int main(){
    long N,D,cnt=0;
    double long len;
    cin >> N >> D;
    vector<long>X(N),Y(N);
    for(int i=0;i<N;i++){
        cin >> X[i] >> Y[i];
    }
    for(int i=0;i<N;i++){
        len = sqrt((X[i])*(X[i]) + Y[i]*Y[i]);
        if(len <= D){
            cnt++;
        }
    }
    cout << cnt;

}

Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N , x; cin >> N >> x;
  int count = 0;
  vector<int> vec(N);
  for(int i = 0; i < N;i++){
    cin >> vec[i];
  }
sort(vec.begin(),vec.end());
for(int j = 0; j < N; j++){
  if(vec[j] <= x && j != N - 1){
    count++;
    x  = x - vec[j];
  }
}
  if (x == vec[N-1]){
    count++;
  }
cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int k, t;
vector<int> a;

int main() {
    ios_base::sync_with_stdio(false);

    cin >> k >> t;

    a.assign(t, 0);
    for (int i = 0; i < t; ++i) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    if (k % 2 == 0) {
        if (a[0] <= k / 2) {
            cout << 0 << endl;
            return 0;
        }

        a[0] -= k / 2 + 1;

        cout << 1 + a[0] * 2 << endl;

    } else {
        if (a[0] <= k / 2 + 1) {
            cout << 0 << endl;
            return 0;
        }

        a[0] -= k / 2 + 1;

        cout << a[0] * 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256