akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n;
	cin >> n;
	
	int mini = 1e12, x, cnt = 0;
	for(int i = 0; i < n; i++){
		cin >> x;
		if(x < mini){
			mini = x;
			cnt++;
		}
	}
	cout << cnt << endl;
	
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static int gcd(int a,int b){
		if(b==0){
			return a;
		}else{
			return gcd(b,a%b);
		}
	}
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		System.out.println(gcd(Math.max(a,b),Math.min(a,b)));
		scan.close();
	}
}

Measured memory_bytes: 17228
# include <iostream>

using namespace std;

//https://atcoder.jp/contests/abc073/tasks/abc073_b

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

    int sheet_remain = 0;

    for (int i=0;i<N;i++){
        int l,r;
        cin >> l >> r;
        sheet_remain += r - l + 1;
        }
    
    cout << sheet_remain << endl;

}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>m;
  for(int i=6;i<=100000;i*=6)
    m.pb(i);
  for(int i=9;i<=100000;i*=9)
    m.pb(i);
  int dp[100010]={};
  for(int i=1;i<=100000;i++)
    dp[i]=dp[i-1]+1;
  for(int i=0;i<m.size();i++){
    for(int j=0;j<=100000-m[i];j++){
      dp[j+m[i]]=min(dp[j+m[i]],dp[j]+1);
    }
  }
  cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 640
from time import time
from random import randrange
import sys
def input():
	return sys.stdin.readline()[:-1]
d = int(input())
c = list(map(int, input().split()))
C = sum(c)
s = [list(map(int, input().split())) for _ in range(d)]
#t = [int(input()) for _ in range(d)]
t = []

def score(t):
	res = 0
	minus = 0
	last = [0 for _ in range(26)]
	for i, x in enumerate(t):
		minus += C - c[x-1] * (i - last[x-1] + 1)
		res -= minus
		res += s[i][x-1]
		last[x-1] = i+1
		#print(res)
	return res

#score(t)
res = 0
minus = 0
last = [0 for _ in range(26)]
for i in range(d):
	minus += C
	M = 0
	M_ind = -1
	for j in range(26):
		if M < c[j] * (i - last[j] + 1) + s[i][j]:
			M = c[j] * (i - last[j] + 1) + s[i][j]
			M_ind = j
	minus -= c[j] * (i - last[j] + 1)
	last[M_ind] = i+1
	res -= minus - s[i][M_ind]
	t.append(M_ind+1)

print(*t, sep="\n")

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

using namespace std;

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

    vector<long long > hoge(N);

    for(auto &x:hoge){
        cin>>x;
    }

    sort(hoge.begin(),hoge.end());

    vector<long long> sa;

    for(int i=0;(i+(K-1))<N;++i){

    long tmp=hoge[(i+(K-1))]-hoge[i];
        sa.emplace_back(tmp);

    }



    cout<<*min_element(sa.begin(),sa.end())<<endl;

}

Measured memory_bytes: 2168
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);

	string s;
	cin >> s;
	if (s[s.size() - 1] != 's')
	{
		cout << s << "s";
	}
	if (s[s.size() - 1] == 's')
	{
		cout << s << "es";
	}


	return 0;
}

Measured memory_bytes: 3620
n,m = map(int,input().split())

a = [[]for _ in range(n)]
for i in range(n):
    a[i] = list(map(int,input().split()))

b = [0 for _ in range(m)]
for i in range(m):
    b[i] = int(input())

for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)


Measured memory_bytes: 6024
N, M = map(int, input().split())
ans = -1
S = [0] * M
C = [0] * M
for i in range(M):
    S[i], C[i] = map(int, input().split())

def check(x):
    if len(str(x)) != N:
        return False
    for s, c in zip(S, C):
        if str(x)[s-1] != str(c):
            return False    
    return True

for i in range(10**N):
    if check(i):
        ans = i
        break

print(ans)

Measured memory_bytes: 3064
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
import Data.Maybe
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 整数の入力
    n <- readLn
    a <- readLn
    -- 出力
    putStrLn $ if mod n 500 <= a then "Yes" else "No"


