akhauriyash/Code-Regression huggingface dataset:
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1;char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')    f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<1)+(x<<3)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<1)+(x<<3)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)    putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=2e5;
int pre[(N<<1)+10],now[N+10],child[(N<<1)+10],val[(N<<1)+10];
int size[N+10],Msize[N+10];
int n,tot,rize,root;
ll Ans;
void join(int x,int y,int z){pre[++tot]=now[x],now[x]=tot,child[tot]=y,val[tot]=z;}
void insert(int x,int y,int z){join(x,y,z),join(y,x,z);}
void dfs(int x,int fa,int v){
	int Max=0; size[x]=1;
	for (int p=now[x],son=child[p];p;p=pre[p],son=child[p]){
		if (son==fa)	continue;
		dfs(son,x,val[p]),size[x]+=size[son];
		Max=max(Max,size[son]);
	}
	Ans+=1ll*min(size[x],n-size[x])*v*2;
	Max=max(Max,n-size[x]);
	Msize[x]=Max;
	if (Max<rize){
		rize=Max;
		root=x;
	}
}
int main(){
	n=read(),rize=inf;
	for (int i=1;i<n;i++){
		int x=read(),y=read(),z=read();
		insert(x,y,z);
	}
	dfs(1,0,0);
	int tmp=inf;
	for (int p=now[root],son=child[p];p;p=pre[p],son=child[p]){
		tmp=min(tmp,val[p]);
		if (Msize[root]==Msize[son]){
			Ans-=val[p];
			printf("%lld\n",Ans);
			return 0;
		}
	}
	printf("%lld\n",Ans-tmp);
	return 0;
}

Measured memory_bytes: 12416
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b,c;
    cin>>a>>b>>c;
    if (a+b>=c)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	S += 'B';
	int c = 0;
	int tn = 0;
	int ans = 0;
	char pc = 'A';
	rep(i, 0, SZ(S))
	{
		if (pc != S[i])
		{
			ans += max(0LL, c - 1);
			c = 0;
			tn++;
		}
		c++;
		pc = S[i];
	}
	tn--;

	if (tn % 2 == 0)
	{
		ans += min(tn / 2 * 2 - 1, 2 * K);
	}
	else
	{
		ans += min(tn / 2 * 2, 2 * K);
	}

	cout << ans << endl;

	return 0;
}

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

#define f first 
#define s second 
#define pb push_back               
#define all(x) x.begin(), x.end())

using namespace std;                    

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

const int N = (int)1e6 + 123, mod = (int)1e9 + 7, inf = (int)1e9, LOG = 18;
const ll INF = (ll)1e8;
const double eps = 1e-9;
int n;
double ans, d, x;

void solve(int n, double d, double x) {
	if (n == 0)
		return;
	solve(n - 1, d + (2 * d + x * 5) / 2 / n, x + x * 2 / n);
	ans += d + x * (2 * n - 1) / 2;
}
 

int main(){
	cin >> n >> d >> x;
	solve(n, d, x);
	cout << fixed << setprecision(20) << ans;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=k;i<(ll)(n);i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
const ll inf=1001001001001001;
const int mod=998244353;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}

int main(){
    ll n,m;cin>>n>>m;
    vi v(n);
    rep(i,n)cin>>v[i];
    vector<vector<P>> g(n);
    //vector<P> hen(m);
    vi ans(m,1000000000);
    vi c(n);
    rep(i,m){
        ll a,b;cin>>a>>b;a--;b--;
        //hen[i].fi=a;hen[i].se=b;
        g[a].eb(b,i);
        g[b].eb(a,i);
        if(v[a]!=v[b]||(c[a]&&c[b]))continue;
        ans[i]=v[a];
        if(c[a])c[b]=3-c[a];
        else if(c[b])c[a]=3-c[b];
        else{
            c[a]=1;c[b]=2;
        }
    }
    vector<P> s(n);
    rep(i,n)s[i].fi=v[i];
    rep(i,n)s[i].se=i;
    sort(all(s));
    rep(i,n){
        if(c[s[i].se])continue;
        for(auto ne:g[s[i].se]){
            if(v[ne.fi]>s[i].fi)continue;
            c[s[i].se]=3-c[ne.fi];
            ans[ne.se]=s[i].fi;
            break;
        }
        if(!c[s[i].se]){
            out(-1);
            return 0;
        }
    }
    rep(i,n){
        if(c[i]==1)cout<<'B';
        else cout<<'W';
    }
    cout<<endl;
    rep(i,m)cout<<ans[i]<<endl;
}


