akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<map>
#include<vector>
#include<ctime>
#include<stack>
#define mp make_pair
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define pb push_back

using namespace std;

const int MAXN=100010;
int a[MAXN],b[MAXN],c[MAXN];
long long ansb[MAXN],ans[MAXN],s[MAXN];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
	}
	sort(b+1,b+1+n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&c[i]);
	}
	sort(c+1,c+1+n);
	for (int i=1;i<=n;i++)
	{
		int pos=lower_bound(a+1,a+1+n,b[i])-a-1;
		ansb[i]=pos;
		s[i]=s[i-1]+ansb[i];
	}
	for (int i=1;i<=n;i++)
	{
		int pos=lower_bound(b+1,b+1+n,c[i])-b-1;
		ans[i]=s[pos];
	}
	long long sum=0;
	for (int i=1;i<=n;i++)
	{
		sum+=ans[i];
	}
	cout<<sum;
	return 0;
}


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

using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;

ll N, K;

int main()
{
    fio;
    cin >> N >> K;
    cout << min(N % K, K - N % K) << endl;
    cerr << "Time : " << (double) clock() / (double) CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
#define ALL(v)  (v).begin(),(v).end()

    /*  ペア関連
    //vector<pair<long long, long long> > pairs(N);
    for(long long i=0; i<N; i++){
        long long a, b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    
    //sort(pairs.begin(), pairs.end(),greater<pair<int,int> >());
	sort(pairs.begin(), pairs.end());
    */

 	//stack<int> sta;   
    //queue<int> que;


int main(){
	signed int N,M,K;
	string s;
    
	//std::cin >> N;
    
	
    //std::cin >> N >> M;
    //std::cin >> N >> M >> K;
    //std::cin >> s;
    
    std::vector<long long> v(3);
	
    
    // 配列入力
    
    for(long long i=0; i<3; i++){
		std::cin >> v[i];
	}

    //ソート
    //std::sort(v.begin(),v.end());//昇順ソート
    //std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
	
	
	//文字列入力
	/*
	for(long long i=0; i<s.length(); i++){
		
		if(s[i]!='1'){
	}
	*/
    if((v[0]<v[1] && v[1]<v[2]) || (v[0]>v[1] && v[1]>v[2]) || (v[0]>v[2] && v[0]<v[1]) || (v[0]<v[2] && v[0]>v[1])){
    	printf("No");
	}
	else{
		printf("Yes");
	}
	return 0;
}

Measured memory_bytes: 256
var
	a,b:array[0..100010] of longint;
	ans:int64;
	n,m,i:longint;
procedure qsort(l,r:longint);
var
	i,j,t,mid:longint;
begin
	i:=l; j:=r; mid:=a[(l+r) div 2];
	repeat
		while a[i]<mid do inc(i);
		while a[j]>mid do dec(j);
		if i<=j then
		begin
			t:=a[i]; a[i]:=a[j]; a[j]:=t;
			t:=b[i]; b[i]:=b[j]; b[j]:=t;
			inc(i); dec(j);
		end;
	until i>j;
	if l<j then qsort(l,j);
	if i<r then qsort(i,r);
end;
begin
	readln(n,m);
	for i:=1 to n do read(a[i],b[i]);
	qsort(1,n);
	ans:=0; i:=1;
	while m>0 do
	begin
		if m<=b[i] then
		begin
			ans:=ans+m*a[i];
			break;
		end;
		m:=m-b[i];
		ans:=ans+a[i]*b[i];
		inc(i);
	end;
	writeln(ans);
end.

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        400005
#define mod         1000000007 
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,mx,i,sum=0,x;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    x=a[0];
    sum++;
    for(i=1;i<n;i++){
        if(a[i]>=x){
            sum++;
            x=a[i];
        }
    }
    cout<<sum;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n, x, i, j, k;
    int count = 0;
    
    while(1){
        
        scanf("%d %d", &n, &x);
        
        if((n == 0)&&(x == 0)) break;
        
        for(i = 1; i <= n; i++){
            for(j = 1; j <= n; j++){
                for(k = 1; k <= n; k++){
                    if((i+j+k == x) && (i < j) && (j < k)){
                        count++;
                    }
                }
            }
        }
        printf("%d\n", count);
        count = 0;
    }
    
    return 0;
    
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;
 
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

//最大公約数
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}

