akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    val (N, M) = readInputLine().split(" ").map { it.toInt() }

    val edges = Array(N) { mutableListOf<Int>() }
    val revEdges = Array(N) { mutableListOf<Int>()}

    repeat(N + M - 1) {
        val (A, B) = readInputLine().split(" ").map { it.toInt() - 1 }
        edges[A].add(B)
        revEdges[B].add(A)
    }

    val topologicalSorted = IntArray(N) { -1 }
    var current = N - 1

    fun topologicalSort(node: Int) {
        for (c in edges[node]) {
            if (topologicalSorted[c] != -1) {
                continue
            }
            topologicalSort(c)
        }
        topologicalSorted[node] = current
        current--
    }

    repeat(N) {
        if (topologicalSorted[it] == -1) {
            topologicalSort(it)
        }
    }

    repeat(N) {
        if (topologicalSorted[it] == 0) {
            println(0)
        } else {
            var minNode = -1
            var minOrder = -1
            for (r in revEdges[it]) {
                if (topologicalSorted[r] > minOrder) {
                    minOrder = topologicalSorted[r]
                    minNode = r
                }
            }
            println(minNode + 1)
        }
    }
}

fun readInputLine(): String {
    return readLine()!!
}


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

int H, W, K;
int pSum[11][1001];
int choco[10][1000];

vector<int> rowcut; //가로선 위 인덱스를 저장한다.
ll ans = 1e9;
void dfs(int n) {
	if (n == H - 1) {
		rowcut.push_back(H - 1);
		vector<int> colcnt(rowcut.size(), 0);

//		cout << "ROWCUT:";
//		for (int i : rowcut) cout << i << ' ';
//		cout << '\n';

		ll cnt = 0;
		for (int i = 0; i < W; i++) {
			for (int j = 0; j < rowcut.size(); j++) {
				if (j) {
					for (int k = rowcut[j - 1] + 1; k <= rowcut[j]; k++) {
						if (choco[k][i] == 1) colcnt[j]++;
					}
				}
				else {
					for (int k = 0; k <= rowcut[0]; k++) {
						if (choco[k][i] == 1) colcnt[j]++;
					}
				}
			}
			bool cut = 0;

//			for (int a : colcnt) cout << a << ' ';
//			cout << '\n';

			//K를 초과하는 블록이 등장
			for (int j = 0; j < colcnt.size(); j++) 
				if (colcnt[j] > K) {
					cut = 1;
					break;
				}

			
			if (cut) {
				//현재 열 이전을 잘라냄.
				cnt++;
				for (int j = 0; j < colcnt.size(); j++) colcnt[j] = 0;
				for (int j = 0; j < rowcut.size(); j++) {
					if (j) {
						for (int k = rowcut[j - 1] + 1; k <= rowcut[j]; k++) {
							if (choco[k][i] == 1) colcnt[j]++;
						}
					}
					else {
						for (int k = 0; k <= rowcut[0]; k++) {
							if (choco[k][i] == 1) colcnt[j]++;
						}
					}
				}

				//열을 하나만 남겨도 K를 넘으면 불가능한 경우
				cut = 0;
				for (int j = 0; j < colcnt.size(); j++)
					if (colcnt[j] > K) {
						cut = 1;
						break;
					}

				if (cut) {
					cnt = 1e9;
					break;
				}
			}
		}
		ans = min(ans, cnt + (int)rowcut.size() - 1);
//		cout << ans << '\n';

		rowcut.pop_back();
		return;
	}
	rowcut.push_back(n);
	dfs(n + 1);
	rowcut.pop_back();
	dfs(n + 1);
}

int main() {
	//	ios::sync_with_stdio(false);
	//	cin.tie(0); cout.tie(0);
	cin >> H >> W >> K;
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++) 
			scanf("%1d", &choco[i][j]);
		
	dfs(0);

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

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

#define repp(i,a,b) for(int i=a;i<b;i++)
#define repm(i,a,b) for(int i=a;a>0;i--)
#define debug_interval endl
#define dump_interval endl
#define debug_toggle 1

typedef long long ll;

inline ll toInt(string s){ll v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
inline ll gcd(ll a,ll b){return a?gcd(b%a,a):b;}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}

ll A,B,C,K;