Measured memory_bytes: 20480
#include<stdio.h>
#include<string.h>

#define MYSTRINGMAX 200000 // 配列20万分取る
#define SIZE MYSTRINGMAX + 2 // MYSTRINGMAX+2した値をSIZEに入れたものを定義する SIZE = 200002

int main(void) {
	char s[SIZE], t[SIZE], c1, c2;

	fgets(s, SIZE, stdin);
	fgets(t, SIZE, stdin);

	int length = strlen(s); // lengthに文字列の長さを返すstrlen関数を配列sにて判定する
	
	for (int i = 0; i < length; i++) {
		if (s[i] != t[i]) { // s[i]とt[j]が等しくない場合に操作開始
			c1 = s[i]; // c1にif文で引っかかった文字sを代入
			c2 = t[i]; // c2にif文で引っかかった文字tを代入
			for (int j = 0; j < i; j++) { // 変更し終わった部分を変えてしまう場合は"No"
				if (s[j] == c2 || s[j] == c1) {
					printf("No\n");
					return 0;
				}
			}
			for (int j = i; j < length; j++) {
				if (s[j] == c1) {
					s[j] = c2; // s[j]の値と入っているc2の値を交換する
				}
				else if (s[j] == c2) {
					s[j] = c1; 
				}
			}
		}
	}
	printf("Yes\n"); // それ以外ならYesを実行
	return 0;
}


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

using namespace std;
using ll = long long;
const int N = 13, M = 1010;
int dp[1 << N];
int mask[M], cost[M];
int n, m;

int rec(int mask_) {
  if(__builtin_popcount(mask_) == n) {
    return 0;
  }
  if(dp[mask_] != -1) return dp[mask_];
  int res = int(1e9);
  for(int i = 0; i < m; ++i) {
    if((mask_ & mask[i]) == mask[i]) continue;
    res = min(res, cost[i] + rec(mask_ | mask[i]));
  }
  return dp[mask_] = res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  memset(dp, -1, sizeof dp);
  for(int i = 0; i < m; ++i) {
    mask[i] = 0;
    int x; cin >> cost[i] >> x;
    for(int j = 0; j < x; ++j) {
      int y; cin >> y;
      mask[i] |= (1 << y);
    }
  }
  int res = rec(0);
  cout << (res == int(1e9) ? -1 : res) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int dp[1000][1000],a[100],b[100],c[100];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    for(int i=0; i<=500; i++)
        for(int j=0; j<=500; j++)
            dp[i][j]=1000;
    int n,p,q;
    cin>>n>>p>>q;
    for(int i=0; i<n; i++)
        cin>>a[i]>>b[i]>>c[i];
    dp[0][0]=0;
    for(int k=0; k<n; k++)
    {
        for(int i=400; i>=a[k]; i--)
        {
            for(int j=400; j>=b[k]; j--)
            {
                dp[i][j]=min(dp[i][j],dp[i-a[k]][j-b[k]]+c[k]);
            }
        }
    }
    int ans=1000;
    for(int i=1; i<=400; i++)
    {
        for(int j=1; j<=400; j++)
        {
            int x=i,y=j,z=__gcd(i,j);
            x/=z;
            y/=z;
            if(x==p && y==q)
                ans=min(ans,dp[i][j]);
        }
    }
    if(ans==1000)
        cout<<"-1"<<endl;
    else
        cout<<ans<<endl;

    return 0;
}


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

int main()
{
	int n, m = 0;

	cin >> n;
	vector<int> a(n), b(n), d(n);

	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		d[i] = a[i] - b[i];
	}

	sort(d.begin(), d.end());
	vector<int>::iterator itr = d.begin();
	long long p = 0;
	
	while (itr != d.end() && *itr < 0) {
		p += *itr;
		m++;
		itr++;
	}

	itr = d.end();
	itr--;

	while (itr != d.begin() && p < 0) {
		p += *itr;
		m++;
		itr--;
	}

	if (p < 0)
		cout << -1 << endl;
	else
		cout << m << endl;

	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

//#include "All.h"

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

string S, T;

