akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <set>
typedef long long ll;

int main(void) {
  ll i, j, n, a;
  scanf("%lld", &n);
  std::multiset<ll> s;
  std::multiset<ll>::iterator it;
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a);
    it = s.lower_bound(a);
    if(it != s.begin()) {
      it--;
      s.erase(it);
    }
    s.insert(a);
  }
  printf("%lld", s.size());
  return 0;
}

Measured memory_bytes: 4864
import math
N, H = map(int, input().split())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
amax = max(A)
# 最強の振り刀より強い攻撃力を持つものを抽出
B = list(filter(lambda x: x > amax, B))
B.sort()
ans = 0
while H > 0:
    # まだ投げれる
    if B:
        H -= B.pop()
    # もう投げれない
    else:
        ans += math.ceil(H/amax)
        break
    ans += 1
print(ans)


Measured memory_bytes: 11716
#include<cstdio>
#include<cmath>
#include<cctype>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<string>
#define INF 0x3f3f3f3f
#define LC(a) (a<<1)
#define RC(a) (a<<1|1)
#define MID(a,b) ((a+b)>>1)
#define fin(name)  freopen(name,"r",stdin)
#define fout(name) freopen(name,"w",stdout)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FOR(i,start,end) for(int i=start;i<=end;i++)  
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long LL;
const int N=5e6+5;

LL a[N],b[N];

int main(){
	LL n;
	LL sum1=0,sum2=0;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%lld",&b[i]);
		if(a[i]<b[i])
			sum1+=(b[i]-a[i])/2;
		if(b[i]<a[i])
			sum2+=a[i]-b[i];
	}
	if(sum1-sum2>=0)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 2432
X, K, D=list(map(int,input().split()))

m=int(abs(X)/D)

if m >= K:
    if X > 0:
        ans = X-K*D
    else:
        ans = X+K*D
else:
    if X > 0:
        if (K-m)%2 == 0:
            ans = X-m*D
        else:
            ans = X-m*D-D
    else:
        if (K-m)%2 == 0:
            ans = X+m*D
        else:
            ans = X+m*D+D

print(abs(ans))


Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  string s[n];
  rep(i,0,n) cin>>s[i];
  int a[n][26];
  rep(i,0,n){
    rep(j,0,26){
      a[i][j]=0;
    }
  }
  rep(i,0,n){
    for(char c:s[i]){
      a[i][c-'a']++;
    }
  }
  int b[26];
  rep(i,0,26) b[i]=810;
  rep(i,0,n){
    rep(j,0,26){
      b[j]=min(b[j],a[i][j]);
    }
  }
  string t;
  rep(i,0,26){
    rep(j,0,b[i]){
      t+='a'+i;
    }
  }
  cout<<t<<endl;
}

Measured memory_bytes: 256
n = int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
      
r = num2alpha(n)
ru = r.lower()
print(ru)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = (1 << 21) + 1;
const int mod = 1e9 + 7;
int n, k, a[30][30];
int dp[N];
int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			cin >> a[i][j];
	dp[0] = 1;
	for (int i = 0; i < (1 << n); ++i) {
		int s = __builtin_popcount(i);
		for (int j = 0; j < n; ++j) {
			if (a[s + 1][j + 1] && !(i >> j & 1)) {
				(dp[i | (1 << j)] += dp[i]) %= mod;
			}
		}
	}
	cout << dp[(1 << n) - 1];
}



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

using namespace std;

