akhauriyash/Code-Regression huggingface dataset:
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
 
/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/

const int N=105;
const int W=1e5+5;
ll a[N];
ll b[N];
ll n,w;
ll dp[N][W];

ll get(ll i,ll w)
{
	if(i==0 || w==0)
	return dp[i][w]=0;
	if(dp[i][w]!=-1)
	return dp[i][w];
	if(a[i-1]>w)
	return dp[i][w]=get(i-1,w);
	ll ans=max(b[i-1]+get(i-1,w-a[i-1]),get(i-1,w));
	return dp[i][w]=ans;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		ll i,j;
		cin>>n>>w;
		rep(i,0,n){
			cin>>a[i]>>b[i];
		}
		rep(i,0,n+1)
		{
			rep(j,0,w+1)
			dp[i][j]=-1;
		}
		ll ans=get(n,w);
		cout<<ans<<'\n';
		
	}
	return 0;
}


Measured memory_bytes: 80128
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))

    ans = 0
    mx = a[0]

    for x in a[1:]:
        diff = mx - x
        if diff > 0:
            ans += diff
        mx = max(mx, x)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 92116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;

        public void Run()
        {
            string S = Console.ReadLine();

            int ret = 0;
            var stack = new Stack<char>();
            for (int i = 0; i < S.Length; i++)
            {
                if (stack.Count > 0 && stack.Peek() != S[i])
                {
                        ret += 2;
                        stack.Pop();
                }
                else
                {
                    stack.Push(S[i]);
                }
            }

            Console.WriteLine(ret);
        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13664
N,K=input().split()
n,k=int(N),int(K)
p=list(input().split())
ans = 0

for i in range (len(p)):
    p[i]=int(p[i])

pre=[0 for i in range (n+1)]
q=[0 for i in range (n-k+100)]


pre[0]=p[0]
for i in range(n):
    pre[i+1]=pre[i]+p[i]

for i in range(0,n-k+1):
    tmp = pre[i+k]-pre[i]
    ans = max(ans , tmp)

print ((ans + k) / 2)

Measured memory_bytes: 19600
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

//ある種類のものを結合し，それらが同じ属性かどうかを確認する．
const int MAX_N=int(1e5+1001);

int par[MAX_N]; // 親
int rank_t[MAX_N]; // 木の深さ
// n要素で初期化
void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        rank_t[i] = 0;
    }
}
// 木の根を求める
int find(int x) {
    if (par[x] == x) {
    return x;
    } else {
    return par[x] = find(par[x]);
    }
}
// xとyの属する集合を併合
void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank_t[x] < rank_t[y]) {
        par[x] = y;
    } else {
    par[y] = x;
    if (rank_t[x] == rank_t[y]) rank_t[x]++;
    }
}
// xとyが同じ集合に属するか否か
bool same(int x, int y) {
    return find(x) == find(y);
}

int main(){
    int debug=0;
    int N,M,K;
    cin>>N>>M>>K;
    init(N);
    vector<int> f_num(N,0);
    if(debug==1){
        REP(i,N){
            cout<<find(i)<<" ";
        }
        cout<<endl;
    }
    REP(i,M){
        int A,B;
        cin>>A>>B;
        A-=1;
        B-=1;
        f_num[A]+=1;
        f_num[B]+=1;
        if(debug==1){
            cout<<"before"<<find(A)<<find(B)<<endl;
        }
        unite(A,B);
               if(debug==1){
            cout<<"after:"<<find(A)<<find(B)<<endl;
        }
        
    }
    //frendcheinを用意して，フレンドのフレンドをグルーピングする
    vector<int> group_mem_num(N,0);
    REP(i,N){
        int tmp=find(i);
        group_mem_num[tmp]+=1;
    }
    //各フレンドチェイン内でフレンドの人数を出す
    //各フレンドチェイン内でブロック人数を出す
    vector<int> block_num_in_group(N,0);
    REP(i,K){
        int C,D;
        cin>>C>>D;
        C-=1;
        D-=1;
        if(same(C,D)){
            block_num_in_group[C]+=1;
            block_num_in_group[D]+=1;
        }
    }
    //各個人が属するフレンドチェインの人数の総数からフレンド人数とブロック人数を引く
    if(debug==1){
    REP(i,N){
        cout<<group_mem_num[find(i)]<<" ";
    }
    cout<<endl;
    }
    
    REP(i,N){
        cout<<group_mem_num[find(i)]-f_num[i]-block_num_in_group[i]-1<<" ";
    }
    cout<<endl;
}

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