//最小公倍数
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}

typedef long long ll;

char str[101];

int main(){
	scanf("%s", str);
	
	int len = strlen(str);
	int c = -1, f = -1;
	
	REP(i,len-1){
		if (str[i] == 'C') c = i;
	}
	
	FOR(j,c+1,len){
		if (str[j] == 'F') f = j;
		if (c == -1) break;
	}
	
	if (c != -1 && f != -1) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.text.*;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			if(n==0) break;
			int max = Integer.MIN_VALUE;
			int min = Integer.MAX_VALUE;
			int sum = 0;
			for(int i=0; i<n; i++){
				int d = in.nextInt();
				sum += d;
				if(max<d) max = d;
				if(min>d) min = d;
			}
			System.out.println((sum-max-min)/(n-2));
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF (1e10+5)
#define F first
#define S second
#define pb push_back
#define MP make_pair
#define FRL(i,a,n) for(i=a;i<n;i++)
#define FR(i,n) FRL(i,0,n)
#define RFRL(i,n) for(i=n;i>=0;i--)
#define MOD 1000000007
#define fill(a) memset(dp,a,sizeof(dp));

using namespace std;

typedef long long int  ll;

typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector< pair<ll,ll> > vpi;
typedef set<ll> st;
typedef map<ll,ll> mp;
typedef unordered_map<ll,ll> ump;

template< class T>
T minn(T a,T b)
{
	return (a>b)?b:a;
}
template< class T>
T maxx(T a,T b)
{
	return (a>b)?a:b;
}


void FILE_OP()
{
	#ifndef ONLINE_JUDGE
        freopen("inputf.txt", "r", stdin);
        freopen("output2.txt", "w", stdout);
    #endif
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void SOLVE()
{

	
	ll tt,m,i,j,k,a,b,c,d,l,r;
	//cin>>tt;
	tt=1;
	//fill(-1)
	ll n,W;
    
    //ll dp[100010];
	while(tt--)
	{
		string s;
		cin>>s;
		l=s.length();
		a=0;
		b=0;
		for(i=0;i<l;i++)
		{
			if(s[i]=='B')
				a++;
			if(s[i]=='A')
				b++;
		}
		if(a==l || b==l)
			cout<<"No\n";
		else
			cout<<"Yes\n";
		
	}


		
}

int main()
{
	FAST_IO
//FILE_OP();
	SOLVE();
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;

namespace AOJ2
{
    class Program
    {
        static List<int> carrList = new List<int>(){1,2,1,2,1,4,1,4};

        static void Main(string[] args)
        {
            List<int> resultList = new List<int>();
 
            string input;
            while ((input = Console.ReadLine()) != null)
            {
                string[] inputArray = input.Split(' ');
                int[] intArray = new int[8];
                int leave=0;

                for (int i = 0; i < 8; i++)
                {
                    intArray[i] = int.Parse(inputArray[i]);
                    if (carrList[i] - intArray[i] > 0)
                    {
                        leave += carrList[i] - intArray[i];
                    }
                }

                int[] minPatrn = new int[2]{ChangeInt(),leave};

                for (int j = 0; j < 7; j++)
                {
                    PushLast();

                    leave = 0;
                    for (int k = 0; k < 8; k++)
                    {
                        intArray[k] = int.Parse(inputArray[k]);
                        if (carrList[k] - intArray[k] > 0)
                        {
                            leave += carrList[k] - intArray[k];
                        }
                    }

                    if (leave < minPatrn[1])
                    {
                        minPatrn[0] = ChangeInt();
                        minPatrn[1] = leave;
                    }
                    else if (leave == minPatrn[1] && ChangeInt() < minPatrn[0])
                    {
                        minPatrn[0] = ChangeInt();
                    }

                }

                PushLast();

                resultList.Add(minPatrn[0]);
     
            }

            foreach (int a in resultList)
            {
                string s = a.ToString();
                for (int i = 0; i < 7; i++)
                {
                    Console.Write("{0} ", s[i]);
                }
                Console.WriteLine(s[7]);
            }

        }

        static int ChangeInt()
        {
            int a = 0;
            for (int i = 7; i >=0; i--)
            {
                a += carrList[i] * (int)Math.Pow(10, (double)7-i);
            }

            return a;
        }

        static void PushLast()
        {
            int last = carrList[7];
            carrList.RemoveAt(7);
            carrList.Insert(0, last);
        }
    }
}

Measured memory_bytes: 5892
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            list.add(Integer.parseInt(sc.next()));
        }
        Collections.sort(list);
        int answer = 0;
        for (int i = 0; i < 2; i++) {
            answer += list.get(i);
        }

        System.out.println(answer);
        sc.close();
    }
}

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