Measured memory_bytes: 508
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<string,int> P;
int ans[200005]={0};
vector<string> vs,vr;
vector<P> vq,vq2,vq3;
int main(){
  ll n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++){
    string s;
    cin>>s;
    vs.push_back(s);
    reverse(s.begin(),s.end());
    vr.push_back(s);
  }
  sort(vs.begin(),vs.end());
  sort(vr.begin(),vr.end());

  for(int i=0;i<m;i++){
    string s;
    cin>>s;
    bool f=false;
    if(s[0]=='*'){
      f=true;
      reverse(s.begin(),s.end());
    }
    bool f_=false;
    int cp=0;
    for(int j=0;j<s.length();j++){
      if(s[j]=='?'){
        f_=true;
        cp=j;
      }
    }
    bool f2=false;
    if(s[s.length()-1]=='*') f2=true;


    if(f){
      s.pop_back();
      if(!f_) vq2.push_back(P(s,i));
      else{
        for(int k=0;k<26;k++){
          s[cp]=(char)('a'+k);
          vq2.push_back(P(s,i));
        }
      }
    }
    else{
      if(f2){
        s.pop_back();
        if(!f_) vq.push_back(P(s,i));
        else{
          for(int k=0;k<26;k++){
            s[cp]=(char)('a'+k);
            vq.push_back(P(s,i));
          }
        }
      }
      else{
        if(!f_) vq3.push_back(P(s,i));
        else{
          for(int k=0;k<26;k++){
            s[cp]=(char)('a'+k);
            vq3.push_back(P(s,i));
          }
        }
      }
    }
  }
  sort(vq.begin(),vq.end());
  sort(vq2.begin(),vq2.end());
  sort(vq3.begin(),vq3.end());

  for(int i=0;i<vq.size();i++) {
    string s=vq[i].first;
    int sl=s.length();
    int idx=vq[i].second;
//    cout<<s<<" "<<idx<<" ";
    int lb=lower_bound(vs.begin(),vs.end(),s)-vs.begin();
    s[sl-1]=(char)(s[sl-1]+1);
  //  cout<<s<<" ";
    int rb=lower_bound(vs.begin(),vs.end(),s)-vs.begin();
    ans[idx]+=rb-lb;
  //  cout<<rb-lb<<endl;
  }
  for(int i=0;i<vq2.size();i++) {
    string s=vq2[i].first;
    int sl=s.length();
    int idx=vq2[i].second;
  //  cout<<s<<" "<<idx<<" ";
    int lb=lower_bound(vr.begin(),vr.end(),s)-vr.begin();
    s[sl-1]=(char)(s[sl-1]+1);
    int rb=lower_bound(vr.begin(),vr.end(),s)-vr.begin();
    ans[idx]+=rb-lb;
  //  cout<<s<<" "<<rb-lb<<endl;
  }
  for(int i=0;i<vq3.size();i++) {
    string s=vq3[i].first;
    int sl=s.length();
    int idx=vq3[i].second;
  //  cout<<s<<" "<<idx<<" ";
    int lb=lower_bound(vs.begin(),vs.end(),s)-vs.begin();
    s.push_back('a');
  //  cout<<s<<" ";
    int rb=lower_bound(vs.begin(),vs.end(),s)-vs.begin();
    ans[idx]+=rb-lb;
  //  cout<<rb<<" "<<lb<<endl;
  }
  for(int i=0;i<m;i++) cout<<ans[i]<<endl;
}



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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	cout << n / 3 << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
		cout << r * x - d << endl;
		x = r * x - d;
	}
}

Measured memory_bytes: 256
from sys import stdin


def readline_from_stdin() -> str:
    return stdin.readline().rstrip


if __name__ == '__main__':
    pass
    # N = input()
    # X, Y, Z = input().split()
    # A = [int(i) for i in input().split()]
    X, N = input().split()
    X, N = int(X), int(N)
    if N == 0:
        print(X)
        exit(0)
    P = [int(i) for i in input().split()]
    P = list(set(P))

    i = 0
    while True:
        v = X-i
        if not (v in P):
            print(v)
            exit(0)
        v = X+i
        if not (v in P):
            print(v)
            exit(0)
        i += 1


Measured memory_bytes: 62016
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
        
    bigline = '#.' * 151
    evenline = bigline[:w]
    oddline = bigline[1:w+1]
     
    for i in range(h):
        if i % 2 == 0:
            print(evenline)
        else:
            print(oddline)
    print()



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

using namespace std;
#define int long long
#define all(v) v.begin(), v.end()
#define pii pair <int , int>
#define F first
#define S second
const int N = 1e5 + 5;
int a[N];

int check(int n, int x) {
    while (n % x == 0) n/=x;
    return (n % x == 1);
}
int32_t main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k; cin >> n >> k;
    n %= k;
    cout << min(n, k - n) << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		String s = scan.next();

		int c = 0;
		int First = 0;
		int Last = 0;

		for (int i = 0; i < N; i++) {

			if (s.charAt(i) == '(') {
				c++;
			} else if (s.charAt(i) == ')') {
				c--;
				if (c == -1) {
					c = 0;
					First++;
				}
			}

		}

		Last = c;

		for (int i = 0; i < First; i++) {
			s = "(" + s;
		}

		for (int i = 0; i < Last; i++) {
			s = s + ")";
		}

		System.out.println(s);

	}
}


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


