akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);
template <typename T>
void MACRO_VAR_Scan(T &t)
{
    std::cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &... rest)
{
    std::cin >> first;
    MACRO_VAR_Scan(rest...);
}

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define yes() printf("yes\n")
#define no() printf("no\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

ll ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
long long a, b, c, d, n;
int x, y;
int sum;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    INIT;
    cin >> n;
    vi q(n);
    rep(i, n) cin >> q[i];

    sort(ALL(q));
    ERASE(q);
    pr(q.size());
    return 0;
}


Measured memory_bytes: 3532
#include <stdio.h>
#include <limits.h>

int n,m[100][100];

void matrixChainOrder(int *p){
  int i,j,k,l,q;
  for(i=1;i<=n;i++)m[i][i] = 0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]= INT_MAX;
      for(k=i;k<j;k++){
	q = m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(m[i][j]>q)m[i][j]=q;
      }
    }
  }
}

int main(){
  int d,i,p[101];
  scanf("%d",&n);
  scanf("%d",&p[0]);
  for(i=1;i<=n;i++){
    scanf("%d",&p[i]);
    if(i<n)scanf("%d",&d);
  }
  matrixChainOrder(p);
  printf("%d\n",m[1][n]);
  return 0;
}



Measured memory_bytes: 2104
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int main()
{
	ll n;
	cin >> n;
	vector<ll> al(n);
	vector<ll> sum(n + 1);
	rep(i, n) {
		ll a;
		cin >> a;
		al[i] = a;
		sum[i + 1] = sum[i] + a;
	}
	map<ll, ll> mp;
	for (auto item : sum) {
		mp[item]++;
	}
	ll ans = 0;
	for(auto item : mp) {
		ans += (item.second * (item.second - 1)) / 2;
	}
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}