int main(){
  ios::sync_with_stdio(false);
  cin>>A>>B>>C>>K;
  if(A==B)dump(0);
  else if(abs(A-B)>1e18)dump("Unfair");
  else if(K%2==0)dump(A-B);
  else dump(B-A);
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		long n = long.Parse(Console.ReadLine());
		long[] t = new long[5];
		for(var i = 0; i < 5; i++)
		{
			t[i] = long.Parse(Console.ReadLine());
		}
		Array.Sort(t);
		long ans = 4 + (n + t[0] - 1) / t[0];
		Console.WriteLine(ans);
	}
	
}

Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main(void) {
	int i, j;
	int n;

	while (cin >> n, n) {
		int m[100], k;
		set<int> s1[100], s2;

		for (i = 0; i < n; i++) {
			cin >> m[i];
			for (j = 0; j < m[i]; j++) {
				int p;
				cin >> p;
				s1[i].insert(p);
			}
		}
		cin >> k;
		for (i = 0; i < k; i++) {
			int k;
			cin >> k;
			s2.insert(k);
		}

		vector<int> ans;
		for (i = 0; i < n; i++) {
			vector<int> v(100);
			const int cnt = set_intersection(s1[i].begin(), s1[i].end(), s2.begin(), s2.end(), v.begin()) - v.begin();
			if (cnt == k)
				ans.push_back(i + 1);
		}
		if (ans.size() == 1)
			cout << ans[0] << endl;
		else
			cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1648
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		a: [usize; n],
	}

	let mut v = vec![0usize; n+1];
	let mut ans = 0;
	v[0] = a[0];
	for i in 1..n {
		v[i] = (v[i-1] + a[i]) % 1000000007;
	}

	for i in 0..n {
		ans += (1000000007 + v[n-1] - v[i]) * a[i];
		ans %= 1000000007;
	}

	println!("{}", ans);
}



Measured memory_bytes: 7104
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/ 

#include<bits/stdc++.h>
#define range 4096
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long 

using namespace std;

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

int dp[5000];

int n,m;

int temp[13];

ii mog[2000];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	cin>>n>>m;
	for(int i=0;i<m;i++){
		for(int j=0;j<=12;j++)
			temp[j] = 0;
		int a,b;
		cin>>a>>b;
		for(int j=0;j<b;j++){
			int c;
			cin>>c;
			c-=1;
			temp[c] = 1;
		}
		int res = 0;
		for(int i=0;i<12;i++)
			res+=(temp[i]*pow(2,i));
		mog[i] = {res,a};
	}
	for(int i=0;i<range;i++) dp[i] = INT_MAX;
	dp[0] = 0;
    int uupar = pow(2,n);
	for(int i=0;i<m;i++){
		for(int j=0;j<uupar;j++){
			int pappu = (j|mog[i].fi);
			dp[pappu] = min(dp[pappu],dp[j] + mog[i].se);
		}
	}
	if(dp[uupar-1]<INT_MAX){
		cout<<dp[uupar-1];
	}
	else cout<<-1;
	return 0;
}


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

