akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

int main() {
  std::size_t constexpr prefix_size_max = 10;
  std::size_t prefix_size = prefix_size_max;
  std::size_t constexpr index_size_max = 800000; // chosen arbitrarily from the memory limit
  std::string text;
  std::getline(std::cin, text);
  std::map<std::vector<char>, std::vector<size_t>> index;
  for (std::size_t j = 1; j <= prefix_size_max; ++j) {
    if (index.size() >= index_size_max) {
      prefix_size = j - 1;
      break;
    }
    for (std::size_t i = 0; i < text.size(); ++i) {
      index[std::vector<char>(text.begin() + i, text.begin() + i + j)].push_back(i);
    }
  }
  int numpats;
  {
    std::string s;
    std::getline(std::cin, s);
    numpats = std::stoi(s);
  }
  std::map<std::string, bool> cache;
  for (int i = 0; i < numpats; ++i) {
    std::string pat;
    std::getline(std::cin, pat);
    bool const found = [&] {
      auto itcache = cache.find(pat);
      if (itcache != cache.end())
        return itcache->second;
      else {
        auto const& is = index[std::vector<char>(pat.begin(), pat.begin() + std::min(prefix_size, pat.size()))];
        auto result = std::any_of(is.begin(), is.end(), [&text, &pat](int i) {
          auto it = text.begin() + i;
          if (text.end() - it < pat.size())
            return false;
          else
            return std::equal(it, it + pat.size(), pat.begin(), pat.end());
        });
        cache.emplace(pat, result);
        return result;
      }
    }();
    if (found)
      std::cout << "1\n";
    else
      std::cout << "0\n";
  }
  return 0;
}



Measured memory_bytes: 165632
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;
int m;
int ans = 0;

int main(){
	cin >> n;
	int tx[110];
	int ty[110];
	int th[110];
	int ind=-1;
	forn(i) {
		cin >> tx[i] >> ty[i] >> th[i];
		if (th[i] > 0)ind = i;
	}
	if (ind == -1) {
		for (int x = 0; x <= 100; x++) {
			for (int y = 0; y <= 100; y++) {
				bool flg = true;
				forn(i) {
					if (x == tx[i] && y == ty[i]) {
						flg = false;
						break;
					}
				}
				if (flg) {
					cout << x << " " << y << " " << 1 << endl;
					goto ANS;
				}
			}
		}
	}
	for (int x = 0; x <= 100; x++) {
		for (int y = 0; y <= 100; y++) {
			bool flg = true;
			int h;
			h = th[ind] + max(x - tx[ind], tx[ind] - x) + max(y - ty[ind], ty[ind] - y);
			forn(i) {
				if (th[i] != max(0,h - max(x - tx[i], tx[i] - x) - max(y - ty[i], ty[i] - y)) ) {
					flg = false;
					break;
				}
			}
			if (flg) {
				cout << x << " " << y << " " << h<<endl;
				goto ANS;
			}
		}
	}
	ANS:
	return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
S = [input() for _ in range(H)]
answer = [[0 if cell == '.' else '#' for cell in row] for row in S]

dxy = [(-1,1),(-1,0),(-1,-1),(0,1),(0,-1),(1,1),(1,0),(1,-1)]
for i in range(H):
    for j in range(W):
        if S[i][j] != '#':
            continue
        for dx, dy in dxy:
            x = i + dx
            y = j + dy
            if x < 0 or x >= H:
                continue
            if y < 0 or y >= W:
                continue
            if S[x][y] == '#':
                continue
            answer[x][y] += 1
#print(answer)
for i in answer:
    print(*i,sep='')

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n, h;
	cin >> n >> h;
	priority_queue<pii> q;
	rep(i,n) {
		int a, b;
		cin >> a >> b;
		q.push(make_pair(a, 1));
		q.push(make_pair(b, 0));
	}
	ll cur = h;
	ll cnt = 0;
	while (true) {
		auto p = q.top();
		q.pop();
		if (p.second) {
			cout << (cur + (p.first - 1)) / p.first + cnt << endl;
			return;
		}
		cur -= p.first;
		cnt++;
		if (cur <= 0) {
			cout << cnt << endl;
			return;
		}
	}
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 5348
W, H, n = map(int, input().split())
w, h = 0, 0

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1 and w < x: w = x
    elif a == 2 and W > x: W = x
    elif a == 3 and h < y: h = y
    elif a == 4 and H > y: H = y

print(max(W - w, 0) * max(H - h, 0))


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

using namespace std;

#define int long long int
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> matrix;

const int inf = 1e18;
const int mod = 1e9 + 7;

inline int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x;}
inline int sub(int x, int y) { x -= y; if (x < 0) x += mod; return x;}
inline int mul(int x, int y) { return ((x % mod) * (y % mod)) % mod;}
inline int power(int a, int b) {
    int x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a) { return power(a, mod - 2);}

