akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int a[3][3];
    int b[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
            b[i][j]=0;
        }
    }
    int n;
    cin >> n;
    int c[n];
    for(int k=0;k<n;k++){
        cin >> c[k];
    }
    string ans = "No";
    for(int k=0;k<n;k++){
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(c[k]==a[i][j]){
                    b[i][j]=1;
                }
            }
        }
    }
    for(int i=0;i<3;i++){
        if(b[i][0]==1&&b[i][1]==1&&b[i][2]==1){
            ans = "Yes";
        }
    }
    for(int j=0;j<3;j++){
        if(b[0][j]==1&&b[1][j]==1&&b[2][j]==1){
            ans="Yes";
        }
    }
    if(b[0][0]==1&&b[1][1]==1&&b[2][2]==1){
        ans="Yes";
    }
    if(b[2][0]==1&&b[1][1]==1&&b[0][2]==1){
        ans="Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    final long mod = 1000000007;
    long Ai[] = new long[n];
    long sum = 0, ans = 0;
    for(int i = 0; i < n; i++){
      Ai[i] = sc.nextInt();
      sum += Ai[i];
      sum %= mod;
    }

    for(int i = 0; i < n; i++){
      sum -= Ai[i];
      if(sum < 0){
        sum += mod;
      }
      ans += Ai[i] * sum;
      ans = ans % mod;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 63220
program name
    implicit none
    integer(4):: n,i,maxgcd
    integer(4),allocatable:: a(:),l(:),r(:)

    read*, n
    allocate(a(n),l(0:n),r(n+1))
    read*, a(:)

    l(0) = 0
    l(1) = a(1)
    r(n) = a(n)
    r(n+1) = 0
    do i=2,n
        l(i) = gcd(l(i-1),a(i))
    end do

    do i=n-1,1,-1
        r(i) = gcd(r(i+1),a(i))
    end do

    maxgcd = r(2)



    do i=2,n-1
        maxgcd = max(maxgcd, gcd(l(i-1),r(i+1)))
    end do

    maxgcd = max(maxgcd,l(n-1))
    print*, maxgcd



contains
    recursive function gcd(x,y) result(ret)
        integer(4),intent(in):: x,y
        integer(4):: ret

        if (mod(x,y) == 0) then
            ret = y
            return
        end if

        ret = gcd(y,mod(x,y))
    end function
end program name

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

class ABC {
  private:
  int A, B, C;
  public:
  void setval(int x, int y, int z);
  int adjust(int x, int y, int z);
};

void ABC::setval(int x, int y, int z) {
  A=x;
  B=y;
  C=z;
}

int ABC::adjust(int x, int y, int z) {
  if (0==x*y*z) return 3000;
  return abs(x-A)+abs(y-B)+abs(z-C);
}

ABC abc;

/*
int main() {
  ABC abc;
  abc.setval(1, 2, 3);
  cout << abc.adjust(1, -2, 6);
  return 0;
}
*/  
  
int add_one(int MMin, int M, int LA, int LB, int LC, vector<int> l) {
  int ll=l.at(0);
  int MM, LLA, LLB, LLC;
  int dummy;
  if (ll==0) return min(MMin, M+abc.adjust(LA, LB, LC));
  if (MMin<=M) return MMin;
  l.erase(l.begin());
  for (int i=0; i<4; i++) {
    MM=M;
    LLA=LA;
    LLB=LB;
    LLC=LC;
    if (i==1) {
      if (LLA!=0) MM+=10;
      LLA += ll;
    } else if (i==2) {
      if (LLB!=0) MM+=10;
      LLB += ll;
    } else if (i==3) {
      if (LLC!=0) MM+=10;
      LLC += ll;
    }
    dummy=add_one(MMin, MM, LLA, LLB, LLC, l);
    //if (dummy < MMin) cout << LLA <<":" << LLB <<":" << LLC << ":" << MM <<":" << dummy << endl;/////
    //MMin=min(MMin, add_one(MMin, MM, LLA, LLB, LLC, l));
    MMin=min(MMin, dummy);
    //cout << LLA <<":" << LLB <<":" << LLC << ":" << MM <<":" << MMin << endl;/////
  }
  return MMin;
}

int main() {
  int N, A, B, C;
  cin >>N >>A >>B >>C;
  //ABC abc;
  abc.setval(A, B, C);
  vector<int> l(8+1, 0);// with guard
  int LA=0, LB=0, LC=0;
  int M=0, MMin=3000;
  for (int i=0; i<N; i++) {
    cin >> l.at(i);
  }
  MMin=add_one(MMin, M, LA, LB, LC, l);
  cout << MMin << endl;
  return 0;
}


Measured memory_bytes: 256
#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>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
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 complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    ll N, c; cin >> N >> c ;
    ll x[100100], v[100100];
    x[0] = 0; x[N + 1] = 0; v[0] = 0; v[N + 1] = 0;
    rep1(i, N) cin >> x[i] >> v[i];
 
    ll A[100100], C[100100];
    A[0] = 0, C[0] = 0;
    rep1(i, N) {
        A[i] = A[i - 1] + v[i] + 2 * x[i - 1] - 2 * x[i];
        C[i] = max(C[i - 1], A[i]);
    }
 
    ll B[100100], D[100100];
    B[N + 1] = 0, D[N + 1] = 0;
    per1(i, N) {
        B[i] = B[i + 1] + v[i] + c - x[i + 1] - c + x[i];
        if (i == N) B[i] -= c;
        D[i] = max(D[i + 1], B[i]);
    }
 
    ll E[100100], F[100100];
    E[0] = 0, F[0] = 0;
    rep1(i, N) {
        E[i] = E[i - 1] + v[i] + x[i - 1] - x[i];
        F[i] = max(F[i - 1], E[i]);
    }
 
    ll G[100100], H[100100];
    G[N + 1] = 0, H[N + 1] = 0;
    per1(i, N) {
        G[i] = G[i + 1] + v[i] - 2 * x[i + 1] + 2 * x[i];
        if (i == N) G[i] -= 2 * c;
        H[i] = max(H[i + 1], G[i]);
    }
 
 
    ll ans = 0;
    rep(i, N + 1) {
        ans = max({ans, C[i] + D[i + 1], F[i] + H[i + 1]});
    }
 
    cout << ans << "\n";
 
    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <fstream>
#include <climits>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <list>
#include <ctime>

#define FOR(i , n)      for(int i = 0 ; i < n ; i++)
#define FORmn(i,m,n)	for(int i = m ; i < n ; i++)
#define FORrev(i,n,m)	for(int i = n - 1 ; i >= m ; i--)
#define ALL(a)			a.begin(),a.end()
#define pii				pair<long long int , long long int>
#define mp(a , b)		make_pair(a , b)

typedef long long int ll; 

using namespace std;

int main() {
	set<string> s;
	int n;
	cin>>n;
	for(int i = 0 ; i < n ; i++) {
		string x;
		cin>>x;
		s.insert(x);
	}
	cout<<s.size();
}

Measured memory_bytes: 19152
N, A, B = map(int, input().split())
arr = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    if (arr[i+1] - arr[i]) * A > B:
        ans += B
    else:
        ans += (arr[i+1] - arr[i]) * A
print(ans)

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

int main() {
  int a,b,result;
  cin>>a>>b;
  if(a>b){
    result=2*a-1;
  }else if(a<b){
    result=2*b-1;
  }else{
    result=a+b;
  }
  cout<<result;
}

Measured memory_bytes: 256
// input macro
// ref: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(unused_mut)]
fn main() {
    input!(
        n: usize,
        a: [usize; n],
    );

    let mut ans = 10_usize.pow(5);
    for ai in a.into_iter() {
        let mut cnt = 0;
        let mut res = ai;
        while res % 2 == 0 {
            cnt += 1;
            res /= 2;
        }
        ans = std::cmp::min(ans, cnt);
    }

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


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

long gcd(long A, long B){
  long a=max(A,B),b=min(A,B),c=b;
  while(b!=0){
    b=a%b;
    a=c;
    c=b;
  }
  return a;
}

int main() {
  int N;
  cin >> N;
  vector<long> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  
  vector<long> L(N),R(N),M(N);
  L.at(0)=0;
  R.at(N-1)=0;
  for(int i=1; i<N; i++){
    L.at(i)=gcd(L.at(i-1),A.at(i-1));
  }
  for(int i=N-2; i>=0; i--){
    R.at(i)=gcd(R.at(i+1),A.at(i+1));
  }
  for(int i=0; i<N; i++){
    M.at(i)=gcd(L.at(i),R.at(i));
  }
  sort(M.begin(),M.end());
  cout << M.at(N-1) << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string S;
    cin >> S;
    if(S.length() % 2 == 0){
        for(int i=0;i<S.length();i=i+2){
            if(S[i] == 'h' && S[i+1] == 'i'){
                continue;
            }
            else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    else{
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3128
#include<iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include<string>
#include<utility>
#include<iterator>
#include<regex>
#include<math.h>
#include<numeric>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007
typedef struct tree Tree;

using namespace std;

bool cmpf(pair<lli, lli> left, pair<lli, lli> right) {
	return left.first < right.first;
}
bool cmp(pair<lli, lli> left, pair<lli, lli> right) {
	if (left.first != right.first)return left.first < right.first;
	else return left.second < right.second;
}

int main() {
	lli n;
	cin >> n;
	vector<lli> a(n), b(n), c(n - 1);

	rep0(i, n)cin >> a[i];
	rep0(i, n)cin >> b[i];
	rep0(i, n - 1)cin >> c[i];
	lli ans = 0;
	rep0(i, n - 1) {
		ans += b[a[i]-1];
		if (a[i] + 1 == a[i + 1])ans += c[a[i]-1];
	}
	ans += b[a[n - 1]-1];
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<x<<endl;
#define endl "\n"
#define pb push_back
#define min3(a,b,c) min(a,min(b,c)) 
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(10);
    //cout<<fixed;
    //cout.tie(NULL);
    string s,t;
    cin>>s;
    int n=s.length();
    stack<string>st;

    int i=0;
    t=s[i];
    st.push(t);
    i++;

    while(i<n)
    {
       t=s[i];
       if(t==st.top() || (i==n-2 && s[i]==s[i+1]))
       {
           t=s.substr(i,2);
           i+=2;
           st.push(t);
       }else
       {
           st.push(t);
           i++;
       }
    }



    cout<<st.size()<<endl;


    return 0;
}


Measured memory_bytes: 11028
N = int(input())

result = 10 ** 10

for a in range(1, N):
    b = N - a
    A = 0
    while a != 0:
        A += a % 10
        a = a // 10
    B = 0
    while b != 0:
        B += b % 10
        b = b // 10

    result = min(result, A + B)

print(result)

Measured memory_bytes: 3064
#include <iostream>
#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>
#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 STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#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 h,w;
    cin>>h>>w;
    vvi ans(h,vi(w,0));
    vs s(h);
    rep(i,h)cin>>s[i];
    rep(i,h)rep(j,w){
        // cout<<i<<" "<<j<<endl;
        if(s[i][j]!='#')continue;
        rep(k,8){
            if(j+dx[k]<0||j+dx[k]>=w||i+dy[k]<0||i+dy[k]>=h)continue;
            else {
                ans[i+dy[k]][j+dx[k]]++;
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#')cout<<'#';
            else cout<<ans[i][j];
        }
        cout<<endl;
    }
}

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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

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

    int M, D;

    cin >> M >> D;

    int ans = 0;
    for (int d=1;d<=D;d++) {
        int d1 = d%10;
        int d10 = d/10;
        if ((d1 >= 2) && (d10 >= 2) && (d1*d10 <= M)) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(void)
{
  int n;
  cin>>n;
  if(n<1000)
    {
      cout<<"ABC"<<endl;
    }
  else
    {
      cout<<"ABD"<<endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
int main(){
    int N,x;
    cin>>N>>x;
    vector<int> a(N+1);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    a[N] = 1000000000;
    sort(a.begin(),a.end());
    int sum = 0;
    int i = 0;
    while(true){
        if(sum+a[i]>x){
            if(i==N)i--;
            break;
        }else if (sum+a[i]==x){
            i++;
            break;
        }else{
            sum += a[i];  
            i++;
        }
    }
    cout<<i<<endl;
}

Measured memory_bytes: 3640
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    ans = S.split('hi')
    for c in ans:
        if c != '':
            print(NO)
            return
    print(YES)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
void no() {
	printf("No\n");
	exit(0);
}
int main() {
	int n, m, q;
	scanf("%d%d%d", &n, &m, &q);
	vector<int> par(n);
	iota(par.begin(), par.end(), 0);
	function<int(int)> root = [&](int a) {
		if (par[a] == a) return a;
		return par[a] = root(par[a]);
	};
	vector<pair<int, int>> dups;
	int comps = n;
	while (q--) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		int ra = root(a), rb = root(b);
		if (c == 0) {
			if (ra == rb) continue;
			par[ra] = rb;
			--comps;
		} else {
			dups.emplace_back(a, b);
		}
	}
	if (m < n - 1) no();
	bool has = false;
	for (auto& e : dups) {
		int a = e.first, b = e.second;
		int ra = root(a), rb = root(b);
		if (ra == rb) no();
		has = true;
	}
	if (comps <= 2) {
		if (has) no();
		if (m != n - 1) no();
	} else {
		// At least 3 components.
		if (m == n - 1) {
			if (has) no();
		} else {
			ll mx = (ll)comps * (comps - 1) / 2;
			int used = n - comps;
			if (used + mx < m) no();
		}
	}
	printf("Yes\n");
}


Measured memory_bytes: 1784
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;
int main()
{
	string s;
	cin >> s;
	int f = 0;
	if (s[0] == s[1])
	{
		f = 1;
	}
	if (s[1] == s[2])
	{
		f = 1;
	}
	if (s[2] == s[3])
	{
		f = 1;
	}
	if (f == 1)
	{
		cout << "Bad" << endl;
	}
	else
	{

		cout << "Good" << endl;
	}
}

Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
#define MAX 3000
int n,k;
int fac[MAX], inv[MAX], finv[MAX];

void pre(){
	inv[1]=1;
	for (int i = 2; i <MAX ; i++)
	{
		inv[i]=inv[mod%i]*(mod-mod/i)%mod;
	}
	fac[0]=finv[0]=1;
	for (int i = 1; i < MAX; ++i)
	{
		fac[i]=fac[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ncr(int n, int r){
	if(r<0||r>n)return 0;
	return fac[n]*finv[r]%mod*finv[n-r]%mod;
}

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

   pre();
   cin >> n >> k;
   int r = n-k;

   if(n==k){
      cout << 1 << endl;
      for(int i=2;i<=n;i++){
         cout << 0 << endl;
      }
      return 0;
   }

   for(int i=1;i<=k;i++){
      int cur = ncr(k-1,i-1);
      //cout << cur << endl;
      int ans = ((2*cur%mod*ncr( r-1, i-1 )%mod + cur*ncr(r-1,i)%mod)%mod + cur*ncr(r-1,i-2)%mod )%mod;
      cout << ans << endl;
   }


return 0;
}
///....


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
 
#include <bits/stdc++.h>
#include <vector> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
const int hell=1000000007;
 
 int h[100010]={0};
 int dp[100010];
 int n,k;

int frog(int index)
{
  if(index>=n)return 0;
  if(dp[index]!=-1)return dp[index];
  
  int ans=hell;
  rep(i,1,k+1)
  {
    if(index+i<=n)
    {
      ans=min(ans,abs(h[index+i]-h[index])+frog(index+i));
    }
  }
  // if(dp[index]!=-1)dp[index]=ans;
  // else dp[index]=min(dp[index],ans);

  return dp[index]=ans;
}


int solve(){    

  memset(dp,-1,sizeof(dp));
  cin>>n>>k;
  rep(i,0,n)cin>>h[i+1];
  cout<<frog(1);


return 0;
}

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


   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);  

 int t=1;                                                                                                                  
// cin>>t;
    while(t--)
     {
      solve();
     }
    return 0;
}

Measured memory_bytes: 6144
#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;

    string S;
    cin >> S;

    int ans = 0;
    rep(pass,1000){
        vector<int> password(3);
        password.at(0) = pass/100;
        password.at(1) = pass/10 - pass/100 * 10;
        password.at(2) = pass%10;
        bool a1,a2,a3;
        a1 = a2 = a3 = false;
        rep(i,N){
            if(!a1 && S.at(i) == ('0' + password.at(0))){
                a1 = true;
                continue;
            }
            if(!a2 && a1 && S.at(i) == ('0' + password.at(1))){
                a2 = true;
                continue;
            } 
            if(a2 && S.at(i) == ('0' + password.at(2))){
                a3 = true;
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3680
package main

import "fmt"

func main() {
	var (
		n int
		d []int
	)
	fmt.Scan(&n)
	d = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&d[i])
	}
	sum := 0
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			sum += d[i] * d[j]
		}
	}
	fmt.Println(sum)
}


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

int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
 int k;
 cin>>k;
 long long ans=0;
 int temp=0;

 for(int i=1;i<=k;i++){
   for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
         temp=gcd(i, j) ;
         temp=gcd(temp,l);
         ans+=temp;
      }
   }
 }
 cout<<ans<<endl;
  
  
 
  return 0;
    
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int N;
    cin >> N;
    ll max = 0;
    ll sum = 0;
    REP(i, N)
    {
        ll p;
        cin >> p;
        sum += p;
        max = std::max(max, p);
    }
    cout << sum - max / 2 << endl;
    return 0;
}

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

int main(){
  	int K, S;
  	cin >> K >> S;
  	int counter=0;
  	for(int A=0;A<=K;A++){
	  	for(int B=0;B<=K;B++){
	        if(S-A-B >=0 && S-A-B <= K) counter++;
    	}
    }
  	cout << counter << endl;
}

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

using namespace std;

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

    int n;
    cin >> n;
    int min_count[26];
    for (int i = 0; i < 26; i++) {
        min_count[i] = numeric_limits<int>::max();
    }

    for (int i = 0 ; i < n; i++) {
        string s;
        cin >> s;
        vector<int> c(26, 0);
        for (int j = 0; j < s.size(); j++) {
            c[s[j] - 'a']++;
        }
        for (int j = 0; j < 26; j++) {
            min_count[j] = min(min_count[j], c[j]);
        }
    }

    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < min_count[i]; j++) {
            cout << char(i + 'a');
        }
    }
    cout << '\n';
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Calc
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a;
  scanf("%d", &a);

  printf("%d\n", a + a * a + a * a * a);
  return 0;
}


Measured memory_bytes: 3188
import sys
s = list(input())
t = list(input())
ss = "".join(s)
tt = "".join(t)
ls = []
for i in range(len(ss)-len(tt)+1):
    l = s[i:i+len(tt)]
    for j in range(len(tt)):
        if l[j] != t[j] and l[j] != "?":
            break
        else:
            l[j] = t[j]
    else:
        l = "".join(l)
        l = "".join(s[:i]) + l + "".join(s[i+len(tt):])
        l = l.replace("?","a")
        ls.append(l)
if ls == []:
    print("UNRESTORABLE")
else:
    ls.sort()
    print(ls[0])
            
    
            


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
  int n, k;
  string s;
  cin >> n >> s >> k;
  char key = s[k - 1];
  for (int i = 0; i < n; i++) {
    if (s[i] != key) s[i] = '*';
  }
  cout << s << endl;
}

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

int gcd(int a,int b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

int main(void){
    int n,m,cnt = 1;
    cin >> n >> m;
    for(int i = 1;i*i <= m;i++){
        if(m % i == 0 && i <= (m/n)){
            cnt = max(cnt,i);
            if((m/i) <= (m/n)){
                cnt = max(cnt,(m/i));
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(n)    for(int i = 0; i < (n); ++i)
#define RREP(n)   for(int i = (n); i >= 0; --i)
#define FOR(m, n) for(int i = (m); i < (n); ++i)
#define SZ(x)       ( (int)(x).size() )
#define BIT(n)      ( 1LL << (n) )
#define EXIST(x)    ( (x).find()		!= (x).end() )
#define DEBUG(n)    cerr << #n << " : " << n << '\n';
#define PB  push_back
#define UB  upper_bound			//k <
#define LB  lower_bound			//k	<= 
#define F   first
#define S   second
#define INF 1.0e9


using namespace std;

typedef long long			ll;
typedef pair<int, int>		pii;
typedef pair<long			long, long long>   pll;
typedef vector<int>			vi;
typedef vector<double>		vd;
typedef vector<long long>   vll
;

template<class T> void chmax(T &	a, const T & b){ if( a < b ) a = b; }
template<class T> void chmin(T &	a, const T & b){ if( a > b ) a = b; }

int r_up(const int a, const int b){ return (a + b - 1) / b; }

const int dx[] = { 0,  0, 1, -1 };
const int dy[] = { 1, -1, 0,  0 };

struct UFT{
  vi	p;
  UFT(){}
  UFT(int N)       { p.resize( N, -1 ); }
  int	par(int a)   { if( p[a] >= 0 ){ p[a]  = par( p[a] ); return p[a]; } return a;  }
  int size(int a)  { return -p[par(a)]; }
  bool	same(int a, int b) { return par(a)	 == par(b); }
  void unite(int	a, int b){
	a													  = par(a);  b = par(b);
	if( a == b ) return;
	if( size(a) < size(b) ) swap(a,b);
	p[a]												 -= size(b);
	p[b]												  = a;
  }
};

int main(){
  int n,sum=0;  cin>>n;
  vi p(n);
  REP(n){cin>>p[i];sum+=p[i];}
  sort(p.rbegin(),p.rend());
  cout<<sum-p[0]/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Edge{
	int src,dst,weight;
	Edge(){}
	Edge(int s,int d,int w):src(s),dst(d),weight(w){}
	bool operator<(const Edge& e)const{return weight<e.weight;}
	bool operator>(const Edge& e)const{return weight>e.weight;}
};
ostream& operator<<(ostream& os,const Edge& e){
	return os<<'('<<e.src<<','<<e.dst<<','<<e.weight<<')';
}

bool BellmanFord(const vector<Edge>& es,int size,int begin,vi& dp)
{
	bool neg=false;
	dp[begin]=0;
	rep(k,size){
		neg=false;
		for(Edge e:es)
			if(dp[e.dst]>dp[e.src]+e.weight){
				dp[e.dst]=dp[e.src]+e.weight;
				neg=true;
			}
	}
	return neg;
}

int main()
{
	for(int m,n,k,d;cin>>m>>n>>k>>d,m|n|k|d;){
		vi cs(m);
		rep(i,m) cin>>cs[i];
		
		int start=2*m+n,goal=start+1,v=goal+1;
		vector<Edge> es;
		rep(i,1<<m) rep(j,m)
			if(!(i>>j&1))
				es.emplace_back(i*v+j,(i|1<<j)*v+m+j,-cs[j]);
		
		while(d--){
			string src,dst; int dist; cin>>src>>dst>>dist;
			int si=-1;
			if(src[0]=='H') si=start;
			if(src[0]=='D') si=goal;
			if(src[0]=='C') si=stoi(src.substr(1))-1;
			if(src[0]=='L') si=2*m+stoi(src.substr(1))-1;
			int di=-1;
			if(dst[0]=='H') di=start;
			if(dst[0]=='D') di=goal;
			if(dst[0]=='C') di=stoi(dst.substr(1))-1;
			if(dst[0]=='L') di=2*m+stoi(dst.substr(1))-1;
			rep(i,1<<m){
				int si2=si,di2=di;
				if(src[0]=='C') si2+=m;
				if(dst[0]=='C') di2+=m;
				es.emplace_back(i*v+si2,i*v+di,dist*k);
				es.emplace_back(i*v+di2,i*v+si,dist*k);
			}
		}
		
		int size=(1<<m)*v;
		vi dp(size,INFTY);
		BellmanFord(es,size,start,dp);
		
		int res=INFTY;
		rep(i,1<<m)
			res=min(res,dp[i*v+goal]);
		cout<<res<<endl;
	}
	
	return 0;
}

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

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(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  vector<vector<ll>> match_l(n);
  vector<vector<ll>> match_r(n);
  rep(i,n){
    if(i - a[i] >= 0){
      match_l[i-a[i]].push_back(i);
    }
    if(i + a[i] <= n-1){
      match_r[i+a[i]].push_back(i);
    }
  }

  ll ans = 0;
  rep(i,n){
    ll tmp_l = match_l[i].size();
    ll tmp_r = match_r[i].size();
    ans += tmp_r*tmp_l;
  }
  

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 22576
#include <bits/stdc++.h>
using namespace std;
int main(){
    int num, nanicount;
    cin >> num;
    string nani;
    cin >> nani;
    nanicount=nani.length();
    if(num>=nanicount){
        cout << nani;
        return 0;
    }
    else{
        for(int i = 0; i<num; i++){
            cout << nani[i];
        }
        cout << "...";
    }
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull B = 100000007;
ll mod = 1000000007;
int INF = 0x3f3f3f3f;

int main() {
    ll x;
    cin >> x;
    ll t = 100;
    int res = 0;
    while(t < x) {
        double tmp = t;
        tmp = floor(tmp * 1.01);
        t = tmp;
        res++;
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 3604
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>
 
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    ll N,M,K;
    cin >> N >> M >> K;

    ll distance_sum=0;
    for(ll d=1; d < N; d++){
        distance_sum += d*(N - d)%MOD*M%MOD*M%MOD;
    }
    for(ll d=1; d < M; d++){
        distance_sum += d*(M - d)%MOD*N%MOD*N%MOD;
    }

    

    COMinit();
    cout << distance_sum%MOD*COM(N*M-2,K-2) % MOD<< endl;
}


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

int main()
{
        string s;

        getline(cin, s);

        for(int i = 0; i < s.length(); i++) {
                if(s[i] == '\0') {
                        break;
                } if((int)s[i]>=0x41 && (int)s[i]<=0x5a) {
                        s[i] += 0x20;
                } else if((int)s[i]>=0x61 && (int)s[i]<=0x7a) {
                        s[i] -= 0x20;
                }
                cout << s[i];
        }

        cout << endl;

        return 0;
}


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

using namespace std;

int N, K, H[112345];
long long dp[112345];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> H[i];
	for (int i = 1; i < N; i++) {
		dp[i] = 1e18;
		for (int k = 1; k <= min(i, K); k++) {
			dp[i] = min(dp[i], dp[i - k] + abs(H[i] - H[i - k]));
		}
	}
	cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1408
#include<cstdio>
#define For(i, a, b) for(register int i = a; i <= b; ++i)
using namespace std;
const int maxn = 6e3 + 5;
const int mod = 998244353;
int f[maxn][maxn], a, b, c, d;

int main() {
	scanf("%d%d%d%d", &a, &b, &c, &d);
	f[a][b] = 1;
	For(i, a, c) For(j, b, d) {
		if(i == a && j == b) continue;
		f[i][j] = (1ll * f[i - 1][j] * j % mod + 1ll * f[i][j - 1] * i % mod) % mod - 
			((1ll * f[i - 1][j - 1] * (i - 1) % mod) * (j - 1)) % mod;
		if(f[i][j] < 0) f[i][j] += mod;
	}
	printf("%d", f[c][d]);
	return 0;
}

Measured memory_bytes: 48820
import Control.Monad
import Data.List

main=do
    [sx,sy,tx,ty] <- map read.words<$>getLine::IO [Int]
    let (dx,dy) = (tx-sx, ty-sy)
    putStrLn $ replicate dy 'U' ++ replicate dx 'R' ++ replicate dy 'D' ++ replicate dx 'L'
        ++ "L" ++ replicate (dy+1) 'U' ++ replicate (dx+1) 'R' ++ "DR"
        ++ replicate (dy+1) 'D' ++ replicate (dx+1) 'L' ++ "U"


Measured memory_bytes: 1020
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

def divisor(n)
  result = SortedSet.new
  result.add(1); result.add(n)
  i = 1
  num = Math.sqrt(n)
  while i <= num do
    remainder = n % i
    if remainder == 0
      result.add(i)
      result.add(n/i)
    end
    i += 1
  end
  result.to_a
end

ans = []
1.step(N) do |n|
  next if n % 2 == 0

  divs = divisor(n)
  ans << n if divs.length == 8
end

puts ans.length


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

int main() {
	int n,k,x; cin>>k>>n; 
	vector<int>b;
	vector<int>a;
	for(int i=0;i<n;i++) {
		cin>>x; a.push_back(x); 
		cin>>x; b.push_back(x);
	}
	sort(b.begin(),b.end()); sort(a.begin(),a.end());
	if((b[0]-a[n-1])>=0) cout<<b[0]-a[n-1]+1<<endl;
	else cout<<"0"<<endl;
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
/*#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>
#include <climits>
#include <iomanip>
*/
using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;

int ans = 0;
ll n;

void dfs(ll num , int mask)
{
    if(num > n)
        return;
    if(mask == 7)   ans++;
    
    dfs(num*10+3 , mask|4);
    dfs(num*10+5 , mask|2);
    dfs(num*10+7 , mask|1);
}

int main()
{
	FAST;
	cin >> n;
	dfs(0 , 0);
	
	cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) {
    if(b==0) return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
int main() {
    ll N; cin >> N;
    vector<ll> T(N), A(N);
    rep(i, N) cin >> T[i] >> A[i];
    ll a=1, b=1;
    rep(i, N) {
        ll x = max((a+T[i]-1)/T[i], (b+A[i]-1)/A[i]);
        a = T[i]*x; b = A[i]*x;
    }
    cout << a + b;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 101
#define R 101

int main(){
  int n,i,j,k,l,p[N],m[R][R];

  scanf("%d",&n);
  for(i = 1;i <= n; i++){
    scanf("%d %d",&p[i-1],&p[i]);
    m[i][i] = 0;
  }

  for(l = 2;l <= n;l++){
    for(i = 1;i <= n-l+1;i++){
      j = i+l-1;
      m[i][j] = 10000000;
      for(k = i;k <= j-1;k++){
	if(m[i][j] > m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]) m[i][j] = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
      }
    }
  }

  printf("%d\n",m[1][n]);
  
  return 0;
}



Measured memory_bytes: 2056
class UnionFind:
  def __init__(self, n):
    self.parent = [i for i in range(n)]
    self.height = [0 for i in range(n)]
        
  def get_root(self, i):
    if self.parent[i] == i:
      return i
    else:
      self.parent[i] = self.get_root(self.parent[i])
      return self.parent[i]
            
  def unite(self, i, j):
    root_i = self.get_root(i)
    root_j = self.get_root(j)
    if root_i != root_j:
      if self.height[root_i] < self.height[root_j]:
        self.parent[root_i] = root_j
      else:
        self.parent[root_j] = root_i
        if self.height[root_i] == self.height[root_j]:
          self.height[root_i] += 1
                
  def is_in_group(self, i, j):
    if self.get_root(i) == self.get_root(j):
      return True
    else:
      return False
    
N, M = map(int, input().split())
graph = list()
ans = 0
for i in range(M):
  a, b = map(int, input().split())
  graph.append([a-1, b-1])
for i in range(M):
  flag = 0
  uf = UnionFind(N)
  for j in range(M):
    if(i != j):
      uf.unite(graph[j][0], graph[j][1])
  for k in range(1, N):
    if uf.is_in_group(0, k) == False:
      flag = 1
  if(flag == 1):
    ans += 1
print(ans)

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

using namespace std;

string distinct(int N, vector<int>& A) {
	unordered_set<int> seen(A.begin(), A.end());
	return (N == seen.size()) ? "YES" : "NO";
}

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	cout << distinct(N, A);
	return 0;
}

Measured memory_bytes: 8832
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    a, b = map(int, input().split())

    if 1 <= a <= 9 and 1 <= b <= 9:
        print(a * b)
    else:
        print(-1)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;
  vi A(N), B(N);
  rep(i,N){
    cin >> A[i] >> B[i];
  }

  i64 ans = 0;
  rrep(i, N - 1, -1){
    ans += (B[i] - (A[i] + ans) % B[i]) % B[i]; 
  }

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

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


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

using namespace std;

bitset<1000001> prime;
vector<int> v;


void sieve(){
    long long n = 1000000;
    prime.set();

    prime[0] = prime[1] = 0;
    
    for (long long p=2; p<=n; p++){
        if (prime[p]){
            v.push_back(p);
            for (long long i=p*p; i<=n; i += p)
                prime[i] = 0;
        }
    } 
}

int main(){
    
    
    long long a,b;
    
    cin >> a >> b;
    long long x = __gcd(a,b);
    int res = 1;
    sieve();
    
    
    for(int p:v){
    
        if(x % p == 0){
            res++;
            while(x % p == 0) x = x/p;
        }
    
    
    }
    
    if(x != 1) res++;
    
    cout << res << endl;


}

Measured memory_bytes: 1020
//    _____ _     _                _           _     _ _     _     
//    \_   \ |_  (_)___  __      _| |__   __ _| |_  (_) |_  (_)___ 
//     / /\/ __| | / __| \ \ /\ / / '_ \ / _` | __| | | __| | / __|
//  /\/ /_ | |_  | \__ \  \ V  V /| | | | (_| | |_  | | |_  | \__ \
//  \____/  \__| |_|___/   \_/\_/ |_| |_|\__,_|\__| |_|\__| |_|___/
//                                                                 
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=2e5+9;
int n;
map<string,int> m;
string s;


int main(){
	cin>>n;
	int mx=-1;
	for(int i=0;i<n;i++){
		cin>>s;
		m[s]++;
		mx=max(mx,m[s]);
	}	
	vector<string>v;
	for(auto u:m){
		if(u.s==mx) v.pb(u.f);
	}
	sort(all(v));
	for(auto u:v) cout<<u<<'\n';
	return 0;
}

Measured memory_bytes: 26868
#include <stdio.h>
int main()
{
  int x,y,f=0;
  scanf("%d%d", &x,&y);
  
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      if(i+j==x && (2*i+4*j)==y){
        f=1;
      }
    }
  }
  if(f==1) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int main() {
	double a, b, c, pi = atan2(0, -1);
	cin >> a >> b >> c;
	if (a * a * b / 2 < c) {
		double d = a * a * b - c;
		double e = d * 2 / (a * a);
		double ans = atan2(e, a);
		ans = ans / (2 * pi) * 360;
		printf("%.10f\n", ans);
	}
	else {
		double e = c * 2 / (a * b);
		double ans = atan2(b, e);
		ans = ans / (2 * pi) * 360;
		printf("%.10f\n", ans);
	}
}

Measured memory_bytes: 384