akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author GYSHGX868
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    TaskB solver = new TaskB();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      long a = in.nextLong();
      long b = in.nextLong();
      long x = in.nextLong();
      long answer = b / x - a / x;
      if (a % x == 0) {
        answer++;
      }
      out.printLine(answer);
    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void close() {
      writer.close();
    }

    public void printLine(long i) {
      writer.println(i);
    }

  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1) {
        throw new InputMismatchException();
      }
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0) {
          return -1;
        }
      }
      return buf[curChar++];
    }

    public long nextLong() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) {
        return filter.isSpaceChar(c);
      }
      return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
      boolean isSpaceChar(int ch);

    }

  }
}



Measured memory_bytes: 21460
#include <iostream>
#include <set>
#include <vector>
#include <sstream>

using namespace std;

set<string> s;
vector<int> cards;
int k;
int n;

bool used[10];
int perm[10];
vector<vector<int> > permList;

void make_perm(int cnt){
	if(cnt != k){
		for(int i = 0; i < n; i++){
			if(!used[i]){
				used[i] = true;
				perm[cnt] = i;
				make_perm(cnt+1);
				used[i] = false;
			}
		}
	}
	else{
		vector<int> tmp;
		for(int i = 0; i < k; i++){
			tmp.push_back(perm[i]);
		}
		permList.push_back(tmp);
	}
}


int main(){

	while(cin >> n >> k && !(n == 0 && k == 0)){
		fill(used,used+10,false);


		for(int i = 0; i < n; i++){
			int c;
			cin >> c;
			cards.push_back(c);
		}
	//	dfs(0,0,0);
		make_perm(0);

		for(int i = 0; i < permList.size(); i++){
			string str;
			for(int j = 0; j < permList[0].size(); j++){
				//cout << permList[i][j] << " " << flush;
				stringstream ss;
				ss << cards[permList[i][j]];
				str += ss.str();
			}
			//cout << str << endl;
			//cout << endl;
			s.insert(str);
		}

		cout << s.size() << endl;

		permList.clear();
		cards.clear();
		s.clear();
	}

	return 0;
}

Measured memory_bytes: 1272
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n, m = LI()
    G = [[] for _ in range(n)]
    for _ in range(m):
        a, b = LI_()
        G[a].append(b)
        G[b].append(a)
    q = deque()
    q.append((0, 0))
    michi = [-1 for _ in range(n)]
    while q:
        v, par = q.popleft()
        michi[v] = par
        for next_v in G[v]:
            if michi[next_v] != -1:
                continue
            michi[next_v] = v
            q.append((next_v, v))
    print('Yes')
    for i in range(1, n):
        print(michi[i] + 1)


main()



Measured memory_bytes: 39580
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

