akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define test int T; cin>>T; while(T--)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

signed main()
{
	fasterthanlight;
	int n;
	cin >> n;
	int arr[100005] = {};
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		arr[a]++;
		sum += a;
	}
	int q;
	cin >> q;
	while (q--)
	{
		int b, c;
		cin >> b >> c;
		sum -= b * arr[b];
		sum += c * arr[b];
		arr[c] += arr[b];
		arr[b] = 0;
		cout << sum << endl;
	}
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  string ans;
  for(int i=1;i<=s.size();i++){
    if( i%2 != 0 ){
      ans += s.at(i-1);
    }
  }
  
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 512
// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

const int N=1e5+5;
int n,a[N];long long ans;

void init()
{
	scanf("%d",&n);int i;
	for(i=1;i<=n;++i) scanf("%d",&a[i]);
}

void work()
{
	int i;
	for(i=1;i<=n;++i)
	{
		ans+=a[i]>>1;
		if(a[i+1]&&(a[i]&1)) --a[i+1],++ans;
	}
	printf("%lld\n",ans);
}

int main()
{
	init();work();
	return 0;
}

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	
	if(s[2]==s[3] && s[4]==s[5])
		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;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}

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

int main(){
    ll mod=1e9+7;
    ll n;
    cin >> n;
    ll wa=0;
    ll se=0;
    ll a;

    rep(i,n){
        cin >> a;
        wa+=a;
        se+=a*a;
        se=se%mod;
    }

    wa=wa%mod;

    ll ans;
    ans=wa*wa-se;
    ans=ans%mod;
    if(ans%2==1){
        ans+=mod;
    }
    cout << ans/2 << endl;

    

    return 0;
}

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

int main() {
	long long n,a,b,c,d,e;
	cin>>n>>a>>b>>c>>d>>e;
	
	cout<<max({(n-1)/a,(n-1)/b,(n-1)/c,(n-1)/d,(n-1)/e})+5;
	return 0;
}

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

void solve(long long D, long long N)
{
    if (N != 100)
    {
        cout << (int)pow(100, D) * N << endl;
    }
    else
    {
        cout << (int)pow(100, D) * (N + 1) << endl;
    }
}

