akhauriyash/Code-Regression huggingface dataset:
using System;

public class Hello
{
    public static void Main()
    {
        var a = new int[,] { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, { 0, 3, 6 }, { 1, 4, 7 }, { 2, 5, 8 }, { 0, 4, 8 }, { 2, 4, 6 } };
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var s = line.Trim();
            Console.WriteLine(checkWin(s, a));
        }
    }
    public static string checkWin(string s, int[,] a)
    {
        for (int i = 0; i < 8; i++)
        {
            var st = "";
            for (int j = 0; j < 3; j++) st += s[a[i, j]].ToString();
            if (st == "ooo") return "o";
            else if (st == "xxx") return "x";
        }
        return "d";
    }
}

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

int main(){
  int a,b,c,d;
  cin >>a >>b >>c >> d;
  cout << min(a,b) + min(c,d) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <string>

#define YES "YES"
#define NO "NO"
#define space ' '

using namespace std;

void init();
void func();

int main(void)
{
	
	func();

	return 0;
}


#define MAXIMUM 1000000
bool table[MAXIMUM];
int cnt[MAXIMUM];
bool non = true;
bool prime = false;

void init()
{
		table[0] = non;
	table[1] = non;
	for (int i = 2; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			for (int j = i * 2; j < MAXIMUM; j += i)
			{
				table[j] = non;
			}
		}
	}
	for (int i = 1; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			cnt[i] = cnt[i - 1] + 1;
		}
		else
		{
			cnt[i] = cnt[i - 1];
		}
	}

}

void func()
{
	
	int n;

	init();

	while (cin >> n, !cin.eof())
	{
		cout << cnt[n] << endl;
	}

}

Measured memory_bytes: 6044
n, k = gets.split(" ")
h = gets.split(" ").map(&:to_i)

number_of_steps = n.to_i
jump_power = k.to_i

# DP配列を初期化
dp = Array.new(1, 0)

(1...number_of_steps).each do |index|
  # コストの最小値
  costs_of_jump_min = 0xFFFFFFFF
  (1..jump_power).each do |jump|
    # ex. 2ステップ目までのコストを考える時、3段ジャンプは計算しない
    break unless index >= jump

    cost = dp[index - jump] + (h[index] - h[index - jump]).abs
    costs_of_jump_min = cost if costs_of_jump_min > cost
  end

  dp.push(costs_of_jump_min)
end

puts dp[number_of_steps - 1]


Measured memory_bytes: 11524
import java.util.*;
import java.io.*;

public class Main {

	private static void solve(){
		//Implement solution here.
		int n = ni();
		long[] la = nal(n);
		long[] da = new long[60];
		long result = 0;
		for(int i = 0; i < n; i++) {
			char[] ca = Long.toBinaryString(la[i]).toCharArray();
			for(int j = 0; j < ca.length;j++) {
				if(ca[ca.length - 1 - j] == '1')da[j]++;
			}
		}

		for(int i = 0; i < da.length; i++) {
//			final long l = pow(i);
			final long l = (long)Math.pow(2, i) % mod;
			final long i1 = da[i] * (n - da[i]) % mod;
			result += (l * i1) % mod;
            result %= mod;
		}
		System.out.println(result);
	}
	
	private static long pow(final long a) {
        long result = 1;
        for (long i = 0; i < a; i++) {
        	result *= 2;
        	result %= mod;
        } 
        return result;
    }
	static int mod = 1000000007;


	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

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

  int n = min(a, b);

  vector<int> p(n, 0);

  for(int i = 0; i < n; i++){
    int c = i + 1;
    if((a % c == 0) && (b % c == 0)){
      p.at(i) = c;
    }
  }

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

  cout << p.at(n - k) << endl;
}

Measured memory_bytes: 256
n, p = [int(i) for i in input().split()]
tmp = p**(1/n)
if tmp - int(tmp) > 0.999:
    max_x = int(tmp) + 1
else:
    max_x = int(tmp)
ans = 1
for i in range(max_x, 1, -1):
    if p % pow(i,n) == 0:
        ans = i
        break
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

int main (){
    ios_base::sync_with_stdio(false);
    int res;
    string first, second;
    cin >> first >> second;
    sort(first.begin(), first.end());
    sort(second.begin(), second.end(), greater<int>());
    res=first.compare(second);
    cout << (res<0? "Yes" : "No") << endl;
    return 0;
}


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