int main(){
	int N,o=0,e=0,count=0;
	char stat='R';
	string S;
	cin>>S;
	N=S.size();
	vector<int> ans(N);
	for(int i=0;i<N;i++)ans[i]=0;
	for(int i=0;i<N;i++){
		if(stat=='R'){
			if(S[i]=='R'){
				if(i%2==0){
					e++;
				}else{
					o++;
				}
			}else{
				stat='L';
				if(i%2==0){
					e++;
				}else{
					o++;
				}
			}
		}else{
			if(S[i]=='L'){
				count++;
				if(i%2==0){
					e++;
				}else{
					o++;
				}
			}else{
				stat='R';
				if((i-1-count)%2==0){
					ans[i-1-count]=e;
					ans[i-2-count]=o;
				}else{
					ans[i-1-count]=o;
					ans[i-2-count]=e;
				}
				o=0;
				e=0;
				count=0;
				if(i%2==0){
					e++;
				}else{
					o++;
				}
			}
		}
	}
	if((N-1-count)%2==0){
		ans[N-1-count]=e;
		ans[N-2-count]=o;
	}else{
		ans[N-1-count]=o;
		ans[N-2-count]=e;
	}
	for(int i=0;i<N;i++){
		cout<<ans[i]<<" ";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<set>
using namespace std;

int main() {
	set<int> st;
	int n, x;
	scanf("%d", &n);
	while (n--) {
		scanf("%d", &x);
		if (st.count(x) == 0)
			st.insert(x);
		else
			st.erase(x);
	}
	printf("%d", st.size());
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

vector<int> G[100100], cnt(100100, 0), ans(100100);

void bfs(int s) {
  queue<pair<int, int>> q;
  q.push({s, -1});
  while (!q.empty()) {
    int v = q.front().first, p = q.front().second;
    q.pop();
    ans[v] = p + 1;
    for (int u: G[v]) {
      if (--cnt[u] == 0) {
        q.push({u, v});
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n, m;
  cin >> n >> m;
  rep(i, n - 1 + m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    cnt[b]++;
  }

  rep(i, n) {
    if (cnt[i] == 0) {
      bfs(i);
      break;
    }
  }
  rep(i, n) cout << ans[i] << '\n';




  
  return 0;
}

Measured memory_bytes: 7040
def Union(x,y,par):
    x = Find(x,par)
    y = Find(y,par)
    if par[x] < par[y]:
        par[y] = par[x]
    else:
        par[x] = par[y]

def Find(x,par):
    return x if x==par[x] else Find(par[x],par)

n,m=map(int,input().split())
p =list(map(int,input().split()))
par=[i for i in range(n)]
for _ in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    Union(x,y,par)
ans = 0
for i in range(n):
    ans += 1 if Find(p[i]-1,par)==Find(i,par) else 0
print(ans)


Measured memory_bytes: 14324
h,w=map(int,input().split())
data=[list(input()) for i in range(h)]
yoko=[[0]*w for i in range(h)]
for i in range(h):
	j=0
	while j <w:
		if data[i][j]=='#':
			j+=1
		else:
			start=j
			while j<w-1:
				j+=1
				if data[i][j]=='#':
					for k in range(start,j):
						yoko[i][k]=j-start-1
					j+=1
					break
			else:
				j+=1
				for k in range(start,j):
					yoko[i][k]=j-start-1
				j+=1
# for i in range(h):
# 	print(yoko[i])

for j in range(w):
	i=0
	while i <h:
		if data[i][j]=='#':
			i+=1
		else:
			start=i
			while i<h-1:
				i+=1
				if data[i][j]=='#':
					for k in range(start,i):
						yoko[k][j]+=i-start-1
					i+=1
					break
			else:
				i+=1
				for k in range(start,i):
					yoko[k][j]+=i-start-1
				i+=1

# print(yoko)
for i in range(h):
	# print(yoko[i])
	yoko[i]=max(yoko[i])
print(max(yoko)+1)







Measured memory_bytes: 221064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	double res = 0;
	double X;
	string S;
	for (int i = 0; i < N; i++) {
		cin >> X >> S;
		if (S[0] == 'J') {
			res += X;
		}
		else {
			res += X * 380000;
		}
	}
	cout << fixed << setprecision(15) << res << endl;
}

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

using namespace std;

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<int> a(n, -1);
    int ans = 0;

    for (int i = 0; i < m; i++) {
        int s, c;
        cin >> s >> c;

        if (a[s - 1] != -1 && a[s - 1] != c) {
            cout << -1 << endl;
            return 0;
        }
        a[s - 1] = c;
    }

    if (a[0] == -1) a[0] = n != 1;

    for (int i = 0; i < n; i++) {
        if (a[i] == -1) continue;
        ans += pow(10, n - i - 1) * a[i];
    }

    if (max((int)log10(ans), 0) + 1 != n) {
        cout << -1 << endl;
        return 0;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 640
program prob4
    implicit none
    character(len=100) :: s
    integer :: i, n

    read(*,*) s

    n = len_trim(s)

    do i = 1, 6
        if(s(1:i)//s(n+i-6:n) == "keyence") then
            write(*,*) "YES"
            stop
        end if
    end do
    
    if(s(1:7) == "keyence") then
        write(*,*) "YES"
        stop
    end if
    
    if(s(n-6:n) == "keyence") then
        write(*,*) "YES"
        stop
    end if
    write(*,*) "NO"
    
    stop
contains
end program prob4

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N;
    string S;
    scan(N);
    scan(S);
    writeln(S[0 .. N / 2] == S[N / 2 .. $] ? "Yes" : "No");
}



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

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

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

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
# coding:utf-8

import numpy as np


def main():
    r, g, b, n = map(int, input().split())

    R = np.arange(0, n + 1, r)
    G = np.arange(0, n + 1, g)

    RG = np.add.outer(R, G).flatten()

    RG = RG[RG <= n]
    RG = RG[(n - RG) % b == 0]
    print(len(RG))


if __name__ == '__main__':
    main()


Measured memory_bytes: 153232
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007
ll fac[1000000];
ll finv[1000000];
ll inv[1000000];

void comb_init(){
  fac[0] = 1;
  fac[1] = 1;
  for(int i=2;i<1000000;i++){
    fac[i] = i*fac[i-1];
    fac[i] %= MOD;
  }
  inv[1] = 1;
  for(int i=2;i<1000000;i++){
    inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
  }
  finv[0] = 1;
  finv[1] = 1;
  for(int i=2;i<1000000;i++){
    finv[i] = inv[i]*finv[i-1];
    finv[i] %= MOD;
  }
}

ll comb(ll n,ll k){
  ll c;
  c = fac[n];
  c *= finv[k];
  c %= MOD;
  c *= finv[n-k];
  c %= MOD;
  return c;
}

int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  bool flag = true;
  if(n%2 != 0) flag = false;
  if(!flag){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0;i<n/2;i++){
    if(s[i] != s[i+n/2]) flag = false;
  }

  if(flag){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;

  return 0;
}


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

int main()
{
	ll n,k;
   cin >> n >> k;
   vector<ll> a(n),f(n);
   for(int i = 0;i<n;i++)cin >> a[i];
   for(int i = 0;i<n;i++)cin >> f[i];
   sort(a.begin(),a.end());
   sort(f.rbegin(),f.rend());
   ll sum = 0;
   for(auto i:a)sum += i;
   if(sum<=k)
   {
      cout<<0<<endl;
      return 0;
   }
   ll l = 0,r = 1e18;
   while(1)
   {
      ll m = (l+r)/2;

      ll now = 0;
      for(int i = 0;i<n;i++)
      {
         now += max(0LL,a[i]-m/f[i]);
      }
      if(k<now)l = m;
      else r = m;
      if(r-l<2)break;
   }
   cout<<r<<endl;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
    int n, q;
    scanf("%d", &n);
    vector<int> S(n);
    for(auto it=S.begin(); it!=S.end(); it++){
        scanf("%d", &(*it));
    }
    S.push_back(-1);
    scanf("%d", &q);
    int sum=0;
    for(int i=0; i<q; i++){
        int qq;
        scanf("%d", &qq);
        *S.end()=qq;
        auto it=S.begin();
        for(; *it!=qq; it++){
        }
        sum+=it==S.end() ? 0 : 1;
    }
    printf("%d\n", sum);
    return 0;
}

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

int main() {
int64_t   a,p,x,i;
	x=1;
	p=1000000000000000000;
	cin >>  a ;
  vector<int64_t> vec(a);
  for (i = 0; i < a; i++) {
    cin >> vec.at(i);
  if ( vec.at(i) == 0) {
      cout << 0 << endl;
	return 0;
	}
  }
  for (i = 0; i < a; i++) {
   if (x>p/vec.at(i)) {
      cout << -1 << endl;
	return 0;
	}
   x=x*vec.at(i);
   }
   if (x<=p && 0 < x) {
     cout << x << endl;
	}
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int n,m,q;
vector<ll> a,b,c,d;

ll score(const vector<int> &A){
    ll res=0;
    rep(i,q){
        if(A[b[i]]-A[a[i]]==c[i]) res+=d[i];
    }
    return res;
}

ll dfs(vector<int> &A){
    if(A.size()==n){
        return score(A);
    }

    ll res=0;
    int  prev_last=(A.empty() ? 0 : A.back());
    for(int add=prev_last;add<m;add++){
        A.push_back(add);
        res=max(res,dfs(A));
        A.pop_back();
    }

    return res;
}

int main() {
    cin>>n>>m>>q;
    a.resize(q),b.resize(q),c.resize(q),d.resize(q);
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--,b[i]--;
    }
    vector<int> A;
    cout<<dfs(A)<<endl;
}



Measured memory_bytes: 3640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.stream.LongStream;
import java.util.stream.Stream;
import java.util.PriorityQueue;
import java.util.Collection;
import java.util.Scanner;
import java.util.Queue;
import java.util.Comparator;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author acesine
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            List<Long> a = new ArrayList<>();
            for (int i = 0; i < 3 * N; i++) {
                a.add(in.nextLong());
            }
            Queue<Long> head = new PriorityQueue<>(Comparator.naturalOrder());
            Queue<Long> tail = new PriorityQueue<>(Comparator.reverseOrder());
            for (int i = 0; i < N; i++) {
                head.add(a.get(i));
                tail.add(a.get(a.size() - 1 - i));
            }
            assert head.size() == N;
            assert tail.size() == N;
            long[] l = new long[N + 1];
            long[] r = new long[N + 1];
            l[0] = head.stream().mapToLong(Long::longValue).sum();
            r[N] = tail.stream().mapToLong(Long::longValue).sum();
            for (int i = 1; i <= N; i++) {
                if (a.get(N + i - 1) > head.peek()) {
                    long t = head.poll();
                    head.add(a.get(N + i - 1));
                    l[i] = l[i - 1] + a.get(N + i - 1) - t;
                } else {
                    l[i] = l[i - 1];
                }
                if (a.get(2 * N - i) < tail.peek()) {
                    long t = tail.poll();
                    tail.add(a.get(2 * N - i));
                    r[N - i] = r[N - i + 1] + a.get(2 * N - i) - t;
                } else {
                    r[N - i] = r[N - i + 1];
                }
                assert tail.size() == head.size();
            }
            long max = l[0] - r[0];
            for (int i = 1; i <= N; i++) {
                if (l[i] - r[i] > max) max = l[i] - r[i];
            }
            out.println(max);
        }

    }
}



Measured memory_bytes: 99584
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t;cin>>n>>t;
  int a[t];for(int i=0;i<t;i++)cin>>a[i];
  sort(a,a+t);
  int c=a[t-1];
  int sum=0;
  for(int i=0;i<t-1;i++)sum+=a[i];
  cout<<max(0,c-sum-1)<<endl;
}
  

Measured memory_bytes: 384
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var a = int.Parse(line[1]);
        var b = int.Parse(line[2]);
        var c = int.Parse(line[3]);
        var d = int.Parse(line[4]);
        var p1 = ((n + a - 1) / a) * b;
        var p2 = ((n + c - 1) / c) * d;
        Console.WriteLine(Math.Min(p1, p2));
    }
}