lint fac[510000],finv[510000],inv[510000];
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<510000;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;
  }
}
lint COM(lint n,lint k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
lint facdiv(lint n,lint k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return (fac[n]*finv[k])%MOD;
}

lint powmod(lint a,lint b){
  return b?powmod(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;
}

int main(void){
    COMinit();
    lint N,M,K;
    cin >> N >> M >> K;
    lint ans=0;
    for(int i=1;i<=N-1;i++){
        lint add=(i*COM(N*M-2,K-2))%MOD;
        add=(add*powmod(M,2))%MOD;
        add=(add*(N-i))%MOD;
        ans+=add;
    }
    for(int i=1;i<=M-1;i++){
        lint add=(i*COM(N*M-2,K-2))%MOD;
        add=(add*powmod(N,2))%MOD;
        add=(add*(M-i))%MOD;
        ans+=add;
    }
    cout << ans%MOD << endl;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int m;
    cin >> m;
    ll y=0,ans=-1;
    rep(i,m){
        ll d,c;
        cin >> d >> c;
        ans+=c;
        y+=d*c;
    }
    while(y/10!=0){
        ans+=y/10;
        y-=(y/10)*9;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
	       ^  ^
			--

	Hello there!   __________    ___  __
	                |       |     |   /
	                |       |     |  /
	                |       |     | /
	                |_______|     |/
	                | \           |\
	                |  \          | \
	                |   \         |  \
	              __|    \________|   \__
*/

#include<bits/stdc++.h>
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define f(x, n)             for(int x = 0; x < n; ++ x)
#define fr(x,n)             for(int x=1;x<=n;x++)
#define mp                  make_pair
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define pb                  push_back
#define eb                  emplace_back
#define pii 				pair<int,int>
#define pll 				pair<ll,ll>
#define F 					first
#define S 					second
#define inf 				1e18
#define MOD 				1000000007
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)

int32_t main()
{
	fast;
	int n;cin>>n;
	vector<int> dp(3);
	for(int day=0;day<n;day++){
		vector<int> new_dp(3,0);
		vector<int> c(3);
		for(int i=0;i<3;i++){
			cin>>c[i];
		}
		
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(i!=j){
					new_dp[j]=max(new_dp[j],dp[i]+c[j]);
				}
			}
		}
		dp=new_dp;
	}
	cout<<max({dp[0],dp[1],dp[2]});
}


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

using namespace std;

const int N_MAX = 100;
int main()
{
    int n = 0;
    int h[N_MAX];

    cin >> n;
    for(int i=0;i<n;i++) {
        cin >> h[i];
    }

    int c = 0;
    while(1) {
        int l=0;
        while(l<n && h[l] == 0) l++;
        if(l==n) break;
        int r=l+1;
        while(r<n && h[r] != 0) r++;
        // h[x]>0 in l <= x < r
        for(int i=l; i<r;i++){
            h[i]--;
        }
        c++;
    }
    cout << c << endl;
}

Measured memory_bytes: 256
inns, days = gets.chomp.split(' ').map(&:to_i)
sections = []
(inns - 1).times do
  sections.push(gets.chomp.to_i)
end
sum = 0
sums = [0]
sections.each do |section|
  sum += section
  sums.push(sum)
end
plans = []
days.times do
  plans.push(gets.chomp.to_i)
end
current = 0
distance = 0
plans.each do |plan|
  start = sums[current]
  finish = sums[current + plan]
  distance += (start - finish).abs
  current += plan
end
puts distance % (10 ** 5)

Measured memory_bytes: 9352
#include <iostream>
using namespace std;
int main() {
int a, b, c, d;
cin >> a >> b >> c >> d;
int n = a + b - c - d;
if (n < 0) cout << "Right" << endl;
else if (n == 0) cout << "Balanced" << endl;
else cout << "Left" << endl;
}

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

int
main(int argc, char *argv[])
{
  int i = 0, j = 0;
  char s[100];
  scanf("%s", s);
  char t[100];
 

  while(s[i] != '\0'){
    if(s[i] == '0'){ t[j++] = '0';}
    else if(s[i] == '1'){ t[j++] = '1';}
    else if(j != 0){
      j--;
      t[j] = '\0';
    }
    i++;
    
  }
  printf("%s\n", t);

  return 0;
}


Measured memory_bytes: 128
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintStream so = System.out;
	
	public static void main(String[] args) throws InterruptedException {
		Map<TRIANGLE_KIND, Integer> counter = new HashMap<>();
		int totalCount = 0;
		counter.put(TRIANGLE_KIND.RIGHT, 0);
		counter.put(TRIANGLE_KIND.ACUTE_ANGLED, 0);
		counter.put(TRIANGLE_KIND.OBTUSE_ANGLED, 0);
		
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			
			TRIANGLE_KIND kind = kind(a, b, c);
			if (kind == TRIANGLE_KIND.NOT_TRIANGLE)
				break;
			
			totalCount++;
			counter.put(kind, counter.get(kind) + 1);
		}
		
		so.println(
				totalCount + " " + 
				counter.get(TRIANGLE_KIND.RIGHT) + " " +
				counter.get(TRIANGLE_KIND.ACUTE_ANGLED) + " " + 
				counter.get(TRIANGLE_KIND.OBTUSE_ANGLED));
	}
	static TRIANGLE_KIND kind(int a, int b, int c) {
		int max = Math.max(a, Math.max(b, c));
		int min = Math.min(a, Math.min(b, c));
		int mid = a+b+c - (min+max);
		
		if (max >= min + mid) return TRIANGLE_KIND.NOT_TRIANGLE;
		
		int d = max*max - (min*min + mid*mid);
		return d == 0 ? TRIANGLE_KIND.RIGHT :
			   d > 0  ? TRIANGLE_KIND.OBTUSE_ANGLED :
			            TRIANGLE_KIND.ACUTE_ANGLED;
	}
	

	enum TRIANGLE_KIND {
		NOT_TRIANGLE(0),
		RIGHT(1), // 直角
		ACUTE_ANGLED(2), // 鋭角 
		OBTUSE_ANGLED(3); // 鈍角
		
		int num;
		TRIANGLE_KIND(int i) {
			this.num = i;
		}
	}
}



