akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, m;
    cin >> n >> m;
    vector<bool> a(n + 1, false);
    rep(i, m){
        int x;
        cin >> x;
        a[x] = true;
    }

    vector<int> dp(n + 1);
    dp[0] = 1;
    rep(i, n){
        if(a[i]){
            continue;
        }
        if(not a[i+1]){
            dp[i+1] += dp[i];
            dp[i+1] %= MOD;
        }
        if(i + 2 <= n && not a[i+2]){
            dp[i+2] += dp[i];
            dp[i+2] %= MOD;
        }
    }
    cout << dp[n] << endl;

    return 0;
}


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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007

#define TIME chrono::system_clock::now
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int m,n;

int main(){
    int i,k;
    int last=0;
    
    ll result=0;
    
    cin>>n;
    
    for (i=0;i<n;i++){
        scanf("%d",&k);
        result+=k/2;
        last+=k&1;
        result+=last/2;
        last=last&1;
        if (k==0) last=0;
    }
    cout<<result<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n , x) for (int i = (int)(x); i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 1; --i)
#define repBX(i, n , x) for (int i = (int)(n); i >= int(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int a;
    cin >> a;
    cout << a + pow(a,2) + pow(a,3) << endl;
    
    return 0;
}

Measured memory_bytes: 4172
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[][] horizontalLine = new int[n][2];
		String[] input = null;
		for(int i = 0; i < n; i++){
			input = sc.next().split(",");
			horizontalLine[i][0] = Integer.parseInt(input[0]);
			horizontalLine[i][1] = Integer.parseInt(input[1]);
		}
		int[] result = solve(w, horizontalLine);
		for(int i : result){
			System.out.println(i);
		}
		sc.close();
	}

	public static int[] solve(int numVerticalLines, int[][] horizontalLine){
		//initialize
		int[] n = new int[numVerticalLines];
		for(int i = 0; i < numVerticalLines; i++){
			n[i] = i + 1;
		}
		
		//solve
		for(int i = 0; i < horizontalLine.length; i++){
			int source = horizontalLine[i][0] - 1;
			int target = horizontalLine[i][1] - 1;
			int tmp = n[source];
			n[source] = n[target];
			n[target] = tmp;
		}
		return n;
	}
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	string s;
	cin >> s;
	int k;
	cin >> k;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] != '1') {
			if(i + 1 <= k ) {
				cout << s[i] << endl;
				return 0;
			}
			else {
				cout << '1' << endl;
				return 0;
			}
		}
	}
	cout << 1 << endl;
	return 0;	
}

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

int main(){
    int N,M,X;
    cin>>N>>M>>X;
    //Nはマスの数、Mは１〜Mについての料金所
    //Xは現在いる座標
    int left=0,right=0;
    for(int i = 0; i < M; i++){
        int a;
        cin >> a;
        if(a < X){
            left++;
        }else{
            right++;
        }
    }
    int ans = min(left, right);
    cout<<ans<<endl;
}

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


int draw(int h,int w){
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << '#';
        }
        cout << endl;
    }
    cout << endl;
    return 0;
}

