akhauriyash/Code-Regression huggingface dataset:
import Data.List

untilFix f x = if f x == x then x else untilFix f (f x)

main = interact $ unlines . map (show . cdp) . unfoldr read' . lines
 where 
  read' (x:xs)
   | x == "0" = Nothing
   | otherwise = let (xs1,xs2) = splitAt (read x) xs in Just (map (map read . words) xs1, xs2)

cdp nss = (sum . concat) nss - (sum . concat . untilFix disappear) nss

disappear = reverse . transpose . map (take 10 . (++ (replicate 10 0)) . filter (/= 0)) . transpose . reverse .
 map (concatMap (\g -> if length g >=3 then map (const 0) g else g) . group)

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

long long n,t[200005],T,r;

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

    cin>>n>>T;
    for(int i=0;i<n;i++)
        cin>>t[i];

    for(int i=1;i<n;i++)
    {
        if(t[i]-t[i-1]>T)
            r+=T;
        else
            r+=t[i]-t[i-1];
    }
    r+=T;

    cout<<r<<endl;

    return 0;
}


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

using namespace std;
using ll = long long int;
#define long ll

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

    ll n;
    cin >> n;
    map<ll, ll> m;
    for(ll i=0; i<n; i++) {
        ll x;
        cin >> x;
        m[x]++;
    }
    
    ll r = 0;
    for(auto &t: m) {
        ll x, c;
        tie(x, c) = t;
        if(x <= c) r += c - x;
        else r += c;
    }
    cout << r << endl;
}


Measured memory_bytes: 6272
program ABC153C
    implicit none
    integer(8)::N,K,i,result
    integer(8),allocatable,dimension(:)::H
    read(5,*)N,K
    allocate(H(N))
    read(5,*)(H(i),i=1,N)
    H=iqsort(H)
    result=sum(H)
    do i=0,min(N,K)-1
        result=result-H(N-i)
    end do

    print'(i0)',result

contains
    recursive function iqsort(ix) result(ires)
      integer(8), allocatable :: ires(:)
      integer(8), intent(in)  :: ix(:)
      integer :: k
      if (size(ix) <= 1) then 
        ires = ix
      else  
        k = ix(size(ix) / 2)
        ires = [iqsort(pack(ix, ix < k)), pack(ix, ix == k), iqsort(pack(ix, ix > k))] 
      end if
    end function iqsort
end program ABC153C

Measured memory_bytes: 9796
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		long start = sc.nextLong();
		long end = sc.nextLong();
		long x = sc.nextLong();
		if(start == 0){
			System.out.println((end / x)  + 1);
		}else{
			System.out.println((end / x)  - ((start -1) / x) );
		}

	}
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define N 105
using namespace std;
int n,u,k,v,e[N][N],cnt;
int ans1[N],ans2[N];
bool used[N];