int main()
{
    long long D;
    scanf("%lld", &D);
    long long N;
    scanf("%lld", &N);
    solve(D, N);
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=2050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int H,W;
	cin>>H>>W;
	string S;
	for(int i=0;i<W+2;i++)
		S+="#";
	cout<<S<<endl;
	for(int i=0;i<H;i++){
		string P;
		cin>>P;
		cout<<"#"<<P<<"#"<<endl;
	}
	cout<<S<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,count,a,b,c,d,e,f;
  cin >> N;
  vector<long long> A(N);
  for(int i=0;i<N;i++){cin >> A[i];}
  sort(A.begin(), A.end());
  count=0; a=0; b=0;
  if(N%2==0){
    count+=A[N/2]-A[0];
    for(int i=0;i<N/2-1;i++){
      count+=2*A[N/2+1+i]-A[i]-A[i+1];
    }
  }
  else{
    c=A[0]; d=A[(N-3)/2];  e=A[(N+1)/2]; f=A[(N-1)];
    A[0]=d; A[(N-3)/2]=c;
    for(int i=0;i<(N-1)/2;i++){
      a+=2*A[(N+1)/2+i]-A[i]-A[i+1];
    }
    A[0]=c; A[(N-3)/2]=d;
    A[(N+1)/2]=f; A[(N-1)]=e;
    for(int i=0;i<(N-1)/2;i++){
      b+=A[(N-1)/2+i]+A[(N-1)/2+i+1]-2*A[i];
    }
    count=max(a,b);
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


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

    int a,b;
    cin >> a >> b;
    int c=b;
    while (c>0) {
        c/=10;
        a*=10;
    }
    c=a+b;
    bool flag=0;
    rep(i,1000000) {
        if (i*i==c) flag=1;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0; 
}


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

int main(void){
    
    long int A, B;
    cin >> A >> B;
    if(A == 1 && B == 1)
        cout << 1 << endl;
    else if(A == 1)
        cout << B - 2 << endl;
    else if(B == 1)
        cout << A - 2 << endl;
    else
        cout << (A - 2) * (B - 2) << endl;
}



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

l=[0]*(n+1)
p=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
for i in p:
    temp=n
    while temp>=i:
        temp//=i
        l[i]+=temp
var=sorted([g for g in l if g])
ans=sum(int(x>=74)for x in var)
lo=len(var)
for a,b in [(3,25),(5,15)]:
    for i in range(lo):
        for j in range(lo):
            if i!=j and a-1<=var[i]and b-1<=var[j]:
                ans+=1
for i in range(lo):
    for j in range(lo):
        for k in range(j+1,lo):
            if i!=j and k!=i and var[i]>=2 and var[j]>=4 and var[k]>=4:
                ans+=1
print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
constexpr int N_MAX=2*1e5;
int N;
string S;

// 0 : '.'
// 1 : '#'
int dp[N_MAX+1][2] = {0};

int main(int argc, char** argv) {
  cin >> N;
  cin >> S;

  /*
  if (S[0] == '#') {
    dp[1][0] = 1;
    dp[1][1] = 0;
  } else {
    dp[1][0] = 0;
    dp[1][1] = 1;
  }
  */

  for (int i=1; i<=N; i++) {
    if (S[i-1] == '#') {
      // 変えない #
      dp[i][1] = min({dp[i-1][0], dp[i-1][1]});
      // 変える .
      dp[i][0] = dp[i-1][0] + 1;
    } else {
      // 変えない .
      dp[i][0] = dp[i-1][0];
      // 変える #
      dp[i][1] = min({dp[i-1][0]+1, dp[i-1][1]+1});
    }
  }

  cout << min({dp[N][0], dp[N][1]}) << endl;

  return 0;
}


Measured memory_bytes: 2196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;
int dp[2][17000]; 
int main(){

	string s;
	cin>>s;
	int x,y;
	cin>>x>>y;
	
	vector<int> list[2];
	int isrow=1,sum=0;
	for(int i=0;i<s.length();i++)
	{
		char c=s[i];
		if(c=='F')
		sum++;
		else if(c=='T')
		{
			list[isrow].pb(sum);
			sum=0;
			isrow=(isrow+1)%2;
		}
	}
	list[isrow].pb(sum);
//	for(int i=0;i<list[0].size();i++)cout<<list[0][i]<<" ";cout<<endl;
//	for(int i=0;i<list[1].size();i++)cout<<list[1][i]<<" ";cout<<endl;	
	dp[0][8500]=1;//0点 
	dp[1][8500]=1;//0点 
	for(int ff=0;ff<2;ff++)
	{
		for(int i=0;i<list[ff].size();i++)
		{
			int x=list[ff][i];
			int temp[17000];
			memset(temp,0,sizeof(temp));
			for(int j=0;j<17000;j++)//+-8000
			{
				if(dp[ff][j]==1)
				{
					if(i==0&&ff==1)
					temp[j+x]=1;
					else
					{
						temp[j+x]=1;
						temp[j-x]=1;
					}
				} 
			}
			memcpy(dp[ff],temp,sizeof(temp)); 
		}
	}
	if(dp[0][y+8500]&&dp[1][x+8500])
	cout<<"Yes"<<endl;
	else 
	cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 512
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

N= int(input())

#n:node s:start
dlines = defaultdict(set)
for i in range(N-1):
    x,y,cost = inpl()
    dlines[x].add((cost,y))
    dlines[y].add((cost,x))

Q,K = inpl()
query = []
for _ in range(Q):
    x2,y2 = inpl()
    query.append((x2,y2))


def dijkstra_heap(n,s,dlines):
    d = [10**20]*(n+1)
    used = [True]*(n+1)
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in dlines[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in dlines[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

res = dijkstra_heap(N,K,dlines)
for order in query:
    print(res[order[0]]+res[order[1]])


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

using namespace std;

int n;
int a[105];
bool flag[105];
int ans;

int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n; i++){
		scanf("%d",&a[i]);
		flag[a[i]] = 1;
	}
	for(int i = 1;i <= 100; i++){
		if(flag[i]) ans++;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
pair<int,int> f(int a){
  int y=a%10;
  int x=0;
  if(a>=10){
    while(a>9){
      a/=10;
      x=a;
    }
  }
  else x=y;
  pair<int,int> p(x,y);
  return p;
}
    

int main(){
  int n;
  cin>>n;
  map<pair<int,int>,int> num;
  long long ans=0;
  for(int i=1;i<=n;i++) num[f(i)]++;
  for(int i=1;i<=n;i++){
    pair<int,int> p=f(i);
    pair<int,int> q(p.second,p.first);
    ans+=num[q];
  }
  cout<<ans;
}

Measured memory_bytes: 256
import sys
INPUT = sys.stdin.readline
#入力関数
def SORO_INT(): return int(INPUT())
def MULT_INT_LIST(): return list(map(int, INPUT().split()))
def MULT_INT_MAP(): return map(int, INPUT().split())
def SORO_STRING(): return INPUT()
def MULT_STRING(): return INPUT().split()

N = SORO_INT()
A = list([int(input()) for i in range(N)])
t = sorted(A)[-2]

B = max(A)
B_in = A.index(B)


for i in range(N):
    A[i] = B
A[B_in] = t
for i in range(N):
    print(A[i])


Measured memory_bytes: 13180
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char[] strArray = S.toCharArray();
		System.out.println(strArray[0] + String.valueOf(strArray.length - 2) + strArray[strArray.length - 1]);
		sc.close();
	}
}

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




typedef long long ll;
#define INF 1LL<<60
int N;
ll A, B;
int X[101010];
//-----------------------------------------------------------------
int main() {
	cin >> N >> A >> B;
	rep(i, 0, N) scanf("%d", &X[i]);
	
	ll ans = 0;
	rep(i, 1, N) {
		ans += min(A * (ll)(X[i] - X[i - 1]), B);
	}
	cout << ans << endl;
}


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


public class C
{
	public static void Main()
	{
		int N = GetInt();
		long[] A = Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
		long[] B = Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();

		if(A.Sum() < B.Sum())
		{
			Console.WriteLine(-1);
			return;
		}

		long S = Enumerable.Range(0, N).Select(x => Math.Max(0, B[x] - A[x])).Sum();
		List<long> T = Enumerable.Range(0, N).Select(x => Math.Max(0, A[x] - B[x])).ToList();
		T.Sort();
		T.Reverse();

		int ans = Enumerable.Range(0, N).Where(x => A[x] < B[x]).Count();
		for(int i = 0; i < N; i++)
		{
			if(S <= 0)
				break;

			S -= T[i];
			ans++;
		}

		Console.WriteLine(ans);
	}
}


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

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

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


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

int main() {
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  
  if (A+B > C+D) {
    cout << "Left" << endl;
  }
  if (A+B < C+D) {
    cout << "Right" << endl;
  }
  if (A+B == C+D) {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
    #include <math.h>
    void main()
    {
      long long int N,th,fiv,fif,ans;
      scanf("%lld", &N);
      th = N / 3;
      fiv = N / 5;
      fif = N / 15;
      ans=(N*(N+1)-3*th*(th+1)-5*fiv*(fiv+1)+15*(fif)*(fif+1))/2;
      printf("%lld", ans);
    }

Measured memory_bytes: 1700
package main

import (
	"fmt"
	"strings"
)

func main() {
	var sx, sy, tx, ty int
	fmt.Scan(&sx, &sy, &tx, &ty)
	x := tx - sx
	y := ty - sy
	s := ""
	s = s + strings.Repeat("R", x)
	s = s + strings.Repeat("U", y)
	s = s + strings.Repeat("L", x)
	s = s + strings.Repeat("D", y)
	s = s + "D"
	s = s + strings.Repeat("R", x+1)
	s = s + strings.Repeat("U", y+1)
	s = s + "LU"
	s = s + strings.Repeat("L", x+1)
	s = s + strings.Repeat("D", y+1)
	s = s + "R"
	fmt.Println(s)
}


Measured memory_bytes: 768
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    # N, D = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    for i, h in enumerate(h_list):
        if h == 0:
            print(i + 1)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """0 2 3 4 5"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 2 0 4 5"""
        output = """3"""
        self.assertIO(input, output)


Measured memory_bytes: 16328
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
def inpl(): return list(map(int, input().split()))

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

ans = 1e16
for s in [1, -1]:
  res, csum = 0, 0
  for a_i in a:
    csum += a_i
    if csum * s <= 0:
      res += abs(csum-s)
      csum = s
    s *= -1
  ans = min(ans, res)

print(ans)

Measured memory_bytes: 14588
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll n;
cin>>n;
ll l[n];
l[0]=2;
l[1]=1;
for(int i=2;i<n+1;i++){
    l[i]=l[i-1]+l[i-2];
}
cout<<l[n]<<endl;
}












Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin>>s;
	int n=s.size(),sum=0,ma=0;
	for(int i=0; i<n; i++) {
		if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')
			sum++;
		else{
			if(sum>ma)
				ma=sum;
			sum=0;
		}
	}
	if(sum>ma)
		ma=sum;
	cout<<ma<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
# include <stdlib.h>

int ord(const void * x, const void * y){
	int a = *((int *) x), b = *((int *) y);
 
	if (a<b)
		return -1;
	if (a>b)
		return 1;
 
	return 0;
 
}
 

int main() {
    int n;
    scanf("%d", &n);
    int vec[n];
    
    for (int i = 0; i < n; ++i)
        scanf("%d", &vec[i]);
        
    qsort(vec, n, sizeof(vec[0]), ord);
    int a = 0;
    for (int i = 0; i < n-1; ++i){
        if (vec[i] == vec[i+1]){
            a = 1;
            break;
        }
    }
    if ( a == 1)
        printf("NO\n");
    else
        printf("YES\n");
    


    return 0;
}


Measured memory_bytes: 1788
SD = list(input())
T = list(input())

S = []
flag = -1

for i in range(len(SD)-len(T), -1, -1):
    Sub_S = SD[i:i+len(T)]
    for t,s in zip(T, Sub_S):
        if s!="?" and s!=t:
            break
    else:
        S=SD[:i]+T+SD[i+len(T):]
        flag = 1
        break
    
if flag<0:
    print("UNRESTORABLE")
else:
    for i in range(len(SD)):
        if S[i]=="?":
            S[i]="a"

print("".join(S))


Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args){
		int flag = 0;
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
		for(int j = 0 ;j<i ;j++){
			int a = sc.nextInt();
			if(a%2 == 0){
				if(a%3 == 0 || a%5 == 0){
				}else{
					flag = 1;
				}
			}
		}
		if(flag == 0){
				System.out.println("APPROVED");
			}else{
				System.out.println("DENIED");
			}
	}
}

Measured memory_bytes: 21844
import math

a, b, x = map(float, raw_input().split())

x /= a
if x<a*b/2:
  # x = a2*b/2
  a2 = x*2/b
  ans = math.atan2(b, a2)
else:
  # x = (b-b2)*a+b2*a/2
  b2 = (a*b-x)*2/a
  ans = math.atan2(b2, a)
print "%.10f"%(ans/math.pi*180)


Measured memory_bytes: 2568
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
lst = []
for _ in range(n):
    a = input().split(".")
    if len(a) == 1:
        a[0] = a[0] + '0' * 9
        lst.append(int(a[0]))
    else:
        l = len(a[1])
        tmp = a[0] + a[1] + '0' * (9 - l)
        lst.append(int(tmp))


two = []
five = []
for i in lst:
    j = i
    cnt = 0
    while j % 2 == 0:
        j //= 2
        cnt += 1
    two.append(cnt)
    j = i
    cnt = 0
    while j % 5 == 0:
        j //= 5
        cnt += 1
    five.append(cnt)

a = [[0] * 100 for _ in range(100)]
for i, j in zip(two, five):
    a[i][j] += 1

S = [[0] * 100 for _ in range(100)]
for i in range(1, 100):
    for j in range(1, 100):
        S[i][j] = a[i-1][j-1] + S[i][j - 1] + S[i - 1][j] - S[i - 1][j - 1]

ans = 0
for i, j in zip(two, five):
    if 18 - i < 0:
        i = 18
    if 18 - j < 0:
        j = 18
    ans += S[-1][-1] - S[-1][18 - j] - S[18 - i][-1] + S[18 - i][18 - j]
    if i + i >= 18 and j + j >= 18:
        ans -= 1
print(ans // 2)

Measured memory_bytes: 114636
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
S=[a,b,c,d,e]
ans="Yay!"
for i in S:
    for j in S:
        if abs(i-j)<=k:
            pass
        else:
            ans=":("
            break
print(ans)

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

int main(){
    int N, M;
    cin >> N;
    string s[N];
    for (int i=0; i<N; i++){
        cin >> s[i];
    }
    cin >> M;
    string t[M];
    for (int i=0; i<M; i++){
        cin >> t[i];
    }

    int count = 0;
    int max = 0;

    for (int i=0; i<N; i++){
        count = 0;
        for(int j=0; j<N; j++){
            if(s[i] == s[j]){
                count++;
            }
        }
        for(int j=0; j<M; j++){
            if(s[i] == t[j]){
                count--;
            }
        }
        if(count > max){
            max = count;
        }
    }

    cout << max << endl;

    return 0;
}


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

int main(){
    int N,M; cin >> N >> M;
    vector<int> P(M),Y(M);
    for(int i = 0; i < M; i++) cin >> P[i] >> Y[i], --P[i];
    vector<vector<int>> vals(N);
    for(int i = 0; i < M; i++)vals[P[i]].push_back(Y[i]);
    for(int v = 0; v < N; v++){
        sort(vals[v].begin(),vals[v].end());
        vals[v].erase(unique(vals[v].begin(),vals[v].end()),vals[v].end());
    }
    for(int i = 0; i < M; i++){
        int v = P[i];
        printf("%06d",v+1);
        int id = lower_bound(vals[v].begin(),vals[v].end(),Y[i]) - vals[v].begin();
        printf("%06d\n",id + 1);
    }
}


Measured memory_bytes: 9364
class Combination:
    """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う"""
    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [0] * (n + 1)
        self.inv_fact[n] = pow(self.fact[n], MOD - 2, MOD)
        for i in reversed(range(n)):
            self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % MOD
        self.MOD = MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD


def way5(ball, box):
    """ball: False / box: True / constraints: 1 or less
    -> ans = combination(box, ball)
    """
    if ball > box:
        return 0
    return comb.combination(box, ball)


n, k = map(int, input().split())
MOD = 10 ** 9 + 7
comb = Combination(10 ** 4, MOD)

print(way5(n, k))


Measured memory_bytes: 6348
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(int j = 0; j < n; j++){
        char a[1000] = {0};
        char b[1000] = {0};
        scanf("%s%s",a,b);
        int len_a = 0,len_b = 0;
        for(int i = 0; a[i] != 0; i++) len_a++;
        for(int i = 0; b[i] != 0; i++) len_b++;
        if(len_a > 80 || len_b > 80){
            printf("overflow\n");
        }
        else{
            char ans[1000] = {0};
            reverse(a,a+len_a);
            reverse(b,b+len_b);
            int len = max(len_a,len_b);
            for(int i = 0; i < len; i++){
                if(ans[i] != 0){
                    if(a[i] == 0 || b[i] == 0)
                        ans[i] += a[i] + b[i] - '0';
                    else ans[i] += a[i] + b[i] - '0' - '0';

                }
                else if(a[i] == 0 || b[i] == 0) ans[i] += a[i] + b[i];
                else ans[i] += a[i] + b[i] - '0';
                if(ans[i] >= 58){
                    ans[i+1]+='1';
                    ans[i] -= 10;
                }
            }
            int len_ans = 0;
            for(int i = 0; ans[i] != 0; i++) len_ans++;
            reverse(ans,ans+len_ans);
            if(len_ans > 80) printf("overflow");
            else for(int i = 0; ans[i] != 0; i++) printf("%c",ans[i]);
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

const int MAX = 5100000;
const ll MOD = 100000000007;

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

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

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    ll N;
    cin >>N;
    vector<ll> A(N);
    map<ll,ll> m1;
    map<ll,ll> m2;
    rep(i,N){
        cin>>A[i];
        m1[i+A[i]]++;
        m2[i-A[i]]++;
    }
    ll ans = 0;
    for (const auto& [key, value] : m1){
        ans += value*m2[key];
    }

    cout<< ans<<endl;
    return 0;
    

}

Measured memory_bytes: 158584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i] = -a[i];
  }

  vector<int> c;
  rep(i, n) {
    auto itr = upper_bound(c.begin(), c.end(), a[i]);
    if (itr == c.end()) {
      c.push_back(a[i]);
    }
    else {
      *itr = a[i];
    }
  }

  cout << c.size() << endl;

  
  return 0;
}

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

int main()
{
	string s,ch;
	int i,j,k,m;
	cin >> s >> ch;
	for(i=s.size()-1,m=ch.size();i-m+1>=0;i--)
	{
		for(j=i-m+1,k=0;k<m;j++,k++)
			if(s[j]!='?' && s[j]!=ch[k]) break;
		if(k==ch.size()) break;
	}
	if(i-m+1<0)
	{
		puts("UNRESTORABLE");
		return 0;
	}
	for(j=i-ch.size()+1,k=0;k<ch.size();j++,k++)
		s[j]=ch[k];
	for(i=0;i<s.size();i++)
		if(s[i]=='?') s[i]='a';
	cout << s << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    ll a[n];for(ll i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    ll ans;
    double val = (a[n-1]*1.0)/2.0;
    double diff = 1e15;
    for(ll i=0;i<n;i++){
        if(abs(val-a[i])<diff)diff=abs(val-a[i]),ans=a[i];
    }
    cout<<a[n-1]<<" "<<ans;
}

Measured memory_bytes: 1024
N,X=map(int,input().split())
a=[1]
p=[1]
for i in range(N):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(n,x):
  if n==0:
    if x<1:
      return 0
    else:
      return 1
  elif x<=a[n-1]+1:
    return f(n-1,x-1)
  else:
    return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(N,X))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
   int N;
   cin>>N;
   map<int,int> m;
   rep(i,N) {
       int A;
       cin>>A;
       m[A]++;
   }
   ll ans=0;
   for(auto c : m) {
       if(c.fi>c.se) ans+=c.se;
       else ans+=(c.se-c.fi);
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 4736
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

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

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; }
typedef pair <ll,ll> P;


int main()
{
    ll X, t;
    cin >> X >> t;
    cout << max((ll)0, X-t) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(2e5)+5;






int ar[30]={0};
int br[30]={0};

int main()
{
    idfc;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int i;
    int e;
    for(i=0;i<n;i++)
    {
        e=s[i]-97;
        br[e]++;
    }
    int a=0;
    int b,j;

    for(i=0;i<n;i++)
    {
        e=s[i]-97;
        ar[e]++;
        br[e]--;
        b=0;
        for(j=0;j<26;j++)
        {
            if(ar[j]&&br[j])b++;
        }
        if(b>a)a=b;
    }
    cout<<a;

    return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

ll x;

int main()
{
    _FastIO;
    cin >> x;
    ll ans = 0;
    while(x > 100){
        ll k = x / 101;
        ans++;
        x -= k;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main ()
{
	int W, H, x, y, r;
	
	scanf ("%d %d %d %d %d", &W, &H, &x, &y, &r);
	
	if (x - r < 0 || x + r > W) {
		printf ("No\n");
	} else if (y - r < 0 || y + r > H) {
		printf ("No\n");
	} else {
		printf ("Yes\n");
	}
	
	return 0;
}


Measured memory_bytes: 1984
N = int(input())
A = list(map(int , input().split()))
SUM = [0 for i in range(N+1)]
d = {0:1}
for i in range(N):
    SUM[i+1] = SUM[i] + A[i]
    if not SUM[i+1] in d:
        d[SUM[i+1]] = 0
    d[SUM[i+1]] += 1
ans = 0
for v in d.values():
    if v >= 2:
        ans += int(v*(v-1)/2)
print(ans)

Measured memory_bytes: 40348
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int X = in.nextInt();
        int Y = in.nextInt();



        List<Integer> group1 = new ArrayList<>();
        List<Integer> group2 = new ArrayList<>();
        group1.add(1);
        group1.add(3);
        group1.add(5);
        group1.add(7);
        group1.add(8);
        group1.add(10);
        group1.add(1);
        group2.add(4);
        group2.add(6);
        group2.add(9);
        group2.add(11);

        if (X==2 && Y == 2)
        {
            System.out.println("Yes");
        }

        else if (group1.contains(X) && group1.contains(Y))
        {
            System.out.println("Yes");
        }

        else if (group2.contains(X) && group2.contains(Y))
        {
            System.out.println("Yes");
        }

        else
            {
                System.out.println("No");
            }






    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


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

using namespace std;
typedef long long LL;

int u[110], v[110];
LL dp[100010];

int main() {
    int n, w;
    cin>>n>>w;
    for (int i=0;i<n;i++) scanf("%d%d", &u[i], &v[i]);
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    for (int i=0;i<n;i++)
        for (int j=w;j>=0;j--)
            if (dp[j]>-1) {
                if (j+u[i]<=w) dp[j+u[i]]=max(dp[j+u[i]], dp[j]+v[i]);
            }
    LL ret=0;
    for (int i=0;i<=w;i++) ret=max(ret, dp[i]);
    cout<<ret<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

bool bad[125252];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, m, h[125252];
  cin>>n>>m;
  REP(i, n){
    cin>>h[i];
  }
  REP(i, m){
    int a, b;
    cin>>a>>b;
    --a;--b;
    if(h[a]<=h[b]){
      bad[a]=true;
    }
    if(h[b]<=h[a]){
      bad[b]=true;
    }
  }
  int ans=0;
  REP(i, n){
    if(!bad[i]){
      // DEBUG(i);
      ++ans;
    }
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 4108
#include <iostream>

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int number[50];
		for (int i = 0; i < n; i++) {
			cin >> number[i];
		}
		bool hantei = true;
		bool hantei2 = false;
		bool hantei3 = false;
		for (int i = 0; i < n; i++) {
			if (i != 0 && number[i] == number[i-1]+1) {
				hantei2 = true;
			} else if (i != 0){
				hantei = true;
				hantei3 = true;
			}
			if (number[i]+1 != number[i+1]) {
				hantei = true;
			}
			if (hantei) {
				if (hantei2) {
					cout << '-';
					hantei2 = false;
				} else if (hantei3) {
					cout << ' ';
					hantei3 = false;
				}
				cout << number[i];
				hantei = false;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<limits>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;

int INF = std::numeric_limits<int>::max();
ll LLINF = 2e18+10;
int NINF = std::numeric_limits<int>::min();
int MOD = 1e9+7;

int col[] = {0,-1,0,1,1,1,-1,-1};
int row[] = {-1,0,1,0,1,-1,1,-1};

//knight moves
int cc[] = {1,2,2,1,-1,-1,-2,-2};
int rr[] = {-2,-1,1,2,-2,2,1,-1};

int main()
{
    //cout << LLINF ;
    ios::sync_with_stdio(0);
    cin.tie(0);

    ll n, w;
    cin >> n >> w;

    vi wts(n), vals(n);

    for(int i = 0; i < n ; ++i)
    {
        cin >> wts[i] >> vals[i];
    }

    vvll dp(n,vll(1e5+5,LLINF));

    //initialize dp table
    for(int i = 0; i < n ; ++i)
        dp[i][vals[i]] = wts[i];


    for(int i = 1 ; i < n; ++i)
    {
        for(int j = 1; j <=  1e5 ; ++j)
        {
            dp[i][j] =  min(dp[i][j],dp[i-1][j]);

            if(vals[i] <= j)
                dp[i][j] = min(dp[i][j], dp[i-1][j-vals[i]] +wts[i]);
        }

    }

    int mn = 0;

    for(int j = 1; j <= 1e5 ; ++j)
    {
        if(dp[n-1][j] <= w)
            {
            //    cout << j << " " << dp[n-1][j] << " " << mn << endl;
                mn = max(mn,j);
            }
            //cout  << mn << " ";
    }
    //cout << endl;

    cout << mn;

    return 0;
}


Measured memory_bytes: 82368
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;


    int dp[100005];
    
    int main(){
       int n;cin>>n;
       VEC(int,h,n);
       rep(i,n+1)dp[i] = INF;
       dp[0] = 0;
       rep(i,n){
           if(i==0)continue;
           dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
           if(i==1)continue;
           dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
       }
       cout<<dp[n-1];
    }
    


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt(); 
        int second = s % 60;
        int minuts = s / 60;
        int hour = minuts / 60;
        minuts = minuts % 60;

        System.out.printf("%d:%d:%d\n", hour, minuts, second);
        sc.close();
    }
}


Measured memory_bytes: 26332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

vector<int> cand(0);
vector<bool> check(10,1);

void dfs(string s){
  if(s.size() > 6) return;
  if(s.size() > 0) cand.push_back(stoi(s));
  for(char c='0';c<='9';c++){
    if(check[c-'0']) dfs(s+c);
  }
  return;
}

int main(){
  int n,k;
  cin >> n >> k;
  rep(i,k){
    int x;
    cin >> x;
    check[x] = 0;
  }
  dfs("");
  sort(cand);
  for(int i : cand){
    if(i >= n){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 4976
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main()
{
   int p,an,ans,sum=0;
   cin>>p;
   for(int i=1;i<=p;i++)
   {
   	for(int j=1;j<=p;j++)
   	{
   	  for(int k=1;k<=p;k++)
	   {
		  an=gcd(i,j);
		  ans=gcd(an,k);
		  sum=sum+ans;	
	   }	
	}
   }
   cout<<sum;
   return 0;
}

Measured memory_bytes: 3632
using namespace std;
#include <iostream>
int main(){
    int a,b;
    cin>>a>>b;
    if(b%2==0){
    if(13<=a){
        std::cout << b << std::endl;
    }
    else if(6<=a && a<13){
        std::cout << b/2 << std::endl;
    }
    else{
        std::cout << "0" << std::endl;
    }}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int>a(n);
    REP(i,n){
        IN(a[i]);
    }
    vector<P>x(m);
    REP(i,m){
        int b,c;
        cin>>b>>c;
        x[i]={c,b};
    }
    sort(ALL(a));
    sort(ALL(x));
    reverse(ALL(x));
    int tmp=0;
    int cnt=0;
    REP(i,n){
        if(tmp>=m)break;
        if(a[i]<x[tmp].first){
            a[i]=x[tmp].first;
            cnt++;
            if(cnt>=x[tmp].second){
                tmp++;
                cnt=0;
            }
        }else{
            break;
        }
    }
    ll ans=0;
    REP(i,n){
        ans+=a[i];
    }
    OUT(ans);
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll a[n];for(ll i=0;i<n;i++)cin>>a[i];
  ll ans=0;
  ll f=0,s=0;
  ll used[20];
  fill(used,used+20,0);
  for(;;){
    if(f==n){
      break;
    }
    //cout<<f<<endl;
    ll k=a[f];
    for(ll i=0;;i++){
      used[i]+=k%2;
      k/=2;
      if(k==0)break;
    }
    ll che=1;
    for(ll i=0;i<20;i++){
      if(used[i]>1){
        che=0;
        break;
      }
    }
    if(che==1){
      ans+=f-s+1;
    }
    else{
      for(;;){
        ll l=a[s];
        for(ll i=0;;i++){
          used[i]-=l%2;
          l/=2;
          if(l==0)break;
        }
        ll chee=1;
        for(ll i=0;i<20;i++){
          if(used[i]>1){
            chee=0;
            break;
          }
        }
        if(chee==1){
          ans+=f-s;
          s++;
          break;
        }
        else{
          s++;
        }
      }
    }
    f++;
  }
   cout<<ans<<endl;
}

Measured memory_bytes: 1792