akhauriyash/Code-Regression huggingface dataset:
N = int(input())

x = []

for _ in range(N):
  inp = input().split(' ')
  if inp[1] == 'JPY':
    x.append(int(inp[0]))
  else:
    x.append(float(inp[0]) * 380000.0)


sum = 0

for i in range(N):
  sum += x[i]

print(sum)


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

main()
{
    unsigned long long int a, b, x, result;

    cin >> a >> b >> x;

    if (a%x != 0)
    {
        result = (b/x - a/x);
    }
    else
    {
        result = (b/x - a/x) + 1;
    }


    cout << result;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    long long a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    if(abs(a - b) <= (v - w) * t)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


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

#define int long long

const int MAX_N = 100;

int N, D[MAX_N], A[MAX_N];
const int fac[8] = {1, 1, 2, 6, 24, 120, 720, 5040};

int ToHash(const vector<int> &v)
{
	int res = 0;
	bool isUsed[7] = {};
	for (int i = 0; i < v.size(); i++)
	{
		int cnt = 0;
		for (int j = 0; j != v[i]; j++)
		{
			if (!isUsed[j]) cnt++;
		}
		isUsed[v[i]] = true;
		//printf("%lld! * %lld\n", D - i - 1, cnt);
		res += fac[v.size() - i - 1] * cnt;
	}
	return res;
}

int memo[MAX_N][5040];

int DFS(int n, const vector<int> &v)
{
	if (n == N) return 0;
	int s = ToHash(v);
	if (memo[n][s] > 0) return memo[n][s];
	//i : n??????????°??±????????????\??????
	for (int i = 0; i <= v.size(); i++)
	{
		vector<int> nv;
		nv.reserve(7);
		int pastSum = 0, futureSum = 0;
		//nv,pastSum,futureSum????¨????
		for (int j = 0; j <= v.size(); j++)
		{
			if (j == i) nv.push_back(0);
			if (j == v.size()) continue;
			if (j < i && v[j] + 1 <= D[n - v[j] - 1]) pastSum += A[n - v[j] - 1];
			else if (j >= i && v[j] + 1 <= D[n]) futureSum += A[n];
			if (v[j] + 1 == 7) continue;
			nv.push_back(v[j] + 1);
		}
		//printf("%lld\n", futureSum);
		memo[n][s] = max(memo[n][s], DFS(n + 1, nv) + pastSum + futureSum);
	}
	return memo[n][s];
}

signed main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> D[i];
	}
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	printf("%lld\n", DFS(0, vector<int>()));
	return 0;
}

Measured memory_bytes: 4892
#include <iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#include<cmath>
#include<string>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int main()
{
    int i,n;

    int a,b,c;
    cin>>a>>b>>c;
    int sa=0,sb=0,sc=0;
    sa=fabs(a-b)+fabs(a-c);
    sb=fabs(b-a)+fabs(b-c);
    sc=fabs(c-a)+fabs(c-b);
    int s=min(sa,sb);
    s=min(s,sc);
    cout<<s<<endl;
     return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }

// 入力
int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    // vectorの初期化で既に 0 が代入される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}

Measured memory_bytes: 4992
#include<cstdio>
const int MOD = 998244353;
const int MAXN = 400;
int inv[MAXN + 5];
void init() {
	inv[1] = 1;
	for(int i=2;i<=MAXN;i++)
		inv[i] = MOD - 1LL*inv[MOD%i]*(MOD/i)%MOD;
}
struct modint{
	int x;
	modint(int _x=0):x(_x) {}
	friend modint operator + (modint x, modint y) {return (x.x + y.x) >= MOD ? x.x + y.x - MOD : x.x + y.x;}
	friend modint operator - (modint x, modint y) {return (x.x - y.x) < 0 ? x.x - y.x + MOD : x.x - y.x;}
	friend modint operator * (modint x, modint y) {return 1LL*x.x*y.x%MOD;}
	friend modint operator / (modint x, int k) {return x*inv[k];}
};
modint pow_mod(modint b, int p) {
	modint ret = 1;
	while( p ) {
		if( p & 1 ) ret = ret*b;
		b = b*b;
		p >>= 1;
	}
	return ret;
}
modint f[2][MAXN + 5][MAXN + 5];
int A[MAXN + 5], B[MAXN + 5], SA, SB;
int main() {
	init();
	int n; scanf("%d", &n);
	for(int i=0;i<n;i++)
		scanf("%d%d", &A[i], &B[i]), SA += A[i], SB += B[i];
	f[0][0][0] = MOD - 1;
	for(int i=0;i<n;i++) {
		for(int j=0;j<=SA;j++)
			for(int k=0;k<=SB;k++)
				f[1][j][k] = f[0][j][k];
		modint p = 1;
		for(int l=0;l<B[i];l++,p=p*A[i]/l)
			for(int j=A[i];j<=SA;j++)
				for(int k=l;k<=SB;k++)
					f[0][j][k] = f[0][j][k] - f[1][j-A[i]][k-l]*p;
	}
	modint ans = 0;
	for(int j=1;j<=SA;j++) {
		modint p = 1, q = modint(SA)/j;
		for(int k=0;k<=SB;k++,p=p*k/j)
			ans = ans + f[0][j][k]*p*q;
	}
	printf("%d\n", ans.x);
}