void dfs(int x){
  if(used[x])return;
  used[x]=true;
  ans1[x]=cnt++;
  for(int i=0;i<n;i++)
    if(e[x][i])dfs(i);
  ans2[x]=cnt++;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++)
      cin>>v,e[u-1][v-1]=1;
  }
  cnt=1;
  for(int i=0;i<n;i++){
    if(!used[i])dfs(i);
  }
  for(int i=0;i<n;i++){
    cout<<i+1<<' '<<ans1[i]<<' '<<ans2[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
import sys

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ls = 0
la = 0
for i in range(n):
    ls += a[i]
    la = i+1
    if(ls > k):
        ls -= a[i]
        la -= 1
        break

samu = ls
ans = la

lb = 0

for j in range(m):
    samu += b[lb]
    lb += 1
    while(True):
        if(samu <= k):
            break
        if(la == 0 and samu > k):
            print(ans)
            sys.exit()
        samu -= a[la-1]
        la -= 1
    if(la+lb > ans):
        ans = la + lb

print(ans)



Measured memory_bytes: 117936
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let t: String = read(&mut stdin_lock, &mut buf, b'\n');
    let sc: Vec<char> = s.chars().collect();
    let mut ans = false;
    for i in 0..sc.len() {
        let mut tc: Vec<char> = Vec::new();
        for j in i..sc.len() {
            tc.push(sc[j]);
        }
        for j in 0..i {
            tc.push(sc[j]);
        }
        let t2: String = tc.into_iter().collect();
        if t2 == t {
            ans = true;
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
    int a,b,r;
    char op;
    while(1)
    {
        scanf("%d %c%d",&a,&op,&b);
        if(op=='?')
            break;
        if(op=='+')
         r=a+b;
        if(op=='-')
         r=a-b;
         if(op=='*')
         r=a*b;
         if(op=='/')
         r=a/b;
        printf("%d\n",r);
    }
    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;

ll powg(ll a, ll b){
    if(b==1) return a;
    else if(b%2==0){
        return powg(a*a,b/2);
    } else {
        return a*powg(a*a,(b-1)/2);
    }
}


int main() {
    ll n;
    cin >> n;
    if(n%2==1){
        cout << 0 << endl;
        return 0;
    }
    ll cnt=1;
    ll ans = 0;

    while (n/(2*powg(5,cnt))>=1)
    {
        ans += n/(2*powg(5,cnt));
        cnt++;
    }
    ans += n/(2*powg(5,cnt));;
    cout << ans << endl;
}

Measured memory_bytes: 3592
import java.util.*;

class Main{
	public static void main(String[] $){
		//入力
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		sc.close();

		//処理

		//出力
		System.out.println(Math.max(a*b, c*d));
	}
}


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

int n, m, a[205][205];
long c[15][15];
long long res;

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

	for (int i = 0; i < 10; ++i)
		for (int j = 0; j < 10; ++j)
			cin >> c[i][j];

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			cin >> a[i][j];

	for (int k = 0; k < 10; ++k)
		for (int i = 0; i < 10; ++i)
			for (int j = 0; j < 10; ++j)
				if (c[i][k] + c[k][j] < c[i][j])
					c[i][j] = c[i][k] + c[k][j];

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			if (a[i][j] != -1)
				res += c[a[i][j]][1];

	cout << res << endl;

	return 0;
}

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

public class Main
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s;
		while((s=br.readLine())!=null && !s.isEmpty())
		{
			int[] l = new int[10];
			int[] v = new int[2];
			for (int i = 0; i < 10; i++) {
				l[i] = Integer.parseInt(s.split(",")[i]);
			}
			for (int i = 10; i < 12; i++) {
				v[i-10] = Integer.parseInt(s.split(",")[i]);
			}
			System.out.println(calc(l,v));
		}
	}
	private static int calc(int[] l, int[] v)
	{
		double sum_l=0.0;
		double intersection;
		for (int i = 0; i < l.length; i++) {
			sum_l+=l[i];
		}
		
		intersection = sum_l/(v[0]+v[1]) * v[0];
		int count=0;
		for(int i=0; intersection>0; i++){
			intersection -= l[i];
			count = i;
		}
		return count+1;
	}
}

Measured memory_bytes: 9728
import java.util.*;

public class Main {
	int[][] ans;
	boolean[] f;
	
	int swap(int z, int x, int y){
		int sum = 0;
		int tx = -1;
		int ty = -1;
		int tz = -1;
		int ten = 1;
		for(int i=7;i>=0;i--){
			tz = z%10;
			if(i==x) tx = tz;
			else if(i==y) ty = tz;
			else sum += tz*ten;
			ten *= 10;
			z /= 10;
		}
		sum += tx*Math.pow(10, 7-y);
		sum += ty*Math.pow(10, 7-x);
		return sum;
	}
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		ans = new int[40320+4000][2];
		f = new boolean[76543211];
		
		ArrayDeque<Integer> que = new ArrayDeque<Integer>();
		que.offer(1234567);
		
		int zero = -1;
		int id, n, a;
		int pos = 0;
		boolean flag = false;
		for(int cnt=0;;cnt++){
			int z = que.size();
			for(int i=0;i<z;i++){
				n = que.poll();
				f[n] = true;
				ans[pos][0] = cnt;
				ans[pos][1] = n;
				pos++;
				
				a = n;
				for(int j=7;j>=0;j--){
					if(a%10==0) zero = j;
					a /= 10;
				}
				
				if(zero!=3 && zero!=7){
					id = swap(n, zero, zero+1);
					if(f[id]==false) que.offer(id);
				}
				if(zero!=0 && zero!=4){
					id = swap(n, zero, zero-1);
					if(f[id]==false) que.offer(id);
				}
				if(zero<4){
					id = swap(n, zero, zero+4);
					if(f[id]==false) que.offer(id);
				}else{
					id = swap(n, zero, zero-4);
					if(f[id]==false) que.offer(id);	
				}
			}
			if(que.size()==0) break;
		}
		
		while(sc.hasNext()){
			int ten = 10000000;
			int num = 0;
			for(int i=0;i<8;i++){
				num += sc.nextInt()*ten;
				ten /= 10;
			}
			for(int i=0;i<pos;i++){
				if(ans[i][1]==num){
					System.out.println(ans[i][0]);
					break;
				}
			}
		}
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}	
}

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

using namespace std;

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  vector<string> v(h);
  for(int i=0;i<h;i++){
    cin>>v[i];
  }
  int count=0;
  for(int r=0;r< 1<<h ;r++){
    for(int c=0;c< 1<<w  ;c++){
      int ans=0;
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          if(((r>>i) & 1)==0 && ((c>>j) & 1)==0 && v[i][j]=='#')
            ans++;
        }
      }
      if(ans==k)
        count++;
    }
  }
	cout<<count;
  return 0;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define PB push_back