Measured memory_bytes: 26352
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =223372036854775807;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define M_PI 3.1415926
int main()
{
 LL a,b,c;
 while(cin>>a>>b>>c){
        if(b>c|| (a==1&&b!=c) ){
            cout<<0<<endl;
            con;
        }

    LL minr=b+c;
    LL maxr=b+c;
    for(int i=1;i<a-1;i++){
        minr+=b;
        maxr+=c;
    }
    cout<<maxr-minr+1<<endl;



 }
    return 0;
}


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

    class Program
    {
        static void Main(string[] args)
        {
            int a;
            int b;
            int[] imp = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
            a = imp[0];
            b = imp[1];

            string ans;
            if (a < 9 && b < 9) ans = "Yay!";
            else ans = ":(";

            Console.WriteLine(ans);
        }
    }


Measured memory_bytes: 13268
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto X = RD!long;
	auto Y = RD!long;

	long ans;
	while (X <= Y / 2)
	{
		X *= 2;
		++ans;
	}

	writeln(ans + 1);
	stdout.flush();
}

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

const int MAXN = 1010;
typedef double db;
struct vec {
	db x, y;
	vec() { x = y = 0; }
	vec(db a, db b) { x = a, y = b; }
	db operator ^ (vec b) const { return x * b.y - y * b.x; }
	db operator * (vec b) const { return x * b.x + y * b.y; }
	db norm2() const { return x * x + y * y; }
	db norm() const { return sqrt(x * x + y * y); }
	vec operator - (vec b) const { return vec(x - b.x, y - b.y); }
	vec operator + (vec b) const { return vec(x + b.x, y + b.y); }
	vec operator * (db k) const { return vec(x * k, y * k); }
	bool operator < (const vec & b) const {
		return x == b.x ? y < b.y : x < b.x;
	}
	friend std::istream & operator >> (std::istream & in, vec & x) {
		in >> x.x >> x.y;
		return in;
	}
	friend std::ostream & operator << (std::ostream & out, vec & x) {
		out << x.x << ' ' << x.y;
		return out;
	}
} ps[MAXN];
int n, rs[MAXN], vis[MAXN];
double dis[MAXN];
db calc(int a, int b) {
	return std::max((ps[a] - ps[b]).norm() - rs[a] - rs[b], 0.);
}
void relax(db & x, db v) { x > v ? x = v : 0; }
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	vec x, y; std::cin >> x >> y >> n;
	ps[1] = x, ps[n + 2] = y;
	for (int i = 2; i <= n + 1; ++i) std::cin >> ps[i] >> rs[i];
	n += 2;
	for (int i = 0; i <= n; ++i) dis[i] = 1e100; dis[1] = 0;
	for (int i = 1; i <= n; ++i) {
		int t = 0;
		for (int j = 1; j <= n; ++j) if (!vis[j] && dis[j] < dis[t]) t = j;
		vis[t] = true;
		for (int j = 1; j <= n; ++j) if (!vis[j])
			 relax(dis[j], dis[t] + calc(t, j));
	}
	std::cout << std::fixed << std::setprecision(10);
	std::cout << dis[n] << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a;
    cin >> n;
    lli val = n / 1000;
    if (n % 1000 != 0) {
        val++;
    }
    lli no = val * 1000;
    lli ans = no - n;
    cout << ans << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int N;
    cin >> N;
    vector<P> A;
    REP(i, N){
        int x, y;
        cin >> x >> y;
        A.pb(mp(x, y));
    }
    sort(All(A));
    cout << A[N-1].first+A[N-1].second << "\n";
    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000],vis[1000000];
vector <long long > v[1000000];
void dfs (long long int x)
{
	long long i;
	vis[x]=1;
	for (i=0;i<v[x].size();i++)
	{
		if (vis[v[x][i]]==0)
		{
			dfs(v[x][i]);
		}
	}
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    long long n,m,i,j,k,x,y,z;
    cin>>n>>m;
    z=0;
    for (i=0;i<m;i++)
    {
    	cin>>x>>y;
    	v[x].push_back(y);
    	v[y].push_back(x);
	}
    for (i=1;i<=n;i++)
    {
    	if (vis[i]==0)
    	{
    		z++;
    		dfs(i);
		}
	}
	cout<<z-1<<endl;
}

Measured memory_bytes: 32160
N,H=list(map(int,input().split()))
a=[0]*N
b=[0]*N

for i in range(N):
    ta,tb=list(map(int,input().split()))
    a[i]=ta
    b[i]=tb

amax=max(a)
b.sort(reverse=True)