const int MX_BIT = 25;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    long long a, b, c;
    cin >> a >> b >> c;
    auto d = c - a - b;
    auto ans = d >= 0 && d*d > 4*a*b;
    cout << (ans ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int find(int a, int b, int c) {
    int l=a;
    int r=b;
    while(l <= (l+r)) {
        if(l%c == 0)
            return l;
        l++;
    }
}
void solve() {
    int n, l;
    cin >> n >> l;
    int a[n], b[n+1];
    b[0] = 0;
    for(int i=0;i<n;i++) {
        cin >> a[i];
        b[i+1] = a[i] + b[i];
    }
    int c=0;
    for(int i=0;i<n+1;i++) {
       // cout << b[i] << " ";
        if(b[i] <= l)
            c++;
    }
    cout << c << endl;
    return ;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

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

int main() {
  int n, k;
  string s;
  cin >> n >> s >> k;
  rep(i,n) {
    if (s[i] != s[k - 1]) s[i] = '*';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

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

	for (int i = A; i <= B; i++) {

		if (i % K == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

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

		long n = sc.nextLong();
		long m = sc.nextLong();
		long ans = 0;

		if (n == 2 || m == 2) {
			ans = 0;
		} else if (n == 1) {
			if (m == 1)
				ans = 1;
			else
				ans = m - 2;
		} else if (m == 1) {
			ans = n - 2;
		} else {
			ans = n * m - 2 * n - (m - 2) * 2;
		}

		System.out.println(ans);
	}

}


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

using namespace std;

typedef long long int64;

template< class T >
struct BinaryIndexedTree
{
  vector< T > data;

  BinaryIndexedTree(int sz)
  {
    data.assign(++sz, 0);
  }

  T sum(int k)
  {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x)
  {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

int main()
{
  int64 N, K, A[200000];

  cin >> N >> K;
  for(int i = 0; i < N; i++) cin >> A[i];

  int64 sum = 0;
  vector< int64 > odd;
  odd.push_back(0);
  for(int i = 0; i < N; i++) {
    sum += A[i];
    odd.push_back(sum - (i + 1) * K);
  }
  sort(begin(odd), end(odd));
  odd.erase(unique(begin(odd), end(odd)), end(odd));

  sum = 0;
  int64 ret = 0;
  BinaryIndexedTree< long long > bit(odd.size() + 2);
  bit.add(lower_bound(begin(odd), end(odd), 0) - begin(odd), 1);
  for(int i = 0; i < N; i++) {
    sum += A[i];
    ret += bit.sum(lower_bound(begin(odd), end(odd), sum - (i + 1) * K) - begin(odd));
    bit.add(lower_bound(begin(odd), end(odd), sum - (i + 1) * K) - begin(odd), 1);
  }
  cout << ret << endl;
}

Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double 
#define pb push_back
#define pii pair<ll,ll>
ll M = 1e9+7;

ll power(ll a,ll b,ll c=M){
    ll res=1;
    a%=c;
    while(b>0){
        if(b%2)res= (res*a)%c;
        a = (a*a)%c;
        b/=2;
    }
    return res;
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    cout << n*n*n << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define mii map<int,int>
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main() {
	io;
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++) cin>>v[i];
	sort(v.begin(),v.end());
	int i,j;
	int ans=0;
	for(i=n-1;i>=1;i--){
	    for(j=i-1;j>=0;j--){
	        int x=upper_bound(v.begin(),v.end(),v[i]-v[j])-v.begin();
	        if(x<j)ans+=j-x;
	    }
	}
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	
    	int[] one = new int[10];
    	int[] two = new int[10];
    	int[] the = new int[10];
    	int[] fou = new int[10];
    	int[] fiv = new int[10];
    	int reg2,sumpoint;
    	for(;;){
    		sumpoint=0;
    		Arrays.fill(one, 0);
    		Arrays.fill(two, 0);
    		Arrays.fill(the, 0);
    		Arrays.fill(fou, 0);
    		Arrays.fill(fiv, 0);
    		
    		int n=sc.nextInt();
    		if(n==0){
    			return;
    		}
    		
    		for(int i=0;i<n;i++){
    			one[9-i]=sc.nextInt();
    			two[9-i]=sc.nextInt();
    			the[9-i]=sc.nextInt();
    			fou[9-i]=sc.nextInt();
    			fiv[9-i]=sc.nextInt();
    		}
    		shift(one);
			shift(two);
			shift(the);
			shift(fou);
			shift(fiv);
    		for(;;){
    			reg2=check(one,two,the,fou,fiv);
    			if(reg2>0){
    				shift(one);
    				shift(two);
    				shift(the);
    				shift(fou);
    				shift(fiv);
    				
    				sumpoint+=reg2;
    			}else{
    				System.out.println(sumpoint);
    				break;
    			}
    		}
    		
    	}
    	
    }
    static int check(int[] one,int[] two,int[] the,int[] fou,int[] fiv){
    	int point;
    	int reg;
    	int sum=0;
    	
    	for(int i=0;i<10;i++){
    		point=0;
    		reg=0;
    		if(two[i]==the[i]&&fou[i]==the[i]){
    			point=3;
    			if(one[i]==the[i]){
    				point++;
    				reg+=1;
    			}
    			if(fiv[i]==the[i]){
    				point++;
    				reg+=2;
    			}
    			
    			if(reg==0){
    				point*=the[i];
    				two[i]=0;
    				the[i]=0;
    				fou[i]=0;
    			}else if(reg==1){
    				point*=the[i];
    				one[i]=0;
    				two[i]=0;
    				the[i]=0;
   					fou[i]=0;
    			}else if(reg==2){
    				point*=the[i];
    				two[i]=0;
    				the[i]=0;
				    fou[i]=0;
				    fiv[i]=0;
    			}else if(reg==3){
    				point*=the[i];
    				one[i]=0;;
    				two[i]=0;;
    				the[i]=0;;
				    fou[i]=0;;
				    fiv[i]=0;
    			}
    		}else if(two[i]==the[i]){
    			if(one[i]==the[i]){
    				point=3*the[i];
    				one[i]=0;
    				two[i]=0;
    				the[i]=0;
    			}
    		}else if(fou[i]==the[i]){
    			if(fiv[i]==the[i]){
    				point=3*the[i];
    				the[i]=0;
    			    fou[i]=0;
 				    fiv[i]=0;
    			}
    		}
    	sum+=point;
    	}
    	return sum;
    }
    static void shift(int[] list){
    	for(int i=1;i<10;i++){
    		int j=0;
            while(i-j-1>=0&&list[i-j-1]==0){
            	j++;
            }
            if(j!=0){
                list[i-j]=list[i];
                list[i]=0;
            }
    	}
    }
}



Measured memory_bytes: 55236
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL << 31) - 1;
const ll mod = 1e9 + 7;



ll L,R,d;


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


	cin >> L >> R >> d;
	cout << R / d - (L-1) / d << endl;



}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
// typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;

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

  int ans=1000;
  rep(i,s.size()-2){
    int a=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
    a=abs(a-753);
    ans=min(ans,a);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
#h, w = map(int,input().split())
#ls = list(map(int,input().split()))
#ls = [list(map(int,input().split())) for i in range(n)]
#ls = [input() for i in range(h)]

ans = 0
for i in range(1,n+1):
  if i%2 == 1:
    yakusuu = 0
    for j in range(1,i + 1):
      if i%j == 0:
        yakusuu += 1
    if yakusuu == 8:
      ans += 1
print(ans)
    

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

const ll INF = INT_MAX;

class SegmentTree {
private:
    int n;
    vector<int> node;

public:
    SegmentTree(vector<int> V) {
        int sz = V.size();
        n = 1;
        while (n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, INF);
        for (int i = 0; i < sz; ++i) {
            node.at(i + n - 1) = V.at(i);
        }
        for (int i = n - 2; i >= 0; --i) {
            node.at(i) = min(node.at(2 * i + 1), node.at(2 * i + 2));
        }
    };
    void update(int x, int val) {
        x += (n - 1);
        node.at(x) = val;
        while (x > 0) {
            x = (x - 1) / 2;
            node.at(x) = min(node.at(2 * x + 1), node.at(2 * x + 2));
        }
    };
    int find(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r == -1) r = n;
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return node.at(k);
        int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    };
};

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

    int n, q;
    cin >> n >> q;
    vector<int> v(n, INF);
    SegmentTree tree(v);
    for (int i = 0; i < q; ++i) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            tree.update(x, y);
        } else {
            cout << tree.find(x, y + 1) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4624
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
  int s;
  double w,h;
  char t;
  
  while(cin>>s>>t>>w>>t>>h){
    double BMI=w/(h*h);
    if(BMI>=25){
      cout<<s<<endl;
    }
  }
  
  return 0;
}

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

public static class Program {
    public static void Main() {
        long[] nda=Console.ReadLine().Split().Select(long.Parse).ToArray();
        long n=nda[0];
        long d=nda[1];
        long a=nda[2];

        var data=new List<Tuple<long,long>>();
        for(int i=0;i<n;i++){
            long[]xh=Console.ReadLine().Split().Select(long.Parse).ToArray();
            data.Add(new Tuple<long,long>(xh[0],(xh[1]+a-1)/a));
        }
        data.Sort();

        long ans=0;
        long now=0;
        long[] lazy=new long[n+1];
        for(int i=0;i<n;i++){
            long x=data[i].Item1;
            long h=data[i].Item2;
            now-=lazy[i];
            h=Math.Max(0,h-now);
            ans+=h;
            now+=h;

            int lwr=-1;
            int upr=(int)n;
            while(1<upr-lwr){
                int mid=(upr+lwr)/2;
                if(data[mid].Item1<=x+2*d)lwr=mid;
                else upr=mid;
            }
            lazy[upr]+=h;
        }
        Console.WriteLine(ans);
    }
}

/*
まず、爆弾は固定ダメージですから、HP をすべて A で割っておくことで、A = 1 としてよいです。
敵を座標でソートして、敵を左から順に、なるべく右に爆弾を置いて倒します。
このとき巻き添えになる敵がたくさんいたら間に合いませんから、それは隣接差で遅延評価しましょう。
配列を用意して、それの累積和が与えたダメージになるようにしておきましょう。
ただし、累積和をとってはいけません。せっかく順番に動いていますから、現在の累積和を管理しておきましょう。
*/


Measured memory_bytes: 31416
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2'000'000'000'000'000'000;
const ll MOD=1e9+7;

ll N;
ll a[200010];
vector<ll> edgeList[200010];
ll dp[200010];
ll ans[200010];
void F(ll now,ll p){
    ll change=lower_bound(dp,dp+N,a[now])-dp;
    ll pre=dp[change];
    dp[change]=a[now];
    ans[now]=lower_bound(dp,dp+N,INF)-dp;
    for(auto v:edgeList[now]){
        if(v!=p) F(v,now);
    }
    dp[change]=pre;
}
int main(){
    cin>>N;
    for(ll i=0;i<N;i++) cin>>a[i];
    for(ll i=0;i<N-1;i++){
        ll u,v;cin>>u>>v;u--;v--;
        edgeList[u].push_back(v);
        edgeList[v].push_back(u);
    }
    for(ll i=0;i<N;i++)dp[i]=INF;
    F(0,-1);
    for(ll i=0;i<N;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 33496
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
using namespace std;


ll gcd(ll a, ll b)   //Function to find gcd of two numbers
{
    if (a == 0)
    return b;
    return gcd(b % a, a);
}

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

    string str;
    cin>>str;

    if(str[str.size()-1]!='s')
    cout<<str<<'s'<<endl;
    else
    {  
        string ans = str+'e' + 's';

        cout<<ans<<endl;
    }
    



    return 0;
}

Measured memory_bytes: 3640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		long r = GetLong();
		long D = GetLong();
		long x = GetLong();
		for(int i = 0; i < 10; i++)
		{
			x = x * r - D;
			Console.WriteLine(x);
		}
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

void solve() {
    int N, Q;
    cin >> N >> Q;
    fenwick_tree<int64_t> fw(N);
    rep(i, N) {
        int a; cin >> a;
        fw.add(i, a);
    }
    while(Q--) {
        int t, a, b;
        cin >> t >> a >> b;
        if(!t) fw.add(a, b);
        else cout << fw.sum(a, b) << '\n';
    }

}

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


Measured memory_bytes: 8256
#include <stdio.h>

#define NODE_MAX (101)
#define DEGREE_MAX (101)
#define false (0)
#define true (1)

int
main(void)
{
        int node_num;
        int i, j;
        int node;
        int degree;
        int graph[NODE_MAX][DEGREE_MAX];
        int place[DEGREE_MAX];


        scanf("%d", &node_num);

        for (i = 0; i <= node_num; i++) {
                for (j = 0; j <= node_num; j++)
                        graph[i][j] = false;
        }

        for (i = 1; i <= node_num; i++) {
                scanf("%d %d", &node, &degree);
                for (j = 0; j < degree; j++) {
                        scanf("%d", &place[j]);
                        graph[node][place[j]] = true;
                }
        }

        for (i = 1; i <= node_num; i++) {
                for (j = 1; j <= node_num; j++) {
                        if (j == 1)
                                printf("%d", graph[i][j]);
                        else
                                printf(" %d", graph[i][j]);
                }
                printf("\n");
        }

        return 0;
}


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

typedef long long ll;
#define INF INT_MAX
#define MAXN 200005

int checkdiff(vector<pair<int,char>> v)
{
    int diff = INF;
    for(int i = 1 ; i < (int)v.size() ; i++){
        diff = min(v[i].first - v[i-1].first,diff);
    }
    return diff;
}



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

    int N;
    cin >> N;
    int a;
    bool ok = true;
    for(int i = 0 ; i < N ; i++){
        cin >> a;
        if((a % 2) == 0){
            //ok = ((a%5 != 0) && (a%3 != 0)) ? false : true;
            if((a%3 != 0) && (a%5 != 0)){
                cout << "DENIED" << '\n';
                return 0;
            }      
        }
    }
    cout << "APPROVED" << '\n';
    //(ok == true) ? cout << "APPROVED" << '\n' : cout << "DENIED" << '\n';

    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = []
for i in range(n):
    a = int(input())
    l.append([tuple(map(int, input().split())) for _ in range(a)])
 
cnt = 0
for i in range(1 << n):
    Flag = True
    for j in range(n):
        if (i >> j) & 1:
            for x, y in l[j]:
                if i >> (x-1) & 1 != y:
                    Flag = False
                    break
    if Flag:
        cnt = max(cnt, sum(map(int, bin(i)[2:])))
 
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    string s;
    cin >> s;
    for(int i=2;i<s.size();i += 2){
        string t="";
        for(int j=0;j<s.size()-i;j++){
            t += s.at(j);
        }
        bool even = true;
        for(int k=0;k<(t.size())/2;k++){
            if(t.at(k) != t.at((t.size())/2+k)) even = false;
        }
        if(even){
            cout << t.size() << endl;
            return 0;
        }
    }
}

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

int main(){
  int t,n,block[100]={},up,down,climb;

  cin >> t;
  for(int i=0;i<t;i++){
    up=0; down=0; climb=0;
    cin >> n;
    for(int j=0;j<n;j++){
      cin >> block[j];
    }
    for(int j=0;j<n-1;j++){
      climb=block[j]-block[j+1];
      if(climb<up){
	up=climb;
      }
      if(climb>down){
	down=climb;
      }
    }
    up*=-1;
    cout << up << " " << down << endl;
  }

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int main()
{
    int n, m;
    cin >> n >> m;
    VVI v(n, VI(m));
    rep(i, n) rep(j, m)
    {
        cin >> v[i][j];
        v[i][j]--;
    }
    VI p(n, 0);
    int ans = IINF;
    map<int, bool> used;
    rep(j, m)
    {
        map<int, int> mp;
        rep(i, n)
        {
            mp[v[i][p[i]]]++;
        }
        int delid = -1;
        int delnum = 0;
        rep(i, m)
        {
            if (mp[i] > delnum)
            {
                delnum = mp[i];
                delid = i;
            }
        }
        chmin(ans, delnum);
        used[delid] = true;
        if (j == m - 1)
            break;
        rep(i, n)
        {
            while (used[v[i][p[i]]])
                p[i]++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
S = input()
N = len(S)
ans = 0

for i in range(1,2**(N-1)):
    A = S[0]
    for j in range(N-1):
        if 1 << j & i:
            A += '+'
        A += S[j+1]
    ans += eval(A)
    # print(A, 'ans: ', ans)

print(ans+int(S))

Measured memory_bytes: 3060
#書き足された各辺 u→v は、
#ある頂点 uからその子孫であるような
#頂点vに向かって伸びています。
#bfsでよい
from sys import stdin
from collections import deque
input = stdin.readline
n,m = map(int, input().split( ))

E = [[] for _ in range(n)]

P = [-1]*n
deg = [0]*n
for i in range(n+m-1):
    ai,bi = map(int, input().split( ))
    ai-=1;bi-=1
    E[ai].append(bi)
    deg[bi]+=1
r = deg.index(0)

Q = deque()
Q.append(r)
P[r] = r

while Q:
    v = Q.popleft()
    for u in E[v]:
        if deg[u]==1:
            P[u]=v
            deg[u]-=1
            Q.append(u)
        else:
            deg[u]-=1


for i in range(n):
    if P[i]==i:
        print(0)
    else:
        print(P[i]+1)


Measured memory_bytes: 20736
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i=0; i<n; i++){
        cin >> x.at(i);
    }
    sort(x.begin(),x.end());
    int mn, mx;
    mn = x.at(0);
    mx = x.at(n-1);
    int tmp = 0;
    int sum = 0;
    for(int j=mn; j<=mx; j++){
        for(int i=0; i<n; i++){
            tmp = tmp + pow(x.at(i)-j,2);
        }
        if(j==mn){
            sum = tmp;
        }else if(tmp < sum){
            sum = tmp;
        }
        tmp = 0;
    }
    cout << sum << endl;
}




Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int k;
    long int count = 0,a = 0;
    scanf("%d",&k);
    if(k % 2 == 0 || k % 5 == 0)
    {
        printf("-1");
        return 0 ;
    }
    while(1)
    {
        a = (a * 10 + 7) % k;
        count++;
        if(a == 0)
        {
            printf("%ld\n",count);
            return 0;
        }
    }
    
}

Measured memory_bytes: 1732
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int getsum(int k){
    return k*(k-1)/2;
}
long long qSum[200003], n, num;
int main(int argc, char const *argv[])
{
    cin>>n;
    for (int i = 1; i <= n; ++i)
    {
        cin>>num;
        qSum[i] = qSum[i-1]+num;
    }
    sort(qSum+1, qSum+n+1);
    long long sum = 0;
    long long k = 1;
    for (int i = 1; i <= n; ++i)
    {
        if(qSum[i] == 0){
            sum++;
        }
        if(qSum[i] == qSum[i+1]&&i != n){
            k++;
        } else {
            sum += k*(k-1)/2;
            k = 1;
        }
    }
    cout<<sum<<endl;
    return 0;
}

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

using ll = long long;

ll dp1[105][10][2][2];  // dp[i番目の席までみて][j人座っている][最初の席の状態][直前の席の状態]
ll dp2[105][10][3][3];  // dp[i番目の席までみて][j人座っている][最初の席の状態][直前の席の状態]
ll fact = 2*3*4*5*6*7*8;

void init(){
    int n = 100;
    // odd
    dp1[1][0][0][0] = 1;
    dp1[1][1][1][1] = 1;
    for(int i=1;i<n;i++){
        for(int j=0;j<=8;j++){
            for(int k=0;k<2;k++){
                dp1[i+1][j][k][0] = dp1[i][j][k][0] + dp1[i][j][k][1];
                dp1[i+1][j+1][k][1] = dp1[i][j][k][0];
            }
        }
    }
    // even
    dp2[1][0][0][0] = 1;
    dp2[1][1][1][1] = 1;
    dp2[1][1][2][2] = 1;
    for(int i=1;i<n/2;i++){
        for(int j=0;j<=8;j++){
            for(int k=0;k<3;k++){
                dp2[i+1][j][k][0] = dp2[i][j][k][0] + dp2[i][j][k][1] + dp2[i][j][k][2];
                dp2[i+1][j+1][k][1] = dp2[i][j][k][0] + dp2[i][j][k][2];
                dp2[i+1][j+1][k][2] = dp2[i][j][k][0] + dp2[i][j][k][1];
            }
        }
    }
}

void solve_odd(int n){
    ll ans = 0;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            if(i==1 && j==1) continue;
            ans += dp1[n][8][i][j];
        }
    }
    cout << ans * fact << endl;
}

void sovle_even(int n){
    ll ans = 0;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(i>0 && j>0 && i!=j) continue;
            ans += dp2[n/2][8][i][j];
        }
    }
    cout << ans * fact << endl;
}