#undef int
int main() {
#define int long long int
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    clock_t start = clock();

    int n,k; cin>>n>>k;
    vi a(n+1);
    for(int i=1;i<=n;i++) cin>>a[i];

    vi dp(n+1,inf);
    dp[1]=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=i+k and j<=n;j++){
            dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]));
        }
    }

    cout << dp[n] << endl;

    clock_t end = clock();
    cerr << "Time: " << (double)(end - start) / CLOCKS_PER_SEC << " seconds" << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void)
{
	int N,i,M;
	scanf("%d",&N);
	
	
	int A[200],B[200];
	
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	
	for(i=0;i<N;i++){
		B[i]=0;
	}
	
	
	for(i=0;i<N;i++){
		while(A[i]%2==0){
			A[i]=A[i]/2;
			B[i]=B[i]+1;
		}
	}
	
	M=B[0];
	for(i=1;i<N;i++){
		if(B[i]<M){
			M=B[i];
		}
	}
	printf("%d\n",M);
	
	return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

vpi adj[100005];
vector<bool> visited(100005, false);
vi X(100005);

void dfs(int s, bool &ret) {
  if (visited[s]) return;
  visited[s] = true;

  for (auto pi: adj[s]) {
    int u = pi.first;
    int d = pi.second;
    if (visited[u]) {
      if (X[u] == X[s] + d) continue;
      else ret = false;
    } else {
      X[u] = X[s] + d;
      dfs(u, ret);
    }
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M; cin >> N >> M;

  int l, r, d;
  rep(i, 0, M) {
    cin >> l >> r >> d;
    l--; r--;
    adj[l].pb({r, d});
    adj[r].pb({l, -d});
  }

  bool ok = true;
  rep(i, 0, N) {
    if (visited[i]) continue;
    dfs(i, ok);
  }


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

  return 0;
};


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define MAX 100002
int N, a[MAX], dp[MAX][2];

int func(int cur, int st){
	if(cur > N)	return 0;
	int &ret = dp[cur][st];
	if(ret != -1)	return ret;
	ret = 1e9;
	if(cur == 1){
		ret = min(ret, func(cur + 1, 0));
		ret = min(ret, func(cur + 1, 1));
	}
	else if(!st){
		if(a[cur] >= a[cur - 1]){
			ret = min(ret, func(cur + 1, 0));
		}
		ret = min(ret, func(cur + 1, 0) + 1);
		ret = min(ret, func(cur + 1, 1) + 1);
	}
	else{
		if(a[cur] <= a[cur - 1]){
			ret = min(ret, func(cur + 1, 1));
		}
		ret = min(ret, func(cur + 1, 0) + 1);
		ret = min(ret, func(cur + 1, 1) + 1);
	}
	return ret;
}

int main(){
	memset(dp, -1, sizeof(dp));
	scanf("%d", &N);
	for(int i = 1; i <= N; i++)
		scanf("%d", a + i);
	if(N == 1){
		puts("1");
		return 0;
	}
	int ans = func(0, 0) + 1;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 6144
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace codeTester.contest190720
{
    class ProblemD
    {
        static int n = 0;
        static List<long> values = new List<long>();
        static List<long> tmps = new List<long>();
        static List<long> answers = new List<long>();

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            n = int.Parse(Console.ReadLine());
            values = ReadSpaceSeparatedValues();
        }

        public static List<long> ReadSpaceSeparatedValues()
        {
            List<long> values = new List<long>();
            string[] inputs = Console.ReadLine().Split(' ');
            foreach (string input in inputs)
            {
                values.Add(long.Parse(input));
            }

            return values;
        }

        static void Logic()
        {
            for (int i = 0; i < n; i++)
            {
                tmps.Add(0);
            }
            for (int i = n - 1; i >= 0; i--)
            {
                if (NeedAdd(i))
                {
                    tmps[i] = 1;
                    answers.Add(i + 1);
                }
            }
        }

        static bool NeedAdd(int index)
        {
            long target = values[index];
            int boxNum = index + 1;
            long tmpValue = 0;
            for (int i = index + boxNum; i < n; i += boxNum)
            {
                DebugPrint("i = " + i.ToString());
                if (tmps[i] == 1)
                {
                    tmpValue = (tmpValue + 1) % 2;
                }
            }

            return tmpValue != target;
        }

        static void Output()
        {
            Console.WriteLine(answers.Count);
            Console.WriteLine(string.Join(" ", answers));
        }

        static void DebugPrint(string msg)
        {
            // 提出時に消す
            // Console.WriteLine(msg);
        }
    }
}


Measured memory_bytes: 34396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            int[] much = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);

            Array.Sort(much);

            int ans = 0;

            for(int i = 0; i < k; i++)
            {
                ans += much[i];
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27652
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 2e5 + 10;

int A[MR];

int main()
{
	int N;
	scanf("%d", &N);
	REP(i, N)
	{
		scanf("%d", &A[i]);
		if ((!i && A[i]) || A[i] > A[i - 1] + 1)
		{
			printf("-1\n");
			return 0;
		}
	}

	LL res = 0;
	int cnt = -1;
	REP(i, N)
	{
		cnt++;
		if (cnt != A[i])
		{
			res += A[i - 1];
			cnt = A[i];
		}
	}

	printf("%lld\n", res + A[N - 1]);

	return 0;
}

Measured memory_bytes: 1024
# coding: utf-8
a = int(input())
b = int(input())
c = int(input())
x = int(input())
X = 0
for i in range(a+1):
  temp1 = x-500*i
  if temp1 < 0:
    break
  for j in range(b+1):
    temp2 = temp1-100*j
    if temp2 < 0:
      break
    for k in range(c+1):
      temp3 = temp2-50*k
      if temp3 < 0:
        break
      if temp3 ==0:
        X += 1
  
print(X)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll a, b;
    cin >> a >> b;
    if(a < 0 && b > 0) {
        cout << "Zero" << endl;
    } else if(a > 0) {
        cout << "Positive" << endl;
    } else {
        int c = abs(a) - abs(b) + 1;
        if(c % 2 == 0) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n,m = map(int, input().split())
t = sorted([tuple(map(int, input().split())) for i in range(m)], key=lambda x:(x[0], x[1]))
d=[0,0]+[1e18]*n
for l,r,c in t:
  for i in range(r,l,-1):
    if d[l]+c<d[i]:
      d[i]=d[l]+c
    else:
      break
print(d[-2]%10**18or-1)


Measured memory_bytes: 93404
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////
#define R(i,n) for(int i=0;i<(n);i=i+1)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	string S, T;
	cin >> S >> T;
	int N = S.size();
	vector<int> SS(26, -1);
	vector<int> TT(26, -1);
	R(i, N) {
		int s, t;
		s = S[i] - 'a';
		t = T[i] - 'a';
		if (TT[t] == -1) {
			TT[t] = s;
		}
		else if(TT[t]!=s){
			cout << "No" << endl;
			return;
		}
		if (SS[s] == -1) {
			SS[s] = t;
		}
		else if (SS[s] != t) {
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 916
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll k=in(),n=in();
    vector<ll>a(n);
    for(int i=0;i<n;++i)a[i]=in();
    ll ans=10000000;
    for(int i=0;i<n;++i){
        ll s=a[i],g=a[(i-1+n)%n];
        if(g<s)g+=k;
        ans=min(ans,g-s);
    }
    cout<<ans<<endl;
}


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

int main(){
    int N,a,b,minB=1000000001;
    long long sum=0;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a >> b;
        sum+=a;
        if(a>b && minB>b)
        minB=b;
    }
    if(minB==1000000001)
    cout << 0 << endl;
    else
    cout << sum-minB << endl;
    return 0;
}

Measured memory_bytes: 256
using System.Linq;
using System;

public class Team
{
    public int tid { get; set; }
    public int ac { get; set; }
    public int[] wa { get; set; }
    public int score { get; set; }
}

public class Hello
{
    public const int INF = 999999999;
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var M = int.Parse(line[0]);
            var T = int.Parse(line[1]);
            var P = int.Parse(line[2]);
            var R = int.Parse(line[3]);
            if (M == 0 && T == 0 && P == 0 && R == 0) break;
            var teams = new Team[T];
            for (int i = 0; i < T; i++)
                teams[i] = new Team { tid = i + 1, ac = 0, wa = new int[10], score = INF };
            for (int i = 0; i < R; i++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                var m = int.Parse(line[0]);
                var t = int.Parse(line[1]) - 1;
                var p = int.Parse(line[2]) - 1;
                var j = int.Parse(line[3]);
                if (j == 0)
                {
                    teams[t].ac++;
                    teams[t].score += m + teams[t].wa[p] * 20;
                }
                else teams[t].wa[p]++;
            }
            print(teams);
        }
    }
    public static void print(Team[] t)
    {
        var a = t.OrderByDescending(x => x.ac).ThenBy(x => x.score).ThenByDescending(x => x.tid).ToArray();
        var pre1 = a[0].ac;
        var pre2 = a[0].score;
        Console.Write(a[0].tid);
        for (int i = 1; i < t.Length; i++)
        {
            if (a[i].ac < pre1) Console.Write(",{0}", a[i].tid);
            else if (a[i].score > pre2) Console.Write(",{0}", a[i].tid);
            else Console.Write("={0}", a[i].tid);
            pre1 = a[i].ac; pre2 = a[i].score;
        }
        Console.WriteLine();
    }
}



Measured memory_bytes: 10452
#include <iostream>
#include <vector>
#include <unordered_set>
#include <cstring>

using namespace std;

const int INF = 1e9 + 5;

using ll = long long;
int main() {

    int n, W;
    cin >> n >> W;
    vector<int> w(n+1), v(n+1);

    for (int i = 1; i <= n; ++i) {
        int tw, tv;
        cin >> tw >> tv;
        w[i] = tw;
        v[i] = tv;
    }

    ll dp[W+1][n+1];

    for (int i = 0; i <= W; ++i) {
        for (int j = 0; j <= n; ++j) {
            dp[i][j] = 0;
        }
    }
    for(int i = 1; i <= W; i++) {
        for(int j = 1; j <= n; j++) {
            dp[i][j] = max( (i - w[j]) >= 0 ? dp[i - w[j]][j - 1] + v[j] : 0 , dp[i][j-1]);
        }
    }

    cout << dp[W][n] << endl;

    return 0;
}

Measured memory_bytes: 79104
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] Arguments) throws IOException 
    {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), X = sc.nextInt(), Y = sc.nextInt();
        
        // Cost of Buying A and B Pizzas separately:
        long costAB = A * X + B * Y;
        
        // Common Number of A and B Pizzas
        long Same = Math.min(X, Y);
        X = X - Same; 
        Y = Y - Same;
        long costCombine = Same * 2 * C + A * X + B * Y;
        long totalCost = Same * 2 * C + Math.max(X, Y) * 2 * C;
        
        // Is it better to buy A and B Pizzas Seperately, or should he use AB Pizzas?
        long Best = Math.min(costAB, costCombine);
        Best = Math.min(Best, totalCost);
        System.out.println(Best);
    }
}