res=10**10
csum=0
for i in range(N+1):
    cnt=i
    ch=H
    csum+=b[i-1] if i>0 else 0
    ch-=csum

    if ch>0:
        cnt+=-(-ch//amax)

    res=min(res,cnt)

print(res)    


Measured memory_bytes: 51672
import math

x = int(input())

primes = []

if x == 2:
    print(2)
    exit(0)

for n in range(3, 10000000000, 2):
    f = True
    mp = math.ceil(math.sqrt(n))
    for p in primes:
        if p > mp:
            break
        if n % p == 0:
            f = False
            break
    if f:
        primes.append(n)
        if n >= x:
            print(n)
            exit(0)


Measured memory_bytes: 3316
x1,y1,x2,y2 = map(int,input().split())
x12 = x2-x1
y12 = y2 - y1
x3 = x2 - y12
y3 = y2 + x12
x4 = x1 - y12
y4 = y1 + x12
print(str(x3) + ' ' + str(y3)  + ' ' +  str(x4)  + ' ' +str(y4))

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
using namespace std;

#define INF 0x33433433

struct Edge {
    int len;
    int to;
};

int n;
int m;
int state;
int ans;
int dp[1 << 16][15];
int adj[15][15];

void calc(int s) {
    int state = 1 << n;
    int start = 1 << s;

    for (int i=0; i<state; i++) {
        for (int j=0; j<n; j++) {
            dp[i][j] = INF;
        }
    }

    dp[start][s] = 0;
    for (int i=start+1; i<state; i++) {
        for (int j=0; j<n; j++) {
            for (int k=0; k<n; k++) {
                bool s1 = ((i >> j) & 1);
                bool s2 = ((i >> k) & 1);

                if (j == k) continue;
                if (adj[k][j] == -1) continue;
                if (s1 && s2) {
                    dp[i][j] = min(dp[i][j], dp[i & ~(1 << j)][k] + adj[k][j]);
                }
            }
        }
    }

    for (int i=0; i<n; i++) {
        if (adj[i][s] == -1) continue;
        ans = min(ans, dp[state-1][i] + adj[i][s]);
    }
}


int main() {
    scanf("%d%d", &n, &m);

    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            adj[i][j] = -1;
        }
    }
    
    for (int i=0; i<m; i++) {
        int s, t, l;

        scanf("%d%d%d", &s, &t, &l);
        adj[s][t] = l;
    }

    ans = INF;
    for (int i=0; i<n; i++) {
        calc(i);
    }

    if (ans == INF) puts("-1");
    else printf("%d\n", ans);
}

Measured memory_bytes: 2952
N, T = map(int, input().split())
c_list = []
t_list = []
time_list = []
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
        t_list.append(t)
        c_list.append(c)
    else:
        continue
if len(t_list) == 0:
    print("TLE")
else:
    print(min(c_list))


Measured memory_bytes: 2940
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Work[] works = new Work[n];
		for (int i = 0; i < n; i++) {
		    works[i] = new Work(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(works);
		int[] dp = new int[n + 1];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		int max = 0;
		for (Work w : works) {
		    int left = 0;
		    int right = max + 1;
		    while (right - left > 1) {
		        int m = (left + right) / 2;
		        if (dp[m] < w.left) {
		            left = m;
		        } else {
		            right = m;
		        }
		    }
		    dp[left + 1] = Math.min(dp[left + 1], w.right);
		    max = Math.max(max, left + 1);
		}
		System.out.println(max);
	}
	
	static class Work implements Comparable<Work> {
	    int left;
	    int right;
	    
	    public Work(int left, int right) {
	        this.left = left;
	        this.right = right;
	    }
	    
	    public int compareTo(Work another) {
	        return right - another.right;
	    }
	}
 }



Measured memory_bytes: 103996
from collections import Counter

N = int(input())
V = list(map(int, input().split()))

V_odd = [V[i] for i in range(1, N, 2)]
V_even = [V[i] for i in range(0, N, 2)]

C_odd = Counter(V_odd)
C_even = Counter(V_even)

C_odd = sorted(C_odd.items(), key=lambda x:x[1], reverse=True)
C_even = sorted(C_even.items(), key=lambda x:x[1], reverse=True)