#define MP make_pair
#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 SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>())

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
using ll = long long;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


void Main() {
  int Y,M,D;
  char a,b;
  
  cin >>Y>>a>>M>>b>>D;
  if(Y <2019) OUT("Heisei");
  else if(Y ==2019 && M < 5) OUT("Heisei");
  else OUT("TBD");
}

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

  return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
flag = 0

for i in range(N-M+1):
    for j in range(N-M+1):
        tmp = 1
        for l in range(M):
            for k in range(M):
                if A[i+l][j+k] != B[l][k]:
                    tmp = 0
        if tmp == 1:
            flag = 1
            
if flag == 1:
    print("Yes")
else:
    print("No")

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int mod = 1e9+7;
int expo(int b, int p) {
    if (p == 0) return 1;
    if (p == 1) return b;

    int x = expo(b, p/2);
    x = (int) ((ll)x*x % mod);
    if (p&1) x = (int) ((ll)x*b % mod);
    return x;
}

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    int a[n+1], b[n+1], z[n+1]; b[0] = z[0] = 0;
    FOR(i,1,n){
        cin >> a[i];
        b[i] = b[i-1] ^ a[i];
        z[i] = z[i-1] + (b[i] == 0);
    }

    if (b[n] != 0) {
        int dp[n+1];

        int x = 0, y = 1;
        RFOR(i,n,0) {
            if (b[i] == 0) {
                dp[i] = y;
                x = (x + dp[i]) % mod;
            } else if (b[i] == b[n]) {
                dp[i] = x;
                y = (y + dp[i]) % mod;
            }
        }
        cout << dp[0] << '\n';
    } else {
        int dp[n+1];

        map<int, ii> f;
        int ans = expo(2, z[n]-1);
        RFOR(i,n,0) {
            if (b[i] != 0) {
                //dp[i] = sum(dp[j]*diffZeroes for all b[j] == b[i]) + 1;
                dp[i] = 1;
                //FOR(j,i+1,n) if (b[i] == b[j]) {
                //    //dp[i] = (int) (((ll)dp[i] + (ll)dp[j]*(z[j]-z[i]) % mod) % mod);
                //    //dp[i] += (ll)dp[j]*(z[j]-z[i]);
                //    dp[i] += (ll)dp[j]*z[j] - dp[j]*z[i];
                //}
                dp[i] = (dp[i] + f[b[i]].fi) % mod;
                dp[i] = (dp[i] - ((ll)f[b[i]].sc * z[i] % mod) + mod) % mod;

                f[b[i]].fi = (f[b[i]].fi + ((ll)dp[i] * z[i] % mod)) % mod;
                f[b[i]].sc = (f[b[i]].sc + dp[i]) % mod;

                ans = (ans + dp[i]) % mod;
            }
        }

        cout << ans << '\n';
    }
}


Measured memory_bytes: 25984
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=3e3+5;
ll inf=1e15;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;

        ll ans=1;
        ll ar[n+1];
        for(int i=1;i<=n;i++)
        {
            cin>>ar[i];
        }
        ll pre[k+1],cur[k+1];
        for(int i=0;i<=k;i++)
        {
            pre[i]=1;
            cur[i]=0;
        }
        for(int i=1;i<=n;i++)
        {
            // for(int j=0;j<=k;j++)
            // {
            //     cout<<pre[j]<<" ";
            // }
            // cout<<endl;
            // for(int j=0;j<=k;j++)
            // {
            //     cout<<cur[j]<<" ";
            // }
            // cout<<endl;
            for(int j=0;j<=k;j++)
            {
                if(j==0)
                {
                    cur[j]=1;
                    if(i==n and j==k)
                        ans=cur[j];
                }
                else
                {

                    ll low=0;
                    if(j-ar[i]-1>=0)
                        low=pre[j-ar[i]-1]%mod;
                    cur[j]=(pre[j]%mod-low+mod)%mod;
                    if(i==n and j==k)
                        ans=cur[j];
                }
            }
            for(int j=1;j<=k;j++)
            {
                cur[j]=(cur[j]%mod+cur[j-1]%mod)%mod;;
                pre[j]=cur[j];
            }
            for(int j=1;j<=k;j++)
                cur[j]=0;
        }

        cout<<ans<<endl;

        
    }

    return 0;
}

Measured memory_bytes: 5256
let n = Int(readLine()!)!
if n < 105 { print(0) }
else if n == 105 { print(1) }
else {
  var ans = 1
  for i in 106...n {
    if i % 2 == 0 { continue }
    var count = 0
    for j in 1...i {
      if i % j == 0 { count += 1}
    }
    if count == 8 { ans += 1}
  }
  print(ans)
}