Measured memory_bytes: 19020
#include<stdio.h>
int main()
{
    int n,s=0,l,r;
    scanf("%d",&n);
    char a[n];
    scanf("%s",&a);
    l=0;
    r=n-1;
    while(l<r)
    {
        while(1)
        {
            if(a[l]=='W')
                break;
            l++;
            if(l==n) break;
        }
        while(1)
        {
           if(a[r]=='R')
                break;
            r--;
            if(r==-1) break;
        }
        if((l==n)||(r==-1)||(l>=r))
            break;
        else
        {
            s++;
            l++;
            r--;
        }
    }
    printf("%d",s);
    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll a, b;
    cin >> n >> a >> b;
    ll ans = 0, cur = 0;
    cin >> cur;
    rep(i,n-1){
        ll x;
        cin >> x;
        ans += min(a*(x - cur), b);
        cur = x;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
numbers = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = gets.to_i
puts numbers[k-1]

Measured memory_bytes: 1788
// Problem : D - Sum of Large Numbers
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/**         srijan_de
 _____      _ _              ______     
/  ___|    (_|_)             |  _  \    
\ `--. _ __ _ _  __ _ _ __   | | | |___ 
 `--. \ '__| | |/ _` | '_ \  | | | / _ \
/\__/ / |  | | | (_| | | | | | |/ /  __/
\____/|_|  |_| |\__,_|_| |_| |___/ \___|
            _/ |                         
           |__/           23.02.2001     **/
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
#include    <bits/stdc++.h>  
using       namespace       std;
using       lli=            long long  int;
using       ulli=           unsigned long long int;
using       ld=             long double;
#define     mem(a,val)      memset( a,  val,  sizeof(a) )
#define     b_s             binary_search
#define     u_b             upper_bound
#define     l_b             lower_bound
#define     nl              cout<<endl
#define     pb              push_back
#define     pf              push_front
#define     ppb             pop_back
#define     ppf             pop_front
#define     in              insert
#define     fi              first
#define     se              second
#define 	pqueue			priority_queue
const lli   MOD=            (int)1e9 + 7;
const lli   MOD1=           (int)1e9 + 9;
const lli   MOD2=           998244353;
const ld    pi=             atan2(0, -1);
const ld    eps=            1e-9;
lli         tests=          1;
template<class x,class y>x max(x a,y b){return (a>b)?a:b;}
template<class x,class y>x min(x a,y b){return (a<b)?a:b;}
template<class x,class y>x log(x n,y r){return (n>r-1)?1+log(n/r,r):0;}

///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
int32_t main() 
{
	auto start = clock();
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);	

//	cout<<fixed;
//	cout<<scientific;
//	cout<<fixed<<setprecision(12);
	// cin>>tests;
	for(lli test=1;test<=tests;test++) 
	{
//		cout<<"Case #"<<test<<": ";
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
		
		
		lli n,m;
		cin>>n>>m;
		lli a[n+1]={0},b[n+1]={0};
		for(lli i=1;i<=n;i++)
		{
		    a[i]=a[i-1]+i;
		}
		lli ans=0;
		for(lli i=m;i<=n+1;i++)
		{
		    lli x,y;
		    if(n-i>=0)
		    x=a[n-i];
		    else
		    x=0;
		    
		    ans+=a[n]-x-a[i-1]+1;
		    ans%=MOD;
		}
		
		cout<<ans%MOD;
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
	}
	cerr<<endl<<endl<<endl<< "Time : " << double(clock() - start) / CLOCKS_PER_SEC <<endl;
	return 0;
}
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.


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

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

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

int main(int argc, char** argv) {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    vector<int> dp(n);

    rep(i, n) {
        cin >> h[i];
        dp[i] = INT_MAX;
    }

    dp[0] = 0;
    rep(i, n) {
        for (int j = 1; j <= k; j++) {
            if (i + j < n)
                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }

    cout << dp[n - 1] << endl;
    return 0;
};


Measured memory_bytes: 1024
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pi pair<int,int>
#define pl pair<long,long>
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define mod ((ll)(1e9+7))
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define vl vector<ll>
#define ml unordered_map<ll,ll> 
#define vpll vector<pair<ll,ll>>
#define INF 0x3f3f3f3f
#define mp make_pair

int main()
{
   ll a,b;
   in2(a,b);
   if(a<10 and b<10) cout<<a*b<<endl;
   else cout<<-1<<endl;    return 0;
} 

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

const int N = 5;

int main() {
  int i;
  int time[N], mod[N];

  for (i = 0; i < N; i++) {
    cin >> time[i];
    mod[i] = time[i] % 10;
  }

  int last = 0;
  for (i = 0; i < N; i++) {
    if (0 < mod[i] && mod[i] < mod[last]) {
      last = i;
    }
  }

  int sum = 0;
  for (i = 0; i < N; i++) {
    if (i == last) continue;    
    if (mod[i] == 0) sum += time[i];
    else sum += time[i] + 10 - mod[i];
  }
  sum += time[last];

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#define N 200000
using namespace std;
typedef long long ll;
int h,w,n;
int c[N];
int col[200][200];
int main(){
	//freopen ("2.in","r",stdin);
	//freopen ("2.out","w",stdout);
	scanf ("%d%d%d",&h,&w,&n);
	int la=1,x;
	for (int i=1;i<=n;++i){
		scanf ("%d",&x);
		while (x--) c[la++]=i;
	}
	int cnt=1,i=0,j=1;
	while(cnt<=h*w){  
        while(i<h&&!col[i+1][j]) col[++i][j]=c[cnt++];
        while(j>1&&!col[i][j-1]) col[i][--j]=c[cnt++];
        while(i>1&&!col[i-1][j]) col[--i][j]=c[cnt++];
        while(j<w&&!col[i][j+1]) col[i][++j]=c[cnt++];
    }  
	for (int i=1;i<=h;++i){
		for (int j=1;j<=w;++j) cout<<col[i][j]<<" ";
		cout<<endl;
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

// Common memset settings
//memset(memo, -1, sizeof memo); // dp memoization with -1
//memset(arr, 0, sizeof arr); //clear array of integers




int main(){
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int x,y;

	cin >> x >> y;

	long long ans = 0;

	if(x == 3){
		ans += 100000;
	}else if(x == 2){
		ans += 200000;
	}else if(x == 1){
		ans += 300000;
	}
	

	if(y == 3){
		ans += 100000;
	}else if(y == 2){
		ans += 200000;
	}else if(y == 1){
		ans += 300000;
	}

	if(x == 1 && y == 1){
		ans += 400000;
	}

	cout << ans;

	return 0;
}




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

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

sort(a.begin(), a.end(), greater<int>());

if (N % 2 != 0) {
    a.push_back(0);
}

int sum_Alice = 0;
int sum_Bob = 0;
for (int i = 0; i < a.size() / 2; i++) {
    sum_Alice += a[2*i];
    sum_Bob += a[2*i+1];
}

cout << sum_Alice - sum_Bob << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<string,int>mp;
  mp["AC"] = 0;
  mp["WA"] = 0;
  mp["TLE"] =0;
  mp["RE"] = 0;
  for(int i=0;i<n;i++){
      string s;
      cin >> s;
      mp[s]++;
  }
  cout << "AC x "<<mp["AC"]<<endl;
  cout << "WA x "<<mp["WA"]<<endl;
  cout << "TLE x "<<mp["TLE"]<<endl;
  cout << "RE x "<<mp["RE"]<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL n, k, s;
    cin >> n >> k >> s;
    LL x = 1000000000;
    if(s == 1000000000){
        x = 1;
    }
    vector<LL> a(n, x);
    for(LL i = 0; i < k; ++i){
        a[i] = s;
    }
    for(LL i = 0; i < n; ++i){
        if(i+1 < n){
            cout << a[i] << " ";
        }else{
            cout << a[i] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 2176
import sys
import copy
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
li = [ni() for _ in range(n)]
li.sort()
d = []
for s in li:
    if s % 10 != 0:
        d.append(s)
ans = sum(li)
if ans % 10 != 0:
    print(ans)
else:
    if not d:
        print(0)
    else:
        print(ans - d[0])

Measured memory_bytes: 3444
line = input().split(" ")
a = int(line[0])
b = int(line[1])

if a > 0:
  print("Positive")
elif a <= 0 and b >= 0:
  print("Zero")
else:
  c = b - a + 1
  if c % 2 == 0:
    print("Positive")
  else:
    print("Negative")

Measured memory_bytes: 3060
var
  i,i1,j,j1:integer;
  a:array [0..102,0..102] of char;
  b:array [0..102,0..102] of longint;
begin
  readln(i1,j1);
  j:=j1;
  i:=i1;
  while (i>0) do
    begin
      while (j>0) do
        begin
          read(a[i,j]);
          dec(j);
        end;
      readln;
      dec(i);
      j:=j1;
    end;
  for i:= 1 to i1 do
    for j:= 1 to j1 do
      if a[i,j]='#' then begin
                           if b[i-1,j-1]<>-1 then inc(b[i-1,j-1]);
                           if b[i+1,j-1]<>-1 then inc(b[i+1,j-1]);
                           if b[i-1,j+1]<>-1 then inc(b[i-1,j+1]);
                           if b[i+1,j+1]<>-1 then inc(b[i+1,j+1]);
                           if b[i-1,j]<>-1 then inc(b[i-1,j]);
                           if b[i+1,j]<>-1 then inc(b[i+1,j]);
                           if b[i,j-1]<>-1 then inc(b[i,j-1]);
                           if b[i,j+1]<>-1 then inc(b[i,j+1]);
                           b[i,j]:=-1;
                         end;
  for i:= i1 downto 1 do
    begin
      for j:= j1 downto 1 do
        if b[i,j]=-1 then  write('#')
                      else write(b[i,j]);
      writeln;
    end;
end.
  

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <map>
using namespace std;

typedef long long ll;
int main() {
  int n, k;
  cin >> n >> k;
  ll r, s, p;
  cin >> r >> s >> p;
  map<char, int> scores;
  scores['r'] = p;
  scores['s'] = r;
  scores['p'] = s;
  string t;
  cin >> t;
  vector<char> hands(n);
  ll ans = 0;
  for (int i = 0; i < n; ++i) { 
    char h = t[i];
    if (i >= k) {
      if (hands[i-k] == h) {
        hands[i] = '.';
        continue;
      }
    }
    ans += scores[h];
    hands[i] = h;
  }
  cout << ans << endl;
}



Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;
int main()
{
    setprecision(20);
    int n;
    cin>>n;
    vector<long double> coins(n+1,0);
    for(int i=1;i<=n;i++)
    {
        cin>>coins[i];
    }
    vector<vector<long double> > dp(n+1,vector<long double>(n+1,0));
    dp[0][0]=1.0;
    // dp[1][0]=1-coins[1];
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=dp[i-1][0]*(1-coins[i]);
        for(int j=1;j<=n;j++)
        {
            dp[i][j]=coins[i]*dp[i-1][j-1]+(1-coins[i])*dp[i-1][j];
        }
    }
    long double ans=0;
    for(int i=0;i<=n;i++)
    {
        if(i>n-i)
        {
            ans+=dp[n][i];
        }
    }
    cout<<setprecision(20)<<ans;
}

Measured memory_bytes: 143928
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    int H,W;
    string S[51];
    int dx[]={1,-1,0,0,1,1,-1,-1};
    int dy[]={0,0,1,-1,1,-1,1,-1};
    int A[51][51]={};
int main(){
    ios_base::sync_with_stdio(false);
    cin>>H>>W;
    REP(i,H)cin>>S[i];
    REP(i,H){REP(j,W){
        DEB(i)DEB(j)
        int cnt=0;
        if(S[i][j]=='#'){
            cout<<'#';
        }else{
            REP(k,8){
                int a=i+dy[k],b=j+dx[k];
                if(a<0||b<0||a>H-1||b>W-1)continue;
                if(S[a][b]=='#')cnt++;
            }
            DEB(cnt)
            cout<<cnt;


        }

    }cout<<endl;}

    return 0;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    int s[m], c[m];
    vector<int> ans(3);
    if (n > 1)
        ans[3 - n] = 1;
    rep(i, m)
    {
        cin >> s[i] >> c[i];
    }
    for (int i = 0; i < m - 1; i++)
    {
        for (int j = i + 1; j < m; j++)
        {
            if (s[i] == s[j] && c[i] != c[j])
            {
                cout << "-1" << endl;
                return 0;
            }
        }
    }
    rep(i, m)
    {
        if (s[i] > n)
        {
            cout << "-1" << endl;
            return 0;
        }
    }
    rep(i, m)
        ans[3 - n + s[i] - 1] = c[i];

    while (ans.size() > 1 && ans[0] == 0)
        ans.erase(ans.begin());
    if (n != ans.size())
        cout << "-1";
    else
        rep(i, n) cout << ans[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int dp[10100];

int main(){
    int N,M; cin >> N >> M;
    vector<Pi> A(M);
    rep(i,M){
        cin >> A[i].first;
    }
    rep(i,M){
        if(A[i].first == 1) A[i].second = 2;
        else if(A[i].first == 4) A[i].second = 4;
        else if(A[i].first == 6 || A[i].first == 9) A[i].second = 6;
        else if(A[i].first == 7) A[i].second = 3;
        else if(A[i].first == 8) A[i].second = 7;
        else A[i].second = 5;
    }
    rep(i,10100) dp[i] = -1;
    dp[0] = 0;
    rep(i,N+1)rep(j,M){
        if(i-A[j].second >= 0) dp[i] = max(dp[i],dp[i-A[j].second]+1);
    }
    sort(A.begin(),A.end(),greater<Pi>());
    string ans = "";
    int k = dp[N];
    while(N > 0){
        rep(i,M){
            if(N-A[i].second >= 0){
                if(dp[N-A[i].second] == k-1){
                    ans += A[i].first+'0';
                    k--;
                    N -= A[i].second;
                    break;
                }
            }
        }
    }
    cout << ans << endl;

}

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

int main() {
  int h, w, n;
  cin>>h>>w>>n;
  set<int> xs[w];
  for (int i=0; i<n; i++) {
    int x, y;
    cin>>x>>y;
    --y;
    --x;
    xs[y].insert(x);
  }
  for (int i=0; i<w; i++) {
    xs[i].insert(h);
  }
  if (h == 1 || (w > 1 && xs[1].find(0) != xs[1].end())) {
    cout<<1<<endl;
    return 0;
  }
  int ans = 1e6;
  int cur_w = 0;
  for (int i=1; i<h; i++) {
    if (xs[cur_w].find(i) != xs[cur_w].end()) {
      ans = min(i, ans);
      break;
    }
    auto it = xs[cur_w].upper_bound(i);
    ans = min(*it, ans);
    if (cur_w < w - 1) {
      if (xs[cur_w+1].find(i) == xs[cur_w+1].end()) {
        ++cur_w;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 31752
import math
def solve():
  s = input()
  n = len(s) + 1
  que = [0]*n
  que2 = [0]*n
  now = 0
  for i in range(n-1):
    if s[i] == "<":
      que[i+1] = now + 1
      now += 1
    else:
      now = 0
      que[i+1] = now

  s2 = s[::-1]
  now = 0
  for i in range(n-1):
    if s2[i] == ">":
      que2[i+1] = now+1
      now += 1
    else:
      now = 0
      que2[i+1] = now
  que2 = que2[::-1]
  ans = 0
  for i in range(n):
    ans += max(que[i],que2[i])
  print(ans)

solve()

Measured memory_bytes: 31528
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;

int main() {
    ll N,K;
    cin >> N >> K;
    ll tmp = N%K;

    cout << min(tmp,K-tmp) << endl;
}

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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< pair<int, int> , null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ull>(a, b)(rng)
#define losuj_real(a, b) uniform_real_distribution<long double>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>            pll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vector<ii>>      vvii;
typedef vector< ll >            vll;
typedef vector< pll >           vpll;
 
#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second
 
template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}
 
template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }
  
const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll N = 1e6+7;
const ll T = 1<<20;
const ll BIG_INF = 1e18 + 7;

ll n, m, k, q;

int dp[3007][3007];

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

    string s, t;
    cin >> s >> t;
    for(int i = 1; i <= sz(s); i++){
    	for(int j = 1; j <= sz(t); j++){
    		if(s[i-1] == t[j-1])
	    		dp[i][j] = dp[i-1][j-1] + 1;
	    	else
	    		dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    	}
    }

    string ans;

    int I = sz(s);
    int J = sz(t);

    while(I && J){
    	if(s[I-1] == t[J-1]){
    		I--;
    		J--;
    		ans.pb(s[I]);
    	}
    	else if(dp[I][J] == dp[I-1][J]){
    		I--;
    	}
    	else{
    		J--;
    	}
    }
    reverse(all(ans));
    cout << ans << '\n';
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define rep(i,m) for(int i=0;i<m;i++)
#define pb(n) push_back(n)

#define int long long

signed main() {
    int n;cin >>n;
    vector<vector<pair<int,int>>> a(n);
    rep(i,n){
        int t;cin >>t;
        rep(j,t){
            int p,q;cin >>p>>q;p--;
            a[i].push_back({p,q});
        }
    }

int ma=0;

    for(int i=0;i<(1<<n);i++){
        vector<int> s;//条件を満たす
        vector<int> ch(n,0);//チェック。矛盾してたら終了
        bool ans=true;//矛盾の有無
        rep(j,n){
            if(i&(1<<j))s.pb(j);
        }
        rep(j,s.size()) {//sを満たすだけ
            int z = s[j];
            ch[z] = 1;
        }
        rep(j,s.size()){
            int z=s[j];
            rep(k,a[s[j]].size()){
                if(ch[a[z][k].fi]!=a[z][k].se){
                    //脱出
                    ans=false;
                    break;
                }
            }
        }

            //sになるの
          /*  rep(k,a[s[j]].size()){//kは主張の番号
                if(ch[a[z][k].fi]==2){
                    ch[a[z][k].fi]=a[z][k].se;
                }
                else{
                    if(ch[a[z][k].fi]!=a[z][k].se){
                        //脱出
                        ans=false;
                        break;
                    }
                }

            }*/




        if(ans)ma=max(ma,(long long)s.size());
    }
    cout << ma <<endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n,k;
    cin>>n>>k;

    ll ans = 0;
    if(k%2==0){
        ans = pow(n/k,3) + pow((n+k/2)/k,3);
    }else{
        ans = pow(n/k,3);
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;
const int mod=1e9+7;
int n;
struct pnt{int x,v;}a[200005];
struct itv{int l,r;}b[200005];
bool cmpp(pnt x,pnt y){return x.v<y.v;}
bool cmpi(itv x,itv y){if(x.r==y.r)return x.l<y.l;return x.r<y.r;}
int stk[200005],tp;
int s[200005];
void add(int x,int y){int i;for(i=x;i<=n+1;i+=(i&-i))(s[i]+=y)%=mod;}
int qry(int x){int i,sum=0;for(i=x;i;i-=(i&-i))(sum+=s[i])%=mod;return sum;}
int main()
{
	cin>>n;int i;rep(i,n)cin>>a[i].x>>a[i].v;sort(a+1,a+n+1,cmpp);
	tp=0;rep(i,n)
	{
		if(!tp||a[stk[tp]].x<a[i].x) stk[++tp]=i;
		int l=0,r=tp,mid;b[i].l=tp;
		while(l<r){mid=(l+r+1)/2;if(a[stk[mid]].x>=a[i].x){r=mid-1;b[i].l=stk[mid];}else l=mid;}
	}
	tp=0;per(i,n)
	{
		if(!tp||a[stk[tp]].x>a[i].x) stk[++tp]=i;
		int l=0,r=tp,mid;b[i].r=tp;
		while(l<r){mid=(l+r+1)/2;if(a[stk[mid]].x<=a[i].x){r=mid-1;b[i].r=stk[mid];}else l=mid;}
	}
	sort(b+1,b+n+1,cmpi);
//	rep(i,n) cerr<<b[i].l<<' '<<b[i].r<<endl;
	add(1,1);rep(i,n) add(b[i].r+1,(qry(b[i].r+1)-qry(b[i].l-1)+mod)%mod);
	cout<<(qry(n+1)-qry(n)+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define pow107 int(pow(10,9) + 7)
#define F(i,x,n) for(int i = x; i < n ; ++i)

bool comp(pair<int, int> a, pair<int, int> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

inline bool pn(long int x){
    if(x <= 1)return false;
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i <= (3 + int(sqrt(x)))/2; ++i){
        if((x != i && x % i == 0) || (x != (3 + int(sqrt(x)) - i) && x % (3 + int(sqrt(x)) - i) == 0))
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

long int Func2(long int n,long int m){
    long int s2 = 1,
        r = 1;
    for(long int i = 1; i <= m; ++i){
        s2 = (s2*(n - (i - 1))/i) % (pow107);
    }
    return s2;
}

bool secsort(pair<int, int> a, pair<int, int> b){
    if(a.second == b.second)return a.first > b.first;
    else return a.second > b.second;
}

long int GCD(long int a,long int b){
    if(b == 0)return a;
    return GCD(b,a%b);
}

long int LCM(long int a,long int b){
    return a/GCD(a,b)*b;
}

void warfl(vector<vector<int> > &dist, int n){
  for(int k=0; k<n; k++){
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
  return;
}
//#define long long long

const int MAX = 1000000;
const int MOD = 1e9+7;

long mpow(long x, long n){
    long ans = 1;
    while(n != 0){
        if(n%2==1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n/2;
    }
    return ans;
}

long mfact(long n){
  long ans = 1;
  for(long i=2; i<=n; i++){
    ans = ans*i % MOD;
  }
  return ans;
}

long mcomb(long n, long m){ //aCbをmod計算
    if(n == 0 && m == 0) return 1;
    if(n < m || n < 0) return 0;
    long ans = mfact(n)*mpow(mfact(m), MOD-2) %MOD;
    ans = ans*mpow(mfact(n-m), MOD-2) %MOD;
    return ans;
}

long int jjjjj(long int n){
    long int x = 1;
    for(int i = 1; i <= n; ++i){
        x *=i;
    }
    return x;
}

int main(){
    int n,y;
    cin >> n >> y;

    int a = n,b = 0,c = 0;

    string s = "-1 -1 -1";

    if(1000 * a > y){
        cout << s << endl;
        return 0;
    }

    for(int i = 0; i <= n; ++i){
        for(int j = 0; j <= n - i; ++j){
            if(i * 10000 + j * 5000 + (n - i - j) * 1000 == y){
                cout << i << " " << j << " " << n - i - j << endl;
                return 0;
            }
        }
    }

    cout << s << endl;

}

Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let m: usize = s.next().unwrap().parse().unwrap();
	let a: Vec<_> = (0..m).map(|_| {
		(s.next().unwrap().parse::<usize>().unwrap(), s.next().unwrap().parse::<usize>().unwrap())
	}).collect();
	let range = match n {
		1 => 0..10,
		2 => 10..100,
		3 => 100..1000,
		_ => panic!(),
	};
	'a: for i in range {
		let mut j = i;
		let mut d = vec![];
		for _ in 0..n {
			d.push(j % 10);
			j /= 10;
		}
		for &(s, c) in a.iter() {
			if d[n - s] != c {
				continue 'a;
			}
		}
		println!("{}", i);
		return;
	}
	println!("-1");
}


Measured memory_bytes: 4352
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();

        out.println((a % 3 == 0) || (b % 3 == 0) || ((a + b) % 3 == 0) ? "Possible" : "Impossible");
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>

using namespace std;

const long long MOD = 1e9 + 7;
const long long MAX = 1e6;

long long fact[MAX], fact_inv[MAX];

long long power(long long a, long long b){
	long long ret = 1;
	while(b > 0){
		if(b & 1){
			ret = (ret * a) % MOD;
		}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return ret;
}

void init_nCr(long long n){
	fact[0] = 1;
	for (int i = 0; i < n; i++){
		fact[i + 1] = (fact[i] * (i + 1)) % MOD;
	}
	fact_inv[n] = power(fact[n], MOD - 2);
	for (int i = n - 1; i >= 0; i--){
		fact_inv[i] = (fact_inv[i + 1] * (i + 1)) % MOD;
	}
}

long long nCr(long long n, long long r){
	return (((fact[n] * fact_inv[r]) % MOD) * fact_inv[n - r]) % MOD;
}

int main() {
	long long H, W, A, B;
	cin >> H >> W >> A >> B;

	init_nCr(H + W);

	long long ans = 0;
	for (int i = B; i < W; i++){
		ans += nCr(H-A-1 + i, H-A-1) * nCr(A-1 + W-i-1, A-1);
		ans %= MOD;
	}

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


Measured memory_bytes: 5888
#include<cstdio>
#include<algorithm>
#include<vector>
#define SZ 262144
using namespace std;
struct Tree {
	long long Mn[SZ + SZ], K[SZ + SZ];
	void Add2(int nd, long long x) {
		Mn[nd] += x;
		K[nd] += x;
	}
	void Spread(int nd) {
		Add2(nd * 2, K[nd]);
		Add2(nd * 2+1, K[nd]);
		K[nd] = 0;
	}
	void UDT(int nd) {
		Mn[nd] = min(Mn[nd * 2], Mn[nd * 2 + 1]);
	}
	void Add(int nd, int b, int e, int s, int l, long long x) {
		if (b == s&&e == l) {
			Add2(nd, x);
			return;
		}
		int m = (b + e) >> 1;
		Spread(nd);
		if (s <= m)Add(nd * 2, b, m, s, min(m, l), x);
		if (l > m)Add(nd * 2 + 1, m + 1, e, max(m + 1, s), l, x);
		UDT(nd);
	}
	void Put(int nd, int b, int e, int x, long long y) {
		if (b == e) {
			Add2(nd, y - Mn[nd]);
			return;
		}
		int m = (b + e) >> 1;
		Spread(nd);
		if (x <= m)Put(nd*2, b, m, x, y);
		else Put(nd * 2 + 1, m + 1, e, x, y);
		UDT(nd);
	}
	long long Min(int nd, int b, int e, int s, int l) {
		if (b == s&&e == l)return Mn[nd];
		int m = (b + e) >> 1;
		Spread(nd);
		long long r = 1e18;
		if (s <= m)r = min(r, Min(nd * 2, b, m, s, min(m, l)));
		if (l > m)r = min(r,Min(nd * 2 + 1, m + 1, e, max(m + 1, s), l));
		UDT(nd);
		return r;
	}
}T;
int n, m;
long long D[201000];
struct AA {
	int b, c;
};
vector<AA>V[201000];
int main() {
	int i, b, e, c;
	scanf("%d%d", &n, &m);
	long long s = 0;
	for (i = 0; i < m; i++) {
		scanf("%d%d%d", &b, &e, &c);
		s += c;
		V[e].push_back({ b,c });
	}
	for (i = 1; i <= n; i++) {
		D[i] = T.Min(1, 0, n, 0, i-1);
		T.Put(1, 0, n, i, D[i]);
		for (auto &t : V[i]) {
			T.Add(1, 0, n, 0, t.b - 1, t.c);
		}
	}
	printf("%lld\n", s - T.Min(1, 0, n, 0, n));
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,border,ans=INF;

main() {
    cin >> n;
    border = (int)sqrt(n)+1;
    rep1(i,border) {
        if(!(n%i)) {
            int a=i,b=n/i,cnta=0,cntb=0;
            while(a || b) {
                if (a) cnta++,a/=10;
                if (b) cntb++,b/=10;
            }
            ans = min(ans,max(cnta,cntb));
        }
    }
    cout << ans << endl;
}




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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n % 2 == 1) {
        cout << "No";
    } else {
        string s1 = s.substr(0, n / 2);
        string s2 = s.substr(n / 2, n / 2);
        if (s1 == s2) {
            cout << "Yes";
        } else {
            cout << "No";
        }
    }
    return 0;
}

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

using namespace std;

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

    string n;

    getline(cin,n);

    long long int sum = 0;

    for(int i=0; i<n.size(); i++)
    {
        sum = sum + (n[i]-'0');
    }

    if(sum%9 == 0)
        cout<<"Yes\n";
    else
        cout<<"No\n";

    

    return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <set>
#include <string>

using namespace std;

int main()
{
    vector<int> a(5);
    for (int i = 0; i < 5; i++)
    {
        cin >> a[i];
    }

    for (int i = 0; i < 5; i++)
    {
        if (a[i] == 0)
        {
            cout << i+1 << endl;
            break;
        }
    }

    return 0;
}

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

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

  int h;
  int ans = 0;
  rep(i, N) {
    cin >> h;
    if (h >= K) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
string s;
ll n;
ll mod=1e9+7;
ll dp[100001][13];
ll fun(ll i,ll r){
	if(i==n) return r==5;
	if(dp[i][r]!=-1) return dp[i][r];
	ll ans=0;
	if(s[i]!='?') ans=(ans+fun(i+1,(r*10+(s[i]-'0'))%13))%mod;
	else{
		for(int d=0;d<10;d++) ans=(ans+fun(i+1,(r*10+d)%13))%mod;
	}
	return dp[i][r]=ans;
}
int main(){
	cin>>s;
	memset(dp,-1,sizeof dp);
	n=s.size();
	cout<<fun(0,0);
}


Measured memory_bytes: 21720
#include <iostream>
#include <algorithm>

using namespace std;

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

  int N, L;
  cin >> N >> L;
  int s = 0;
  int ans = 100 * 200;
  int x = -1;
  for (int i = 0; i < N; i++) {
    s += L + i;
    if (abs(L + i) < ans) {
      ans = abs(L + i);
      x = i;
    }
  }
  cout << s - (L + x) << endl;
  
  return 0;
}


Measured memory_bytes: 256
N, L = map(int, input().split())
sum_py = 0
apple_list = []
eat_num = 0
eat_i = 0

for i in range(1, N + 1):
    if eat_num < abs(L + i - 1):
        eat_num = abs(L + i - 1)

for i in range(1, N + 1):
    if abs(L + i - 1) < eat_num:
        eat_num = abs(L + i - 1)
        eat_i = i
    apple_list.append(L + i - 1)

del apple_list[eat_i - 1]
sum_py = sum(apple_list)

print(sum_py)


Measured memory_bytes: 3064
int main(int argc, const char * argv[]) {
    int A,B;
    scanf("%d\n",&A);
    scanf("%d\n",&B);
    
    if(A==1){
        A=14;
    }
    if(B==1){
        B=14;
    }
    
    if(A>B){
        printf("Alice\n");
    }
    
    else if(B>A){
        printf("Bob\n");
    }
    
    else{
        printf("Draw\n");
    }
    return 0;
}


Measured memory_bytes: 128
n = int(input())
for _ in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    dx12, dx34, dy12, dy34 = x1 - x2, x3 - x4, y1 - y2, y3 - y4
    print('YES' if abs(dx12 * dy34 - dy12 * dx34) < 1e-10 else 'NO')

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}
int main(){
	ll n;
	cin>>n;
	if(n<=1){
	    cout<<0<<endl;
	    return 0;
	}
	ll mod=pow(10,9)+7;
	ll ans=(power(10,n,mod)%mod+power(8,n,mod)%mod-power(9,n,mod)%mod-power(9,n,mod)%mod+mod+mod)%mod;
// 	ans=(((ans%mod)*(n%mod))%mod*(n-1)%mod)%mod;
	cout<<ans%mod<<endl;
}

Measured memory_bytes: 3632
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
const ll nmax = 1e9 + 7;
const ll MOD = 998244353;
const double PI = 2 * asin(1);

int main(){
  ll N, M; cin >> N >> M;
  
  vector <ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());

  vector <ll> sum(N); sum[0] = A[0];
  for (int i = 1; i < N; i++) sum[i] = sum[i - 1] + A[i];

  ll L = 0, R = A[N - 1] * A[N - 1] + 4;

  while (R - L > 1){
    ll now = (L + R) / 2;
    ll cnt = 0;
    for (int i = 0; i < N; i++){
      if (A[i] + A[N - 1] < now) continue;
      
      if (A[i] + A[0] >= now){
        cnt += N; continue;
      }

      ll l = 0, r = N;
      while (r - l > 1){
        ll n = (l + r) / 2;
        if (A[i] + A[n] < now) l = n;
        else r = n;
      }
      cnt += N - r;
    }
    
    if (cnt >= M) L = now;
    else R = now;
  }

  ll ans = 0, cnt = 0;
  for (int i = 0; i < N; i++){
    if (A[i] + A[N - 1] < L){
      continue;
    }
    if (A[i] + A[0] >= L){
      ans += A[i] * N + sum[N - 1];
      cnt += N;
      continue;
    }

    ll l = 0, r = N;
    while (r - l > 1){
      ll now = (l + r) / 2;
      if (A[i] + A[now] < L) l = now;
      else r = now;
    }
    ans += A[i] * (N - r) + sum[N - 1] - sum[l];
    cnt += N - r;
  }
  
  ans += L * (M - cnt);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	long long int N, sum = 0;
	cin >> N;
	vector<long long int>D(N);
	vector<long long int>M(N, 0);
	for (int i = 0; i < N; i++) {
		cin >> D[i];
		sum += D[i];
	}
	{
		int i = 0;
		for (int j = 0;j<N-1;j++)
		{
			M[(i + 2) % N] = M[i%N]+2 * (D[(i + 1) % N] - D[(i + 0) % N]);
			i += 2;
		}
	}
	for (int i = 0; i < N; i++)
	{
		sum -= M[i];
	}
	M[0] = sum / N;
	for (int i = 0; i < N-1; i++)
	{
		M[i + 1] = M[0] + M[i + 1];
	}
	for (int i = 0; i < N; i++)
	{
		cout << M[i] << " ";
	}
}


Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>

using ll = long long;
using namespace std;

int main() {
    int a[3];
    int x = 0, y = 0, z = 0;
    while (true){
        for (int &i : a) cin >> i;
        sort(a, a+3);
        if (a[0]+ a[1] <= a[2]) break;
        if (a[0] * a[0] + a[1]  * a[1] == a[2] * a[2]) x++;
        else if (a[0] * a[0] + a[1] * a[1] < a[2] * a[2]) z++;
        else y++;
    }
    printf("%d %d %d %d\n",x+y+z, x, y, z);
    return 0;
}


Measured memory_bytes: 3264
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
const long long inf = 1LL << 60;
int main() {
    int N; cin >> N;
    vector<long long int> h(N, 0), dp(N, inf);
    for (int i = 0; i < N; i++) cin >> h[i];
    dp[0] = 0;
    for (int i = 1; i < N; i++) {
        chmin(dp[i], abs(h[i] - h[i - 1]) + dp[i - 1]);
        if (i > 1) chmin(dp[i], abs(h[i] - h[i - 2]) + dp[i - 2]);
    }
    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 4816