if C_odd[0][0] != C_even[0][0]:
    ans = (N//2 - C_odd[0][1] + (N//2 - C_even[0][1]))
else:
    if len(C_odd) > 1:
        second_odd = C_odd[1][1]
    else:
        second_odd = 0
    if len(C_even) > 1:
        second_even = C_even[1][1]
    else:
        second_even = 0
    if second_odd > second_even:
        ans = (N//2 - second_odd) + (N//2 - C_even[0][1])
    else:
        ans = (N//2 - C_odd[0][1]) + (N//2 - second_even)

print(ans)

Measured memory_bytes: 25416
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,K = imn()


if N == 0 or N % K == 0:
    print(0)
else:
    ans = 0
    if N > K:
        ans = N % K
        ans = min(ans, abs(K-ans))
    else:
        ans = min(N, abs(N-K))
    print(ans)

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

void solve(){
	int A, B, C, X;
	int count = 0;
	cin >> A >> B >> C >> X;

	for(int i = 0; i <= A; i++){
		for(int j = 0; j <= B; j++){
			for(int k = 0; k <= C; k++){
				if(i * 500 + j * 100 + k * 50 == X){
					count++;
					//cout << i << "," << j << "," << k << endl;
				}
				else if(i * 500 + j * 100 + k * 50 > X)
					break;
			}
			if(i * 500 + j * 100 > X)
				break;
		}
		if(i * 500 > X)
				break;
	}
	cout << count << endl;
}

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

Measured memory_bytes: 256
loop do
  a,op,b = gets.chomp.split
  
  break if op == "?"
  
  case op
  when "+"
    puts a.to_i + b.to_i
  when "-"
    puts a.to_i - b.to_i
  when "*"
    puts a.to_i * b.to_i
  when "/"
    puts a.to_i / b.to_i
  end
end

Measured memory_bytes: 8628
n = gets.to_i
t = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

h = Array.new(n) {|i| [1, t[i]]}
h[0][0] = t[0]
1.upto(n-1) do |i|
    h[i][0] = t[i] if t[i] > t[i-1]
end

if a[-1].between?(h[-1][0], h[-1][1]) 
    h[-1][0] = h[-1][1] = a[-1]
else
    p 0
    exit
end

(n-2).downto(0) do |i|
    if a[i] > a[i+1]
        if a[i].between?(h[i][0], h[i][1])
            h[i][0] = h[i][1] = a[i]
        else
            p 0
            exit
        end
    else
        h[i][1] = [h[i][1], a[i]].min
    end
end

M = 10 ** 9 + 7
p h.inject(1) {|r,(min,max)| r * (max - min + 1) % M}

Measured memory_bytes: 24680
using System;
using System.Collections.Generic;

namespace atCoder
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] temp = Console.ReadLine().Split(' ');
            List<int> a = new List<int>();

            for (int i = 0; i < n; i++)
            {
                a.Add(int.Parse(temp[i]));
            }

            a.Sort();

            int result = 0;
            int start = 0;

            for (int i = a[0]; i <= a[a.Count - 1] + 1; i++)
            {
                int count = Test(n, a, ref start, i);

                if (result < count)
                {
                    result = count;
                }
            }

            Console.WriteLine(result);
        }

        private static int Test(int n, List<int> a, ref int start, int x)
        {
            int result = 0;

            for (int j = start; j < n; j++)
            {
                if (a[j] == x || a[j] - 1 == x || a[j] + 1 == x)
                {
                    result++;
                }
                else if (a[j] + 1 < x)
                {
                    start = j;
                }
                else if (x + 1 < a[j])
                {
                    break;
                }
            }

            return result;
        }        
    }
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
vector<string> ans;
void dfs(string s, int ub) {
    if (s.length() == N) {
        ans.push_back(s);
        return;
    }
    for (int i = 0; i < ub; i++) {
        dfs(s + (char) (i + 'a'), ub);
    }
    dfs(s + (char) (ub + 'a'), ub + 1);
}
signed main() {
    cin >> N;
    dfs("", 0);
    sort(all(ans));
    rep(i, ans.size()) { cout << ans[i] << endl; }
}


Measured memory_bytes: 7796
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

string s;
vector<pair<char, int>> p;
vector<int> ans;

void runlength() {
    char f = s[0];
    int cnt = 1;
    for (int i = 1; i < s.length(); ++i) {
        if (f == s[i]) {
            ++cnt;
        } else {
            p.push_back(make_pair(f, cnt));
            f = s[i];
            cnt = 1;
        }
    }
    p.push_back(make_pair(f, cnt));
}

void answer()
{
    int idx = 0;
    for (int i = 0; i < p.size(); ++i) {
        if (p[i].first == 'R') {
            idx += p[i].second;
            if (p[i].second % 2) {
                ans[idx-1] += p[i].second / 2 + 1;
                ans[idx] += p[i].second / 2;
            } else {
                ans[idx-1] += p[i].second / 2;
                ans[idx] += p[i].second / 2;
            }
        } else {
            if (p[i].second % 2) {
                ans[idx-1] += p[i].second / 2;
                ans[idx] += p[i].second / 2 + 1;
            } else {
                ans[idx-1] += p[i].second / 2;
                ans[idx] += p[i].second / 2;
            }
            idx += p[i].second;
        }
    }
}

