akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int a[maxn];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    rep(i,1,n){cin>>a[i];}
    int q;cin>>q;
    while(q--){
        int k;
        cin>>k;
        cout<<lower_bound(a+1,a+1+n,k)-a-1<<' '<<upper_bound(a+1,a+1+n,k)-a-1<<endl;
    }
}
/* 
4
1 2 2 4
3
2
3
5
 */


Measured memory_bytes: 3608
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        h: i64, a: i64,
    }
    puts!("{}\n", (h + a - 1) / a);
}

fn main() {
    // 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(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;

int main(){
    int64_t A, B, C;
    cin >> A >> B >> C;
    cout << max(A - C, (int64_t)0) << " " << max(B - max((C - A), (int64_t)0), (int64_t)0) << endl;
}

Measured memory_bytes: 256
import numpy
N,K=(int(x) for x in input().split())
S=input()

def Solve(S,K):

    if S.count("0")<=K:
        return len(S)
    if S[0]=="1":
        S="0"+S
    

    LA=[]#立ってる人 = 0
    LB=[]#逆立ちしてる人 = 1
    k=-1
    current="0"
    appendLA=LA.append
    appendLB=LB.append
    for i,s in enumerate(S):
        k+=1
        if s!=current:
            if s=="0":
                appendLA(k)#逆立ちの個数 = 1
                current="0"
                k=0
            else:
                appendLB(k)#立ってる人個数 = 0
                current="1"
                k=0
    
    if current=="1":
        appendLA(k+1)
    else:
        appendLB(k+1)
        appendLA(0)
    mx=0
    if len(LA)<=K:
        return len(S)
    if K==0:
        return max(LA)

    sum_LA = list(numpy.cumsum(LA))
    sum_LB=list(numpy.cumsum(LB))
    

    for i in range(len(LA)-K+1):
        if i==0:
            result=sum_LA[K-1]+sum_LB[K-1]
        elif i==1:
            result=sum_LA[i+K-1]+sum_LB[i+K-1]-sum_LB[i-1]
        else:
            result=sum_LA[i+K-1]-sum_LA[i-2]+sum_LB[i+K-1]-sum_LB[i-1]
        mx=max(mx,result)

    return mx

print(Solve(S,K))


Measured memory_bytes: 20804
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

// ティツ、ツ?ヲツ閉ーテヲツ鳴?・ツュツ耀plit
vector<string> split(const string &str, const string &delim = " ") {
    size_t start = 0, pos;
    vector<string> result;
    
    while ( (pos = str.find_first_of( delim, start) ) != string::npos ) {
        if (pos - start != 0)
            result.push_back( str.substr( start, pos - start) );
        start = pos + 1;
    }
    if (str.size() - start != 0)
        result.push_back( str.substr( start, str.size() - start ) );

    return result;
}

int main(void) {
	string s;
	getline(cin, s);

	vector<string> sp = split(s, ",. ");

	vector<string> ans;
	for (auto &str : sp) {
		int sz = str.size();
		if (3 <= sz && sz <= 6) {
			ans.push_back(str);
		}
	}

	for (int i = 0; i < (int)ans.size(); i++) {
		cout << ans[i] << (i + 1 == (int)ans.size() ? '\n' : ' ');
	}

	return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
typedef long long int LLI;
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
LLI gcd(LLI n,LLI m){
  while(m){
    n=n%m;
    swap(n,m);
  }
  return n;
}
int main(){
  LLI n,m;
  while(cin>>n>>m){
    LLI ans=gcd(n,m);
    cout<<ans<<" "<<ans*(n/ans)*(m/ans)<<endl;
  }
}

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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

	int p = 0;
	while (k > 1 && s[p] == '1') p++, k--;
	cout << s[p] << endl;
}


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

using namespace std;

int n, A[50];

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

int main(void) {
  int q;
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  cin >> q;
  for (int i = 0; i < q; i++) {
    int M; cin >> M;
    if (solve(0, M))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
}



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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  if (A + B < C + D) {
    cout << "Right" << endl;
  }
}


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

/*連続する正の整数の組合せを求める*/
int Search_Consecutive_Integers(int n)
{
  int count = 0;

  for(int i = 1; 2 < n; i++) {
    n = n - i;
      if(n % (i + 1) == 0) {
        if(n >= 2)
          count++;
      }
  }
  return count;
}

int main()
{
  int num;

  while(1) {
    cin >> num;
    if(num <= 0)
      break;
    cout << Search_Consecutive_Integers(num) << endl;
  }

  return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    A.at(i) = x;
  }
  sort(A.begin(), A.end());
  int sum1 = 0;
  int sum2 = 0;
  for (int i = 0;; i += 2) {
    if (i >= N ) {
      break;
    }
    sum1 += A.at(N-1-i);
    if (i >= N-1) {
      break;
    }
    sum2 += A.at(N-2-i);
  }
  cout << sum1 - sum2 << endl;  
}

Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    boolean[] sunukes = new boolean[n];
    for (int i = 0; i < k; i++) {
      int d = sc.nextInt();
      for (int j = 0; j < d; j++) {
        sunukes[sc.nextInt() - 1] = true;
      }
    }
    int ans = 0;
    for (boolean hasSweets : sunukes) {
      if (hasSweets) continue;
      ans++;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 46484
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
const ll mod=998244353;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
struct node{
	ll x,d;
	bool operator<(const node &t)const{
		return x<t.x;
	}
};
node a[N];
stack<node>s;
int n;
ll dp[N];
int main(){
	read(n);
	for(int i=1;i<=n;i++)read(a[i].x),read(a[i].d);
	sort(a+1,a+1+n);
	dp[n+1]=1;
	for(int i=n;i;i--){
		int t=a[i].x+a[i].d;
		int idx=i+1;
		while(!s.empty()&&t>a[s.top().x].x){
			idx=s.top().d;
			s.pop();
		}
		node tmp;tmp.x=i;tmp.d=idx;
		s.push(tmp);
		dp[i]=(dp[i+1]+dp[idx])%mod;
	}
	cout<<dp[1]<<endl;
	return 0;
}


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

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

    vector<string> s(n);
    vector<int> t(n);
    rep(i, n) {
        cin >> s.at(i);
        cin >> t.at(i);
    }

    string x; cin >> x;
    bool flg = false;
    int ans = 0;
    rep(i, n) {
        if (flg == false && x == s.at(i)) {
            flg = true;
            continue;
        }

        if (flg == true) {
            ans += t.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> P(M), Y(M);
    for (int i = 0; i < M; i++) {
        cin >> P[i] >> Y[i];
    }

    // vals[v] := P[i] = v であるようなiについてのY[i]の値を集めたもの
    vector<vector<int>> vals(N+1);
    for (int i = 0; i < M; i++) {
        vals[P[i]].push_back(Y[i]);
    }

    for (int v = 0; v <= N; v++) {
        sort(vals[v].begin(), vals[v].end());

        //今回は不要だが通常は数のダブりをなくす
        vals[v].erase(unique(vals[v].begin(), vals[v].end()), vals[v].end());
    }

    //答え
    for (int i = 0; i < M; i++) {
        int v = P[i];
        printf("%06d", v);

        //座標圧縮して導いた答え
        int id = lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin();
        printf("%06d\n", id+1);
    }
    return 0;
}

Measured memory_bytes: 7808
#include<iostream>

using namespace std;

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

int n, x, m;
int l[10], r[10], s[10];
int num[10];
int res = -1;
int rs[10];

void solve(int i) {
  if (i == n) {
    rep (i, m) {
      int cnt = 0;
      for (int j = l[i]; j <= r[i]; ++j) cnt += num[j];
      if (cnt != s[i]) return;
    }
    int cnt = 0;
    rep (i, n) cnt += num[i];
    if (res < cnt) {
      res = cnt;
      rep (i, n) rs[i] = num[i];
    }
    return;
  }
  rep (j, x + 1) {
    num[i] = j;
    solve(i + 1);
  }
}

int main() {
  cin >> n >> x >> m;
  rep (i, m) cin >> l[i] >> r[i] >> s[i];
  rep (i, m) --l[i], --r[i];
  solve(0);
  if (res == -1) {
    cout << -1 << endl;
    return 0;
  }
  rep (i, n) {
    cout << rs[i];
    if (i == n - 1) cout << endl;
    else cout << " ";
  }
}

Measured memory_bytes: 1160
r,c = map(int,input().split())
num=[]
r_sum =[]
for i in range(r):
    num.append([int(i) for i in input().split()])
for i in range(r):
    line_sum = 0
    for j in range(c):
        line_sum += num[i][j]
    num[i].append(line_sum)
for i in range(c+1):
    row_sum = 0
    for j in range(r):
        row_sum += num[j][i]
    r_sum.append(row_sum)
num.append(r_sum)
for i in range(len(num)):
    print(' '.join(str(i) for i in num[i]))


Measured memory_bytes: 5688
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000009;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
char c[22][22];
int w, h;
int sx, sy;
vector<P> v;
void init() {
	v.clear();
	rep(i, 22) {
		rep(j, 22) {
			c[i][j] = 'x';
		}
	}
	rep1(i, h) {
		rep1(j, w) {
			cin >> c[i][j];
			if (c[i][j] == 'o') {
				sx = i; sy = j;
			}
			else if (c[i][j] == '*') {
				v.push_back({ i,j });
			}
		}
	}
}
int d[22][22][22][22];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
void make_distance() {
	rep(i, 22) {
		rep(j, 22) {
			rep(k, 22) {
				rep(l, 22)d[i][j][k][l] = mod;
			}
		}
	}
	rep1(i, h) {
		rep1(j, w) {
			rep(k, 4) {
				int ni = i + dx[k], nj = j + dy[k];
				if (c[i][j] == 'x' || c[ni][nj] == 'x')continue;
				d[i][j][ni][nj] = 1;
			}
		}
	}
	rep1(k1, h) {
		rep1(k2, w) {
			rep1(i1, h) {
				rep1(i2, w) {
					rep1(j1, h) {
						rep1(j2, w) {
							d[i1][i2][j1][j2] = min(d[i1][i2][j1][j2], d[i1][i2][k1][k2] + d[k1][k2][j1][j2]);
						}
					}
				}
			}
		}
	}
}
bool valid() {
	rep(i, v.size()) {
		if (d[sx][sy][v[i].first][v[i].second] == mod)return false;
	}
	return true;
}
struct vertice {
	int id, use, dis;
	bool operator<(const vertice &v)const {
		if (v.dis != dis)return v.dis < dis;
		if (v.id != id)return v.id < id;
		return v.use < use;
	}
};
void run_bitdp() {
	int dp[10][1 << 10];
	int n = v.size();
	rep(i, n) {
		rep(j, (1 << n)) {
			dp[i][j] = mod;
		}
	}
	priority_queue<vertice> q;
	rep(i, n) {
		q.push({ i,(1 << i),d[sx][sy][v[i].first][v[i].second] });
		dp[i][1 << i] = d[sx][sy][v[i].first][v[i].second];
	}
	while (!q.empty()) {
		vertice x = q.top(); q.pop();
		if (x.use == (1 << n) - 1)continue;
		rep(i, n) {
			if (x.use&(1 << i))continue;
			int to = x.use ^ (1 << i);
			int nd = x.dis + d[v[x.id].first][v[x.id].second][v[i].first][v[i].second];
			if (nd < dp[i][to]) {
				dp[i][to] = nd; q.push({ i,to,nd });
			}
		}
	}
	int out = mod;
	rep(i, n) {
		out = min(out, dp[i][(1 << n) - 1]);
	}
	cout << out << endl;
}
int main(){
	while (cin >> w >> h, w) {
		init(); make_distance();
		if (!valid())cout << -1 << endl;
		else run_bitdp();
	}
	return 0;
}


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

int main(void)
{
    int n, cnt = 0;
    cin >> n;

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

	for ( int i = 1; i < n - 1; i++ ) {
		if(p[i-1] > p[i] && p[i] > p[i+1]) {
			cnt++;
		} else if(p[i-1] < p[i] && p[i] < p[i+1]) {
			cnt++;
		}
	}

    cout << cnt <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>//コンパイルコードは"g"をエイリアス登録してある
using namespace std;//なのでg xxx.cpp　とすればコンパイルできる
#define rep(i, n) for (int i=0; i<(n); i++)

int main(){
    int n; cin >> n;
    vector<string> data1(n), data2(n);
    for(int i=0; i<n; i++){
        cin >> data1[i];
        data2[i] = data1[i];
    }
    bool flag = true;
    int i=0;//ソート済みの配列の末端を持つ変数
    while(flag){
        flag = false;
        for(int j=n-1; j>i; --j){//最大位置から、ソート済みの配列の場所まで入れ替えていく
            if(data1[j][1] < data1[j-1][1]){
                swap(data1[j], data1[j-1]);
                flag = true;
            }
        }
    }
    for(int i=0; i<data2.size(); i++){
        int minj = i;
        for(int j=i; j<data2.size(); j++){
            if(data2[minj][1] > data2[j][1]){
                minj = j;
            }
        }
        if (minj != i){
            swap(data2[i], data2[minj]);
        }
    }
    for(int i=0; i<n; i++){
        cout << data1[i][0] << data1[i][1];
        if (i == n-1) cout << endl;
        else cout << " ";
    }
    cout << "Stable" << endl;
    for(int i=0; i<n; i++){
        cout << data2[i][0] << data2[i][1];
        if (i == n-1) cout << endl;
        else cout << " ";
    }
    if (data1 == data2) cout << "Stable" << endl;//配列は==演算子が使える
    else cout << "Not stable" << endl;
    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;      
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int N; cin >> N;
  vi H(N); rep(i,N) cin >> H.at(i);

  int ans = 1;
  int max_H = 0;
  repf(i,1,N) {
    max_H = max(max_H,H.at(i-1));
    if(max_H <= H.at(i)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int k, m;
long long c[301][301];
long long dp[301][301];

long long dfs(int x, int y) {
    int i;
    long long ans;
    
    if (x <= 0 || y == k) return 1;
    if (dp[x][y] >= 0) return dp[x][y];
    
    ans = dfs(x, y + 1);
    
    for (i = 0; i < x; i++) {
        long long p = dfs(i, y + 1);
        long long q = dfs(x - i - 1, y);
        
        ans += c[x][i] * p % m * q % m;
        if (ans >= m) ans -= m;
    }
    
    return dp[x][y] = ans;
}

int main() {
    int n, i, j;
    
    scanf("%d %d %d", &n, &k, &m);
    
    for (i = 0; i <= 300; i++) {
        c[i][0] = c[i][i] = 1;
        for (j = 1; j < i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % m;
    }
    
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= k; j++) {
            dp[i][j] = -1;
        }
    }
    
    printf("%lld\n", dfs(n, 1));
    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  for (int i=0; i<N; ++i) {
    cin >> V.at(i);
  }
  for (int i=0; i<N; ++i) {
    cin >> C.at(i);
  }
  
  int sum=0;
  int var;
  for (int i=0; i<N; ++i) {
    var = V[i] - C[i];
    if (var > 0) {
      sum += var;
    }
  }
  cout << sum << endl;
  return 0;
}





Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    cin>>N;
    int sum=0;
    vector<int> T(N);
    rep(i,N){
        cin>>T.at(i);
        sum+=T.at(i);
    }
    
    int M;
    cin>>M;
    vector<int> P(M),X(M);
    rep(i,M){
        cin>>P.at(i)>>X.at(i);
    }
    rep(i,M){
        cout<<sum-T.at(P.at(i)-1)+X.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N, C, K = map(int, input().split())

T = [int(input()) for _ in range(N)]

bus = []
indexes = [i for i in range(N)]
sorted_indexes = sorted(indexes, key=lambda i: T[i])

count = 0
for i in range(N):
    if count == 0:
        first = T[sorted_indexes[i]]
        count += 1
    else:
        if T[sorted_indexes[i]] - first <= K:
            count += 1
        else:
            bus.append(count)
            first = T[sorted_indexes[i]]
            count = 1
    if count >= C:
        bus.append(count)
        count = 0

if count > 0:
    bus.append(count)

print(len(bus))

Measured memory_bytes: 13396
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 50;
int N;
int A[MAX_N], B[MAX_N];
bool S[MAX_N+1];

ll pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = pow(x*x, n/2);
  if (n & 1) res *= x;
  return res;
}

const int MAX_V = 51, INF = 1e9;
int V = MAX_V;
int d[MAX_V][MAX_V];

void warshall_floyd() {
  for (int k = 0; k < V; ++k) {
    for (int i = 0; i < V; ++i) {
     for (int j = 0; j < V; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];
  for (int i = 0; i < N; ++i) cin >> B[i];

  fill(S+1, S+50, true);


  for (int i = 49; i >= 0; --i) {

    // iより大きいtrueの数と、i以下の数でグラフを作る
    fill(d[0], d[0]+V*V, INF);
    for (int i = 0; i <= 50; ++i) d[i][i] = 0;
    for (int i = 0; i <= 50; ++i) {
      for (int k = 1; k <= 49; ++k) {
        if (S[k]) { d[i][i%k] = 1; }
      }
    }

    // A[i]からB[i]にたどり着けるかどうか判定
    warshall_floyd();
    bool ok = true;
    for (int i = 0; i < N; ++i) {
      if (d[A[i]][B[i]] >= INF) ok = false;
    }

    // 全て書き換え可能ならS[i]をfalse、書き換え不可能ならS[i+1]をtrue。
    if (!ok) S[i+1] = true;
    S[i] = false;
  }

  if (S[50]) {
    cout << -1 << endl;
  } else {
    ll ans = 0;
    for (int k = 1; k < 50; ++k) if (S[k]) { ans += pow(2, k); }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val a = readInputLine().toCharArray()
    val b = readInputLine().toCharArray()
    
    if (a.size > b.size) {
        println("GREATER")
        return
    }
    if (b.size > a.size) {
        println("LESS")
        return
    }

    for (i in 0 until a.size) {
        if (a[i] > b[i]) {
            println("GREATER")
            return 
        }
        if (b[i] > a[i]) {
            println("LESS")
            return
        }
    }

    println("EQUAL")
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 33396
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int dp[200][200];
int a[1234], b[1234], c[1234];
signed main() {
	int n, m; cin >> n >> m;
	for1(i, n)for1(j, n)dp[i][j] = (i == j ? 0 : mod);
	for1(i, m) {
		cin >> a[i] >> b[i] >> c[i]; dp[a[i]][b[i]] = c[i]; dp[b[i]][a[i]] = c[i];
	}
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
	int ans = 0;
	for1(i, m) if (dp[a[i]][b[i]] < c[i])ans++;
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, P; cin >> N >> P;
    int cnt[2] = {};
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        cnt[a%2]++;
    }
    if (P == 1 && cnt[1] == 0) {
        cout << 0 << endl;
    } else {
        cout << (1LL << (N - !!cnt[1])) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <set>

int main()
{
  int n;
  scanf("%d", &n);
  int p[100000];
  int idx[100000];
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", p + i);
    p[i]--;
    idx[p[i]] = i;
  }
  std::set<int> set;
  long long ans = 0;
  for (int x = n - 1; x >= 0; --x)
  {
    int i = idx[x];
    set.insert(i);
    long long pos[] = {-1, -1, n, n};
    {
      auto it = set.find(i);      
      for (int j = 1; j >= 0; --j)
      {
        if (it == set.begin()) break;
        --it;
        pos[j] = *it;
      }
    }
    {
      auto it = set.find(i);
      for (int j = 2; j < 4; ++j)
      {
        ++it;
        if (it == set.end()) break;
        pos[j] = *it;
      }
    }
    long long c = (i - pos[1]) * (pos[3] - pos[2]) + (pos[2] - i) * (pos[1] - pos[0]);
    ans += (x + 1) * c;
  }
  printf("%lld\n", ans);
  return 0;
}


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

using ll = long long;

int  kaibun(string s){
  int size = s.size();
  for(int i=0; i<=(size-1)/2; i++){
    if(s[i]!=s[size-i-1]){
      return false;
    }
  }
  return true;
}

int main(){
  string S;
  cin >> S;
  int N = S.size();

  bool All,L,R;
  All = kaibun(S);

  string SL,SR;
  SL = S.substr(0, ((N-1)/2));
  SR = S.substr((N+1)/2);
  L = kaibun(SL);
  R = kaibun(SR);

  bool tsuyoikaibun = All && L && R;

  //cout << SL << endl;
  //cout << R << endl;
  cout << ( tsuyoikaibun ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
<?php
  list($d, $n) = explode(" ", trim(fgets(STDIN)));

  if($d == 0){
    if($n == 100) echo 101;
    else echo $n;
  }else if($d == 1){
    if($n == 100) echo 10100;
    else echo $n * 100;
  }else if($d == 2){
    if($n == 100) echo 1010000;
  	else echo $n * 10000;
  }

Measured memory_bytes: 16200
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn skip_same(s: &[char]) -> bool {
    let f = &s[0];
    for (i, c) in s.iter().enumerate() {
        if i % 2 == 0 && c != f {
            return false;
        }
    }
    true
}

fn main() {
    let s = scan!().chars().collect::<Vec<_>>();
    if skip_same(&s) && skip_same(&s[1..]) {
        println!("Second");
        return;
    }
    if (s.len() - if s.first() == s.last() { 3 } else { 2 }) % 2 == 1 {
        println!("First")
    } else {
        println!("Second")
    }
}


Measured memory_bytes: 4352
function Main(input) {
    var lines = input.split("\n");
    var N = parseInt(lines[0]);
    var a = lines[1].split(" ").map(function(i) { return parseInt(i);});
    var sortedA = a.slice().sort(function(a,b) { return a - b;});
    var med1 = sortedA[N/2-1];
    var med2 = sortedA[N/2];
    a.forEach(function(i) {console.log(i<=med1 ? med2 : med1);})
}
 
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 40720
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n;
ll a[2010],mn[2010][2010],x,ans;
int main()
{
	scanf("%d%lld",&n,&x);
	for (int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for (int i=0;i<n;i++)
	{
		mn[i][i]=a[i];
		for (int j=1;j<n;j++)
		{
			mn[i][(i+j)%n]=min(mn[i][(i+j-1)%n],a[(i+j)%n]);
		}
	}
	ans=1e18;
	for (int i=0;i<n;i++)
	{
		ll now=x*i;
		for (int j=0;j<n;j++)
		{
			now+=mn[j][(j+i)%n];
		}
		ans=min(ans,now);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 31616
#include<cstdio>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int s;

int main()
{
	while( scanf( "%d", &s ), s )
	{
		rep( i, 9 )
		{
			int a;
			scanf( "%d", &a );
			s -= a;
		}

		printf( "%d\n", s );
	}

	return 0;
}

Measured memory_bytes: 1028
n=int(input())
l=list(map(int,input().split()))
d=list(map(int,input().split()))
k=list(map(int,input().split()))
s=sum(d)
for i in range(n-1):
    if(l[i]+1==l[i+1]):
        s+=k[l[i]-1]
print(s)


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

def z(x,  y,  x1,  y1,  x2,  y2):
    if (x1 > x2):x1,x2=x2,x1;y1,y2=y2,y1
    return x1 <= x and x <= x2 and ((y1 <= y2 and y1 <= y and y <= y2) | (y1 > y2 and y2 <= y and y <= y1)) and (y-y1)*(x2-x1) == (y2-y1)*(x-x1);

for i in range(n):
    a,b,c,d,e,f,g,h = map(int, input().split())
    
    p = d-b
    q = c-a
    r = h-f
    s = g-e
    
    t = (f-b)*q - (e-a)*p
    u = (h-b)*q - (g-a)*p
    
    v = (b-f)*s - (a-e)*r
    w = (d-f)*s - (c-e)*r

    if (t*u<0 and v*w<0) | z(a,b,e,f,g,h) | z(c,d,e,f,g,h) | z(e,f,a,b,c,d) | z(g,h,a,b,c,d):
        print(1)
    else:
        print(0)


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for(int i=0; i<=100; i++){
    for(int j=0; j<=100; j++){
      if(n == i*4 + j*7){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
n=int(input())
adj=[]
for i in range(n):
      adj.append(list(map(int, input().split())))

a=[[0 for i2 in range(n)]for i1 in range(n)]

for i in range(n):
    for j in range(adj[i][1]):
        a[i][adj[i][j+2]-1]=1

    for j in range(n):
        if j ==n-1:
            print(a[i][j])
        else:
            print(a[i][j], end=" ")

Measured memory_bytes: 8492
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        int i = 1;
        while(true) {
            int n = num.nextInt();
            if (n == 0) break;
            System.out.println("Case " + i + ": " + n);
            i++;
        }
    }
}


Measured memory_bytes: 40596
using System.Collections.Generic;
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var param = ReadLine().Split(' ').Select(int.Parse).ToArray();
    var n = param[0];
    var c = param[2];
    var b = ReadLine().Split(' ').Select(int.Parse).ToArray();

    var ans = Enumerable.Range(0, n).Select(_ =>
      {
        var sum = ReadLine().Split(' ').Select(int.Parse)
          .Select((a, i) => a * b[i]).Sum();
        return (sum + c > 0) ? 1 : 0;
      }
    ).Sum();

    WriteLine(ans);
  }
}

Measured memory_bytes: 13396
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]
flag = False
for i in range(N-M+1):
  for j in range(N-M+1):
    tmp = True
    for k in range(i,i+M):
      if A[k][j:j+M] != B[k-i]:
        tmp = False
    if tmp:
      flag = True
      break
  if flag:
    break
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

struct mint {
    ll x;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    ll value() const {
        return x;
    }
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (t == 0) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t % 2 == 1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = fact[i - 1] * i;
        }
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; i--) {
            ifact[i - 1] = ifact[i] * i;
        }
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint h(int n, int k) {
        n += k - 1;
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(2002002);

int main() {
    int a, b, c, d;
    cin >> a >> c >> b >> d;
    mint ans = 0;
    ans += comb(a + c, c);
    ans -= comb(a + d + 1, d + 1);
    ans -= comb(b + c + 1, c);
    ans += comb(b + d + 2, d + 1);
    cout << ans.value() << endl;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
     ll n;
     cin>>n;
     string s[n];
     ll a=0;
     ll b=0;
     ll c=0;
     ll d=0;
     for(ll i=0;i<n;i++){
         cin>>s[i];
         if(s[i]=="AC"){
             a++;
         }
         if(s[i]=="WA"){
             b++;
         }
         if(s[i]=="TLE"){
             c++;
         }
         if(s[i]=="RE"){
             d++;
         }
     }
     cout<<"AC"<<" "<<"x"<<" "<<a<<endl;
          cout<<"WA"<<" "<<"x"<<" "<<b<<endl;
               cout<<"TLE"<<" "<<"x"<<" "<<c<<endl;
                    cout<<"RE"<<" "<<"x"<<" "<<d<<endl;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int b_digit = log10(b);
	int num = a * pow(10, b_digit + 1) + b;
	if ((int)sqrt((double)num) == sqrt((double)num)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 512
import numpy as np
import fractions
from functools import reduce
from sys import stdin
N=int(stdin.readline().rstrip())
data=[int(x) for x in stdin.readline().rstrip().split()]
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

if len(set(data))==1 or len(data)==1:
    print(data[0])
else:
    print(gcd_list(data))

Measured memory_bytes: 25032
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int N;
ll X;
ll len[51];
ll pan[51];

ll l(int n){
    if(n == 0) return len[n] = 1;
    return len[n] = l(n - 1) * 2 + 3;
}

ll p(int n){
    if(n == 0) return pan[n] = 1;
    return pan[n] = p(n - 1) * 2 + 1;
}

ll rec(int n, ll x){
    if(n == 0){
        return 1;
    }
    if(x == 1){
        return 0;
    }else if(x <= 1 + len[n - 1]){
        return rec(n - 1, x - 1);
    }else if(x == 1 + len[n - 1] + 1){
        return pan[n - 1] + 1;
    }else{
        return pan[n - 1] + 1 + rec(n - 1, x - (1 + len[n - 1] + 1));
    }
}

signed main(){
    cin >> N >> X;
    l(50);
    p(50);
    cout << rec(N, X) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <numeric>

namespace TokorotenLab
{
    class Logger
    {
    private:
        bool isEnable;

    public:
        Logger(bool isEnable = true) : isEnable(isEnable) {}

        template<class T>
        Logger& operator<<(const T& val)
        {
            if(isEnable)
            {
                std::cout << val;
            }
            return *this;
        }

        void set_enable()
        {
            isEnable = true;
        }

        void set_disable()
        {
            isEnable = false;
        }

        void endl()
        {
            if(isEnable)
            {
                std::cout << std::endl;
            }
        }
    };

    Logger logger;

    /*
    Arguments:
        Search range: [begin, end)
        Target function: f(x)
    Requirement:
        f(x) => { false, ..., false, true, ..., true }
    Judge:
        true_bound == begin => All f(x) are true
        true_bound == end => All f(x) are false
    */
    std::pair<long long, long long> binary_search(long long begin, long long end, std::function<bool(long long)> f)
    {
        long long false_bound = begin - 1LL; // ( ..., false_bound] => false
        long long true_bound = end; // [true_bound, ... ) => true
        long long x;

        while(true_bound - false_bound > 1LL)
        {
            x = false_bound + (true_bound - false_bound) / 2LL;
            if(f(x))
            {
                true_bound = x;
            }
            else
            {
                false_bound = x;
            }
        }

        return std::make_pair(false_bound, true_bound);
    }
}

using namespace std;

#define int long long

int gcd(int x, int y)
{
    if(y == 0) return x;
    return gcd(y, x % y);
}

int lcm(int x, int y)
{
    return x / gcd(x, y) * y;
}

signed main()
{
    int n;
    vector<int> t;
    int gcd_val;
    int lcm_val = 1LL;

    cin >> n;

    t.resize(n);

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

    lcm_val = t[0];
    for(int i = 1; i < n; ++i)
    {
        lcm_val = lcm(lcm_val, t[i]);
    }

    cout << lcm_val << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

int main()
{
  string s; cin >> s;
  int K; cin >> K;

  int N = s.size();
  vector<string> v;
  for(int i = 0; i< N; i++){
    for(int j = 1; j < min(6, N - i + 1); j++){
      string tmp = s.substr(i, j);
      v.push_back(tmp);
    }
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  cout << v[K - 1] << endl;
}


Measured memory_bytes: 1660
// AOJ 0334 Amidakuji
// 2019.8.11 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//// 高速入出力
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()  // 非負整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(long long n)  // 正整数の表示（出力）
{
	int i;
	char ob[40];

	i = 0; while (n) ob[i++] = n % 10 + '0', n /= 10;
	while (i--) pc(ob[i]);
	pc('\n');
}

void outs(char *s) { while (*s) pc(*s++); pc('\n'); }

#define MAX 1005
int  hi[MAX], to[MAX][MAX];
int  seen[MAX];
int  match[MAX];
int  mark = 1;

int bpm(int u);
int bipartiteMatching(int m, int n)
{
	int u, max;

	memset(match, -1, sizeof(match));
	max = 0;
	for (u = 0; u < m; u++) if (match[u] < 0) {
		mark++;
		if (bpm(u)) max++;
	}
	return max;
}

int bpm(int u)
{
	int i, v, w;

	seen[u] = mark;
	for (i = 0; i < hi[u]; i++) {
		v = to[u][i], w = match[v];
		if (w < 0 || (seen[w] != mark && bpm(w))) {
			match[v] = u, match[u] = v;
			return 1;
		}
	}
	return 0;
}

int cmp(const void *u, const void *v) { return *(int *)u - *(int *)v; }

int main()
{
	int N, i, j, k;
	
	N = in()-1;
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			if (gc() & 1) to[j][hi[j]++] = N+i;
			gc();
		}
	}
	if (bipartiteMatching(N, N) < N) outs("no");
	else {
		outs("yes");
		for (i = 0; i < N; i++) {
			match[match[i]] = -1;
			match[i] = -1;
			mark++;
			bpm(i);
			hi[i] = 0;
			to[i][hi[i]++] = match[i];
			out(match[i]-N+1);
		}
	}
	return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll,ll> > vpll;
typedef vector< vector<int> > matrix;

#define SET(Ar,val) memset(Ar,val,sizeof(Ar))
#define rep(i,val,n)  for(int i=val;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LMAX LONG_LONG_MAX
#define LMIN LONG_LONG_MIN
#define IMAX INT_MAX
#define IMIN INT_MIN
#define Modulo 1000000007ll

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

template <class T> T modpower(T a,T b,T MOD)
{
    T ans=1;
    while(b!=0)
    {
        if(b%2==1)
        ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b/=2;
    }
    return ans;
}

void init()
{
    int n;
    cin >> n ;
    int z = 0;
    int fg = 0;
    rep(i,0,26)
    {
        rep(j,0,15)
        {
            z = 4*i+7*j;
            if(z == n)
            {
                fg = 1;
                break;
            }
        }
    }
    if(fg)
        cout << "Yes";
    else
        cout << "No";
}

int main()
{
    clock_t time1 = clock();
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    init();
    clock_t time2 = clock();
    cerr <<"Time: " <<(double)(time2-time1)/CLOCKS_PER_SEC * 100000 <<" seconds" <<endl;
	return 0;
    }


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

    ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
    ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
const ll INF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    ll ans =0;
    rep(i,n){
        cin >> a[i];
        ans+=a[i];
        ans--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
//#define int long long
const int INF = 1 << 30;

signed main(){

  int D; cin >> D;
  vector<int> C(26);
  for(int i = 0; i < 26; i++){
    cin >> C[i];
  }

  vector<vector<int>> S(D, vector<int>(26));
  for(int i = 0; i < D; i++){
    for(int j = 0; j < 26; j++){
      cin >> S[i][j];
    }
  }

  random_device seed_gen;
  mt19937_64 rnd(seed_gen());
  uniform_int_distribution<int> dist_T(1, 26);

  int score = -INF;
  vector<int> ans(D);
  clock_t start = clock();
  while(true){
    int res = 0;
    vector<int> L(26, -1);
    vector<int> dp(D);
    for(int i = 0; i < D; i++){
      int T = dist_T(rnd);
      res += S[i][T-1];
      L[T-1] = i;
      for(int j = 0; j < 26; j++){
        if(L[j] == -1) continue;
        res -= C[j] * (i - L[j]);
      }
      dp[i] = T;
    }
    if(score < res){
      score = res;
      ans = dp;
    }

    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    if(time >= 1950) break;
    //cout << dp << " " << res << endl;
  }

  for(int p : ans){
    cout << p << endl;
  }

  return 0;
}

Measured memory_bytes: 3720
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		List<Integer> aiList = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int ai = scan.nextInt();
			aiList.add(ai - 1);
		}

		int ans = 0;
		boolean[] used = new boolean[n];
		for (int i = 0; i < n; i++) {
			if (used[i]) continue;
			int ai = aiList.get(i);
			if (aiList.get(ai) == i) {
				ans++;
				used[ai] = true;
			}
		}

		System.out.println(ans);

		scan.close();

	}

}

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

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// #define ll long long
// bool isEven(ll n) {return (n%2!=0)?false:true;}

using namespace std;

//atcoder - dp
//b

int a[100005], dp[100005];
int n, k;


int main()
{
	std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

	cin>>n>>k;

	FOR0(i, n)
	{
    	cin>>a[i+1];
    	dp[i+1] = -1;
	}

	dp[1] = 0;
	dp[2] = abs(a[1]-a[2]);

	for (int i = 3; i < n+1; ++i)
	{
		int ans = INT_MAX;

		for (int j = 1; j < k+1; ++j)
		{
			if(i-j>0)
			{
				ans = min(ans, abs(a[i-j]-a[i]) + dp[i-j]);
			}
		}
		dp[i] = ans;
	}

	cout<<dp[n]<<endl;

}


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

int main(){

while(1){
int a,b;
string op;
cin>>a>>op>>b;
if(op=="?") break;

int ans;
if(op == "+") ans=a+b;
if(op =="-") ans=a-b;
if(op == "*") ans=a*b;
if(op == "/") ans=a/b;

cout<<ans<<endl;

}

return 0;
}


Measured memory_bytes: 3136