Measured memory_bytes: 9196
#include <stdio.h>
#define INF 1010001000

int d[101][101][21];
int ans[101][101];
int p[21], q[51][21], r[51][21];
int n, m, s, g, cl;

void init(void);
int calc(int val, int col);
int min(int a, int b);

int main(void)
{
    int i, j, k, l, z, x;
    int fr, to, c, val;
    scanf("%d %d %d %d %d", &n, &m, &cl, &s, &g);
    while (n != 0) {
        init();
        if (n != 0) {
            for (i = 0; i < m; i++) {
                scanf("%d %d %d %d", &fr, &to, &val, &c);
                d[fr][to][c] = min(d[fr][to][c], val);
                d[to][fr][c] = min(d[to][fr][c], val);
            }
        }
        for (i = 1; i <= cl; i++) {
            scanf("%d", &p[i]);
        }
        for (i = 1; i <= cl; i++) {
            q[0][i] = 0;
            for (j = 1; j < p[i]; j++) {
                scanf("%d", &q[j][i]);
            }
            for (j = 0; j < p[i]; j++) {
                scanf("%d", &r[j][i]);
            }
        }
        for (l = 1; l <= cl; l++) {
            for (k = 1; k <= n; k++) {
                for (i = 1; i <= n; i++) {
                    for (j = 1; j <= n; j++) {
                        d[i][j][l] = min(d[i][j][l], 
                                d[i][k][l] + d[k][j][l]);
                    }
                }
            }
        }
        for (i = 1; i <= n; i++) {
            for (j = 1; j <= n; j++) {
                for (k = 1; k <= cl; k++) {
                    d[i][j][k] = calc(d[i][j][k], k);
                }
            }
        }
        for (i = 1; i <= n; i++) {
            for (j = 1; j <= n; j++) {
                for (l = 1; l <= cl; l++) {
                    ans[i][j] = min(ans[i][j], d[i][j][l]);
                }
            }
        }
        for (k = 1; k <= n; k++) {
            for (i = 1; i <= n; i++) {
                for (j = 1; j <= n; j++) {
                    ans[i][j] = min(ans[i][j], ans[i][k] + ans[k][j]);
                }
            }
        }

        if (ans[s][g] == INF) { 
            puts("-1");
        } else {
            printf("%d\n", ans[s][g]);
        }
        scanf("%d %d %d %d %d", &n, &m, &cl, &s, &g);
    }
    return 0;
}