Measured memory_bytes: 35800
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

int main() {
  int h,w;
  cin>>h>>w;
  vector<string> pic(h);
  rep(i,h) cin>>pic[i];
  bool ans=true;
  int dh[]={1,0,-1,0};
  int dw[]={0,1,0,-1};
  rep(i,h) rep(j,w){
    if(pic[i][j]=='#'){
      int black=0;
      rep(dir,4){
        int nh=i+dh[dir];
        int nw=j+dw[dir];
        if(nh<0 || h<=nh || nw<0 || w<=nw) continue;
        if(pic[nh][nw]=='#') black++;
      }
      if(black==0){
        ans=false;
        break;
      }
    }
    if(!ans) break;
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
N = 5
List = [int(input()) for _ in range(N)]
K = int(input())
# print(List)
flag = 0

for i in range(N-1):
    for j in range(i+1,N):
        k = List[j]-List[i]
        # print(k)
        if k>K:
            flag=1
            break

if flag==1:
  print(":(")
else:
  print("Yay!")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int time = sc.nextInt();
		int h = time / 3600;
		int m = (time - 3600 * h) / 60;
		int s = (time - 3600 * h - m * 60);
		System.out.println(h + ":" + m + ":" + s);

	}
}


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

int gcd(int x, int y){
    if(x < y){
        int temp = x;
        x = y;
        y = temp;
    }

    while(y > 0){
        int r = x % y;
        x = y;
        y = r;
    }

    return x;
}