int main(){
    int a,b,c;
    int k;
    cin >> a >> b >> c;
    cin >> k;
    int cnt=0;
    while(cnt<k){
        if(a>=b){
            b *= 2;
            cnt++;
        }
        else break;
    }
    while(cnt<k){
        if(b>=c){
            c *= 2;
            cnt++;
        }
        else break;
    }
    if (a < b && b < c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
# from log import logger

N, M = map(int, input().split())
key_value = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    key_value[a].append(b)
    key_value[b].append(a)

# logger.info('key_value: {}\n'.format(key_value))

closed_list = [False] * N
closed_list[0] = True
cnt = 0


def dfs(target):
    global cnt
    # logger.info('key_value[target]: {}'.format(key_value[target]))
    if all(closed_list):
        cnt += 1
        return
    for node in key_value[target]:
        # logger.info('node: {}'.format(node))
        # 探索済みでない場合
        if closed_list[node] is False:
            closed_list[node] = True
            dfs(node)
            closed_list[node] = False
        # logger.info('closed_list: {}\n'.format(closed_list))
    return


dfs(0)
print(cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
string S,S1,S2;
map <string,LL> M[30];
int n, flag;
string test(int mask,string pom) {
    string re;
    //de(mask);
    f0(i,pom.size()) {
        if(mask&(1<<i)) re.PB(pom[i]);
    }
    for(int i=pom.size()-1;i>=0;i--) {
        if(!(mask&(1<<i))) re.PB(pom[i]);
    }
    if(flag==0) reverse(ALL(re));
    //cout<<re<<endl;
    return re;
}
int32_t main(void) {
    cin>>n;
    cin>>S;
    f0(i,n) S1.PB(S[i]);
    f0(i,n) S2.PB(S[i+n]);
    reverse(ALL(S2));
    f0(i,(1<<n)) {
        string pom=test(i,S1);
        int ile=__builtin_popcount(i);
        if(M[ile].find(pom)==M[ile].end()) M[ile][pom]=0;
        M[ile][pom]++;
    }
    LL wynik=0;
    //flag=1;
    f0(i,(1<<n)) {
        string pom=test(i,S2);
        int ile=__builtin_popcount(i);
        if(M[ile].find(pom)!=M[ile].end()) wynik+=M[ile][pom];//, cout<<M[ile][pom]<<endl;
    }
    cout<<wynik<<endl;
}


Measured memory_bytes: 33024
#!/usr/bin/env python3

from collections import defaultdict
from heapq import heappush, heappop
import sys
import numpy as np


sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")


def debug(*x):
    print(*x)


def solve(D, CS, S):
    "void()"
    for i in range(D):
        print(S[i].argmax() + 1)


def calcScore(answer, D, CS, S):
    last = [-1] * 26
    score = 0
    for i in range(D):
        j = answer[i] - 1
        score += S[i, j]
        last[j] = i
        score -= sum(CS[j] * (i - last[j]) for j in range(26))
    return score


def main():
    D = int(input())
    CS = list(map(int, input().split()))
    S = np.int16(read().split())
    S = S.reshape((D, 26))

    # print(calcScore(answer, D, CS, S))
    solve(D, CS, S)


T = """
5
86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82
19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424
6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570
6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256
8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452
19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192
"""

OUT = """
1
17
13
14
13
"""


def _test():
    import doctest
    doctest.testmod()
    as_input(T)
    main()


def as_input(s):
    "use in test, use given string as input file"
    import io
    global read, input
    f = io.StringIO(s.strip())
    input = f.readline
    read = f.read


USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
    print("compiling")
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', solve.__doc__.strip().split()[0])(solve)
    cc.compile()
    exit()
else:
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read

    if (USE_NUMBA and sys.argv[-1] != '-p') or sys.argv[-1] == "--numba":
        # -p: pure python mode
        # if not -p, import compiled module
        from my_module import solve  # pylint: disable=all
    elif sys.argv[-1] == "-t":
        _test()
        sys.exit()
    elif sys.argv[-1] != '-p' and len(sys.argv) == 2:
        # input given as file
        input_as_file = open(sys.argv[1])
        input = input_as_file.buffer.readline
        read = input_as_file.buffer.read

    main()


Measured memory_bytes: 27412
#include <stdio.h>
#include <math.h>

int main(void){
    int a;
    scanf("%d", &a);
    int c[1000001];
    int i;
    for(i = 1; ; i++){

        if(c[a] == 1) break;

        c[a] = 1;
        if(a % 2 == 0)  a /= 2;
        else            a = 3 * a + 1;
        //printf("%d\n", a);
    }

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

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        int x = sc.nextInt();
        if (x == 1 || x == 2 * n - 1) {
            out.println("No");
        } else {
            out.println("Yes");
            int [] ret = new int [2 * n - 1];
            Set<Integer> used = new HashSet<>();
            used.add(x); used.add(x + 1); used.add(x - 1);
            ret[n - 1] = x;
            ret[n] = x + 1;
            ret[n - 2] = x - 1;
            if (n >= 3) {
                if (x > 2) {
                    ret[n + 1] = x - 2;
                    used.add(x - 2);
                } else {
                    ret[n - 3] = x + 2;
                    used.add(x + 2);
                }
            }
            int idx = 1;
            for (int i = 0; i < ret.length; i++) {
                if (ret[i] == 0) {
                    while (used.contains(idx)) idx++;
                    ret[i] = idx;
                    idx++;
                }
            }
            for (int i = 0; i < ret.length; i++) out.println(ret[i]);
        }
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 51340
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,D,A; cin>>N>>D>>A; 

    vector<ll> x(N);
    vector<ll> h(N);
    vector<P> da(N);
    rep(i,N) cin>>da[i].first>>da[i].second;
    SORT(da);
    rep(i,N) x[i]=da[i].first,h[i]=da[i].second;
    deque<P> dq; //basho,damage
    ll ans=0;
    ll sodam=0;
    rep(i,N){
        while(!dq.empty() and dq.front().first<x[i]){
            sodam-=dq.front().second;
            dq.pop_front();
        }
        h[i]-=sodam;
        ll kai=(h[i]+A-1)/A;
        if(kai<0) continue;
        ans+=kai;
        sodam+=kai*A;
        dq.emplace_back(x[i]+D*2,kai*A);
    }
    cout<< ans <<"\n";


}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 8192
n,a,b = map(int,input().split())
cnt = 0
for i in range(2):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                for m in range(10):
                    num = 10000*i+1000*j+100*k+10*l+m
                    if num>n:
                        break
                    if a<=i+j+k+l+m<=b:
                        cnt+=num
print(cnt)

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

Measured memory_bytes: 3632
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.readline().split()))
    FOODS = set(range(1, M + 1))

    for n in range(N):
        K, *A = list(map(int, sys.stdin.readline().split()))
        FOODS &= set(A)

    print(len(FOODS))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<stdio.h>
int dp[22][1048576],dp2[22][1048576];
int len0[22][1048576],len1[22][1048576];
int tmp[1048576];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<(1<<i);j++)
		{
			char c=getchar();
			while(c<'0'||c>'1')
			{
				c=getchar();
			}
			dp[i][j]=c-'0';
			len0[i][j]=-1;
			len1[i][j]=-1;
			for(int k=0;k<i;k++)
			{
				if(j&(1<<k))
				{
					len1[i][j]=k;
				}
				else
				{
					len0[i][j]=k;
				}
			}
		}
	}
	int ansl=-1,ans=0;
	for(int len=0;len<=n;len++)
	{
		for(int i=0;i<(1<<len);i++)
		{
			tmp[i]=0;
		}
		for(int i=len;i<=n;i++)
		{
			for(int j=0;j<(1<<i);j++)
			{
				tmp[j>>(i-len)]+=dp[i][j];
				dp2[i][j]=dp[i][j];
				dp[i][j]=0;
			}
		}
		for(int i=0;i<(1<<len);i++)
		{
			if(tmp[i]>=k)
			{
				ansl=len;
				ans=i;
				break;
			}
		}
		if(ansl<len)
		{
			break;
		}
		for(int i=len;i<=n;i++)
		{
			for(int j=0;j<(1<<i);j++)
			{
				int high=(j>>(i-len));
				int low=(j&((1<<(i-len))-1));
				int l0=len0[i-len][low];
				int l1=len1[i-len][low];
				if(l0>=0)
				{
					int high0=(high<<1);
					int low0=(low&((1<<l0)-1));
					dp[len+1+l0][(high0<<l0)+low0]+=dp2[i][j];
				}
				if(l1>=0)
				{
					int high1=(high<<1)+1;
					int low1=(low&((1<<l1)-1));
					dp[len+1+l1][(high1<<l1)+low1]+=dp2[i][j];
				}
			}
		}
	}
	for(int i=ansl-1;i>=0;i--)
	{
		if(ans&(1<<i))
		{
			putchar('1');
		}
		else
		{
			putchar('0');
		}
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 200832
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let p: Vec<usize> = sc.vec(n);
    let mut count = 0;
    for i in 0..n {
        if p[i] != i + 1 {
            count += 1;
        }
    }
    if count <= 2 {
        println!("YES");
    } else {
        println!("NO");
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

namespace AltCoder
{
    public sealed class B_Frog_2
    {
        public static void Main()
        {
            long[] Nk = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt64(x)).ToArray();
            long N = Nk[0], k = Nk[1];
            long[] heights = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt64(x)).ToArray();

            long[] d = new long[N];
            for(int i = 0; i < d.Length; i++)
            {
              d[i] = long.MaxValue;
            }
            
            d[0] = 0;
            d[1] = Math.Abs(heights[1] - heights[0]);
            for (int i = 0; i < N; i++)
            {
                for (int j = 1; j <= k && j < N - i; j++)
                {
                    d[i + j] = Math.Min(d[i + j], d[i] + Math.Abs(heights[i] - heights[i + j]));
                }
            }

            Console.WriteLine(d[N - 1]);
        }
    }
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int main() {
  int64_t N;
  cin >> N;
  int64_t c;
  vector<vector<int64_t>> num(10, vector<int64_t>(10,0));

  FOR(i,1,N+1){
    vector<int64_t> d;
    int64_t nn = i;
    while(nn){
      d.push_back(nn%10);
      nn /= 10;
    }
    int64_t a = d[0];
    int64_t b = d.back();

    if(!a || !b) continue;
    num[a][b]++;

  }
  int64_t res = 0;
  FOR(i,1,10){
    FOR(j,1,10){
      res += num[i][j] * num[j][i];
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>

int n, k;
int A[200000];
int dp[200001];
std::pair<int, int> S[200001];
int dp2[200001];

/*
Al + .. + Ar = QK + (r - l);
(Al -1) + .. + (Ar - 1) = QK;
*/

int main(){
  scanf("%d%d", &n,&k);
  for(int i=0; i<n; i++) scanf("%d",A+i);
  for(int i=1; i<=n; i++) dp[i] = ((long long) dp[i-1] + A[i-1]+ k-1) % k;
  for(int i=0; i<=n; i++) S[i] = std::pair<int, int>(i, dp[i]);
//  std::sort(dp, dp+n+1);
  std::stable_sort(S, S+n+1, [](const std::pair<int, int> &x, const std::pair<int, int> &y){return x.second < y.second; });
  long long int ans = 0;
  for(int i = 0; i<=n; i++){
    int lb = i;
    int ub = n+1;
    while(ub - lb > 1){
      int m = (lb + ub) / 2;
      if(S[m].first - S[i].first < k && S[m].second == S[i].second) lb = m;
      else ub = m;
    }
    ans += lb - i;
  }

  printf("%lld\n", ans);

  return 0;
}


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

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    vector<long long> v(n);
    for(int i = 0;i<n;i++)
    {
        cin>>v[i];
    }
    vector<string> answers;
    int start = 0;
    int end = k;
    while(end < n)
    {
        if(v[end] > v[start])
        {
            answers.push_back("Yes");
        }
        else
        {
            answers.push_back("No");
        }
        start++;
        end++;
        
    }

    for(string s:answers)
    {
        cout<<s<<"\n";
    }

    return 0;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int l=0,r=1e9;
  while(r-l>1){
    int m = (r+l)/2;
    auto f = [&](int m){
      ll c = 0;
      rep(i,n){
      c += (a[i]-1)/m;
      }
      return c<=k;
    };
    if(f(m)) r=m;
    else l=m;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 4024
#include <stdio.h>

int n,A[50];

int solve(int i,int m)
{
  int res;

  if(m == 0) return 1;
  else if(i >= n) return 0;
  else
  {
    res = solve(i + 1,m) || solve(i + 1,m - A[i]);
  }

  return res;
}

int main()
{
  int i,q,m;

  scanf("%d",&n);
  for(i = 0;i < n;i++) scanf("%d",&A[i]);

  scanf("%d",&q);
  for(i = 0;i < q;i++)
  {
    scanf("%d",&m);
    if(solve(0,m)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}



Measured memory_bytes: 2100
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b = map(float, input().split())
    a = int(a)
    b = int(b*1000)
    print(a*b//1000)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 65660
// Problem : A - Payment
// Contest : Virtual Judge - abc173
// URL : https://vjudge.net/contest/381879#problem/A
// Memory Limit : 1048 MB
// Time Limit : 2000 ms

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

#define ll long long

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

	int n;
	while( cin >> n )
	{
		int d = (n/1000) + (n%1000 != 0);
		cout << d*1000 - n << endl;
	}

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
#define int long long int
#define endl "\n"
#define PI 3.14159265
int  MAX_CHARS=10000;
const int mod=1e9+7;
const int INF =LONG_LONG_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}

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

    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int dp[n][n];
  int pre[n];
  pre[0]=a[0];
  for(int i=1;i<n;i++)
    pre[i]=pre[i-1]+a[i];

    for(int len=1;len<=n;len++)
    {
        for(int i=0;i<=n-len;i++)
        {
            int j=len+i-1;
            dp[i][j]=1e18;
            //cout<<i<<" "<<j<<endl;

            if(len==1)
                {dp[i][j]=0;continue;}
            if(len==2)
            { dp[i][j]=a[i]+a[j];continue;}

            int x=pre[j]-(i-1>=0?pre[i-1]:0);
            for(int k=i;k<=j-1;k++)
            {
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+x);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;

    return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
  Scanner scan = new Scanner(System.in);
   
  
  int a = scan.nextInt();
  int b = scan.nextInt();
  int c = scan.nextInt();
  scan.close();
  int p = (a + b);
  int q = (a + c);
  int r = (b + c);
  
  if(p < q && p < r){
    System.out.println(p);
  	}
  else if(q < p && q < r){
  	System.out.println(q); 	
  	}
  else if(r < p && r < q){
  	System.out.println(r);
  	}
  	else if(r == p && r == q){
  	System.out.println(p);
  	}
  }
}


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

int main(){
    int n; cin >> n;
    while(n > 0){
        if(n%10 == 7){
            cout << "Yes\n";
            return 0;
        }
        n /= 10;
    }
    cout << "No\n";
    return 0;
}


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

int main(){
  long long n;
  cin >> n;
  long long a, b;
  a = n;
  string ans = "";
  
  while(n>0){
    a = (n-1)/26;
    b = (n-1)%26;
    char tmp = 'a' + b;
    ans = tmp + ans;
    n = a;
  }
  

  cout << ans;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, N, A;
  cin >> H >> N;
  
  for(int i=0; i<N; i++){
    cin >> A;
    H -= A;
  }
  
  if(H<=0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,a,b,c,x;
  while(cin >>n>>a>>b>>c>>x,n|a|b|c|x){
    int r[10000] = {0},tab[10001][2] = {0};
    tab[0][0] = x;
    for(int i=0; i<n; i++){cin>>r[i];}
    for(int i=0; i<10000; i++){tab[i+1][0] = (tab[i][0]*a+b)%c;}
    for(int i=0,at=-1; i<n; i++){
      int nat = at;
      for(int j=nat+1; j<10001; j++){
	if(tab[j][0] == r[i]){
	  if(at == nat){at = j;}
	  tab[j][1] = i+1;
	}
      }
      if(nat == at){break;}
    }
    int ans = -1;
    for(int i=0; i<10001; i++){if(tab[i][1] == n){ans = i;break;}}
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 980
s1 = raw_input()
s2 = raw_input()

m = len(s1)
n = len(s2)
dp = [[0 for j in xrange(n + 1)] for i in xrange(m + 1)]

for i in xrange(m + 1):
    dp[i][0] = i

for j in xrange(1, n + 1):
    dp[0][j] = j

for i in xrange(1, m + 1):
    for j in xrange(1, n + 1):
        f = 0 if s1[i - 1] == s2[j - 1] else 1
        dp[i][j] = min(
            dp[i - 1][j - 1] + f,
            dp[i - 1][j] + 1,
            dp[i][j - 1] + 1
        )

print dp[m][n]

Measured memory_bytes: 37488
#include <iostream>

using namespace std;

int main()
{
    int a,b,res=0;
    char op;
    cin>>a>>op>>b;
    if(op=='+'){
        res=a+b;
        cout<<res;
    }
    else if(op=='-'){
            res=a-b;
            cout<<res;

    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <numeric>
typedef long long int ll;
using namespace std;

int main(){
	int N,M;
	cin>>N>>M;
	cout<<(N+M)*(N+M-1)/2-N*M<<endl;
	return 0;
}

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

int main(){
  int a,b;
  while(cin >> a >> b){
    int ans=a+b;
    if(ans>=1000000){
      cout << 7 << endl;
    }else if(ans>=100000){
      cout << 6 << endl;
    }else if(ans>=10000){
      cout << 5 << endl;
    }else if(ans>=1000){
      cout << 4 << endl;
    }else if(ans>=100){
      cout << 3 << endl;
    }else if(ans>=10){
      cout << 2 << endl;
    }else if(ans >=0){
      cout << 1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2996
import javax.swing.*;
import java.awt.datatransfer.SystemFlavorMap;
import java.util.*;
import java.io.*;


public class Main {
    public static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

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

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

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

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }


    }
    public class pair {
        int a;
        int b;

        pair(int p, int q) {
            a = p;
            b = q;
        }
        public int hashCode() {
            return new Integer(a).hashCode() * 31 + new Integer(b).hashCode();
        }
    }

    public static int gcd(int a, int b) {
        if (a == 1 || b == 1)
            return 1;
        if (a == 0)
            return b;
        if (b == 0)
            return a;
        return gcd(b % a, a);
    }






    public static void main(String[] args) {
        FastReader s = new FastReader();
        int n=s.nextInt();
        int[] arr=new int[n];
        for(int i=0;i<n;i++)
        {
            arr[i]=s.nextInt();
        }
        Arrays.sort(arr);
        int flag=0;
        for(int i=0;i<n-1;i++)
        {
            if(arr[i]==arr[i+1])
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
            System.out.println("YES");
        else
            System.out.println("NO");

    }


}









Measured memory_bytes: 47884
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9012337203685477580
using ll = long long;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> M;
    N = 55555;
    // エラトステネスの篩
    // N以下の素数
    vector<bool> isprime(N + 1, true);
    vector<int> prime;
    for (int i = 2; i*i <= N; i++)
    {
        if (isprime[i]) {
            for (int j = i + i; j <= N; j += i)
            {
                isprime[j] = false;
            }
        }
    }
    for (int i = 2; i < N; i++)
    {
        if (isprime[i]) {
            prime.push_back(i);
        }
    }
    for (int n : prime) {
        if (M <= 0) {
            break;
        }
        else {
            if (n % 5 == 1) {
                cout << n << " ";
                M--;
            }
        }
    }
    getchar(); getchar();
}

Measured memory_bytes: 384
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc091 {
    export class TaskB implements AtCoder.Paramable, AtCoder.Task {
        constructor(readonly args: string[][]) {
        }

        main(this: TaskB): void {
            const n: number = parseInt(this.args[0][0], 10);
            const m: number = parseInt(this.args[n + 1][0], 10);
            const map = new Map;

            for (let i = 0; i < n; i++) {
                const key: string = this.args[i + 1][0];
                if (!map.has(key)) {
                    map.set(key, 0);
                }
                map.set(key, 1 + map.get(key))
            }

            for (let i = 0; i < m; i++) {
                const key: string = this.args[n + i + 2][0];
                if (!map.has(key)) {
                    map.set(key, 0);
                }
                map.set(key, -1 + map.get(key));
            }

            // const array: number[] = [];
            // map.forEach((value) => {
            //     array.push(value);
            // });
            const ans: number = Math.max(...Array.from(map.values()));
            console.log(ans > 0 ? ans : 0);
        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(x => x.split(' '));
    const task: AtCoder.Task = new TaskB(args);
    task.main();
}

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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  int a, b, c;
  cin >> a >> b >> c;

  cout << max(0, c - (a - b)) << endl;
}

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

  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x;
        int y;
        while ((x = sc.nextInt()) != 0 | (y = sc.nextInt()) != 0) {
            if (x > y) {
                System.out.println(y + " " + x);
            } else {
                System.out.println(x + " " + y);
            }
        }
    }
}


Measured memory_bytes: 36512
n = int(input())
w = list(map(int, input().split()))


LtoR = []

for i in range(len(w)):
    if i==0:
        LtoR.append(w[i])
    else:
        LtoR.append(w[i]+LtoR[-1])
        
RtoL = []
for i in range(len(w)):
    
    if i==0:
        RtoL.append(w[-i-1])
    else:
        RtoL.append(w[-i-1]+RtoL[-1])
RtoL.reverse()

i = 0
val = abs(LtoR[i]-RtoL[i+1])
while i<len(w)-1:
#     print(val)
    next_val = abs(LtoR[i]-RtoL[i+1])
    if next_val > val:
        break
    else:
        val = next_val
        i+=1
        
print(val)

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	string s; cin >> s;
	deque<char> S;
	for (int i=0; i<s.size(); i++) S.push_back(s[i]);

	int ret = 0;
	while (!(S.empty() || S.size()==1)) {
		char f = S.front();
		char b = S.back();
		if (f==b) {
			S.pop_front();
			S.pop_back();
		} else if (f=='x') {
			S.pop_front();
			ret++;
		} else if (b=='x') {
			S.pop_back();
			ret++;
		} else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

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

    cout<<a*b/2;                               
}

Measured memory_bytes: 256
m,d=map(int,input().split())
ans=0
if d<22:
    print(0)
else:
    for j in range(1,m+1):
        for i in range(22,d+1):
            if int(str(i)[0])>=2 and int(str(i)[1])>=2 and int(str(i)[0])*int(str(i)[1])==j:
                ans+=1
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    int n,m;
    vector<int> a,b;
    Problem(LL n,LL m):n(n),m(m),a(n),b(n){};

    void solve(){
        for(int i=0; i<m; ++i){
            int x,y;
            cin >> x >> y;
            x--;y--;
            if(x>y) swap(x,y);
            if(x==0)a[y]=1;
            if(y==n-1)b[x]=1;
        }
        bool ans=false;
        for(int i=1; i<n-1; ++i){
            if(a[i] and b[i])ans=true;
        }
        cout << (ans?"POSSIBLE":"IMPOSSIBLE")<<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0,m;
    cin >> n>> m;
    Problem p(n,m);
    p.solve();
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
  int A,B;
  cin>>A>>B;
  vector<int> a(A),b(B),c(B);
  r(i,A)cin>>a[i];
  r(i,B)cin>>b[i];
  sort(b.begin(),b.end());
  r(i,B)c[i]=b[i];
  r(i,B-1)c[i+1]+=c[i];
  int sum=0;
  r(i,A){
    int x=a[i];
    int p=lower_bound(b.begin(),b.end(),x)-b.begin();
    if(p)sum+=c[p-1];
    p=b.end()-lower_bound(b.begin(),b.end(),x);
    sum+=x*p;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 5224
n = int(input())
a = list(map(int,input().split()))
m=1
sum = 0
def gcd(a, b):
 if a < b:
    a, b = b, a
 if b == 0:
    return a
 c = a % b
 return gcd(b, c)
def lcm(a,b):
    return int(a*b/gcd(a,b))
for i in range(n):
    m = m *a[i]
for i in range(n):
        sum += (m-1) % a[i]

print(sum)

Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define FORN(i, x, y) for (int i = x; i <= y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define scan1(X) scanf("%d", &X)
#define scan2(X, Y) scanf("%d%d", &X, &Y)
#define scan3(X, Y, Z) scanf("%d%d%d", &X, &Y, &Z)
#define scan4(X, Y, Z, W) scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define scanl1(X) scanf("%lld", &X);
#define scanl2(X, Y) scanf("%lld%lld", &X, &Y)
#define scanl3(X, Y, Z) scanf("%lld%lld%lld", &X, &Y, &Z)
#define scanl4(X, Y, Z, W) scanf("%lld%lld%lld%lld", &X, &Y, &Z, &W)
#define print1(X) printf("%d\n", X);
#define print2(X, Y) printf("%d %d\n", X, Y);
#define print3(X, Y, Z) printf("%d %d %d\n", X, Y, Z);
#define print4(X, Y, Z, W) printf("%d %d %d %d\n", X, Y, Z, W);
#define printl1(X) printf("%lld\n", X);
#define printl2(X, Y) printf("%lld %lld\n", X, Y);
#define printl3(X, Y, Z) printf("%lld %lld %lld\n", X, Y, Z);
#define printl4(X, Y, Z, W) printf("%lld %lld %lld %lld\n", X, Y, Z, W);
#define max3(X, Y, Z) max(X, max(Y, Z))
#define max4(X, Y, Z, W) max(max(X, Y), max(Z, W))
#define min3(X, Y, Z) min(X, min(Y, Z))
#define min4(X, Y, Z, W) min(min(X, Y), min(Z, W))
#define popcount(X) __builtin_popcount(X)
#define all(x) x.begin(), x.end()
#define size(X) (int)X.size()
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define lc(x) 2 * x
#define rc(x) 2 * x + 1
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;
const long long l_inf = numeric_limits<long long>::max();
const long long l_ninf = numeric_limits<long long>::min();
const int inf = numeric_limits<int>::max();
const int ninf = numeric_limits<int>::min();
const double pi = 1.00 * acos(-1.00);
const double eps = 1e-8;
void cio(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
int sq( int x ) {return x * x;}
////////////////////////////////////////////////////////////////////Header
int main () {
    int cur = 0;
    ll ans = 0;
    int n;
    scan1(n);
    FORN(i, 1, n) {
        int x;
        scan1(x);
        if ( x <= cur ) {
            ans += cur - x;
        }
        else {
            cur = x;
        }
    }
    printl1(ans);
}

Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int w = scan.nextInt();
		String[][] s = new String[h][w];
		int i = 0;
		int j = 0;
		for(i = 0; i < h; i++) {
			String str = scan.next();
			for(j = 0; j < w; j++) {
				s[i][j] = str.charAt(j) + "";
			}
		}
		for(i = 0; i < h; i++) {
			for(j = 0; j < w; j++) {
				if(s[i][j].equals(".")) {
					int count = 0;
					for(int k = -1; k < 2; k++) {
						for(int l = -1; l < 2; l++) {
							if(i == 0 && k == -1) {
								break;
							} else if(j == 0 && l == -1) {
							} else if(j == w - 1 && l == 1) {
							} else if(i == h - 1 && k == 1) {
							} else {
								if(k == 0 && l == 0) {
								} else if(s[i + k][j + l].equals("#")) {
									count++;
								}
							}
						}
					}
					s[i][j] = count + "";
				}
			}
		}
		for(i = 0; i < h; i++) {
			for(j = 0; j < w; j++) {
				System.out.print(s[i][j]);
				if(j == w - 1) {
					System.out.println();
				}
			}
		}
	}
}

Measured memory_bytes: 23252
N, A, B = map(int,input().split())

ans = 0

for i in range(1, N+1, 1):
  stri = str(i)
  sum = 0
  for j in range(len(str(i))):
    sum += int(stri[j])
  else:
    if sum >= A and sum <= B:
      ans += i
      
print(ans)
    

Measured memory_bytes: 9084
#include <stdio.h>
int main(){
  int sum_result,k[10],i;
  while(1){
    scanf("%d",&sum_result);
    if(sum_result==0){
      break;
    }
  for(i=0;i<9;i++){
    scanf("%d",&k[i]);
  }
  for(i=0;i<9;i++){
    sum_result=sum_result-k[i];
  }
  printf("%d\n",sum_result);
  }
  return 0;
}

Measured memory_bytes: 1028
n = int(input())
r = []
for i in range(n):
    r.append(int(input()))

minv = r[0]
result = -float("inf")
for  i in range(1, n, 1):
    result = max(result, r[i] - minv)
    minv = min(minv, r[i])
print(result)


Measured memory_bytes: 13592
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
#define NUM 10000000
bool is_prime[NUM];
int dp[NUM];
int main(void) {
    for (int i = 0; i < NUM; i++) {
        is_prime[i] = true;
        dp[i] = 0;
    }
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i < NUM; i++) {
        if (is_prime[i]) {
            for (int j = 2; i * j < NUM; j++) {
                is_prime[i*j] = false;
            }
        }
    }
    for (int i = 1; i < NUM; i++) {
        if (is_prime[i]) dp[i] = dp[i-1] + 1;
        else dp[i] = dp[i-1];
    }
    long long n;
    while (cin >> n) {
        cout << dp[n] << endl;
    }
    return 0;
}

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

#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define ll long long int

string s;
ll k, pos;

int main(){	
	cin >> s >> k;
	for(int i = 0; i < s.size(); i++) if(s[i] != '1'){
		pos = i;
		break;
	}
 	if(k <= pos) cout << "1\n";
	else cout << s[pos] << '\n';
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int alice = 0;
    int kirito = 0;
    vector<int>vec(N); 
    for(int i = 0; i < N; i++){
    cin >>vec[i];
    }
    sort(vec.begin(), vec.end()); 
    reverse(vec.begin(), vec.end()); 
    for(int i = 0; i < N; i++){
    if(i%2 == 0){
      alice+=vec[i];
    }
    else{
      kirito+=vec[i];
    }
    }
    cout << alice - kirito <<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void)
{
  char s[110],t[110];
  scanf("%s%s",s,t);

  int len = strlen(s);

  int i,j;
  char stmp;
  for(i=0;i<=len;i++){
    if(strcmp(s,t)==0){
      printf("Yes\n");
      return 0;
    }
    stmp = s[len-1];
    for(j=0;len-j>1;j++)
      s[len-j-1] = s[len-j-2];
    s[0] = stmp;

  }

  printf("No\n");
  return 0;
}

Measured memory_bytes: 1660
package main
 
import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func main() {
  n := 0
  if sc.Scan() {
    n, _ = strconv.Atoi(sc.Text())
  }
  if sc.Scan() {
    max := 0;
    sum := 0;
    idx := -1
    ary := strings.Split(sc.Text(), " ")
    for j, s := range ary {
      if j >= n {
        break
      }
      i, _ := strconv.Atoi(s)
      if max < i {
        max = i
        idx = j
      }
    }
    for j, s := range ary {
      if j >= n {
        break
      }
      if j != idx {
        i, _ := strconv.Atoi(s)
        sum += i
      }
    }
    if sum > max {
      fmt.Printf("Yes")
    } else {
      fmt.Printf("No")
    }
  }
}

Measured memory_bytes: 640
#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 (b < a) { a = b; return true; } return false; }

using Weight = int;
using Flow = int;
struct Edge {
	int s, d; Weight w; Flow c;
	Edge() {};
	Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void add_arc(Graph &g, int s, int d, Weight w = 1) {
	g[s].emplace_back(s, d, w);
}
void add_edge(Graph &g, int a, int b, Weight w = 1) {
	add_arc(g, a, b, w);
	add_arc(g, b, a, w);
}

int dp[1 << 15][15] = {};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int V, E; cin >> V >> E;
	Matrix g(V, Array(V, INF));
	rep(i, 0, E) {
		int s, t, d; cin >> s >> t >> d;
		g[s][t] = d;
	}
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	for (int mask = 0; mask < (1 << V); mask++) {
		rep(i, 0, V) {
			rep(j, 0, V) {
				if (mask >> j & 1)continue;
				if (dp[mask][i] == INF || g[i][j] == INF)continue;
				chmin(dp[mask | (1 << j)][j], dp[mask][i] + g[i][j]);
			}
		}
	}
	cout << (dp[(1 << V) - 1][0] == INF ? -1 : dp[(1 << V) - 1][0]) << endl;
	return 0;
}

Measured memory_bytes: 5140