int calc(int val, int col)
{
    int ans = 0, i;
    if (val == INF) {
        return INF;
    }
    if (p[col] != 1) {
        for (i = 1; i < p[col]; i++) {
            if (q[i][col] > val) {
                ans += ((val-q[i-1][col]) * r[i-1][col]);
                return ans;
            } else {
                ans += (q[i][col] - q[i-1][col]) * r[i-1][col];
            }
        }
    } else {
        i = 1;
    }
    if (q[i-1][col] < val) {
        ans += (val - q[i-1][col]) * r[i-1][col];
    }
    //printf("%d %d %d\n", val, col, ans);
    return ans;
}

int min(int a, int b)
{
    return a<b?a:b;
}

void init(void)
{
    int i, j, k;
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= n; j++) {
            ans[i][j] = INF;
            for (k = 1; k <= cl; k++) {
                d[i][j][k] = INF;
            }
        }
        ans[i][i] = 0;
        for (k = 1; k <= cl; k++) {
            d[i][i][k] = 0;
        }
    }
}

Measured memory_bytes: 1496
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');

        int[] num = new int[3];

        num[0] = int.Parse(str[0]);
        num[1] = int.Parse(str[1]);
        num[2] = int.Parse(str[2]);

        Array.Sort(num);

        Console.WriteLine(num[0] + " " + num[1] + " " + num[2]);
    }
}

