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

#define INF 1e16
#define MAX_N 2000
const long long MOD = 1e9 + 7;

long long extgcd(long long a, long long b, long long& x, long long& y) {
    long long d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}
long long mod_inverse(long long a, long long m) {
    long long x, y;
    if (extgcd(a, m, x, y) == 1)
        return (m + x % m) % m;
    else
        return -1;
}
vector<long long> fact(MAX_N + 1, INF);
long long mod_fact(long long n, long long& e) {
    if (fact[0] == INF) {
        fact[0] = 1;
        if (MAX_N != 0) fact[1] = 1;
        for (int i = 2; i <= MAX_N; ++i) {
            fact[i] = (fact[i - 1] * i) % MOD;
        }
    }
    e = 0;
    if (n == 0) return 1;
    long long res = mod_fact(n / MOD, e);
    e += n / MOD;
    if ((n / MOD) % 2 != 0) return (res * (MOD - fact[n % MOD])) % MOD;
    return (res * fact[n % MOD]) % MOD;
}
// return nCk
long long mod_comb(long long n, long long k) {
    if (n < 0 || k < 0 || n < k) return 0;
    long long e1, e2, e3;
    long long a1 = mod_fact(n, e1), a2 = mod_fact(k, e2),
              a3 = mod_fact(n - k, e3);
    if (e1 > e2 + e3) return 0;
    return (a1 * mod_inverse((a2 * a3) % MOD, MOD)) % MOD;
}

int main() {
    long long N, K;
    cin >> N >> K;
    long long red = N - K;
    for (long long i = 1; i <= K; i++) {
        long long a = mod_comb(red + 1, i);
        long long b = mod_comb(K - 1, i - 1);
        cout << a * b % MOD << endl;
    }
}

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