int main(void){

    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
}

Measured memory_bytes: 3068
a, b, c = map(int, input().split())

count = 0
while True:
    if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        new_a = int(b/2) + int(c/2)
        new_b = int(a/2) + int(c/2)
        new_c = int(b/2) + int(a/2)
    else:
        break
    if a == new_a and b == new_b and c == new_c:
        count = -1
        break
    else:
        count += 1
        a = new_a
        b = new_b
        c = new_c
print(count)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
    long N;
    long a[5];
    long max = 0;
    cin >> N;
    for(int i = 0;i < 5;i++){
        cin >> a[i];
        max = std::max(max, (N - 1) / a[i]);
    }
    cout << max + 5<< endl;
}


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

char board[301][301];
int h,w,k;
int res[301][301];

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

	cin >> h >> w >> k;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin >> board[i][j];
		}
	}

	memset(res,0,sizeof(res));

	int select = 0;
	for(int i=1;i<=h;i++)
	{
		int sy = 1;
		for(int j=1;j<=w;j++)
		{
			if(board[i][j]=='#')
			{
				select++;
				for(int k=sy;k<=j;k++)
				{
					res[i][k] = select;
				}
				sy = j + 1;
			}
		}
		if(sy!=1)
		{
			for(int j=sy;j<=w;j++)
			{
				res[i][j] = select;
			}
		}
		else
		{
			if(i!=1)
			{
				for(int j=1;j<=w;j++)
				{
					res[i][j] = res[i-1][j];
				}
			}
		}
	}

	for(int j=1;j<=w;j++)
	{
		for(int i=1;i<=h;i++)
		{
			if(res[i][j]!=0)
			{
				for(int k=1;k<i;k++)
				{
					res[k][j] = res[i][j];
				}
				break;
			}
		}
	}

	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cout << res[i][j] << ' ';
		}
		cout << '\n';
	}

	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int a[3];
cin>>a[0] >>a[1] >>a[2];
sort(a,a+3);
cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;

}