int main()
{
    cin >> s;
    ans.resize(s.length(), 0);
    runlength();
    answer();

    for (int i = 0; i < ans.size(); ++i) {
        if (i == 0) printf("%d", ans[i]);
        else printf(" %d", ans[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 1912
def f(n):
    res = []
    for p in range(2, int(n**0.5)):
        k = 0
        while(n % p == 0):
            n //= p
            k += 1
        if k:
            res.append((p, k))
    if n != 1:
        res.append((n,1))
    return res


n = int(input())
ans = 0
r = f(n)
for p,k in r:
    tmp = 0
    cur = 1
    while(k>=cur):
        tmp += 1
        k -= cur
        cur += 1
    ans += tmp
print(ans)

Measured memory_bytes: 9372
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int inf=1e9;
int n,m,x,y;
struct node{int y,id,nxt;
}g[200010];int h[410],tot=0;
void _link(int x,int y,int id){g[++tot]=node{y,id,h[x]};h[x]=tot;}
int pre[410][410];
bool might_alive[410];
void dfs(int x,int id)
{
    if (!might_alive[id]) return;
    for (int i=h[x];i;i=g[i].nxt)
    if (g[i].id<pre[id][x])
    {
        if(pre[id][g[i].y]) might_alive[id]=0;
        pre[id][g[i].y]=g[i].id;
        dfs(g[i].y,id);
    }
}
int ans=0;
bool _is;
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        _link(x,y,i);_link(y,x,i);
    }
    for (int i=1;i<=n;i++) might_alive[i]=1,pre[i][i]=inf,dfs(i,i);
    
    int c;
    for (int i=1;i<n;i++) if (might_alive[i])
        for (int j=i+1;j<=n;j++) if (might_alive[j])
        {
            for (_is=0,c=1;c<=n;c++) 
            if (pre[i][c]&&pre[j][c]) {_is=1;break;}
            if (!_is) ans++;            
        }

    cout<<ans;
}

Measured memory_bytes: 3200
import bisect
n = int(input())
S = sorted(map(int, input().split()))
q = int(input())
T = map(int, input().split())
T = set(T)
ans = 0
for t in T:
    i = bisect.bisect_left(S, t)
    if 0 <= i < len(S) and S[i] == t:
        ans += 1
print(ans)


Measured memory_bytes: 17172
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define ifYN(x) cout<<(x?"APPROVED":"DENIED")<<"\n"
using namespace std;
//-------------------------------------------

int main(void){
  ll N;cin>>N;
  map<string,ll> mp;
  string s;
  REP(i,N){
    cin>>s;
    mp[s]++;
  }
  ll m=0;
  for(auto c:mp) m=max(m,c.second);
  //ll m=max_element(ALLv(mp))->second;
  //cout<<m<<endl;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
   if(m==itr->second)
    cout<<itr->first/*<<itr->second*/<<"\n";
  }
  return 0;
}


Measured memory_bytes: 25216
class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __str__(self):
        return "BIT: [{}]".format(
            ", ".join(str(self.sum(i + 1) - self.sum(i))
                      for i in range(self.size))
        )

    def bisect(self, i):
        l, r = 0, i
        s = self.sum(r)
        if s == 0:
            return 0
        while r - l > 1:
            m = (r + l) // 2
            if self.sum(m) < s:
                l = m
            else:
                r = m
        return l + 1


N, *A = map(int, open(0).read().split())

memo = {a: i for i, a in enumerate(sorted(set(A)), 1)}
B = [memo[a] for a in A]
M = len(memo) + 10

bit = BIT(M)
for b in B:
    i = bit.bisect(b - 1)
    if i != 0:
        bit.add(i, -1)
    bit.add(b, 1)

print(bit.sum(M))

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

int main(){
    int x;
    cin >> x;
    if(x) cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 3632
def main():
    R, G, B, N = map(int, input().split())
    ans = 0
    cnt = 0
    for r in range(N + 1):
        for g in range(N + 1 - (R * r)):
            if (N - (R * r) - (G * g)) % B == 0 and N - (R * r) - (G * g) >= 0:
                cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


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

struct edge {
  edge () {}
  edge (int to, int cost) : to(to), cost(cost) {}

  int to, cost;
};

vector<long long> Dijkstra(int s, const vector<vector<edge>> &G) {
  const long long linf = 1001001001001001001ll;
  vector<long long> d(G.size(), linf);
  priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;

  d[s] = 0;
  q.push(make_pair(0, s));

  while (!q.empty()) {
    pair<long long, int> p = q.top();
    q.pop();

    int v = p.second;
    if (d[v] < p.first) continue;
    for (auto &e : G[v]) {
      if (d[e.to] > p.first + e.cost) {
        d[e.to] = p.first + e.cost;
        q.push(make_pair(d[e.to], e.to));
      }
    }
  }

  return d;
}

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

  vector<vector<edge>> G(n);
  for (int i = 0; i < m; ++i) {
    int u, v, c;
    cin >> u >> v >> c;

    G[u].push_back(edge(v, c));
    // G[v].push_back(edge(u, c));
  }

  vector<long long> d = Dijkstra(r, G);
  for (int i = 0; i < d.size(); ++i) {
    if (d[i] == 1001001001001001001ll) cout << "INF" << endl;
    else cout << d[i] << endl;
  }
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m), y(m);
  vector<vector<int>> yd(n);
  rep(i, m) {
    cin >> p[i] >> y[i];
    p[i]--;
    yd[p[i]].push_back(y[i]);
  }
  rep(i, n) sort(yd[i].begin(), yd[i].end());
  rep(i, m) {
    vector<int> pp = yd[p[i]];
    int num = lower_bound(pp.begin(), pp.end(), y[i]) - pp.begin();
    printf("%06d%06d\n", p[i] + 1, num + 1);
  }
  return 0;
}