Measured memory_bytes: 7688
s=list(map(int,input().split()))
a=0
if s[0]+s[1]>=2*s[2]:
  b=min(s[3],s[4])
  a+=(b*s[2]*2)
  s[3]-=b
  s[4]-=b
  if s[3]==0:
    if s[1]>=2*s[2]:
      a+=2*s[2]*s[4]
    else:
      a+=s[1]*s[4]
  else:
    if s[0]>=2*s[2]:
      a+=2*s[2]*s[3]
    else:
      a+=s[0]*s[3]
else:
  if s[0]>=2*s[2]:
    a+=2*s[2]*s[3]
    a+=s[1]*s[4]
  else:
    if s[1]>=2*s[2]:
      a+=2*s[2]*s[4]
      a+=s[0]*s[3]
    else:
      a+=s[0]*s[3]
      a+=s[1]*s[4]
print(a)

Measured memory_bytes: 3064
#pragma GCC target("avx2")

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
struct SAComp{
	const int h,*g;
	SAComp(const int h, const int* g) : h(h), g(g) {}
	bool operator()(const int a, const int b){
		return a == b ? false : g[a] != g[b] ? g[a] < g[b] : g[a+h] < g[b+h];
	}
};
vector<int> buildSA(const string &t){
	int n=t.size();
	int g[n],b[n];
	vector<int>suff(n);
	for(int i=0;i<n;i++)suff[i]=i,g[i]=t[i];
	b[0]=b[n-1]=0;
	sort(suff.begin(),suff.end(),SAComp(0,g));
	for(int h=1;b[n-1]!=n-1;h<<=1){
		SAComp comp(h,g);
		sort(suff.begin(),suff.end(),comp);
		for(int i=0;i<n-1;i++)b[i+1]=b[i]+comp(suff[i],suff[i+1]);
		for(int i=0;i<n;i++)g[suff[i]]=b[i];
	}
	return suff;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	cin>>s;
	s+='$';
	int n=s.size();
	vector<int>suff=buildSA(s);
	vector<pair<char,int>>sorted(n);
	for(int i=0;i<n;i++)sorted[i]={s[(suff[i]-1+n)%n],i};
	sort(sorted.begin(),sorted.end());

	int T;
	for(cin>>T;T--;){
		string q;
		cin>>q;
		int start=0,stop=n,idx=q.size()-1;
		for(;idx>=0;idx--){
			pair<char,int> ql={q[idx],start},qr={q[idx],stop};
			start=lower_bound(sorted.begin(),sorted.end(),ql)-sorted.begin();
			stop=lower_bound(sorted.begin(),sorted.end(),qr)-sorted.begin();
			if(start==stop)break;
		}
		if(idx<0){
			//{vector<int>v;for(;start<stop;start++)v.push_back(suff[start]);sort(v.begin(),v.end());for(auto &e:v)printf("%d\n",e);}
			puts("1");
		}else{
			puts("0");
		}
	}
}

Measured memory_bytes: 23356
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;


vector<vector<pair<int,ll>>> G;
vector<ll> dist;