int main() {
    cin >> S >> T;
    int ans = 0;
    rep(i, S.size()) {
        if (S[i] != T[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3844
#include<bits/stdc++.h>
using namespace std;
vector<int> L[2000];int N,M,E,match[2000],x[2000],y[2000];bool used[2000];
 bool DFS(int V) {
    used[V] = true;
    for (int i = 0; i < L[V].size(); i++) {
        int u = L[V][i]; int w = match[u];
        if (w < 0 || !used[w] && DFS(w)) {
            match[V] = u;
            match[u] = V;
            return 1;
        }
    }
    return 0;
}
int SM() {
    int r = 0;
    memset(match, -1, sizeof(match));
    for (int j = 0; j < N + M; j++) {
        if (match[j] < 0) {
            memset(used, 0, sizeof(used));
            if (DFS(j)) { r++; }
        }
    }
    return r;
}
 
//main.
int main() {
    while (true) {
        for (int i = 0; i < 2000; i++) { L[i].clear(); }
        cin >> N >> M; if (!N) { break; }
        for (int i = 0; i < N; i++) {
            cin >> x[i];
        }
        for (int i = 0; i < M; i++) {
            cin >> y[i];
        }
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                if (__gcd(x[i], y[j]) != 1) {
                    L[i].push_back(j + N);
                }
            }
        }
        cout << SM() << endl;
    }
    return 0;
}

Measured memory_bytes: 4088
import math


h,w,k = map(int, input().split())

l = [0]*9

for i in range(9):
    a = 0
    b = i
    while b >= a:
        l[i]+=int(math.factorial(b)/math.factorial(a)/math.factorial(b-a))
        b-=1
        a+=1

dp = [[0]*(w+2) for i in range(h+1)]
dp[0][1]=1

for i in range(1,h+1):
    for j in range(1,w+1):
        dp[i][j]=int(dp[i-1][j-1]*l[j-2]*l[w-j] + dp[i-1][j]*l[j-1]*l[w-j] + dp[i-1][j+1]*l[j-1]*l[w-j-1])
        dp[i][j]%=(10**9+7)

print(int(dp[-1][k]))

Measured memory_bytes: 3064
using System;
class Program{
  static void Main(string[] args){
    string[] inp=Console.ReadLine().Split(' ');
    int a=int.Parse(inp[0]);
    int b=int.Parse(inp[1]);
    int r=0;
    for(int i=2;i>0;i--){
      if(a>b){
        r+=a;
        a--;
      }else{
        r+=b;
        b--;
      }
    }
    Console.WriteLine(r.ToString());
  }
}

Measured memory_bytes: 11092
///https://codeforces.com/blog/entry/69629
#include <bits/stdc++.h>
using namespace std;

int Factorial_of(int n)
{
    int fac = 1;
    for(int i = 1; i <= n; ++i)
    {
        fac *= i;
    }
    return fac;
}

int main()
{
    long long n, pass = 1, fac = 1;
    cin >> n;
    if(n == 1)cout << "1\n";
    else if(n == 2)cout << "8\n";
    else
    {
        for(int i = 1; i <= n; ++i)
        {
            fac *= i;
        }
        ///pass = (fac/6) * 6;
        pass = fac/Factorial_of((n-3)); ///nCr
        pass += (n * (n-1)) * 3 + n;
        cout << pass << endl;

    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vector<vpll> path; vs S;

int main() {
	ll D, T, S;
	cin >> D >> T >> S;
	if (S * T >= D) cout << "Yes";
	else cout << "No";
}







Measured memory_bytes: 3624
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int []cnt= new int[2019];
        int x=1;
        int  tat=0;
        long ans=0;
        long m =2019;
        cnt[0]++;
        int n=S.length();

        for(int i=S.length()-1;i>=0;i--)
        {
          int num=(S.charAt(i)-'0');

          tat+=num*x;
          tat%= 2019;

          cnt[tat]++;
          x=x*10;
          x=x%2019;
        }

        for(int i=0;i<2019;i++)
        {if(cnt[i]!=1){
         
          ans+=(cnt[i]*(cnt[i]-1))/2;

        }
        }
        System.out.println(ans);
      }
    }

Measured memory_bytes: 40252
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
bool operator<(string a, string b){
  if(a.length()==b.length()){
    return a < b;
  }
  return a.length() < b.length();
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<string, int> mp;
  FOR(i,0,n){
      string s;
      int x;
      cin >> s >> x;
      mp[s] += x;
  }
  FOR(i,1,6){
    for(auto m : mp){
      if(m.first.length() == i) cout << m.first <<  " " << m.second << endl;
    }
  }
}


Measured memory_bytes: 3200
/*input
3 4 10 40
*/

#include <bits/stdc++.h>
using namespace std;
 
 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))
#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
 
