akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1e9
//Writing 1d DP of value as our dp param 
//in normal knapsack you do dp[i] - maximum value with weight i
// dp[i] - minimum total weight with value i
//Knapsack
ll solnE(ll n,ll cap,vector<ll> &w,vector<ll> &v){
	ll tot_val=0;
	for(int i:v) tot_val+=i;
	vector<ll> dp(tot_val+1,INF);
	int ans=INF;
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int val_already = tot_val-v[i];val_already>=0;val_already--)
			dp[val_already+v[i]] = min(dp[val_already+v[i]],dp[val_already]+w[i]);
	}
	for(int i=tot_val;i>=0;i--){
		if(dp[i]<=cap){
			return i;
		}
	}
	return 0;
}
int main(){
	ll n,cap;
	cin>>n>>cap;
	vector<ll> v(n);
	vector<ll> w(n);
	for(int i=0;i<n;i++) cin>>w[i]>>v[i];
	cout<<solnE(n,cap,w,v)<<endl;
}

Measured memory_bytes: 4056
import sys
n, t = [int(i) for i in sys.stdin.readline().split()]
t_ls = [int(i) for i in sys.stdin.readline().split()]
diff_ls = []
for i in range(len(t_ls)-1):
    diff = t_ls[i+1] - t_ls[i]
    if diff > t:
        diff_ls.append(t)
    else:
        diff_ls.append(diff)
print(sum(diff_ls) + t)

Measured memory_bytes: 25336
let read_ints () =
  let str = read_line() in
  List.map (fun x -> int_of_string x) (Str.split (Str.regexp " +") str)
;;

let rec sum lst =
  match lst with
  |[] -> 0
  |h :: t -> h + sum t
;;

let x = read_ints() in
print_endline (string_of_int (15 - sum x))


Measured memory_bytes: 3684
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define PI 3.14159265

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

    double a,b,x;
    cin >> a >> b >> x;

    double hApa = x/(a*a);
    double hAer = (b-hApa);
    if(x/(a*a) - hAer > 0)
    {
        cout << fixed << setprecision(10) << atan2(2*(b-hApa),a) * 180 / PI;
        return 0;
    }
    else
    {
        cout << fixed << setprecision(10)  << 90 * 1.0 - atan2(2*x,a*b*b) * 180 / PI;
    }
    
    

    return 0;
}

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

template<typename T> struct Graph {
  struct Edge { int to; T cost; };
  vector<int> prev;
  vector<vector<Edge>> g;
  Graph(int n) : prev(n, -1), g(n) {}

  void addEdge(int u, int v, T w) {
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  vector<T> dijkstra(int s) {
    vector<T> dist(g.size(), -1);
    using Node = pair<T, int>;
    priority_queue<Node, vector<Node>, greater<Node>> pq;
    pq.push({dist[s] = 0, s});

    while (!pq.empty()) {
      auto d = pq.top().first;
      auto u = pq.top().second;
      pq.pop();
      if (dist[u] < d) continue;
      for (auto&& v : g[u]) {
        if (dist[v.to] < 0 || dist[v.to] > dist[u] + v.cost) {
          dist[v.to] = dist[u] + v.cost;
          prev[v.to] = u;
          pq.push({dist[v.to], v.to});
        }
      }
    }
    return dist;
  }
  vector<int> getPath(int t) {
    vector<int> path;
    for (; t != -1; t = prev[t]) path.push_back(t);
    reverse(begin(path), end(path));
    return path;
  }
};

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

  int n; cin >> n;
  Graph<int> g(n);
  while (--n) {
    int s, t, w; cin >> s >> t >> w;
    g.addEdge(s, t, w);
  }
  vector<int> d = g.dijkstra(0);
  int maxId = distance(begin(d), max_element(begin(d), end(d)));
  d = g.dijkstra(maxId);
  cout << *max_element(begin(d), end(d)) << endl;
  return 0;
}



Measured memory_bytes: 10432
#include <stdio.h>
#include <string.h>
#include <vector>
#include <bitset>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;

int len;
char s[8001];
int x,y;

vector<int> a,b;

bool ok(const vector<int> &a,int x){
  if(x<-8000||x>8000)return 0;
  typedef bitset<16001> bs;
  bs cur;
  cur[8000]=true;
  for(int b:a){
    if(b==0)continue;
    bs tmp=cur<<b|cur>>b;
    cur=tmp;
  }
  return cur[8000+x];
}

