akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using Graph = vector<vector<pii>>;
int n;
Graph G;

int main() {
  cin >> n;
  G.assign(n, vector<pii>());
  rep(i, n - 1){
    int a, b; cin >> a >> b; a--; b--;
    G[a].emplace_back(b, i);
    G[b].emplace_back(a, i);
  }
  int mx = 0;
  rep(i, n) chmax(mx, (int)G[i].size());
  vector<int> res(n-1, -1);

  vector<int> dist(n, -1);
  queue<pii> que;
  que.push({0, -1});
  dist[0] = 0;
  while(!que.empty()){
    auto p = que.front(); que.pop();
    int v = p.first, c = p.second;
    int color = 1;
    if(color == c) ++color;
    for(auto e : G[v]){
      if(dist[e.first] == -1){
        dist[e.first] = dist[v] + 1;
        que.push({e.first, color});
        res[e.second] = color;
        color++;
        if(color == c) color++;
      }
    }
  }
  cout << mx << ln;
  for(auto v: res) cout << v << ln;
  
}
    


Measured memory_bytes: 7424
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    edge=[set() for _ in range(N)]
    for i in range(M):
        a,b=map(int1,input().split())
        edge[a].add(b)
        edge[b].add(a)
    for i in range(N):
        if i in edge[0] and N-1 in edge[i]:
            print('POSSIBLE')
            exit()
    print('IMPOSSIBLE')

if __name__ == '__main__':
    main()


Measured memory_bytes: 100044
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int n, c, tmp, ans;
int p[100];

int main() {

	cin >> n >> c;
	rep(i, c) {
		cin >> p[i];
		tmp += p[i];
	}
	n++;

	if (tmp % n != 0)ans = tmp / n + 1;
	else ans = tmp / n;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
ll bigmod(ll a, ll b,ll m)
{
    ll ans=1;
    a%=m;
    while(b)
    {
        if(b&1) ans=(ans*a)%m;
        b>>=1;
        a=(a*a)%m;
    }
    return ans;
}
ll facto[1000009];
int main()
{
    facto[0]=facto[1]=1;
    for(int i=1;i<=1000002;i++) facto[i]=(facto[i-1]*i)%mod;
    ll x,y;
    cin>>x>>y;
    ll d=x+y;
    if(d%3) cout<<0<<endl;
    else
    {
        d/=3;
        if(x-d<0) cout<<0<<endl;
        else if(2*d-x<0) cout<<0<<endl;
        else {
        ll e=bigmod(facto[x-d],mod-2,mod);
        ll f=bigmod(facto[2*d-x],mod-2,mod);
        ll ans=(facto[d]*e)%mod;
        ans=ans*f; ans%=mod;
        cout<<ans<<endl;
        }
    }
}


Measured memory_bytes: 8064
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
 
#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647
 
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);
 
 
void solve()
{
  int n , k, d, x;
  cin >> n >> k;
  map<int,int>mp;
  for(int i = 0 ; i < n ; i++){
    cin >> d;
    for(int j = 0 ; j < d ; j++){
      cin >> x;
      mp[x] = d;
    }
  }
  int c = 0;
  for(int i = 1 ; i <= n ; i++)
  {
    if(mp.find(i) == mp.end())
    {
      c++;
    }
  }
  cout << c << endl;
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //TEST
    solve();
    return 0;
}

Measured memory_bytes: 3612
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            tmp = i * 500 + j * 100 + k * 50
            if tmp == x:
                ans += 1
print(ans)

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

int main() {
  vector<int> in(3);
  rep(i, 3) cin >> in[i];
  sort(in.begin(), in.end());
  if(in[0]==5 && in[1]==5 && in[2]==7) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3600
n = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]

s = 0
prev_a = -1
for a in A:
    s += B[a - 1]
    if a == prev_a + 1:
        s += C[prev_a - 1]
    prev_a = a

print(s)

Measured memory_bytes: 3060
n,k=[int(x) for x in input().split()]
A=[]
for i in range(n):
  a,b=[int(x) for x in input().split()]
  A.append([b,a,True])

A.sort(reverse=True)

typ=set()

for i in range(n):
  if A[i][1] in typ:
    A[i][2]=False
  else:
    typ.add(A[i][1])

num=0

for j in range(k):
  if A[j][2]==True:
    #print(j)
    num+=1

ans=0
for i in range(k):
  ans+=A[i][0]
ans+=num**2



curr=ans
nxt = k
lst = k-1

while(True):

	while(nxt < n and A[nxt][2] == False):
		nxt += 1
	while(lst >= 0 and A[lst][2] == True):
		lst -= 1
	if not(nxt < n and lst >= 0):
		break

	curr += A[nxt][0] - A[lst][0]
	curr +=  (num+1) ** 2 - num**2


	num+=1
	nxt+= 1
	lst  -= 1

	ans=max(ans,curr)