Measured memory_bytes: 9392
#include <stdio.h>

int main(){
  int a,b,c,w;

  scanf("%d%d%d",&a,&b,&c);

  if(a>c){
    w=c;
    c=a;
    a=w;
  }
  if(b>c){
    w=c;
    c=b;
    b=w;
  }
  if(a>b){
    w=b;
    b=a;
    a=w;
  }
  printf("%d %d %d\n",a,b,c);
  return 0;
}

Measured memory_bytes: 1812
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <cstdint>

using namespace std;

int main()
{
    uint64_t N, Q;
    cin >> N;
    unordered_map<uint64_t, int> hmap;
    uint64_t tot = 0;
    for (int i = 0; i < N; ++i)
    {
        int a;
        cin >> a;
        if (hmap.find(a) != hmap.end())
            hmap[a] += 1;
        else
            hmap[a] = 1;
        tot += a;
    }
    cin >> Q;
    vector<uint64_t> ans(Q);
    for (int i = 0; i < Q; ++i)
    {
        int b, c;
        cin >> b >> c;
        ans[i] = i > 0 ? ans[i - 1] : tot;
        auto it = hmap.find(b);
        if (it != hmap.end())
        {
            int &nb = it->second;
            hmap[c] += nb;
            ans[i] += (c - b) * nb;
            nb = 0;
        }
    }
    for (int i = 0; i < Q; ++i)
        cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 7496
fn main() {
    let n = read::<i32>();
    let k = read::<i32>();

    let mut a = 1;
    for _ in 0..n {
        if a < k {
            a *= 2;
        } else {
            a += k;
        }
    }
    println!("{}", a);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

using namespace std;

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

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s;
    cin >> s;
    rep (i, s.size()) {
        if (i % 2 == 0) cout << s[i];
    }
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 592
#include <stdio.h>

int main(void)

{

int a,b,c,i;

int count;

scanf("%d %d %d\n",&a,&b,&c);

for(i=a,count=0;i<=b;i++){

if(c%i==0)

count++;

}

printf("%d\n",count);

return 0;

}

Measured memory_bytes: 600
#Detectando Ciclos en un grafo
#Se puede mejorar a un mas
from collections import deque
import sys

def dfs(G,u):
    n = len(G)
    vis=[-1]*n
    stackV = []
    pila = deque()
    pila.append(u)
    vis[u]=1
    stackV.append(u)
    while(pila):
        w = pila.pop()
        for v in G[w]:
            if(vis[v]==-1):
                vis[v]=1
                pila.append(v)
                stackV.append(v)
            elif(vis[v]==1 and v==u):
                return True
    return False

def main():
    G =[]
    val = [int(x) for x in sys.stdin.readline().strip().split()]
    for i in range(val[0]):
        G.append([])
    for i in range(val[1]):
        L = [int(x) for x in sys.stdin.readline().strip().split()]
        G[L[0]].append(L[1]) 
    veri=[]

    for i in range(val[0]):
        veri.append(dfs(G,i))
    if(True in veri):print(1)
    else:print(0)
        
main()
        



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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    ll cnt = 0;
    vector<ll> A(N);
    rep (i, N) {
        cin >> A[i];
        if (A[i] < 0) {
            cnt++;
        }
    }

    ll memo = INF;
    rep (i, N) {
        if (memo > abs(A[i])) {
            memo = abs(A[i]);
        }
    }

    ll ans = 0;
    rep (i, N) {
        ans += abs(A[i]);
    }

    if (cnt%2) {
        ans -= memo*2;
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;
typedef pair<ll,ll> P;

int main() {
  int n;
  cin>>n; 
  vector<ll>a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end()); 
  int co=0;
  rep2(i,1,n){
    a[i]+=a[i-1];
  }
  rep2(i,1,n){
    if(a[i]>3*a[i-1]){
      co=i;
    }
  }
  cout<<n-co<<endl;
}

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

//long long int kk(int a)
//{
//	if(a==1)return 1;
//	long long int s;
//	s=1+2*kk(a/2);
//	return s;
//}
int main()
{
	long long int h,s,i,k=1;
	cin>>h;
	for(i=1;k<=h;)
	    k*=2;
	k--;
	cout<<k;
	return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	int n, k; cin >> n >> k;

	string s; cin >> s;

	for(int i = 0; i < n; i++){
		if(i == k - 1)
			cout << (char) (s[i] - 'A' + 'a');
		else
			cout << s[i];
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
num1,num2,num3=0,0,0
for i in range(n):
    if a[i]==1:
        num1+=1
    elif a[i]==2:
        num2+=1
    else:
        num3+=1
dp=[[[-1.0 for k in range(n+1)] for i in range(n+1)] for j in range(n+1)]
def f(n1,n2,n3):
    if dp[n1][n2][n3]>=0.0:
        return dp[n1][n2][n3]
    if n1==n2==n3==0:
        return 0.0
    ret=n
    if n1>0:
        ret+=f(n1-1,n2,n3)*n1
    if n2>0:
        ret+=f(n1+1,n2-1,n3)*n2
    if n3>0:
        ret+=f(n1,n2+1,n3-1)*n3
    ret*=1.0/(n1+n2+n3)
    dp[n1][n2][n3]=ret
    return dp[n1][n2][n3]
print(f(num1,num2,num3))

Measured memory_bytes: 364560
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	difference_of_big_integers
# CreatedDate:  2020-07-26 14:25:25 +0900
# LastModified: 2020-07-26 14:25:41 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    a, b = map(int, input().split())
    print(a-b)


if __name__ == "__main__":
    main()



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

int main(){
    int N;
    cin >> N;
    vector<int> a;
    for (int i = 0; i < N; i++) {
        int t;
        cin >> t;
        a.push_back(t);
    }
    for (int i = 0; i < N; i++) {
        if (a[i] % 2 == 0) {
           if(a[i] % 3 != 0 && a[i] % 5 != 0) {
               cout << "DENIED" << "\n";
               exit(0);
           }
        }
    }
    cout << "APPROVED" << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
  string S;
  cin >> S;

  if(S.size()%2!=0)
    {
      cout << "No" << endl;
      return 0;
    }
  
  for(int i=0; i<S.size(); i++)
    {
      if(i%2 == 0 && S[i]!='h')
	{
	  cout << "No" << endl;
	  return 0;
	}
      if(i%2==1 && S[i]!='i')
	{
	  
	  cout << "No" << endl;
	  return 0;
	}
    }

  cout << "Yes" << endl;
 
  return 0;
}
 
 
//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count
 


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

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

map<ll, ll> prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; ++i) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    map<ll,ll> ans;
    for(ll i=2;i<=N;++i){
        map<ll,ll> M=prime_factor(i);
        for(auto p: M){ans[p.first]+=p.second;ans[p.first]%=MOD;}
    }
    ll ret=1;
    for(auto p: ans){ret*=p.second+1;ret%=MOD;}
    prt(ret)
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){int n,i,j,s,m,a[5000];while(scanf("%d", &n)&&n){for(i=0;i<n;i++)scanf("%d",&a[i]);m=-2147483647;for(i=0;i<n;i++,s=0)for(j=i;j<n;j++)if((s+=a[j])>m)m=s;printf("%d\n",m);}}

Measured memory_bytes: 0
//============================================================================
// Name        : desk.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<stdio.h>
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
int m,f,r;
while(1){
	cin>>m>>f>>r;
	if(m==-1&&f==-1&&r==-1){
		break;
	}
	if(m==-1||f==-1){
		cout<<"F"<<endl;
	}
	else if(m+f>=80){
		cout<<"A"<<endl;
	}
	else if(m+f>=65){
		cout<<"B"<<endl;
	}
	else if(m+f>=50){
		cout<<"C"<<endl;
	}
	else if(m+f>=30){
		if(r>=50){
			cout<<"C"<<endl;
			}
		else{
			cout<<"D"<<endl;
			}
		}

	else{
		cout<<"F"<<endl;
	}
}
  return 0;
}

Measured memory_bytes: 3068
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int w,h,n,x1,x2,y1,y2,x,y,a,i,s;
	scanf("%d %d %d",&w,&h,&n);
	x1=0;	x2=w;
	y1=0;	y2=h;
	for(i=0;i<n;i++)	{
		scanf("%d %d %d",&x,&y,&a);
		if(a==1)	x1=max(x1,x);
		if(a==2)	x2=min(x2,x);
		if(a==3)	y1=max(y1,y);
		if(a==4)	y2=min(y2,y);
	}
	if(x2-x1<0 || y2-y1<0)	s=0;
	else s=(x2-x1)*(y2-y1);
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <iomanip>
#include <numeric>
#include <bitset>

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

using namespace std;

typedef long long ll;

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  int h, w, k;
  cin >> h >> w >> k;

  char cake[333][333];
  int ans[333][333] = {0};

  rep(i, h) {
    rep(j, w) {
      cin >> cake[i][j];
    }
  }

  bool is_empty_row[333];
  rep(i, 333) {
    is_empty_row[i] = false;
  }

  rep(i, h) {
    bool f = true;
    rep(j, w) {
      if (cake[i][j] == '#') {
        f = false;
      }
    }
    if (f) { is_empty_row[i] = true; }
  }

  int now = 1;
  rep(i, h) {
    rep(j, w) {
      if (cake[i][j] == '#') {
        ans[i][j] = now++;
      }
    }
  }

  rep(i, h) {
    rep(j, w) {
      if (ans[i][j] == 0) {
        // look left
        int t = j;
        while ( ans[i][t] == 0 && t > 0) { t--; }
        ans[i][j] = ans[i][t];
      }
      if (ans[i][j] == 0) {
        // look right
        int t = j;
        while ( ans[i][t] == 0 && t < w-1) { t++; }
        ans[i][j] = ans[i][t];
      }
    }
  }

  rep(i, h) {
    rep(j, w) {
      if (is_empty_row[i]) {
        int t = i;
        while (is_empty_row[t]) { t++; }
        ans[i][j] = ans[t][j];
      }
    }
  }

  rep(i, h) {
    rep(j, w) {
      if (ans[i][j] == 0) {
        int t = i;
        while (ans[t][j] == 0 && t > 0) { t--; }
        ans[i][j] = ans[t][j];
      }
    }
  }

  rep(i, h) {
    rep(j, w) {
      cout << ans[i][j];
      if ( j == w-1 ) {
        cout << endl;
      } else {
        cout << " ";
      }
    }
  }

  return 0;
}