Measured memory_bytes: 1408
import java.io.*;
public class Main{
	public static void main(String [] args) throws NumberFormatException, IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=0;
		for(int i=1;;i++){
			t=Integer.parseInt(br.readLine());
			if(0==t)break;
			System.out.println("Case "+i+": "+t);
		}}}

Measured memory_bytes: 27208
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long
#define rep(i, a, b) for(ll i = (ll)a; i < (ll)b; i++)
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a+b+1) / 2 << "\n";
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A = 0, B = 0, sum = 0;
  cin >> A >> B ;
  for (int i = 0; i < B-A+1; i++){
	int C, D, C10000, C1000, C10, C1;
    C = A + i;
    C10000 = C / 10000;
    C1000 = C / 1000 - C10000 * 10;
    C10 = C / 10 - C / 100 * 10;
    C1 = C - C/ 10 * 10;
    D = C + C1 * 9999 + C10 * 990 - C1000 * 990 - C10000 * 9999;
  	if (C==D){
 		sum++;
    }
  }
  cout << sum << endl;
}

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

#define pb  push_back
#define ll  long long
#define INF 0x3f3f3f3f
#define pii pair<int, int>
#define ull unsigned long long int

const int t = 1005;
const int mod = 1e9 + 7;
char mat[t][t];
int n, m;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> mat[i][j];
    
    int ans = 0;
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
    dp[n - 1][m - 1] = 1;
    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            if (mat[i][j] == '#' || i == n - 1 && j == m - 1) continue;
            ans = dp[i + 1][j] + dp[i][j + 1];
            ans %= mod;
            dp[i][j] = ans;
        }
    }
    /*
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++)
            cout << dp[i][j] << " ";
        cout << "\n";
    }
    */
    cout << dp[0][0] << "\n";
    
    //cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 5248
import sys

def is_counter_clockwise(x1, y1, x2, y2, x3, y3):
    px = x2 - x1
    py = y2 - y1
    qx = x3 - x1
    qy = y3 - y1
    return px * qy - py * qx > 0

def is_in_triangle(x1, y1, x2, y2, x3, y3, xp, yp):
    if is_counter_clockwise(x1, y1, x2, y2, x3, y3):
        return is_counter_clockwise(x1, y1, x2, y2, xp, yp) and \
            is_counter_clockwise(x2, y2, x3, y3, xp, yp) and \
            is_counter_clockwise(x3, y3, x1, y1, xp, yp)
    else:
        return is_counter_clockwise(x1, y1, x3, y3, xp, yp) and \
            is_counter_clockwise(x3, y3, x2, y2, xp, yp) and \
            is_counter_clockwise(x2, y2, x1, y1, xp, yp)

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    if is_in_triangle(x1, y1, x2, y2, x3, y3, xp, yp):
        print("YES")
    else:
        print("NO")

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


int main(void)
{
  int n;
  cin >> n;
  vector<int> data(n);
  rep(i,n) cin >> data[i];
  int cnt = 0;
  for(int i = 0; i < n; i++)
  {
    int minv = i;
    for(int j = i; j < n; j++)
    {
      if(data[j] < data[minv])
      {
        minv = j;
      }
    }
    swap(data[i],data[minv]);
    if(i != minv) cnt++;
  }
  rep(i,n)
  {
    if(i > 0)cout << " ";
    cout << data[i];
  }
  cout << endl;
  cout << cnt << endl;
  return (0);
} 


Measured memory_bytes: 3112
#include <stdio.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int n;
int A[2000000];
int B[2000000];
int C[10000] = {};

void CountingSort(int k)
{
    for (int i = 0; i < n; i++)
        C[A[i]]++;

    for (int i = 1; i <= k; i++)
        C[i] += C[i - 1];

    for (int i = n - 1; i >= 0; i--)
        B[--C[A[i]]] = A[i];
}