void dfs(int x, int pre,ll d){
    dist[x] = d;
    for(auto nxt: G[x]){
        if(nxt.first == pre)continue;
        dfs(nxt.first, x, d+nxt.second);
    }
}
int main() {
    int N;cin>>N;
    G.resize(N);
    dist.resize(N);
    rep(i,N-1){
        int a,b;ll c;
        cin>>a>>b>>c;
        a--;b--;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    int Q,K;cin>>Q>>K;
    K--;
    dfs(K, -1, 0);
    rep(i,Q){
    int x,y;cin>>x>>y;
    x--;y--;
    ll ans = dist[x] + dist[y];
    cout<<ans<<endl;
    }
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define fv            first
#define sv            second
#define ll            long long
#define pb            push_back
#define mp            make_pair
#define pll           pair<ll,ll>
#define pii           pair<int,int>
#define READ(x)       freopen(x,"r",stdin)
#define WRITE(x)      freopen(x,"w",stdout)
#define isWorking()   cout<<"Wroking"<<endl
#define all(x)        (x).begin(),(x).end()
#define allr(x)       (x).rbegin(),(x).rend()
#define PRINT(ok)     cout<<(ok? "YES":"NO")<<endl
#define DoublePrint(x,a) cout<<fixed<<setprecision(x)<<a<<endl
#define Fast_Input    ios_base :: sync_with_stdio(0),cin.tie(0);

const ll mod= 1e9+7,INF=1e8,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

int Cnt[200],Taken[200];

int main() {
    Fast_Input

    //cin >> testCase;
    while(testCase--) {
        int n; cin >> n;
       string str; cin >> str;

       int ans = 0;

       for(int i=0; i<str.size(); i++){
            Cnt[ str[i] ] = 1;

            int cnt = 0;

            for(int j=i+1; j<str.size(); j++){
                if(Cnt[ str[j] ] && !Taken[ str[j] ]){
                    cnt ++;
                    Taken [ str[j] ] = 1;
                }
            }

            ans = max(ans,cnt);
            memset(Taken,0,sizeof Taken);
       }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
template<class Key, class Compare = less<Key>>
using Tree = tree<Key, null_type, Compare, rb_tree_tag, tree_order_statistics_node_update>;




const int unvisited = 0, explored = 1, visited = 2;

int N, M;
vector<int> G[100005];

int parent[100005];
int numparents[100005];
int status[100005];

void dfs(int u) {
  status[u] = explored;
  for (int v : G[u]) {
    if (parent[v] == -1 || status[parent[v]] == explored) {
      parent[v] = u;
    }
    if (status[v] == unvisited) {
      dfs(v);
    }
  }
  status[u] = visited;
}


void Main() {
  cin >> N >> M;
  memset(numparents, 0, sizeof(numparents));
  for (int i = 0; i < N-1+M; ++i) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    ++numparents[b];
  }
  int root;
  for (int u = 1; u <= N; ++u) {
    if (numparents[u] == 0) {
      root = u;
      break;
    }
  }
  memset(status, unvisited, sizeof(status));
  memset(parent, -1, sizeof(parent));
  dfs(root);
  parent[root] = 0;
  for (int u = 1; u <= N; ++u) {
    cout << parent[u] << '\n';
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  #ifdef _DEBUG
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  #endif
  Main();
  return 0;
}


Measured memory_bytes: 12160
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<typename T>
struct SWAG{
	using F=function<T(T, T)>;
	const F f;
	stack<T> stl, str, str2;
	SWAG(const F f): f(f){}
	void push(const T &x){
		if(str.empty()) str.push(x);
		else str.push(f(str.top(), x));
		str2.push(x);
	}
	bool pop(){
		if(stl.empty() && str.empty()) return false;
		if(stl.empty()){
			while(!str2.empty()){
				if(stl.empty()) stl.push(str2.top());
				else stl.push(f(str2.top(), stl.top()));
				str2.pop();
				str.pop();
			}
		}
		stl.pop();
		return true;
	}
	T get(){
		if(stl.empty()) return str.top();
		else if(str.empty()) return stl.top();
		else return f(stl.top(), str.top());
	}
};
int main()
{
	int n, l;
	scanf("%d %d", &n, &l);
	SWAG<int> swag([](int x, int y){ return min(x, y);});
	for(int i=0; i<l; i++){
		int a;
		scanf("%d", &a);
		swag.push(a);
	}
	printf("%d", swag.get());
	for(int i=l; i<n; i++){
		int a;
		scanf("%d", &a);
		swag.pop();
		swag.push(a);
		printf(" %d", swag.get());
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 3636
// #include<bits/stdc++.h>
// using namespace std;
 
// const int N = 1000000000, MAXI = N, D = 14;
 
// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 5, flag = 1;
//     cout << tc << "\n";
//     while (tc--)
//     {
//         int a = rand()%N+1;
//         a *= flag;
      
//         flag *= -1;

//         int b = rand()%MAXI + 1, c;

//         int d = rand()%D + 1;

//         int flag2 = rand()%3, k;

//         if(flag2==0)
//         {
//         	k = rand()%d+1;
//         	c = a + k*b;
//         }
//         else if(flag2==1)
//         {
//         	k = rand()%d + 1;
//         	c = a - k*b;
//         }
//         else
//         	c = rand()%MAXI;

//         cout << a << " " << b << " " << c << " " << d;
//         cout << "\n";
//         cout << "~\n";
//     }
 
//     return 0;
// }
 
 
 
 
 
 
 
 
//---------------------------------------------//
 
 
 
/*
#define int long long 
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */ 
 
 
 
 
 
 
//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005

 
// Driver code to test above functions
int32_t main()
{
   
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
 
    
   	int n;
   	cin >> n;

   	int ans = 0;
   	for(int i=1;i<=n;i++)
   	{
   		if(i%3!=0 and i%5!=0)
   			ans += i;
   	}

   	cout << ans;

    
    return 0;
 
} 

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=45,INF=1<<30;
int dp[MAX][4];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        for(int i=0;i<=N+1;i++){
            for(int j=0;j<4;j++){
                dp[i][j]=INF;
            }
        }
        dp[0][0]=0;
        
        vector<int> p(N+2),t(N+2);
        for(int i=0;i<N;i++){
            cin>>p[i+1]>>t[i+1];
        }
        p[0]=0;
        t[0]=0;
        p[N+1]=0;
        t[N+1]=INF;
        
        for(int i=0;i<=N;i++){
            for(int j=0;j<=2;j++){
                int lim=t[i+1]-t[i];
                int use=abs(p[i+1]-p[i])*(j+1);
                if(use<=lim){
                    dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+abs(p[i+1]-p[i]));
                }
            }
            
            for(int j=0;j<=3;j++){
                int lim=t[i+1]-t[i];
                int use=p[i]*(j+1)+p[i+1];
                if(use<=lim){
                    dp[i+1][1]=min(dp[i+1][1],dp[i][j]+p[i]+p[i+1]);
                }
            }
        }
        
        if(dp[N+1][1]==INF){
            int ans=INF;
            for(int i=0;i<=N+1;i++){
                bool ok=false;
                for(int j=0;j<4;j++){
                    if(dp[i][j]!=INF) ok=true;
                }
                if(!ok){
                    ans=i;
                    break;
                }
            }
            cout<<"NG "<<ans<<endl;
        }
        else{
            cout<<"OK "<<dp[N+1][1]<<endl;
        }
    }
}




Measured memory_bytes: 3140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	
		Scanner in = new Scanner(System.in);
		int input = in.nextInt();
		int S[] = new int[input];
		
		for (int i = 0; i < input; i++)
			S[i] = in.nextInt();
			int nextInput = in.nextInt();
		
		int T[] = new int[nextInput];
		for (int i = 0; i < nextInput; i++)
			T[i] = in.nextInt();
		
		int C = 0;
		for (int i = 0; i < nextInput; i++) {	
			if (binarySearch(S, T[i]))	
				C++;		
		}
		
		System.out.println(C);
		
		}
		
		public static boolean binarySearch(int arr[], int param) {
		
			int left = 0; 
			int right = arr.length - 1;
			while (left <= right) {	
					int middle = (left + right) / 2;
					if (arr[middle] == param)
						return true;
					if (arr[middle] < param)
						left = middle + 1;
					else
						right = middle - 1;
		}
				return false;
	
	}
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;
template <typename T>
struct BIT {
  vector<T> bit;
  int size;
  BIT(int _size) : bit(vector<T>(_size + 1, 0)), size(_size) {}
  void add(int index, T value) {
    for (int i = index + 1; i <= size; i += (i & -i)) bit[i] += value;
  }
  T sum(int a, int b) {  //sum of[a,b)
    return sum(b) - sum(a);
  }
  T sum(int a) {  // sum of[0,a) = sum of bit[0]~bit[a]
    T ret = 0;
    for (int i = a; i > 0; i -= (i & -i)) ret += bit[i];
    return ret;
  }
};
class Solver {
 public:
  LL n, x;
  vector<LL> b, l, u;
  BIT<LL> bit;
  Solver(LL n, LL x) : n(n), x(x), b(n), l(n), u(n), bit(n + 2){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> b[i] >> l[i] >> u[i];
    }
    vector<int> idx(n);
    for (int i = 0; i < n; ++i) {
      idx[i] = i;
    }
    sort(idx.begin(), idx.end(), [&](int p, int q) {
      return l[p] * b[p] + u[p] * (x - b[p]) > l[q] * b[q] + u[q] * (x - b[q]);
    });
    LL aoki = 0;
    for (int i = 0; i < n; ++i) {
      aoki += l[i] * b[i];
    }
    for (int i = 0; i < n; ++i) {
      int id = idx[i];
      bit.add(i, calc(id));
    }
    LL ans = LINF;
    for (int i = 0; i < n; ++i) {
      int id = idx[i];
      bit.add(i, -calc(id));
      DBG(i, id, calc(id))
      int lb = bins(aoki - calc(id));
      DBG(lb)
      //int ub = bins(aoki);
      LL tmp = x * (lb + 1) - x * (i <= lb);
      DBG(tmp)
      if (inv(id, aoki - bit.sum(lb + 1)) >= 0) tmp += inv(id, aoki - bit.sum(lb + 1));

      ans = min(ans, tmp);
      DBG(tmp, lb)
      bit.add(i, calc(id));
    }
    cout << ans << endl;
  }
  LL calc(int p) {
    return l[p] * b[p] + u[p] * (x - b[p]);
  }
  int bins(LL x) {
    int lb = -1, ub = n - 1;
    while (ub - lb > 1) {
      int mid = (lb + ub) / 2;
      if (bit.sum(mid + 1) >= x) {
        ub = mid;
      } else {
        lb = mid;
      }
    }
    return ub;
  }
  LL inv(int i, LL x) {
    if (calc(i) < x) return LINF;
    if (l[i] * b[i] >= x) return (x + l[i] - 1) / l[i];
    x -= l[i] * b[i];
    return (x + u[i] - 1) / u[i] + b[i];
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, x;
  std::cin >> n >> x;

  Problem::Solver sol(n, x);
  sol.solve();
  return 0;
}


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

const long long mod = 1e9 + 7;

long long add_mod (long long a, long long b) {
	return (a + b) % mod;
}

long long mul_mod (long long a, long long b) {
	return (a * b) % mod;
}

long long pow_mod (long long a, long long b) {
	long long res = 1, t = a;
	while (b) {
		if (b & 1)
			res = mul_mod(res, t);
		b >>= 1;
		t = mul_mod(t, t);
	}
	return res;
}

long long div_mod (long long a, long long b) {
	return mul_mod(a, pow_mod(b, mod - 2));
}

map < int, int > factors (int x) {
	map < int, int > res;
	for (int i = 2; i <= sqrt(x); ++i) {
		while (x % i == 0) {
			++res[i];
			x /= i;
		}
	}
	if (x != 1)
		res[x] = 1;
	return res;
}

void cklcm (map < int, int > &a, map < int, int > &b) {
	for (auto &p: b) 
		a[p.first] = max(a[p.first], p.second);
}

signed main () {
	int n;
	cin >> n;
	vector < int > a(n);
	map < int, int > g;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		map < int, int > x = factors(a[i]);
		cklcm(g, x);
	}
	long long t = 1;
	for (auto p: g)
		t = mul_mod(t, pow_mod(p.first, p.second));
	long long ans = 0;
	for (int i = 0; i < n; ++i)
		ans = add_mod(ans, div_mod(t, a[i]));
	cout << ans << '\n';
}


Measured memory_bytes: 768
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int max =0;
    for (int i=1; i<= X; i++) {
      for (int j=2; j<= 10; j++) {
        int sum = (int)Math.pow(i,j);
        if (sum <= X) {
          max = Math.max(sum,max);
        }
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 22740
N = int(input())
A = list(map(int, input().split()))

flg = True

for a in A:
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
            pass
        else:
            flg = False
if flg:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct X {
  int v;
  string str;
};

bool operator<(const X& a, const X& b) {
  if (a.v == 0) {
    if (b.v == 0) {
      return a.str < b.str;
    }
    return false;
  } else if (b.v == 0) {
    return true;
  }
  return a.v < b.v;
}

vector<X> parse(const string& s) {
  vector<X> r;
  int v = 0;
  string str;
  for (char c : s) {
    if ('0' <= c && c <= '9') {
      if (!str.empty()) {
        r.emplace_back(X{v, str});
        str = "";
      }
      v = v * 10 + c - '0';
    } else {
      if (v != 0) {
        r.emplace_back(X{v, str});
        v = 0;
      }
      str.push_back(c);
    }
  }
  r.emplace_back(X{v, str});
  return r;
}

int n;
string in[1024];
vector<X> p[1024];

int main() {
  while (cin >> n) {
    for (int i = 0; i <= n; ++i) {
      cin >> in[i];
      p[i] = parse(in[i]);
      // for (auto x : p[i]) {
      //   cout << x.v << "/" << x.str << " ";
      // }
      // cout << endl;
      if (i != 0) {
        cout << (p[i] < p[0] ? '-' : '+') << endl;
      }
    }
  }
}



Measured memory_bytes: 3508
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n;
    cin >> n;
    int h[n],c[n] = {};
    inrep(n,h);

    rep(i,1,n){
	if( i-2 < 0){
	    c[i] = c[i-1] + abs(h[i] - h[i-1]);
	}else{
	    c[i] = min(c[i-1] + abs(h[i] - h[i-1]) , c[i-2] + abs(h[i] - h[i-2]));
	}
    }
    P(c[n-1]);
    return  0;
}


Measured memory_bytes: 1024
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] week = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
        for(int i = 0;i < week.length;i++){
            if(s.equals(week[i])){
                System.out.println(7-i);
                break;
            }
        }
    }
}