const int N = (int)1e5 + 10;
const double eps = 1e-8;

template <typename T> inline T gcd(T a, T b) { a = abs(a), b = abs(b); while ( b ) { a %= b; swap(a, b); } return a; }
ll dp[N + 7][2];
bool vis[N + 7][2];
ll arr[N + 7];
int n;
ll solve(int pos, int changed) {
	if ( pos == n - 1 ) {
		if ( changed ) return -arr[pos];
		return arr[pos];
	}
	if ( vis[pos][changed] ) return dp[pos][changed];
	ll ret1, ret2;
	if ( changed == 0 ) {
		ret1 = arr[pos] + solve(pos + 1, 0);
		ret2 = arr[pos]*-1 + solve(pos + 1, 1);
	} else if ( changed ) {
		ret1 = arr[pos]*-1 + solve(pos + 1, 0);
		ret2 = arr[pos] + solve(pos + 1, 1);
	}
	vis[pos][changed] = 1;
	return dp[pos][changed] = max(ret1, ret2);
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for ( int i = 0; i < n; ++i ) cin >> arr[i];
	cout << solve(0, 0) << endl;
    return 0;
}


Measured memory_bytes: 7424
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, m = i_map()
    for i in range(m):
        p, y = i_map()
        num_list.append([p, y, i])

    sorted_data = sorted(num_list, key=lambda x: x[1])
    sorted_data = sorted(sorted_data, key=lambda x: x[0])

    ans_list = []
    count_index = 0
    for num in sorted_data:
        if count_index != num[0]:
            count_index = num[0]
            count_num = 1
        else:
            count_num += 1
        ans_num = str(num[0]).zfill(6) + str(count_num).zfill(6)
        ans_list.append([num[2], ans_num])

    ans_list.sort()

    for ans in ans_list:
        print(ans[1])
 
if __name__ == '__main__':
    main()


Measured memory_bytes: 125020
#// Problem link : 
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<=n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}}cout<<endl;
#include<climits>
int n;
ll dp[100005];
std::vector<int> v(100004);
ll frog( int i)
{
	if(i>=n)
	{
		return 0;
	}
	if(dp[i]!=-1) return dp[i];
	ll op1 = frog(i+1)+abs(v[i+1]-v[i]);
	ll op2 = (i!=n-1)?frog(i+2)+abs(v[i+2]-v[i]):INT_MAX;
	dp[i] = min(op1,op2);
	return dp[i];
}
int main()
{
	memset(dp,-1,sizeof dp);
cin>>n;
for(int i=1;i<=n;i++)
{
	cin>>v[i];
}
cout<<frog(1);


}

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

import array
from bisect import *
from collections import *
from fractions import *
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())

def is_valid(arr):
    size = len(arr)
    sumarr = sum(arr)
    if max(arr) > 30000:
        return False

    gcd_of_all = gcd(arr[0], arr[1])
    for i in range(2, size):
        gcd_of_all = gcd(gcd_of_all, arr[i])
    if gcd_of_all != 1:
        return False

    for i in range(size):
        n1 = arr[i]
        n2 = sumarr - n1
        if gcd(n1, n2) == 1:
            return False
    return True

def brute_force(SIZE):
    MAX = 50
    for comb in combinations(list(range(1,MAX+1)), SIZE):
        if is_valid(list(comb)):
            return list(comb)

# N = 41で死ぬ
def solve(N):
    if N <= 4:
        ans = brute_force(N)
    else:
        ans = [2, 3, 4, 5]
        cand = 6
        sumans = sum(ans)
        while (len(ans) < N - 1):
            if not (cand % 2 == 0 or cand % 3 == 0 or cand % 5 == 0):
                cand += 1
                continue
            if len(ans) == N - 2:
                if (sumans + cand) % 2 == 1:
                    cand += 1
                    continue
            ans.append(cand)
            sumans += cand
            cand += 1

        ans.append(cand)
        while True:
            if is_valid(ans): break
            else: ans[-1] += 1
    # assert(is_valid(ans))
    return ans