#ifdef Voneone
#define TRACE
#endif
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); 
    cout.write(names, comma - names) << " : " << arg1 << " | "; 
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef unordered_set<int> usi;
 

 typedef long double ld;


 
void solve() 
{ 
 




    int a, b, h, m;

    cin >> a >> b >> h >> m;


    ld ang1 = 2*PI*m/60;
    ld ang2 = 2*PI*((ld)h/12 + (ld)m/(60.0*12));
    
    ld dif = abs(ang1 - ang2);

    cout << setprecision(10) << sqrt(a*a + b*b - 2*a*b*cos(dif));


 
} 
 
 
 
 
signed main()
{
 
    
    #ifdef _DEBUG
    inputFile;
    #endif
    #ifndef __CINP
    fast;
    #endif
 
 
    int T = 1;
    // cin >> T;
    while(T--){
        solve();
        cout << endl;
        
        
 
    }
    
    
    return 0;
 
}
 



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

int main(){
    
    std::vector<int> num;

    
    for(int i; std::cin>>i; )
        num.emplace_back(std::move(i));
    
    std::sort(num.begin(), num.end());
        
    std::cout << num[0] << " " << num[1] << " " << num[2] << std::endl;
    
    return 0;
}

Measured memory_bytes: 3136
#include <stdio.h>
int main(void){
    double a,b,c,d,e,f;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
        if(a!=1){
           b/=a; c/=a;
        }
        e=e-b*d; f=f-c*d; 
        
        if(e!=0){
            f/=e;
        }
         c=c-b*f; b=0;
        printf("%.3lf %.3lf\n",c,f);
        
    }
    return 0;
}



Measured memory_bytes: 2060
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int time = 0, t = 0;	
	bool is_clear = false;	
	rep(i, 1000) {
		if(time > 60) {
			time -= 60; ++t;		
		}
		if(time <= C && C <= time + A) { 
			is_clear = true;	
		}
		if(is_clear) break;
		time += A+B;
	}

	cout << ((is_clear) ? 60*t + C : -1) << endl;
	return 0;
}

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