Measured memory_bytes: 23252
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<tuple>
using namespace std;

int n, m;
string s;

typedef pair<int, int> P;
typedef vector<int> VI;
typedef tuple<string, int, int> TU;

bool comp(const TU& a, const TU&b) {
	if (get<0>(a)< get<0>(b))
	{
		return 1;
	}
	else if (get<0>(a) > get<0>(b)) {
		return 0;
	}
	else {
		return get<1>(a) > get<1>(b);
	}
}


int main() {
	cin >> n;
	vector<TU> mem(n);
	int q;
	for (int i = 0; i < n; i++)
	{
		cin >> s >> q;
		mem[i] = make_tuple(s, q, i + 1);
	}
	sort(mem.begin(), mem.end(), comp);

	for (int i = 0; i < n; i++)
	{
		cout << get<2>(mem[i])<<endl;
	}
}

Measured memory_bytes: 256
using System;

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

            int a, b, c;
            a = int.Parse(num[0]);
            b = int.Parse(num[1]);
            c = int.Parse(num[2]);

            if (a < b && b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }




Measured memory_bytes: 8984
#include<bits/stdc++.h>
using namespace std;
#define lli long long int

int main() {
    //c_p_c();
    string c;   cin>>c;
    if(c[2]==c[3]&&c[4]==c[5]){
        cout<<"Yes";
    } else  cout<<"No";
    return 0;
//    lli c;  cin>>c;
//    lli hap=0;
//    hap+=c/500;
//    hap*=1000;
//    c-=500*(c/500);
//    hap+=5*(c/5);
//    cout<<hap;
//    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] array = new int[h+2][w+2];
		for(int i = 0; i < h+2;i++) for(int j = 0; j < w+2;j++) array[i][j] = 0;
		for(int i = 0; i < h; i++){
			String s = sc.next();
			for(int j = 0; j < w; j++){
				array[i+1][j+1] = s.charAt(j) == '#' ? 1 : 0;
			}
		}
		for(int i = 1; i < h+1; i++){
			for(int j = 1; j < w+1; j++){
				if(array[i][j] == 0) continue;
				int sum = 0;
				sum += array[i-1][j];
				sum += array[i+1][j];
				sum += array[i][j-1];
				sum += array[i][j+1];
				if(sum == 0){
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
		return;
	}
}

Measured memory_bytes: 21844
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n;
	cin >> n;
	int ans = 0;
	if (n < 10) { ans = n; }
	else if (n < 100) { ans = 9; }
	else if (n < 1000) { ans = n - 99 + 9; }
	else if (n < 10000) { ans = 999 - 99 + 9; }
	else if (n < 100000) { ans = n - 9999 + (999 - 99 + 9); }
	else { ans = 99999 - 9999 + (999 - 99 + 9); }

	cout << ans << endl;


	return 0;
}

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

using namespace std;
#define BUF (1000)
#define ll long long 

int n;
int A[2][BUF];

int main(void){
	cin >> n;
	for(int i=1;i<=n;i++) cin >> A[0][i];	
	for(int i=1;i<=n;i++) cin >> A[1][i];	

	int ans=0;
	for(int i=1;i<=n;i++){
		int tmp=0;
		for(int j=1;j<=i;j++)tmp+=A[0][j];
		for(int j=i;j<=n;j++)tmp+=A[1][j];
		ans=max(ans,tmp);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    return a * b // gcd(a, b)


def submit():
    a, b = map(int, input().split())
    print(lcm(a, b))


if __name__ == "__main__":
    submit()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long  long
#define INF 1000000000000000000LL
#define pll pair<long long , long long>
const int MAX=5e6+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int main() 
{
   int n;
   cin>>n;
   ll arr[n+1];
   for(int i=1;i<=n;i++)
    cin>>arr[i];
    ll ans = 0;

    for(int i=2;i<=n;i++){
        if(arr[i]<arr[i-1]){
            ans = ans+(arr[i-1]-arr[i]);
            arr[i]=arr[i-1];
        }
    }
    cout<<ans;

}


Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<vector<int>> f(n, vector<int>(n, -1));
    for (int i = 0; i < n; ++i) {
        int m;
        cin >> m;
        for (int j = 0; j < m; ++j) {
            int x, y;
            cin >> x >> y;
            --x;
            f[i][x] = y;
        }
    }
    int ans = 0;
    auto check = [&](int s) {
        for (int i = 0; i < n; ++i)
            if (s >> i & 1)
                for (int j = 0; j < n; ++j)
                    if (f[i][j] != -1 && f[i][j] != (s >> j & 1))
                        return false;
        return true;
    };
    for (int s = 0; s < (1 << n); ++s)
        if (check(s))
            ans = max(ans, __builtin_popcount(s));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

	ll n; cin >> n;

	auto digit = [](int n) {
	  int d = 1;
		while(n / 10 != 0) { n /= 10; d++;}
		return d;
	};

	int sq = sqrt(n);
	for (int i = sq; i >= 0; --i) {
		if (n % i == 0) {cout << digit(n / i) << endl; return 0;}
	}
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

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

    cout << a*b << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}


////////////////////////////////////////////////////////////////////

ll sum(ll m){
ll s=0;
ll t=m;
while(t){
	s+=t%10;
	t/=10;
}
return s;
}


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

ll a,b;
ll ans=0;
cin>>a>>b;
for(ll i=1;i<=n;i++){
	ll y=i;
	if(sum(y)>=a && sum(y)<=b) ans+=y;
}

cout<<ans<<endl;
return 0;



}




Measured memory_bytes: 256