print(*solve(N))

# # for debug
# for N in range(3, 20001):
#     ans = solve(N)
#     print("N {}: ok".format(N))
#     is_valid(ans)

# arr = list(range(1, 6000))
# while True:
#     random.shuffle(arr)
#     arr2 = arr[:3000]
#     if is_valid(arr2):
#         print("valid!", arr2)
#     else:
#         print("not valid")
    


# for a in range(1, MAX):
#     for b in range(a+1, MAX):
#         for c in range(b+1, MAX):
#             numset = [a,b,c]
#             if is_valid(numset):
#                 print(numset)


Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using namespace std;

int main(void) {
    Bint a, b, c, d;
    cin >> a >> b >> c >> d;
    Bint max = a * c;
    if (a * d > max)
        max = a * d;
    if (b * c > max)
        max = b * c;
    if (b * d > max)
        max = b * d;
    
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    double ave;
    ave=(double)sum/(double)n;
    double sa=10000000.0;
    rep(i,n){
        if(sa>=(double)abs((double)a[i]-ave)){
            sa=(double)abs((double)a[i]-ave);
        }
    }
    rep(i,n){
        if(sa==(double)abs((double)a[i]-ave)){
            Cout(i);
            return 0;
        }
    }
    return 0;
}


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

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

  if(N == 1)
    cout << "Hello World" << "\n";
  else {
      cin >> A >> B;
      cout << A+B << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
//#include<vector>
#include<algorithm>


#ifdef L_JUDGE
#pragma warning(disable:4996)
#endif

using namespace std;
const int MAXN=1005;
const int MODU=1e9+7;

bool isPrime[MAXN];
int primelist[MAXN];
int cntprime;
int num[MAXN];

void Init(){
    memset(isPrime,true,sizeof(isPrime));
    cntprime=0;
    isPrime[0]=isPrime[1]=false;
    for(int i=2;i<MAXN;i++){
        if(isPrime[i]){
             primelist[cntprime++]=i;
        }
        for(int pi=0;pi<cntprime;pi++){
            int tmp=primelist[pi]*i;
            if(tmp>=MAXN)continue;
            isPrime[tmp]=false;
            if(i%primelist[pi]==0)break;
        }
    }
}


int main(){
	#ifdef L_JUDGE
		freopen("in.txt","r",stdin);
//		freopen("out.txt","w",stdout);
	#endif
    Init();
    int N;
    cin>>N;
    memset(num,0,sizeof(num));
    for(int ni=2;ni<=N;ni++){
        int tmpni=ni;
        for(int pi=0;pi<cntprime;pi++) {
             if(primelist[pi]>tmpni)break;
             if(0==tmpni%primelist[pi]){
                 while(0==tmpni%primelist[pi]){
                     num[pi]++;
                     tmpni/=primelist[pi];
                 }
             }
        }
    }
    long long int ans=1;
    for(int i=0;i<cntprime;i++){
        if(num[i]==0)continue;
        ans=ans*(num[i]+1)%MODU;
    }
    printf("%lld\n",ans);


	#ifdef L_JUDGE
		fclose(stdin);
		fclose(stdout);
//		system("out.txt");
	#endif

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll A, B, X;

int main()
{
  std::cin >> A >> B >> X;

  puts( A <= X && X <= A+B ? "YES" : "NO" );

  return 0;
}

Measured memory_bytes: 256
import java.lang.Math.abs

fun main(args:Array<String>):Unit {
    while(true){
        val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0 && m == 0) return
        val cell = Array(n){readLine()!!.trim().toInt()}
        var pos = 0
        var goaled = false
        repeat(m){
            pos += readLine()!!.trim().toInt()
            if (!goaled){
                if (pos >= n - 1){
                    goaled = true
                    println(it + 1)
                }
                else {
                    pos += cell[pos]
                    if (pos >= n - 1) {
                        goaled = true
                        println(it + 1)
                    }
                }
            }
        }
    }

}



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

using pii = pair<int, int>;
using ll  = long long;
#define rep(i, j) for (int i = 0; i < (int)(j); i++)
#define repeat(i, j, k) for (int i = (j); i < (int)(k); i++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " : " << x << endl

template <class T>
bool set_min(T &a, const T &b) {
    return a > b ? a = b, true : false;
}

template <class T>
bool set_max(T &a, const T &b) {
    return a < b ? a = b, true : false;
}
// vector
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &a : v) is >> a;
    return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &t : v) os << "\t" << t;
    return os << endl;
}
// pair
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &v) {
    return os << "<" << v.first << ", " << v.second << ">";
}

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