int main(void){
  scanf("%8001s",s);
  len=strlen(s);
  scanf("%d%d",&x,&y);
  int cur=0;
  int dir=0;
  REP(i,0,len+1){
    if(i<len&&s[i]=='F')cur++;
    else {
      if(dir==0)x-=cur;
      else if(dir==1)b.push_back(cur);
      else a.push_back(cur);
      dir=dir==1?2:1;
      cur=0;
    }
  }
  puts(ok(a,x)&&ok(b,y)?"Yes":"No");
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    String s=sc.nextLine();
    int cntr=0;
    for(int i=0,j=s.length()-1;i<s.length()/2;i++,j--)
    {
      if(s.charAt(i)!=s.charAt(j))
        cntr++;
    }
    System.out.println(cntr);
  }
}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    cin>>n;
    if(n%2==0) cout<<n/2<<endl;
    else cout<<(n+1)/2<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
  int a, b, c, k;
  cin >> a >> b >> c;
  cin >> k;

  int rest, max;
  if (a > b) {
    max = a;
    rest = b;
  } else {
    max = b;
    rest = a;
  }
  if (max > c) {
    rest += c;
  } else {
    rest += max;
    max = c;
  }
  printf("%d\n", max * (int)pow(2, k) + rest);
  
  return 0;
}


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

int main()
{
	int gamenum = 0;
	cin >> gamenum;
	int taroP = 0, hanakoP = 0;
	string taro, hanako;
	while (gamenum--) {
		cin >> taro >> hanako;
		if (taro < hanako) {
			hanakoP += 3;
		}
		else if (taro > hanako) {
			taroP += 3;
		}
		else {
			hanakoP += 1;
			taroP += 1;
		}
	}
	cout << taroP << " " << hanakoP << endl;
    return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define all(v)    ((v.begin()),(v.end()))
#define sz(v)     ((int)(v.size()))
#define forv(i, v) for(int i = 0; i < sz(v); ++i)
#define forn(i,n)   for(int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<double>  vd;
typedef vector< vi >    vii;
typedef vector< vd >    vdd;
typedef vector<string>  vs;


int main()
{
	fast;
	ll n;
	cin >> n;
	double s;
	s = 1.0 * n / 3;
	s = (double)s * s * s;
	printf("%0.12lf\n", s);

	return 0;
}


Measured memory_bytes: 256
//////https://atcoder.jp/contests/abc178/tasks/abc178_d
#include <bits/stdc++.h>

using namespace std;

const int MO=1e9+7;
const int MAXN=2e3+2;
long long ans[MAXN];

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

    //初始化ans
    ans[0]=1;

    for (int i=3; i<=s; i++) {
        for (int j=3; j<=i; j++) {
            ans[i]=(ans[i]+ans[i-j])%MO;
        }
    }

    cout<<ans[s]<<"\n";

    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define FFOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>


signed main(){
	
	string s;cin >> s;
	
	int ans = 9*s.size()-9;
	ans += s[0] - '1';
	
	bool ok = true;
	FOR(i,1,s.size()-1) if(s[i] !='9') ok=false;
	
	if(ok) ans++;
	
	cout << ans  << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n,k;
	cin>>n>>k;
	int a[alength]={};
	fori(n){cin>>a[i];}
	cout<<(n-3+k)/(k-1);
}

Measured memory_bytes: 3992
let input = require("fs").readFileSync("/dev/stdin", "utf8")

function main({ input, load, yesno, math_sum, log_json }) {
    let [N] = load()
    
    const factors = math_factors(N)

    let count = 0
    for(const p in factors) {
        let e = factors[p]
        for(let i = 1; i <= e; i++) {
            e -= i
            count++
        }
    }

    return count
}



// console.time()
let inputs = input.split(/[\s\n]/)
let result = main({
    input,
    yesno: value => value ? 'Yes' : 'No',
    math_sum: numbers => numbers.reduce((acc, cur) => acc + cur, 0),
    load(rows = 1, cols = 1, type = Number) {
        const length = rows * cols
        let result = inputs.splice(0, length)
        if(type !== String) result = result.map(type)
        if(cols > 1) {
            const arrays = new Array(cols)
            for(let col = 0; col < cols; col++) {
                arrays[col] = new Array()
                for(let row = 0; row < rows; row++) {
                    arrays[col].push(result[row * cols + col])
                }
            }
            result = arrays
        }
        return result
    },
    inifinite_loop_preventer() {
        throw new Error("Infinite loop")
    },
    log_json(value) {
        console.log(JSON.stringify(value))
    },
})

if(result === undefined) {
    console.warn("result is undefined")
} else {
    console.log(result)
}
// console.timeEnd()

function math_max(numbers, initial_value = null) {
    let result = (initial_value === null) ? numbers[0] : initial_value
    for(const n of numbers) if(n > result) result = n
    return result
}

function math_min(numbers, initial_value = null) {
    let result = (initial_value === null) ? numbers[0] : initial_value
    for(const n of numbers) if(n < result) result = n
    return result
}

function math_factors(n) {
    const result = {}
    for(let i = 2; i * i <= n; i++) {
        if(n % i === 0) {
            n /= i
            result[i] = 1
            
            while(n % i === 0) {
                n /= i
                result[i]++
            }
        }
    }

    if(n > 1) result[n] = 1

    return result
}


Measured memory_bytes: 33068
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <queue>
#include <cstring>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <ctime> 
using namespace std;

#define pb push_back
#define All(a) a.begin(), a.end()
#define met(a, b) memset(a, b, sizeof(a))
#define rep1(i, l, r) for(int i = l; i <= r; ++i)
#define rep2(i, l, r) for(int i = l; i < r; ++i) 
#define per(i, r, l) for(int i = r; i >= l; --i)
typedef long long ll;
typedef double db;
typedef long double ldb;
const int NIL = -1;
const int oo = 0x3f3f3f3f;
const ll INF = 2e18;
const db eps = 1e-8;
const db PI = acos(-1.0);
const int maxn = 2e5 + 7;

ll T[maxn], S[maxn];

inline int read(void)
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{ if(ch == '-') f = -1; ch = getchar(); } 
	while(ch >= '0' && ch <= '9') {	x = (x << 1) + (x << 3) + ch - '0';	ch = getchar();	}
	return x * f;
}