Measured memory_bytes: 1280
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int a, b;
    cin >> a >> b;
    cout << a*b << "\n";
    
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        1000000007
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
ll a[10000001];
void sieve() {
	ll i,j;
	fli(i,2,10000001) {
		if(a[i]==0) {
			for(j=i*2;j<10000001;j+=i) {
				a[j]++;
			}
		}
	}
}
void comp() {
	ll i,j,k,n,m;
	cin>>n;
	sieve();
	vector<ll>primes;
	fli(i,2,1000001) {
		if(!a[i]) primes.pb(i);
	}
	map<ll,ll>m1;
	fl(i,primes.size()) {
		ll count1=0;
		while(n%primes[i]==0) {
			n/=primes[i];
			count1+=1;
		}
		if(count1>0) m1[primes[i]]=count1;
		if(n==1) break;
	}
	if(n>1) m1[n]=1;
	ll ans=0;
	map<ll,ll> :: iterator it = m1.begin();
	while(it!=m1.end()) {
		ll temp1=0;
		fli(i,1,40) {
			ll temp=(i*(i+1))/2;
			if(temp<=it->second) {
				temp1=i;
			}
			else {
				break;
			}
		}
		ans+=temp1;
		it++;
	}
	cout<<ans<<"\n";
	
}

int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

