akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        int former = scanner.nextInt();
        int answer = 0;
        int counter = 0;
        for (int i = 1; i < n; i++) {
            final int height = scanner.nextInt();
            if (height <= former) {
                counter++;
            } else {
                if (counter > answer) {
                    answer = counter;
                }

                counter = 0;
            }

            former = height;
        }

        System.out.println(Math.max(counter, answer));
    }
}


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

#define int long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second


signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int n,a,b;
    cin >> n >> a >> b;
    int ans = 0;
    int x = (n/(a + b));
    ans += (a*x);
    x = (n%(a + b));
    x = min(x,a);
    ans += (x);
    cout << ans;
}		

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;
import java.util.Queue; 


class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	private int[] myDist;
	
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			in.nextInt();
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		LinkedList<Integer> tempNode;
		Iterator<LinkedList<Integer>> outer = adjList.iterator();
		int  rw = 0;
		while (outer.hasNext()) {
			tempNode = outer.next();
			Iterator<Integer> inner = tempNode.iterator();
			while(inner.hasNext()) {
				adjMatrix[rw][inner.next()] = 1;
			}
			rw++;
		}
			
		for(int i = 0; i<totalVertex;i++) {
			for (int j = 0; j < totalVertex; j++) {
				if (adjMatrix[i][j] != null) {
					System.out.print(adjMatrix[i][j]);
				} else {
					System.out.print(0);
				}
				if (j != totalVertex-1) {
					System.out.print(" ");					
				}				
			}
			System.out.println(); 
		}
	}
	
	public void buildDist() {
		Queue<Integer> toVisit = new LinkedList<>(); 
		myDist = new int[totalVertex];
		for (int i = 1; i < totalVertex; i++) {
			myDist[i] = -1;
		}
		
		// myDist[1] = 0; // set distance to node 1 to be 0
		toVisit.add(0);
		
		while (!toVisit.isEmpty()) {
			int u =  toVisit.remove();
			// int v = 1;
			LinkedList<Integer> tempList = adjList.get(u);

			for (int j = 0; j<tempList.size(); j++) {
				int v = tempList.get(j);
				if (myDist[v] == -1) {
					toVisit.add(v);
					myDist[v]= myDist[u]+1;
				}
			}
		}
	}
	
	public void printDist() {
		for (int i = 1; i<=totalVertex; i ++) {
			System.out.println(i+" "+myDist[i-1]);
		}
	}
}

public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		// g.printAdjMatrix();
		g.buildDist();
		g.printDist();
	}
}


Measured memory_bytes: 28432
import java.util.Scanner;

/**
 * パーティション
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_B&lang=ja">ALDS1_6_B</a>
 */
public class Main {

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

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int q = partition(a, 0, n);

		for (int i = 0; i < n; i++) {
			if (0 < i) System.out.print(" ");
			if (i == q) System.out.print("[");
			System.out.print(a[i]);
			if (i == q) System.out.print("]");
		}
		System.out.println();

		sc.close();
	}

	private static int partition(int a[], int p, int r) {
		int j = p - 1;
		int x = a[r - 1];
		for (int i = p; i < r; i++) {
			if (a[i] <= x) {
				j++;
				int tmp = a[j];
				a[j] = a[i];
				a[i] = tmp;
			}
		}
		int tmp = a[r - 1];
		a[j] = x;
		a[r - 1] = tmp;

		return j;
	}

}



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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> list(N);
  for (int i = 0; i < N; i++) {
    string s;
    int a;
    cin >> s >> a;
    list.at(i) = make_tuple(s, - a, i);
  }
  sort(list.begin(), list.end());
  for (int i = 0; i < N; i++) {
    int b = get<2>(list.at(i));
    cout << b + 1 << endl;
  }  
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		String S=stdIn.next();
		int a=Integer.valueOf(S.substring(0,2));
		int b=Integer.valueOf(S.substring(2,4));
		if(a<=12&&b<=12&&a>0&&b>0)
			System.out.println("AMBIGUOUS");
		if(a<=12&&b>12&&a>0&&b>0)
			System.out.println("MMYY");
		if(a>12&&b<=12&&a>0&&b>0)
			System.out.println("YYMM");
		if(a>12&&b>12&&a>0&&b>0)
			System.out.println("NA");
		if(a==0&&b>12)
			System.out.println("NA");
		if(b==0&&a>12)
			System.out.println("NA");
		if(a==0&&b<=12&&b>0)
			System.out.println("YYMM");
		if(b==0&&a<=12&&a>0)
			System.out.println("MMYY");
		if(a==0&&b==0)
			System.out.println("NA");
	}
}

Measured memory_bytes: 22996
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>

using namespace std;