int main(){
  int A,B,Q; cin>>A>>B>>Q;
  vector<ll> S(A+2),T(B+2);
  S[0]=-1e11,S[A+1]=1e11;
  T[0]=-1e11,T[B+1]=1e11;
  rep(i,A) cin>>S[i+1];
  rep(i,B) cin>>T[i+1];

  while(Q--){
    ll X; cin>>X;
    int s=lower_bound(S.begin(),S.end(),X)-S.begin();
    int t=lower_bound(T.begin(),T.end(),X)-T.begin();

    ll ans=1e18;
    ans=min(ans,X-min(S[s-1],T[t-1]));
    ans=min(ans,max(S[s],T[t])-X);
    ans=min(ans,T[t]-S[s-1]+min(T[t]-X,X-S[s-1]));
    ans=min(ans,S[s]-T[t-1]+min(S[s]-X,X-T[t-1]));
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>

using namespace std;

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

Node *root, *NIL;

Node* newNode(int key) {
    Node *node = new Node();
    node->key = key;
    node->left = NIL;
    node->right = NIL;
    return node;
}

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

void inorder(Node *t) {
    if (t == NIL)
        return;
    inorder(t->left);
    cout << " " << t->key;
    inorder(t->right);
}

void preorder(Node *t) {
    if (t == NIL)
        return;
    cout << " " << t->key;
    preorder(t->left);
    preorder(t->right);
}

int main() {
    int n, v;
    string s;
    root = NIL;
    cin >> n;
    while (n--) {
        cin >> s;
        if (s == "insert") {
            cin >> v;
            insert(v);
        }
        if (s == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 18792
from sys import stdin


def main():
    readline = stdin.readline
    readline()
    *A, = map(int, readline().split())
    *B, = map(int, readline().split())
    ans = 0
    pre = 0
    for a, b in zip(A, B):
        brave = pre + b
        if brave < a:
            ans += brave
            pre = 0
        elif a < pre:
            ans += a
            pre = b
        else:
            ans += a
            pre = brave - a
    if A[-1] < pre:
        ans += A[-1]
    else:
        ans += pre
    print(ans)
    return


main()


Measured memory_bytes: 19376
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;
typedef long long ll;
int main(int argc, char const *argv[])
{
    int w,h,x,y;cin>>w>>h>>x>>y;
    cout << ll(w)*ll(h)/2.0l << " ";
    if(2*x==w && 2*y==h)cout << "1" << endl;
    else cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;

int fact(int k) {
	if (k == 1)
		return 1;
	else return k*fact(k - 1);
}
int main()
{
	double ans=0;
	int n,x[10],y[10];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	for (int a = 0; a <n; a++) {
		for (int b = 0; b < n; b++) {
			if (a == b) continue;
			else {
				ans += sqrt(pow(x[a] - x[b],2)  + pow(y[a] - y[b],2) );
			}
		}
	}
	ans /= n;
	cout<<fixed<<setprecision(10)<< ans << endl;
	return 0;
}



Measured memory_bytes: 256
n,m=map(int,input().split())
if abs(n-m)>1:
    ans=0
elif abs(n-m)==1:
    ans=1
    for i in range(1,n+1):
        ans*=i
        ans%=10**9+7
    for i in range(1,m+1):
        ans*=i
        ans%=10**9+7
else:
    ans=2
    for i in range(1,n+1):
        ans*=i**2
        ans%=10**9+7
print(ans)


Measured memory_bytes: 9196
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int, int>;
//加算代入演算子は+=！！！！！

int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i, n) cin >> vec.at(i);
    int ans = inf;
    int cost;
    for (int y = -100; y < 101; y++) {
        cost = 0;
        rep (i, n) {
            cost += (vec.at(i) - y) * (vec.at(i) - y);
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
  if(a+b<=2*c){
    P(a*x+b*y);
  }else if(x<=y){
    if(b<2*c){
      P(2*c*x+b*(y-x));
      // P(1);
    }else{
      P(2*c*y);
      // P(2);
    }
  }else{
    if(a<2*c){
      P(2*c*y+a*(x-y));
      // P(3);
    }else{
      P(2*c*x);
      // P(4);
    }
  }
  return 0;
}


Measured memory_bytes: 256
N, X, T = map(int, input().split())
count = 1
check = X
if X > 1:
    while True:
        value = int(N / X)
        re = N % X
        if re == 0:
            count = value
            TotalTime = T * count
            break
        else:
            count += value
            TotalTime = T * count
            break
else:
    TotalTime = T * N

print(TotalTime)

Measured memory_bytes: 9152
/**
 *   created: 09 June 2019  14:03:36
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	// cin>>tt;
	while(tt--){
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		ll temp = b/c - a/c;
		if(a%c==0)
			temp++;
		temp += b/d - a/d;
		if(a%d==0)
			temp++;
		c = (c*d)/__gcd(c,d);
		ll res = b/c - a/c;
		if(a%c==0)
			res++;
		cout<<b-a+1-temp+res;
	}	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 2000001
#define V 10000
int main(){
  int n,i,j,cnt[V+1];
  unsigned short *ans,*A;
  scanf("%d",&n);
  A = malloc(sizeof(short)*n+1);
  ans = malloc(sizeof(short)*n+1);
  for(i=0;i<V+1;i++)cnt[i]=0;
  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
    cnt[A[i+1]]++;
  }
  for(i=1;i<V+1;i++)cnt[i]=cnt[i]+cnt[i-1];
  for(i=1;i<=n;i++){
    ans[cnt[A[i]]]=A[i];
    cnt[A[i]]--;
  }
  for(i=1;i<n+1;i++){
    if(i==n)printf("%d\n",ans[i]);
    else printf("%d ",ans[i]);
  }
  return 0;
}



Measured memory_bytes: 9600
/*input
7
14 14 2 13 56 2 37

*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> vii;
#define pb push_back
#define print(a) for(auto x:a){cout<<x<<' ';}cout<<endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve(){
	int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i){
    	cin>>a[i];
    }
    sort(a,a+n);
    int ans = INT_MAX, ansi = -1;
    for(int i=a[0];i<=a[n-1];++i){
    	int y = 0;
    	for(auto x:a){
    		y += (x-i)*(x-i);
    	}
    	if(y<ans){
    		ans = y;
    	}
    }
    cout<<ans<<endl;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define all(x) x.begin(),x.end()
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL);
#define N 200005
const int mod = 998244353;
ll n,m,K, F[N];
ll expmod(ll a, ll b) {
    a %= mod;
    ll res = 1;
    while (b > 0) {
        if (b & 1) res = (res * a)% mod;
        a = ( a * a )% mod;
        b >>= 1;
    }
    return res;
}
int main(){
	FIO;
    F[0] = 1;
    for(ll i = 1 ; i < N ; i++) F[i] = (F[i-1]*i) % mod;
    cin >> n >> m >> K;
    ll ans = 0;
    for(int k = 0 ; k <= K ; k++){
        ll cur =  m % mod * expmod(m-1,n-1-k) % mod * F[n-1] % mod * expmod(F[k],mod-2) %mod * expmod(F[n-1-k],mod-2) %mod;
        ans = (ans + cur)%mod;
    }
    cout << ans << endl;
	return 0;
}

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

ll mypow(ll x, int n) {
  ll y = 1;
  for (int i=0; i<n; i++) {
    y *= x;
  }
  return y;
}

int main(){
  string s;
  cin >> s;
  ll n = stoll(s);
  ll sum = 0;
  for (ll i=0; i < (1 << s.size()-1); i++) {
    bitset<9> op(i);
    int k = 0;
    ll copy_n = n;
    for (int j=0; j<10; j++) {
      if (j < 9) {
        k++;
        if (op[j]) {
          sum += copy_n%mypow(10, k);
          copy_n /= mypow(10, k);
          k = 0;
        }
      }
      else {
        sum += copy_n;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int a, b;
   cin >> a >> b;
   if((a <= 8)and(b <= 8)){
      cout << "Yay!" << endl;
   }
   else{cout << ":(" << endl;}
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N, R;
    cin >> N >> R;
    if(N >= 10){
        cout << R << endl;
    }else{
        cout << R+100*(10-N) << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define l long long
using namespace std;
l n,m,a[100010],g;
l gcd(l a,l b)
{
	if(b==0)return a;
	else gcd(b,a%b);
}
l lcm(l a,l b)
{
	return a/gcd(a,b)*b;
}
int main()
{
	cin>>n>>m;
	bool pd=true;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]/=2;
		if(i==1)g=a[i];
		g=lcm(g,a[i]);
		if(g>m)pd=false;
	}
	for(int i=1;i<=n;i++)
		if(g/a[i]%2==0)
		{
			pd=false;
			break;
		}
	if(!pd)
	{
		cout<<"0";
		return 0;
	}
	l ans,b=m/g;
	ans=b/2;
    if(b&1)ans++;	//判断是否是奇数 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

lli n,a,b;
int main(void){
	scanf("%lld",&n);
	reg(p,1,3500)reg(q,1,3500){
		a=p; b=q;
		lli d=4*a*b-n*a-n*b;
		if(d<=0 || (n*a*b) % d!=0)continue;
		printf("%lld %lld %lld\n",a,b,n*a*b/d);
		return 0;
	}
	return 0;
}






Measured memory_bytes: 256
N, K = map(int, input().split())
X = list(map(int, input().split()))
ans = float("inf")

for i in range(0, N - K + 1):
	ans = min(ans, min(abs(X[i]) + abs(X[i] - X[i + K - 1]), abs(X[i + K - 1]) + abs(X[i] - X[i + K - 1])))
	
print(ans)

Measured memory_bytes: 62576
#include <bits/stdc++.h>
#include <iostream>
// #define vi vector <int>
#define seti set<int>
#define mii map<int,int>
#define ull unsigned long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MAX 100100

using namespace std;


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

	vector<pair<int,int> > v;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		v.push_back(make_pair(a,i));
	}

	sort(v.begin(), v.end());

	for(int i = 0; i < n; i++){
		cout << v[i].se+1 << " ";
	}

	return 0;
}


Measured memory_bytes: 1780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC127D
{
    class Program
    {
        struct cond
        {
            public int Index;
            public int Value;

            public cond(int i, int v) { Index = i; Value = v; }
        }

        static void Main(string[] args)
        {
            var nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            var n = nums[0];
            var m = nums[1];

            var cards = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();

            // 昇順
            cards.Sort();

            var conds = new List<cond>();
            foreach (var _ in Enumerable.Range(0, m))
            {
                nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
                var b = nums[0];
                var c = nums[1];

                conds.Add(new cond(b, c));
            }

            // 降順
            conds.Sort((x, y) => y.Value - x.Value);


            var ovalues = new List<int>();
            foreach (var cond in conds)
            {
                foreach (var _ in Enumerable.Range(0, cond.Index))
                {
                    if (ovalues.Count() >= n) break;

                    ovalues.Add(cond.Value);
                }
                if (ovalues.Count() >= n) break;
            }

            foreach (var i in Enumerable.Range(0, ovalues.Count()))
            {
                if (cards[i] > ovalues[i]) break;
                cards[i] = ovalues[i];
            }

            Console.WriteLine(cards.Select(x => (long)x).Sum());
        }
    }
}


Measured memory_bytes: 32184
program A176
implicit none
integer(4) :: N, X, T
integer(4) :: a, ans

read(5,*) N, X, T

if (mod(N,X) == 0) then
    a = N / X
else
    a = N / X + 1
end if

ans = a * T

write(6,*) ans


end program A176

Measured memory_bytes: 2796
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n){return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}

	public static void main(String[]$){
		System.out.println(s.next().startsWith("YAKI")?"Yes":"No");
	}
}

Measured memory_bytes: 23252
n  = int(input())
ls = []
for i in range(n):
    s,p = input().split()
    p = int(p)
    ls.append((s,p,i+1))
ls.sort(key=lambda x:x[1],reverse=True)
ls.sort(key=lambda x:x[0])
for s,p,i in ls:
    print(i)


Measured memory_bytes: 3060
import numpy as np

X=int(input())

#エラトステネスの篩
def get_next_primenumber(number):
    x=number
    number=number*2
    prime_list = []
    search_list = list(range(2,number+1))
    answer=2
    while True:
      if search_list[0] > np.sqrt(number):
        prime_list.extend(search_list)
        break
      else:
        head_num = search_list[0]
        prime_list.append(head_num)
        search_list.pop(0)
        search_list = [num for num in search_list if num % head_num != 0]
    
    plist=prime_list[::-1]
    for i in range(1,len(plist)):
        if(x>plist[i]):
            answer=plist[i-1]
            break

    return answer


print(get_next_primenumber(X))

Measured memory_bytes: 22392
#include<iostream>


int main()
{
    int n;//h's num
    std::cin >> n;
    
    int now_max_h = 0;
    
    for(int i=0;i<n;i++){
        unsigned int h;
        std::cin >> h;
        
        if( h > now_max_h ){
            now_max_h = h;
            continue;
        }
        if( now_max_h - h >= 2){
            std::cout<<"No"<<std::endl;
            return 0;
        }
    }
    
   std::cout<<"Yes"<<std::endl;
    
    return 0;
}


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

using namespace std;

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



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

    string str;
    cin >> str;
    str[3] = '8';
    cout << str;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextLong();
    long d = sc.nextLong();

    System.out.println(Math.max(Math.max(a * c, b * d), Math.max(a * d, b * c)));

  }
}

Measured memory_bytes: 35676
N,M = list(map(int,input().split()))
S = input()
T = input()
sl = list(S)
tl = list(T)
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(x, y):
    return int((x * y) / gcd(x, y))

lcm = lcm(N,M)
Sd = int(lcm/N)
St = int(lcm/M)
kaisu = min(int((N-1)/St),int((M-1)/Sd))
flag = 0
for i in range(kaisu+1):
    if sl[St*i] != tl[Sd*i]:
        flag = 1
if flag == 0:
    print(lcm)
else:
    print(-1)


Measured memory_bytes: 4596
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

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

signed main() {
  int N, M; 
  cin >> N >> M;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int l = 1;
  REP(i, N) l = lcm(l, A[i]/2);

  int cnt = 0;
  while(A[0]%2 == 0){
    A[0] /= 2;
    cnt++;
  }
  FOR(i, 1, N){
    int c = 0;
    while(A[i]%2 == 0){
      A[i] /= 2;
      c++;
    }
    if(c != cnt){
      cout << 0 << endl;
      return 0;
    }
  }
  cout << M/l-M/(l*2) << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a;
    cin >> a;
    
    cout << a / 3 << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


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

	string s, t;
	cin >> s >> t;
	Matrix dp(1010, Array(1010, INF));
	dp[0][0] = 0;
	REP(i, s.size()+1) {
		REP(j, t.size()+1) {
			if (i - 1 >= 0 && j - 1 >= 0) {
				if (s[i - 1] == t[j - 1]) chmin(dp[i][j], dp[i - 1][j - 1]);
				else chmin(dp[i][j], dp[i - 1][j - 1] + 1);//置換
			}
			//追加、削除
			if (i - 1 >= 0)chmin(dp[i][j], dp[i - 1][j] + 1);
			if (j - 1 >= 0)chmin(dp[i][j], dp[i][j - 1] + 1);
		}
	}

	cout << dp[s.size()][t.size()]<<endl;

	return 0;
}



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

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

	int d,r;
	double f;

	d = a / b;
	r = a % b;
	f = (double)a / (double)b;

	cout << d << ' ' << r << ' ' << fixed << f << '\n';

	return 0;
}


Measured memory_bytes: 3240
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n,m;cin >> n >> m;
  vector<int> a(m), b(m);
  vector<vector<int>> c(m);
  rep(i,m) {
    cin >> a[i] >> b[i];
    c[i].resize(b[i]);
    rep(j,b[i]) {
      cin >> c[i][j];
      c[i][j]--;
    }
  }

  vector<vector<int>> dp(m+1, vector<int>( (1<<n), 1e+9));

  dp[0][0] = 0;
  rep(i,m) {
    int tmp = 0;
    rep(j,b[i]) tmp += (1<<c[i][j]);
    rep(mask, (1<<n) ) {
      dp[i+1][mask] = min(dp[i+1][mask], dp[i][mask]);
      dp[i+1][mask|tmp] = min(dp[i+1][mask|tmp], dp[i][mask] + a[i]);
    }
  }

  
  if(dp[m][(1<<n)-1] == 1e+9) cout << -1 << "\n";
  else cout << dp[m][(1<<n)-1] << "\n";
  
  return 0;
}


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

#define deb(x) cerr<<"["#x<<" : "<<x<<" ]\n";

int main()
{
	int n;
	cin >> n;
	int time = 0, currX = 0, currY = 0;
	
	for(int i = 0; i < n; i++) {
		int t, destX, destY;
		cin >> t >> destX >> destY;
		
		int distance = abs(currX - destX) + abs(currY - destY);
		
		if((t-time-distance)%2 != 0) {
				puts("No");
				return 0;
		}
		
		if(distance > t-time) {
			puts("No");
			return 0;
		}
		
		time = t;
		currX = destX;
		currY = destY;
	}
	puts("Yes");
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define int long long


signed main(){
	int H, W;
	char a[120][120] = {}, temp[120][120] = {};
	
	cin>>H>>W;
	
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			cin>>a[i][j];
		}
	}
	
	while(1){
		int flag = 0;
		for(int i = 1; i <= H; i++){
			int f = 0, x=0;
			for(int j = 1; j <= W; j++){
				if(a[i][j] == '#'){
					f = 1;
					//flag = 1;
					//break;
				}
				if(a[i][j] == 'X')x++;
				
			}
			if(f == 0){
				if(x == W){//cout<<"aaaaa"<<endl;
					a[i][0] = 'A';
				}else{
				flag = 1;
				for(int j = 1; j <= W; j++)a[i][j] = 'X';
				}
			}
			
			
		}
		
		for(int i = 1; i <= W; i++){
			int f = 0, x = 0;
			for(int j = 1; j <= H; j++){
				if(a[j][i] == '#'){
					f = 1;
					//flag = 1;
					//break;
				}
				if(a[j][i] == 'X')x++;
			}
			if(f == 0){
				if(x == H){
				}else{
					flag=1;
				
					for(int j = 1; j <= H; j++)a[j][i] = 'X';
				}
			}
			
			
			
		}
		flag  = 0;
			for(int i = 1; i <= H; i++)
		for(int j = 1; j <= W; j++){
			if(temp[i][j] != a[i][j]) flag = 1;
			temp[i][j] = a[i][j];
		}
		/*
			for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			//if(a[i][j] != 'X')cout<<a[i][j];
			cout<<a[i][j];
		}cout<<endl;
		}cout<<endl;
		*/
		
		
		if(flag == 0)break;
		//cin>>flag;
	}
	
	for(int i = 1; i <= H; i++){
		if(a[i][0] == 'A')continue;
		for(int j = 1; j <= W; j++){
			if(a[i][j] != 'X')cout<<a[i][j];
		}
		cout<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace atCoder
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] temp = Console.ReadLine().Split(' ');
            List<double> list = new List<double>();

            foreach (string s in temp)
            {
                list.Add(int.Parse(s));
            }

            while (1 < list.Count)
            {
                double d = double.MaxValue;
                double ii = 0;
                double jj = 0;

                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        if (i == j) continue;

                        if ((list[i] + list[j]) / 2 < d)
                        {
                            ii = list[i];
                            jj = list[j];

                            d = (list[i] + list[j]) / 2;
                        }
                    }
                }

                list.Remove(ii);
                list.Remove(jj);
                list.Insert(0, d);

                n--;
            }

            Console.WriteLine(list[0]);
        }
    }
}

Measured memory_bytes: 13152