Measured memory_bytes: 9384
#include<bits/stdc++.h>
using namespace std;
int m,n;
int f[100111];
int has[100111];
int main()
{
	f[1]=1;
	scanf("%d%d",&m,&n);
	for(int i=1;i<=m;i++)has[i]=1;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		{
			has[x]--;
			has[y]++;
			if(f[x]==1)
			{
				f[y]=1;
				if(has[x]==0)f[x]=0;
			}
		}
	}
	int ans = 0;
	for(int i=1;i<=m;i++)
	{
		if(f[i])
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
	int cnt, f1, f2, f3, f4, n;
	while(scanf("%d",&n) != EOF){
		cnt = 0;
		for(f1 = 0; f1 <= 9; f1++)
		{
			for(f2 = 0; f2 <= 9; f2++)
			{
				for(f3 = 0; f3 <= 9; f3++)
				{
					for(f4 = 0; f4 <= 9; f4++)
					{
						if(f1 + f2 + f3 + f4 == n)
							cnt++;
					}
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long

static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {

    ll ans = 1;
    ll N;
    cin >> N;
    vector<ll> num(N);
    REP(i, N){
        cin >> num[i];
        if(num[i] == 0){
            cout << 0;
            return 0;
        }
    }
    ll ans_ =1000000000000000000;
    REP(i, N){
        if(num[i]>(ans_/ans)){
            cout << -1 << endl;
            return 0;
        }else{
            ans *= num[i];
        }
    }
    cout << ans << endl;
    return 0;

}

/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll A, B, C; cin >> A >> B >> C;
  ll x = min(B / A, C);
  cout << x << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(), a, max = Integer.MIN_VALUE, min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++)
		{
			a = scan.nextInt();
			max = a > max ? a : max;
			min = a < min ? a : min;
		}
		scan.close();
		System.out.println(max - min);
		
	}
}

Measured memory_bytes: 22604
def digit_sum(x):
    ret = 0
    for c in str(x):
        ret += int(c)
    return ret

def main():
    a,n,m = map(int,input().split())

    ans = 0
    y = 0
    while True:
        x = (y+a)**n
        if x > m:
            break

        if x>0 and digit_sum(x) == y:
            ans += 1

        y += 1

    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 5600
#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 k, a = 7;
    cin >> k;
	int ans = -1;
	for(int i = 0; i < k ; ++i){
		if(a % k == 0){
			ans = i + 1;
			break;
		}
		a = a % k * 10 + 7;
	}
	cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3648
program divisible_substring
  implicit none
  integer :: n, p, i, j, d, k = 0, cnt(0:10000) = 0, hash = 0, pow = 1
  character(200000) :: s
  integer(8) :: x = 0
  read(*,*) n, p
  read(*,*) s
  if (p == 2 .or. p == 5) then
    do i = 1, n
      d = ichar(s(i:i)) - 48
      if (mod(d, p) == 0) then
        x = x + i
      end if
    end do
    write(*,'(i0)') x
    stop
  end if
  cnt(0) = 1
  do i = n, 1, -1
    d = ichar(s(i:i)) - 48
    hash = mod(d * pow + hash, p)
    x = x + cnt(hash)
    cnt(hash) = cnt(hash) + 1
    pow = mod(10 * pow, p)
  end do
  write(*,'(i0)') x
end program divisible_substring

Measured memory_bytes: 3292
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, y;
	cin >> n >> y;
	int i = -1, j = -1, k = -1;
	bool flag = false;
	for (int a = 0; a <= n; a++) {
		for (int b = 0; b <= n - a; b++) {
			int c = y - 10000 * a - 5000 * b;
			if (c / 1000 == n - a - b && c % 1000 == 0) {
				i = a;
				j = b;
				k = c / 1000;
				flag = true;
				break;
			}
		}
		if (flag) break;
	}
	cout << i << " " << j << " " << k << endl;
 	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;

ll n, w;
vector<ll> vvv, www;

void solve() {
  vector<ll> dp(w+1, 0);
  for (ll i=0; i<n; ++i) {
    for (ll j=w; j>=www[i]; --j) {
      // cout << j << ",";
      dp[j] = max(dp[j], dp[j-www[i]] + vvv[i]);
    }
  }
  ll res = 0;
  for (ll i=0; i<=w; ++i) {
    // cout << dp[i] << ",";
    res = max(res, dp[i]);
  }
  cout << res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> w;
  vvv = vector<ll>(n);
  www = vector<ll>(n);
  for (ll i=0; i<n; ++i) {
    cin >> www[i] >> vvv[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 1234567890ll
using namespace std;
typedef long long LL;
typedef pair<LL, int> pii;

int N;
int cnt[202020], K;
pii P[404040];
LL A[202020], B[202020];
LL ans;

int main(){
    scanf("%d", &N);
    LL Rmin=INF, Rmax=-INF, Bmin=INF, Bmax=-INF;
    for (int i=1; i<=N; i++){
        scanf("%lld %lld", &A[i], &B[i]);
        if (A[i] > B[i]) swap(A[i], B[i]);
        Rmin = min(Rmin, A[i]);
        Rmax = max(Rmax, A[i]);
        Bmin = min(Bmin, B[i]);
        Bmax = max(Bmax, B[i]);
        P[i] = pii(A[i], i);
        P[N+i] = pii(B[i], i);
    }
    ans = (Bmax - Bmin) * (Rmax - Rmin);
    sort(P+1, P+2*N+1);
    int t=0;
    for (int i=1; i<=2*N; i++){
        if (cnt[P[i-1].second] == 1) K--;
        cnt[P[i-1].second]--;
        while (t <= 2*N && K < N){
            t++;
            if (!cnt[P[t].second]) K++;
            cnt[P[t].second]++;
        }
        if (t > 2*N) break;
        ans = min(ans, (Bmax-Rmin) * (P[t].first - P[i].first));
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 10624
#include <stdio.h>
int main()
{
	int S, h, a, m, s;
	scanf("%d", &S);
	h = S / 3600;
	a = S % 3600;
	m = a / 60;
	s = a % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 2728
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
    }
    let ans = (1900 * m + 100 * (n - m)) * 2u32.pow(m as u32) as usize;
    println!("{}", ans);
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort(ALL((c)))
#define debug(x)                 \
    do {                         \
        std::cout << #x << ": "; \
        view(x);                 \
    } while (0)

template <typename T>
void view(T e) {
    std::cout << e << std::endl;
}
template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << ", ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

struct UnionFind {
    vector<ll> size, parents;
    UnionFind() {}
    UnionFind(ll n) {
        size.resize(n, 0);
        parents.resize(n, 0);
        for (ll i = 0; i < n; i++) {
            make(i);
        }
    }
    void make(ll x) {
        parents[x] = x;
        size[x] = 1;
    }
    bool same(ll x, ll y) { return root(x) == root(y); }
    bool union_(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    int root(ll x) {
        if (x != parents[x]) {
            parents[x] = root(parents[x]);
        }
        return parents[x];
    }
    ll size_(ll x) { return size[root(x)]; }
};

int main() {
    ll X, K, D;
    cin >> X >> K >> D;

    if (abs(X) > abs(K * D)) {
        cout << abs(X) - abs(K * D) << endl;
        return 0;
    }
    ll cnt = abs(X) / abs(D);
    if ((K - cnt) % 2 == 1) {
        ll tmp = abs(X) - abs(D) * cnt;
        cout << abs(tmp - D) << endl;
    } else {
        cout << abs(X) - abs(D) * cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3636