print(ans)


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


int main() {
    long n,l,m,i,j,count;
    int a[10007]={0};
    //cin>>m>>n;
    for(i=2;i<=100;i++)
        {
        for(j=2;;j++)
            {
            a[i*j]=1;
            if(i*j>=10000) break;
        }
    }
    a[0]=1;
    a[1]=1;
    while((scanf("%ld",&n))!=EOF)
        {
        /*string s;
        cin>>s;
        //cout<<s<<'l'<<endl;;
       // if(s=="\0")
         //   break;
        l=s.length();
        if(l==0) break;
        n=0;
        for(i=0;i<l;i++)
        {
            n=n+((s[i]-'0')*(pow(10,l-1-i)));
        }
        s="\0";
        //cout<<n<<endl;*/
        count=0;
        for(i=1;i<=n;i++)
        {
            if((a[i]==0) && (a[n+1-i]==0))
                count+=1;
            //cout<<count<<' '<<n<<endl;
        }
        //printf("l%d\n",count);
        cout<<count<<endl;
    }
    return 0;
}

Measured memory_bytes: 3252
using System;
using System.Linq;

namespace Dequeue
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = inputs[0];    // D に詰められている宝石の数
            var k = inputs[1];    // 操作回数
            var jewels = Console.ReadLine().Split().Select(int.Parse).ToArray();    // 宝石の価値
            
            // 左から left 個、右から right 個を獲得して、同じ宝石を stay 回出し入れし、ret 個を戻す
            // (合計価値が下がってしまう場合、'操作しない' が可能）
            // left + right + 2 * stay + ret <= k
            var maxPop = Math.Min(n, k);
            var maxPrice = int.MinValue;
            for (var left = 0; left <= maxPop; left++)
            {
                for (var right = 0; right <= maxPop - left; right++)
                {
                    // まずは左から left 個、右から right 個取り出してしまう
                    var poppedJewels = new int[left + right];
                    Array.Copy(jewels, 0, poppedJewels, 0, left);
                    Array.Copy(jewels, n - right, poppedJewels, left, right);
                    Array.Sort(poppedJewels);

                    var negatives = poppedJewels.Count(price => price < 0);
                    for (var stay = 0; 2 * stay + left + right <= k; stay++)
                    {
                        // 負の値だけ可能な限り戻す
                        var ret = k - (2 * stay + left + right);
                        if (negatives < ret) ret = negatives;
                        if (ret > left + right) continue;

                        var sum = poppedJewels.Skip(ret).Sum();
                        if (maxPrice < sum) maxPrice = sum;
                    }
                }
            }

            // 解答の出力
            Console.WriteLine(maxPrice);
        }
    }
}


Measured memory_bytes: 17488
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   ll arr[n];
   rep(n)
        cin>>arr[i];
  
   ll ans = inf;
   for(ll i=1;i<=100;i++)
   {
       ll temp = 0;
       repi(j,n)
            temp+=(arr[j]-i)*(arr[j]-i);
       ans = min(ans, temp);        
   }
   
   cout<<ans;
   
   return 0;        
}  
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
const double pi=3.1415926535897932384626;