typedef long long ll;
#define INF INT_MAX/2
int W, H;
int p[101010], q[101010];
ll ans = 0;
//-----------------------------------------------------------------
int main() {
	cin >> W >> H;
	rep(i, 0, W) scanf("%d", &p[i]);
	rep(i, 0, H) scanf("%d", &q[i]);

	priority_queue<int, vector<int>, greater<int>> pi, pj;
	rep(i, 0, W) pi.push(p[i]);
	rep(i, 0, H) pj.push(q[i]);

	while (!pi.empty() || !pj.empty()) {
		int i = INF, j = INF;
		
		if(!pi.empty()) i = pi.top();
		if(!pj.empty()) j = pj.top();

		if (i < j) {
			pi.pop();
			ans += (ll)i * (ll)(H + 1);
			W--;
		}
		else {
			pj.pop();
			ans += (ll)j * (ll)(W + 1);
			H--;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 2296
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline LL Read()
{
	LL x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100005;

map <LL, LL> s;
LL a[MAXN];
int n, m;

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = Read() + 1;
	a[1] = n;
	for (int i = 2; i <= m; i ++)
		a[i] = Read();
	LL cur = a[m];
	s[cur - 1] = 1;
	for (int i = m - 1; i; i --)
		if (a[i] < cur)
			for (cur = a[i]; (-- s.end()) -> xx >= cur; )
			{
				auto it = -- s.end();
				if (it -> yy)
					s[cur - 1] += it -> yy * (it -> xx / cur), s[it -> xx % cur] += it -> yy;
				s.erase(it);
			}
	for (int i = n - 1; i; i --)
		s[i - 1] += s[i];
	for (int i = 0; i < n; i ++)
		printf("%lld\n", s[i]);
	return 0;
}


Measured memory_bytes: 8704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
using Graph = vector<vector<int>>;

int main() {
	int n, h, w, a, b, ans = 0;
	cin >> n >> h >> w;
	rep(i, n) {
		cin >> a >> b;
		if (a >= h && b >= w)ans++;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] city = new int[n+1];
	    for(int i = 0; i < n; i++){
	        city[i] = sc.nextInt();
	    }
	    city[n] = x;
	    Arrays.sort(city);
		
		// 計算
		int result = city[1] - city[0];
		for(int i = 1; i < n; i++){
	        int sabun = city[i+1] - city[i];
	        result = gcd(result, sabun);
	    }
		
		// 出力
		System.out.println(result);
		
	}
	
	static int gcd(int x, int y){
	    if(y == 0) return x;
	    return gcd(y , x%y);
	}
}


Measured memory_bytes: 49824
#include <iostream>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;
    ll cs = 0;
    map<ll, ll> modcount;
    modcount[0] = 1;
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        ll a;
        cin >> a;
        cs += a;
        cs %= m;
        ans += modcount[cs];
        modcount[cs]++;
    }
    cout << ans << endl;
    return 0;
}


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

//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define mod1 998244353
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef priority_queue <ll> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
    int t;
t=1;
//cin>>t;
while(t--){
	int n;
	cin>>n;
	int a[n][3],dp[n][3];
	fo(i,n){
		fo(j,3)cin>>a[i][j];
	}
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	fo1(i,n-1){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));

}
    return 0;
}

Measured memory_bytes: 5912
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
//#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}

//DEBUG_OUT("----\n");