Measured memory_bytes: 3144
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int k=sc.nextInt();

		int max=a;
		int ans=0;

		if(a<b && b>c) max=b;
		else if(a<c && b<c) max=c;

		int max_i=max;

		for(int i=0;i<k;i++){
			max=2*max;
		}

		ans=max+(a+b+c-max_i);

		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String str = in.readLine();

		String[] vowel = {"w", "", "k", "s", "t", "n", "h", "m", "y", "r" };

		for (int i = 0; i < str.length(); i += 2) {
			char m = str.charAt(i);
			char c = str.charAt(i + 1);
			if (m == '0' && c == 'U') {
				System.out.print("nn");
			} else {
				System.out.print(vowel[m - '0']);
				switch (c) {
				case 'T':
					System.out.print('a');
					break;
				case 'L':
					System.out.print('i');
					break;
				case 'U':
					System.out.print('u');
					break;
				case 'R':
					System.out.print('e');
					break;
				case 'D':
					System.out.print('o');
					break;
				}
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 17100
#ABC121B-CanYouSolveThis?.py

from sys import stdin

input = stdin.readline

N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

correctN = 0

for i in range(N):
    sum = 0
    for j in range(M):
        sum += A[i][j] * B[j]
    if sum + C > 0:
        correctN += 1

print(correctN)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-9
#define PI 2 * acos (0.0)
using namespace std;

struct st
{
    int i;
    int j;
};

vector<st>v[100005];
int N, M;
int bit[100005];

void update(int j, int k)
{
    for(int i = j; i <= M; i = i + (i & -i))
    {
        bit[i] = bit[i] + k;
    }
}

int query(int j)
{
    int sum = 0;
    for(int i = j; i >= 1; i = i - (i & -i))
    {
        sum = sum + bit[i];
    }
    return sum;
}


int main()
{
    

    int a, b, c, d, e, x, y, z;

    scanf("%d %d", &N, &M);

    st s;

    for(a = 0; a < N; a++)
    {
        scanf("%d %d", &s.i, &s.j);
        v[ s.j - s.i + 1 ].push_back(s);
    }

    e = 0;

    for(a = 1; a <= M; a++)
    {
        for(b = 0; b < v[a - 1].size(); b++)
        {
            update(v[a - 1][b].i, 1);
            update(v[a - 1][b].j + 1, -1);
        }
        
        e = e + v[a - 1].size();
        x = 0;
        for(b = a; b <= M; b = b + a)
        {
            x = x + query(b);
        }
        printf("%d\n", N - e + x);
    }
    
    return 0;
}


Measured memory_bytes: 7936
fun main(args: Array<String>) {
    val list = readInputLine().split(" ").map { it.toInt() }

    for (i in 0..2) {
        if (list.count { it == list[i] } == 2) {
            println("Yes")
            return
        }
    }

    println("No")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 36200
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

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

        Integer[] a = new Integer[n];
        Arrays.fill(a,0);
        for(int i=0; i<n; i++) {
            a[sc.nextInt()-1]++;
        }

        Arrays.sort(a, Collections.reverseOrder());

        int sum = 0;
        for(int i=0; i<a.length; i++) {
            if(i > k-1) {
                sum += a[i];
            }
        }

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


Measured memory_bytes: 87180
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];

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

		Arrays.sort(a);
		Arrays.sort(c);

		long ans = 0;
		// 2段目の値
		for (int i = 0; i < n; i++) {
			ans += binarySearch(b[i], a) * (n - binarySearch(b[i] + 1, c));
		}
		System.out.println(ans);
	}

	private static long binarySearch(int key, int[] a) {

		int left = 0;
		int right = a.length;
		int mid;

		while (left < right) {
			mid = (left + right) / 2;
			if (key == a[mid]) {
//				return mid;
				right = mid;
			} else if (key < a[mid]) {
				right = mid;
			} else {
				left = mid + 1;
			}
		}
		return right;
	}
}


Measured memory_bytes: 93684
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
#if DEBUG
            Solve(Console.In, Console.Out);
            Console.ReadLine();
#else
            Solve(Console.In, Console.Out);