int main()
{
    cin >> n;
    int maxn = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
        maxn = max(maxn, A[i]);
    }

    CountingSort(maxn);

    for (int i = 0; i < n; i++)
    {
        if (i)
            cout << " ";
        cout << B[i];
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 18588
#include"bits/stdc++.h" 
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
vector<int>u;
vector<int>w;
priority_queue<int>pq;
const int N=1e5+10;
/*--------------------------hbp16@hbp16-Inspiron-3543:-$------------------------------*/

int main(int argc, char const *argv[])
{
	int y,t=0;
	cin>>y;

	while(y >= 5)
	{
		if(y>=500)
		{
			y -= 500;
			t += 1000;
		}
		else
		{
			y -= 5;
			t += 5;
		}
	}
	cout<<t;

	return 0;
}

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

int main(){
  int R;
  cin >> R;
  if(R<1200){
    cout << "ABC" << endl;
  } else if(R<2800){
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#define N 1000
using namespace std;

int main(){
  while(1){
    int n,q,e[N],w[N],que,f;
    string str[N];
    cin>>n>>q;
    if(n+q==0) break;
    for(int i=0;i<n;i++)cin>>str[i]>>e[i]>>w[i];
    for(int i=0;i<q;i++){
      cin>>que,f=0;
      for(int j=0;j<n;j++)if(e[j]-(w[j]-que)>0 && e[j]-(w[j]-que)<=e[j]) cout<<str[j]<<" "<<e[j]-(w[j]-que)<<endl,f=1;
      if(!f) cout<<"Unknown"<<endl;
    }
  }
  return 0;
}

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

int n, m;
string s;

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

    vector<int> res(0);
    int pos = n;
    
    while(pos > 0)
    {
        int p = 0;
        for (int i = 1; i <= m; i++)
        {
            if(pos - i < 0)
            {
                break;
            }

            if(s[pos - i] == '0')
            {
                p = max(p, i);
            }
        }

        if(p == 0)
        {
            cout << -1 << endl;
            return 0;
        }

        res.emplace_back(p);
        pos -= p;
    }
    
    reverse(res.begin(), res.end());
    for(int i = 0; i < res.size(); i++)
    {
        cout << res[i] << ((i == res.size() - 1)? "\n" : " ");
    }

    return 0;
}

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

int main () {
	int n; cin >> n;
  	int a[n], m = 0;
  bool ok = 0;
 	for (int i =0 ; i < n; i++) {
      cin >> a[i];
      m = max(m,a[i]);
    }
  int ans = 0;
  for (int i = 0; i < n; i++) {
   	if (m == a[i] && !ok) {
      ok = 1;
      ans += a[i]/2;
    } else ans += a[i];
    
  }
  cout << ans << endl;
  
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<stack>
#include<queue>
#include<sstream>
#include<bitset>
#include<cstdio>
#include<stdio.h>
#include<cstring>
using namespace std;
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
int main()
{
	//in_out_txt();
	fast();
	string str;
	cin>>str;
	str[3]='8';
	cout<<str<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
$|=1;
$Q = <STDIN>;chomp $Q;

@P=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317);

$s=0;
for($i=3;$i<=100000;$i++){
	$f=1;
	$ii=($i+1)/2;
	for($j=0;$P[$j]*$P[$j]<=$ii;$j++){
		if($ii%$P[$j]==0) { $f=0; last; }
	}
	if ($f) {
		for($j=0;$P[$j]*$P[$j]<=$i;$j++){
			if($i%$P[$j]==0) { $f=0; last;}
		}
		$s=$s+1 if ($f);
	}
	$S[$i]=$s;
	#push @PP,$i;
}

for($i=0;$i<$Q;$i++){
	$line = <STDIN>;chomp $line;
	($l,$r)=split " ",$line;
	$c=$S[$r]-$S[$l-1];
	print "$c\n";
}


Measured memory_bytes: 4096
use io::*;
use std::*;

fn solve(_n: i64, a: Vec<i64>) {
    let max = a.iter().cloned().fold(i64::MIN, cmp::max);
    let min = a.iter().cloned().fold(i64::MAX, cmp::min);
    println!("{}", max - min);
}

fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let n: i64;
    n = scanner.next();
    let mut a: Vec<i64> = vec![0i64; (n) as usize];
    for i in 0..(n) as usize {
        a[i] = scanner.next();
    }
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(n, a)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 8572
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int x;
    cin >> x;
    if (x == 3 || x == 5 || x == 7)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }

        int[] dp = new int[N+1];
        dp[0] = 0;
        dp[1] = 0;
        dp[2] = Math.abs(arr[1]-arr[0]);

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

            dp[i]= Math.min(
                    dp[i-1] + Math.abs(arr[i-1]-arr[i-2]),
                    dp[i-2] + Math.abs(arr[i-1]-arr[i-3])
            );

        }

        System.out.println(dp[N]);


    }

}


Measured memory_bytes: 50240
n, m, x = gets.split.map(&:to_i)
c = []
a = []
min = 10**7

n.times do |i|
  c[i], *a[i] = gets.split.map(&:to_i)
end

1.upto(n) do |i|
  [*0..(n - 1)].combination(i) do |arr|
    tmp = Array.new(m) { 0 }
    cost = 0

    arr.each do |e|
      cost += c[e]
      a[e].each_with_index { |i, idx| tmp[idx] += i }
    end

    if tmp.all? { |i| i >= x }
      min = cost if min > cost
    end
  end
end

puts min == 10**7 ? -1 : min

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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