int main(){
  int Time[3][6];
  int ans[3][3];
  
  for(int i = 0 ; i < 3 ; i++){
    for(int j = 0 ; j < 6 ; j++){
      cin >> Time[i][j];
    }
  }
  
  for(int i = 0 ; i < 3 ; i++){
    for(int j = 0 ; j < 3 ; j++){
      ans[i][j] = Time[i][j+3] - Time[i][j];
    }
  }
  
  for(int i = 0 ; i < 3 ; i++){
    if(ans[i][2] < 0){ans[i][2] += 60; ans[i][1]--;}
    if(ans[i][1] < 0){ans[i][1] += 60; ans[i][0]--;}
  }
  
  for(int i = 0 ; i < 3 ; i++){
    for(int j = 0 ; j < 3 ; j++){
      if(j != 2)cout << ans[i][j] << ' ';
      else cout << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, H, W; 
  cin >> N >> H >> W;

  cout << (N-H+1)*(N-W+1) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
const long long INF = 1LL << 60;
using namespace std;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

int main() {
  int k;
  string s;
  cin >> k >> s;
  int l = s.length();
  if (k >= l)rep(i,l){
    cout << s[i];
  }
else {
  rep(i,k){
    cout << s[i];
  }
  cout << "...";
}
return 0;
}

Measured memory_bytes: 3636
program i_hate_matrix_construction
  implicit none
  integer, parameter :: intkind = 16
  integer :: n, i, j, k
  integer, dimension(500) :: s = 0, t = 0, p = 0, q = 0, x = 0, y = 0
  integer(intkind), dimension(500) :: u = 0, v = 0
  integer(intkind), dimension(500, 500) :: a = 0
  read(*,*) n
  read(*,*) s(1:n)
  read(*,*) t(1:n)
  read(*,*) u(1:n)
  read(*,*) v(1:n)
  do k = 0, 64
    do i = 1, n
      p(i) = pattern(s(i), btest(u(i), k))
      q(i) = pattern(t(i), btest(v(i), k))
    end do
    x(1:n) = 0
    y(1:n) = 0
    do i = 1, n
      do j = 1, n
        if (p(i) + q(j) == 1) call halt()
        if (p(i) == 1 .or. q(j) == 1 .or. p(i) + q(j) == 6) then
          a(i, j) = ibset(a(i, j), k)
          x(i) = x(i) + 1
          y(j) = y(j) + 1
        end if
      end do
    end do
    j = 1
    do i = 1, n
      if (p(i) == 2 .and. x(i) == n) call halt()
      if (.not.(p(i) == 3 .and. x(i) == 0)) cycle
      do while (j <= n .and. .not.(q(j) == 2 .and. y(j) < n - 1))
        j = j + 1
      end do
      if (j > n) call halt()
      a(i, j) = ibset(a(i, j), k)
      x(i) = x(i) + 1
      y(j) = y(j) + 1
    end do
    i = 1
    do j = 1, n
      if (q(j) == 2 .and. y(j) == n) call halt()
      if (.not.(q(j) == 3 .and. y(j) == 0)) cycle
      do while (i <= n .and. .not.(p(i) == 2 .and. x(i) < n - 1))
        i = i + 1
      end do
      if (i > n) call halt()
      a(i, j) = ibset(a(i, j), k)
      x(i) = x(i) + 1
      y(j) = y(j) + 1
    end do
  end do
  do i = 1, n
    write(*,'(i0)',advance='no') a(i, 1)
    do j = 2, n
      write(*,'(x,i0)',advance='no') a(i, j)
    end do
    write(*,*)
  end do
contains
  integer function pattern(s, b) result(res)
    integer, intent(in) :: s
    logical, intent(in) :: b
    ! 0: all 0
    ! 1: all 1
    ! 2: any 0
    ! 3: any 1
    res = mod(2 * s + merge(0, 1, b) + 1, 4)
  end
  subroutine halt()
    write(*,'(i0)') -1
    stop
  end
end program i_hate_matrix_construction

Measured memory_bytes: 9636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>

/*
 *変数
 */
int d;

/*
 *解 
 */
void solve(){
    if(d==25)printf("Christmas");
    else if(d==24)printf("Christmas Eve");
    else if(d==23)printf("Christmas Eve Eve");
    else if(d==22)printf("Christmas Eve Eve Eve");
}

/*
 *入力 
 */
int main(){
       std::cin.tie(0);
       std::ios::sync_with_stdio(false);
       std::cin>>d;
       solve();
       return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define ALL(v) v.begin(), v.end()

const int MAX = 1e5+10;
ll N, a, b, d;
vii u;
bool used[MAX];
int cnt[MAX];
map<ii, int> pos;
map<ll, vi> v, h;

vi check(vi& line, ll c, ll d, bool isHol, ll p) {
  vi res;
  int idx = lower_bound(ALL(line), c-d) - line.begin();
  while (idx < line.size()) {
    if (line[idx] > c+d) break;
    int m;
    if (isHol) m = pos[MP(line[idx], p)];
    else m = pos[MP(p, line[idx])];
    res.PB(m);
    line.erase(line.begin()+idx);
  }
  return res;
}

vi check_hol(ll y, ll c) {
  vi& line = h[y];
  return check(line, c, d, true, y);
}

vi check_ver(ll x, ll c) {
  vi& line = v[x];
  return check(line, c, d-1, false, x);
}

ll dfs(int n) {
  used[n] = true;
  ll ans = cnt[n];
  ll x = u[n].first, y = u[n].second;
  FORE (m, check_hol(y+d, x)) if (!used[m]) ans += dfs(m);
  FORE (m, check_hol(y-d, x)) if (!used[m]) ans += dfs(m);
  FORE (m, check_ver(x+d, y)) if (!used[m]) ans += dfs(m);
  FORE (m, check_ver(x-d, y)) if (!used[m]) ans += dfs(m);
  return ans;
}

int main() {
  cin >> N >> a >> b;
  a--; b--;
  REP (i, N) {
    ll x, y, xx, yy;
    cin >> x >> y;
    xx = x+y, yy = x-y;
    u.PB(MP(xx, yy));
    h[yy].PB(xx);
    v[xx].PB(yy);
    pos[MP(xx,yy)] = i;
  }
  d = max(abs(u[a].first-u[b].first), abs(u[a].second-u[b].second));  

  ll key;
  vii value;
  for(map<ll,vi>::iterator it = v.begin(); it != v.end(); ++it) {
    sort(ALL(v[it->first]));
  }
  for(map<ll,vi>::iterator it = h.begin(); it != h.end(); ++it) {
    sort(ALL(h[it->first]));
  }

  REP (i, N) {
    ll x = u[i].first, y = u[i].second;
    cnt[i] = upper_bound(ALL(h[y-d]), x+d) - lower_bound(ALL(h[y-d]), x-d) + upper_bound(ALL(h[y+d]), x+d) - lower_bound(ALL(h[y+d]), x-d)
           + upper_bound(ALL(v[x-d]), y+d-1) - lower_bound(ALL(v[x-d]), y-d+1) + upper_bound(ALL(v[x+d]), y+d-1) - lower_bound(ALL(v[x+d]), y-d+1);
  }

  cout << dfs(a)/2 << endl;
}

Measured memory_bytes: 53104
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n / 100 == 9){
        n -= 800;
    }else if(n / 100 == 1){
        n += 800;
    }

    if(n % 100 / 10 == 9){
        n -= 80;
    }else if(n % 100  / 10 == 1){
        n += 80;
    }

    if(n % 10 == 9){
        n -= 8;
    }else if(n % 10 == 1){
        n += 8;
    }
    cout << n << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch=='A'){
    return 1;
  }
  else if(ch=='C'){
    return 2;
  }
  else if(ch=='G'){
    return 3;
  }
  else if(ch=='T'){
    return 4;
  }
  else return 0;
}

long long getKey(char str[]){
  long long sum=0, p=1, i;
  for(i=0;i<strlen(str);i++){
    sum += p*getChar(str[i]);
    p*=5;
  }
  return sum;
}

int h1(int key){
  return key%M;
}

int h2(int key){
  return 1+(key%(M-1));
}

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key)) % M;
    if (strcmp(H[h],str)==0){
      return 1;
    }
    else if(strlen(H[h])==0){
      return 0;
    }
  }
  return 0;
}
int insert(char str[]){
  long long key,i,h;
  key = getKey(str);

  for(i=0;;i++){
    h=(h1(key)+i*h2(key)) % M;
    if (strcmp(H[h],str)==0){
      return 1;
    }
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++){
    H[i][0] = '\0';
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
    if(com[0]=='i'){
      insert(str);
    }
    else{
      if(find(str)){
        printf("yes\n");
      }
      else{
        printf("no\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 17052
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    A.append(K + A[0])
    Diff = [y - x for x, y in zip(A, A[1:])]
    answer = K - max(Diff)
    return answer


if __name__ == "__main__":
    answer = main()
    print(answer)


Measured memory_bytes: 26100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()


int main() {
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    a--; b--; c--; d--;
    s.push_back('.');
    bool ok = true;
    for(int i=a;i<c;i++){
        ok &= s[i] == '.' || s[i+1] == '.';
    }
    for(int i=b;i<d;i++){
        ok &= s[i] == '.' || s[i+1] == '.';
    }
    if(a < b != c < d){
        bool f = false;
        for(int i=max(a,b)-1; i<min(c,d); i++){
            f |= s.substr(i,3) == "...";
        }
        ok &= f;
    }
    cout << (ok?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string.h>
using namespace std;
#define REP(i,n) for(i=1;i<=n;i++)
short x,y,w[505][505];char map[505][505];int main(){int i,j,k;while(cin>>y>>x,y){REP(i,y)cin>>map[i]+1;memset(w,0,sizeof(w));REP(i,y)REP(j,x)w[i][j]=x-j+1;REP(i,y)REP(j,x)if(map[i][j]=='.')continue;else for(k=j;k>0;k--)if(w[i][k]>j-k)w[i][k]=j-k;int max=0;REP(i,y)REP(j,x){int h=1;if(!w[i][j])continue;for(k=i-1;w[k][j]>=w[i][j];k--)h++;for(k=i+1;w[k][j]>=w[i][j];k++)h++;if(max<w[i][j]*h)max=w[i][j]*h;}cout<<max<<endl;}}

Measured memory_bytes: 1616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 2e18
#define h_p 1110111110111;
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________
int main()
{
       ll x;
       cin>>x;
       ll curr = 100;
       int ye = 0;
       while(1)
       {
              curr += (curr/100);
              ye++;
              if(curr >= x){
                     cout<<ye<<endl;
                     return 0;
              }
       }
}


Measured memory_bytes: 3632
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=998244353;
const int N=1e5+10;
const int inf=1e9;
ll f[3030][3030][3];
int n,s,a[3030];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	scanf("%d%d",&n,&s);
	rep(i,1,n) scanf("%d",&a[i]);
	f[0][0][0]=1;
	rep(i,0,n-1) rep(j,0,s){
		(f[i+1][j][0]+=f[i][j][0])%=mod;
		(f[i+1][j][1]+=f[i][j][0]+f[i][j][1])%=mod;
		(f[i+1][j][2]+=f[i][j][0]+f[i][j][1]+f[i][j][2])%=mod;
		if(j+a[i+1]<=s){
			(f[i+1][j+a[i+1]][1]+=f[i][j][0]+f[i][j][1])%=mod;
			(f[i+1][j+a[i+1]][2]+=f[i][j][0]+f[i][j][1])%=mod;
		}
	}
	cout<<f[n][s][2]<<endl;
	return 0;
}


Measured memory_bytes: 215168
// Problem : A - Multiplication 1
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vdb vector<double>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define bloop(i,a,b) for(int i = a;i>=b;i--)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"
#define CHECK1(a) cout<<a<<endl
#define CHECK2(a,b) cout<<a<<' '<<b<<endl;
#define br '\n'
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
int m_inf = INT_MIN;
// int extendedgcd(int a,int b,int &x,int &y){
	// if(a == 0){
		// x = 0; y = 1;
		// return b;
	// }
	// int x1,y1;
	// int d = extendedgcd(b%a,a,x1,y1);
	// x = y1 - (b/a)*x1;y = x1;
	// return d;
// }
// int expmod(int a,int b) {
// 	if(b == 1) return a;
// 	if(b == 0) return 1;
// 	int m1 = expmod(a,b/2)%mod;
// 	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
// 	return (m1*m1)%mod;
// }
// int power(int a,int b) {
// 	if(b == 1) return a;
// 	if(b == 0) return 1;
// 	int m1 = power(a,b/2);
// 	if(b%2) return m1*m1*a;
// 	return m1*m1;
// }
// int logn(int n, int r) 
// { 
//     return (n > r - 1) ? 1 + logn(n / r, r) : 0; 
// } 

// int nCr(int n,int r)
// {
	// r = min(r,n-r);
	// if(r<0)
		// return 0;
	// if(r == 0)
		// return 1;
	// int ans = 1;
	// for(int i = 1;i<=r;i++)
	// {
		// ans = ans*(n-i+1)/i;
	// }
	// return ans;
// 		
// }
// vi factmod(int n)
// {
	// vi ans(n+1);
	// ans[0] = 1;
	// loop(i,1,n+1)
	// {
		// ans[i] = (ans[i-1]*i)%mod;
	// }
	// return ans;
// }
// int nCrmod(int n,int r,vi &fact)
// {
	// int x1,y1;
	// extendedgcd(fact[r],mod,x1,y1);
	// int x2,y2;
	// extendedgcd(fact[n-r],mod,x2,y2);
	// int ans = (fact[n]*((x1+mod)%mod))%mod;
	// ans = (ans*((x2+mod)%mod))%mod;
	// return ans;
// }
// void dfs(vector<vector<int> > &adj,int root,bool vis[])
// {
// 	vis[root] = true;
// 	for(int i = 0;i<adj[root].size();i++){
// 		int v = adj[root][i];
// 		if(!vis[v])		
// 			dfs(adj,v,vis);
// 	}
// }

int32_t main() 
{
	FastIO; PRECISION;
	int t = 1;
	// cin>>t;
	while(t--)
	{
		int a,b;
		cin>>a>>b;
		cout<<a*b<<'\n';
	}
}

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

int z[8][2];
int main(){
    int N;
    cin>>N;
    rep(i,N){
        cin>>z[i][0]>>z[i][1];
    }
    long double sum=0;
    rep(i,N-1){
        for(int j=i+1;j<N;j++){
            long double x=(long double)z[i][0]-(long double)z[j][0];
            long double y=(long double)z[i][1]-(long double)z[j][1];
            sum+=sqrtl(x*x+y*y);
        }
        
    }
  	sum=sum/(long double)N*2;
    cout<<setprecision(18)<<sum<<endl;
    
    return 0;
}



Measured memory_bytes: 256
/*
				   _ooOoo_
				  o8888888o
				  88" . "88
				  (| -_- |)
				  O\  =  /O
			   ____/`---'\____
			 .'  \\|     |//  `.
		    /  \\|||  :  |||//  \
		   /  _||||| -:- |||||-  \
		   |   | \\\  -  /// |   |
		   | \_|  ''\---/''  |   |
		   \  .-\__  `-`  ___/-. /
		 ___`. .'  /--.--\  `. . __
	  ."" '<  `.___\_<|>_/___.'  >'"".
	 | | :  `- \`.;`\ _ /`;.`/ - ` : | |
	 \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
				   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		fozubaoyou    pass System Test!
		quoted from "https://codeforces.com/contest/472/submission/7996840"
*/
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void){


	int n,x;
	cin>>n>>x;
	if(x==1||x==2*n-1){
		cout<<"No"<<endl;
	} else{
		if(n==2){
			cout<<"Yes"<<endl;
			cout<<1<<endl;
			cout<<2<<endl;
			cout<<3<<endl;
		}
		else if(x==2){
			vector<int> v(2*n-1,-1);
			set<int> use;
			for(int i=1;i<=2*n-1;i++){
				use.insert(i);
			}
			v[n-1]=x;
			v[n]=x-1;
			v[n+1]=x+2;
			v[n-2]=x+1;
			use.erase(x);
			use.erase(x+1);
			use.erase(x-1);
			use.erase(x+2);
			for(int i=0;i<2*n-1;i++){
				if(v[i]==-1){
					v[i]=*use.begin();
					use.erase(*use.begin());
				}
			}
			cout<<"Yes"<<endl;
			for(int i=0;i<2*n-1;i++){
				cout<<v[i]<<endl;
			}
		} else{
			vector<int> v(2*n-1,-1);
			set<int> use;
			for(int i=1;i<=2*n-1;i++){
				use.insert(i);
			}
			v[n-1]=x;
			v[n]=x+1;
			v[n+1]=x-2;
			v[n-2]=x-1;
			use.erase(x);
			use.erase(x+1);
			use.erase(x-1);
			use.erase(x-2);
			for(int i=0;i<2*n-1;i++){
				if(v[i]==-1){
					v[i]=*use.begin();
					use.erase(*use.begin());
				}
			}
			cout<<"Yes"<<endl;
			for(int i=0;i<2*n-1;i++){
				cout<<v[i]<<endl;
			}
		}
	}

}


Measured memory_bytes: 11648
#include <stdio.h>

int main(void){
  double a,b,c,d,e,f;
  double x,y,z;
  int r;
  while( 1 ){
    r=scanf("%lf %lf %lf %lf %lf %lf ",&a,&b,&c,&d,&e,&f);
    if( r==EOF )
      break;

    if( a<0 ){
      a=-a; b=-b; c=-c;
    }
    if( d<0 ){
      d=-d; e=-e; f=-f;
    }

    z = b*d-a*e;
    x = (b*f-c*e)/z;
    y = (c*d-a*f)/z;
    printf("%.3lf %.3lf\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        int sum = 0;
        int temp = num;
        while (temp > 0) {
            sum += temp % 10;
            temp /= 10;
        }

        if (num % sum == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21588
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val pp = readLine()!!.split(" ").map { it.toInt() }.toMutableList()

    var cnt = 0
    var idx = 0

    while (idx <= n-2) {
        if (((pp[idx] == idx+1 && pp[idx+1] == (idx+1)+1)) || (pp[idx] == idx+1)) {
            val tmp = pp[idx]
            pp[idx] = pp[idx+1]
            pp[idx+1] = tmp
            cnt++
            idx+=2
        } else {
            idx++
        }
    }

    if (pp[n-1] == n) cnt++

    println(cnt)
}

Measured memory_bytes: 52032
#include <iostream>
#include <string>
#include <string.h>
#include <set>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <cmath> 
#include <queue> 
#include <stdlib.h>
#include <cstdio>
#include <cstdlib> 
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
using namespace std;  
int main()
{
	int a,b,c,x,cnt;
	cnt=0;
	cin>>a>>b>>c>>x;
	for (int i=0;i<=a;i++)
	{
		for (int j=0;j<=b;j++)
		{
			for (int n=0;n<=c;n++)
			{
				if ((500*i+100*j+50*n)==x) cnt++;
			}
		}
	}
	cout<<cnt;
    return 0;  
}  

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

int main() {
  ll N, M; cin >> N >> M;
  vector<P> v;
  for (ll i = 0; i < N; i++) {
    ll a, b; cin >> a >> b;
    v.push_back(P(a,b));
  }
  sort(v.begin(), v.end());
  ll cost = 0;
  ll rem = M;
  ll i = 0;
  for (ll i = 0; i < N; i++) {
    P p = v[i];
    if (p.second < rem) {
      cost += p.first * p.second;
      rem -= p.second;
    } else if (p.second >= rem && rem > 0) {
      cost += p.first * rem;
      rem = 0;
    } else if (rem == 0) {
      break;
    }
  }
  cout << cost << endl;
}

Measured memory_bytes: 2420
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    ll x=0,y=0,z=0;
    ll ans=1;
    for(ll i=0;i<n;i++){
        ll num=0;
        if(a[i]==x)num++;
        if(a[i]==y)num++;
        if(a[i]==z)num++;
        if(num==1){
            if(a[i]==x)x++;
            if(a[i]==y)y++;
            if(a[i]==z)z++;
        }
        if(num==2){
            if(a[i]==x&&x==y)x++;
            if(a[i]==y&&y==z)y++;
            if(a[i]==z&&z==x)x++;
        }
        if(num==3)x++;
        ans=(ans*num)%N;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
import numpy as np


def main():
    n = int(input())
    A = [int(i) for i in input().split()]

    max_dp = max(A) + 1
    dp = np.zeros(max_dp, dtype="int32")


    for a in A:
        if dp[a] >= 2:
            continue
        dp[np.arange(a, max_dp, a)] += 2
        dp[a] -= 1

    print(np.sum(dp == 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 51504
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<pll> v(n+1,pll(0,0));
	rep(i,n)cin>>v[i+1].fs>>v[i+1].sc;
	sort(all(v));
	rep(i,n){ v[i+1].sc+=v[i].sc; }

	ll ans=0,mn=LINF;
	range(i,1,n+1){
		chmin(mn,v[i-1].sc-v[i].fs);
		chmax(ans,v[i].sc-v[i].fs-mn);
		//puta(i,mn,ans);
	}
	puta(ans);
	return 0;
}


Measured memory_bytes: 10756
# coding: utf-8
# Your code here!
S = input()
ans = 0
for i in range(1 << len(S)): # 階乗(1,2,4,8...)
    string = str(0)
    tmp = 0
    enzan = []
    for j in range(len(S)):
        if ((i >> j) & 1) == 1:
            tmp+=int(S[j])
            enzan.append("+")
        else:
            tmp -= int(S[j])
            enzan.append("-")
    #print(tmp)
    if tmp == 7:
        #print(enzan)
        print(S[0]+enzan[1]+S[1]+enzan[2]+S[2]+enzan[3]+S[3]+"=7")
        exit()


Measured memory_bytes: 3064
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    s = readline().strip()

    ans = s[0] + str(len(s) - 2) + s[-1]
    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 8944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
// const int INFTY = (1 << 21); // 2097152
const ll INFTY = (1LL << 60);

class Edge{
public:
	int from, to; ll cost;
	Edge(int from = 0, int to = 0, ll cost = 0) :
			from(from), to(to), cost(cost){}

	bool operator < (const Edge &e) const{
		return cost < e.cost;
	}
	bool operator >(const Edge &e) const{
		return cost > e.cost;
	}

};

class Node{
public:
	vector<Edge> edges;
    ll dist;

	Node(){
		dist = INFTY;
	}
};

class Graph{
public:
	vector<Node> nodes;
	Graph(int n) {
		rep(i, n) { Node n;  nodes.push_back(n); }
	}
	Node& operator[](int i){
		return nodes[i];
	}
};

class Data{

public:
    ll dist;
	Edge *edge;
	Data(ll dist, Edge *edge) {
		this->dist = dist;
		this->edge = edge;
	}

	bool operator < (const Data &d) const{
		return dist < d.dist;
	}
	bool operator >(const Data &d) const{
		return dist > d.dist;
	}
};

Graph G(0);
int N, E, R;
vector<ll> D;
bool bellman_ford() {

    D = vector<ll>(N, INFTY);
    D[R] = 0; // ????§????????????¢???0

    for (int i = 0; i < N; i++) {
        for (int v = 0; v < N; v++) {
            for (int k = 0; k < G[v].edges.size(); k++) {
                Edge e = G[v].edges[k];
                if (D[v] != INFTY && D[e.to] > D[v] + e.cost) {
                    D[e.to] = D[v] + e.cost;
                    if (i == N - 1) return true; // n??????????????´??°???????????????????????????????????¨
                }
            }
        }
    }
    return false;
}

int main() {
	cin >> N >> E >> R;
	G = Graph(N);

    rep(i, E){
        int from, to;
        ll dist;
        cin >> from >> to >> dist;
        G[from].edges.push_back(Edge(from, to, dist));
    }

    bool is_nc = bellman_ford();
    if(is_nc){
        cout << "NEGATIVE CYCLE" << endl;
    }
    else{
        rep(i, N) {
            if (D[i] == INFTY)
            {
                cout << "INF" << endl;

            }
            else{
                cout << D[i] << endl;

            }
        }
    }
}

Measured memory_bytes: 3184
def gli
  gets.split.map(&:to_i)
end

e, t = gli

i = 0
while 1
  i += 1
  if i * 8 / 100  == e && i / 10 == t
    puts i
    exit
  end
  if i > 10000
    puts -1
    exit
  end
end


Measured memory_bytes: 1788
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	std::ostringstream oss;
	oss<<R"(^[0-9]{)" << a<<R"(}-[0-9]{)"<<b << R"(}$)";
	string exp = oss.str();
	regex r(exp);
	cout << (regex_match(s, r) ? "Yes" : "No") << endl;
	return 0;
}





Measured memory_bytes: 384
n = int(input())

cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

for _ in range(n):
    ch, rank = input().split()
    rank = int(rank)
    cards[pattern.index(ch)][rank-1] = True

for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j+1)


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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int a, p;
  cin >> a >> p;
  int s = a * 3 + p;
  int ans = s / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3560
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#include <bits/stdc++.h>
#define endl "\n"
#define ll   long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define plll pair<long long, pll>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }	
using namespace std;
 
ll t,ans,n,m,x,y,l,r;

void solve(){
  cin>>ans;
  if(ans>=30){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}

int main(){
    SPEED;
   t=1;
    while(t--){
      solve();
    }
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
    int H, W, i, j;
    while(1){
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0){return 0;}
        for(i = 0; i < H; i++){
            for(j = 0; j < W; j++){
                if(!(i % (H - 1) && j % (W - 1))) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

int main(){
    int k;
    cin >> k;
    
    if(k % 10 != 1 && k % 10 != 3 && k % 10 != 7 && k % 10 != 9) {
        cout << -1 << endl;
        return 0;
    }

    int sum = 0, ans = 0, num = 7;
    while(1){
        sum += num;
        ans++;
        if(sum % k == 0) break;
        sum %= k;
        num = (num*10) % k;
    }

    cout << ans << endl;
}

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

using ll = long long;
using Field = vector<vector<ll>>;
using Graph = vector<vector<ll>>;
using VI = vector<int>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VC = vector<char>;
using PI = pair<int, int>;

#define FOR(i, s, n) for (int i = s; i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

long long A;
long double B;

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

    cin >> A >> B;
    cout << (ll)(A * B + 0.001) << endl;

    return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...







int Main(){



ll  n ,x, t;
cin>>n>>x>>t;

ll temp = (n/x)*t + ( n%x >0?t:0);

cout<<temp<<endl;

return 0;

}

















int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		int d = sc.nextInt();
		int x = sc.nextInt();
		sc.nextLine();
		int eatNum = 0;
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(sc.nextLine());
			int k = 1;
			while (k <= d) {
				eatNum++;
				k += a;
			}
		}

		System.out.println(eatNum + x);

		sc.close();
	}
}

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

public class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader vd = new BufferedReader(new InputStreamReader(System.in));

		String[] cd = vd.readLine().split(" ");
		int a = Integer.parseInt(cd[0]);
		int b = Integer.parseInt(cd[1]);
		int x = Integer.parseInt(cd[2]);

		if(x>=a&&x<(a+b)) System.out.println("YES");
		else System.out.println("NO");

	}

}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

map<int,int>mp;

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		if(mp.find(x)==mp.end()) mp[x]=1;
		else mp[x]++;
	}
	int ans=0;
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
		if((*it).S%2) ans++;
	}
	cout<<ans;
	return 0;
}


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

int main()
{
	int n;
	char a[110];
	
	scanf("%d%s", &n, a);
	int s = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == 'I') {
			s++;
			ans = max(ans, s);
		} else {
			s--;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define ll int64_t
using namespace std;

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

int main(){
    ll n,m,mini=10000000000000,number = 0;
    cin>>n>>m;
    vector<pair<ll,ll>> s(n);
    rep(i,n) cin>>s[i].first>>s[i].second;
    vector<pair<ll,ll>> d(m);
    rep(i,m) cin>>d[i].first>>d[i].second;
    vector<int> p;
    
    rep(i,n){
        rep(j,m){
            if((abs(s[i].first-d[j].first)+abs(s[i].second-d[j].second))<mini) {
                mini = (abs(s[i].first-d[j].first)+abs(s[i].second-d[j].second));
                number = j+1;
            }
        }
        cout<<number<<endl;
        number = 0;
        mini = 1000000000000;
    }
    return 0;
}


Measured memory_bytes: 256