int main() {
    int n,k;
    scanf("%d%d",&n,&k);
    vector<int> d(k);
    rep(i,k) {
        scanf("%d",&d[i]);
    }
    int ans = 0;
    for(int i = n; i <= 10000000; i++) {
        string s = to_string(i);
        bool ok = true;
        rep(j,s.size()) {
            int x = s[j] - '0';
            rep(g,k) {
                if(x == d[g]) {
                    ok = false;
                    break;
                }
            }
            if(!ok) {
                break;
            }
        }
        if(ok) {
            ans = i;
            break;
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

int main(){
  int N;
  int T;
  int A;
  cin >>N;
  cin >>T>>A;
  float min=100000000;
  int height;
  float tmp;
  int index=-1;
  for(int i=0;i<N;i++){
    cin >> height ;
    tmp=abs(T-height*0.006-A);
    if(tmp <min){
      index=i;
      min=tmp;
    }
  }
  cout <<index+1<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 準備
            List<ClsInp> lstInp = new List<ClsInp>();

            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            sS = System.Console.ReadLine().Trim().Split(' ');

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            // 指定箇所の左側の最大公約数取得(自身を含めない)
            int iGcd = int.Parse(sS[0]);
            lstInp.Add(new ClsInp() { iX = int.Parse(sS[0]), iL = 0 });
            for (int i = 1; i < sS.Length; i++)
            {
                ClsInp oneUsr = new ClsInp();
                oneUsr.iX = int.Parse(sS[i]);
                oneUsr.iL = iGcd;
                iGcd = Gcd(iGcd, int.Parse(sS[i]));
                lstInp.Add(oneUsr);
            }
            // 指定箇所の右側の最大公約数取得(自身を含めない)
            iGcd = lstInp[lstInp.Count - 1].iX;
            lstInp[lstInp.Count - 1].iR = 0;
            for (int i = lstInp.Count - 1 - 1; i >= 0; i--)
            {
                lstInp[i].iR = iGcd;
                iGcd = Gcd(iGcd, lstInp[i].iX);
            }
            // 指定箇所の左側と右側の最大公約数取得(自身を含めない)
            for (int i = 0; i < lstInp.Count; i++)
            {
                lstInp[i].iM = Gcd(lstInp[i].iL, lstInp[i].iR);
            }
            //DebugDisp(lstInp);
            lstInp.Sort(delegate (ClsInp mca1, ClsInp mca2) { return (int)(mca2.iM - mca1.iM); });        // iMの降順

            // 出力
            System.Console.WriteLine("{0}", lstInp[0].iM.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

        // debug
        private static void DebugDisp(List<ClsInp> lstInp)
        {
            for (int i = 0; i < lstInp.Count; i++)
            {
                string sOut = "" ;
                sOut += " iX = " + lstInp[i].iX.ToString("000");
                sOut += " iL = " + lstInp[i].iL.ToString("000");
                sOut += " iR = " + lstInp[i].iR.ToString("000");
                sOut += " iM = " + lstInp[i].iM.ToString("000");
                System.Console.WriteLine("{0}", sOut.ToString());
            }
        }

        // 最大公約数取得
        private static int Gcd(int a, int b)
        {
            if (a < b) { return Gcd(b, a); }
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

        private class ClsInp
        {
            public int iX { get; set; } = 0;    // 値
            public int iL { get; set; } = 0;    // 左側の最大公約数(自身を含めない)
            public int iR { get; set; } = 0;    // 右側の最大公約数(自身を含めない)
            public int iM { get; set; } = 0;    // 左側と右側の最大公約数(自身を含めない)
        }

}


Measured memory_bytes: 30812
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

sx, sy, tx, ty = nm()

ans = ''

ans += 'L'
ans += 'U' * (ty - sy + 1)
ans += 'R' * (tx - sx + 1)
ans += 'D'

ans += 'L' * (tx - sx)
ans += 'D' * (ty - sy)

ans += 'D'
ans += 'R' * (tx - sx + 1)
ans += 'U' * (ty - sy + 1)
ans += 'L'

ans += 'D' * (ty - sy)
ans += 'L' * (tx - sx)

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
#define INF 1e9
#define INFL 1e12
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    int a, b; cin>>a>>b;
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n;
	cin >> n;
	
	vector<ll> a(n), b(n);
	
	for(int i = 0; i < n; i++)
		cin >> a[i];
	
	for(int i = 0; i < n; i++)
		cin >> b[i];
	
	ll ans = 0;
	
	vector<ll> c(n);
	for(int i = 0; i < n; i++)
		c[i] = a[i] - b[i];
	
	sort(c.rbegin(), c.rend());
	ll sum = 0;
	
	for(int i = 0; i < n; i++){
		sum += c[i];
		ans = max(ans, sum);
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

const int INF = 1e18;

#define GRAY 400
#define BROWN 800
#define GREEN 1200
#define SKY 1600
#define BLUE 2000
#define YELLOW 2400
#define ORANGE 2800
#define RED 3200
#define WHITE -1

void solve()
{
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("./sample.txt");
    std::cin.rdbuf(in.rdbuf());

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

    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n)
    {
        int a;
        cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for (auto nmp : mp)
    {
        int key = nmp.first;
        int value = nmp.second;

        ans += (value - key >= 0) ? value - key : value;
    }

    cout << ans << endl;
}

signed main()
{
    solve();
    return 0;
}


Measured memory_bytes: 6272
N, K = map(int, input().split())
mod = 10**9 + 7
nums = []
p_cnt = 0
for i in list(map(int, input().split())):
    if i >= 0:
        nums.append((i, True))
        p_cnt += 1
    else:
        nums.append((-i, False))
nums.sort()
if p_cnt == 0 and K%2!=0:
    ans = 1
    for k in range(K):
        ans *= -nums[k][0]
        ans %= mod
    print(ans)
    import sys
    sys.exit()
pl = []
ml = []
for k in range(K):
    x, b = nums.pop()
    if x == 0:
        print(0)
        import sys
        sys.exit()
    if b:
        pl.append(x)
    else:
        ml.append(x)
if len(ml) % 2 != 0:
    p = float("inf")
    px = float("inf")
    m = float("inf")
    mx = float("inf")
    while nums:
        x, b = nums.pop()
        if b:
            if ml and p == float("inf"):
                p = ml[-1]
                px = x
        else:
            if pl and m == float("inf"):
                m = pl[-1]
                mx = x
        if m != float("inf") and p != float("inf"):
            if px * m > mx * p:
                ml.pop()
                pl.append(px)
            else:
                pl.pop()
                ml.append(mx)
            break
    else:
        if p != float("inf"):
            ml.pop()
            pl.append(px)
        elif m != float("inf"):
            pl.pop()
            ml.append(mx)
ans = 1
for x in pl:
    ans *= x
    ans %= mod
for x in ml:
    ans *= -x
    ans %= mod
print(ans)

Measured memory_bytes: 114388
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
int A,B,C,D;
cin >> A >> B >> C >> D;
bool e = false;
bool r = false;
bool l = false;
if(A + B == C + D)e = true;
if(A + B > C + D)r = true;
if(A + B < C + D)l = true;
if(e)cout << "Balanced" << endl;
if(r)cout << "Left" << endl;
if(l)cout << "Right" << endl;
        return 0;
}

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

using namespace std;

int main(){
    long int x,k,d;
    cin >> x >> k >> d;

    long int c = abs(x)/d;

    c = min(c,k);

    x = (x < 0 ? x + c * d : x - c * d);
    k -= c;

    k %= 2;

    long int ans = min(abs(x - k * d), abs(x + k * d));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    string s,t;
    cin >> s >> t;

    int ans = 0;

    for(int i=0; i<s.size(); i++){
        if(s[i] != t[i]) ans ++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<string>
//#include<queue>
//#include<cmath>
//#include<algorithm>
//#define debug1 cout<<"?"<<endl;
//#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
typedef long long ll;
const int maxn=3e5+9;
const double pi=acos(-1);
const int mod=998244353;
const int INF=0x3f3f3f3f;
const double ep=1e-7;
using namespace std;
int main()
{
	int a,b,m;
	int aa[maxn]={0},ma1=1e9,bb[maxn]={0},ma2=1e9;
	scanf("%d%d%d",&a,&b,&m);
	for(int i=1;i<=a;i++)scanf("%d",&aa[i]),ma1=min(ma1,aa[i]);
	for(int i=1;i<=b;i++)scanf("%d",&bb[i]),ma2=min(ma2,bb[i]);
	int ans=ma1+ma2;
	while(m--)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		ans=min(ans,aa[x]+bb[y]-z);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
string s;
void dfs(ll wei)
{
	if(wei==n)
	{
		cout<<s<<endl;
	}
	else
	{
		char ma='a';
		for(ll i=0;i<wei;i++)
		{
			ma=max(ma,s[i]);
		}
		for(ll i='a';i<=ma+1;i++)
		{
			s[wei]=i;
			dfs(wei+1);
		}
	}
}
int main(void)
{
	scanf("%lld",&n);
	for(ll i=0;i<n;i++)
	{
		s.push_back('a');
	}
	s[n]='\0';
	dfs(1);
}

Measured memory_bytes: 1536
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
int ckck(int n)
{
    if(n==2||n==3)
        return 1;
    else if(n%2==0||n%3==0)
        return 0;
    else
    {
        for(int j=2;j*j<=n;j++)
        {
            if(n%j==0)
                return 0;
        }
        return 1;
    }
}
const ll N=1e5+5;
ll freq[N+1]={0};
int main()
{
   char p;
   cin>>p;
   if(p>='A'&&p<='Z')
    cout<<"A";
   else
    cout<<"a";


}




Measured memory_bytes: 3628
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    
    if(s == "AC") AC++;
    if(s == "WA") WA++;
    if(s == "TLE") TLE++;
    if(s == "RE") RE++;
  }
  
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
  
  return 0;
}


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

int main(){
  int a[5];
  double ave = 0.0;

  for(int i = 0 ; i < 5 ; i++){
    cin >> a[i];
    ave += (a[i] >= 40 ?  a[i] : 40);
  }
  cout << ave / 5 << endl;

  return 0;
}

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

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

  int ans = 1;
  int max_count = 0;
  for (int i = 1; i <= N; i++) {
    int count = 0;
    int num = i;
    while (num % 2 == 0) {
      num = num / 2;
      count++;
    }

    if (count > max_count) {
      max_count = count;
      ans = i;
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

template< typename Monoid >
struct SegmentTree {
    using F = function< Monoid(Monoid, Monoid) >;
    int size;
    vector< Monoid > data;

    const F f;
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
        size = 1;
        while(size < n) size *= 2;
        data.assign(2*size-1, M1);
    }

    SegmentTree(vector<Monoid> vec, const F f, const Monoid &M1) : f(f), M1(M1) {
        size = 1;
        while(size < sz(vec)) size *= 2;
        data.assign(2*size-1, M1);

        rep(i, size) data[i+size-1] = vec[i];
        for(int i=sz(vec)-2; i>=0; i--) data[i] = f(data[2*i+1], data[2*i+2]);
    }

    void update(int x, const Monoid &val) {
        x += size-1;
        data[x] = val;
        while(x) {
            x = (x-1) / 2;
            data[x] = f(data[2*x+1], data[2*x+2]);
        }
    }

    Monoid query(int a, int b, int k=0, int l=0, int r=-1) {
        if (r<0) r = size;
        if (r<=a || l>=b) return M1;
        if (a<=l && b>=r) return data[k];
        Monoid val_l = query(a, b, 2*k+1, l, (l+r)/2);
        Monoid val_r = query(a, b, 2*k+2, (l+r)/2, r);
        return f(val_l, val_r);
    }
};

int main() {
    int n, q; cin >> n >> q;
    SegmentTree<ll> seg(n, [](ll a, ll b){return min(a,b);}, (1ll<<31)-1ll);
    rep(i, q) {
        int c, x, y; cin >> c >> x >> y;
        if (!c) seg.update(x, y);
        else cout << seg.query(x, y+1) << endl;
        debug(seg.data);
    }
}


Measured memory_bytes: 4912
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

struct edge {
  int from;
  int to;
  edge(int from, int to) : from(from), to(to) {}
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int> > G(3*N);
  rep(i, M) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    G[u].push_back(N+v);
    G[N+u].push_back(2*N+v);
    G[2*N+u].push_back(v);
  }
  int S, T;
  cin >> S >> T;
  S--, T--;
  vector<int> D(3*N, inf);
  vector<bool> vis(3*N);
  queue<edge> Q;
  Q.push(edge(-1, S));
  while(!Q.empty()) {
    auto ne = Q.front();
    Q.pop();
    if(!vis[ne.to]) {
      vis[ne.to] = true;
      D[ne.to] = ne.from != -1 ? D[ne.from]+1 : 0;
      for(auto to: G[ne.to])
        Q.push(edge(ne.to, to));
    }
  }
  cout << (D[T] == inf ? -1 : D[T] / 3) << endl;
  return 0;
}



Measured memory_bytes: 17920
use std::cmp;
use std::collections::BTreeMap;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n = read_as_vec::<usize>()[0];
    let a = read_as_vec::<u64>();
    let mut tree: BTreeMap<u64, u64> = BTreeMap::new();
    for elem in a {
        *tree.entry(elem).or_insert(0) += 1;
    }
    let mut ans: u64 = 0;
    for (k, v) in &tree {
        ans += k * v;
    }

    let q = read_as_vec::<usize>()[0];
    for _ in 0..q {
        let line = read_as_vec::<u64>();
        let (b, c) = (line[0], line[1]);
        let bnum = *tree.entry(b).or_insert(0);
        let removed = bnum * b;
        let added = bnum * c;
        ans = ans + added - removed;
        println!("{}", ans);
        *tree.entry(c).or_insert(0) += *tree.entry(b).or_insert(0);
        *tree.entry(b).or_insert(0) = 0;
    }
}


Measured memory_bytes: 4872
#include<bits/stdc++.h>
#define N 500005
#define M 500005
using namespace std;
inline int read(){
    int ans=0;
    char ch=getchar();
    while(!isdigit(ch))ch=getchar();
    while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
    return ans;
}
int n,m,first[N],cnt=0,d[N];
bool vis[N];
struct edge{int v,next,c;}e[M<<1];
inline void add(int u,int v,int c){e[++cnt].v=v,e[cnt].next=first[u],e[cnt].c=c,first[u]=cnt;}
struct heap{int u,v;};
inline bool operator<(heap a,heap b){return a.v==b.v?a.u<b.u:a.v<b.v;}
priority_queue<heap>q;
set<int>col[N];
inline void dijkstra(){
    for(int i=2;i<=n;++i)d[i]=0x3f3f3f3f,vis[i]=false;
    d[1]=0;
    q.push((heap){1,d[1]});
    while(!q.empty()){
        heap x=q.top();
        q.pop();
        if(vis[x.u])continue;
        vis[x.u]=1;
        for(int i=first[x.u];i;i=e[i].next){
            int v=e[i].v,w=col[x.u].count(e[i].c)?0:1;
            if(d[v]>d[x.u]+w)d[v]=d[x.u]+w,q.push((heap){v,-d[v]}),col[v].clear(),col[v].insert(e[i].c);
            else if(d[v]==d[x.u]+w)col[v].insert(e[i].c);
        }
    }
}
signed main(){
    n=read();m=read();
    for(int i=1;i<=m;i++){
        int x=read();int y=read();int z=read();
        add(x,y,z);add(y,x,z);
    }
    memset(d,0x3f,sizeof(d));
    dijkstra();
    if(d[n]==0x3f3f3f3f)cout<<-1<<endl;
    else cout<<d[n]<<endl;
    return 0;
}

Measured memory_bytes: 42744
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
using namespace std;

int n, k, cnt, mem, a[200000], ans;


int main(){
	cin >> n >> k;
	lp(200000)
		a[i] = 0;
	lp(n) {
		cin >> mem;
		a[mem - 1]++;
	}
	cnt = 0;
	ans = 0;
	lp(200000)
		if (a[i])cnt++;
	sort(a, a + 200000);
	lp(200000) {
		if (cnt <= k)break;
		if (a[i]) {
			ans += a[i];
			cnt--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

ll grid[600][600];

int main() {
  ll H, W;
  scanf("%lld %lld", &H, &W);

  for (ll y = 0; y < H; y++) {
    for (ll x = 0; x < W; x++) {
      ll v;
      scanf("%lld", &v);
      grid[y][x] = v;
    }
  }

  vector<tuple<ll, ll, ll, ll>> list;

  ll y = 0;
  ll x = 0;

  ll vx = 1;
  for (;;) {
    if (y >= H) {
      break;
    }
    ll v = grid[y][x];
    ll edge = (vx > 0 && x == W - 1) || (vx < 0 && x == 0);
    ll ty, tx;
    if (!edge) {
      ty = y;
      tx = x + vx;
    } else {
      ty = y + 1;
      tx = x;
    }

    if (v % 2 == 1) {
      if (tx < W && ty < H) {
        grid[y][x]--;
        grid[ty][tx]++;
        list.emplace_back(make_tuple(y, x, ty, tx));
      }
    }

    x = tx;
    y = ty;

    if (edge) {
      vx = -vx;
    }
  }

  cout << (list.size()) << endl;
  for (ll i = 0; i < list.size(); i++) {
    auto v = list[i];

    ll y = get<0>(v) + 1;
    ll x = get<1>(v) + 1;
    ll ty = get<2>(v) + 1;
    ll tx = get<3>(v) + 1;

    cout << (y) << " " << (x) << " " << (ty) << " " << (tx) << endl;
  }
}


Measured memory_bytes: 9812
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    int A[2], B[2];
    cin >> A[0] >> A[1]; 

    for (int i = 0; i < 2; i++) {
        if (((A[i] % 2) == 1) && (A[i] < 9)) {
            B[i] = 1;
        } else if (((A[i] % 2) == 1) && (A[i] >= 9)) {
            B[i] = 2;
        }
        if (((A[i] % 2) == 0) && (A[i] == 2)) {
            B[i] = 3;
        } else if (((A[i] % 2) == 0) && (A[i] <= 6)) {
            B[i] = 2;
        } else if (((A[i] % 2) == 0) && (A[i] >= 8)) {
            B[i] = 1;
        }
    }

    if (B[0] == B[1]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int main()
{
	int n,num;
	while(~scanf("%d",&n)) {
		scanf("%d",&num);
		int maxx=-INF,minn=num;
		for (int i=1;i<n;i++) {
			scanf("%d",&num);
			maxx=max(maxx,num-minn);
			minn=min(minn,num);
		}
		printf("%d\n",maxx);
	}	
 	return 0;
}

Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;

int main(){
  int n;
  string a,b;
  cin>>n;
  for(int j=0;j<n;j++){
    cin>>a>>b;
    int asize=a.length();
    int bsize=b.length();
    int smax=max(asize,bsize);
    bool flag=false;
    int s;
    stringstream ss;
    for(int i=0;i<smax;i++){
      if(asize-i-1<0) s=strtol(b.substr(bsize-i-1,1).c_str(),NULL,0);
      else if(bsize-i-1<0) s=strtol(a.substr(asize-i-1,1).c_str(),NULL,0);
      else s=strtol(a.substr(asize-i-1,1).c_str(),NULL,0)+strtol(b.substr(bsize-i-1,1).c_str(),NULL,0);
      if(flag) s++;
      ss<<s%10;
      if(s>9)
	flag=true;
      else
	flag=false;
    }
    string ans=ss.str();
    if(ans.length()+flag>80){
      cout<<"overflow"<<endl;
      continue;
    }
    if(flag) cout<<1;
    for(string::reverse_iterator rit=ans.rbegin();rit!=ans.rend();rit++)
    cout<<*rit;
    cout<<endl;
  }
  return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int t[MAXN];

void solve(){
	int n, k, c;
	scanf("%d%d%d", &n, &c, &k);
	REP(i, 0, n){
		scanf("%d", &t[i]);
	}
	sort(t, t + n);
	int cur_t = 0, cur_cnt = 0;
	int ans = 0;
	REP(i, 0, n){
		if (cur_cnt == 0){
			cur_t = t[i];
			cur_cnt = 1;
		} else {
			cur_cnt++;
		}
		if (t[i] - cur_t > k){
			ans++;
			cur_cnt = 0;
			i--;
		} else if (cur_cnt == c){
			ans++;
			cur_cnt = 0;
		}
	}
	if (cur_cnt){
		ans++;
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 640
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;
int main() {
	int i;
	int j;
	int A, B;
	int ans = 0;
	int num = 0;
	int ng = 0;
	int count = 0;//ハイフンカウント
	string S;
	cin >> A >> B;
	cin >> S;
	if (S[A] == '-') {
		++ans;
		//cout << "test" << endl;
	}
	for (i = 0; i < S.size(); ++i) {
		if (S[i] == '-') {
			++count;

		}
		if (count >= 2) {
			++ng;
		}
	}


	for (i = 0; i <A; ++i) {
		num = S[i];
		if (num >= 48 && 57 >= num) {

		}
		else {
			++ng;
		}
	}

	for (i = A+1; i < A+B; ++i) {
		num = S[i];
		if (num >= 48 && 57 >= num) {

		}
		else {
			++ng;
		}
	}




	if (ans == 1&&ng==0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

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

struct Card {char suit, value;};

void bubble(struct Card A[], int N){
    for (int i=0; i<N; i++){
        for (int j=N-1; j>=i+1; j--){
            if(A[j].value<A[j-1].value){
                Card t=A[j]; A[j]=A[j-1]; A[j-1]=t;
            }
        }
    }
}

void selection(struct Card A[], int N){
    for(int i=0; i<N; i++){
        int minj=i;
        for(int j=i;j<N;j++){
            if(A[j].value<A[minj].value) minj=j;
        }
        Card t=A[i]; A[i]=A[minj]; A[minj] =t;
    }
}

void print(struct Card A[], int N){
    for(int i=0; i<N; i++){
        if(i>0) cout<<" ";
        cout<<A[i].suit<<A[i].value;
    }
    cout<<endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
    for (int i=0; i<N; i++){
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin>>N;
    for (int i=0; i<N; i++){
        cin>>C1[i].suit>>C1[i].value;
    }
    
    for(int i=0; i<N; i++) C2[i] = C1[i];
    
    bubble(C1, N);
    selection(C2, N);
    
    print(C1, N);
    
    cout<<"Stable"<<endl;
    
    print(C2,N);
    
    if(isStable(C1,C2,N)){
        cout<<"Stable"<<endl;
        
    }else{
        cout<<"Not stable"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

const int MAX = 100;
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;

int n, M[MAX][MAX];

int prim()
{
	int u, minv;
	int d[MAX], p[MAX], color[MAX];

	for (int i = 0; i < n; i++) {
		d[i] = INF;
		p[i] = -1;
		color[i] = WHITE;
	}

	d[0] = 0;

	while (1) {
		minv = INF;
		u = -1;
		for (int i = 0; i < n; i++){
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}

		if (u == -1) break;

		color[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK && M[u][v] != INF) {
				if (d[v] > M[u][v]) {
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}

	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] != -1) sum += M[i][p[i]];
	}

	return sum;
}

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int e;
			cin >> e;
			M[i][j] = (e == -1) ? INF : e;
		}
	}

	cout << prim() << endl;

	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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; }

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]" << endl; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    ll N;
    string S;
    cin >> N >> S;
    vvec<int> dp(N+1, vec<int>(N+1, 0));
    rep(i,N)rep(j,N){
        if(i >= j)continue;
        if(S[i] == S[j])dp[i+1][j+1] = dp[i][j] + 1;
    }
    auto calc = [&](int x, int y) -> ll{
        int sx = x;
        int sy = y;
        while(x < N && y < N && dp[x][y] + 1 == dp[x+1][y+1]){x++, y++;};
        int gx = x;
        int gy = y;
        if(gx < sy)return gx - sx + 1;
        else return sy - 1 - sx + 1;
    };
    ll ans = 0;
    rep(i,N+1)rep(j,N+1){
        if(i >= j)continue;
        if(dp[i][j] == 1)chmax(ans, calc(i,j));
    }
    cout << ans << endl;
}


Measured memory_bytes: 101148
#include <bits/stdc++.h>
#define MOD 998244353
using namespace std;
inline void Add(int &a,int b)
{a+=b;a>=MOD?a-=MOD:1;}
inline void Max(int &a,int b)
{a<b?a=b:1;}
const int Q=305;
int f[Q][Q][Q],ok[Q][Q][Q];
char s[Q];
int main()
{
    scanf("%s",s+1);
    int n=strlen(s+1);
    for(int i=0;i<=n;i++)
        (s[n]=='0'?f[n+1][0][i]:f[n+1][i][0])=1;
    for(int i=n;i;--i)
        for(int j=0;j<i;j++)
            for(int k=0;j+k<i;k++){
                f[i][j][k]=f[i+1][j][k];
                if(j&&s[i-1]=='1')Add(f[i][j][k],f[i][j-1][k]);
                if(k&&s[i-1]=='0')Add(f[i][j][k],f[i][j][k-1]);
            }
    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)
            fill(ok[i][j],ok[i][j]+n+1,(int)-1e9);
    ok[0][0][0]=ok[1][0][0]=0;
    for(int i=2;i<=n;i++)
        for(int j=0;j<=i;j++)
            for(int k=0;j+k<=i;k++){
                ok[i][j][k]=ok[i-1][j][k];
                if(j&&s[i]=='0')Max(ok[i][j][k],ok[i-1][j-1][k]-1);
                if(j&&min(s[i],s[i-1])=='0')Max(ok[i][j][k],ok[i-2][j-1][k]);
                if(k&&s[i]=='1')Max(ok[i][j][k],ok[i-1][j][k-1]-1);
                if(k&&max(s[i],s[i-1])=='1')Max(ok[i][j][k],ok[i-2][j][k-1]);
                Max(ok[i][j][k],ok[i-2][j][k]+1);
                if(ok[i][j][k]<0)ok[i][j][k]=-1e9;
            }
    int tmp=MOD-1;
    for(int i=1;i<=n+1;i++)
        for(int j=0;j<i;j++)
            for(int k=0;j+k<i;k++)
                if(ok[i-1][j][k]>=0)
                    Add(tmp,f[i][j][k]);
    printf("%d\n",tmp);
    return 0;
}

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

s = []
for nk in range(n):
  tmp = list(input())
  tmp.sort()
  mo = ''
  for i in tmp:
    mo += i

  s.append(mo)

def comb(x):
  res = x*(x-1)/2
  return res
  
s.sort()
tc = 1
l = []
ans = 0

for i in range(1,n):
  if s[i-1] == s[i]:
    tc += 1

  else:
    if tc >= 2 :
      ans += comb(tc)
      tc = 1

if tc >= 2 :
  ans += comb(tc)
  tc = 1

print(int(ans))

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

int main(){
  int n, m; cin >> n >> m;
  int cnt = 0;
  for(int i = 0; i < m; i++){
    int k; cin >> k;
    cnt += k;
  }
  if(cnt <= n) cout << n - cnt << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 3624
n, x, y = map(int, input().split())
ans = [0] * (n - 1)

x -= 1
y -= 1
for i in range(n):
    for j in range(n):
        c = min(abs(i - j), abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1)
        if c:
            ans[c-1] += 1

for ai in ans:
    print(ai//2)


Measured memory_bytes: 75148
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 222222


pll ss[MAX], tt[MAX];


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


	string t;
	cin >> s;
	cin >> t;
	cin >> n;
	rep(i, s.length()) {
		ss[i + 1] = ss[i];
		if (s[i] == 'A') ss[i + 1].first++;
		else ss[i + 1].second++;
	}
	rep(i, t.length()) {
		tt[i + 1] = tt[i];
		if (t[i] == 'A') tt[i + 1].first++;
		else tt[i + 1].second++;
	}

	while (n--) {
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		ll sa = ss[b].first - ss[a - 1].first;
		ll sb = ss[b].second - ss[a - 1].second;
		ll ta = tt[d].first - tt[c - 1].first;
		ll tb = tt[d].second - tt[c - 1].second;
		if (sa >= sb) {
			(sa -= sb) %= 3;
			if (ta >= tb) {
				(ta -= tb) %= 3;
				if (sa == ta) cout << "YES" << endl;
				else cout << "NO" << endl;
			}
			else {
				(tb -= ta) %= 3;
				if ((sa + tb) % 3) cout << "NO" << endl;
				else cout << "YES" << endl;
			}
		}
		else {
			(sb -= sa) %= 3;
			if (ta >= tb) {
				(ta -= tb) %= 3;
				if ((sb + ta) % 3) cout << "NO" << endl;
				else cout << "YES" << endl;
			}
			else {
				(tb -= ta) %= 3;
				if (sb == tb) cout << "YES" << endl;
				else cout << "NO" << endl;
			}
		}
	}


	return 0;
}

Measured memory_bytes: 6608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	string S;
	cin >> S;
	bool isNorth = false;
	bool isSouth = false;
	bool isEast = false;
	bool isWest = false;
	for (int i = 0; i < S.size(); ++i)
	{
		if (S[i] == 'N')
		{
			isNorth = true;
		}
		else if (S[i] == 'S')
		{
			isSouth = true;
		}
		else if (S[i] == 'E')
		{
			isEast = true;
		}
		else if (S[i] == 'W')
		{
			isWest = true;
		}
	}
	if ((isNorth && isSouth && isEast && isWest) || 
		((isNorth && isSouth) && (isEast == false && isWest == false)) || 
		(isEast && isWest) && (isNorth == false && isSouth == false))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
import fractions
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#mod=1777777777
pi=3.1415926535897932
IS=float('inf')
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def niten(a,b): return abs(a-b) if a>=0 and b>=0 else  a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))
def fib(n): return [(seq.append(seq[i-2] + seq[i-1]), seq[i-2])[1] for seq in [[0, 1]] for i in range(2, n)]
# fractions.gcd(x,y)
def lcm(a,b): return a*b//fractions.gcd(a,b)
def eucl(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
def eof(t): print(t); exit()


a,b=map(int,input().split())
print(lcm(a,b))

Measured memory_bytes: 66028
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int F[100][10];
    for(int i=0; i<N; i++)
        for(int j=0; j<10; j++)
            cin >> F[i][j];

    int P[100][11];
    for(int i=0; i<N; i++)
        for(int j=0; j<=10; j++)
            cin >> P[i][j];

    int ans = -(1<<30);
    for(int i=1; i<(1<<10); i++){
        int tot = 0;
        for(int j=0; j<N; j++){
            int cnt = 0;
            for(int k=0; k<10; k++){
                if( (i&(1<<k)) && F[j][k] ) cnt++;
            }
            tot += P[j][cnt];
        }
        ans = max(ans, tot);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);

 int main(){
   string S, T;
   bool can = false;
   char tmp;
   int canj;
   cin >> S >> T;
   const int N = S.size();
   rep(j, N){
     tmp = S[0];
     rep(i, N-1){
      S[i]= S[i+1];
    }
     S[N-1] = tmp;
     if (S == T){
       can = true;
       break;
     }
   }
   if(can) cout << "Yes" << endl;
   else cout << "No" << endl;
     
     
     
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define maxn 100005
#define Mod 1000000007
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<long long> vll;
typedef vector<bool> vb;
typedef set<int> si; 
#define fori(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,b,a) for(int i = (b); i >= (a); --i)
#define all(a) (a).begin(), (a).end()
#define __builtin_popcountll bitCountLL
#define __builtin_popcount bitCount
//__builtin_ctz 末尾0的个数, __builtin_clz 前导0的个数
//__builtin_ffs 最后一个1的位置
const int INF = 2e9;
const ll ML = 4e18;

void solve() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
	//cout.precision(30); cout << fixed;
	solve();
    
    /*clock_t start,finish;
    start = clock();
   
    finish = clock();
    cout << "\n" << (double)(finish - start) / (double)(CLOCKS_PER_SEC) * 1000 << "ms" << endl;
    */
    return 0;
}

/***************************************************************
 question:
 idea:
 tag:
 record:
 ***************************************************************/


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

template<ll mod> struct Mod_Int{
    ll x;
    Mod_Int() {}
    Mod_Int(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod){}

    Mod_Int &operator += (const Mod_Int &p) {
        x = (x + p.x) % mod;
        return *this;
    }

    Mod_Int &operator -= (const Mod_Int &p) {
        x = (x + mod - p.x) % mod;
        return *this;
    }

    Mod_Int &operator *= (const Mod_Int &p) {
        x = (x * p.x) % mod;
        return *this;
    }

    Mod_Int &operator /= (const Mod_Int &p) {
        *this *= p.inverse();
        return *this;
    }

    Mod_Int operator -() const {return Mod_Int(-x);}

    Mod_Int operator + (const Mod_Int &p) const {return Mod_Int(*this) += p;}

    Mod_Int operator - (const Mod_Int &p) const {return Mod_Int(*this) -= p;}

    Mod_Int operator * (const Mod_Int &p) const {return Mod_Int(*this) *= p;}

    Mod_Int operator / (const Mod_Int &p) const {return Mod_Int(*this) /= p;}

    bool operator == (const Mod_Int &p) const {return x == p.x;}

    bool operator != (const Mod_Int &p) const {return x != p.x;}

    Mod_Int pow(ll n) const{
        Mod_Int now = *this, ret = 1;
        while(n > 0){
            if(n & 1) ret *= now;
            now *= now, n >>= 1;
        }
        return ret;
    }

    Mod_Int inverse() const{
        return pow(mod-2);
    }
};

using mint = Mod_Int<MOD>;
const int MAX_N = 1e5;
mint fac[MAX_N+1];

void init(){
    fac[0] = {1};
    rep2(i, 1, MAX_N){
        fac[i] = fac[i-1]*mint(i);
    }
}

mint comb(mint n, mint k){
    return fac[n.x]/(fac[n.x-k.x]*fac[k.x]);
}

mint perm(mint n, mint k){
    return fac[n.x]/fac[n.x-k.x];
}

const int MAX_V = 1e5;
vector<int> es[MAX_V];
int K;

void add_edge(int u, int v){
    es[u].pb(v), es[v].pb(u);
}

//自分より下の部分木の色の決め方の総数
mint dfs(int now, int par){
    mint res = 1;
    for(auto &e: es[now]){
        if(e == par) continue;
        res *= dfs(e, now);
    }
    int n = es[now].size();
    if(n >= K) res *= 0;
    elif(par != -1) res *= perm(K-2, n-1);
    else res *= perm(K-1, n);
    return res;
}

int main(){
    init();
    int N;
    cin >> N >> K;
    rep(i, N-1){
        int u, v; cin >> u >> v; u--, v--;
        add_edge(u, v);
    }
    mint ans = mint(K)*dfs(0, -1);
    cout << ans.x << endl;
}

Measured memory_bytes: 11136
#include <stdio.h>
int main(void){
int a,b;
scanf("%d %d",&a,&b);
if(a>b){
  for(int i=1;i<=a;i++){
    printf("%d",b);
  }
}
  else if(a<=b){
  for(int i=1;i<=b;i++){
    printf("%d",a);
  }
}

}

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

int main() {
    // input
    int N, K;
    cin >> N >> K;

    // solve
    int ans = 1;
    for (int i = 0; i < N; ++i) {
        ans = min(ans * 2, ans + K);
    }

    // output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N, L = map(int, input().split())
A = [L + i for i in range(N)]
d = 10000
min_i = -1
for i in range(N):
    if abs(A[i]) < d:
        min_i = i
        d = abs(A[i])

del A[min_i]

print(sum(A))

Measured memory_bytes: 38384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;

int main(){

	int A,B;

	cin >> A >> B;

	if(B%A == 0){
		cout << A+B << endl;
	} else {
		cout << B-A << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

#define all(x) (x).begin(), (x).end()
#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(str) printf(#str "\n")

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int k, a, b, c;
  cin >> k >> a >> b;
  c = k;
  while (1) {
    if (b < c) break;
    if (a <= c && c <= b) {
      cout << "OK" << endl;
      return 0;
    }
    c += k;
  }
  cout << "NG" << endl;
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

Measured memory_bytes: 3604
N,M = map(int,input().split(" "))
X = map(int,input().split(" "))
X = sorted(X)

if N >= M:
    print(0)
    exit()

o = []
for i in range(M-1):
    o.append(X[i+1]-X[i])

ans = X[-1]-X[0]

o.sort(reverse=True)
for i in range(N-1):
    ans -= o[i]

print(ans)

Measured memory_bytes: 13960
s = input()
kisuu = ['R', 'U', 'D' ]
gusuu = ['L', 'U', 'D' ]
ki = []
gu = []

for i in range(len(s)):
    if i % 2 != 0:
        gu.append(s[i])
    else:
        ki.append(s[i])

if set(gu).issubset(gusuu) and set(ki).issubset(kisuu):
    print('Yes')
else:
    print('No')

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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int N;
  cin >> N;
  vector<vector<int> > num(1000 + 1, vector<int>(1000 + 1, 0));
  for(int i = 2; i <= N; i++){
    for(int j = 2; j <= N; j++){
      if(i % j == 0){
        bool flag = true;
        for(int k = 2; k <= sqrt(j); k++){
          if(j % k == 0){
            flag = false;
            break;
          }
        }
        int k = i;
        while(flag && k % j == 0){
          num[i][j]++;
          k /= j;
        }
      }
    }
  }

  vector<int> cnt(N + 1, 0);
  for(int i = 2; i <= N; i++){
    for(int j = 2; j <= N; j++){
      if(num[j][i])cnt[i] += num[j][i];
    }
  }
  unsigned long long ans = 1;
  for(int i = 0; i <= N; i++){
    if(cnt[i] == 0)continue;
    if(cnt[i] == 1){
      ans *= 2;
    }else {
      ans *= cnt[i] + 1;
    }
    ans %= 1000000000 + 7;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4224