vector<int> primes{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};

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

  int s = primes.size();
  vector<int> countP(s, 0);

  for (int i = 1; i <= N; i++) {
    int temp = i;
    for (int j = 0; j < s; j++) {
        if (temp == 1) break;
        while (temp % primes[j] == 0) {
            countP[j]++;
            temp /= primes[j];
        }
    }
  }
//  SHOW(countP);

  int check75 = 0, check25 = 0, check15 = 0, check5 = 0, check3 = 0;
  for (int i = 0; i < s; i++) {
    if (countP[i] >= 74) check75++;
    if (countP[i] >= 24) check25++;
    if (countP[i] >= 14) check15++;
    if (countP[i] >= 4) check5++;
    if (countP[i] >= 2) check3++;
    }

    ll ans = 0;
    ans += check75;
    ans += check25 * (check3 - 1);
    ans += check15 * (check5 - 1);
    ans += check5 * (check5 - 1) / 2 * (check3 - 2);

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

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	double T,X;
	cin >>T>>X;
	
	cout << T/X<< endl;
}

Measured memory_bytes: 256
n = int(input())
p = [int(e) for e in input().split()]
count=0
p_min=p[0]

for i in range(n):
    if p[i] <= p_min:
        count+=1
#        p_min=min(p[0:i+1])
        p_min=p[i]

print (count)


Measured memory_bytes: 24744
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

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

    priority_queue<ll, vector<ll>, greater<ll>> pq;
    for (int i = 1; i <= 9; ++i) pq.push(i);

    ll x;
    rep(loop, k) {
        x = pq.top();
        pq.pop();

        int s = x % 10;
        for (int i = max(0, s - 1); i <= min(9, s + 1); ++i)
            pq.push(x * 10 + i);
    }
    cout << x << '\n';
    return 0;
}


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

const ll MAX = 1LL << 60;
ll h[100010];
ll dps[100010];

// n番目のジャンプ台まで到達するための最小コストを返す
ll dp(int n) {
  if (n == 0) {
     return 0;
  }
  if (dps[n] < MAX) {
    return dps[n];
  }
  
  ll n1 = dp(n-1) + abs(h[n] - h[n-1]);
  ll n2 = MAX;
  if (n > 1) {
    n2 = dp(n-2) + abs(h[n] - h[n-2]);
  }
  
  dps[n] = min(n1, n2);
  return dps[n];
}

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> h[i];
  }
  for (int i = 0; i < 100010; i++){
    dps[i] = MAX;
  }
  cout << dp(N-1) << endl;
}