#define ALL(a) (a).begin(),(a).end()
#define REP(index, begin, end) for (int (index) = (begin); (index) < (end); (index)++)
#define RE(index, end) REP(index, 0, end)
#define INF INT_MAX / 3
#define DINT(x) printf(#x " = %d\n", x);
#define GETINT(x) scanf("%d", &x)
#define GETSTR(x) scanf("%s", x)

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

struct column_num
{
	int white,
		blue,
		red;
};

int main()
{
	int h, w;
	vector<column_num> row;
	GETINT(h);
	GETINT(w);
	RE(i, h)
	{
		char temp[256] = {};
		GETSTR(temp);
		column_num col = {};
		RE(j, w)
		{
			switch (temp[j])
			{
			case 'W':
				col.white++;
				break;
			case 'B':
				col.blue++;
				break;
			case 'R':
				col.red++;
				break;
			}
		}
		row.push_back(col);
	}
	int result = 0;
	REP(w_len, 0, h - 2)
	{
		int w_sum = 0;
		REP(i, 0, w_len + 1)
		{
			w_sum += row[i].white;
		}
		REP(b_len, w_len + 1, h - 1)
		{
			int b_sum = 0;
			REP(i, w_len + 1, b_len + 1)
			{
				b_sum += row[i].blue;
			}
			{
				int r_sum = 0;
				REP(i, b_len + 1, h)
				{
					r_sum += row[i].red;
				}
				int sum_all = w_sum + b_sum + r_sum;
				if (result < sum_all)
				{
					result = sum_all;
				}
			}
		}
	}
	printf("%d\n", (w * h) - result);
	return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <string>
#define loop(i,n) for(int i=0;i<(int)n;i++)

using namespace std;

int main()
{
int a,b,c;
cin>>a>>b>>c;

if((a==5 && b==5 && c==7) || (a==5 && b==7 && c==5) || (a==7 && b==5 && c==5))
    cout<<"YES"<<endl;
else cout<<"NO"<<endl;


}


Measured memory_bytes: 3616
t1,t2 = map(int, input().split())
a1,a2 = map(int, input().split())
b1,b2 = map(int, input().split())
x,y=(a1-b1)*t1 + (a2-b2)*t2, (a1-b1)*t1
if x == 0:
    print("infinity")
elif x*y > 0:
    print(0)
else:
    s,t = divmod(abs(y), abs(x))
    print(s*2+(1 if t else 0))


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

using namespace std;


typedef long long int ll;
typedef vector<int>vi;
typedef deque<int> di;
#define f(i, a, b) for(int i = a; i < b; i++)

int main() {
ll x;
ll n;
ll sum = 0;
cin >> x >> n;
int y[x];
f(i, 0, x) {
cin >> y[i];

}
sort(y,y+x);
f(j, 0, n) {
sum+= y[j];
}

cout << sum;

return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
struct Nums{
    long long n;
    vector<long long> kaijo;
    Nums(int N){
        n=N;
        kaijo.push_back(1);
        for(long long i=1;i<=n;i++){
            kaijo.push_back((kaijo[i-1]*i)%MOD);
        }
    }
    long myPow(long x, long n, long m){
        if(n == 0)
            return 1;
        if(n % 2 == 0)
            return myPow(x * x % m, n / 2, m);
        else
            return x * myPow(x, n - 1, m) % m;
    }
    long long modinv(long long a, long long m) {
        long long b = m, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }
    long long comb(long long N,long long K,long long rest){
        long long res=kaijo[N]*modinv(kaijo[K],rest)%rest;
        res*=modinv(kaijo[N-K],rest);
        res%=rest;
        return res;
    }
};
void Prime(vector<int>& primes,int n){
  vector<bool> memo(n,true);
  for(int i=2;i<=n;i++){
    if(memo[i]){
      int buf=i;
      while(buf<=n){
        memo[buf]=false;
        buf+=i;
      }
      primes.push_back(i);
    }
  }
}
signed main(){
  int n,k;cin>>n>>k;
  Nums lib(n);
  int res=0;
  vector<int> primes(1,0);
  Prime(primes,k);
  int num=primes.size();
  vector<int> memo(k*3,0);
  int hoge=0;
  for(int i=k;i>=2;--i){
    int sup=k/i;
    int buf=lib.myPow(sup,n,MOD);
    for(int j=1;j<=sup;j++){
      buf-=memo[j*i];
    }
    hoge+=buf;
    memo[i]=buf;
  }
  memo[1]=lib.myPow(k,n,MOD)-hoge;
  rep1(i,k){
    res+=i*memo[i];
    res%=MOD;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 6620
// AOJ 2784 Similarity of Subtrees
// 2018.4.15 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// 数値のハッシュ関数
#define HASHSIZ 500009
typedef struct { unsigned long long id; int c; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash+HASHSIZ;
int  many;

void insert(unsigned long long id)
{
	HASH *p = hash + (int)(id % HASHSIZ);
	while (p->id) {
		if (p->id == id) { many = 1, p->c++; return; }
		if (++p == hashend) p = hash;
	}
	p->id = id, p->c = 1;
}

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define M   1000000007
#define MAX 100002
int hi[MAX], *to[MAX];

long long dfs(int node)
{
	int i;
	unsigned long long ans;
	
	ans = 1;
	for (i = 0; i < hi[node]; i++) ans += (long long)dfs(to[node][i]) * M;
	insert(ans);
	return ans;
}

int main()
{
	int N, a, b, i, j;
	long long ans;
	int *memo;

	N = in();
	memo = malloc(N<<3);
	j = 0; for (i = 1; i < N; i++) {
		memo[j++] = a = in(), memo[j++] = b = in();
		hi[a]++;
	}
	for (i = 1; i <= N; i++) if (hi[i]) to[i] = malloc(hi[i]<<2);
	memset(hi, 0, N<<2);
	j = 0; for (i = 1; i < N; i++) {
		a = memo[j++], b = memo[j++];
		to[a][hi[a]++] = b;
	}

	dfs(1);

	ans = 0;
	if (many) for (i = 0; i < HASHSIZ; i++) {
		if ((j = hash[i].c) > 1) ans += (long long)j*(j-1) >> 1;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 19420
#include <iostream>
#include <vector>
#include <set>
using namespace std;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    vector<int> flag(10, 0);
    int ans = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(flag[s[i] - '0']) continue;
        vector<int> flag1(10, 0);
        for(int j = i + 1; j < s.size(); j++)
        {
            if(flag1[s[j] - '0']) continue;
            vector<int> flag2(10, 0);
            for(int k = j + 1; k < s.size(); k++)
            {
                if(flag2[s[k] - '0']) continue;
                ans++;
                flag2[s[k] - '0'] = true;
            }
            flag1[s[j] - '0'] = true;
        }
        flag[s[i] - '0'] = true;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N; ll x; cin >> N >> x;
  ll ans = 0;
  ll prev = 0;
  rep(i, N) {
    ll a; cin >> a;
    ll use = max(0LL, (prev + a) - x);
    ans += use;
    prev = a - use;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = []
for _ in range(N):
  A.append(input())
  
C = Counter(A)

print("AC x " + str(C["AC"]))
print("WA x " + str(C["WA"]))
print("TLE x " + str(C["TLE"]))
print("RE x " + str(C["RE"]))


Measured memory_bytes: 16468
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int ans[10050]={0};
  for(int i=1;i<=105;i++){
    for(int j=1;j<=105;j++){
      for(int k=1;k<=105;k++){
        int v=i*i+j*j+k*k+i*j+j*k+k*i;
        if(v<10050)ans[v]+=1;
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout << ans[i] << endl;
  }
}
          


Measured memory_bytes: 3596
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n,k=LI()
h=sorted(LI())
ans=sum(h[:max(0,n-k)])

print(ans)


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

int main()
{
    static char num[5];
    int i, sum;
    
    do{
        cin >> num;
        sum = 0;
        for(i = 0; *(num + i); i++){
            sum = sum + static_cast<int>(*(num + i) - '0');
		}
        if(sum == 0) break;
        cout << sum << endl;
    }while(1);

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  bool res = true;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    if (A % 2 == 0) if (A % 3 != 0 && A % 5 != 0) res = false;
  }
  if (res) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 3652
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def cal_divisors(N):
    divisors = []
    i = 1
    while i*i < N:
        if N % i == 0:
            divisors.append(i)
        i += 1
    divisors.sort()
    return divisors

def main():
    N = int(input())
    l = cal_divisors(N)
    ans = 0
    for i in l:
        if N//i - i > 1:
            ans += N//i - 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9416
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <iomanip>

#define maxn 100010

using namespace std;

int n, m;
int p[maxn], ans[maxn], x[maxn];
long long k;

void mult(int a[], int b[], int c[]) {
    int temp[maxn];
    for (int i = 1; i <= n-1; ++i) {
        temp[i] = c[b[i]];
    }
    for (int i = 1; i <= n-1; ++i) {
        a[i] = temp[i];
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    
    for (int i = 1; i <= n; ++i) {
        cin >> x[i];
    }
    
    cin >> m >> k;
    
    for (int i = 1; i <= n-1; ++i) {
        ans[i] = i;
        p[i] = i;
    }
    
    for (int i = 1; i <= m; ++i) {
        int x;
        cin >> x;
        swap(p[x-1], p[x]);
    }
    
    for (int i = 0; (1LL<<i) <= k; ++i) {
        if((k>>i)&1) {
            mult(ans, ans, p);
        }
        mult(p, p, p);
    }
    
    long long rez = x[1];
    cout << x[1] << "\n";
    for (int i = 1; i <= n-1; ++i) {
        rez += x[ans[i]+1] - x[ans[i]];
        cout << rez << "\n";
    }
}

Measured memory_bytes: 2816
from collections import defaultdict as dd
n, x, y = map(int, input().split())

ans_lis = dd(lambda: 0)
for j in range(1, n+1):
  for i in range(1, n+1):
    reg_way = abs(j - i)
    warp_x_y = abs(x - i) + 1 + abs(y - j)
    warp_y_x = abs(y - i) + 1 + abs(x - j)
    ans = min(reg_way, warp_x_y, warp_y_x)
    #print(j, i, ans)
    ans_lis[ans] += 1
    
for i in range(1, n):
  print(ans_lis[i] // 2)

Measured memory_bytes: 56796
import java.util.Scanner;

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

        char a = sc.next().charAt(0);
        char b = sc.next().charAt(0);

        System.out.println(solve(a, b));

        sc.close();
    }

    static char solve(char a, char b) {
        return (a == b) ? 'H' : 'D';
    }
}

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

int main() {
  int i; cin >> i;
  
  if(i >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	ll n, i, l, r, k, ans = -1;
	cin >> n >> k;
	vll a(n), b(n);
	for(i = 0; i < n; i++)
		cin >> a[i];
	for(i = 0; i < n; i++)
		cin >> b[i];
	sort(all(a));
	sort(all(b), greater <ll>());
	r = 0;
	for(i = 0; i < n; i++)
		r = max(r, a[i] * b[i]);
	l = 0;
	while(l <= r)
	{
		ll mid = (l + r) >> 1, c = 0;
		for(i = 0; i < n; i++)
		{
			if(a[i] * b[i] > mid)
				c += max(0ll, min(a[i], (ll)ceil((a[i] * b[i] - mid) / (db)b[i])));
		}
		// cout << c << ' ' << mid << endl;
		if(c <= k)
			ans = mid, r = mid - 1;
		else
			l = mid + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
import math

N, D = map(int, input().split())
P = []
for n in range(N):
    X_n, Y_n = map(int, input().split())
    P.append((X_n, Y_n))

def distance(p:tuple):
    return math.sqrt(p[0] ** 2 + p[1] ** 2)

count = [p for p in P if distance(p) <= D]
print(len(count))

Measured memory_bytes: 37228
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int N;
LL A[300000],nonzero[300000];

int main(void){
    GI(N);
    REP(i,N)GLL(A[i]);
    // A[N] = ((LL)1<<(LL)60)-1;
    nonzero[N] = N;
    for(int i=N-1;0<=i;i--){
        if(A[i+1] == 0)
            nonzero[i] = nonzero[i+1];
        else
            nonzero[i] = i+1;
    }
    LL ans = 0;
    REP(i,N){
        int j=i;
        LL x=0,s=0;
        while(j<N){
            x^=A[j];
            s+=A[j];
            if(x!=s)
                break;
            j = nonzero[j];
        }
        ans += j - i;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3840
N,Q = map(int, input().split())

S = input()
l =[0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())

left = [0] * N
if S[0:2] == "AC":
    left[1] = 1
for i in range(2,N):
    if S[i-1:i+1] == "AC":
        left[i] = left[i-2]+1
    else:
        left[i] = left[i-1]

for i in range(Q):
    if (l[i] == 1):
        res = left[r[i]-1]
    else:
        res = left[r[i]-1] - left[l[i]-2]
    if l[i] >= 2 and S[l[i]-1] == "C" and S[l[i]-2] == "A":
        res -= 1
    print(res)


Measured memory_bytes: 14200
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define itrep(it, a) for(it = (a).begin(); it != (a).end; it++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

int main(){
    int n, money, b, pizza, ans;
    vector<int> top;
    cin >> n >> money >> b >> pizza;
    rep(i,n){
        int inp;
        cin >> inp;
        top.push_back(inp);
    }
    sort(all(top), greater<int>());
    rep(i,n){
        ans = max(ans, pizza / money);
        pizza+=top[i];
        money+=b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1220
#include<iostream>
#include<vector>
#include<cstring>
typedef long long int lli;
using namespace std;

int main(){
  lli n,m,q;
  while(cin>>n>>m>>q,n){
    lli ans[m];
    lli h[2]={0};
    string s,b;
    for(int i=0;i<m;i++)ans[i]=(1LL<<n)-1;
    for(int i=0;i<q;i++){
      h[0]=0;
      cin>>s>>b;
      for(int j=0;j<n;j++)
	if(s[j]=='1')h[0]+=1LL<<j;
      //cout << "h:" << h << endl;
      h[1]^=h[0];
      for(int j=0;j<m;j++){
	if(b[j]=='1'){
	  ans[j]&=h[1];
	}else{
	  ans[j]&=~h[1];
	}
	//cout << "h[1]:"<<h[1] << endl;
	//cout << ans[j] << endl;
      }
    }
    for(int i=0;i<m;i++){
      if(__builtin_popcountll(ans[i])>1){
	cout << "?";
      }else{
	for(int j=0;j<n;j++){
	  if(ans[i]==1){
	    if(j<10){
	      cout << j;
	      break;
	    }else{
	      cout << (char)('A'-10+j);
	      break;
	    }
	  }
	  ans[i]/=2;
	}
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


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

    vvi a(10, vi(10));
    rep(i, n+1) {
        string t = to_string(i);
        a[t[0]-'0'][t[t.size()-1]-'0']++;
    }

    int res = 0;
    FOR(i, 1, 10) {
        FOR(j, 1, 10) {
            res += a[i][j]*a[j][i];
        }
    }

    cout  << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
S = gets.chomp

ans = []

current = N

while current > 0
  updated = false

  M.downto(1) do |m|
    n = current - m

    next if n < 0
    next if S[n] == '1'

    ans << m
    current = n
    updated = true
    break
  end

  break unless updated
end

if current == 0
  puts ans.reverse.join(' ')
else
  puts -1
end


Measured memory_bytes: 3964
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)

void read_problem(int& n, vector<int>& heap)
{
    scanf("%d\n", &n);

    heap.resize(n+1);
    heap[0] = numeric_limits<int>::min();
    FOR(i, 1, n+1) {
        scanf("%d", &heap[i]);
    }
}

int main()
{
    int n;
    vector<int> heap;
    read_problem(n, heap);

    FOR(i, 1, n+1) {
        int idx_parent = i/2;
        int idx_left   = 2*i;
        int idx_right  = 2*i + 1;

        printf("node %d: key = %d, ", i, heap[i]);
        if(idx_parent != 0)
            printf("parent key = %d, ", heap[idx_parent]);
        if(idx_left <= n)
            printf("left key = %d, ", heap[idx_left]);
        if(idx_right <= n)
            printf("right key = %d, ", heap[idx_right]);
        puts("");
    }

    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, K;
    cin >> N >> K;

    // K回の操作中，i回まず取り出して，そのうち価値が小さい方からK-i回戻す(i >= K-i)
    vector<ll> V(N); rep(i, N){cin >> V.at(i);}
    ll ans = 0;
    rep(a, K+1){rep(b, K+1){
        if ((a + b > K) || (a + b > N)){continue;}
        ll max_cd = K - (a + b);
        ll left = 0;
        ll right = N-1;
        priority_queue< ll, vector<ll>, greater<ll> > q;
        for(ll i=0;i<(ll)(a);i++){q.push(V.at(i));}
        for(ll i=N-1;i>(ll)(N-1-b);i--){q.push(V.at(i));}
        rep(i, max_cd){
            if (q.size() == 0){break;}
            ll x = q.top();
            if (x < 0){q.pop();} else {break;}
        }
        ll tmp_ans = 0;
        while(q.size() > 0){tmp_ans += q.top(); q.pop();}
        if (tmp_ans > ans){ans = tmp_ans;}
    }}
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
const int N=100005;

int lowbit(int x){return x&-x;}
int main(){
  //  freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout);
    int n;cin>>n;
    if (lowbit(n)==n) {puts("No");return 0;}
    puts("Yes");
    int m=n-(n+1)%4,s=m+1;
    printf("2 1\n%d %d\n",2+n,1+n);
    printf("1 3\n%d %d\n",1+n,3+n);

    if (n==m+1){
        int t=m^(m+1);
        for (int i=3;i<m;i++){
            if (i==t) continue;
            int x= i+1==t ? i+2 : i+1 ;
            printf("%d %d\n%d %d\n",i,x,i+n,x+n);
        }
        printf("%d %d\n%d %d\n",m,t,m+n,t+n);
        printf("%d %d\n",t,2+n);
        printf("%d %d\n%d %d\n",n,m,n+n,t);
        return 0;
    }

    for (int i=3;i<m;i++) printf("%d %d\n%d %d\n",i,i+1,i+n,i+n+1);
    printf("%d %d\n",m,2+n);
    if (n==m+2){
        printf("%d %d\n%d %d\n",s,s+1,s+n,s+1+n);
        printf("%d 1\n%d 1\n",s+1,s+n);
    } else if (n==m+3){
        printf("%d %d\n%d %d\n",s,s+1,s+n,s+1+n);
        printf("%d 1\n%d 1\n",s,s+1+n);
        printf("%d %d\n%d 3\n",s,s+2,s+2+n);
    }

    return 0;
}


Measured memory_bytes: 2816
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	ps := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&ps[i])
	}

	cnt := 0
	min := ps[0]
	for i, p := range ps {
		if i == 0 {
			continue
		}
		if p > min {
			cnt++
		}
		if min > p {
			min = p
		}
	}

	fmt.Println(n - cnt)
}


Measured memory_bytes: 4992
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> ls(n);

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

    sort(ls.begin(), ls.end());
    long long int ans = 0;
    for (int a = 0; a < n; a++) {
        for (int b = a+1; b < n; b++) {
            int lower = abs(ls[a] - ls[b]);
            int upper = ls[a] + ls[b];

            auto l = upper_bound(ls.begin(), ls.end(), lower);
            auto u = lower_bound(ls.begin(), ls.end(), upper);

            int lidx = l - ls.begin();
            int uidx = u - ls.begin();
            
            int num = uidx - lidx;

            if (lidx <= a && a < uidx) {
                num--;
            }
            if (lidx <= b && b < uidx)  {
                num--;
            }
            if (num > 0) {
                ans += num;
            }
        }
    }
    cout << ans / 3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	int a[2][100];
	int a1;
	int x = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a1;
		if(i){
			a[0][i] = a[0][i - 1] + a1;
		}else{
			a[0][i] = a1;
		}
	}
	for(int i = 0;i < n;i++){
		cin >> a1;
		if(i){
			a[1][i] = a[1][i - 1] + a1;
		}else{
			a[1][i] = a1;
		}
	}
	x = a[0][0] + a[1][n - 1];
	for(int i = 1;i < n;i++){
		x = max(x, a[0][i] + a[1][n - 1] - a[1][i - 1]);
	}
	cout << x << endl;
}

Measured memory_bytes: 256
#include "stdio.h"
int a[4];
void sort(void) {
  for (int i = 0; i < 3; i++) {
    for (int j = i; j < 3; j++) {
      if (a[i] > a[j]) {
        int tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }
}

int main() {
  scanf("%d %d %d", &a[0], &a[1], &a[2]);
  sort();
  printf("%d %d %d\n", a[0], a[1], a[2]);
}



Measured memory_bytes: 2108
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll dp[51][51][2501]={};//dp[i][j][k]:上からi段目まで見て左右各j個保留していて今のスコアがkの結び方
int main(){
	int N,K;
	scan(N>>K);
	ll MOD=1e+9+7;
	dp[0][0][0]=1;
	rep(i,N){
		rep(j,i+1){
			rep(k,K+1){
				int nextj=j;
				dp[i+1][nextj][k+nextj*2]+=dp[i][j][k];
				dp[i+1][nextj][k+nextj*2]%=MOD;

				nextj=j+1;
				dp[i+1][nextj][k+nextj*2]+=dp[i][j][k];
				dp[i+1][nextj][k+nextj*2]%=MOD;

				nextj=j;
				int x=j*2;
				dp[i+1][nextj][k+nextj*2]+=dp[i][j][k]*x;
				dp[i+1][nextj][k+nextj*2]%=MOD;

				if(j>=1){
					nextj=j-1;
					int x=j*j;
					dp[i+1][nextj][k+nextj*2]+=dp[i][j][k]*x;
					dp[i+1][nextj][k+nextj*2]%=MOD;
				}
			}
		}
	}
	prin(dp[N][0][K]);
	return 0;
}


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

int main() {
  for(int W, H, N; cin >> W >> H >> N && (W|H|N); ) {
    N *= 2;
    vector<double> x(N), y(N);
    for(int i = 0; i < N; ++i) {
      cin >> x[i] >> y[i];
    }
    x.push_back(W);
    y.push_back(0);
    x.push_back(W);
    y.push_back(H);

    vector<double> ys = y;
    ys.push_back(0);
    ys.push_back(H);
    for(int i = 0; i < x.size(); ++i) {
      for(int j = i+1; j < x.size(); ++j) {
        if(x[i] == x[j]) continue;
        double a = (y[i] - y[j]) / (x[i] - x[j]);
        double b = y[i] - a * x[i];
        if(0 < b && b < H) ys.push_back(b);
      }
    }
    sort(ys.begin(), ys.end());
    double res = 0;
    for(int i = 0; i+1 < ys.size(); ++i) {
      double m = (ys[i] + ys[i+1]) / 2.0;
      vector<pair<double, int> > v;
      for(int j = 0; j < N; ++j) {
        double rad;
        rad = (y[j] - m) / x[j]; //atan2(y[j] - m, x[j]);
        v.push_back(make_pair(rad, j));
      }
      sort(v.begin(), v.end());
      int s = v[N/2-1].second;
      int t = v[N/2].second;
      double y1 = (y[s] - m) / x[s] * W + m;
      double y2 = (y[t] - m) / x[t] * W + m;
      double w = min((double)H, y2) - max(0.0, y1);
      if(w <= 0.0) continue;
      res += (ys[i+1] - ys[i]) * w / pow((double)H, 2.0);
    }
    printf("%.10f\n", res);
  }
  return 0;
}

Measured memory_bytes: 1396
sa = list(input())
sb = list(input())
sc = list(input())
current_order = sa.pop(0)
result = 0
while True:

    if current_order == "a":
        result = sa
    elif current_order == "b":
        result = sb
    elif current_order == "c":
        result = sc

    try:

        current_order = result.pop(0)

    except:
        if current_order == "a":
            print("A")
        elif current_order == "b":
            print("B")
        elif current_order == "c":
            print("C")

        break


Measured memory_bytes: 3060
N, M = map(int, input().split())
a = map(int, input().split())
bc = [[0,0] for i in range(M)]

for i in range(M):
    b, c = map(int, input().split())
    bc[i][0] = c
    bc[i][1] = b

a = sorted(a)
bc = sorted(bc, reverse=True)

count = 0
for i in range(M):
    for j in range(bc[i][1]):
        a[count] = max(a[count], bc[i][0])
        count += 1
        if count >= N:
            break
    if count >= N:
        break

print(sum(a))


Measured memory_bytes: 31048
n = input()
K = int(input())
len_n = len(n)
dp = [[[0]*2 for _ in range(K+2)] for _ in range(len_n+1)]


dp[0][0][1] = 1
for i in range(1, len_n+1):
    d = int(n[i-1])
    for j in range(K+1):
        dp[i][j][0] += dp[i-1][j][0]
        dp[i][j+1][0] += dp[i-1][j][0]*9
        if 0 < d:
            dp[i][j+1][0] += dp[i-1][j][1]*(d-1)
            dp[i][j][0] += dp[i-1][j][1]
            dp[i][j+1][1] += dp[i-1][j][1]
        else:
            dp[i][j][1] += dp[i-1][j][1]

ans = dp[-1][K][0]+dp[-1][K][1]
print(ans)


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

int main(void){
  int n;cin >> n;
  int s[14],h[14],c[14],d[14];
  fill(s,s+14,0);fill(h,h+14,0);fill(c,c+14,0);fill(d,d+14,0);
  s[0]=1;h[0]=1;c[0]=1;d[0]=1;
  rep(i,n){
    char l;int a;
    cin >> l >> a;
    if(l == 'S')s[a] = 1;
    if(l == 'H')h[a] = 1;
    if(l == 'C')c[a] = 1;
    if(l == 'D')d[a] = 1;
  }
  rep(i,14){
    if(s[i] == 0)cout << "S " << i << endl;
  }
  rep(i,14){
    if(h[i] == 0)cout << "H " << i << endl;
  }
  rep(i,14){
    if(c[i] == 0)cout << "C " << i << endl;
  }
  rep(i,14){
    if(d[i] == 0)cout << "D " << i << endl;
  }
  return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 4e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time"<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//______________________________________________________________________________
const int N = 3003;
ll dp[N][N][4];
ll mat[N][N];
int n,m;
ll f(int i,int j,int k)
{
       if(i>=n || j >= m){return 0;}
       if(dp[i][j][k] != -1){return dp[i][j][k];}
       if(k != 3)
       {
              return dp[i][j][k] = max({mat[i][j]+f(i,j+1,k+1),f(i,j+1,k),mat[i][j]+f(i+1,j,0)});
       }
       else
       {
              return dp[i][j][k] = max(f(i+1,j,0),f(i,j+1,k));
       }
}
int main()
{
       int k;
       cin>>n>>m>>k;
       memset(mat,0,sizeof mat);
       memset(dp,-1,sizeof dp);
       fri(i,0,k){
              int x,y;
              cin>>x>>y;
              --x;--y;
              cin>>mat[x][y];
       }
       cout<<f(0,0,0)<<endl;
}


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

using namespace std;
using ll = long long;

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> id[10];
    for (int i = 0; i < n; i++) {
        id[s[i] - '0'].push_back(i);
    }
    ll cnt = 0;
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            for (int k = 0; k <= 9; k++) {
                if (id[i].empty() or id[j].empty() or id[k].empty()) continue;

                int id_i = id[i].front();
                auto it = upper_bound(id[j].begin(), id[j].end(), id_i);
                if (it == id[j].end()) continue;

                int id_j = *it;
                it = upper_bound(id[k].begin(), id[k].end(), id_j);
                if (it == id[k].end()) continue;

                ++cnt;
            }
        }
    }
    cout << cnt << '\n';
}

Measured memory_bytes: 512
#include<iostream>
#include <vector>
// #include "cxx-prettyprint/prettyprint.hpp"
#define MSG(x) std::cout << (x) << std::endl;

using namespace std;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int AB = A * B;
    int CD = C * D;
    int ans = AB;
    if (CD > AB) {
        ans = CD;
    }
    MSG(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;
 
int main(){
	
	long double a,b,x;
	long long ans;
	long long nm,n;
	cin >> a >> b >> x;
	     
	 nm = b/x;
	  
	  if(0==fmod(a,x)){
	  	n = a/x;
	  	ans = nm-n+1;
	  	cout << ans <<endl;}
	  else{
	  	n = a/x;
	  	ans = nm-n;
	  	cout << ans <<endl;}

  	     
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

inline bool valid(int x, int n) {
    return 0 <= x && x < n;
}

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

template <typename T>
inline T pop(queue<T>& q) {
    T front = q.front();
    q.pop();
    return front;
}

template <typename T>
inline T gcd(T a, T b) {
    for (; b; a %= b, swap(a, b));
    return a; 
}

template <typename T>
tuple<T, T, T> xgcd(T a, T b) {
    if (b == 0) return {1, 0, a};
    T x, y, g;
    tie(x, y, g) = xgcd(b, a%b);
    return {y, x-(a/b)*y, g};
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int N; cin >> N;
    vvi graph(N+1);
    vi H(N+1);
    

    int M; cin >> M;
    for (int i = 1; i <= N; i++) cin >> H[i];
    while (M--) {
        int A, B; cin >> A >> B;
        graph[A].push_back(B);
        graph[B].push_back(A);
    }

    

    int rst = 0;
    for (int i = 1; i <= N; i++) {
        bool isgood = 1;
        for (int j : graph[i]) {
            if (H[i] <= H[j]) {
                isgood = 0;
                break;
            }
        }
        if (isgood) ++rst;
    }
    cout << rst;
}

Measured memory_bytes: 8744
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
	double x[3], y[3], xp, yp, r;
	int n;
	scanf("%d", &n );
	for( int i=0; i<n; i++ ){
		scanf("%lf %lf %lf %lf %lf %lf", &x[0], &y[0], &x[1], &y[1], &x[2], &y[2]);
		double A1 = 2.0 * (x[1]-x[0]);
		double B1 = 2.0 * (y[1]-y[0]);
		double C1 = x[0]*x[0] - x[1]*x[1] + y[0]*y[0] - y[1]*y[1];
		double A2 = 2.0 * (x[2]-x[0]);
		double B2 = 2.0 * (y[2]-y[0]);
		double C2 = x[0]*x[0] - x[2]*x[2] + y[0]*y[0] - y[2]*y[2];
		xp = (B1*C2-B2*C1)/(A1*B2-A2*B1);
		yp = (C1*A2-C2*A1)/(A1*B2-A2*B1);
		r = sqrt( (xp-x[0])*(xp-x[0])+(yp-y[0])*(yp-y[0]) );
		printf("%.3f %.3f %.3f\n", xp, yp, r);
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
struct rest{
	char name[20];
	int point;
	int id;
};

rest r[108];

bool cmp(rest x, rest y){
	int fcmp = strcmp(x.name, y.name);
	if(fcmp < 0){
		return true;
	}else if(fcmp > 0){
		return false;
	}else{
		if(x.point > y.point){
			return true;
		}
		else{
			return false;
		}
	}
}
int main(){
	int n, i;
	cin >> n;
	for(i = 1; i <= n; i++){
		cin >> r[i].name;
		cin >> r[i].point;
		r[i].id = i;
	}
	sort(r + 1, r + n + 1, cmp);
	
	for(i = 1; i <= n; i++){
		cout << r[i].id << endl;
	}
	
	return 0;
}

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

using namespace std;

int main()
{
	long n, k;
    cin>>n>>k;
    long a[n], cost[n];
    for(int i = 0; i < n; ++i)
        cost[i] = INT_MAX;
    for(int i = 0; i < n; ++i)
        cin>>a[i];
    cost[0] = 0;
    for(int i = 0; i < n; ++i)
        for(int j = i + 1; j <= i + k and j < n; ++j)
            cost[j] = min(cost[j], cost[i] + abs(a[j] - a[i]));
    cout<<cost[n - 1];
    return 0;
}

Measured memory_bytes: 1792
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma region header
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
#pragma endregion
#pragma endregion

lint dp[1000][2020];

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	lint s; cin >> s;
	for (int i = 0; i < 700; i++) {
		for (int j = 0; j < 2013; j++) {
			dp[i][j] = 0;
		}
	}
    dp[0][0] = 1;
	
	for (int i = 1; i < 800; i++) {
		for (int j = 3 * i; j < 2005; j++) {
			for (int k = j - 3; k >= 0; k--) {
				dp[i][j] += dp[i - 1][k];//
			}
          dp[i][j]%=mod;
		}
	}
	lint ans = 0;
	for (int i = 1; i < 750; i++) {
		ans += dp[i][s];
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 14516