int main() {
    int S, W; cin >> S >> W;
    cout << (W >= S ? "unsafe" : "safe") << endl;
    
    

    return 0;
}


Measured memory_bytes: 3592
//
// Created by tac on 2016/10/25.
//

#include <cstdlib>
#include <iostream>

namespace {

const int N_SIZE = 100;
int a[N_SIZE];

void print_array(int a[], int n) {
    for (int i = 0; i < n; ++i) {
        if (i > 0) {
            std::cout << " ";
        }
        std::cout << a[i];
    }
    std::cout << std::endl;
    return;
}

//1 bubbleSort(A, N) // N ??????????´?????????? 0-????????????????????? A
//2   flag = 1 // ????????£??\????´?????????¨??????
//3   while flag
//4     flag = 0
//5     for j ??? N-1 ?????? 1 ?????§
//6       if A[j] < A[j-1]
//7         A[j] ??¨ A[j-1] ?????????
//8         flag = 1
void sort_array(int a[], int n) {
    int count = 0;
    bool flag = true;
    while (flag) {
        flag = false;
        for (int j = n - 1; j > 0; --j) {
            if (a[j] < a[j - 1]) {
                std::swap(a[j], a[j - 1]);
                ++count;
                flag = true;
            }
        }
    }
    print_array(a, n);
    std::cout << count << std::endl;
    return;
}

}

int main() {
    int n;

    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
    }
    sort_array(a, n);

    return EXIT_SUCCESS;
}

Measured memory_bytes: 3096
import numpy as np 
import math

def comb2(n):
    return math.factorial(n) // (math.factorial(n-2) * math.factorial(2))

N = int(input())
S = {}
for i in range(N):
    s = ''.join(sorted(input()))
    if s in S.keys():
        S[s] += 1
    else:
        S[s] = 1
      
res = [comb2(e) if e>1 else 0 for e in S.values()]
print(sum(res))

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

using namespace std;
void output(deque<char> & q, int flg){
    if(flg>0) rep(i,q.size()) cout <<q[i];
    else{
        for(int i=q.size()-1;i>=0;i--){
            cout<<q[i];
        }
    }
    cout << endl;
}