#endif
        }

        public static void Solve(TextReader ci, TextWriter co)
        {
            int n;
            int t, a;
            int[] h;
            n = ReadInt(ci);
            ReadInts(ci, out t, out a);
            h = IntArrayFrom(ci.ReadLine());

            double min_d = double.MaxValue;
            int min_i = -1;
            for (int i = 0; i < h.Length; ++i) {
                double d = Math.Abs(a - (t - 0.006 * h[i]));
                if (d < min_d) {
                    min_d = d;
                    min_i = i;
                }
            }
            co.WriteLine(min_i + 1);
            co.Flush();
        }

        public static int ReadInt(TextReader ci) => int.Parse(ci.ReadLine());

        public static void ReadInts(TextReader ci, out int a, out int b)
        {
            var array = IntArrayFrom(ci.ReadLine());
            a = array[0];
            b = array[1];
        }

        public static void ReadInts(TextReader ci, out int a, out int b, out int c)
        {
            var array = IntArrayFrom(ci.ReadLine());
            a = array[0];
            b = array[1];
            c = array[2];
        }

        public static int[] IntArrayFrom(string s)
            => s.Split(' ').Select(p => int.Parse(p)).ToArray();
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main() {
    int N;
    cin >> N;

    map<int, int> m;
    for(int i = 0; i < N; i++) {
        int temp;
        cin >> temp;

        decltype(m)::iterator it = m.find(temp);
        if(it != m.end()) {
            m[temp]++;
        } else {
            m.insert(make_pair(temp, 1));
        }
    }

    int count = 0;
    for(auto it = m.begin(); it != m.end(); it++ ) {
        if (it->second % 2 != 0) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 4992
n = gets.chomp.to_i
a, b, c, ma, mb, mc = [], [], [], [], [], []
a[0], b[0], c[0] = gets.chomp.split.map(&:to_i)
ma[0], mb[0], mc[0] = a[0], b[0], c[0]
n.times do |i|
  next if i == 0
  a[i], b[i], c[i] = gets.chomp.split.map(&:to_i)
  ma[i] = a[i] + [mb[i-1], mc[i-1]].max
  mb[i] = b[i] + [mc[i-1], ma[i-1]].max
  mc[i] = c[i] + [ma[i-1], mb[i-1]].max
end
puts [ma[n-1], mb[n-1], mc[n-1]].max


Measured memory_bytes: 6660
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
using namespace std;

int main()
{
	int n;cin>>n;
	int k,c,d;
	vector <vector <int>> a(100000);
	int b[100010];
	for(int i=0;i<100000;b[i++]=-1);
	for(int i=0;i<n;i++)
	{
		cin>>k>>c;
		for(int j=0;j<c;j++)
		{
			cin>>d;
			b[d]=k;
			a[k].push_back(d);
		}
	}
	for(int i=0;i<n;i++)
	{
		int dep=1;
		if(b[i]!=-1)
		{
			for(k=b[i];b[k]!=-1;k=b[k],dep++);
		}
		else dep=0;
		cout<<"node "<<i<<": parent = "<<b[i]<<", depth = "<<dep<<", ";
		
		if(b[i]==-1)cout<<"root";
		else if(a[i].size()==0)cout<<"leaf";
		else cout<<"internal node";
		
		cout<<", [";
		if(a[i].size())
		{
			
			for(int j=0;j<a[i].size();j++)
			{
				if(j==0)cout<<a[i][0];
				else cout<<", "<<a[i][j];
			}
		}
		cout<<"]"<<endl;
	}
	return 0;
}

Measured memory_bytes: 6232
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;
  long vec[100000];
  long count;
  long sum;
  long min;
  
  sum=0;
  count=0;
  cin >> N;
  
  for(long i=0; i<N; i++){
    cin >> vec[i];
    sum+=abs(vec[i]);
    if(vec[i]<=0)
      count++;
  }
  if(count%2==0)
    cout << sum << endl;
  else{
    min=abs(vec[0]);
    for(long j=1; j<N; j++){
      if(abs(vec[j])<min)
         min=abs(vec[j]);
    }
         sum=sum-2*min;
         cout << sum <<endl;
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;

int main()
{


	ll n, w;
	cin >> n >> w;
	ll arr[w + 1] = {0};
	for (ll i = 1; i <= n; i++)
	{
		ll u, v;
		cin >> u >> v;
		for (ll j = w; j >= u; j--)
		{
			arr[j] = max(arr[j - u] + v, arr[j]);
		}
	}

	ll ans = -1;
	for (ll i = 0; i <= w; i++)
	{
		ans = max(ans, arr[i]);
	}
	cout << ans << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

double d(double x1, double x2, double y1, double y2) {
  return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}

int main() {
  int n;
  cin >> n;
  vd x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  double ans = 1e9;
  rep(i, n - 1) rep2(j, i + 1, n) {
    double ox = (x[i] + x[j]) / 2;
    double oy = (y[i] + y[j]) / 2;
    double r = 0;
    rep(l, n) r = max(r, sqrt(pow(ox - x[l], 2) + pow(oy - y[l], 2)));
    ans = min(ans, r);
  }
  rep(i, n - 2) rep2(j, i + 1, n - 1) rep2(k, j + 1, n) {
    double a = d(x[j], x[k], y[j], y[k]);
    double b = d(x[i], x[k], y[i], y[k]);
    double c = d(x[j], x[i], y[j], y[i]);
    if(-a + b + c < 1e-9 || a - b + c < 1e-9 || a + b - c < 1e-9) continue;
    double aa = a * a * (b * b + c * c - a * a);
    double bb = b * b * (c * c + a * a - b * b);
    double cc = c * c * (a * a + b * b - c * c);
    double ox = (aa * x[i] + bb * x[j] + cc * x[k]) / (aa + bb + cc);
    double oy = (aa * y[i] + bb * y[j] + cc * y[k]) / (aa + bb + cc);
    double r = 0;
    rep(l, n) r = max(r, sqrt(pow(ox - x[l], 2) + pow(oy - y[l], 2)));
    ans = min(ans, r);
  }
  printf("%.18f\n", ans);
}

Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (A, B, Q) = readLine()!!.split(" ").map { it.toInt() }
    val s = LongArray(A)
    val t = LongArray(B)
    (0 until A).forEach {
        s[it] = readLine()!!.toLong()
    }
    (0 until B).forEach {
        t[it] = readLine()!!.toLong()
    }
    // O(AlogA)
    s.sort()
    // O(BlogB)
    t.sort()

    // O(QlogQ)
    (0 until Q).forEach {
        val x = readLine()!!.toLong()
        val s1 = s.getOrElse(upperBound(s, x), { -50000000001L }) // x未満の最大のs
        val s2 = s.getOrElse(lowerBound(s, x), { 50000000001L }) // ｘ以上の最小のs
        val t1 = t.getOrElse(upperBound(t, x), { -50000000001L }) // x未満の最大のt
        val t2 = t.getOrElse(lowerBound(t, x), { 50000000001L })  // x以上の最小のt
        val answer = listOf(Math.max(x - t1,  x - s1), Math.max(t2 - x, s2 - x), t2 - s1 + Math.min(Math.abs(t2 -x), Math.abs(s1 -x)), s2 - t1 + Math.min(Math.abs(s2-x), Math.abs(t1-x)))
                .min()!!
        println(answer)
    }
}

fun lowerBound(array: LongArray, value: Long): Int {
    var low = 0
    var high = array.size
    while (low < high) {
        val mid = (low + high) / 2
        if (value <= array[mid]) {
            high = mid
        } else {
            low = mid + 1
        }
    }
    return low
}

fun upperBound(sortedList: LongArray, key: Long) : Int {
    var ng = sortedList.size // left
    var ok = 0  // left

    fun isOk(mid: Int) : Boolean {
        return sortedList.get(mid) < key
    }

    while (Math.abs(ok - ng) > 1) {
        var mid = (ok + ng) / 2
        if (isOk(mid)) {
            ok = mid
        } else {
            ng = mid
        }
    }

    if (ok == 0 && sortedList[0] > key) {
        return -1
    }
    return ok
}

Measured memory_bytes: 59036
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>

using namespace std;
int main() {

	int A, B, C, D;
	int ans = 0;
	
	cin >> A >> B >> C >> D;

	for (int i = 0; i < 100; i++) {
		if (A <= i && i < B) {
			if (C <= i && i < D) {
				ans++;
			}
		}
	}

	cout << ans << endl;


	return(0);
}

Measured memory_bytes: 256
void main(){
	int n, a;
	n = _scan();
	a = _scan();
	writeln(n%500 <= a?"Yes":"No");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2676
#define _[301][301]
N,M,i,j,t,r,C _,D _;char S _;main(v){for(scanf("%d%d ",&N,&M);gets(S+i++););for(;i=j=++t<M;r+=v)for(;j>N?j=i++<N:1;++j)v=D[i][j]=fmin(D[i-1][j],D[i][j-1])+(C[i][j]=C[i-1][j-1]+(S[i-1][t-1]==S[j-1][t]));printf("%d\n",r);}

Measured memory_bytes: 1024
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector <int> c(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  vector <vector <pair <int, pair <int, int> > > > qrs(n);
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    qrs[r].push_back({l, {i, 1}});
    if (l)
      qrs[l - 1].push_back({l, {i, -1}});
  }
  vector <int> f(n);
  auto inc = [&] (int x) {
    for (; x < n; x = (x | (x + 1))) {
      f[x]++;
    }
  };
  auto get = [&] (int x) {
    int ans = 0;
    for (; x >= 0; x = (x & (x + 1)) - 1) {
      ans += f[x];
    }
    return ans;
  };
  vector <int> ret(q);
  map <int, int> last;
  vector <int> prev(n, -1);
  for (int i = 0; i < n; i++) {
    if (last.count(c[i])) {
      prev[i] = last[c[i]];
    }
    last[c[i]] = i;
    inc(prev[i] + 1);
    for (auto c : qrs[i]) {
      ret[c.second.first] += get(c.first) * c.second.second;
    }
  }
  for (int i = 0; i < q; i++) cout << ret[i] << '\n';
}


Measured memory_bytes: 67196
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+9;
const double ep=1e-7;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const double pi=acos(-1);
#define debug1 puts("?");
#define debug(x) cout<<"##"<<(x)<<endl;
#define mk make_pair
#define PII pair<int,int>
#define PIII pair<PII,int>
#define PIL pair<int,ll>
#define PLL pair<ll,ll>
#define eb emplace_back
#define fi first
#define se second
#define rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define sd(x) scanf("%d",&(x))
#define slld(x) scanf("%lld",&(x))
#define sdd(x,y) scanf("%d%d",&(x),&(y))
#define sc(s) scanf("%s",(s))
#define pd(x) printf("%d\n",(x))
#define plld(x) printf("%lld\n",(x))
#define pdk(x) printf("%d ",(x))
typedef long long ll;
ll n,a[maxn],sum[maxn],res;
void solve()
{
	slld(n);
	rep(i,1,n)slld(a[i]);
	for(int i=n;i>=1;i--)sum[i]=(sum[i+1]+a[i])%mod;
	rep(i,1,n-1)res=(res+a[i]*sum[i+1]%mod)%mod;
	plld(res);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T=1;
//	sd(T);
	while(T--)solve();
} 

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


int a[200001];

int main()
{
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> a[i];

	if ((N%2)==1) {
		for (int i = N; i > 0; i-=2) {
			cout << a[i] << " ";
		}
		for (int i = 2; i <= N; i+=2) {
			cout << a[i] << " ";
		}
	} else {
		for (int i = N; i > 0; i-=2) {
			cout << a[i] << " ";
		}
		for (int i = 1; i <= N; i+=2) {
			cout << a[i] << " ";
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

int main()
{
	int sx, sy, tx, ty;
	while (~scanf("%d%d%d%d", &sx, &sy, &tx, &ty))
	{
		int i;
		for (i = 0; i < ty - sy; i++) printf("U");
		for (i = 0; i < tx - sx; i++) printf("R");
		for (i = 0; i < ty - sy; i++) printf("D");
		for (i = 0; i < tx - sx; i++) printf("L");
		printf("L");
		for (i = 0; i < ty - sy + 1; i++) printf("U");
		for (i = 0; i < tx - sx + 1; i++) printf("R");
		printf("DR");
		for (i = 0; i < ty - sy + 1; i++) printf("D");
		for (i = 0; i < tx - sx + 1; i++) printf("L");
		printf("U\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
 long long int a,b,ans;
 cin>>a>>b;
 ans=0;
 vector<long long int> v;
 for(long long int i=0; i<a;i++){
   long long int tmp;
   cin>>tmp;
   v.push_back(tmp);
 }
 if(b>=a){
   cout<<0<<endl;
 }else{
   sort(v.begin(),v.end(),greater<int>());
   for(long long int i=0;i<b;i++){
   	  v[i]=0;
   }
   for(long long int i=0;i<a;i++){
   	ans+=v[i];
   }
   cout<<ans<<endl;
  }
 return 0;


}

Measured memory_bytes: 2420
#include <stdio.h>
#define MAX 20001
   
 
struct pair {
  int x;
  int ar;
};
   
 
void push_stack1(int);
void push_stack2(int, int);
int returnTopElement(void);
int pop_stack1(void);
struct pair pop_stack2(void);
   
 
int top_stack1 = 0, top_stack2 = 0;
   
 
int stack1[MAX];
struct pair stack2[MAX];
   
int main() {
  int i, j;
  int sum = 0, a;
  struct pair c;
  char input[MAX];
   
 
  scanf("%s", input);
   
 
  for (i = 0; input[i] != '\0'; i++) {
    if(input[i] == '\\') push_stack1(i);
    else if((input[i] == '/') && (top_stack1 > 0)) {
      j = pop_stack1();
      sum += i - j;
      a = i - j;
      while ((top_stack2 > 0) && stack2[top_stack2 - 1].x > j) {
        a += stack2[top_stack2 - 1].ar ;
        c = pop_stack2();
      }
      push_stack2(j, a);
    }
  }
   
 
  printf("%d\n", sum);
  printf("%d", top_stack2);
  for(i = 0; i < top_stack2; i++) {
    if(i < top_stack2) printf(" ");
    printf("%d", stack2[i].ar);
  }
  printf("\n");
   
   
  return 0;
}
   
void push_stack1(int x) {
  stack1[top_stack1] = x;
  top_stack1++;
}
   
void push_stack2(int j, int a) {
  stack2[top_stack2].x = j;
  stack2[top_stack2].ar = a;
  top_stack2++;
}
   
int pop_stack1(void) {
  int r = 0;
   
  top_stack1--;
     
  if(top_stack1 < 0) {
    top_stack1 = 0;
    return 0;
  }
  r = stack1[top_stack1];
  return r;
   
}
   
struct pair pop_stack2(void) {
  struct pair s;
   
  top_stack2--;
     
  if(top_stack2 < 0) {
    top_stack2 = 0;
    return;
  }
  s = stack2[top_stack2];
  return s;
   
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

int main(){
        string s;
        ll n;
        cin >>  n >> s;
        REP(i,0,SIZE(s)){
                ll tmp = s[i] - 'A';
                tmp = (tmp + n) % 26;
                s[i] = 'A' + tmp;
        }
        cout << s << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int N,counter=0,check=0;
    
    scanf("%d",&N);
    int H[N],i,j=0;
    for(i=0;i<N;i++) scanf("%d",&H[i]);
    
    i=0;
    while(i<N){
        while(j<i){
            if(H[j]<=H[i]) check++;
            j++;
        }
        if(check==i) counter++;
        check=0;
        i++;
        j=0;
    }
    printf("%d",counter);
    
    return 0;
}

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

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

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int n, m;

struct Seg{
  vector<ll>val;
  vector<ll>mx;

  Seg(){
    val.resize(1<<19, 0);
    mx.resize(1<<19, 0);
  }

  void add_val(ll l, ll r, ll score, ll pos=1, ll bottom=0, ll top=1<<18){
    if(bottom>=r || top<=l)return;
    if(l<=bottom && top<=r){
      val[pos] += score;
      return;
    }

    ll mid = (top+bottom)/2;
    add_val(l, r, score, pos*2, bottom, mid);
    add_val(l, r, score, pos*2+1, mid, top);
    mx[pos] = max<ll>(mx[pos*2] + val[pos*2], mx[pos*2+1]+val[pos*2+1]);
  }

  ll max_val(ll l, ll r, ll pos=1, ll bottom=0, ll top = 1<<18){
    if(l >= top || r<=bottom)return -INF;
    if(l <= bottom && top <= r)return mx[pos]+val[pos];

    ll mid = (bottom+top)/2;
    return max<ll>(
      max_val(l, r, pos*2, bottom, mid),
      max_val(l, r, pos*2+1, mid, top)
    ) + val[pos];
  }
};

int main(){
  cin>>n>>m;
  vector<vector<pll>>is(n+1);
  rep(i, m){
    int l,r,a;cin>>l>>r>>a;
    is[r].push_back({l, a});
  }

  Seg seg;

  rep1(r, n){
    ll mx = seg.max_val(0, r);
    seg.add_val(r, r+1, mx);
    for(auto p:is[r]){
      ll l = p.first;
      ll a = p.second;
      seg.add_val(l, r+1, a);
    }
  }

  cout<<seg.max_val(0, n+1)<<endl;

//  rep(i, n)cout<<seg.max_val(0, i+1)<<' ';cout<<endl;

  return 0;
}

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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  
  int largest = ( B/K ) * K;
  
  if(A <= largest){
	cout << "OK" << endl;
  }else{
	cout << "NG" << endl;
  }
}

Measured memory_bytes: 3600