inline void write(int x)
{
	if(x < 0) { putchar('-'); x = -x; }
    if(x >= 10) write(x/10); 
	putchar(x%10+'0'); 
}

int main(void)
{
	int n = read();
//	int n = 1e5;
	rep1(i, 1, n)
	{
		T[i] = read();
//		T[i] = i;
		S[i] = S[i-1] + T[i];
	}
	ll ans = INF;
	int l = 1, r = 3;
	rep1(i, 2, n-2)
	{
		ll A, B, C, D;
		while(l < i && abs((S[i]-S[l])-(S[l]-S[0])) > abs((S[i]-S[l+1])-(S[l+1]-S[0]))) ++l;
		while(r < n && abs((S[n]-S[r])-(S[r]-S[i])) > abs((S[n]-S[r+1])-(S[r+1]-S[i]))) ++r;
		A = S[l] - S[0];
		B = S[i] - S[l];
		C = S[r] - S[i];
		D = S[n] - S[r];
		ans = min(ans, max(max(A, B), max(C, D)) - min(min(A, B), min(C, D)));
	}
	printf("%lld", ans);
	
	return 0;
} 

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
	char c;
	cin>>c;
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')cout<<"vowel\n";
    else cout<<"consonant\n";
	return 0;
}


Measured memory_bytes: 256
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

const int nax = 2e5 + 5;
VII intervals[nax];

// add to the prefix
// give the min of everything
struct S {
    ll small, lazy;
    void merge(const S& a, const S& b) {
        small = min(a.small, b.small);
        assert(lazy == 0);
    }
    void add(ll x) {
        small += x;
        lazy += x;
    }
};

vector<S> tree;
const int TYPE_ADD = 1, TYPE_MIN = 2;
void rec(int id, int low, int high, int q_low, int q_high, int type, ll& x) {
    if (high < q_low || q_high < low) {
        return;
    }
    if (q_low <= low && high <= q_high) {
        if (type == TYPE_ADD) {
            tree[id].add(x);
        } else if (type == TYPE_MIN) {
            x = min(x, tree[id].small);
        } else {
            assert(false);
        }
        return;
    }
    for (int b : {2 * id, 2 * id + 1}) {
        tree[b].add(tree[id].lazy);
    }
    tree[id].lazy = 0;
    int last_left = (low + high) / 2;
    rec(2 * id, low, last_left, q_low, q_high, type, x);
    rec(2 * id + 1, last_left + 1, high, q_low, q_high, type, x);
    tree[id].merge(tree[2 * id], tree[2 * id + 1]);
}