int main(){
    string s; cin>>s;
    int Q; cin>>Q;
    deque<char> deq;

    // init deque
    rep(i,s.length()){
        deq.push_back(s[i]);
    }
    // 1:→　-1:←
    int dir = 1;
    rep(i,Q){
        int Ti; cin>>Ti;
        if(Ti==1){
            dir*=-1;
        }else{
            int F; char C;
            cin >> F >> C;
            if(F==2) F=-1;
            if(dir*F >0 ) deq.push_front(C);
            else deq.push_back(C);
        }

    }
    output(deq,dir);

    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
using namespace std;

int main()
{
	int q, lim, query, x;
	vector<int> List;
	vector<int>::iterator it;
	while(scanf("%d %d", &q, &lim) && q > 0)
	{
		for(int f1 = 1; f1 <= q; f1++){
			scanf("%d %d",&query, &x);
			switch(query)
			{
				case 0:
					List.push_back(x);
					if((int)List.size() > lim){
						it = List.begin();
						List.erase(it);
					}
				break;
				case 1:		
					it = List.begin() + (x - 1);
					List.erase(it);
				break;
				case 2:
					if(x <= (int)List.size() / 2)
						it = List.begin() + (x - 1);
					else
						it = List.end() - (List.size() - (x - 1));
					printf("%d\n", *it);
				break;
				default:
					it = find(List.begin(), List.end(), x);
					List.erase(it);
				break;
			}
		}
		printf("end\n");
		List.clear();
	}
	return 0;
}

Measured memory_bytes: 1720
#include <iostream>
using namespace std;
int main(void){
int N,M;
cin >> N >> M;
int sum = 0;
for(int i=0;i<M;i++){
int a;
cin >> a;
sum += a;
}

if(sum > N) cout << "-1" << endl;
else cout << N - sum << endl;

return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1e9;

typedef long long ll;

#define MAX_V 10000

struct edge {
    int to;
    int cost;
};


int V;
vector<edge> G[MAX_V];
int d[MAX_V];


void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}



int main(){
  int E,r;
  cin >> V >> E >> r;
  vector <int> R;
  REP(i,r){
    int aa;
    cin >> aa;
    aa--;
    R.pb(aa);
  }
  sort(R.begin(),R.end());
  REP(i,E){
    int f,t,c;
    cin >> f >> t >> c;
    f--;
    t--;
    edge e = {t,c};
    G[f].pb(e);
    e.to = f;
    G[t].pb(e);
  }
  int dis[V][V];
  REP(i,V){
    dijkstra(i);
    REP(j,V){
      dis[i][j] = d[j];
    }
  }
  int sum = 100000000;
  do{
    int res = 0;
    REP(i,r-1){
      res += dis[R[i]][R[i+1]];
    }
    sum = min(res,sum);
  } while(next_permutation(R.begin(),R.end()) );
  cout << sum << endl;
  /*REP(i,V){
    REP(j,V){
      cout << dis[i][j] << "  ";
    }
    cout << endl;
  }
  */
  /*
  for (int i=0; i<V; ++i) {
        if(d[i] != INF)
	  cout <<  d[i] << endl;
	else if(d[i] == INF)
	  cout << "INF" << endl;
  }
  */
  return 0;
}


Measured memory_bytes: 1152
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define LL long long int
#define REP(i,n) for (int i = 1; i <= (n); i++)
#define Redge(u) for (int k = h[u],to; k; k = ed[k].nxt)
#define cls(s,v) memset(s,v,sizeof(s))
#define mp(a,b) make_pair<int,int>(a,b)
#define cp pair<int,int>
using namespace std;
const int maxn = 100005,maxm = 100005,INF = 0x3f3f3f3f;
inline int read(){
	int out = 0,flag = 1; char c = getchar();
	while (c < 48 || c > 57){if (c == '-') flag = 0; c = getchar();}
	while (c >= 48 && c <= 57){out = (out << 1) + (out << 3) + c - 48; c = getchar();}
	return flag ? out : -out;
}
int main(){
	int K = read(),t = 1,now = 0;
	for (int i = 1; i <= 1000000; i++){
		now = (now + 1ll * t * 7 % K) % K;
		t = 1ll * t * 10 % K;
		if (!now){printf("%d\n",i); return 0;}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 3772
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()

	a := ""
	z := int('Z' - 'A' + 1)
	k := z
	cnt := 1
	for {
		if n <= k {
			n--
			for i := 0; i < cnt; i++ {
				a = string([]byte{byte('a' + n%26)}) + a
				n /= z
			}
			break
		}
		n -= k
		k *= z
		cnt++
	}

	fmt.Fprintln(stdout, a)
}


Measured memory_bytes: 1744
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	ll s; cin >> s;
	ll x1 = 0, y1 = 0;
	ll x2, y2, x3, y3;
	x2 = 1e9;
	x3 = 1;
	if (s%x2 == 0)y3 = s / x2;
	else y3 = s / x2 + 1;
	y2 = x2 * y3 - s;
	cout << 0 << " " << 0 << " " << x2 << " " << y2 << " " << x3 << " "<<y3<< endl;
	return 0;
}


Measured memory_bytes: 256
for _ in range(10000):
    res = list(map(int,input().split()))
    if res == [-1,-1,-1]:
        break
    su = res[0]+res[1]
    if su<30:
        gr="F"
    elif su<50:
        if res[2]>=50:
            gr="C"
        else:
            gr="D"
    elif su<65:
        gr="C"
    elif su<80:
        gr="B"
    else:
        gr="A"
    if res[0]==-1 or res[1]==-1:
        gr="F"
    print(gr)



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

int main() {
  int n;
  int num;  
  int copy;
  
  cin >> n;
  copy = n;
  num = 0;
  while (n > 0)
  {
    num += n % 10;   
    n /= 10;
  }
  if (!(copy % num))
    cout << "Yes" << endl;
  else
    cout << "No"  << endl; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(void){
	int n, k, m;
	m = 0;
	VI array;
	VI array2;
	cin >> n >> k;
	REP(i,n){
		int a = 0;
		cin >> a;
		array.push_back(a);
		m = max(m, a);
	}
	// dump(m);
	REP(i, m)
	{
		array2.push_back(0);
	}
	SORT(array);
	REP(i, n)
	{
		array2[array[i]-1] += 1;
	}
	SORT(array2);
	REP(i,m){
		// dump(array2[i]);
	}
	int cnt = 0;
	REP(i,m-k){
		cnt += array2[i];
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 2548
import math
N = int(input())
ans = 0

arr = set()
for a in range(1, int(math.sqrt(N))+1):
    for b in range(a, N+1):
        if N-(a*b) <= 0:
            break
        ans += 2
        if a == b:
            ans -= 1
print(ans)


Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int A;
  cin >> A;
  if(A == 0) {
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}

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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) cin<<(x);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x, v) lower_bound((x).begin(), (x).end(), (v))
#define uboundv(x, v) upper_bound((x).begin(), (x).end(), (v))
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	int n, a, ans=0;
	cin>>n;
	map<int, int> ma;
	F(n) {
		cin>>a;
		//cout<<ma[a]<<endl;
		if(ma[a]>0) {
			if(ma[a]==2) {
				ma[a]=1;
				ans--;
			}
			else {
				ma[a] = 2;
				ans++;
			}
		}
		else {
			ma[a] = 2;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  bool a[N];
  rep(i, N){
    cin >> a[i];
  }
  bool b[N] = {0};
  bool c[N] = {0};
  for(int i=N-1; i>=0; i--){
    if(a[i] != b[i]){
      rep(j, sqrt(i+1)){
        if((i+1)%(j+1) == 0){
          b[j] ^= 1;
          if((j+1)*(j+1) != i+1) b[(i+1)/(j+1) - 1] ^= 1;
        }
      }
      c[i]=1;
    }
  }
  int cnt = 0;
  rep(j, N){
    if(c[j]) cnt++;
  }
  cout << cnt << endl;
  rep(j, N){
   if(c[j]) cout << j+1 << endl;
  }
 
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;

int h1[2000000];
int w1[2000000];

int main(){
	
	while(true){
		
		int N, M;
		
		cin >> N >> M;
		if(N == 0 && M == 0){
			break;
		}
		
		int h[2000];
		int w[2000];
		
		for(int i = 0; i < 2000000; i++){
			h1[i] = 0;
			w1[i] = 0;
		}
		
		
		for(int i = 0; i < N; i++){
			cin >> h[i];
		}
		
		for(int i = 0; i < M; i++){
			cin >> w[i];
		}
		
		for(int i = 0; i < N; i++){
			int sum = 0;
			for(int j = i; j < N; j++){
				sum += h[j];
				h1[sum]++;
			}
		}
		
		for(int i = 0; i < M; i++){
			int sum = 0;
			for(int j = i; j < M; j++){
				sum += w[j];
				w1[sum]++;
			}
		}
		
		int ans = 0;
		
		for(int i = 0; i < 2000000; i++){
			ans += h1[i] * w1[i];
		}
		
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 18704
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
const int INF = 1001001001;

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

int dp[100005];
vector<vector<int>> to;

int rec(int i) {
	if (dp[i] != -1)return dp[i];

	int res = 0;
	for (auto v : to[i]) {
		chmax(res, rec(v) + 1);
	}
	return dp[i] = res;
}

int main() {
	int n, m;
	cin >> n >> m;
	to.resize(n);
	rep(i, m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		to[x].push_back(y);
	}
	rep(i, n) dp[i] = -1;

	int res = 0;
	rep(i, n) chmax(res, rec(i));
	cout << res << endl;
}

Measured memory_bytes: 8192
#include <iostream>

using namespace std;
int n,i,j,m,v[305][305],nr[305],ok[305],maxi,mini,m2,val;

int main()
{
    cin>>n>>m;
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++) cin>>v[i][j];
    maxi=0;
    for(i=1;i<=n;i++) nr[v[i][1]]++;
    for(j=1;j<=m;j++) maxi=max(maxi,nr[j]);
    mini=maxi;
    m2=m;
    for(i=1;i<=m;i++) ok[i]=1;
    while(m2>1)
    {
        maxi=0; val=0;
        for(j=1;j<=m;j++)
            if(ok[j] && nr[j]>maxi) maxi=nr[j], val=j;
        for(i=1;i<=n;i++)
        {
            j=1;
            while(ok[v[i][j]]==0) j++;
            if(v[i][j]==val)
            {
                j++;
                while(ok[v[i][j]]==0) j++;
                nr[v[i][j]]++;
            }
        }
        ok[val]=0;
        m2--;
        maxi=0;
        for(i=1;i<=m;i++) if(ok[i] && nr[i]>maxi) maxi=nr[i];
        if(maxi<mini) mini=maxi;
    }
    cout<<mini<<'\n';
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7;
const double PI = acos(-1);


int main (){
    ll n, ans = 0LL;

    cin >> n;

    vector<ll> count(62, 0LL);

    for (ll i=0; i<n; i++){
        ll a;
        cin >> a;
        bitset<62> b(a);
        for (ll j=0; j<62; j++){
            count[j] += b[j];
        }
    }

    for (ll i=0; i<62; i++){
        ans = (((((n - count[i])*(count[i]))%mod)*((1LL << i)%mod) + mod)%mod + mod + ans)%mod;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
int a[200000], vs[200000],b[200020], co[200200];
vector<int>v[300000];
string s;
int main()
{
    long long i, j, m, k, n, l;
    cin>>n;
    m=n/3; j=n/5; k=n/15;
    cout<<(n*(n+1))/2+15*(k*(k+1))/2-5*(j*(j+1))/2-3*(m*(m+1))/2<<endl;
    return 0;

}


Measured memory_bytes: 10704
s = input()

ATCG = ['A','T','C','G']
ans = 0
count = 0
for i in range(len(s)):
  temp = s[i]
  if temp in ATCG:
    count += 1
    ans = max(ans,count)
  else:
    ans = max(ans,count)
    count = 0
print(ans)

Measured memory_bytes: 3060
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let X = parseInt(input[0][0], 10);
    let K = parseInt(input[0][1], 10);
    let D = parseInt(input[0][2], 10);
    
    let tmp = Math.floor(Math.abs(X) / D);
    
    let ans;

    if (K <= tmp){
        ans = Math.abs(X) - D * K;
    } else {
        if ((K - tmp) % 2 === 0){
            ans = Math.abs(X) - D * tmp;
        } else {
            ans = Math.abs(X) - D * tmp;
            ans = D - ans;
        }
    }

    console.log(ans);

}


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


Measured memory_bytes: 29696
#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() {
  string s;
  cin >> s;
  if (s[2]==s[3] && s[4]==s[5]) {
      cout << "Yes" << endl;
  } else {
      cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<=e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const ll MAXN = 10000001;
ll spf[MAXN];

//O(nloglogn) 
void sieve() 
{   
    for(int i = 2;i<MAXN;i++){
        spf[i] = i;
    }
    spf[1] = 1; 
    for (int i=2; i*i<MAXN; i++) 
    { 
        if (spf[i] == i) 
        {   
            //spf[i] = i;
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  
//O(log n)
ll cf(ll x) 
{ 
    ll res = 1;
    ll y = spf[x]; 
    while (x != 1) 
    { 
        ll c = 0;
        while(spf[x] == y){
            c++;
            x = x/spf[x];
        }
        res*=(c + 1);
        y = spf[x];
         
    } 
    return res; 
    
}
void solve(){
    ll n;
    cin >> n;
    ll ans = 0;
    //cout << cf(81) << nl;
    for(ll i = 1; i < n; i++){
        ans += cf(i);
    }
    cout << ans << nl;
}
int main(){ 
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    sieve();
    ll TC = 1;
    //cin>>TC;
    fo(TT, TC){
        // Google,FB cout << "Case #"<< TT + 1 << ": ";
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 81928
#include <stdio.h>
int main(void){
	int S;
	scanf("%d",&S);
	int h,m,s;
	s=S%60;
	S-=s;
	S/=60;
	m=S%60;
	S-=m;
	S/=60;
	h=S;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

int main(){
	int H,W,i,j;
	cin >> H >> W ;
	while(H!=0||W!=0){
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			if(i%2){
				if(j%2){
					cout << '#';
				}else{
					cout << '.';
				}
			}else{
				if(j%2){
					cout << '.';
				}else{
					cout << '#';
				}
			}	
		}
		cout << endl;
	}
		cout << endl;
		cin >> H >> W ;
	}
	return 0;
}

Measured memory_bytes: 3116