akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	// Code for A - Rainy Season
	var S string
	fmt.Scanf("%s", &S)
	var count int
	var max int = 0
	for i := 0; i < 3; i++ {
		if S[i] == 'R' {
			count++
			if max < count {
				max = count
			}
		} else {
			count = 0
		}
	}

	fmt.Println(max)
}


Measured memory_bytes: 1836
import collections


if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    q = int(input())
    key = [i for i in range(10**5+1)]
    val = [0]*(10**5+1)
    dict = dict(zip(key,val))
    dict.update(collections.Counter(a))
    ans = sum(a)

    for i in range(q):
        b, c = map(int, input().split())
        ans= ans - b*dict[b] + c*dict[b]
        count = dict[b]
        dict[b]=0
        dict[c]+=count
        print(ans)





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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int N;
	cin >> N;
	vec(A);
	fx(N) {
		vecp(A);
	}
	ll ans = N;
	int sum = A[0];
	int Xor = A[0];
	ll l = 0, r = 1;
	while (l<N) {
		while (r<N&&sum+A[r]==(Xor^A[r])) {
			sum += A[r];
			Xor ^= A[r++];
		}

		ans += (r - l-1);
		sum -= A[l];
		Xor ^= A[l++];
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 1400
#include <stdio.h>

int main(void) {
	int i,j,p,n,num,c[4][13]={0};
	char s[2],ref[]="SHCD";
	scanf("%d",&n);
	while (n--){
		scanf("%s %d",&s,&num);
		if (s[0]=='S') p=0;
		if (s[0]=='H') p=1;
		if (s[0]=='C') p=2;
		if (s[0]=='D') p=3;
		c[p][num-1]=1;
	}
	for (i=0;i<4;i++){
		for (j=0;j<13;j++){
			if (c[i][j]==0){
				printf("%c %d\n",ref[i],j+1);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Rounding | diff Rounding.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Rounding.cpp && ./a.out

/*
 
 6/16/2019
 
 5:00-
 
 */

int X,A;

int solve() {
  if(X<A) return 0;
  else return 10;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>X>>A;
  cout<<solve()<<endl;
  
  return 0;
}


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

h,n = l_in()
ab = []
for _ in range(n):
    ab.append(l_in())
    
## dp[i][x] iまでの魔法をいくつ使うか確定させて，ダメージがxの時の最小魔力
dp = [10**8 for _ in range(2*h)]

dp[0] = 0

for x in range(1, h+1):
    for a,b in ab:
        if x-a >= 1:
            dp[x] = min(dp[x], dp[x-a]+b)
        else:
            dp[x] = min(dp[x], b)

print(min(dp[h:]))


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

#define ll long long
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define PP pair<P,int>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define all(a) (a).begin(),(a).end()


signed main(){
    int n;
    cin>>n;
    int mi=114514,ma=-810;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        ma=max(ma,t);
        mi=min(mi,t);
    }
    cout<<ma-mi<<endl;

    return 0;
}

Measured memory_bytes: 256
S = str(input())
l = len(S)
st = 0
en = 0
for i in range(l):
    if S[i] == 'A':
        st = i
        break
for j in range(l-1,-1,-1):
    #print(j)
    if S[j] == 'Z':
        en = j
        break
#print(st,en)
print(en-st+1)

Measured memory_bytes: 9204
#include <stdio.h>
int main(void){
	int n;
	scanf("%d",&n);
	if(n==1){
		printf("%d",1);
	}
	else if(n%2==0){
		printf("0.5");
	}
	else{
		printf("%f",(float)(n+1)/(2*n));
	}
return(0);
}

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

using namespace std;
using ll=long long;
// when range [l, r), has property notP~P, want first P.
// when return r, means not found.
template <typename T>
T bs_first(T l, T r, function<bool (T)> f) {
    assert(l < r);
    T mid;
    while (l != r) {
        mid = l + (r-l)/2;
        if (f(mid)) {
            r = mid;
        }else {
            l = mid + 1;
        }
    }
    return r;
}

void solve() {
    ll x; cin >> x;
    ll n = bs_first<ll>(1, 100000, [&](ll n){
            return n*(n+1)/2 >= x;
            });
    cout << n;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int n,q;
string s;
vector<set<int>> chara(26);
vector<int> ans;
int main(){
    clock_t start,end;
    cin >> n >> s >> q;
    start=clock();
    rp(i,n){
        chara[s[i]-'a'].insert(i);
    }
    rp(i,q){
        int t;
        cin >> t;
        if(t==1){
            int a;
            char c;
            cin >> a >> c;
            a--;
            int cint=c-'a';
            int bef=s[a]-'a';
            if(s[a]==c) continue;
            s[a]=c;
            chara[bef].erase(a);
            chara[cint].insert(a);
            
        }
        if(t==2){
            int l,r;
            cin >> l >> r;
            l--; r--;
            int ctr=0;
            rp(j,26){
                auto ite=chara[j].lower_bound(l);
                if(ite!=chara[j].end()&&*ite<=r) {ctr++;}
            }
            ans.push_back(ctr);
        }
    }
    /*auto it=chara[3].begin();
    print(*it);
    print(s);*/
    for(auto an:ans){
        cout << an << endl;
    }
    end=clock();
    //print(to_string((double)(end-start)));
    return 0;
}

Measured memory_bytes: 24452
# -*- coding: utf-8 -*-

N, W = [int(t) for t in input().split()]
item = [tuple(int(t) for t in input().split()) for _ in range(N)]

MAX_V = sum(v for v, w in item)

# weight[u] = 品物 0〜i だけ, かつ価値 u になる最小の重さ
weight = {u: float('inf') for u in range(MAX_V + 1)}
weight[0] = 0

# 品物の種類をだんだん増やす
for v, w in item:
    weight = {u: (min(weight[u - v] + w, weight[u]) if u >= v else weight[u])
              for u in range(MAX_V + 1)}

v = max(v for v in weight if weight[v] <= W)
print(v)



Measured memory_bytes: 7536
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function root(uf::Array{Int,1},x)
	s = x
	while uf[s] != s
		s = uf[s]
	end
	s
end

function find(uf::Array{Int,1},x,y)
	s = x
	t = y
	while uf[s] != s
		s = uf[s]
	end
	while uf[t] != t
		t = uf[t]
	end
	s==t?true:false
end

function main()
	n,m = readline() |> split |> parseMap
	p = readline() |> split |> parseMap
	uf = [i for i in 1:n]
	for i in 1:m
		x,y = readline() |> split |> parseMap
		l = root(uf,x)
		r = root(uf,y)
		if l < r
			uf[r] = l
		else
			uf[l] = r
		end
	end
	for i in 1:n
		uf[i] = root(uf,uf[i])
	end
	count = 0
	for i in 1:n
		if uf[p[i]] == uf[i]
			count += 1
		end
	end
	println(count)
end
main()

Measured memory_bytes: 170752
#include<stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define max(p,q)((p)>(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))

ll n;
ll a[1010];
ll e,o;
ll M=-INF,Mi;
ll ans[1010],anscnt;

void del(ll n){
	//-1を削除
	ll i=0;
	while(a[0]==-1){
		ans[anscnt++]=0;
		rep(i,0,n)a[i]=a[i+1];
		n--;
	}
	while(a[n-1]==-1){
		ans[anscnt++]=n-1;
		a[n-1]=0;
		n--;
	}
	ll flag=1;
	while(flag){
//		rep(i,0,n)printf("%d ",a[i]);printf("%d\n",n);
		flag=0;
		for(ll i=1;i<n-1;i++)if(a[i]==-1&&a[i-1]==a[i+1]){
			ans[anscnt++]=i;
			rep(j,i-1,n)a[j]=a[j+2];		
			n-=2;
			flag=1;
		}
	}
}

int main(){
	scanf("%lld",&n);
	//偶奇どっちを残すか決める
	//oxoxxxo→xが1つならそれ、2つ以上続くなら左から2番目を選択(n-1)/2回選択した後左端を選ぶ
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		if(t>M)M=t,Mi=i;
		if(t>0){
			a[i]=1;
			if(i%2)o+=t;
			else e+=t;
		}else{
			a[i]=-1;
		}
	}
	
	if(M<=0){
		printf("%lld\n%lld\n",M,n-1);
		for(ll i=n-1;i>Mi;i--)printf("%lld\n",i+1);
		rep(i,0,Mi)printf("%lld\n",1);
	}else{
		if(o>e)repp(i,0,n,2)a[i]=-1;
		else repp(i,1,n,2)a[i]=-1;
		del(n);
		printf("%lld\n%lld\n",max(e,o),anscnt);
		rep(i,0,anscnt)printf("%lld\n",ans[i]+1);
	}
	return 0;
}

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

using namespace std;

int selectionSort(int a[], int n)
{
	int count = 0;
	for (int i = 0; i < n; i++) {
		int index = i;
		for (int j = i + 1; j < n; j++) {
			if (a[index] > a[j]) {
				index = j;
			}
		}
		if (i != index) {
			count++;
			swap(a[i], a[index]);
		}
	}
	return count;
}

int main(void)
{
	int N;
	int A[100];

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int count = selectionSort(A, N);
	cout << A[0];
	for (int i = 1; i < N; i++) {
		cout << ' ' << A[i];
	}
	cout << endl << count << endl;

	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int maks = 0;
const int N = 2e5 + 1;
int u,n,arr[N];
int main()
{
    cin >> u >> n;
    for(int i = 0; i < n; i++){
        scanf("%d",&arr[i]);
    }
    maks = arr[0] + u - arr[n-1];
    for(int i = 1; i < n; i++){
        maks = max(maks,arr[i] - arr[i-1]);
    }
    cout << u - maks;
    return 0;
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> height(n);
    for(int i = 0; i < n; i++)
        cin >> height[i];
    vector<int> dp(n + 1, INT_MAX);
    dp[1] = 0;
    for(int i = 2; i <= n; i++)
    {
        for(int j = 1; i - j - 1 >= 0 && j <= k; j++)
            dp[i] = min(abs(height[i - j - 1] - height[i - 1]) + dp[i - j], dp[i]);
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	int res=0;
	res=(n-1)/(k-1);
	if((n-1)%(k-1)!=0)res++;
	cout<<res<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int a,b,i,j;
  while(1){
  cin>>a;
  if(a==0) break;
  vector<char>from(a);
  vector<char>to(a);
  for(i=0;i<a;i++){
    cin>>from[i]>>to[i];
  }
  cin>>b;
  vector<char>v(b);
  for(i=0;i<b;i++){
    cin>>v[i];
    for(j=0;j<a;j++){
      if(v[i]==from[j]){
        v[i]=to[j];
        break;
      }
    }
  }
  for(i=0;i<b;i++){
    cout<<v[i];
  }
  cout<<"\n";
}
return 0;
}

Measured memory_bytes: 3080
function main(input){

    const data = input.split(' ')
    const a = parseInt(data[0], 10)
    const b = parseInt(data[1], 10)

    if((a * b) % 2 === 0){
        console.log("Even");
    }else{
        console.log("Odd")
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
n, q = gets.split.map(&:to_i)
s = gets.chomp

csum = Array.new(n+1, 0)
for i in 0..n - 1
    if i <= n - 2
        if s[i..i+1] == 'AC'
            csum[i+1] += 1
            s[i] = 'a'
        end
    end
    csum[i+1] += csum[i]
end

q.times do
    l, r = gets.split.map(&:to_i)
    l -= 1
    puts csum[r-1] - csum[l]
end


Measured memory_bytes: 15260
#include"iostream"
using namespace std;
int n,ans;
string s[4];
int main(){
	cin>>n>>s[1]>>s[2]>>s[3];
	for(register int i=0;i<n;i++){
		if(s[1][i]==s[2][i]&&s[2][i]==s[3][i]);
		else if((s[1][i]==s[2][i])||(s[1][i]==s[3][i])||(s[2][i]==s[3][i]))ans+=1;
		else ans+=2;
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int m=scn.nextInt();
		HashSet<Integer> set=new HashSet<>();
		HashSet<Integer> s=new HashSet<>();
		for(int i=0;i<n;i++) {
			int k=scn.nextInt();
			//System.out.println(s+" "+set);
			s=new HashSet<>();
			for(int j=0;j<k;j++) {
				int x=scn.nextInt();

				if(i==0) {
					set.add(x);
					s.add(x);
				}else {
					if(set.contains(x)) {
						s.add(x);
					}
				}
			}
			if(i!=0) {
				set.removeAll(set);
				set.addAll(s);
			}
		}
		System.out.println(s.size());
	}

}


Measured memory_bytes: 23496
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t N,K;
    cin>>N>>K;

    while(1){
        int64_t x;
        if(N>K){
            int64_t a=max(N,K),b=min(N,K);
            x=a/b;
            x*=b;
            x=a-x;
        }else{
            x=min(N,K-N);
        }
        if(x<N) N=x;
        else break;
        if(N==0) break;
    }

    cout<<N<<endl;
}

Measured memory_bytes: 384
using System;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            string[] In= Console.ReadLine().Split(' ');
            int n = int.Parse(In[0]);
            int m = int.Parse(In[1]);
            string[] In2 = Console.ReadLine().Split(' ');
            for(int i=0; i<m; i++)
            {
                n -= int.Parse(In2[i]);
            }
            if (n >= 0) Console.WriteLine(n);
            else Console.WriteLine(-1);

        }
    }
}

Measured memory_bytes: 28460
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         long[] tmp = ReadLine().Split(' ').Select(long.Parse).ToArray();
         long X = tmp[0], Y = tmp[1];
         if(X % Y == 0){
             WriteLine(-1);
             return;
         }
         int i = 2;
         while(true){
             if((X*i) % Y != 0){
                 WriteLine(X*i);
                 return;
             }
             i++;
         }
      }
   }
}

Measured memory_bytes: 13396
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
using namespace std;

int main() {
	string s;
	cin >> s;
	long long ans = 0;
	int b_count = 0;
	for (char c : s) {
		if (c == 'B') {
			b_count += 1;
		}
		if (c == 'W') {
			ans += b_count;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main () {
  int K ; 
  cin >> K ; 
  
  int64_t T = 0 ; 
  
  for(int i = 1 ; i <= K ; i++){
    for(int j = 1 ; j <= K ; j++){
      for(int k = 1 ; k <= K ; k++ ){
        T += gcd(gcd(i , j ) , k ) ; 
      }
    }
  }
  cout << T << endl ; 

}

Measured memory_bytes: 3588
int main(void){
    int r,d,x[100],i;
	scanf("%d %d %d",&r,&d,&x[0]);
	for(i=0;i<10;i++){
		printf("%d\n",r*x[i]-d);
		x[i+1]=r*x[i]-d;
	}
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n = int(input().strip())

    sum = 0
    for i in range(1, n + 1):
        sum += i if i % 3 != 0 and i % 5 != 0 else 0
    print(sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9160
#include <stdio.h>


int main()
{
	int a,i,j;
	int vc[1000];
	int vd[1000];
	int ve[1000];
	int max[1000];
	int sec[1000];
	int thi[1000];

	scanf("%d",&a);

	for(i=0;i<a;i++){
		scanf("%d",&vc[i]);
		scanf("%d",&vd[i]);
		scanf("%d",&ve[i]);
	}

	for(i=0;i<a;i++){
		max[i] = vc[i];
		sec[i] = vd[i];
		thi[i] = ve[i];
		if(thi[i]>=sec[i]){
			j = sec[i];
			sec[i] = thi[i];
			thi[i] = j;
		}
		if(sec[i]>=max[i]){
			j = max[i];
			max[i] = sec[i];
			sec[i] = j;
		}
		if(max[i]*max[i]==sec[i]*sec[i]+thi[i]*thi[i])
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 588
N,M=map(int,input().split())
H=list(map(int,input().split()))
result=[]
for h in range(N):
    result.append(0)
for i in range(M):
    A,B=map(int,input().split())
    result[A-1]=max(result[A-1],H[B-1])
    result[B-1]=max(result[B-1],H[A-1])
count=0
for j in range(N):
    if result[j]<H[j]:
        count+=1
print(count)

Measured memory_bytes: 20108
#include<bits/stdc++.h>
using namespace std;
bool a[205][205],b[205][205];
int has[205],n,ans,x,y; 
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>x>>y,a[x][y]=1;
	for(int i=0;i<n;i++)cin>>x>>y,b[x][y]=1;
	for(int i=0;i<n+n;i++)
	{
		for(int j=0;j<n+n;j++)
	    if(b[i][j])
		{
			int k=j-1;
			while(k>=0&&!has[k])k--;
			if(k>=0)has[k]--,ans++;
		}
		for(int j=0;j<n+n;j++)
		if(a[i][j])
		has[j]++;
	}
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

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

int keta(ll get)
{
	int ret = 0;
	ll a = 1;
	while(1) {
		if (get / a == 0) return ret;
		ret++;
		a *= 10;
	}
}

int main(void)
{
	ll n;
	cin >> n;
	ll mid = (ll)sqrt(n);

	for (ll k = mid; k > 0; k--) {
		if (n % k) continue;
		cout << keta(n / k) << endl;
		return 0;
	}
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    Ass = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(N)]

    games = []
    for i in range(N):
        for j in range(i+1, N):
            games.append(i*N+j)
    adjL = [[] for _ in range(N*N)]

    indegs = [0] * (N*N)
    for i, As in enumerate(Ass):
        for j in range(len(As)-1):
            p1, p2, p3, p4 = i, As[j], i, As[j+1]
            if p1 > p2:
                p1, p2 = p2, p1
            if p3 > p4:
                p3, p4 = p4, p3
            adjL[p1*N+p2].append(p3*N+p4)
            indegs[p3*N+p4] += 1

    gameTodays = set()
    for game in games:
        if indegs[game] == 0:
            gameTodays.add(game)

    ans = 0
    numDone = 0
    while gameTodays:
        gameTomorrows = set()
        for game in gameTodays:
            numDone += 1
            for game2 in adjL[game]:
                indegs[game2] -= 1
                if indegs[game2] == 0:
                    gameTomorrows.add(game2)
        ans += 1
        gameTodays = gameTomorrows

    if numDone == N*(N-1)//2:
        print(ans)
    else:
        print(-1)

solve()



Measured memory_bytes: 144304
s=input()
if len(s)==26:
	d=[]
	for i in range(26):
		if list(s[-i-1:][::-1])!=sorted(s[-i-1:]):
			for j in range(i+1):
				d.append(s[-j-1])
			d.sort()
			if d[0]==s[-i-1]:
				k=d[1]
			else:
				for j in range(len(d)):
					if d[j]>s[-i-1]:
						k=d[j]
						break
			print(s[:-i-1]+k)
			exit()
	print(-1)
	exit()
d=[0]*26
for i in range(len(s)):
	d[ord(s[i])-ord("a")]+=1
for i in range(26):
	if d[i]==0:
		x=chr(ord("a")+i)
		break
print(s+x)

Measured memory_bytes: 3064
/* ITP1_6_B */
import java.io.*;

class Main
{
  static final String[] SUIT = {"S", "H", "C", "D"};

  public static void main(String[] args)
  {
    boolean[][] cards = new boolean[4][13];

    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();

      int n = Integer.parseInt(br.readLine());
      if(n < 0 || n > 52) System.exit(-1);
      // check
      for(int i = 0; i < n; i++){
        String[] str = br.readLine().split(" ");
        String suit = str[0];
        int lank = Integer.parseInt(str[1]);

        if(suit.equals(SUIT[0])) cards[0][lank-1] = true;
        else if(suit.equals(SUIT[1])) cards[1][lank-1] = true;
        else if(suit.equals(SUIT[2])) cards[2][lank-1] = true;
        else if(suit.equals(SUIT[3])) cards[3][lank-1] = true;
        else
          System.exit(-1);
      }
      // output
      for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
          if(cards[i][j] != true) sb.append(SUIT[i] + " " + (j + 1) + "\n");
        }
      }
      System.out.print(sb);

    }catch(Exception e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 24144
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<(n);i++)
typedef long long ll;

ll gcd(ll a, ll b){
    if(a<b) swap(a,b);
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}

int main(){
    int x=0;
    cin >> x;
    cout << 1-x << endl;
}

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

#define ll long long int

void dfs(ll u, vector<ll>& val, vector<vector<ll>>& adj, ll prev) {
    for(int i = 0; i < adj[u].size(); i++) {
        if(adj[u][i] != prev) {
            val[adj[u][i]] += val[u];
            dfs(adj[u][i], val, adj, u);
        }
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    vector<vector<ll>> adj(n);
    vector<ll> val(n, 0);
    for(int i = 0; i < n - 1; i++) {
        ll u, v;
        cin >> u >> v;
        adj[u - 1].push_back(v - 1);
        adj[v - 1].push_back(u - 1);
    }
    for(int i = 0; i < q; i++) {
        ll u, v;
        cin >> u >> v;
        val[u - 1] += v;
    }
    dfs(0, val, adj, -1);
    for(int i = 0; i < n; i++)
        cout << val[i] << " ";
}

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

Char = [chr(97 + i) for i in range(N+10)]

ans = ["a"]
for i in range(N - 1):
    tmp = []
    for a in ans:
        rng = ord(max(a)) - 97
        for c in Char[: rng + 2]:
            tmp.append(a + c)
    ans = tmp

ans.sort()
print(*ans, sep="\n")


Measured memory_bytes: 14788
import java.util.*;

public class Main {

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

        long a = sc.nextLong();

        double money = 100;


        for (int i = 1; i < 1000000; i++) {
            money = Math.floor((double)money * 1.01);

            if (money >= a){
                System.out.println(i);
                return;
            }

        }

        sc.close();
    }

}

Measured memory_bytes: 35764
#include<stdio.h>
#define MAX 100000
#define NIL 200000000
struct Card{
  char suit;
  int value;
};
struct Card L[MAX/2+2],R[MAX/2+2];
void merge(struct Card A[],int n,int left ,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1].value=R[n2].value=NIL;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value)
      A[k]=L[i++];
    else A[k]=R[j++];
  }
}
void quick(struct Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quick(A,n,p,q-1);
    quick(A,n,q+1,r);
  }
}

void mergeSort(struct Card A[],int n,int left,int right){
  int mid;
  if(left + 1 < right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
    t=A[i];
  t=A[i+1];
  A[i+1]=A[r];
  A[j]=t;
  return i+1;
}


int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable=1;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%s %d", S, &v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
  mergeSort(A,n,0,n);
  quick(B,n,0,n-1);
  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit)stable=0;
  }
  if(stable==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++)
    printf("%c %d\n",B[i].suit,B[i].value);
  return 0;
}

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

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

    rep(i, 50000){
        if (floor(i * 1.08) == n) { 
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())

from math import factorial
def comb2(n):
    return factorial(n)//(2*factorial(n-2))
if n>=2 and m>=2:
    print(comb2(n)+comb2(m))
elif n>=2 and m<2:
    print(comb2(n))
elif n<2 and m>=2:
    print(comb2(m))
else:
    print(0)

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

def cnt(s):
    r = [0] * (len(s)+1)
    for i, v in enumerate(s):
        if v == '(':
            r[i+1] = r[i] + 1
        else:
            r[i+1] = r[i] - 1
    return r[0], r[-1], min(r)

# S1 := 始点 < 終点
S1 = []
# S2 := 始点 => 終点
S2 = []
for i in range(N):
    s = input()
    t = tuple(cnt(s))
    if t[1] > 0:
        S1.append(t)
    else:
        S2.append(t)
def main():
    # Sの終点を合計して0じゃなかったら、終わり
    if sum([s[1] for s in S1]) + sum([s[1] for s in S2]) != 0:
        print("No")
        return
    # S1の中で、最小値が大きい順に並べる
    X1 = sorted(S1, key=lambda x: x[2], reverse=True)
    # S2の中で、最小値が小さい順に並べる
    X2 = sorted(S2, key=lambda x: x[2]-x[1])
    T = 0
    # X1を並べきった後に、X2を並べて実現可能か調べる、終点を合計して0になることは確認済み
    for s, t, mi in X1:
        if T + mi < 0:
            print("No")
            return
        T += t
    for s, t, mi in X2:
        if T + mi < 0:
            print("No")
            return
        T += t
    print("Yes")

main()


Measured memory_bytes: 239472
function main(input){
    var num = input.split(" ");
    for(var i=0; i<num.length; i++){
        num[i] = Number(num[i]);
    }
    if(num[0]<=num[2]){
        if(num[2]>=num[1]){
            console.log(0);
        }else if(num[1]<=num[3]){
            console.log(num[1]-num[2]);
        }else{
            console.log(num[3]-num[2]);
        }
    }else{
        if(num[0]>=num[3]){
            console.log(0);
        }else if(num[3]<=num[1]){
            console.log(num[3]-num[0]);
        }else{
            console.log(num[1]-num[0]);
        }
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
b,c[9<<20],n;main(a){for(;++a<9e6;)for(b=a;(b+=a)<2e6;)c[b]+=!c[a];for(;~scanf("%d",&n);n&&printf("%d\n",b))for(b=0,a=1;a++<n/2;)c[a]+c[n-a]||b++;}

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

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

    int ans = (1900 * m + 100 * (n - m)) * pow(2, m);

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


Measured memory_bytes: 256
def iin(): return int(input())
def nl(): return list(map(int, input().split()))

n = iin()
a = nl()

csum = [0]
for x in a:
    csum.append(csum[-1] + x)

d = dict()
ans = 0
for x in csum:
    t = d.get(x, 0)
    ans += t
    d[x] = t + 1
    
print(ans)

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

using namespace std;

int SumDigits(int A) {
  int sum = 0;
  while (A) {
    sum += A % 10;
    A /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  if (N % SumDigits(N) == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}


Measured memory_bytes: 256
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define re register
#define rep(i,s,t) for(re int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(re int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define pt(x) putchar(x)
#define pti(x) printf("%d",x)
#define ptll(x) printf("%lld",x)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
using namespace std;
il int ci(){
	re char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	re int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}
int main(){
	int n=ci();
	int x= n*(1.0/1.08);
//	printf("%d\n",x);
	if( floor(x*1.08)==n ) printf("%d\n",x);
	else if( floor((x+1)*1.08)==n ) printf("%d\n",x+1);
	else puts(":(");
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main()
{
	long long int n, a,save, remind, a500=0, b =0, sum =0 ;

	scanf("%lld%lld", &n, &a);
	save = n;
		a500 = save / 500;
		remind = n % 500;
		if(remind >= 1)
			b = remind / 1;

		sum = b;

		if(sum <= a)
			printf("Yes\n");

		else
			printf("No\n");

		return 0;
}

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

constexpr int MAXN = 1e3 + 3;
constexpr double down = 0.996;

int n;
long long sum;

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0 || i % 5 == 0) continue;
		sum += i;
	}
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>

using namespace std;

const double inf = 1e10;

void update_min(double &x, double y) {
	x = min(x, y);
}
void update_max(double &x, double y) {
	x = max(x, y);
}


class D
{
private:
	vector<double> l, r;
	vector<double> hoehoe;
public:
	D() : l(3, inf), r(3, -inf) {}

	void add(double x, int v) {
		update_min(l[v], x);
		update_max(r[v], x);
	}

	double get_len(double t) {
		double min_l = inf;
		double max_r = -inf;

		for (int i = 0; i < 3; i++) {
			update_min(min_l, l[i] + t * i);
			update_max(max_r, r[i] + t * i);
		}

		return max_r - min_l;
	}

	set<double> events() {
		set<double> s;
		// for (int i = 0; i < 3; i++) {
		// 	printf("events %d: %f %f\n", i, l[i], r[i]);
		// }
		for (int i = 0; i < 3; i++) {
			for (int j = i + 1; j < 3; j++) {
				double tmp = (l[i] - l[j]) / (j - i);
				// printf("tmp %f %f %d %d\n", l[i], l[j], i, j);
				if (tmp > 0) {
					s.insert(tmp);
				}
				tmp = (r[i] - r[j]) / (j - i);
				if (tmp > 0) {
					s.insert(tmp);
				}
			}
		}
		return s;
	}
};

int main() {
	int n, x, y;
	char d;

	D xd, yd;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> x >> y >> d;

		switch (d) {
			case 'R': xd.add(x, 2); yd.add(y, 1); break;
			case 'L': xd.add(x, 0); yd.add(y, 1); break;
			case 'U': xd.add(x, 1); yd.add(y, 2); break;
			case 'D': xd.add(x, 1); yd.add(y, 0); break;
		}
	}

	set<double> ts = {0, inf};
	auto ts1 = xd.events();
	auto ts2 = yd.events();
	ts.insert(ts1.begin(), ts1.end());
	ts.insert(ts2.begin(), ts2.end());

	double ans = inf * inf * 10;
	for (double t: ts) {
		double area = xd.get_len(t) * yd.get_len(t);
		// cout << t << ": " << area << endl;
		update_min(ans, area);
	}

	printf("%.12f\n", ans);
	return 0;
};


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a[3],i,j,w;
	for(i=0;i<3;i++){
	    scanf("%d",&a[i]);
	}
	for(i=0;i<2;i++){
	    for(j=i+1;j<3;j++){
		    if(a[i]>a[j]){
			    w=a[i];
				a[i]=a[j];
				a[j]=w;
			}
		}
	}
	for(i=0;i<3;i++){
	    if(i==2) printf("%d\n",a[i]);
		else printf("%d ",a[i]);
	}
	return 0;
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B,K;cin>>A>>B>>K;
    for(int i=0;i<K;i++){
        if(i%2==0){
            A=A/2;
            B=B+A;
        }
        if(i%2==1){
            B=B/2;
            A=B+A;
        }
    }
    cout<<A<<' '<<B<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

static const int INF=1<<29;

bool testcase_ends() {
    int n;
    scanf("%d", &n);

    if (!n) return 1;

    int res=-INF, seq=-INF;
    for (int i=0; i<n; ++i) {
        int a;
        scanf("%d", &a);

        seq = max(seq+a, a);
        res = max(res, seq);
    }

    printf("%d\n", res);
    return 0;
}

int main() {
    int solved=0;
    while (!testcase_ends())
        ++solved;

    return !solved;
}

Measured memory_bytes: 2672
from collections import Counter
from operator import itemgetter

n = int(input())
a = list(map(int, input().split()))

c = Counter(a)

def num(n):
	if n in c.keys():
		return c[n]
	else:
		return 0

ans = 0

for i in range(99998):
	candidate = num(i) + num(i+1) + num(i+2)
	if candidate > ans:
		ans = candidate

print(ans)

Measured memory_bytes: 14564
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
int main()
{
    ll k, x;
    cin >> k >> x;
    if (500 * k >= x)
        cout << "Yes";
    else
        cout << "No";
}

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

using namespace std;

int main() {
	// 入力を整数と文字の並びとして受け取る
	int y, m, d;
	char c1, c2;
	cin >> y >> c1 >> m >> c2 >> d;
	if (m <= 4) cout << "Heisei" << endl;
	else cout << "TBD" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  int a=0,b=0;
  for(int i=0;i<S.length();i++){
    a+=2*(S[i]=='S')-1;
    if(a<0){b++;a=0;}
  }
  cout<<b*2;
}

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

const int N = 1e2 + 10;

int a[2][N];

int main() {
	int n;
	scanf("%d", &n);
	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < n; j++) {
			scanf("%d", &a[i][j]);
			if(i >= 1 && j >= 1) {
				a[i][j] += max(a[i-1][j], a[i][j-1]);
			} else if(i >= 1) {
				a[i][j] += a[i-1][j];
			} else if(j >= 1) {
				a[i][j] += a[i][j-1];
			}
		}
	}
	printf("%d\n", a[1][n-1]);
}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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() {
  // Failed to predict input format
  long long ans = 0;
  int N,M;
  cin >> N >> M;
  ans = (1ll<<M) - 1;
  for(int i = 0 ; i < N ; i++){
    int K;
    cin >> K;
    long long t = 0;
    for(int j = 0 ; j < K ; j++){
      int x;
      cin >> x;
      t |= (1ll<<(x-1));
    }
    ans &= t;
  }

  cout << __builtin_popcountll(ans) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
ll tej[200];
int main(){
	ll n;
	cin>>n;
	vector<ll> a;
	a.pb(0);
	for(int i=1;i<=n;i++){
		ll x;
		cin>>x;
		a.pb(x);
	}
	for(int i=n;i>=1;i--){
		ll gnum = 0;
		for(int j=1;j<=i;j++){
			if(a[j]==j && j>gnum){
				gnum = j;
			}
		}
		if( gnum == 0){
			cout<<-1<<endl;
			return 0;
		}
		else{
			tej[i] = gnum;
			for(int j=gnum;j<i;j++){
				a[j] = a[j+1];
			}
		}
	}
	for(int i=1;i<=n;i++){
		cout<<tej[i]<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n, z, w, a[2010];
    cin>>n>>z>>w;
    for (int i=0; i<n; i++) cin>>a[i];
    cout<<max(abs(a[n-2]-a[n-1]), abs(a[n-1]-w))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp()//true for a before b
{
	bool ans = 0;
	return ans;
}

const int N = (1e2) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 650;

// This is a self-modified code taken from :
// https://github.com/jaehyunp/stanfordacm/blob/master/code/MaxBipartiteMatching.cc
// This is a property of abhishek_1997

int graph_[N][N];
int mr_[N], mc_[N];
bool vis_[N];

void init_graph_assigning_nodes(int n, int m)
{
	int i, j;
	fo(i,0,n+1)
	{
		fo(j,0,m+1)
			graph_[i][j] = 0;
		mr_[i] = -1;
	}
	fo(j,0,m+1)
	{
		mc_[j] = -1;
		vis_[j] = 0;
	}
	return;
}

void init_values_(int n)
{
	int i;
	fo(i,0,n+1)
		vis_[i] = 0;
	return;
}

void add_edge(int from, int to)
{
	graph_[from][to] = 1;
	return;
}

bool find_match_(int v, int m)
{
	int i;
	fo(i,1,m+1)
	{
		if(graph_[v][i] && !vis_[i])
		{
			vis_[i] = 1;
			if(mc_[i] < 0 || find_match_(mc_[i], m))
			{
				mr_[v] = i;
				mc_[i] = v;
				return 1;
			}
		}
	}
	return 0;
}

int maximum_bipartite_matching(int n, int m)
{
	int cnt = 0, i;
	fo(i,1,n+1)
	{
		init_values_(m);
		if(find_match_(i, m))
			cnt++;
	}
	return cnt;
}

pii r[N], b[N];

void solve()
{
	int n, i, j, ans = 0;
	cin >> n;
	fo(i,1,n+1)
		cin >> r[i].F >> r[i].S;
	fo(i,1,n+1)
		cin >> b[i].F >> b[i].S;
	init_graph_assigning_nodes(n,n);
	fo(i,1,n+1)
		fo(j,1,n+1)
			if(r[i].F < b[j].F && r[i].S < b[j].S)
				add_edge(i,j);
	cout << maximum_bipartite_matching(n,n);
	return;
}

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1;
	// cout << fixed << setprecision(9);
	// cin >> t;
	while(t--)
		solve();
	// Code ends here

	// clk = clock() - clk;
	// cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int INF = 1000000007;
 
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
 
  int A;
  cin >> A;
  cout << A*A << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second

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

signed main(){
	int n;
	cin>>n;
	int a[n];
	r(i,n)cin>>a[i];

	int b[n]={};
	for(int i=(n+1)/2;i<n;i++){
		if(a[i])b[i]=1;
	}

	for(int i=(n+1)/2-1;i>=0;i--){
		int sum=0;
		for(int j=i;j<n;j+=(i+1)){
			sum += b[j];
		}
		sum %= 2;
		if(sum==a[i]) b[i]=0;
		else b[i]=1;
	}

	vector<int>v;
	r(i,n){
		if(b[i])v.push_back(i+1);
	}

	cout<<v.size()<<endl;
	r(i,v.size())cout<<v[i]<<endl;

}

Measured memory_bytes: 4980
import numpy as np
import math

INF = 1000000

N,M = map(int, input().split())
match = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}
A = list(map(int, input().split()))

match = {a:match[a] for a in A}

dp = []

for i in range(N+1):
    if i == 0:
        dp.append(0)
    else:
        tmp = [dp[i-m] for m in match.values() if i-m >= 0]
        if tmp == []:
            dp.append(-float('inf'))
        else:
            dp.append(max(tmp)+1)
s = ''
nums = list(match.keys())
nums.sort(reverse=True)
while(True):
    for num in nums:
        if N - match[num] >= 0 and dp[N - match[num]] == dp[N] - 1:
            s = s + str(num)
            N-=match[num]
            break
    if N == 0:
        break

print(int(s))


Measured memory_bytes: 21268
import numpy as np
import bisect
def sieve_of_eratosthenes(n):
    max = int(np.sqrt(n))
    seachList = [i for i in range(2,n+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        prm = seachList[0]
        seachList = [i for i in seachList if i%prm != 0]
    primeNum.extend(seachList)
    return primeNum


Q = int(input())
l = []
r = []
for i in range(Q):
    a,b = map(int,input().split())
    l.append(a)
    r.append(b)

prime_list = sieve_of_eratosthenes(max(r))

ruiseki = [0]*len(prime_list)
for i in range(len(prime_list)):
    if (prime_list[i]+1)//2 in prime_list:
        ruiseki[i] += 1 + ruiseki[i-1]
    else:
        ruiseki[i] = ruiseki[i-1]

ruiseki.insert(0,0)

for i in range(Q):
    ans = 0
    ans = ruiseki[bisect.bisect_right(prime_list,r[i])] - ruiseki[bisect.bisect_left(prime_list,l[i])]
    print(ans)


Measured memory_bytes: 39340
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

LL factorial(int x){
	if(x<=1)return 1;
	return x * factorial(x-1) % MOD;
}

int main(){
	int N;
	cin >> N;
	string str;
	cin >> str;
	
	int count = 0;
	LL ans = 1;
	foreach(i, str){
		if(i=='W'){
			if(count <= 0){
				cout << 0 << endl;
				return 0;
			}
			if(count % 2){
				++count;
			}else{
				ans *= count;
				ans %= MOD;
				--count;
				if(count < 0){
					cout << 0 << endl;
					return 0;
				}
			}
		}else{
			if(count == 0){
				++count;
			}else if(count % 2){
				ans *= count;
				ans %= MOD;
				--count;
				if(count < 0){
					cout << 0 << endl;
					return 0;
				}
			}else{
				++count;
			}
		}
	}
	if(count != 0){
		cout << 0 << endl;
		return 0;
	}

	cout << ans * factorial(N) % MOD << endl;
	return 0;
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const double eps = 1e-9;
const ll N = 1e6 + 10;
const int M = 998244353;
const ll MAX = 1e18 + eps;
int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};

ll be(ll b, ll e) {
    if (e == 0)
        return 1;
    if (e % 2 == 0) {
        ll x = be(b, e / 2);
        return (x * x) % M;
    } else return (b * be(b, e - 1)) % M;
}

int main() {
    ll n, s;
    cin >> n >> s;
    ll dp[n + 1][s + 1];
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= s; ++j) {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = be(2, n);
    ll inv = be(2, M - 2);
    ll a[n];
    for (int k = 0; k < n; ++k) {
        cin >> a[k];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= s; ++j) {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= M;
            if (j + a[i] <= s) {
                dp[i + 1][j + a[i]] += (inv * dp[i][j]) % M;
                dp[i + 1][j + a[i]] %= M;
            }
        }
    }
    cout << dp[n][s] << endl;
}

Measured memory_bytes: 74028
// 30/07/19 // 9:04 PM //

#include <iostream>

using namespace std;

#define MAXN 110
#define MAXV 100010
#define INF 0x3f3f3f3f // 2000000000

int n, w;
int value[MAXN], weight[MAXN];
int memo[MAXN][MAXV+5];

void knapsack(){

    for(int j=0; j<=MAXV; j++)
        memo[0][j] = INF;
    memo[0][0] = 0;

    for(int i=1; i<=n; i++)
        for(int j=0; j<=MAXV; j++){
            memo[i][j] = memo[i-1][j];

            if(j-value[i]>=0)
                memo[i][j] = min(memo[i][j], weight[i] + memo[i-1][j-value[i]]);
        }


}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> w;
    for(int i=1; i<=n; i++)
        cin >> weight[i] >> value[i];


    knapsack();

    int resp = -1;

    for(int j=0; j<=MAXV; j++)
        if(memo[n][j]>0 && memo[n][j]<=w)
            resp = max(resp, j);

    cout << resp << "\n";


    return 0;
}


Measured memory_bytes: 41216
int main(){ 
   int H,N; 
   scanf("%d%d",&H,&N); 
   for(int i=0;i<N;i++){ 
     int A; 
     scanf("%d",&A); 
     H-=A; 
   } 
   if(H<=0)puts("Yes"); 
   else puts("No"); 
 }


Measured memory_bytes: 128