int main() {
    int n = nxt(), m = nxt();
    ll sum_of_scores = 0;
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        intervals[b].emplace_back(a, c);
        sum_of_scores += c;
    }
    ll answer = 0;
    int base = 1;
    while (base <= n + 1) base *= 2;
    tree.resize(2 * base, {INF, 0});
    ll w = 0 - INF;
    rec(1, 0, base - 1, 0, 0, TYPE_ADD, w);
    for (int i = 1; i <= n + 1; i++) {
        // I want to put '1' here
        for (PII p : intervals[i - 1]) {
            ll whatever = p.second;
            rec(1, 0, base - 1, 0, p.first - 1, TYPE_ADD, whatever);
        }
        ll best = INF;
        rec(1, 0, base - 1, 0, base - 1, TYPE_MIN, best);
        if (i == n + 1) answer = best;
        w = best - INF;
        rec(1, 0, base - 1, i, i, TYPE_ADD, w);
    }
    printf("%lld\n", sum_of_scores - answer);
    return 0;
}


Measured memory_bytes: 22620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long[] a = sc.LongArray();

        for (int i = 0; i < n; i++)
        {
            a[i] -= i + 1;
        }

        a = a.OrderBy(num => num).ToArray();
        long count = a.Count();

        long mid = count % 2 == 0 ? (a[count / 2 - 1] + a[count / 2]) / 2 : a[count / 2];

        long answer = a.Select(num => Math.Abs(num - mid)).Sum();

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 51536
//
// Created by tac on 2016/10/12.
//

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <climits>
#include <vector>
#include <numeric>

int main() {
    int n;
    long a;
    long min, max, sum;

    std::cin >> n;
//    std::vector<long> vec;
//    for (int i = 0; i < n; ++i) {
//        std::cin >> a;
//        vec.push_back(a);
//    }
//    min = *std::min_element(vec.begin(), vec.end());
//    max = *std::max_element(vec.begin(), vec.end());
//    sum = std::accumulate(vec.begin(), vec.end(), 0);
    min = LONG_MAX;
    max = LONG_MIN;
    sum = 0;
    for (int i = 0; i < n; ++i) {
        std::cin >> a;
        if (a < min) {
            min = a;
        }
        if (max < a) {
            max = a;
        }
        sum += a;
    }
    std::cout << min << " " << max << " " << sum << std::endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  cout << n / 3 << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

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

    ll cnt = 0;
    if (2*x ==w && 2*y == h) cnt = 1;

    double a = (double) w;
    double b = (double) h;
    double s = a * b / 2.0;

    cout.precision(20);
    cout << s << " " << cnt << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}