int main() {
    init();
    int n;
    while(cin >> n, n){
        if(n&1){
            solve_odd(n);
        } else {
            sovle_even(n);
        }
    }
    return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long;

int main()
{
    // 整数の入力
    ll A,B,K;
    cin >> A >> B >> K;
    ll remainA = max(0LL,A-K);
    K = max(0LL,K - A);
    ll remainB = max(0LL,B-K);

    cout << remainA << " " << remainB << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func read() string {
        sc.Scan()
        var input = sc.Text()
        return input
}

func main() {
        input := read()
        is := make([]int, 0)
        for _, elem := range strings.Split(input, " ") {
                i, _ := strconv.Atoi(elem)
                is = append(is, i)
        }
        if is[0]%3 == 0 || is[1]%3 == 0 || (is[0]+is[1])%3 == 0 {
                fmt.Println("Possible")
        } else {
                fmt.Println("Impossible")
        }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long int
const int MOD=1000000007;
int po26[2000005];
int po25[2000005];
int fact[2000005];
int ifact[2000005];
int add(int x, int y)
{
	return (x + y) % MOD;
}

int sub(int x, int y)
{
	return add(x, MOD - y);
}

int mul(int x, int y)
{
	return (x * 1ll * y) % MOD;
}

int binpow(int x, int y)
{
	int z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = mul(z, x);
		x = mul(x, x);
		y /= 2;
	}
	return z;
}

int inv(int x)
{
	return binpow(x, MOD - 2);
}



int C(int n, int k)
{
	return mul(fact[n], (mul(ifact[k], ifact[n - k])));
}
 main() {
 	po26[0]=1;
 	po25[0]=1;
 	fact[0]=1;
 	for(int i=1; i<=2000000; i++){
 		fact[i]=mul(i, fact[i-1]);
 	}
 	for(int i=0; i<=2000000; i++){
 		ifact[i]=inv(fact[i]);
 	}
 	for(int i=1; i<2000005; i++){
 		po26[i]=(26*po26[i-1])%MOD;
 		po25[i]=(25*po25[i-1])%MOD;
 	}
	int k;
	string s;
	cin>>k;
	cin>>s;
	int sz=s.size();
	int ans=0;
	for(int i=sz-1; i<sz+k; i++){
		int num1=po26[k+sz-i-1];
		int num2=po25[i-sz+1];
		int num3=(num1*num2)%MOD;
		num3=mul(num3, C(i, sz-1));
		ans=(ans+num3)%MOD;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 67844
def solve():
    S = input()[::-1]
    i = 0
    while i < len(S):
        if S[i:i+5] in ['maerd', 'esare']:
            i += 5
        elif S[i:i+6] == 'resare':
            i += 6
        elif S[i:i+7] == 'remaerd':
            i += 7
        else:
            return 'NO'
    return 'YES'

    
if __name__ == '__main__':
    ans = solve()
    print(ans)

Measured memory_bytes: 9248
#include<bits/stdc++.h>
using namespace std;
int n,K,go[22][22][22];
string s[22],ans;
string dp[66666][20][7]; 
void upd(string &a,string &b,char c)
{
	string s=b+c;
	if (a=="") a=s;
	else if (a>s) a=s;
}
int fuck(int x,int y,int z)
{
	string a,b,c,d;
	a=b=c=d="";
	a=s[x];
	reverse(a.begin(),a.end());
	bool u[22];
	memset(u,0,sizeof(u));
	for (int i=0;i<a.size();i++)
	{
		u[a[i]-'A']=1;
	}
	for (int i=0;i<n;i++) 
	{
		if (!u[i]) b+=(char)('A'+i);
	}
	if (n-K==1) a=a+b;
	else if (n-K==2)
	{
		if (y==1) a=a+b;
		else a=a+b[1]+b[0];
	}
	else 
	{
		if (y==1) a=a+b;
		else if (y==2) a=a+b[0]+b[2]+b[1];
		else if (y==3) a=a+b[1]+b[0]+b[2];
		else if (y==4) a=a+b[1]+b[2]+b[0];
		else if (y==5) a=a+b[2]+b[0]+b[1];
		else a=a+b[2]+b[1]+b[0];
	}
	c=s[z];int pos=0;
	for (int i=0;i<c.size();i++)
	{
		while(pos<a.size() && a[pos]!=c[i]) 
		{
			d=d+a[pos];
			pos++;
		}
		if (pos>=a.size()) return -1;
		pos++;
	}
	while(pos<a.size()) 
	{
		d=d+a[pos];
		pos++;
	}
	if (n-K==1) return 1;
	if (n-K==2)
	{
		if (d[0]>d[1]) return 2;
		return 1;
	}
	if (d[0]<d[1] && d[1]<d[2]) return 1;
	if (d[0]<d[2] && d[2]<d[1]) return 2;
	if (d[1]<d[0] && d[0]<d[2]) return 3;
	if (d[2]<d[0] && d[0]<d[1]) return 4;
	if (d[1]<d[2] && d[2]<d[0]) return 5;
	return 6; 
}
int main()
{
	scanf("%d%d",&n,&K);
	for (int i=0;i<n;i++)
	{
		cin>>s[i];
	}
	for (int i=0;i<n;i++)
	{
		if (n-K==1) dp[1<<i][i][1]+=(char)('A'+i);
		else if (n-K==2) 
		{
			dp[1<<i][i][1]+=(char)('A'+i);
			dp[1<<i][i][2]+=(char)('A'+i);
		}
		else
		{
			dp[1<<i][i][1]+=(char)('A'+i);
			dp[1<<i][i][2]+=(char)('A'+i);
			dp[1<<i][i][3]+=(char)('A'+i);
			dp[1<<i][i][4]+=(char)('A'+i);
			dp[1<<i][i][5]+=(char)('A'+i);
			dp[1<<i][i][6]+=(char)('A'+i);
		}
	}
	for (int j=0;j<n;j++)
	{
		for (int k=1;k<=6;k++)
		{
			if (n-K==1 && k>1) continue;
			if (n-K==2 && k>2) continue;
			for (int h=0;h<n;h++)
			{
				go[j][k][h]=fuck(j,k,h);
			}
		}
	}
	for (int i=1;i<(1<<n);i++)
	{
		for (int j=0;j<n;j++)
		{
			if (!(i&(1<<j))) continue;
			for (int k=1;k<=6;k++)
			{
				if (dp[i][j][k]=="") continue;
				for (int h=0;h<n;h++)
				{
					if (i&(1<<h)) continue;
					int hs=go[j][k][h];
					if (!~hs) continue;
					upd(dp[i^(1<<h)][h][hs],dp[i][j][k],'A'+h);
				}
			}
		}
	}
	ans="";
	for (int i=0;i<n;i++)
	{
		for (int k=1;k<=6;k++)
		{
			if (dp[(1<<n)-1][i][k]=="") continue;
			if (ans=="") ans=dp[(1<<n)-1][i][k];
			else if (ans>dp[(1<<n)-1][i][k]) ans=dp[(1<<n)-1][i][k];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 108264
import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/20 11:36 下午
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long x = scanner.nextLong();
        long k = scanner.nextLong();
        long d = scanner.nextLong();
        x = Math.abs(x);
        long n = x/d;
        if(x%d !=0)n++;
        if(n > k){
            System.out.println(x-k*d);
        }else{
            long tmp = k - n;
            if(tmp % 2 == 1){
                System.out.println(x - (n-1)*d);
            }else{
                System.out.println(Math.abs(x-n*d));
            }
        }
    }
}


Measured memory_bytes: 35860
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;
int main(){
  int k,x;cin >> k >> x;
  for(int i=x-k+1;i<=x+k-1;i++){
    cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <stack>
#include <string>
using namespace std;

int main(){
    int N,M;
    while(cin>>N>>M){
        if(N==M){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }   
}

Measured memory_bytes: 888
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var x = (int)cin.Read()[0];
            var y = (int)cin.Read()[0];
            if (x == y) WriteLine("=");
            else if (x > y) WriteLine(">");
            else WriteLine("<");
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}



Measured memory_bytes: 13268
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        PriorityQueue<Apple> queue = new PriorityQueue<>();
        for (int i = 0; i < a; i++) {
            queue.add(new Apple(0, sc.nextInt()));
        }
        for (int i = 0; i < b; i++) {
            queue.add(new Apple(1, sc.nextInt()));
        }
        for (int i = 0; i < c; i++) {
            queue.add(new Apple(2, sc.nextInt()));
        }
        int z = x + y;
        long total = 0;
        while (z > 0) {
            Apple ap = queue.poll();
            if (ap.type == 0) {
                if (x <= 0) {
                    continue;
                }
                x--;
            } else if (ap.type == 1) {
                if (y <= 0) {
                    continue;
                }
                y--;
            }
            z--;
            total += ap.value;
        } 
        System.out.println(total);
    }
    
    static class Apple implements Comparable<Apple> {
        int type;
        int value;
        
        public Apple(int type, int value) {
            this.type = type;
            this.value = value;
        }
        
        public int compareTo(Apple another) {
            return another.value - value;
        }
    }
}

Measured memory_bytes: 102644
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define debug(x) cout << #x << " : " << x << endl;
#define part cout << "----------------------\n";
#define fastinput ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int main()
{
    fastinput;
    LL n,i,j,k,t,temp,m;
    priority_queue<LL> q;
    LL sum=0;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>j;
        sum+=j;
        q.push(j);
    }

    while(m--)
    {
        LL top_element=q.top();
        //debug(top_element);
        sum+=top_element/2-top_element;;
        q.pop();
        q.push(top_element/2);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1400
from collections import deque

v,e = map(int,input().split()) 
ins = [0]*v
outs = [[] for i in range(v)]
ans = []
for i in range(e):
    a,b = map(int,input().split())
    outs[a].append(b)
    ins[b] += 1
Q = deque([])
for i in range(v):
    if ins[i] == 0:
        Q.append(i)
while len(Q) > 0:
    cur = Q.popleft()
    ans.append(cur)
    for e in outs[cur]:
        ins[e] -= 1
        if ins[e] == 0:
            Q.append(e)
if len(ans) == v:
    print(0)
else:
    print(1)    


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

int main()
{
	string s;
	int a, b;
	bool f1 = 1, f2 = 1;
	
	cin >> s;
	a = stoi(s.substr(0, 2));
	b = stoi(s.substr(2, 2));

	if (a == 0 || a > 12)
		f1 = 0;
	if (b == 0 || b > 12)
		f2 = 0;

	if (f1 && f2)
		cout << "AMBIGUOUS" << endl;
	else if (f1)
		cout << "MMYY" << endl;
	else if (f2)
		cout << "YYMM" << endl;
	else
		cout << "NA" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const int N=1e5;
int main()
{
    FASTINOUT;
    ll h,w;
    cin>>h>>w;
    if (h==1 ||w==1)
        cout<<1<<endl;
    else
    {
        cout<<(w*h)/2+((w*h)%2!=0)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
S=str(input().strip())

T=""
for i in S:
    if i=="A" or i=="C" or i=="G" or i=="T":
        T+="1"
    else:
        T+="0"

TT=T.split("0")
num=0
for i in TT:
    num=max(num,len(i))
print(num)

Measured memory_bytes: 3060
N = int(input())
A = sorted(list(map(int, input().split())))
M = 1000001
D = [False]*M
ans = 0
for i, a in enumerate(A):
    if D[a]: continue
    if i==N-1 or A[i+1]>a : ans += 1
    b = a
    while b<M:
        D[b] = True
        b += a

print(ans)

Measured memory_bytes: 32168
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxt();
    vector <ll> t(n),a(n);
    for(int i=0;i<n;i++)
        cin>>t[i]>>a[i];

    ll n1=t[0],n2=a[0];
    for(int i=1;i<n;i++)
    {
        ll x=(n1+t[i]-1)/t[i];
        ll y=(n2+a[i]-1)/a[i];
        ll fin=max(x,y);
        n1=t[i]*fin;
        n2=a[i]*fin;
    }
    cout<<n1+n2<<endl;
  

    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <stdio.h>
#include <time.h>
#include <queue>
#include <ctype.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s[0]==s[2]) cout<<"Yes";
    else cout<<"No";
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100005
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){int i;LL x=a;if(n==0)return 1;else if(n==1)return a;else FOR(i,0,n-1){x=x*a;if(x>MOD)x%=MOD;}return (int)x;}
int cmp(const void* a,const void* b){return *(int*)a-*(int*)b;}

int main() {
  int r,i,ans=0;
  scanf("%d",&r);

  printf("%d\n",3*r*r);
	return 0;
}


Measured memory_bytes: 128
"素因数分解のライブラリ"
from collections import Counter


def prime_factorize(n):
    b = 2
    fct = []
    while n >= b ** 2:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct


N = int(input())
MOD = 1000000007
numbers = []
for i in range(1, N+1):
    numbers.extend(prime_factorize(i))

count_numbers = Counter(numbers)
ans = 1
for n in count_numbers.values():
    ans *= ((n+1) % MOD)

print(ans % MOD)


Measured memory_bytes: 3316
N = int(input())
ans = 0
prev_A = -10
prev_card_num = 0
for i in range(1,N+1):
    A = int(input())
    ans += (prev_card_num + A)//2
    if prev_card_num == 1 and A == 0:
        prev_card_num = 0
    elif (prev_card_num+A)%2 == 1:
        prev_card_num = 1
        prev_A = i
    else:
        prev_card_num = 0
        prev_A = i
print(ans)

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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int lcm(int a,int b){return a*b/gcd(a, b);}

int main()
{
  int n, v;
  double a, b;
  priority_queue<double, vector<double>, greater<double>> pq;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> v;
    pq.push(v);
  }
  for (int i = 0; i < n - 1; i++)
  {
    a = pq.top();
    pq.pop();
    b = pq.top();
    pq.pop();
    pq.push((a + b) / 2);
  }
  cout << fixed << setprecision(5) << pq.top() << endl;
}

Measured memory_bytes: 3740
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int64_t l[87] = { 2, 1 };
    for (int i = 2; i < 87; i++) {
        l[i] = l[i - 1] + l[i - 2];
    }

    cout << l[n] << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
			double d = sc.nextInt();
      		double t = sc.nextInt();
      		double s = sc.nextInt();
      		double A = d/s;
      		if(A <= t){
            	System.out.println("Yes");
            }else{
            	System.out.println("No");
            }
	}
}

Measured memory_bytes: 27036
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int n,k,ans=0,a;
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a;
    ans=(n-1)/(k-1);
    if((n-1)%(k-1)) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256