int main(){
    int h[300];
    int w[300];
    int cnt;
    for(int i=0;;i++){
        cin >> h[i] >> w[i];
        cnt = i;
        if(h[i] == 0 && w[i] == 0){
            break;
        }
    }
    for(int i=0;i<cnt;i++){
        draw(h[i],w[i]);
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


Measured memory_bytes: 3088
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

template<typename T>
struct WarshallFloyd {
    const T INF = numeric_limits<T>::max();
    int n;
    vector<vector<T>> d;
    WarshallFloyd(int n) : n(n), d(n, vector<T>(n, INF)) {
        for (int i = 0; i < n; i++) d[i][i] = 0;
    }
    void add_edge(int s, int t, T w, bool directed) {
        d[s][t] = min(d[s][t], w);
        if (directed) d[t][s] = min(d[t][s], w);
        for (int k : {s, t})
            for (int i = 0; i < n; i++) if (d[i][k] != INF)
                for (int j = 0; j < n; j++) if (d[k][j] != INF)
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
    bool has_neg_cycle() {
        for (int i = 0; i < n; i++) if (d[i][i] < 0) return true;
        return false;
    }
    bool in_shortest_path(int s, int t, T w) {
        for (int i = 0; i < n; i++) if (d[i][s] + w == d[i][t]) return true;
        return false;
    }
};

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(m), b(m), c(m);
    for (int i = 0; i < m; i++) cin >> a[i] >> b[i] >> c[i], a[i]--, b[i]--;
    WarshallFloyd<int> wf(n);
    for (int i = 0; i < m; i++) wf.add_edge(a[i], b[i], c[i], true);
    int cnt = 0;
    for (int i = 0; i < m; i++) cnt += !wf.in_shortest_path(a[i], b[i], c[i]);
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String chara = scan.nextLine();
        int count = 0;
        for (char c :chara.toCharArray()) {
            if (c == '+') {
                count++;
            } else {
                count--;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35832
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
ll test[12345678];
signed main() {
	ll n, m, k, l, cnt = 0, z = 0; cin >> n >> m;
	while (cnt < n) {
		cnt += m * 2; cnt++; z++;
	}
	cout << z << endl;
	cin >> n; return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a;
    rep(i, n){
        int x;
        cin >> x;
        a.push_back(x);
    }
    rep2(i, k, n){
        if(a[i]>a[i-k]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4320
n = list(input())

last = int(n[len(n)-1])
if last == 2 or last == 4 or last == 5 or last == 7 or last == 9:
    print("hon")
elif last == 0 or last == 1 or last == 6 or last==8:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 9172
S = list(map(int, list(input())))

mod = 2019
ss = [0]
tmp = 0
for i, s in enumerate(S[::-1]):
    tmp += s * pow(10, i, mod)
    tmp %= mod
    ss.append(tmp)

cnts = [0] * 2019
ans = 0
for s in ss:
    ans += cnts[s]
    cnts[s] += 1

print(ans)


Measured memory_bytes: 19264
fun main(args:Array<String>): Unit {
    while(true) {
        val (n, m) = readLine()!!.trim().split(' ').map(String::toLong)
        if (n == 0L && m == 0L) return
        val probability = probabilities(n.toInt())
        val prospects = probability.mapIndexed { index, d -> index * d }.toDoubleArray().also {
            for (i in (1 until it.size).reversed()) it[i - 1] += it[i]
        }
        for (i in 1 until probability.size) probability[i] += probability[i - 1]
        var count = m - 1
        var current = 3.5 * n
        while (count != 0L && current < 6 * n) {
            val next = binSearch(current, count, prospects, probability)
            count = next.second
            current = next.first
        }
        println(current)
    }
}
fun exponent(n:Int): Long {
    return when(n){
        0 -> 1
        else -> 6 * exponent(n - 1)
    }
}
fun probabilities(n: Int): DoubleArray {
    val res = LongArray(6 * n + 1){0L}.also{it[0] = 1}
    repeat(n){
        for (i in (0 until res.size).reversed()){
            if (res[i] > 0){
                for (j in 1 .. 6){
                    res[i + j] += res[i]
                }
                res[i] = 0
            }
        }
    }
    val all = exponent(n)
    return res.map{it.toDouble() / all}.toDoubleArray()
}

class Matrix2x2(private val array: DoubleArray) {
    operator fun get(row: Int, column: Int): Double = array[row * 2 + column]
    operator fun times(matrix: Matrix2x2): Matrix2x2 {
        return Matrix2x2(
                doubleArrayOf(
                        array[0] * matrix.array[0] + array[1] * matrix.array[2],
                        array[0] * matrix.array[1] + array[1] * matrix.array[3],
                        array[2] * matrix.array[0] + array[3] * matrix.array[2],
                        array[2] * matrix.array[1] + array[3] * matrix.array[3]
                )
        )
    }
}
fun exponent(matrix: Matrix2x2, exp: Long): Matrix2x2 {
    return when(exp){
        0L -> Matrix2x2(doubleArrayOf(1.0, 0.0, 0.0, 1.0))
        1L -> matrix
        else -> exponent(matrix, exp / 2).let{if (exp % 2 == 0L) it * it else it * it * matrix}
    }
}
fun binSearch(sm: Double, count: Long, prospects: DoubleArray, probability: DoubleArray): Pair<Double, Long> {
    val matrix = Matrix2x2(
            doubleArrayOf(
                    probability[sm.toInt()], prospects[(sm + 1).toInt()], 0.0, 1.0
            )
    )
    val target = (sm + 1).toInt()
    var left = 0L
    var right = count
    while (left < right){
        val mid = (left + right) / 2
        val m = exponent(matrix, mid)
        if (m[0, 0] * sm + m[0, 1] >= target){
            right = mid
        }else{
            left = mid + 1
        }
    }
    val m = exponent(matrix, right)
    return (m[0, 0] * sm + m[0, 1] to count - right)
}


Measured memory_bytes: 62904
import java.util.Scanner;

/**
 *
 * @author psygn
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int num = scanner.nextInt();
        long amount = scanner.nextLong();

        int x = 0;
        int y = 0;
        int z = 0;

        int maxX = (int) (amount / 10000);

        boolean exitFlg = false;

        for (int i = maxX; i >= 0; i--) {
            for (int j = (int) (amount - (i * 10000)) / 5000; j >= 0; j--) {
                x = i;
                y = j;
                z = num - i - j;
                if (((x * 10000) + (y * 5000) + (z * 1000)) == amount) {
                    exitFlg = true;
                    break;
                }
            }
            if (exitFlg) {
                break;
            }
        }
        if (!exitFlg) {
            x = -1;
            y = -1;
            z = -1;
        }
        System.out.println(x + " " + y + " " + z);

    }
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int A, P;
    cin >> A >> P;

    cout << (A*3+P)/2 << endl;

    return 0;
}

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

typedef long long ll;

int main() {
	ll a, b, k; cin >> a >> b >> k;
	if (k >= a) {
		k -= a; a = 0;
	}
	else {
		a -= k; k = 0;
	}
	if (k >= b) {
		k -= b; b = 0;
	}
	else if (k != 0) {
		b -= k; k = 0;
	}
	cout << a << ' ' << b << endl;

	return 0;
}

Measured memory_bytes: 256
k=int(input())
s=len(input())
c=1
m=10**9+7
p=0
a=[1]
b=[1]
for i in range(k):
    a.append(a[-1]*25%m)
    b.append(b[-1]*26%m)
for i in range(k+1):
    p=(p+a[i]*b[k-i]*c)%m
    c=(c*(s+i)*pow(i+1,m-2,m))%m
print(p)

Measured memory_bytes: 213700
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 10005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll n;
  cin>>n;
  ll cur = 100;
  for(int i=1;;i++){
    cur = floor(cur * 1.01);
    if(cur>=n){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	
	int n;
	cin >> n;
	for(int i = 111; i < 1000; i += 111) {
		if(i >= n) {cout << i << endl; return 0;}
	}
	return 0;
}



Measured memory_bytes: 256
s = list(input())
a = int(s[0] + s[1])
b = int(s[2] + s[3])

if (a == 0 or 13 <= a <= 99) and (b != 0 and 1 <= b <= 12):
    print("YYMM")
elif (1 <= a <= 12) and (b == 0 or 13 <= b <=99):
    print("MMYY")
elif 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")
else:
    print("NA")


Measured memory_bytes: 3060
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>


using namespace std;
typedef long long int ll;


int main() {
    ll ans;
    cin >> ans;
    cout << (24 - ans) + 24 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    string t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;
    if(s==u)
    {
        a--;
    }
    else
    {
        b--;
    }
    cout<<a<<" "<<b;
    
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, D, X;
	cin >> N >> D >> X;
	int eaten = N;
	REP(i, 0, N){
		int j = 1;
		int n;
		cin >> n;
		while(j*n + 1 <= D){
			eaten +=1;
			++j;
		}
	}
	cout << eaten + X;

}


Measured memory_bytes: 256
#include <iomanip>
#include <iostream>
#include <numeric>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int K;
  cin >> K;
  int answer = 0;
  for (int a = 1; a <= K; ++a) {
    for (int b = 1; b <= K; ++b) {
      for (int c = 1; c <= K; ++c) {
        answer += std::gcd(a, std::gcd(b, c));
      }
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
long long n,m;
int main()
{
    cin>>n>>m;
    if(n<=m)
    {
        cout<<min(n,m-n);
    }
    else
    {
        long long x=n%m;
        cout<<min(x,m-x);
    }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.InputStream;

import java.io.PrintWriter;

import java.util.TreeSet;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);

        final int N = nextInt();

        TreeSet<Integer> s = new TreeSet<>();

        int sum = 0;

        for (int i = 0; i < N; i++) {
            int tmp = nextInt();
            s.add(tmp);
            sum += tmp;
        }

        if (sum % 10 != 0) {
            out.println(sum);
            out.flush();
            return;
        }

        boolean flg = true;

        for (int x : s) {
            if (x % 10 == 0) continue;

            sum -= x;
            flg = false;
            break;
        }

        out.println(flg ? 0 : sum);

        out.flush();
    }

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


Measured memory_bytes: 23124
A, B, C, K = map(int, input().split())

sum=0

if A>K:
    sum += K
    K = 0
else:
    sum += A
    K = K-A

if B>K:
    K = 0
else:
    K = K-B

if C>K:
    sum -= K
    K = 0
else:
    sum -= C
    K = K-C

print(sum)

Measured memory_bytes: 61804
N, C, K = map(int, input().split())
bus_count = 0
waiting_count = 0
time_limit = 0
D = [int(input()) for _ in range(N)]
D.sort()
# C == 1の場合にあロジックが崩壊してしまうわ
for i in range(N):
    T = D[i]
    waiting_count += 1
    if T > time_limit and not time_limit == 0:
        time_limit = T + K
        bus_count += 1
        waiting_count = 1
    if waiting_count == C:
        bus_count += 1
        waiting_count = 0
        time_limit = 0
    else:
        if waiting_count == 1:
            time_limit = T + K

if not waiting_count == 0:
    print(bus_count+1)
else:
    print(bus_count)


Measured memory_bytes: 7392
from collections import deque


def solve(string):
    n, *ab = map(int, string.split())
    e = [[] for _ in range(n + 1)]
    # q = deque([1])
    q = [1]
    c = [0] * (n + 1)
    for a, b in zip(*[iter(ab)] * 2):
        e[a].append(b)
    while q:
        s = q.pop(0)
        d = 0
        for t in e[s]:
            d += 1 + (d + 1 == c[s])
            c[t] = d
            q.append(t)
    return str("{}\n{}".format(max(c), "\n".join(str(c[b]) for _, b in zip(*[iter(ab)] * 2))))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


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

int main(void){
  while(1){
    int stone[50];
    for(int k = 0 ; k < 50 ; k++){stone[k] = 0;}

    int bowl;
    int n, p;  // n：候補者人数，p：小石の総数
    cin >> n;
    cin >> p;

    if(n == 0 && p == 0){return 0;}

    bowl = p;

    bool flg = true;
    int ans;

    for(int i = 0 ; flg ; i = (i+1) % n){

      if(bowl == 0){
        bowl = bowl + stone[i];
        stone[i] = 0;
      }else{
        stone[i]++;
        bowl--;
        if(bowl == 0 && stone[i] == p){ans = i; flg = false;}
      }
    }

    for(int i = 0 ; i < 10000000 ; i++){
        for(int j = 0 ; j < 10000000 ; j++){
            for(int k = 0 ; k < 10000000 ; k++){
                int K = i + j + k;
            }
        }    
    }


    cout << ans << endl;
  }
}



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

/*------------------------------------------------------------------*/

#define ll long long int
#define mp make_pair
#define pb push_back
#define MOD 1000000007

bool isvowel(char c)
{
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        return true;
        return false;
}
ll isprime(ll n)
{
    ll ans=1;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            ans = i;
    }
    return ans;
}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    if(b==1)
        return a%m;
    ll temp=power(a,b/2,m);
    if(b%2==0)
        return ((temp%m)*(temp%m))%m;
    else
        return ((((temp%m)*(temp%m))%m)*a%m)%m;
}

/*-----------------------------------------------------------------------------*/

ll c(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;

    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {

            if (j == 0 || j == i)
                C[i][j] = 1;

            else
                C[i][j] = (C[i - 1][j - 1]%MOD +
                          C[i - 1][j])%MOD;
        }
    }
    return C[n][k]%MOD;
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {

        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;


        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
ll func(ll n)
{
    ll ans=0;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            if(i/10==0)
                ans+=1+func(i)*func(n/i);
            else
                ans+=func(i)*func(n/i);
        }
    }
    return ans;
}
ll dp[2001][2001];
ll check(vector<pair<ll,ll> >v,ll l,ll r,ll i)
{ 
   //cout<<l<<" "<<r<<endl;
   if(l>r)
    return 0; 
   if(dp[l][r]!=-1)
    return dp[l][r]; 
   ll ans=0;
   ll p1=v[i].first;
   ll p2=v[i].second;
   ans=max(p1*(p2-l)+check(v,l+1,r,i+1),p1*(r-p2)+check(v,l,r-1,i+1));
   return dp[l][r]=ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    //freopen("1.txt","rt",stdin);
    //freopen("output.txt","wwt",stdout);

    ll t;
    t=1;
    //cin>>t;
    //ll t1=0;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        if(abs(n-k)>n)
        {
          cout<<n;
        }
        else
        {
          if(n>=k)
          {
            ll p=n/k;
            ll zero=0;
            if(n%k==0)
             cout<<zero;
            else
            {
                cout<<min(n-p*k,abs(n-p*k-k));
            }
          }
          else
          {
              cout<<k-n;
          }
        }
    }
}


Measured memory_bytes: 3672
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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 solve(int n, const int K) {
    int ans = 0;
    while (n > 0) {
        ans++;
        n /= K;
    }
    return ans;
}

int main(void) {
    int N, K;
    cin >> N >> K;

    cout << solve(N, K) << endl;

    return 0;
}


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

int main(){
    int N;
    cin >>N;
    vector<string>vec(N);
    for(int i=0;i<N;i++){
        cin >>vec.at(i);
    }
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(vec.at(i)==vec.at(j)){
                cout <<"No"<<endl;
                return 0;
            }
        }   
    }
    for(int i=0;i<N-1;i++){
        int a;
      a=vec.at(i).size();//最後の文字をとっている
      if(vec.at(i).at(a-1)!=vec.at(i+1).at(0)){
          //vec.at(i+1).at(0)最初の文字
          cout << "No"<<endl;
          return 0;
      }
    }
    cout <<"Yes"<<endl;
}

Measured memory_bytes: 3616
N,M = map(int,input().split())
es = [[] for i in range(N)]
for i in range(M):
    l,r,d = map(int,input().split())
    l,r = l-1,r-1
    es[l].append((r,d))
    es[r].append((l,-d))

dist = [None] * N
for i in range(N):
    if dist[i] is not None: continue
    dist[i] = 0
    stack = [i]
    while stack:
        v = stack.pop()
        for to,d in es[v]:
            if dist[to] is None:
                dist[to] = dist[v] + d
                stack.append(to)
            else:
                if dist[to] != dist[v] + d:
                    print('No')
                    exit()
print('Yes')


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

int main(){
    int N;
    cin >> N;
    int cnt = 0;
        for(int i = 1; i <= N; i += 2){ 
            int cnt_2 = 0;            
                for(int j = 1; j <= i; j++){                    
                     if(i % j == 0) cnt_2++;
                }    
        if(cnt_2 == 8) cnt++;
        }
cout << cnt << endl;
return 0; 
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD ((ll)1e9+7)
ll N;
ll m,ans,F[1010101];
ll i, j, k;
ll moddiv(ll a,ll b){
    a %= MOD;
    b %= MOD;
    for(ll m=MOD-2;m>0;m/=2){
        if(m&1){
            a=a*b%MOD;
        }
        b=b*b%MOD;
    }
    return a;
}
int main(){
    //printf("%lld\n", MOD);
    scanf("%lld", &N);
    F[0] = 1;
    fornum(i,0,N+1){
        F[i + 1] = F[i] * (i + 1) % MOD;
    }
    m = 0;
    fornum(k,(N+1)/2,N){
        ll a=moddiv(F[k-1],F[N-k-1]*F[k*2-N]);
        a = a * F[k] % MOD;
        a = a * F[N-1-k] % MOD;
        ans = (ans + (MOD+a-m)%MOD*k%MOD) % MOD;
        m = a;
        //printf("%lld %lld %lld %lld\n",k, moddiv(F[k-1],F[N-k-1]*F[k*2-N]),F[N-1-k],ans);
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, x, y;
    int ans[2001] = {};
    cin >> n >> x >> y;
    for(int i = 1 ; i < n ; i++)
        for(int j = i + 1 ; j <= n ; j++){
            int dist = j - i;
            dist = min(dist, abs(j - y) + abs(x - i) + 1);
            dist = min(dist, abs(j - x) + abs(y - i) + 1);
            ans[dist] += 1; 
        }
    for (int i = 1 ; i < n ; i++)
        printf("%d\n", ans[i]);
        
}


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

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long int x,k,d;
	cin>>x>>k>>d;
	if(x==0)
	{
		if(k%2==0)
			cout<<0<<endl;
		else
			cout<<d<<endl;
	}
	else 
	{
		x=abs(x);
		long long int t=x/d;
		if(t<=k)
		{
			long long int p=x-d*t;
			if((k-t)%2==0)
				cout<<p<<endl;
			else
				cout<<abs(p-d)<<endl;
		}
		else
		{
			long long int p=x-d*k;
			cout<<p<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3648
/*input
5
6 7 9 10 31

*/
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)cin>>arr[i];
    int flag=0;
    for(ll i=0;i<n;i++){
    	if(arr[i]%2==0 && (arr[i]%3!=0 && arr[i]%5!=0))flag=1;
    }
    if(flag==0)cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    int y; cin >> y;
    y /= 1000;
    for (int i = 0; 10*i <= y; i++) {
        for (int j = 0; 10*i+5*j <= y; j++) {
            int x = y-(10*i+5*j);
            if (n-x == i+j) {
                cout << i << " " << j << " " << x << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
static const double pi = 3.141592653589793;

int main()
{
    ll n, l, r, count = 0;

    cin >> n;
    l = 0;
    r = n - 1;
    string s;
    cin >> s;
    while (l < r)
    {
        if (s[l] == 'W' && s[r] == 'R')
        {
            l++;
            r--;
            count++;
        }
        else if (s[l] == 'W')
        {
            r--;
        }
        else if (s[r] == 'R')
        {
            l++;
        }
        else
        {
            l++;
            r--;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long n, long long m)
{
    if (n % m == 0) {
        return m;
    } else {
        return gcd(m, n % m);
    }
}
long long lcm(long long n, long long m)
{
    return n * m / gcd(n, m);
}
int main()
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long e = lcm(c, d);
    cout << (b - a + 1) - (b / c - a / c + (a % c == 0 ? 1 : 0)) - (b / d - a / d + (a % d == 0 ? 1 : 0)) + (b / e - a / e + (a % e == 0 ? 1 : 0)) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            ans += a - 1;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 25412
#!/usr/bin/env python3
from copy import deepcopy
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]

last = {}
for i in range(26):
    last[i] = -1

s = 0
for d in range(D):
    ret = 0
    sr = {}
    for c in range(26):
        last_cp = deepcopy(last)
        s_cp = deepcopy(s)
        last_cp[c] = d
        s_cp += S[d][c]
        for i in range(26):
            s_cp -= C[i] * (d-last[i])
        sr[c] = s_cp
    sr = sorted(sr.items(), key=lambda x:x[1])
    s += sr[-1][1]
    ret = sr[-1][0]
    print(ret+1)


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

using namespace std;

struct sec{
    int s,t;
};

struct event{
    int type;//0:cut +1:begin(on) +2:begin(off) +3:end(on) +4:end(off)
    int x;
    event(int type, int x){
        this->type=type,this->x=x;
    }
};

int main(){
    int N,M;
    cin>>N>>M;
    sec S[N];
    int C[M];
    for(auto&s:S) scanf("%d %d",&s.s,&s.t);
    for(auto&c:C) scanf("%d",&c);

    vector<event> E;
    for(auto&c:C) E.emplace_back(event(0,c));
    sort(C,C+M);
    long long sum=0;

    for(auto&s:S){
        auto lo=lower_bound(C,C+M,min(s.s,s.t));
        auto up=upper_bound(C,C+M,max(s.s,s.t));
        if(lo==up){
            sum+=abs(s.s-s.t);
            continue;
        }
        if(s.s<s.t){
            sum+=*lo-s.s;
            E.emplace_back(event(2,*lo));
            if((up-lo)%2==0){
                sum+=s.t-*(up-1);
                E.emplace_back(event(4,*(up-1)));
            }else{
                E.emplace_back(event(3,*(up-1)));
            }
        }else{
            sum+=s.s-*(up-1);
            E.emplace_back(event(4,*(up-1)));
            if((up-lo)%2){
                E.emplace_back(event(1,*lo));
            }else{
                E.emplace_back(event(2,*lo));
                sum+=*lo-s.t;
            }
        }
    }
    sort(E.begin(),E.end(),[](const event& a, const event& b){return a.x==b.x?a.type<b.type:a.x<b.x;});

    int on_n=0,off_n=0;
    for(auto e=E.begin();e!=E.end();e++){
        // cout << e->x << " " << e->type << endl;
        switch(e->type){
            case 0:
                if(on_n)sum+=(long long int)on_n*(e->x - (e-1)->x);
                swap(on_n,off_n);
                break;
            case 1:
                on_n++;
                break;
            case 2:
                off_n++;
                break;
            case 3:
                off_n--;
                break;
            case 4:
                on_n--;
                break;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 8292
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 1000000007;

LL n,a[405];
LL pre[405] = {0};
LL dp[405][405] = {0};

int main(){
	memset(dp,0x3f,sizeof(dp));
	scanf("%lld",&n);
	for(LL i = 1;i <= n;i ++){
		scanf("%lld",&a[i]);
		dp[i][i] = 0;
		pre[i] = pre[i - 1] + a[i];
	}
	for(LL l = 1;l < n;l ++){
		for(LL i = 1;i < n;i ++){
			LL j = i + l; if(j > n) break;
			for(LL k = i;k < j;k ++) dp[i][j] = min(dp[i][j],dp[i][k] + dp[k + 1][j] + pre[j] - pre[i - 1]);
		}
	}
	printf("%lld\n",dp[1][n]);
	return 0;
}

Measured memory_bytes: 1536
import numpy as np
n,m,c = list(map(int,input().split()))
b = list(map(int,input().split()))
a = [list(map(int,input().split())) for _ in range(n)]

b = np.array(b)
ans = 0
for i in range(n):
    ch = 0
    t_a = np.array(a[i])
    if sum(t_a*b) + c > 0:
        ans += 1

print(ans)

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
// end of Template

int n,a,b;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<newl;

}


Measured memory_bytes: 256
class Parenter:
    def __init__(self):
        self.left = 0
        self.right = 0
        self.data = ""

    def _run(self, letter):
        if letter == "(":
            self.data += "("
            self.left += 1
        if letter == ")":
            if self.left > 0:
                self.left -= 1
                self.data += ")"
            else:
                self.right += 1
                self.data += ")"
    
    def run(self, string):
        for s in string:
            self._run(s)
        self.data = "("*self.right + self.data + ")"*self.left
    

p = Parenter()
N = input()
data = input()
p.run(data)
print(p.data)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n;
    in(n);
    vector<ll> t(n);
    in(t);
    ll ans,divide;
    rep(i,n){
        if(i==0)ans=t[i];
        else{
            divide=__gcd(ans,t[i]);
            if(t[i]%divide==0)ans=ans*(t[i]/divide);
            else if(ans%divide==0)ans=t[i]*(ans/divide);
            else ans=ans*t[i]/divide;
        }
    }
    out(ans);
}


Measured memory_bytes: 3760
import std.stdio;
import std.algorithm;
import std.container;
import core.stdc.stdio;
import std.typecons;

int n,k;
int[][] sg;
int[][] graph;

int[2][] queue;
bool[] visited;

int gSize=0;
void buildGraph(int idx,int r){
	visited[] = false;
	int qc=0;
	visited[idx]=true;
	foreach(c;sg[idx]){
		queue[qc++] = [1,c];
		visited[c]=true;
	}
	for(int i=0;i<qc;i++){
		int s=queue[i][0];
		int p=queue[i][1];
		if(s>r)
			return;
		graph[idx] ~= p;
		gSize++;
		foreach(c;sg[p]){
			if(!visited[c]){
				visited[c] = true;
				queue[qc++] = [s+1,c];
			}
		}
	}
}

void main(){
	scanf("%d%d",&n,&k);
	graph = new int[][n];
	sg = new int[][n];
	int[] cs=new int[n];
	int[] rs=new int[n];
	queue = new int[2][n];
	visited = new bool[n];
	for(int i=0;i<n;i++){
		scanf("%d%d",&cs[i],&rs[i]);
	}
	for(int i=0;i<k;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		sg[--a] ~= --b;
		sg[b] ~= a;
	}
	for(int i=0;i<n;i++){
		buildGraph(i,rs[i]);
	}
	visited[] = false;
	alias Tuple!(int,"cost",int,"idx") ci;
	alias BinaryHeap!(ci[],"a>b") pq;
	pq q = pq(new ci[gSize+1],0);
	q.insert(ci(0,0));
	int ans;
	while(1){
		ci s = q.front;
		q.removeFront;
		if(s.idx==n-1){
			ans=s.cost;
			break;
		}
		if(visited[s.idx])
			continue;
		visited[s.idx]=true;
		foreach(c;graph[s.idx]){
			if(!visited[c]){
				q.insert(ci(s.cost+cs[s.idx],c));
			}
		}
	}
	
	printf("%d\n",ans);
}

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

int main(void)
{
    long long int N, i, min, hoge;
    
    scanf("%lld",&N);
    
    min=N;
    
    for(i=1; i<=sqrt(N); i++){
        if((N%i == 0) && (min > (N/i))){
            min = N/i;
        }
    }
    
    hoge = N/min-1;
    
    printf("%lld\n",min+hoge-1);
    
    return 0;
}

Measured memory_bytes: 256
# coding: UTF-8
r,c = map(int,raw_input().split(" "))
mtrix = [map(int,raw_input().split()) for i in range(r)]
last_line = [0 for i in range(c+1)]
for i in range(r):
    mtrix[i].append(sum(mtrix[i]))
    last_line = [x+y for (x,y) in zip(mtrix[i],last_line)]
mtrix.extend([last_line])
for i in range(r+1):
    print " ".join(map(str,mtrix[i]))




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


int main()
{
	double s;
	while (cin >> s){
		for (int i = 1;; i++){
			double h = 5 * i - 5;
			double v = sqrt(2 * 9.8 * h);
			if (v >= s){
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1224
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, s);
    ll ans = 0;
    FOR(c, s)
    {
        ans += c - '0';
    }
    OUT(ans);
}

Measured memory_bytes: 3600