int n;
int arr[100010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    cin >> n;

    string s, t;
    cin >> s >> t;

    if (n == 1)
    {
        cout << 3 << endl;
        return 0;
    }
    ll ans = 1;
    int f = 0; //1なら縦棒 -1なら横棒

    for (int i = 0; i < n; ++i)
    {
        if (s[i] == t[i])
        {
            if (f == 0)
            {
                ans *= 3;
            }
            else if (f == 1)
            {
                ans *= 2;
            }
            ans %= MOD;
            f = 1;
        }
        else
        {
            if (f == 0)
            {
                ans *= 6;
            }
            else if (f == 1)
            {
                ans *= 2;
            }
            else
                ans *= 3;

            ans %= MOD;
            f = -1;

            i++;
        }
    }
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 256
INF = float("inf") #const

def main():
    s = input()
    n = len(s) - 1
    ans = 0

    for i in range(2**n):
        op = [""]*n
        for j in range(n):
            if (i>>j)&1:
                op[j] = "+"
        res = ""
        for a,b in zip(s,op+[""]):
            if len(b) != 0:
                res += a + b
            else:
                res += a
        ans += eval(res)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
main(i){
int s[9000],n,m,t,f;
while(scanf("%d%d",&n,&m),i=0,t=f=1,n)
	while(++i<=n+m)
		if(scanf("%d",&s[i]),i>n)if(t+=s[t+=s[i]],t>=n&f==1)
			printf("%d\n",i-n,f=0);
	
}

Measured memory_bytes: 0
# https://atcoder.jp/contests/abc118/tasks/abc118_c

import fractions as math
N = int(input())
monsters = list(map(int, input().split()))
for i in range(N):
    if i != 0:
        monsters[i] = math.gcd(monsters[i - 1], monsters[i])
print(monsters[N - 1])


Measured memory_bytes: 16244
class Combination():
    def __init__(self, N:int, P:int):
        self.N = N
        self.P = P
        self.fact = [1, 1]   
        self.factinv = [1, 1]
        self.inv = [0, 1] 

        for i in range(2, N+1):
            self.fact.append((self.fact[-1] * i) % P)
            self.inv.append((-self.inv[P % i] * (P // i)) % P)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % P)
    def getComb(self, n:int, k:int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] % self.P * self.factinv[n-k] % self.P

def main():
    n,k = map(int,input().split())
    MOD = 10**9 +7

    COMB = Combination(n,MOD)

    ans = 0
    for i in range(min(n, k+1)):
        ans += COMB.getComb(n,i) * COMB.getComb(n-1,i)
        ans %= MOD

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 27092
using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading;
using System.IO;
using System.Text;

//============================================================================
namespace Sweet
{
    class Program
    {
        static StreamWriter writer = null;
        //============================================================================
        static void setstdio(string[] args)
        {
            if (0 < args.Length)
            {
                // Redirect standard input from the console to the input file.
                Console.SetIn(new StreamReader(args[0]));
                if (args.Length == 2)
                {
                    // Attempt to open output file.
                    writer = new StreamWriter(args[1]);
                    // Redirect standard output from the console to the output file.
                    Console.SetOut(writer);
                }
            }
        }
        //============================================================================
        static int Swing()
        {
            int i;
            string ring = Console.ReadLine();
            string words = Console.ReadLine();
            ring += ring;
            //StringBuilder builder = new StringBuilder(ring.Length*2);
            //builder = ring.ToString;

                for (i = 0; i < ring.Length/2+1; i++)
                    if (words==ring.Substring(i,words.Length))
                        break;

            if (i < ring.Length / 2)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            return 0;
        }

        private static bool isalpha(char v)
        {
            if ('a' <= v && v <= 'z' || 'A' <= v && v <= 'Z')
                return true;
            return false;
        }

        //============================================================================
        static void Main(string[] args)
        {
            setstdio(args);

            while(Swing()!=0);
            if (writer != null)
                writer.Close();
            //Console.ReadLine();
        }
        //============================================================================
    }
}

Measured memory_bytes: 8920
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <cstring>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main(void)
{
    int a,b;
    cin >> a >> b;
    
    cout << (a-1) * (b-1);
    
}

Measured memory_bytes: 3604
import java.util.*;	
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long sum = 1;
		for(long i = 1;i <= n;i++) {
			sum = (sum*i)%(1000000000+7);
		}
		System.out.println(sum);
	}

}

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

int main(){
  int N;
  string S;
  int yellow = 0;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> S;
    if (S == "Y")
      yellow = 1;
  }
  if (yellow)
    cout << "Four";
  else
    cout << "Three";
  cout << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
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;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int N;
ll a[110000];
ll d[110000];

int main () {
  cin >> N;
  rep(i, N) cin >> a[i];

  rep(i, N) {
    d[i] = d[i-1] + a[i];
  } 

  ll ans1 = 0;
  ll ans2 = 0;

  ll tmp1 = 0;

  rep(i, N) {
    //cout << d[i] << " " << tmp1 << "\n";
    ll n = d[i] + tmp1;
    //cout << n << "\n";

    if (i % 2 == 1) {
      if (n < 1) {
        tmp1 += (1 - n);
        ans1 += (1 - n);
      }
    } else {
      if (n > -1) {
        tmp1 += (-1 - n);
        ans1 += (n + 1);
      }
    }
  }

  //cout << ans1 << "\n";

  ll tmp2 = 0;

  rep(i, N) {
    //cout << d[i] << " " << tmp2 << "\n";
    ll n = d[i] + tmp2;
    //cout << n << "\n";

    if (i % 2 == 0) {
      if (n < 1) {
        tmp2 += (1 - n);
        ans2 += (1 - n);
      }
    } else {
      if (n > -1) {
        tmp2 += (-1 - n);
        ans2 += (n + 1);
      }
    }
  }

  //cout << ans2 << "\n";

  cout << min(ans1, ans2) << "\n";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);
#define STR clock_t startTime = clock();
#define END clock_t endTime = clock();cout << double(endTime - startTime) / CLOCKS_PER_SEC *1000<< "ms" << endl;
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const long long mod2=998244353;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
inline ll mul_64(ll x,ll y,ll c){return (x*y-(ll)((long double)x/c*y)*c+c)%c;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=a*a%c)if(b&1)ans=ans*a%c;return ans;}
void exgcd(ll a,ll b,ll &x,ll &y){if(!b)x=1,y=0;else exgcd(b,a%b,y,x),y-=(a/b)*x;}
int main(){
    int a,b,x;
    cin>>a>>b>>x;
    if(x==a*a*b)return o("0.00000000000");
    if(2*x>a*a*b)printf("%.10f\n",atan((1.0*2*a*a*b-2*x)/(a*a*a))*(180/acos(-1)));
    else printf("%.10f\n",atan(a*b*b*1.0/(2*x))*(180/acos(-1)));
}

Measured memory_bytes: 256
import math

X = list(map(int,input().split()))
Ahp = X[0]
Aat = X[1]
Bhp = X[2]
Bat = X[3]
Atm = math.ceil(Bhp/Aat)
Btm = math.ceil(Ahp/Bat)

if Atm<=Btm:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9164
import java.util.*;

class Main{
  public static void main(String[] args){
    try(Scanner sc = new Scanner(System.in)){
      int n = Integer.parseInt(sc.next());
      Integer[]d = new Integer[n];
      for(int i = 0; i < n; i++){
        d[i] = Integer.parseInt(sc.next());
      }
      
      Arrays.sort(d, Collections.reverseOrder());
      int cnt = 1; //初期値1
      for(int i = 0; i < n - 1; i++){
        if(d[i] > d[i + 1]){
          cnt++;
        }
      }
      System.out.println(cnt);
    }
  }
}
      

Measured memory_bytes: 23124
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra

n,m = map(int,input().split())
edges = [[int(x) for x in input().split()] for i in range(m)]
graph = [[False]*n for i in range(n)]
for a, b, c in edges :
    graph[a-1][b-1] = c

graph = csgraph_from_dense(graph)
dist = dijkstra(graph, directed=False).astype(int)

ans = 0
for a, b, c in edges :
    if dist[a-1][b-1] != c :
        ans += 1

print(ans)


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

public class Main {

	public static void main(String[] args) throws IOException {
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));		

		int n = Integer.parseInt(reader.readLine());
		int[] numbers = new int[n+1];
		String[] strArray = reader.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			numbers[i] = Integer.parseInt(strArray[i]);
		}
		
		int q = Integer.parseInt(reader.readLine());
		strArray = reader.readLine().split(" ");
		int ans = 0;
		for (int i = 0; i < q; i++) {
			int target = Integer.parseInt(strArray[i]);
			numbers[n] = target;
			int j = 0;
			while (target != numbers[j]) {
				j++;
			}
			if (j != n) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 27540
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+50;
int n;
int res=1;
char ch[N];
int main(){
	scanf("%d",&n);
	scanf("%s",ch+1);
	for(int i=2;i<=n;++i){
		if(ch[i]!=ch[i-1]) res++;
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 384
let rec upper_bound l r p =
  if r <= 1 + l
  then l
  else let m = (l + r) / 2 in
       if p m
       then upper_bound m r p
       else upper_bound l m p

let () = Scanf.scanf "%d %d\n" @@ fun n x ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  Array.sort compare as_;
  let acc = Array.make (n + 1) 0 in
  for i = 0 to n - 1 do
    acc.(i + 1) <- acc.(i) + as_.(i)
  done;
  Printf.printf "%d\n" @@
    if acc.(n) < x then n - 1
    else if x = acc.(n) then n
    else upper_bound 0 (n + 1) @@ fun i -> acc.(i) <= x

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> b(n-1), a(n);
    rep(i, n-1) cin >> b[i];
    a[0] = b[0];
    a[n-1] = b[n-2];

    for(int i = 1; i < n-1; ++i){
        a[i] = min(b[i-1], b[i]);
    }
    int res = 0;
    rep(i, n){
        res += a[i];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
/*
	Author  : Malisetti Samrat 
	Date    : 2020-05-10 17:36:12 
 */


//Optimisation Flags
#pragma GCC optimize ("O3")
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC optimize("Ofast")

#include   <bits/stdc++.h>
//#include   <ext/pb_ds/assoc_container.hpp>
//#include   <ext/pb_ds/tree_policy.hpp>
#include   <algorithm>
#include   <queue>
#include   <list>
#include   <map>
#include   <math.h>
#include   <numeric>
using      namespace        std;
#define    endl             '\n'
#define    FAST             ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define    ipfile           ifstream cin ("input.txt");std::cin.rdbuf(std::cin.rdbuf())
#define    pb(x)            push_back(x)
#define    int              long long int
#define    itn              unsigned long long int
#define    db               long double
#define    vll              vector<int>
#define    all(v)           v.begin(),v.end()
#define    rall(v)          v.rbegin(),v.rend()
#define    GCD(m,n)         __gcd(m,n)
#define    LCM(m,n)         m*(n/GCD(m,n))
#define    REVVEC(v)        reverse(v.begin(),v.end())
#define    REVARR(a)        reverse(a,a+n)
#define    maxc(v)          max_element(all(v))
#define    minc(v)          min_element(all(v))
#define    inputarr(a,n)    for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define    outputarr(a,n)   for(int xxx=0;xxx<n;xxx++) cout<<a[xxx]<<" "
#define    rep(i,m, n)      for(int i = m; i < (n); ++i)
#define    sp               setprecison(10)
#define    sz(a)            (int)a.size()
#define    erase(vec,val)   vec.erase(std::remove(vec.begin(), vec.end(), val), vec.end()); //deleting specific value element in vector
#define    PI               (db)3.141592653589793238462643383279502884197169399375105820974944
#define    inf              (int)1000000000
#define    mod              (int)1000000007
#define    mem(a,b)          memset(a,b,sizeof(a));
#define    w(x)              int T;cin>>T;while(T -- > 0)
#define    ff                first
#define    ss                second
#define    pqueue            priority_queue< int >
#define    pdqueue           priority_queue< int,vll ,greater< int > >

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

clock_t time_p = clock();

void time()
{
  time_p = clock() - time_p;
  cerr << "Time  : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}

void solveTC(){

	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int res=0;
	if((k-a)>=0)
		res+=(a) , k-=a;
	else
		res+=k , k=0;

	if((k-b)>=0){
		k-=b;
	}
	else{
		k=0;
	}

	if((k-c)>=0){
		res-=(c);
		k-=c;
	}
	else{
		res-=k;
	}

	cout<<res<<endl;

}

int32_t main()
{

    FAST

  //  w(x){

        solveTC();

   // }

    time();

    return 0;

}

Measured memory_bytes: 3804
_,*A=*$<;101.times{|x|101.times{|y|a=A.map{|s|i,j,k=s.split.map &:to_i;[k,(i-x).abs+(j-y).abs]};K,D=a.max;a.all?{|k,d|k==[K+D-d,0].max}&&p(*[x,y,K+D])}}

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>

using namespace std;
int main()
{
	int A[32][32],B[32],C;
	int N,M;
	int i,j,k;
	cin>>N>>M>>C;
	for(i=0;i<M;i++)
	{
		cin>>B[i];
	}
	for(i=0;i<N;i++)
	{
		for(j=0;j<M;j++)
		{
			cin>>A[i][j];
		}
	}
	int ans=0;
	for(i=0;i<N;i++)
	{
		k=C;
		for(j=0;j<M;j++)
		{
			k += A[i][j]*B[j];
		}
		if(k>0)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const S = r.s()

    return /^(hi)+$/.exec(S) ? 'Yes' : 'No'
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map(line => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}


Measured memory_bytes: 7372
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] h = new int[n];
        for(int i = 0; i < n; i++) h[i] = scan.nextInt();
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(h[1] - h[0]);
        for(int i = 2; i < n; i++){
            dp[i] = Math.min(dp[i - 2] + Math.abs(h[i] - h[i - 2]), dp[i - 1] + Math.abs(h[i] - h[i - 1]));
        }
        System.out.println(dp[n - 1]);
    }

    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 59052
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int n;
    while (~scanf("%d", &n)) {
        printf("%d\n", (n-2)*180);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();

        if(b - a > k || c -a > k || d -a > k || e-a > k || c-b > k || d-b > k || e-b > k || d - c > k || e-c > k || e -d > k){
            System.out.println(":(");
        } else {
            System.out.println("Yay!");
        }


    }

}


Measured memory_bytes: 23252
# coding: utf-8
n = int(input())
data = list(map(int,input().split()))
dic = {}
max1=0
max2=0
for x in data:
    if x not in dic:
        dic[x]=1
    else:
        dic[x]+=1
    if dic[x]>=2:
        if max1<x:
            max2=max1
            max1=x
            dic[x]=0
        elif max2<x:
            max2=x
            dic[x]=0
        else:
            pass
print(max1*max2)

Measured memory_bytes: 18316
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
double dp[333][333][333];
int n,a[333],cnt[4];
double dfs(int a,int b,int c)
{
	if(a==0 && b==0 && c==0)
	{
		return 0;
	}
	if(dp[a][b][c]!=0)
	{
		return dp[a][b][c];
	}
	int sum=a+b+c;
	double ans=1.0*n/sum;
	if(a)
	{
		ans+=1.0*dfs(a-1,b,c)*a/sum;
	}
	if(b)
	{
		ans+=1.0*dfs(a+1,b-1,c)*b/sum;
	}
	if(c)
	{
		ans+=1.0*dfs(a,b+1,c-1)*c/sum;
	}
	dp[a][b][c]=ans;
	return dp[a][b][c];
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		cnt[a[i]]++;
	}
	printf("%.10f\n",dfs(cnt[1],cnt[2],cnt[3]));
	return 0;
}

Measured memory_bytes: 260224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
#define MOD 998244353 //1000000007


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

    // solution comes here

    ll ans=0;
    char c;
    rep(i, 4) {
        cin >> c;
        if(c=='+') ans++;
        else ans--;
    }
    cout << ans << nl;
}

Measured memory_bytes: 256
/*
 * main.cpp
 *
 *  Created on: 2011/04/09
 *      Author: satoki
 *      10:51 ~ 11:17
 *      ツδーツクツδ環ッツドツづ個古敖渉慊法
 */
#include <iostream>
#include <string.h>
using namespace std;

int iA;
int iB;

int iGCD;
int iLCM;

bool input() {
  if (scanf("%d %d", &iA, &iB) == EOF) return false;
  return true;
}

void manage() {
  int a, b, tmp;
  a = iA;
  b = iB;
  while (b) {
    tmp = a % b;
    a = b;
    b = tmp;
  }
  iGCD = a;
  a = iA;
  b = iB;
  iLCM = a / iGCD * b;
}

int main() {
  while (1) {
    if (!input()) break;
    manage();
    printf("%d %d\n", iGCD, iLCM);
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
int main(){
  char s[10];
  scanf("%s",s);
  int len = strlen(s);
  //printf("%d\n",len);
  //printf("%s\n",s);
  int count = 0;
  int max = -1;
  for(int i=0;i<len;i++){
    if(s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T'){
      count++;
    }else{
      if(count > max) max = count;
      count = 0;
    }
  }
  if(count > max) max = count;
  printf("%d\n",max);
  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define ll __int128
//#define int ll
//#define int ll
//#define char ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(4) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

void smain() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    for (int len = n; len < 2 * n; ++len) {
        int clen = 2 * n - len;
        if (s.substr(n - clen, clen) == t.substr(0, clen)) {
            cout << len << '\n';
            return;
        }
    }
    cout << 2 * n;
}

Measured memory_bytes: 256
inf = input().split()
X = int(inf[0])
Y = int(inf[1])
Z = int(inf[2])
K = int(inf[3])

A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
ab = []
for a in A:
  for b in B:
    ab +=[a+b]
ab.sort(reverse=True)
C.sort(reverse=True)
state = [[ab[0]+C[i],0,i] for i in range(len(C))]
count  = 0
while count<K:
  s = max(state)
  print(s[0])
  count +=1
  x = s[1]
  i = s[2]
  if x<X*Y-1:
    state[i][0] = C[i]+ab[x+1]
    state[i][1] = x+1
  else:
    state[i][0] = -1


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int inf = 1000000;

int dp[41][401][401];

int main()
{
    int n, ma, mb;
    cin >> n >> ma >> mb;

    int a[n], b[n], c[n];

    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    rep(i, n + 1) rep(j, 401) rep(k, 401) dp[i][j][k] = inf;

    dp[0][0][0] = 0;

    rep(i, n)
    {
        rep(j, 401)
        {
            rep(k, 401)
            {
                dp[i + 1][j][k] = dp[i][j][k];
                if (j - a[i] >= 0 && k - b[i] >= 0)
                    dp[i + 1][j][k] = min(dp[i][j - a[i]][k - b[i]] + c[i], dp[i][j][k]);
            }
        }
    }
    int ans = 1e7;

    for (int j = 1; j <= 400; j++)
    {
        for (int k = 1; k <= 400; k++)
        {
            if (j * mb == k * ma)
                ans = min(ans, dp[n][j][k]);
        }
    }

    OP((ans == inf ? -1 : ans));

    return 0;
}

Measured memory_bytes: 25984
N,W = map(int, input().split())
ws = []
vs = []
for i in range(N):
    w,v = map(int, input().split())
    ws.append(w)
    vs.append(v)
ws_m = [w-ws[0] for w in ws]

"""
i番目まで見て、n個選んでいて、重さがwのときのvの最大値
ただし、wはN個選んだときにW-N*[w[0]]となっているので、そこをmaxとする
dp[i][n][w] 
"""
dp = [[[-1]*(3*N+10) for i in range(N+1)] for j in range(N+1)]
dp[0][0][0] = 0
for i,(w,v)  in enumerate(zip(ws_m,vs)):
    for n in range(i+1):
        for j in range(3*N):
            dp[i+1][n][j] = max(dp[i+1][n][j], dp[i][n][j])
            if dp[i][n][j] == -1: continue
            if j + (n+1)*ws[0] + w <= W:
                dp[i+1][n+1][j+w] = max(dp[i][n][j+w], dp[i][n][j] + v)

ans= 0
for i,As in enumerate(dp[N]):
    w = min(W - i*ws[0], sum(ws_m))
    if w >= 0:
        ans = max(ans,max(As[:w+1]))
print(ans)   


Measured memory_bytes: 69212