Measured memory_bytes: 82404
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> H >> W;
	vector<string>s(H + 2);
	for (int i = 1; i <= H; i++) {
		cin >> s[i];
		s[i] = '#' + s[i] + '#';
	}
	s[0] = string(W + 2, '#');
	s.back() = string(W + 2, '#');
	H += 2, W += 2;
	int sy, sx, gy, gx;
	int sd;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == 'G')gy = i, gx = j;
			if (s[i][j] != 'G'&&s[i][j] != '.'&&s[i][j] != '#')sy = i, sx = j;
			if (s[i][j] == '^')sd = 0;
			if (s[i][j] == '>')sd = 1;
			if (s[i][j] == 'v')sd = 2;
			if (s[i][j] == '<')sd = 3;
		}
	}
	vector<vector<pair<int, int>>>add(4, vector<pair<int, int>>(4));
	int dir[] = { 0,1,0,-1,0 };
	int ans = 1;
	vector<vector<int>>used(H, vector<int>(W));
	used[sy][sx] = 1;
	for (int loop = 0; loop < 20000; loop++) {
		if (sy == gy && sx == gx) {
			cout << ans << endl;
			return 0;
		}
		//cout << sy << " " << sx << " " << sd << endl;
		for (int i = 0; i < 12; i += 3) {
			int dy = dir[(i + sd) % 4];
			int dx = dir[(i + sd) % 4 + 1];
		//	cout << dy << " " << dx << endl;
			if (s[sy+dy][sx+dx] != '#') {
				sy += dy, sx += dx;
				ans += 1 - used[sy][sx];
				used[sy][sx] = 1;
				if (i == 0)sd++;
				if (i == 3)sd += 0;
				if (i == 6)sd += 3;
				if (i == 9)sd += 2;
				sd %= 4;
				break;
			}
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    int r[a],g[b],n[c];
    priority_queue<int>q;
    for(int i=0;i<a;i++)cin>>r[i];
    for(int i=0;i<b;i++)cin>>g[i];
    for(int i=0;i<c;i++){
        cin>>n[i];
        q.push(n[i]);
    }
    sort(r,r+a,greater<int>());
    sort(g,g+b,greater<int>());
    for(int i=0;i<x;i++)q.push(r[i]);
    for(int i=0;i<y;i++)q.push(g[i]);
    long long del=0;
    for(int i=0;i<x+y;i++){
        del+=q.top();
        q.pop();
    }
    cout<<del<<endl;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    int k=0,j=0;
    for(int i=1;i<=N;i++){
        int a;
        cin>>a;
        if(a==1){
            k++;
            j=max(j,k);
        }else{
            k=0;
            
        }
        
    }
    cout<<j+1<<endl;
    return 0;
    
}
     


Measured memory_bytes: 3112
#include <iostream>
#include <vector>

using namespace std;

int N, M;
vector< vector<bool> > ts;
vector< vector<int> > done;
void init() {
    cin >> N >> M;
    ts.resize(N);
    done.resize(N);
    for (int i = 0; i < N; i++) {
        ts[i].resize(i+1, false);
        done[i].resize(i+1, -1);
    }
}

void enclose(int a, int b, int x) {
    if (done[a][b] < x) {
        ts[a][b] = true; if (x == 0) return;
        enclose(a+1, b, x-1);
        enclose(a+1, b+1, x-1);
        done[a][b] = x;
    }
}

int main() {
    init();
    for (int i = 0; i < M; i++) {
        int A, B, X;
        cin >> A >> B >> X;
        A--, B--;
        enclose(A, B, X);
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) 
        for (int j = 0; j < ts[i].size(); j++) 
            if (ts[i][j]) cnt++;
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 52224
#include<stdio.h>
#include<stdlib.h>
int linearSearch(int n,int key,int *S);
int main(){
  int n,*S,q,*T,i,N,count=0;
  scanf("%d\n",&n);
  S=(int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d\n",&q);
  T=(int *)malloc(q*sizeof(int));
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    N=linearSearch(n,T[i],S);
    if(N!=77777){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}
int linearSearch(int n,int key,int *S){
  int i=0;
  S[n]=key;
  while(S[i]!=key){
    i++;
  }
  if(i>=n) return 77777;
  return i;
}



Measured memory_bytes: 2104
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

vector<pair<ll, ll>> prime_factorize(ll N) {
	vector<pair<ll,ll>> res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0; 
		while (N % a == 0) {
			++ex;
			N /= a;
		}
		res.push_back({ a, ex });
	}
	if (N != 1) res.push_back({ N, 1 });
	return res;
}

int main() {
	int n;
	cin >> n;
	ll ans = 1;
	ll over = (ll)1e18;
	bool zero = false;
	bool flag = false;
	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		if (a == 0) {
			zero = true;
			continue;
		}
		if (ans > over / a) {
			flag = true;
		}
		ans *= a;
	}
	if (zero) {
		cout << 0 << endl;
	}
	else if (flag) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>
using namespace std;

//快读
ll read() {
	char c = getchar();
	ll x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
const int N = 2e5 + 5;
ll a[N], b[N], sum[N];
ll  k, n, m;
int ans;
int main() {
	n = read(); m = read(); k = read();
	for_ll(i, 1, n) a[i] = read() + a[i - 1];
	for_ll(i, 1, m) b[i] = read() + b[i - 1];
	int  p = m;
	for_int(i, 0, n) {
		if (a[i] > k) break;
		for (int j = p; j >= 0; --j)
			if (b[j] <= k - a[i]) {
				ans = max(ans, i + j);
				p = j;
				break;
			}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6720
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]

ans = [0] * n
for i in range(q):
    ans[a[i] - 1] += 1

for i in range(n):
    if k - q + ans[i] <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 56024
c = [list(map(int, input().split())) for _ in range(3)]

# 斜め同士を足し合わせ比較をする
if c[0][0] + c[1][1] == c[0][1] + c[1][0]:
  if c[0][1] + c[1][2] == c[0][2] + c[1][1]:
    if c[1][0] + c[2][1] == c[1][1] + c[2][0]:
      if c[1][1] + c[2][2] == c[1][2] + c[2][1]:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 9188