int main(){
    int a,b,c,d;
    std::cin >> a>>b>>c>>d;
    if(a<=c){
        if(b<=d)std::cout << max(b-c,0) << std::endl;
        else std::cout << d-c << std::endl;
    }
    else{
        if(b<=d)std::cout << b-a << std::endl;
        else std::cout << max(0,d-a)<< std::endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -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 UnionFind{
  vector<int> par;

  UnionFind(int n) : par(n,-1) { }

  int root(int x){
    if(par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }

  bool merge(int x,int y){
    x = root(x);
    y = root(y);
    if(x == y){
      return false;
    }
    if(par[x] > par[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x){
    return -par[root(x)];
  }
}
;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> X(M),Y(M),Z(M);
  for(int i=0; i<M; i++){
    cin >> X[i] >> Y[i] >> Z[i];
    X[i]--;
    Y[i]--;
  }
  UnionFind uf(N);
  for(int i=0; i<M; i++){
    uf.merge(X[i],Y[i]);
  }
  set<int> se;
  for(int i=0; i<N; i++){
    if(se.count(uf.root(i))) continue;
    se.insert(uf.root(i));
  }
  cout << se.size() << endl;
  return 0;
}


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

using namespace std;

using ll = long long;

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

typedef pair<int, int> P;

template<class T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T>
bool chmin(T &a, const T &b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin>>n;
	int a[2][n];
	REP(i,2){
		REP(j, n){
			cin>>a[i][j];
		}
	}
	
	int maxsum=0;
	maxsum+=a[0][0];
	REP(i,n) maxsum+=a[1][i];
	
	int sum=maxsum;
	REP(i,n-1){
		sum-=a[1][i];
		sum+=a[0][i+1];
		chmax(maxsum, sum);
	}
	
	cout<<maxsum<<endl;
	
	return 0;
}

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int a,b,t;
int main(){
	ios::sync_with_stdio(false);
	cin>>a>>b>>t;
	int x=0;
	for(int i=1;i<=t;i++){
		if(i%a==0)x+=b;
	}
	cout<<x<<endl;
	return 0;
}

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

int a, b;

int Equivalent(int width, int height){
	int S = width * height;
	return S;
}

int Perimeter(int width, int height){
	int L = 2 * ( width + height );
	return L;
}

int main(void){
	cin >> a >> b;
	cout << Equivalent(a, b) << " " << Perimeter(a, b) << endl;
	return 0;
}

Measured memory_bytes: 3068
void solve(){
}
void main(){
	int[] val = inary();
	( (val[0]-1)*(val[1]-1) ).writeln();
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;
alias instr = () => readln().chomp();
T inelm(T= int)(){ return to!(T)( readln().chomp() ); }
T[] inary(T = int)(){ return readln().chomp().split().to!(T[])(); }



Measured memory_bytes: 2664
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;

void main() {
    int n, k;
    int[] a;

    scan(n, k);
    a = readln.split.to!(int[]);
    a.sort();

    auto dp1 = new bool[][](n + 1, k);
    dp1[0][0] = 1;

    foreach (i ; 1 .. n + 1) {
        foreach (j ; 0 .. k) {
            dp1[i][j] = dp1[i-1][j];
            if (j - a[i-1] >= 0) dp1[i][j] |= dp1[i-1][j-a[i-1]];
        }
    }

    auto dp2 = new bool[][](n + 1, k);
    dp2[n][0] = 1;

    foreach_reverse (i ; 0 .. n) {
        foreach (j ; 0 .. k) {
            dp2[i][j] = dp2[i+1][j];
            if (j - a[i] >= 0) dp2[i][j] |= dp2[i+1][j-a[i]];
        }
    }

    int ans;

    foreach (i ; 0 .. n) {
        int mv;

        for (int l = 0, r = k-1; l < k; l++) {
            if (!dp1[i][l]) continue;
            for (; r >= 0; r--) {
                if (dp2[i+1][r] && l + r < k) {
                    mv = max(mv, l + r);
                    break;
                }
            }
        }

        if (mv < k - a[i]) ans++;
        else break;
    }

    writeln(ans);
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 82428
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string.h>
#include <deque>
#define REP(i,j,n) for(int i=j;i<n;i++)
#define SORT(x) sort(x.begin(),x.end())

using namespace std;

int main() {
	float n, sum = 0, avr,bunsan1=0 ,bunsan2;

	for (;;) {
		cin >> n;
		vector<int> v(n);
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			cin >> v[i];
			sum += v[i];
		}
		avr = sum / n;

		for (int i = 0; i < n; i++) {
			bunsan1 += (avr - v[i])*(avr - v[i]);
		}
		bunsan2 = bunsan1 / n;

		printf("%f\n", sqrt(bunsan2));
		sum = 0; bunsan1 = 0;
	}
	return 0;
}

Measured memory_bytes: 3260
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();

			if (a < 1200) {
				System.out.println("ABC");
			} else if (a < 2800) {
				System.out.println("ARC");
			} else {
				System.out.println("AGC");
			}
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
typedef long long ll;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int main() {
    int n, m; cin >> n >> m;
    int a[n]; rep(i, n) cin >> a[i];
    int b[m], c[m];
    rep(i, m) cin >> b[i] >> c[i];
    priority_queue<pii> q;
    rep(i, n) q.push({a[i], 1});
    rep(i, m) q.push({c[i], b[i]});
    ll ans = 0;
    rep(i, n) {
        pii p = q.top();
        q.pop();
        ans += p.first;
        if (p.second > 1) {
            p.second--;
            q.push(p);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>    
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define pb push_back
#define inf 1e16
#define mod 998244353
#define en '\n'
#define ld long double
#define ff first
#define ss second
#define ull unsigned long long 
#define fr(a,b,c) for(int a = b ; a <= c ; a ++ )
const ll MAXN = 200010;
ll pw(ll b, ll r, ll md){
	ll ans = 1;
	while(r){
		if(r&1)ans = (ans*b)%md;
		b = (b*b)%md;
		r>>=1;
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll a,b,c,d;cin>>a>>b>>c>>d;
	ll at1 = c/b+(c%b==0?0:1);
	ll at2 = a/d+(a%d==0?0:1);
	if(at1<=at2)cout<<"Yes\n";
	else cout<<"No\n";
	return 0 ; 
}

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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

char t[maxn];
int f[maxn],s[maxn],n,a[maxn];
vector<int > e[maxn];

void dfs(int x,int fa) {
    s[x]=a[x],f[x]=0;
    for(auto v:e[x]) {
        if(v==fa) continue;
        dfs(v,x),s[x]+=s[v],f[x]+=s[v]+f[v];
    }
}

int gao(int x,int fa) {
    if(!x) return 0;
    int mx=0;
    for(auto v:e[x])
        if(v!=fa&&f[v]>f[mx]) mx=v;
    int w=gao(mx,x)+s[mx];
    if(f[x]-f[mx]-s[mx]>=w) return f[x]&1;
    else return w-(f[x]-f[mx]-s[mx]);
}

int main() {
    read(n);scanf("%s",t+1);
    for(int i=1;i<=n;i++) a[i]=t[i]-'0';
    for(int i=1,x,y;i<n;i++) read(x),read(y),e[x].pb(y),e[y].pb(x);
    int ans=inf;
    for(int i=1;i<=n;i++) {
        dfs(i,0);// write(f[i]);
        if(!gao(i,0)) ans=min(ans,f[i]/2);
    }write(ans==inf?-1:ans);
    return 0;
}


Measured memory_bytes: 29056
def main():
    num = int(input())
    data = list(map(int, input().split()))

    count = 0
    for i in range(num):
        now_num = data[i]
        while now_num % 2 == 0:
            now_num //= 2
            count += 1
    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 40432
#include<stdio.h>
int main(void){
  int N,i,max,sum=1;
  int H[20];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&H[i]);
  }
  max=H[0];
  for(i=1;i<N;i++){
    if(max<=H[i]){
      sum++;
      max=H[i];
    }
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 128
import math
K=int(input())
ans=0
A=0

for n in range(1,K+1):
    for m in range(1,K+1):
        x=math.gcd(n,m)
        for l in range(1,K+1):
            A=math.gcd(x,l)    
            ans+=A
            
print(ans)


Measured memory_bytes: 9200
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,w[110],sum2=0,sum1=0,ans=1e9;

int main()
{
	cin>>n;
	rep(i,n) cin>>w[i],sum2+=w[i];
	rep(i,n-1)
	{
		sum1+=w[i];
		sum2-=w[i];
		ans=min(ans,abs(sum1-sum2));
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define testcase ll tt; cin>>tt; while(tt--)
#define pb push_back
#define nn cout<<"\n"
#define MOD 1000000007
#define vll vector<ll>
#define here cout<<"I'm here\n";
template<class T> void dispvector(vector<T> v){for(int i=0;i<v.size();i++) cout<<v[i]<<" "; nn;}
void vout(vector<ll> ans){
    for(auto ele:ans) cout<<ele;
}

int main() {
    SPEED;
    cout.precision(8);
    cout << fixed;
    string s;
    cin>>s;
    bool flag=true;
    if(s.size()%2==0){
        flag=false;
        cout<<"No";
        return 0;
    }
    ll n=s.size();
    ll m=n/2;
    // m--;
    // bool flag=true;
    for(ll i=m;i>=0;i--){
        if(s[i]!=s[n-i-1]){
            flag=false;
            break;
        }
    }
    if(!flag){
        cout<<"No";
        return 0;
    }
    else{
        
        if(m%2==0){
            m--;
            bool flag2=true;
            for(ll i=0;i<=m;i++){
                if(s[i]!=s[m-i]){
                    flag2=false;
                    break;
                }
            }
            if(!flag2){
                cout<<"No";
                return 0;
            }
            else{
                cout<<"Yes";
                return 0;
            }
        }
        
        else{
            bool flag3=true;
           for(ll i=0;i<m;i++){
               if(s[i]!=s[m-i-1]){
                   flag3=false;
                   break;
               }
           } 
           if(!flag3){
               cout<<"No";
               return 0;
           }
           else{
               cout<<"Yes";
               return 0;
           }
        }
    }
    return 0;
}

Measured memory_bytes: 256
S = input()
result = 'Yes'
N = len(S)
S = '-' + S
for i in range(1, N + 1):
    if S[i] != S[N - i + 1]:
        result = 'No'
for i in range(1, (int((N - 1) / 2)) + 1):
    if S[i] != S[int((N - 1) / 2) - i + 1]:
        result = 'No'
for i in range(int((N + 3) / 2), N + 1):
    if S[i] != S[N - i + 1]:
        result = 'No'
print(result)


Measured memory_bytes: 3064
N, M = map(int, input().split())

l = ["a"] * N

for i in range(M):
    s, c = map(int, input().split())
    if l[s-1] == "a" or l[s-1] == c:
        l[s-1] = c
    else:
        print(-1)
        exit()

if l[0] == "a" and N != 1:
    l[0] = 1
elif l[0] == 0 and N != 1:
    print(-1)
    exit()
#elif l[0] == 0 and N == 1:


for i in range(N):
    if l[i-1] == "a":
        l[i-1] = 0

l = [str(i) for i in l]
print("".join(l))

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

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

int main(){
    double a[11];
    double fi;
    while(cin>>fi){
        rep(i,11) a[i]=0;
        a[0]=fi;
        for(int i=1;i<11;i++){
            if(i%2==1){
                a[i]=a[i-1]*2;
            }else{
                a[i]=a[i-1]/3;
            }
        }
        double sum=0;
        for(int i=0;i<10;i++) sum+=a[i]; 
        cout<< fixed <<setprecision(7) << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 1276
#include<iostream>
#include<vector>
#include<set>
#include<bitset>
#include<algorithm>
using namespace std;

const int N = 49;

int w, h;
vector<vector<int>> field;
int size;
vector<vector<int>> vertex;
vector<vector<int>> edge;
bitset<N> visited;
set<unsigned long long> memo;

void make_graph() {
    enum {Y, X};
    const int NEXT[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
    const int NIL = -1;
    size = 0;
    vertex = vector<vector<int>>(h, vector<int>(w, NIL));
    for(int y = 0; y < h; ++y) for(int x = 0; x < w; ++x) if(!field[y][x]) vertex[y][x] = size++;
    edge = vector<vector<int>>(h * w, vector<int>());
    for(int y = 0; y < h; ++y) for(int x = 0; x < w; ++x) {
        if(vertex[y][x] == NIL) continue;
        for(const auto &d: NEXT) {
            int ny = y + d[Y];
            int nx = x + d[X];
            if(ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
            if(vertex[ny][nx] == NIL) continue;
            edge[vertex[y][x]].push_back(vertex[ny][nx]);
        }
    }
};

void reachability(int from, bitset<N> &visited) {
    visited.set(from);
    for(const auto &to: edge[from]) if(!visited[to]) reachability(to, visited);
}
bool cut_vertex(int from) {
    auto dup = visited;
    dup.set(from);
    for(const auto &to: edge[from]) {
        if(dup[to]) continue;
        reachability(to, dup);
        return dup.count() != size;
    }
    return dup.count() != size;
}

bool dfs(int start, int from) {
//     cout<<visited<<" "<<from<<endl;
    unsigned long long m = visited.to_ullong() * N + from;
    if(memo.count(m)) return false;
    memo.insert(m);

    // startの四方が囲まれていたらダメ
    bool deadend = true;
    for(const auto &v: edge[start]) deadend &= visited[v];
    if(deadend) return false;

    // cut vertexはダメ
    if(cut_vertex(from)) return false;

    // 現在地以外で次数1の頂点があるとダメ
    for(int u = 0; u < size; ++u) {
        if(u == from) continue;
        if(visited[u]) continue;
        int degree = 0;
        for(const auto& v: edge[u]) if(v == start || !visited[v]) ++degree;
        if(degree < 2) return false;
    }

    visited.set(from);
    for(const auto &to: edge[from]) {
        if(to == start && visited.count() == size) return true;
        if(visited[to]) continue;
        if(dfs(start, to)) return true;
    }
    visited.reset(from);
    return false;
}

bool solve() {
    visited = bitset<N>(0);
    make_graph();
    memo.clear();
    for(int y = 0; y < h; ++y) for(int x = 0; x < w; ++x) if(!field[y][x]) return dfs(vertex[y][x], vertex[y][x]);
    return false;
}

int main() {
    while(cin >> w >> h, w | h) {
        field = vector<vector<int>>(h, vector<int>(w));
        for(auto &line: field) for(auto &v: line) cin >> v;
        cout << (solve() ? "Yes" : "No") << endl;
    }
}

Measured memory_bytes: 15324
//
//  main.cpp
//  ABC122
//
//  Created by hiroaki on 2019/03/24.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    
    //B
    string s;
    cin >> s;
    long l = s.size();
    int longest=0;
    int log_long=0;
    for (int i=0; i<l; i++) {
        if (s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T') {
            log_long = 1;
        for (int j=0; j<l-1-i; j++) {
            if (s[i+1+j]!='A'&&s[i+1+j]!='C'&&s[i+1+j]!='G'&&s[i+1+j]!='T') {
                break;
            }else{
                log_long++;
            }
          }
            if (log_long>longest) {
                longest=log_long;
            }
        }
    }
    cout<<longest<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
	int f[50000] = {1,1};
	for(int i = 2; i < 25000; i++){
		f[i * 2] = 1;
	}
	for(int i = 3; i <= 224; i += 2){
		for(int j = 3; j * i < 50000; j += 2){
			f[i*j] = 1;
		}
	}

	int n;
	scanf("%d", &n);
	while(n){
		int count = 0;
		for(int i = 2; i * 2 <= n; i++){
			if(!f[i] && !f[n-i]){
				count++;
			}
		}
		printf("%d\n", count);
		scanf("%d", &n);
	}

}

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

int main()
{
    std::int64_t N;
    std::cin >> N;
    std::vector<std::int64_t> As(N);
    for(auto& A : As)
    {
        std::cin >> A;
    }

    std::sort(As.begin(), As.end(), std::greater<std::int64_t>{});

    std::int64_t sat   = 0;
    std::int64_t score = -As.front();
    for(const auto A : As)
    {
        sat += 1;
        score += A;
        if(sat == N) {break;}
//         std::cerr << sat << "people sat, confortability = " << score << std::endl;

        sat += 1;
        score += A;
        if(sat == N) {break;}
//         std::cerr << sat << "people sat, confortability = " << score << std::endl;
    }

    std::cout << score << std::endl;
    return 0;
}


Measured memory_bytes: 4836
#include<stdio.h>

int dp[50];

int fib(int n){
  if(n==0 ||n==1)return 1;
  if(dp[n]!=-1)return dp[n];
  return dp[n]=fib(n-1)+fib(n-2);
}

int main(){
  int n,i;
  for(i=0;i<50;i++)dp[i]=-1;
  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}



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

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

  int ans = 0;
  rep(i,0,S.size()-1) {
    if (S[i] != T[i]) ans++;
  }

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


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define F           first
#define S           second
#define ld          long double
#define rep(i,a,b)  for(ll i=a;i<b;i++)
 
void solve()
{
    ll n; cin>>n;
    ll a[n+1];
    for(ll i=1; i<=n; i++) cin>>a[i];
    ll dp[n][n];
    ll sum[n+1];
    memset(sum, 0, sizeof sum);
    for(ll i=1; i<=n; i++) sum[i]=sum[i-1]+a[i];
    for(ll L=n-1; L>=0; L--) {
        for(ll R=L; R<n; R++) {
            if(L==R) {
                dp[L][R] = 0;
            } else {
                ll s = sum[R+1] - sum[L];
                dp[L][R] = 1e15+5;
                for(ll i=L; i<R; i++) {
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + s);
                }
            }
        }
    }
    ll ans = dp[0][n-1];
    cout<<ans<<endl;
}

int main() {
	ll T = 1;
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
int main(){
  long long a,b,c,d,e,x1,x2,x3;
  scanf("%lld %1lld.%1lld%1lld",&a,&b,&c,&d);
  e=((a*c)%10*10)+((a*d)%100);
  x1=a*b;
  x2=(a*c)/10;
  x3=(a*d)/100;
  printf("%lld\n",x1+x2+x3+(e/100));
  return 0;
}


Measured memory_bytes: 1736
#include<cstdio>
#define mid ((l+r+1)>>1)
using namespace std;
int n,a[100001],ans,num[100001]; 
inline int rd()
{
	char tmp=getchar();
	int ddd=0;
	while('0'>tmp&&tmp<'9')
	{
		tmp=getchar();
	}
	while('0'<=tmp&&tmp<='9')
	{
		ddd=(ddd<<3)+(ddd<<1)+(tmp^48);
		tmp=getchar();
	}
	return ddd;
}
inline int Find(int x)
{
	int l=0,r=ans;
	while(l+1<r)
	{
		if(num[mid]>=x)
		{
			l=mid;
		}
		else
		{
			r=mid;
		}
	}
	num[r]=x;
}
int main()
{
	n=rd();
	num[0]=0x7fffffff;
	for(int i=1;i<=n;++i)
	{
		a[i]=rd();
		if(a[i]<=num[ans])
		{
			num[++ans]=a[i];
		}
		else
		{
			Find(a[i]);
		}
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  int total =0;
  for (int i = 0; i < N; i++) {
  cin >> p.at(i);
    total += p.at(i);
  }
  int a;
  for (int i = 0; i < N; i++) {
  a = max(p.at(i), a);
  }
  cout << total - a/2 << endl;
}

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

using namespace std;

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
    vector < int > a;
    for (int i = 0; i < 5; ++i) {
        cin >> x;
        a.push_back(x);
    }
    for (int i = 0; i < 5; ++i) {
        if (a[i] == 0) {
            cout << i + 1;
            exit(0);
        }
    }
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)

#define SORT(c) sort((c).begin(),(c).end())
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
VI F;

int main(int argc, char const *argv[]) {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; std::cin >> n;
  F.reserve(100);
  F.PB(1); F.PB(1);
  for (int i = 2; i <= n; i++) {
    F.PB(F[i-1]+F[i-2]);
  }
  std::cout << F[n] << '\n';
  return 0;
}



Measured memory_bytes: 3228
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nm = Input.ar;
        var adj = Enumerable.Repeat(0, nm[0]).Select(_ => new List<int>()).ToArray();
        for(var i = 0; i < nm[1]; i++)
        {
            var inp = Input.ar;
            adj[inp[0] - 1].Add(inp[1] - 1);
            adj[inp[1] - 1].Add(inp[0] - 1);
        }
        var color = new int[nm[0]];
        if (isBip(color, adj, 0, 1))
            WriteLine((long)color.Count(v => v == 1) * color.Count(v => v == 2) - nm[1]);
        else WriteLine((long)nm[0] * (nm[0] - 1) / 2 - nm[1]);
    }
    private static bool isBip(int[] color,List<int>[] adj,int index,int c)
    {
        color[index] = c;
        var r = true;
        foreach (var ad in adj[index])
            if (r && color[ad] == 0)
                r = isBip(color, adj, ad, 3 - c);
            else r &= color[ad] == 3 - c;
        return r;
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18/2;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

using namespace std;

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

    int n,a;
    cin >> n >> a;

    if (n%500 <= a) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

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

int main() {
  int A,B,x,i=0;
  cin >>A >>B ;
 
  for(x=A;x<=B;x++){      
   
    if(x/10000==x%10) {
      if(x%10000/1000==x%100/10) i++;
    }
 
  }
  
  cout <<i;
      
}

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

#define ll long long 

using namespace std;

ll n,m;
vector < pair <ll,ll> > stores;
ll price;
ll aux,aux1;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    for (int i=0; i<n; i++){
        cin>>aux;
        cin>>aux1;
        stores.push_back({aux,aux1});
    }
    
    sort(stores.begin(),stores.end());

    for (int i=0; i<n; i++){
        if(m==0) break;
        if(stores[i].second >= m){
            price+=stores[i].first*m;
            m-=m;
        }
        else{
            m-=stores[i].second;
            price+=stores[i].first*stores[i].second;
            
        }
        
    }
    
    cout<<price;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define all(s) s.begin(),s.end()
#define pb push_back
#define uno unordered_map
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define foreach(var,i) for(auto i = var.begin();i!=var.end();i++)
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
ll power(ll a, ll n) {ll res = 1; while (n) {if (n % 2) {res *= a;} n >>= 1; a *= a;} return res;}
ll powerm(ll a, ll n, ll m) {ll res = 1; while (n) {if (n % 2) {res = (res * a) % m;} n >>= 1; a = (a * a) % m;} return res;}
const int M=1e9+7;
ll mod(ll x){
      return ((x%M + M)%M);
}
ll add(ll a, ll b){
      return mod(mod(a)+mod(b));
}
ll mul(ll a, ll b){
      return mod(mod(a)*mod(b));
}

const int maxx = 1e6+5;

int main(){
	fast();
	int t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		vector<int> cn(maxx,0);
		int x;
		for(int i=0;i<n;i++){
			cin>>x;
			cn[x]++;
		}
		int c=0;
		vector<int> vis(maxx,0);
		for(int i=1;i<=1000000;i++){
			if(cn[i]==0 || vis[i]){
				continue;
			}
			if(cn[i]==1 && !vis[i]){
				c++;
			}
			for(int j=i;j<=1000000;j+=i){
				vis[j] = 1;
			}
		}	
		cout<<c<<endl;
	}
	
	return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int x = 0, ans = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'I')
      x++;
    else if (S[i] == 'D')
      x--;
    ans = max(ans, x);
  }
  cout << ans << endl;
}

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

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

int main() {
    int n, k;
    cin >> n >> k;
    if ( n % k == 0 ) cout << 0 << endl;
    else              cout << 1 << endl;
    return 0;
}

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

int main(int argc, char const *argv[]) {
  int a, b;
  cin >> a >> b;
  int sum = 0;
  for(int i = 1; i < b-a; i++) {
    sum += i;
  }
  cout << sum - a << endl;
  return 0;
}


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

int main() {
  unsigned int N, K;
  std::cin >> N >> K;
  std::vector<unsigned int> l(N);
  for (unsigned int i = 0; i < N; ++i) std::cin >> l[i];

  std::sort(l.begin(), l.end());
  std::reverse(l.begin(), l.end());
  unsigned int res = 0;
  for (unsigned int i = 0; i < K; ++i) res += l[i];

  std::cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  vector<int>vec(5);
  for(int i=0;i<5;i++)cin>>vec[i];
  sort(vec.begin(),vec.end());
  int MIN=INF;
  do{
    int sum=0;
    for(int i=0;i<5;i++){
      sum+=vec[i];
      if(i==4)continue;
      sum=((sum+10-1)/10)*10;
      
      }
    //cout<<sum<<endl;
    MIN=min(MIN,sum);
  }while(next_permutation(vec.begin(),vec.end()));
  cout<<MIN<<endl;
}
    
    
      

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
    Node *cur = nil->next; // 番兵の次の要素から辿る
    while ( cur != nil && cur -> key != key ) {
       cur = cur -> next;
    }
    return cur;
}

void init() {
   nil = (Node *)malloc(sizeof(Node));
   nil->next = nil;
   nil->prev = nil;
}

void printList(){
    Node *cur = nil->next;
    int isf = 0;
    while( 1 ) {
        if(cur == nil) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur -> next;
    }
    printf("\n");
}

void deleteNode(Node *t){
     if( t == nil ) return;
     t->prev->next = t->next;
     t->next->prev = t->prev;
     free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deleteKey(int key){
   deleteNode(listSearch(key));
}

void insert(int key){
     Node *x = (Node *)malloc(sizeof(Node));
     x->key = key;
     x->next = nil->next;
     nil->next->prev = x;
     nil->next = x;
     x->prev = nil;
}

int main(){
   int key, n, i;
   int size = 0;
   char com[20];
   int np = 0, nd = 0;
   scanf("%d", &n);
   init();
   for( i = 0; i < n; ++i){
      scanf("%s%d", com, &key);
      if(com[0] == 'i' ) { insert(key); np++; size++;}
      else if (com[0] == 'd') {
          if (strlen(com) > 6) {
              if(com[6] == 'F') deleteFirst();
              else if(com[6] == 'L') deleteLast();
          } else {
              deleteKey(key); nd++;
          }
          size--;
        }
      }

      printList();

      return 0;
}


Measured memory_bytes: 33824
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	VI a(n);
	VI b(m);
	REP(i, n) { cin >> a[i]; }
	REP(i, m) { cin >> b[i]; }
	vector<ll> as(n + 1);
	vector<ll> bs(m + 1);
	as[0] = bs[0] = 0;
	REP(i, n) { as[i + 1] = as[i] + a[i]; }
	REP(i, m) { bs[i + 1] = bs[i] + b[i]; }
	int j = m;
	int result = 0;
	REP(i, n + 1) {
		while(as[i] + bs[j] > k && j >= 0) {
			j--;
		}
		if(j < 0) {
			continue;
		}
		chmax(result, i + j);
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 7956
H, W = gets.split.map(&:to_i)
M = H.times.map{ gets.chomp }

POSS = [
  [-1, -1], [0, -1], [1, -1],
  [-1,  0],          [1,  0],
  [-1,  1], [0,  1], [1,  1],
]
def get(x, y)
  if (0...W) === x && (0...H) === y
    M[y][x]
  else
    nil
  end
end
def count(x, y)
  POSS.map{|dx, dy|
    get(x+dx, y+dy) == "#" ? 1 : 0
  }.inject(:+)
end

H.times do |y|
  W.times do |x|
    if M[y][x] == "#"
      print "#"
    else
      print count(x, y)
    end
  end
  puts
end


Measured memory_bytes: 1788
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n, 0), b(n);
	rep(i,n){
		cin >> b[i];
		if(i%2 == 0) a[0] += b[i];
		else a[0] -= b[i];
	}
	cout << a[0];
	for(int i = 1; i < n; ++i){
		a[i] = 2 * b[i-1] - a[i-1];
		cout << " " << a[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2944
class binaryindexedtree():
  def __init__(self,n):
    self.n=n
    self.tree=[0]*n
  def add(self,a,w):
    x=a
    while x<=self.n:
      self.tree[x-1]+=w
      x+=x&(-x)
  def sums(self,a):
    x=a
    S=0
    while x!=0:
      S+=self.tree[x-1]
      x-=x&(-x)
    return S
n,q=map(int,input().split())
a=list(map(int,input().split()))
bit=binaryindexedtree(n)
for i,x in enumerate(a,1):
  bit.add(i,x)
ans=[]
for _ in range(q):
  x,y,z=map(int,input().split())
  if x:ans+=[bit.sums(z)-bit.sums(y)]
  else:bit.add(y+1,z)
print(*ans,sep='\n')

Measured memory_bytes: 151856
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define N 3009
#define inf 1e18
int mod=1e9+7;
int maxN=1e9;

#define P pair<int,int>

P v[N];
int dp[N][N];
int n;

int fun(int idx,int l,int r){
    if(idx>n)return 0;
    int &ans=dp[l][r];
    if(ans!=-1)return ans;
    int x=abs(l-v[idx].second)*v[idx].first+fun(idx+1,l+1,r);
    int y=abs(r-v[idx].second)*v[idx].first+fun(idx+1,l,r-1);
    ans=max(x,y);
    return ans;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;cin>>x;
        v[i].first=x;
        v[i].second=i;
    }
    sort(v+1,v+n+1);
    reverse(v+1,v+1+n);
    memset(dp,-1,sizeof(dp));
    cout<<fun(1,1,n)<<"\n";
   
    return 0;
}

Measured memory_bytes: 74516