void func(void)
{
    int A, B;
    string s;

    cin >> A >> B;
    cin >> s;

    if (s.size() != (A + B + 1)) {
        cout << "No" << endl;
        return;
    }
    for (int i = 0; i < A; i++) {
        if (!(s[i] >= '0' && s[i] <= '9')) {
            cout << "No" << endl;
            return;
        }
    }
    if (s[A] != '-') {
        cout << "No" << endl;
        return;
    }
    for (int i = A + 1; i < A + B + 1; i++) {
        if (!(s[i] >= '0' && s[i] <= '9')) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> dp(n+1, -1);
  rep(i,n) {
    auto itr = upper_bound(ALL(dp), a[i], greater<int>());
    debug(itr - dp.begin());
    *itr = a[i];
  }
  cout << lower_bound(ALL(dp), -1, greater<int>()) - dp.begin() << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {

	var S string

	fmt.Scan(&S)
	
	N:= len(S)

	forward := S[:(N-1)/2]

	back := S[(((N-1)/2)+1):]


	if forward ==back{

		fmt.Println("Yes")
	}else{

		fmt.Println("No")
	}



}


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

int N, S;

int rec(int sum, int i, int k){
	if(k == N)return sum == S ? 1 : 0;
	if(sum > S)return 0;
	
	int ans = 0;
	for(int j = i; j < 10; j++)
		ans += rec(sum + j, j + 1, k + 1);
	
	return ans;
	
}

int main() {
	while(1){
		cin >> N >> S;
		if(N == 0 && S == 0)break;
		
		cout << rec(0, 0, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
# include <bits/stdc++.h>
# define ll long long int
# define pb push_back
# define pf push_front
# define mpi make_pair
# define pi pair<ll,ll>
# define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
# define mod 1000000007
# define endl "\n"
using namespace std;
int main()
{
	fast
	ll a,b,c;
	cin>>a>>b>>c;
	if((a-b)>=c)
	{
		cout<<"0";
	}
	else
	{
		cout<<(c-(a-b));
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
l_ls = list(map(int, input().split()))
l_ls.sort()
def check(a,b,c):
    return abs(a-b) < c < a+b
ans = 0
for i in range(n):
    short = l_ls[i]
    num = 0
    r = i+1
    for l in range(i+1,n):
        while r+1 < n and check(short, l_ls[l], l_ls[r+1]):
            r += 1
        num += r - l
        if r == l:
            r += 1
    ans += num
print(ans)
            


Measured memory_bytes: 9308
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
 
using namespace std;
 
typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

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

    struct Data {
        int idx = 0;
        int val = 0;
    };

    vector<Data> A(N);
    for (int i=0; i<N; i++) {
        A[i].idx = i;
        cin >> A[i].val;
    }

    sort(A.begin(), A.end(), [](const Data& lhs, const Data& rhs) {
        return lhs.val > rhs.val;
    });

    vector<int> outVal(N);
    for (int i=0; i<N; i++) {
        const auto &v = A[i];
        if (i != 0 || N == 1) {
            outVal[v.idx] = A[0].val;
        } else {
            outVal[v.idx] = A[1].val;
        }
    }

    for (int i=0; i<N; i++) {
        cout << outVal[i] << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3968
package main

import (
	"io"
	"os"

	"fmt"

	"strconv"
)

func Solve(in io.Reader, out io.Writer) {
	var ns string
	fmt.Fscan(in, &ns)
	n, _ := strconv.Atoi(ns)

	sum := 0
	for _, c := range ns {
		i, _ := strconv.Atoi(string(c))
		sum += i
	}
	if n%sum == 0 {
		fmt.Fprintln(out, "Yes")
	} else {
		fmt.Fprintln(out, "No")
	}
}

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


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

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b, c; cin >> a >> b >> c;
    if (a+b+c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll q;
    cin >> q;

    vl ans(q);
    rep(i, q) {
        ll a, b;
        cin >> a >> b;

        // 対称性より a <= b を仮定してよい。
        if(a > b) {
            swap(a, b);
        }

        // 1問目が1～a-1位の人たちについて考える。
        // 2問目でb+(a-1)～b+1位を取ると
        // (a - i)*(b + i) = ab - i*(b - a) - i^2 < ab より条件を満たす。
        // 同様に2問目が1～a-1位の人たちは1問目でb+(a-1)～b+1位を取ると条件を満たす。
        // よって2*(a - 1)人は条件を満たすことが確定。

        // 以下、1問目がa+1～b位, 2問目がa～b-1位の人たちについて考える。
        // 判定問題「x組作れるか？」を二分探索で解く。
        ll left = 0;
        ll right = b - a;
        while(right - left > 1) {
            ll x = (left + right)/2;
            // 1問目がa+1～a+x位、2問目がa+(x-1)～a位とするのが最適。
            // すべての 1 <= i <= x に対して (a + i)*(a + x - i) < ab のときx組作れる。
            // f(i) = (a + i)*(a + x - i) は i = x/2 で最大値を取るので f(x/2) < ab ならok。
            if((a + x/2)*(a + x - x/2) < a*b) {
                left = x;
            }
            else {
                right = x;
            }
        }
        ans[i] = 2*(a-1) + left;
    }

    rep(i, q) {
        out(ans[i]);
    }
    
    re0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
typedef pair<int, int> pii;
const int maxn = 22;
int L, n, m, cur;
int bin[maxn];
vector<pii> E[maxn], G[maxn];
int main()
{
	scanf("%d", &L);
	bin[0] = 1;
	for(int i = 1; i < maxn; ++i)
		bin[i] = bin[i - 1] * 2;
	--L;
	for(n = 2; bin[n - 1] <= L; ++n);
	for(int i = n - 1; i >= 2; --i)
	{
		E[i].push_back(mp(i + 1, 0));
		E[i].push_back(mp(i + 1, bin[n - 1 - i]));
	}
	E[1].push_back(mp(2, 0));
	L -= bin[n - 2];
	cur += bin[n - 2]; 
	for(int i = 2; i <= n; ++i)
		if(L >= bin[n - i] - 1)
		{
			E[1].push_back(mp(i, cur));
			L -= bin[n - i];
			cur += bin[n - i];
		}
	if(n <= 20)
	{
		for(int i = 1; i <= n; ++i)
			m += E[i].size();
		printf("%d %d\n", n, m);
		for(int i = 1; i <= n; ++i)
			for(auto v : E[i])
				printf("%d %d %d\n", i, v.first, v.second);
	}
	else
	{
		for(int i = 2; i <= n; ++i)
			for(auto v : E[i])
				G[i - 1].push_back(mp(v.first - 1, v.second));
		for(auto v : E[1])
			if(v.first == 2)
				for(auto k : E[2])
					G[1].push_back(mp(2, v.second + k.second));
			else
				G[1].push_back(mp(v.first - 1, v.second));
		--n;
		sort(G[1].begin(), G[1].end());
		G[1].erase(unique(G[1].begin(), G[1].end()), G[1].end());
		for(int i = 1; i <= n; ++i)
			m += G[i].size();
		printf("%d %d\n", n, m);
		for(int i = 1; i <= n; ++i)
			for(auto v : G[i])
				printf("%d %d %d\n", i, v.first, v.second);
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<functional>

using namespace std;

int main(){
	int n, ans = 0;
	string s, t;
	cin >> s >> t;
	vector<int> scnt(26), tcnt(26);
	for(int i = 0; i < s.size(); i++){
		scnt[s[i] - 'a']++;
		tcnt[t[i] - 'a']++;
	}
	sort(scnt.begin(), scnt.end(), greater<int>());
	sort(tcnt.begin(), tcnt.end(), greater<int>());
	bool f = true;
	for(int i = 0; i < 26; i++){
		if(scnt[i] != tcnt[i]){
			f = false;
			break;
		}
	}
	if(f){
		cout << "Yes" << endl;
	} else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 776
#include <stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if (a==b)
	{
		printf("%d\n",c);
	}else if (b==c)
	{
		printf("%d\n",a);
	}else if (a==c)
	{
		printf("%d\n",b);
	}
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll A, B, C, D;
vector<vector<vector<ll>>> Dp;
const ll MOD = 998244353;

int main() {
	cin >> A >> B >> C >> D;
	vector<vector<long long>> DP(C + 1, vector<long long >(D + 1));
	DP[A][B] = 1;
	for (int n = A; n <= C; ++n) {
		for (int m = B; m <= D; ++m) {
			if (n == A && m == B) {
				continue;
			}
			DP[n][m] = ((m) % MOD*DP[n - 1][m] % MOD + (n) % MOD*DP[n][m - 1] % MOD - (n - 1) % MOD*(m - 1) % MOD*DP[n - 1][m - 1] % MOD + MOD) % MOD;
		}
	}
	cout << DP[C][D] << endl;
	return 0;
}

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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


int N;
int X[200010];
pii XX[200010];
int ans[200010];

int main(){
    

    cin >> N;
    for(int i = 0; i < N; i++) cin >> X[i], XX[i] = pii(X[i], i);
    sort(XX, XX + N);
    for(int i = 0; i < N; i++){
        if(i < N / 2){
            ans[XX[i].second] = XX[N/2].first;
        }
        else if(i >= N / 2){
            ans[XX[i].second] = XX[N/2-1].first;
        }        
    }
    for(int i = 0; i < N; i++){
        cout << ans[i] << endl;
    }

}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
// #define vec(v) vector<int>(v)
// #define be(v) (v).begin(), (v).end()
// #define pb(q) push_back(q)
// #define mapci(mp) map<char*,int>(mp)
// #define mapcc(mp) map<char*,char*>(mp)
// typedef long long ll;
using namespace std;

int main(){
    char b;
    cin>>b;
    if(b=='A') cout<<'T'<<endl;
    if(b=='T') cout<<'A'<<endl;
    if(b=='C') cout<<'G'<<endl;
    if(b=='G') cout<<'C'<<endl;
    return 0;
}

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

ll f(ll b, ll n){
  if (b == 1) return -1;
  else if (n < b) return n;
  else return f(b,n/b) + n % b;
}


ll ma(vector<ll> ANS){
  if(ANS.size()==0) return -1;
  ll ans=1000000000000;
  for (ll i: ANS) ans=min(ans,i);
  return ans;
}


ll gcd(ll a, ll b)
  {return b==0 ? a : gcd(b,a%b);}


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  ll n,s;
  ll ans=1000000000000;
  cin >> n >> s;
  if (n==s) cout<<n+1<<endl;
  else{
    for (ll i=1; i*i<=n-s; i++){
      if ((n-s)%i==0){
        if (f(i+1,n)==s) ans=min(ans,i+1);
        if (f((n-s)/i+1,n)==s) ans=min(ans,(n-s)/i+1);
      } 
    }

    if (ans==1000000000000) ans=-1;
    cout<<ans<<endl;
  }
  
} 


Measured memory_bytes: 256
//c
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
 
#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair
 
using namespace std;
 
static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;   
 
int n, m;
int h[3000], w[3000];

 
int main(){
	
	while(cin>>n>>m, (n||m)){
		
		vector<int> hsum, wsum;
		int res = 0;
		
		for(int i=0; i<n; ++i){
			cin>>h[i];
		}
		
		for(int i=0; i<m; ++i){
			cin>>w[i];
		}
		
		for(int i=0; i<n; ++i){
			
			int d = 0;
			
			for(int j=i; j<n; ++j){
				hsum.push_back(d += h[j]);
			}
		}
		
		sort(hsum.begin(), hsum.end());
		
		for(int i=0; i<m; ++i){
			
			int d = 0;
			
			for(int j=i; j<m; ++j){
				
				d += w[j];
				
				res += (int)(upper_bound(hsum.begin(), hsum.end(), d)
								- lower_bound(hsum.begin(), hsum.end(), d));
			}
		}
		
		cout << res << endl;
	}
	
	return 0;   
}

Measured memory_bytes: 15148
#include <cstdio>

using namespace std;

int a[10];

int check(int x) {
    while (x > 0) {
        if (a[x % 10] == 1) return 0;
        
        x /= 10;
    }
    
    return 1;
}

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


Measured memory_bytes: 128
def check(m, i, j, H, W):
    left = False
    up = False
    right = False
    down = False
    left = ((j == 0) or (m[i][j-1] == "#"))
    up = ((i == 0) or (m[i-1][j] == "#"))
    right = ((j == (W - 1)) or (m[i][j+1] == "#"))
    down = ((i == (H-1)) or (m[i+1][j] == "#"))
    return left or right or up or down
  
H, W = map(int, input().split())
l = [str(input()) for i in range(H)]
ans = "Yes"
for i in range(H):
    for j in range(W):
        if (l[i][j] == "#") and (not(check(l, i, j, H, W))):
            ans = "No"
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair 
#define f(i,n) for(int i=0;i<n;i++) 
#define F first 
#define S second 
#define pb push_back 

using namespace std;

const int mod = 1e9 + 7; 

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1LL; 
    x = x % p;
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
}

ll gcdExtended(ll a, ll b, ll *x, ll *y); 

ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
    ll res = (x%m + m) % m; 
    return res;
}  
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{  
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1);  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 

ll fact[500005], invfact[500005];

ll f1(ll n, ll c){
	ll num = fact[n];
	ll den = (invfact[c]*invfact[n-c])%mod;
	num = (num*den)%mod;
	return num;
}

ll f2(ll n, ll c){
	ll num = fact[n];
	ll den = invfact[n-c];
	num = (num*den)%mod;
	return num;
}


void test(){
	fact[0] = 1;
	for(int i=1;i<=500001;i++){
		fact[i] = (fact[i-1]*i)%mod;
	}
	invfact[0] = 1;
	for(int i=1;i<=500001;i++){
		invfact[i] = (invfact[i-1]*modInverse(i,mod))%mod;
	}
	ll n,m;
	cin>>n>>m;
	ll sum = 0;
	f(i,n+1){
		if(i%2==0) sum = (sum + (f2(m-i,n-i)*f1(n,i))%mod)%mod;
		else sum = (sum - (f2(m-i,n-i)*f1(n,i))%mod + mod)%mod;
	}
//	cout<<sum<<"\n";
	sum = (sum*fact[m])%mod;
	sum = (sum*invfact[m-n])%mod;
	cout<<sum<<"\n";
	
}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
//	cin>>tests;
	while(tests--){
		test();
	}
}

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

int n;
vector<vi> to;

vi state;
vi vs;
bool dfs(int v) {
  if (state[v]) {
    if (state[v] == 1) {
      vs.erase(vs.begin(), find(vs.begin(),vs.end(),v));
      return true;
    }
    return false;
  }
  vs.push_back(v);
  state[v] = 1;
  for (int u : to[v]) {
    if (dfs(u)) return true;
  }
  state[v] = -1;
  vs.pop_back();
  return false;
}

void solve() {
  vector<int> nxt(n), visited(n), erased(n,1);
  rep(i,vs.size()) {
    int v = vs[i];
    int u = vs[(i+1)%vs.size()];
    nxt[v] = u;
    erased[v] = 0;
  }
  int v = vs[0];
  while (!visited[v]) {
    for (int u : to[v]) {
      if (erased[u]) continue;
      int nv = v;
      while (nxt[nv] != u) {
        nv = nxt[nv];
        erased[nv] = 1;
      }
      nxt[v] = u;
    }
    visited[v] = 1;
    v = nxt[v];
  }
  vi ans;
  int sv = v;
  while (1) {
    ans.push_back(v);
    v = nxt[v];
    if (v == sv) break;
  }
  cout<<ans.size()<<endl;
  for (int v : ans) cout<<v+1<<endl;
}

int main() {
  int m;
  cin>>n>>m;
  to.resize(n);
  rep(i,m) {
    int a, b;
    cin>>a>>b;
    --a; --b;
    to[a].push_back(b);
  }

  state = vi(n);
  rep(i,n) if (!state[i]) {
    if (dfs(i)) {
      solve();
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 384
import itertools as iter
import math as m

def main():
    N, M, X = list(map(int, input().split()))
    C = []
    for _ in range(N):
        C.append(list(map(int, input().split())))
    result = []
    for i in range(1, N+1):
        for c in iter.combinations(C, i):
            cost = 0
            s = [0] * (M+1)
            for x in c:
                for j, y in enumerate(x):
                    s[j] += y
                cost += x[0]
            if check(s[1:], X):
                result.append(cost)
    if len(result) > 0:
        print(min(result))
    else:
        print(-1)
    pass

def check(s, X) -> bool:
    return all([a >= X for a in s])

if __name__ == '__main__':
    main()

Measured memory_bytes: 68852
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  ll n;
  cin>>n;
  int l=-1;
  for(ll i=1;i<=n;i++){
    if(i*i+i-2*n==0){
      l=i;
    }
  }
  if(l==-1){
    cout<<"No"<<endl;
    return(0);
  }
  vector<vector<int>>s(l+1,vector<int>(l));

  int cnt=1;
  rep(i,l){
    rep2(j,i,l){
      s[i][j]=cnt;
      cnt++;
    }
  }
  cnt=1;
  rep(i,l){
    rep2(j,i,l){
      s[j+1][i]=cnt;
      cnt++;
    }
  }

  cout<<"Yes"<<endl;
  cout<<l+1<<endl;
  rep(i,l+1){
    cout<<l<<' ';
    rep(j,l){
      cout<<s[i][j];
      if(j+1==l)cout<<endl;
      else cout<<' ';
    }
  }
  return(0);
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++) 
#define REP(i,n) FOR(i,0,n) 
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second 
signed main(){
  ll A,B;string S;cin>>A>>S;
  S=S.substr(0,S.size()-3)+S.substr(S.size()-2,2);
  B=stoll(S);S=to_string(A*B);
  if(S.size()>2)cout<<S.substr(0,S.size()-2)<<endl;
  else cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 3692
import java.util.*;
import java.util.stream.*;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    
    List<Integer> numList = new ArrayList<>();
    
    while(sc.hasNextInt()){
      numList.add(sc.nextInt());
    }
    
    numList = numList.stream().distinct().collect(Collectors.toList());
    
    System.out.println(numList.size());
  }
 
}

Measured memory_bytes: 26964
n = int(input())
a = list(map(int, input().split()))

flag = True
for i in range(n):
  if a[i] % 2 == 0:
    if a[i] % 3 == 0 or a[i] % 5 == 0:
      pass
    else:
      flag = False
if flag:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define stdi(in) freopen(in, "r", stdin)
#define stdo(out) freopen(out, "w", stdout)
#define stdio(in, out) stdi(in); stdo(out)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define MAX 100007
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<pair<int, int> , null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update>

const ll modd = 998244353;
const ll inf = 1e18;

int dp[3002][3002];
string ans;

int solve(string s, string t, int i, int j){
	
	if(i>=s.length() || j>=t.length()){
		return 0;
	}

	if(dp[i][j]!=-1) return dp[i][j];

	if(s[i]==t[j]){
		int l = 1+solve(s,t,i+1, j+1);
		if(l>ans.length()){
			ans+=s[i];
		}
		return dp[i][j] = l;
	}

	return dp[i][j] = max(solve(s,t,i+1,j), solve(s,t,i,j+1));
}

int main(){
	/*#ifndef ONLINE_JUDGE
        stdio("in", "out");
    #endif*/
    fast;
    string s,t;
    cin>>s>>t;
    ans = "";
    int sl, tl;
    sl = s.length();
    tl = t.length();

    for(int i=1;i<=sl;i++){
    	for(int j=1;j<=tl;j++){
    		if(s[i-1] == t[j-1]){
    			dp[i][j] = dp[i-1][j-1]+1;
    			/*if(dp[i][j]>ans.length()){
    				//cerr<<"s[i] == "<<s[i-1]<<'\n';
    				ans+=s[i-1];
    			}*/
    		} else {
    			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    		}
    	}
    }
    int i=sl, j=tl;
    while(i>0&&j>0){
	    if(dp[i][j]==dp[i-1][j]){
			i--;
	    }
	    else if(dp[i][j]==dp[i][j-1]){
	    	j--;
	    }
	    else if(dp[i][j]==dp[i-1][j-1]+1){
			ans = s[i-1]+ans;
			i--;
			j--;
	    }
	}

    //cout<<dp[sl][tl]<<'\n';
/*
    for(int i = l-1; i >= 0 ; i--){
    	cout<<ans[i];
    }
*/
    cout<<ans<<'\n';

	return 0;
}



Measured memory_bytes: 35456
N = int(input())
h = list(map(int, input().split()))
INF = 10 ** 9

dp = [0] + [INF for _ in range(N - 1)]
for i in range(1, N):
    if i == 1:
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1])
    else:
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[N - 1])

Measured memory_bytes: 13784
import sys
from collections import Counter

input = sys.stdin.readline

def main():
    N = int(input())
    a = Counter(list(map(int, input().split())))
    
    ans = 0
    
    for n, c in a.items(): ans = max(ans, c + a[n-1] + a[n+1])
        
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14500
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
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 (a > b) { a = b; return true; } return false; }

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

	int N; cin >> N; vector<double>a(N); rep(i, 0, N)cin >> a[i];

	map<double, int>m;

	rep(i, 0, N) {
		m[a[i]]++;
	}
	for (auto it = next(m.begin()); it != m.end(); it++) {
		it->second += prev(it)->second;
	}

	rep(i, 0, N) {
		auto it = m.find(a[i]);
		int sum(0);
		if (it != m.begin())sum += prev(it)->second * 3;
		if (it != m.begin()) {
			sum += (it->second - prev(it)->second - 1);
		}
		else {
			sum += it->second - 1;
		}
		cout << sum << endl;

	}

	return 0;
}

Measured memory_bytes: 3964
#include<iostream>
using namespace std;
int mod(int a,int b)
{
  if(a>b)
    return a-b;
  else
    return b-a;
}
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
  cin>>a[i];
  if(n==1)
  {
    cout<<0<<endl;
    return 0;
  }
  int dp[n];
  dp[0]=0;
  dp[1]=mod(a[0],a[1]);
  for(int i=2;i<n;i++)
  {
    dp[i]=dp[i-1]+mod(a[i],a[i-1]);
    for(int j=i-2;j>=i-k&&j>=0;j--)
    {
        if(dp[i]>dp[j]+mod(a[i],a[j]))
            dp[i]=dp[j]+mod(a[i],a[j]);
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <time.h>

#define loop(i, num)  for (int i = 0; i < num; i++)

using namespace std;

int n, nums[100005];

int main() {
    
    cin >> n;
    
    loop (i, n) {
        
        int num;
        
        cin >> num;
        
        if (num != 0) {
            
            ++nums[num - 1];
            
        }
        
        ++nums[num];
        
        if (num != 1e5) {
            
            ++nums[num + 1];
            
        }
        
    }
    
    sort(nums, nums + 100005);
    
    reverse(nums, nums + 100005);
    
    cout << nums[0] << endl;
    
}


Measured memory_bytes: 640
#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()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;
void solve()
{
	int n, m, x;
	cin>>n>>m>>x;
	int num;
	set<int> st;
	REP(i,m)
	{
		cin>>num;
		st.insert(num);
	}	
	int cost1 = 0, cost2 = 0;
	for(int i = x+1; i<=n; i++)
	{
		if(st.count(i))
			cost1++;
	}
	for(int i=x-1; i>0; i--)
	{
		if(st.count(i))
			cost2++;
	}
	cout<<min(cost1, cost2);
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3660
S=str(input())
S2=[]
ans=0
for i in range(len(S)):
  for j in range(len(S)+1):
    S2=S[i:j]
    que=len(S2)
    S2=S2.replace("A","")
    S2=S2.replace("G","")
    S2=S2.replace("C","")
    S2=S2.replace("T","")
    if S2=="":
      if que>ans:
        ans=que
    S2=[] 
print(ans)

Measured memory_bytes: 9036
'use strict'

const main = (input) => {
    input = input.split('\n')[0].split(' ').map(i => parseInt(i))
    const D = input[0]
    const N = input[1]

    if(D === 2){
        let num = N * 10000
        if(num % 1000000 === 0){
            console.log(num + 10000)
            return
        }else{
            console.log(num)
            return
        }
    }

    if(D === 1){
        let num = N * 100
        if(num % 10000 === 0){
            console.log(num + 100)
            return
        }else{
            console.log(num)
            return
        }
    }

    if(D === 0){
        let num = N
        if(num % 100 === 0){
            console.log(num + 1)
            return
        }else{
            console.log(num)
            return
        }
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 21064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int count = 0;
		for(int i=0;i<n-2;i++) {
			if(s.charAt(i) == 'A') {
				if(s.charAt(i+1) == 'B') {
					if(s.charAt(i+2) == 'C') {
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 21844
def sum_of_digits(n):
	mod=0
	num=[]
	while n !=0:
		mod=n%10
		n=n//10
		num.append(mod)
	return (sum(num))

N=int(input())
sum_of_all =0
for i in range(1,N//2+2):
	sum1=sum_of_digits(i)
	sum2=sum_of_digits(N-i)
	sum_of_all=sum1+sum2
	if i ==1:
		ans=sum_of_all
	elif ans>sum_of_all:
		ans=sum_of_all
print(ans)
		
	

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    ll A, B, C;

    cin >> A >> B >> C;

    ll res = __LONG_LONG_MAX__;

    res = min(res, A * B * (C % 2));
    res = min(res, C * B * (A % 2));
    res = min(res, A * C * (B % 2));

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
int main(){
  int n;cin>>n;
  int sm = 0;
  int mx = 0;
  int a[n];
  rep(i,n){
    cin>>a[i];
    mx = max(mx,a[i]);
    sm += a[i];
  }
  if(mx < sm-mx)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll     = long long;
using prefix = __attribute__((constructor))void;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807LL;

#define elif           else if
#define def            inline auto
#define func           inline constexpr ll
#define up(i,a,n)      for(ll i=(a),i##_1=(n);i<i##_1;++i)
#define down(i,a,n)    for(ll i=(a),i##_1=(n);i>=i##_1;--i)
#define rep(i,n)       up(i,0,n)

func    gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
func    lcm(ll a,ll b) {return a*b/gcd(a,b);}
def     dig(ll a)      {return to_string(a).length();}
prefix  init()         {cin.tie(0),ios::sync_with_stdio(0);}

func fact(ll a){return a?fact(a-1)*a:1;}

signed main(){
    ll N;
    cin>>N;
    cout<<(N/2)*(N-N/2)<<endl;
}
//for compilation: g++ -o _ _.cpp -std=c++14 (or 17)
//
//for fastening: g++ -O2 -o _ _.cpp -std=c++14 (or 17)
//for fastening: g++ -O3 -mtune=native -march=native -o _ _.cpp -std=c++14 (or 17)


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

int main(){


    int n; cin >> n;
    vector<long long> a(n);
    vector<long long> b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    long long ans = 0;
    for(int i = n - 1; i >= 0; i--){
        if((ans + a[i]) % b[i] == 0) continue;
        ans += b[i] - (ans + a[i]) % b[i];
    }

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

Measured memory_bytes: 1792