Measured memory_bytes: 4992
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s;
    cin >> s;
    ll e = 1000000000LL;
    if(s<=e){
        printf("%lld %lld %lld %lld %lld %lld\n",0,0,0,1,s,0);
    }else{
        ll r = s%e;
        if(r!=0){
            ll x2 = e-r;
            ll y3 = 1;
            ll y2 = (s+x2)/e;
            printf("%lld %lld %lld %lld %lld %lld\n",0,0,x2,y2,e,y3);
        }else{
            ll x2 = 0;
            ll y3 = 0;
            ll y2 = s/e;
            printf("%lld %lld %lld %lld %lld %lld\n",0,0,x2,y2,e,y3);
        }
        
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
map<pair<int,int>,ll> mpi;
vector<int> to[100010];
vector<ll> dis(100010,inf);
void bfs(int i,int p){
    for(auto u : to[i]){
        if(u==p) continue;
        dis[u] = dis[i] + mpi[{u,i}];
        bfs(u,i);
    }
}
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    rep(i,n-1){
        int a,b;
        ll c;
        cin >> a >> b >> c;
        a--;b--;
        mpi[{a,b}] = c;
        mpi[{b,a}] = c;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int q,k;
    cin >> q >> k;
    k--;
    dis[k] = 0;
    bfs(k,-1);
    rep(i,q){
        int x,y;
        cin >> x >> y;
        x--;y--;
        cout << dis[x] + dis[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 33152
#include <iostream>

using namespace std;
using ll = long long;

ll labs(ll a)
{
  if (a >= 0) return a;
  else return -a;
}

ll diffabs(ll a, ll b)
{
  if (a >= b) return a - b;
  else return b - a;
}

int main()
{
  ll x, y;
  cin >> x >> y;

  int ans = diffabs(labs(x), labs(y));
  if (x * y > 0 && x > y)
    ans += 2;
  else if (x * y == 0 && x > y)
    ans += 1;
  else if (x * y < 0)
    ans += 1;
  
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <utility>
#include <cstdio>

using namespace std;

int main(void) {

    int nums[3];
    cin >> nums[0] >> nums[1] >> nums[2];

    if (nums[2] < nums[1])
        swap(nums[2], nums[1]);

    if (nums[2] < nums[0])
        swap(nums[2], nums[0]);

    if (nums[1] < nums[0])
        swap(nums[1], nums[0]);

    printf("%d %d %d\n", nums[0], nums[1], nums[2]);

    return 0;
}

Measured memory_bytes: 1144
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	int64_t A, B, C, X, Y;
	int64_t ABnum;
	int64_t answer = INT64_C(11111111111111111);
	if (scanf("%" SCNd64 "%" SCNd64 "%" SCNd64 "%" SCNd64 "%" SCNd64, &A, &B, &C, &X, &Y) != 5) return 1;
	for (ABnum = 0; ABnum / 2 < X + 10 || ABnum / 2 < Y + 10; ABnum += 2) {
		int64_t Aleft = X - ABnum / 2, Bleft = Y - ABnum / 2;
		int64_t candidate;
		if (Aleft < 0) Aleft = 0;
		if (Bleft < 0) Bleft = 0;
		candidate = A * Aleft + B * Bleft + C * ABnum;
		if (candidate < answer) answer = candidate;
	}
	printf("%" PRId64 "\n", answer);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    char s[100];
    int sum=0;
    for(int i=1;i<=6;i++)
    {
        cin>>s[i];
        if(s[i]=='1')
            sum++;
            else continue;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#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) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#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.1415926535897932384626433832795028;
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 T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &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, T;
int A[3300], B[3300];
int dp[3300][6600][2];
signed main() {
    cin >> N >> T;
    rep(i, N) { cin >> A[i] >> B[i]; }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= T; j++) {
            rep(k, 2) {
                chmax(dp[i + 1][j][k], dp[i][j][k]);
                chmax(dp[i + 1][j + A[i]][k], dp[i][j][k] + B[i]);
                if (k == 0) {
                    chmax(dp[i + 1][j + 1][1], dp[i][j][k] + B[i]);
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= T; i++) { chmax(ans, dp[N][i][1]); }
    cout << ans << endl;
}


Measured memory_bytes: 311424
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let mut x = get_line().parse::<u64>().unwrap();
    let mut happy = 0;

    happy += 1000 * (x / 500);
    x %= 500;

    happy += 5 * (x / 5);

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


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

int main() {
  string s;
  cin >> s;
  
  if (s[0]==s[1] && s[1]==s[2] && s[2] == s[3])
  cout << "No" << endl;
  else if (s[0]==s[1] && s[2]==s[3])
  cout << "Yes" << endl;
  else if (s[0]==s[2] && s[1]==s[3])
  cout << "Yes" << endl;
  else if (s[0]==s[3] && s[1]==s[2])
  cout << "Yes" << endl;
  else
  cout << "No" << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
string a,b,c;cin>>a>>b>>c;
if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
else cout<<"NO"<<endl;
	return 0;
}



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

int main()
{
    ll n,k,x,y;
    cin>>n>>k;
    ll ar[n+1],dp[n+1];
    for(ll i=1; i<=n; i++ )
    {
        cin>>ar[i];
    }
    dp[n]=0;
    dp[n-1]=abs(ar[n-1]-ar[n]);
    for(ll i=n-2;i>=1;i--)
    {
        y=1e+9;
        for(ll j=1;j<=k&&j<=n-i;j++)
        {
            x=dp[i+j]+abs(ar[i+j]-ar[i]);
            if(x<y)
                y=x;
        }
        dp[i]=y;
    }
    cout<<dp[1];
}


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int a[n][n];
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n-1; ++j)
		{
			cin>>a[i][j];
			--a[i][j];
		}
		a[i][n-1]=-1;
	}
	int ans=0,cnt=0,f=0,memo[n]={},done[n]={};
	while (cnt<n*(n-1)/2)
	{
		f=0;
		++ans;
		for (int i = 0; i < n; ++i)
		{
			done[i]=0;
		}
		for (int i = 0; i < n; ++i)
		{
			if (memo[i]>=n-1)
			{
				continue;
			}
			int vs=a[i][memo[i]];
			if (vs<i&&a[vs][memo[vs]]==i&&done[i]==0&&done[vs]==0)
			{
				f=1;
				++cnt;
				++memo[i];
				++memo[vs];
				done[i]=1;
				done[vs]=1;
			}
		}
		if (f==0)
		{
			cout<<"-1\n";
			return 0;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
// template<typename T> using Graph = vector<vector<T>>;

struct edge {
    Pii to;
    int cost;
    edge(){}
    edge(Pii _to, int _cost) : to(_to), cost(_cost) {}
};

map<Pii, vector<edge>> G;

int dijkstra(Pii s, Pii g) {
    // cerr << endl;
    // cerr << "dijkstra: " << endl;

    priority_queue<pair<int, Pii>, vector<pair<int, Pii>>, greater<pair<int, Pii>>> pq;   // {cost, vertex}
    map<Pii, int> d;
    for (auto p : G) {
        d[p.first] = inf;
    }
    d[g] = inf;
    d[s] = 0;

    pq.push(make_pair(0, s));

    while (!pq.empty()) {
        int cost;
        Pii v;
        tie(cost, v) = pq.top(); pq.pop();
        // cerr << cost << " " << v.first << " " << v.second << endl;
        if (v == g) break;
        if (d[v] < cost) continue;
        for (auto e : G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push(make_pair(d[e.to], e.to));
            }
        }
    }
    return d[g];
}
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int N, M;
    cin >> N >> M;
    vi p(M), q(M), c(M);
    vector<set<int>> vst(N); //vst[i] = 頂点iから乗れる会社の集合
    rep(i, M) {
        cin >> p[i] >> q[i] >> c[i];
        p[i]--, q[i]--, c[i]--;
        vst[p[i]].insert(c[i]);
        vst[q[i]].insert(c[i]);
    }

    rep(i, N) {
        for (auto x : vst[i]) {
            G[Pii(i, -1)].emplace_back(Pii(i, x), 1);
            G[Pii(i, x)].emplace_back(Pii(i, -1), 1);
        }
    }

    rep(i, M) {
        G[Pii(p[i], c[i])].emplace_back(Pii(q[i], c[i]), 0);
        G[Pii(q[i], c[i])].emplace_back(Pii(p[i], c[i]), 0);
    }

    // for (auto p : G) {
    //     cerr << "(" << p.first.first << ", " << p.first.second << "):";
    //     for (auto e : p.second) {
    //         cerr << "{(" << e.to.first << ", " << e.to.second << "), " << e.cost << "}, ";
    //     }
    //     cerr << endl;
    // }

    int ans = dijkstra(Pii(0, -1), Pii(N - 1, -1));
    cout << (ans == inf ? -1 : ans / 2) << endl;
}


Measured memory_bytes: 153076
/*
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
//*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3100;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) cout << x , exit(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

string s;
string t;
int dp[maxn][maxn];
int par[maxn][maxn];

int32_t main(){
    migmig
    cin >> s;
    cin >> t;
    int n = s.size() , m = t.size();
    s = "." + s;
    t = '.' + t;
    pii mx = {0 , 0};
    for(int i = 1 ; i <= n ; i ++){
        for(int j = 1 ; j <= m ; j ++){
            if(s[i] == t[j]){
                dp[i][j] = dp[i-1][j-1]+1;
                par[i][j] = 3;
            }
            else if(dp[i-1][j] > dp[i][j-1]){
                dp[i][j] = dp[i-1][j];
                par[i][j] = 2;
            }
            else{
                dp[i][j] = dp[i][j-1];
                par[i][j] = 1;
            }
            if(dp[i][j] > dp[mx.first][mx.second])
                mx = {i , j};
        }
    }
    string ans = "";
    while(mx!=pii(0 , 0)){
        auto [f , s] = mx;
        if(par[f][s] == 3){
            ans = t[s] + ans;
        }
        int bz = par[f][s]>=2;
        s -= par[f][s]%2;
        f -= bz;
        mx = {f , s};
        if(par[f][s] == 0)
            break;
    }
    cout << ans;
    return(0);
}

Measured memory_bytes: 76352
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
	static string s;

	static void Main(){
		s = Console.ReadLine();
		long ans_01 = 0;
		for (int i = 0;i < s.Length;i++){
			if (i % 2 == 0 && s[i] == '1') ans_01++;
			if (i % 2 == 1 && s[i] == '0') ans_01++;
		}	
		long ans_10 = 0;
		for (int i = 0;i < s.Length;i++){
			if (i % 2 == 0 && s[i] == '0') ans_10++;
			if (i % 2 == 1 && s[i] == '1') ans_10++;
		}	
		Console.WriteLine(Min(ans_01,ans_10));
	}
}

Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
#define ran 101111
#define i64 long long int
int n,a[ran];
int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	--n;
	for(int i=n; i>=1; i--)a[i] -= a[i-1];
	int L = 1, R = n;
	i64 res = 0, c = 2;
	while(R - L > 1){
		res += c * a[L];
		res += c * a[R];
		L ++;
		R --;
		c += 2;
	}
	c -= 2;
	if(L == R)res += (c + 1) * a[L];else
		res += (c + 1) * (a[L] + a[R]) + max(a[L], a[R]);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int r, d, x;
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> r >> d >> x;
 	for(int i=1; i<=10; i++)
 	{
 		x = r*x - d;
 		cout << x << '\n';
 	}
	return 0;
}


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

int main()
{
    int n;
    while(cin >> n, n){
        int a[10] = {};
        for(int i = 0; i < n; ++i){
            int temp;
            cin >> temp;
            ++a[temp];
        }
        
        for(int i = 0; i < 10; ++i){
            if(a[i] == 0) cout << '-' << endl;
            else {
                for(int j = 0; j < a[i]; ++j){
                    cout << '*';
                }
                cout << endl;
            }
        }
    }
}

Measured memory_bytes: 1152
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(0, min(b, d) - max(a, c)) << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = [int(_) for _ in input().split()]
h = []
for _ in range(n):
    h.append(int(input()))
h.sort()

answer = int(10e9)
for i in range(n - k + 1):
    d = h[i + k - 1] - h[i]
    if d < answer:
        answer = d

print(answer)


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

typedef long long ll;
const ll MOD = 1e9+7;

struct Matrix{
    ll a[55][55];
    int n;

    Matrix(int _n=0){n=_n;memset(a,0,sizeof(a));}
    Matrix operator * (const Matrix b) const {
        Matrix c(n);
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                for(int k=1;k<=n;k++){
                    c.a[i][j]=(c.a[i][j]+(a[i][k]*b.a[k][j])%MOD)%MOD;
                }
            }
        }
        return c;
    }
    void id(){for(int i=1;i<=n;i++)a[i][i]=1;}
};

int n;
ll k;

Matrix bpow(Matrix x,ll b){
    Matrix sol(n);sol.id();
    while(b){
        if(b&1)sol=sol*x;
        x=x*x;
        b>>=1;
    }
    return sol;
}



int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>k;
    Matrix v(n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)cin>>v.a[i][j];
    }
    Matrix p(n);
    p=bpow(v,k);

    ll ans=0LL;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            ans+=p.a[i][j];
            if(ans>=MOD)ans%=MOD;
        }
    }

    cout<<ans;
    return 0;
}


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

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

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

  char b;
  cin >> b;

  char ans;

  if (b == 'A') {
    ans = 'T';
  } else if (b == 'T') {
    ans = 'A';
  } else if (b == 'C') {
    ans = 'G';
  } else if (b == 'G') {
    ans = 'C';
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n,m,l;
    int i,j,k;
    long int a[101][101],b[101][101],c[101][101]={0};
    /*入力部*/
    scanf("%d %d %d",&n,&m,&l);
    for(i = 0;i < n;i++){
        for(j = 0;j < m;j++){
            scanf("%ld",&a[i][j]);
        }
    }
    for(i = 0;i < m;i++){
        for(j = 0;j < l;j++){
            scanf("%ld",&b[i][j]);
        }
    }
    /*出力部*/
    for (i = 0; i < n; i++){
        for(j = 0;j < l;j++){
            for(k = 0;k < m;k++)c[i][j] += a[i][k] * b[k][j];
            printf("%ld",c[i][j]);
            printf((j + 1 < l)? " ": "");
        }
        printf("\n");
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mods[] = {998244353, 1000000007, 1000000009};
const ll bases[] = {997, 1009, 1013};
// const ll mod = mods[0];
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll k;
string festival = "FESTIVAL";
string ans;
const ll base = 256;

void dfs(ll d, ll k){
  if(d == -1) return;
  k--;
  while(k%256 != 0){
    k--;
    ans += festival[d];
  }
  if(k == 0) return;
  dfs(d-1, k/256);
  for(ll i = 0;i < 256;i++){
    ans += festival[d];
  }
}

int main(){
  cin >> k;
  ans = festival;
  dfs(7, k);
  cout << ans << endl;
  vl cnt(128, 0);
  unordered_map<ll,ll> m;
  m[festival[0]] = 0;
  for(ll i = 1;i < festival.size();i++){
    m[festival[i]] = festival[i-1];
  }
  cnt[0] = 1;
  for(ll i = 0;i < ans.size();i++){
    cnt[ans[i]] = cnt[ans[i]] + cnt[m[ans[i]]];
  }
  cerr << cnt['L'] << " " << k << endl;
  assert(cnt['L'] == k);
  assert(ans.size() <= 5000);





}


Measured memory_bytes: 256
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    if(n == 0){
        cout << 0 << endl;
        return 0;
    }
    string ans = "";
    ll base = 1;
    while(n != 0){
        if(n % (base * 2) == 0) ans += '0';
        else{
            ans += '1';
            n -= base;
        }
        base *= -2; 
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 3560
#include <stdio.h>
int main (){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d = a/b;
    r = a%b;
    f = (double)a/b;
    printf("%d %d %.5lf\n",d,r,f);
    return 0;
}


Measured memory_bytes: 2112
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			int a = sc.nextInt();
			String s = sc.next();
			int b = sc.nextInt();
			if (s.equals("?")) {break;}
			if (s.equals("+")) {System.out.println(a+b);}
			else if (s.equals("-")) {System.out.println(a-b);}
			else if (s.equals("*")) {System.out.println(a*b);}
			else if (s.equals("/")) {System.out.println(a/b);}
		}
	}
}



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

ans = 0  # 何も操作しない

# 何かしら操作するなら、最後に黒がK列または白がK列残った状態になる。他は任意っぽそうなのでベストを尽くす
best = [0]
for a in A:
    if a < 0:
        a = 0
    best.append(best[-1] + a)

for i in range(N - K + 1):
    if i == 0:
        black = sum(A[:K])
    else:
        black = black + A[i + K - 1] - A[i - 1]
    score_white = best[N] - best[i + K] + best[i] - best[0]
    score_black = black + score_white
    ans = max(ans, score_white, score_black)


print(ans)

Measured memory_bytes: 14988
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
string s;
int dp[2][2020];

int main(void) {
    cin >> s;
    int n = sz(s);

    dp[0][s[0]-'0']++;
    for (int i=1; i<n; i++) {
        int now = i%2;
        int prev = (i-1)%2;
        int d = s[i]-'0';
        dp[now][d]++;
        
        for (int j=0; j<2019; j++) {
            int r = (j*10+d)%2019;
            dp[now][r] += dp[prev][j];
        }
        ans += dp[now][0];
        for (int j=0; j<2019; j++) dp[prev][j] = 0;


    }

    
    

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e6+1;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n, k;
	cin >> n >> k;
	int a[n], ans = 0, ind = 0;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	while(ind < (n - 1))
		ind += (k - 1), ans++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    String S = scan.nextLine();

    for (int i = 1; i < S.length() - 1; i++) {
      if ((S.charAt(i - 1) == S.charAt(i)) || (S.charAt(i) == S.charAt(i + 1))) {
        System.out.println("Bad");
        return;
      }
    }
    System.out.println("Good");
  }
}


Measured memory_bytes: 23508
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int N,D;
bool IsDist(vector<vector<int>> &X,int x,int y)
{
	double D1=0;
	for (int j=0;j<D;j++){
		int d=X[x][j]-X[y][j];
		D1+=d*d;
	}
	D1=sqrt(D1);
	if (D1==(int)D1){
		return true;
	}else{
		return false;
	}
}
int main(int argc, char* argv[])
{

	cin>>N>>D;
	vector<vector<int>> X(N,vector<int>(D));
	int i,j;
	for (i=0;i<N;i++){
		for (j=0;j<D;j++){
			cin>>X[i][j];
		}
	}
	int ans=0;
	for (i=0;i<N-1;i++){
		for (j=i+1;j<N;j++){
			if (IsDist(X,i,j)){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lb long double
#define eps 1e-10
#define N 110
using namespace std;
struct Po{lb x,y;}a[N],x;
int n,q;
void get(Po &x){scanf("%Lf %Lf",&x.x,&x.y);}
Po operator +(Po x,Po y){return (Po){x.x+y.x,x.y+y.y};}
Po operator -(Po x,Po y){return (Po){x.x-y.x,x.y-y.y};}
lb operator *(Po x,Po y){return x.x*y.y-x.y*y.x;}
lb operator ^(Po x,Po y){return x.x*y.x+x.y*y.y;}
int pa(int x){if (x>n)return x-n;return x;}
bool pan(Po x,Po y,Po z){
	if (y.x>z.x)swap(y,z);
	if (x.x<y.x-eps||x.x>z.x+eps) return 0;
	if (y.y>z.y)swap(y,z);
	if (x.y<y.y-eps||x.y>z.y+eps) return 0;
	return 1;
}
int que(Po x){
	int an=0;
	for (int i=1;i<=n;i++){
		Po p=a[i]-x,q=a[pa(i+1)]-x;
		if (p.y<q.y) swap(p,q);
		if (p.y>eps&&q.y<eps&&p*q>eps) an=2-an;
		if (fabs(p*q)<eps&&pan(x,a[i],a[pa(i+1)])) return 1;
	}
	return an;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)get(a[i]);
	scanf("%d",&q);
	while (q--){
		get(x);
		printf("%d\n",que(x));
	}
	return 0;
}


Measured memory_bytes: 3236
def main():
    H, N = map(int, input().split())
    l = []
    for _ in range(N):
        a, b = map(int, input().split())
        l.append((a,b))
    dp = [[0] * N for _ in range(H+1)]
    for w in range(H+1):
        if w % l[0][0] == 0:
            dp[w][0] = l[0][1] * (w//l[0][0])
        else:
            dp[w][0] = l[0][1] * (1 + (w//l[0][0]))
    for i in range(1, N):
        for w in range(H+1):
            if w > l[i][0]:
                dp[w][i] = min(dp[w-l[i][0]][i] + l[i][1], dp[w][i-1])
            else:
                dp[w][i] = min(dp[w][i-1], l[i][1])
    print(min(dp[-1]))
main()




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

using namespace std;

int main(){
    char alp[26];
    int n;
    string s;

    forn(i, 26){
        alp[i] = ((char)65+i);
    }

    cin>>n;
    cin>>s;

    forn(i, s.length()){
        if(((int)s[i]+n) > 90){
            cout<<(char)(s[i]+n-26);
        }else{
            cout<<(char)(s[i]+n);
        }
    }    

    cout<<endl;

    return 0;
}

Measured memory_bytes: 256