akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{ 
    static void Main(string[]args)
    {
        Magatro alice = new Magatro();
        alice.Scan();
        alice.Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;
    private string[] S;
    private int Index;
    private const char Separator = ' ';
    public Scanner()
    {
        Index = 0;
        S = new string[0];
        Sr = new StreamReader(Console.OpenStandardInput());
    }
    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }
    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[] LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }
    public bool EndOfStream
    {
        get { return Sr.EndOfStream; }
    }
}

public class Magatro
{
    private string s;
    public void Scan()
    {
        Scanner sc = new Scanner();
        s = sc.Next();
    }

    public void Solve()
    {
        int l=-1;
        for(int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'A')
            {
                l = i;
                break;
            }
        }
        int r=-1;
        for(int i = s.Length - 1; i >= 0; i--)
        {
            if (s[i] == 'Z')
            {
                r = i;
                break;
            }
        }
        Console.WriteLine(r - l + 1);
    }
}

Measured memory_bytes: 4184
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1180&lang=jp

#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 calc(vector<int> &num);
vector<int> sub(vector<int> &max_num, vector<int> &min_num);
vector<int> convert_to_vector(int value, int L);

int calc(vector<int> &num)
{
	int digit=1, total=0;
	for(int i=num.size()-1; i>=0; --i)
	{
		total += num[i] * digit;
		digit *= 10;
	}

	return total;
}

vector<int> sub(vector<int> &max_num, vector<int> &min_num)
{
	int value = calc(max_num) - calc(min_num);
	
	return convert_to_vector(value, max_num.size());
}

vector<int> convert_to_vector(int num, int L)
{
	vector<int> value(L,0);
	
	rep(i,L)
	{
		int tmp = num % 10;
		num = num / 10;
		value[i] = tmp;
	}
	
	reverse(ALL(value));

	return value;
}

int main()
{
	int a0,L;

	while(cin >> a0 >> L)
	{
		if(a0 == 0 && L == 0){ break; }
		
		
		vector<int> value = convert_to_vector(a0,L);

		vector<int> table(21,0);
		table[0] = calc(value);
		
		REP(i,1,21)
		{
			vector<int> max_num = value;
			vector<int> min_num = value;

			sort(ALL(min_num));
			sort(max_num.rbegin(), max_num.rend());

			value = sub(max_num, min_num);
			table[i] = calc(value);
		}

		pair<int,int> i_j;
		int ans;

		rep(j,21){
			REP(i,j+1,21)
			{
					if(table[i] == table[j])
					{
						i_j=make_pair(j,i-j);
						ans = table[i];
						goto end;
					}
			}
		}
end:
		cout << i_j.first << " " << ans << " " << i_j.second << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
const int INF = 1 << 30;
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()
int main() {
	int n, v[110], ans=0, ch[1000] = {};
	cin >> n;
	rep(i, n) { cin >> v[i]; if (ch[v[i]] == 0) { ++ans; ch[v[i]] = 1; } }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,max,i,j;
	
	while(0<=scanf("%d",&n)){
		if(n==0){
			break;
		}
		max=0;
		for(i=0;i<n/4;i++){
			scanf("%d",&j);
			max+=j;
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
	int n,m,k;
	Edge edge[];
	int d[];
	int V,E;
	

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}
	
	void run(){
		Scanner sc=new Scanner(System.in);
		while(true){
			E=sc.nextInt();
			V=sc.nextInt();
			if(E+V==0)break;
			edge=new Edge[E*2];
			d=new int[V];

			for(int i=0;i<E;i++){
				int a=sc.nextInt()-1;
				int b=sc.nextInt()-1;
				int cost=sc.nextInt();
				int time=sc.nextInt();
				edge[i*2]=new Edge(a,b,cost,time);
				edge[i*2+1]=new Edge(b,a,cost,time);
			}
			k=sc.nextInt();

			for(int i=0;i<k;i++){
				int p=sc.nextInt()-1;
				int q=sc.nextInt()-1;
				int r=sc.nextInt();
				solve(p,q,r);
			}
		}
	}
	int INF=Integer.MAX_VALUE;
	
	void solve(int p,int q,int r){
		for(int i=0;i<V;i++)d[i]=INF;
		d[p]=0;
		while(true){
			boolean update=false;
			for(int i=0;i<E*2;i++){
				Edge e=edge[i];
				if(r==0){
					if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
						d[e.to]=d[e.from]+e.cost;
						update=true;
					}
				}else{
					if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.time){
						d[e.to]=d[e.from]+e.time;
						update=true;
					}
				}
			}
			if(!update)break;
		}
		System.out.println(d[q]);
	}
	
	class Edge{
		int from,to,cost,time;
		
		Edge(int f,int t1,int c,int t2){
			from=f;to=t1;cost=c;time=t2;
		}
	}
}

Measured memory_bytes: 64164
#include<iostream>
#include<cstring>
#include<cassert>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<time.h>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(int i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(int i=pos[x];~i;i=e[i].next)
#define ll long long
#define db double
const int N=4e5+7;
const int INF=1e9+7;
int n,k;
int p[N],S[N],s1[N][22],s2[N][22],mn[N];

int main(){
	scanf("%d%d",&n,&k);
	rep(i,n)scanf("%d",&p[i]);
	rep(i,n)s1[i][0]=s2[i][0]=p[i]+1;
	rep(i,n)S[i]=S[i-1]+(p[i]>p[i-1]);
	for(int i=1;(1<<i)<=n;i++){
		rep(j,n-(1<<i)+1){
			s1[j][i]=min(s1[j][i-1],s1[j+(1<<(i-1))][i-1]);
			s2[j][i]=max(s2[j][i-1],s2[j+(1<<(i-1))][i-1]);
		}
		REP(j,(1<<i)+1,(1<<(i+1)))mn[j]=i;
	}
	int ans=n-k+1,hh=0;
	rep(i,n-k+1){
		int o=mn[k];
		int mx=max(s2[i][o],s2[i+k-(1<<o)][o]);
		int mi=min(s1[i][o],s1[i+k-(1<<o)][o]);
		if(i>1&&p[i-1]+1<mi&&p[i+k-1]+1==mx)ans--;
		else if(S[i+k-1]-S[i]==k-1&&hh)ans--;
		if(S[i+k-1]-S[i]==k-1)hh=1;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 41472
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = [a[i]-b[i] for i in range(n)]
l.sort()
if sum(l)<0:
    ans = -1
else:
    s = sum(l[i] for i in range(n) if l[i]<0)
    if s>=0:
        ans = 0
    else:
        for j in range(n-1, -1, -1):
            s += l[j]
            if s>=0:
                break
        ans = sum(l[i]<0 for i in range(n)) + (n-j)
print(ans)

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

static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
    
    int minv;
    int d[MAX], color[MAX];
    
    for (int i = 0; i < n; i ++) {
        
        d[i] = INFTY;
        color[i] = WHITE;
        
    }
    
    d[0] = 0;
    
    while(1) {
        
        minv = INFTY;
        int 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] != INFTY) {
                
                if (d[v] > d[u] + M[u][v]) {
                    
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                    
                }
                
            }
            
        }
        
    }
    
    for (int i = 0; i < n; i ++) {
        
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
        
    }
    
}

int main() {
    
    cin >> n;
    
    for (int i = 0; i < n; i ++) {
        
        for (int j = 0; j < n; j ++) {
            
            M[i][j] = INFTY;
            
        }
        
    }
    
    int k, c, u, v;
    
    for (int i = 0; i < n; i ++) {
        
        cin >> u >> k;
        
        for (int j = 0; j < k; j ++) {
            
            cin >> v >> c;
            
            M[u][v] = c;
            
        }
        
    }
    
    dijkstra();
    
    return 0;
    
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define inf (long long)1e18
using namespace std;

struct data {
  long long num, id;
};
bool operator<(const data &l, const data &r) {
  if(l.num != r.num) return l.num < r.num;
  return l.id < r.id;
}

long long n;
vector<long long> a, b;

long long solve();
long long calc(vector<long long> &v);

int main() {
  cin >> n;
  a.resize(n);
  b.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) cin >> b[i];

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = inf;
  for(long long bit = 0; bit < (1LL << n); ++bit) {
    vector<data> odd, even;
    for(int i = 0; i < n; ++i) {
      long long now = (bit >> i & 1);
      if(now == 0) {
        if(i % 2)
          even.push_back({a[i], i});
        else
          odd.push_back({a[i], i});
      }
      else {
        if(i % 2)
          odd.push_back({b[i], i});
        else
          even.push_back({b[i], i});
      }
    }
    if(abs((int)odd.size() - (int)even.size()) > 1 ||
       odd.size() < even.size())
      continue;
    sort(odd.begin(), odd.end());
    sort(even.begin(), even.end());
    long long now = odd[0].num;
    bool ch = 1;
    vector<long long> v;
    v.push_back(odd[0].id);
    for(int i = 1; i < n; ++i) {
      data nextd;
      if(i % 2)
        nextd = even[i / 2];
      else
        nextd = odd[i / 2];
      if(now > nextd.num) { ch = 0; }
      now = nextd.num;
      v.push_back(nextd.id);
    }
    if(!ch) continue;
    now = calc(v);
    res = min(res, now);
  }
  if(res == inf) return -1;
  return res;
}

long long calc(vector<long long> &v) {
  int x = v.size();
  if(x <= 1) return 0;
  long long res = 0;
  vector<long long> p(v.begin(), v.begin() + x / 2),
      q(v.begin() + x / 2, v.end());
  res += calc(p) + calc(q);
  int aid = 0, bid = 0, cid = 0, psize = p.size(),
      qsize = q.size();
  while(aid < x) {
    if(bid < psize && (cid == qsize || p[bid] <= q[cid]))
      v[aid++] = p[bid++];
    else {
      res += x / 2 - bid;
      v[aid++] = q[cid++];
    }
  }
  return res;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll>pll;

int main() {
	int N, M, Q, p, q, L, R, S[501][501] = { 0 };
	
	cin >> N >> M >> Q;
	REP(i, M) {
		cin >> L >> R;
		S[L][R]++;
	}

	FOR(i, 1, N + 1) {
		FOR(j, 1, N + 1) {
			if (i <= j) {
				S[i][j] += S[i - 1][j];
			}
			else {
				S[i][j] = S[j][j];
			}
		}
	}

	REP(i, Q) {
		cin >> p >> q;
		int ans = 0;
		REP(j, q - p + 1) {
			ans += S[q][p+j] - S[p - 1][p + j];
		}
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
// typedef pair<ll,ll> p
typedef pair<ll,pair<ll,ll> > ppp;
#define mk make_pair
#define all(a) (a).begin(), (a).end()
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define parr(A,n) for(int xxx=0;xxx<n;xxx++){cout<<A[xxx]<<" ";}cout << "\n";
// #define ordered_set tree < pp ,  null_type ,  less<pp> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define MOD 1000000007
#define endl "\n"
inline ll power(ll x, ll y)
{
    ll res = 1;x = x % MOD;
    while (y > 0){if (y & 1) res = (res*x) % MOD;y = y>>1;x = (x*x) % MOD;}
    return res%MOD;
}
inline ll sum(ll a, ll b, ll m = MOD){b = ((b%m) + m)%m;a = ((a%m) + m)%m;return ((a+b)%m + m)%m;}
inline ll mul(ll a, ll b, ll m = MOD){b = ((b%m) + m)%m;a = ((a%m) + m)%m;return ((a*b)%m + m)%m;}
int main() {
    boost;
    ll n,m;
    cin >> n >> m;
    string s1, s2;
    cin >> s1 >> s2;
    if(n==m){
        if(s1!=s2) cout << -1 << "\n";
        else cout << n << "\n";
    }
    else{
        if(s1[0]!=s2[0]){
            cout << -1 << "\n";
            return 0;
        }
        if(__gcd(n,m)==1){
            cout << n*m << "\n";
        }
        else{
            ll n1 = n/__gcd(n,m);
            ll m1 = m/__gcd(n,m);
            bool ch = true;
            for(int i=0;i<n && i*n1<n && i*m1 < m;i++){
                if(s1[n1*i]!=s2[m1*i]){ch = false;break;}
            }
            ll lc = (n*m)/__gcd(n,m);
            if(ch) cout << lc << "\n";
            else cout << -1 << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define PI 3.14159265358979323846L
using namespace std;

double A, B, H, M;
double anglemin, anglehour, diffangle;

int main() {
  cin >> A >> B >> H >> M;
  anglemin = 6 * M;
  anglehour = 30 * H + 0.5 * M;
  diffangle = max(anglemin, anglehour) - min(anglemin, anglehour);
  if(diffangle > 180) diffangle = 360 - diffangle;
  cout << fixed;
  cout << setprecision(10) << sqrt(A * A + B * B - 2 * A * B * cos(diffangle * PI / 180)) << "\n";
}

Measured memory_bytes: 4152
#include <stdio.h>
int main(){
   
  int x,y,i,a;
   
  for(i = 0 ; 1 ; i++){
    scanf("%d%d",&x,&y);
    if(x == 0 && y == 0) break;
     
    if(x > y){
      a = x;
      x = y;
      y = a;
    }
    printf("%d %d\n",x,y);
  }
  return 0;
}

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

using namespace std;

int main()
{
    uint32_t nn;
    uint64_t sum = 0;
    cin >> nn;
    vector<uint32_t> nary(nn, 0);

    for(int i = 0; i < nn; i++){
        if((((i + 1) % 3) == 0) || (((i + 1) % 5) == 0))
        nary[i] = 1;
    }

    for(int i = 1; i <= nn; i++){
        if(nary[i - 1] == 0)
        sum += i;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 7112
//IN THE NAME OF LORD
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int              long long 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vvi             vector<vector<int>>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             9e18
#define ALL(a)          a.begin(),a.end()
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define from(i,n)       for(int i=0;i<(int)n;i++)
#define from_j(i,j,n)   for(int i=j;i<(int)n;i++)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
int dp[101][10001][2];
string K;
int D;
//int mod = 1e9 + 7;
int findans(int sum,int i,bool r){
  if(i==K.length()){
    return sum==0?1:0;
  }
  if(dp[sum][i][r]!=-1)
    return dp[sum][i][r];
  int ans = 0;
  int maxi = r==1?K[i]-'0':9;
  for(int num=0;num<=maxi;num++){
    ans = (ans + findans((sum+num)%D, i+1, r&&(num==maxi)))%mod;
  }
  return dp[sum][i][r] = ans;
}
int32_t main()
{
    c_p_c();                    
    cin>>K>>D;
    for(int i=0;i<=D;i++)
      for(int j=0;j<=K.length();j++)
        dp[i][j][0] = dp[i][j][1] = -1;
    int ans = findans(0,0,1) - 1;
   // cout<<ans<<endl;
    if(ans<0)
      ans += mod;
    cout<<ans;



 cerr << "proc time: " << 1.0 * clock() / CLOCKS_PER_SEC << "s    ";
    return 0;
        
}


Measured memory_bytes: 20260
#include<bits/stdc++.h>
using namespace std;
int n,x[105],y[105],h[105];
pair<int,pair<int,int> >mx;
int main() {
mx.first=2e9;
cin>>n;
for(int i=1;i<=n;++i)
cin>>x[i]>>y[i]>>h[i];
for(int i=0;i<=100;++i)
for(int j=0;j<=100;++j) {
int hei=2e9,flg=0;
for(int k=1;k<=n;++k)
if(h[k]) {
hei=h[k]+abs(i-x[k])+abs(j-y[k]),flg=1;
break;
}
for(int k=1;k<=n;++k)
if(max(0,hei-abs(i-x[k])-abs(j-y[k]))!=h[k]) {
flg=0;
break;
}
if(flg)
mx=min(mx,make_pair(hei,make_pair(i,j)));
}
printf("%d %d %d\n",mx.second.first,mx.second.second,mx.first);
}

Measured memory_bytes: 256
a=input()
b=list(a)
c=0
for i in range(len(b)):
    if b[i]!=b[(len(b)-1-i)]:
        c=1
for i in range(int(len(b)/2)):
    if b[i]!=b[int(((len(b)-1)/2))-1-i]:
        c=1

if c==1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define clr(x, y) memset(x, y, sizeof(x))
#define fl(a, b) for(int i=a; i<b; i++)
using namespace std;
typedef long long ll;
const int maxn = 100000 + 5;
const int inf = INT_MAX;

int main() {
	int N;
	cin >> N;
	char s[110], ans[220];
	cin >> s;
	int cnt = 0, t2 = 100, t1 = 99;
	for(int i=N-1; i>=0; i--) {
		if(s[i]==')') {
			ans[t2++] = ')';
			cnt++;
		}
		else if(cnt > 0) {
			ans[t2++] = '(';
			cnt--;
		}
		else {
			ans[t1--] = ')';
			ans[t2++] = '(';
		}
	}
	while(cnt--) printf("(");
	for(int i=t2-1; i>t1; i--) printf("%c", ans[i]);
	printf("\n");
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let h: usize = input();
    let w: usize = input();
    let s: Vec<Vec<char>> = (0..h)
        .map(|_| input::<String>().chars().collect())
        .collect();

    let mut v = vec![vec![0; w + 1]; h + 1];
    for i in 0..h {
        let mut j = 0;
        while j < w {
            if s[i][j] == '#' {
                j += 1;
                continue;
            }
            let l = j;
            let mut cnt = 0;
            while j < w && s[i][j] == '.' {
                cnt += 1;
                j += 1;
            }
            v[i][l] = cnt;
            v[i][j] = -cnt;
        }
        for j in 0..w {
            v[i][j + 1] += v[i][j];
        }
    }

    let mut u = vec![vec![0; w + 1]; h + 1];
    for j in 0..w {
        let mut i = 0;
        while i < h {
            if s[i][j] == '#' {
                i += 1;
                continue;
            }
            let l = i;
            let mut cnt = 0;
            while i < h && s[i][j] == '.' {
                cnt += 1;
                i += 1;
            }
            u[l][j] = cnt;
            u[i][j] = -cnt;
        }
        for i in 0..h {
            u[i + 1][j] += u[i][j];
        }
    }

    let mut ans = 0;
    for i in 0..h {
        for j in 0..w {
            ans = std::cmp::max(ans, v[i][j] + u[i][j] - 1);
        }
    }

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


Measured memory_bytes: 53500
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String ars[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int n=Integer.parseInt(str[0]);
        int k=Integer.parseInt(str[1]);
        str=br.readLine().split(" ");
        int arr[]=new int[n];
        for(int i=0;i<n;i++)
        arr[i]=Integer.parseInt(str[i]);
        Arrays.sort(arr);
        int sum=0;
        for(int i=0;i<k;i++)
        sum+=arr[i];
        pw.println(sum);
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 33028
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int h, w, a, b;
    cin>>h>>w>>a>>b;
    rep(i, h) {
        rep(j, w) {
            if(i < b && j < a || i >= b && j >= a) cout<<1;
            else cout<<0;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

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

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    ll ans = 0;
    ll a,b;
    rep(i,N){
        cin >> a >> b;
        ans += b - a + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int[] a, p, max;
    int i, j, res, pn;

    n = sc.nextInt();
    pn = 1000;
    a = new int[n];
    p = new int[pn];
    max = new int[pn];
    for(i = 0;i < n;i++)a[i] = sc.nextInt();

    for(i = 0;i < n;i++){
      for(j = 0;j < pn;j++)p[j] = 0;
      for(;a[i] != 1;){
        for(j = 2;j * j <= a[i];j++){
          if(a[i] % j == 0){
            p[j]++;
            a[i] = a[i] / j;
            break;
          }
        }
        if(j * j > a[i]){
          p[a[i]]++;
          break;
        }
      }
      for(j = 2;j < pn;j++)if(max[j] < p[j])max[j] = p[j];
    }
    res = 1;
    for(i = 2;i < pn;i++)if(isprime(i))for(j = 0;j < max[i];j++)res *= i;
    System.out.println(res);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }

  private static boolean isprime(int p){
    int i;
    if(p == 1)return false;
    for(i = 2;i * i <= p;i++){
      if(p % i == 0)return false;
    }
    return true;
  }
}

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

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

    int N, H;
    cin >> N >> H;
    vector<vector<int>> ab(N, vector<int>(2));
    for (int i = 0; i < N; i++) {
        cin >> ab[i][0] >> ab[i][1];
    }
    sort(ab.begin(), ab.end(), [](auto& x, auto& y) { return x[1] < y[1]; });
    sort(ab.begin(), ab.end(), [](auto& x, auto& y) { return x[0] > y[0]; });

    int max_a = ab[0][0];
    sort(ab.begin(), ab.end(), [](auto& x, auto& y) { return x[1] > y[1]; });

    int cnt = 0, d = 0;
    for (int i = 0; i < N; i++) {
        if (ab[i][1] < max_a) break;
        d += ab[i][1];
        cnt++;
        if (d >= H) break;
    }

    if (d < H) cnt += (H - d - 1) / max_a + 1;
    cout << cnt << endl;
}


Measured memory_bytes: 5760
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

  	Int A, B; cin >> A >> B;
    rep(C, 1, 4) {
        if ((A*B*C)%2 == 1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
def main():
    n, t, *s = map(int, open(0).read().split())
    ans = 0
    s = [0] + s
    for i, j in zip(s, s[1:]):
        if j - i >= t:
            ans += t
        else:
            ans += j - i
    else:
        ans += t

    print(ans)


if __name__ == '__main__':
    main()


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

int main(){


  int x1,y1,x2,y2,x3,y3,x4,y4;
  cin>>x1>>y1>>x2>>y2;
  
  x3=x2+y1-y2;
  y3=y2-x1+x2;
  x4=x1+y1-y2;
  y4=y1-x1+x2;
  
  cout<<x3;
  cout<<' ';
  cout<<y3;
  cout<<' ';
  cout<<x4;
  cout<<' ';
  cout<<y4<<endl;
  
}
  













Measured memory_bytes: 256
# ABC060C - Sentou (ARC073C)
n, t = list(map(int, input().rstrip().split()))
lst = list(map(int, input().rstrip().split()))
ans, cur = 0, lst[0]
for i in lst[1:]:
    ans += min(t, i - cur)
    cur = i
ans += t
print(ans)

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

using namespace std;

int main() {
	int N;
	cin >> N;
	int64_t a = 1;
	int64_t b = 1;

	for (int i = 0; i < N; i++) {
		int T, A;
		cin >> T >> A;

		long long int k = max((a + T - 1) / T, (b + A - 1) / A);
		a = T * k;
		b = A * k;

	}

	cout << a + b << endl;

	return 0;
}

Measured memory_bytes: 256
// c++ cpp.cpp -o cpp.exe -std=c++14

#include <iostream>
using namespace std;

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

class Dice
{
    int faces[6];

  public:
    int top, front, right, left, back, bottom;
    void in()
    {
        rep(i, sizeof(faces) / sizeof(int))
        {
            cin >> faces[i];
        }
        top = faces[0];
        front = faces[1];
        right = faces[2];
        left = faces[3];
        back = faces[4];
        bottom = faces[5];
    }

    void rotate(char command)
    {
        int pre_top = top;
        switch (command)
        {
        case 'N':
            top = front;
            front = bottom;
            bottom = back;
            back = pre_top;
            break;
        case 'E':
            top = left;
            left = bottom;
            bottom = right;
            right = pre_top;
            break;
        case 'W':
            top = right;
            right = bottom;
            bottom = left;
            left = pre_top;
            break;
        case 'S':
            top = back;
            back = bottom;
            bottom = front;
            front = pre_top;
            break;
        case 'R':
            int pre_front = front;
            front = left;
            left = back;
            back = right;
            right = pre_front;
            break;
        }
    }
};

int main()
{
    Dice dice_x, dice_y;
    dice_x.in();
    dice_y.in();

    rep(i, 4)
    {
        dice_x.rotate('N');
        rep(j, 4)
        {
            dice_x.rotate('E');
            rep(k, 4)
            {
                dice_x.rotate('R');
                if (dice_x.top != dice_y.top)
                {
                }
                else if (dice_x.bottom != dice_y.bottom)
                {
                }
                else if (dice_x.left != dice_y.left)
                {
                }
                else if (dice_x.right != dice_y.right)
                {
                }
                else if (dice_x.front != dice_y.front)
                {
                }
                else if (dice_x.back != dice_y.back)
                {
                }
                else
                {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
}



Measured memory_bytes: 3104
import math
import numpy as np
A, B, H, M = map(int, input().split(" "))

alpha = 0.5 * (60 * H + M)
beta = 6 * M
x = abs(beta - alpha)
if x > 180:
  x = 360 - x
rad = np.pi * x / 180
cos = np.cos(rad)
ans = math.sqrt(A**2 + B**2 - 2 * A * B * cos)
print(ans)

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

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

// UnionFind
struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n,-1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

int main(){
    int n, m;
    cin >> n >> m;
    vi a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    UnionFind uf(n);
    vll ans(m);
    ans[m-1] = (ll)n*(n-1)/2;
    rep1r(i, m-1) {
        if (uf.same(a[i], b[i])) {
            ans[i-1] = ans[i];
        }
        else {
            ll as = uf.size(a[i]), bs = uf.size(b[i]), pre = as*(as-1)/2 + bs*(bs-1)/2;
            uf.unite(a[i], b[i]);
            ll ts = uf.size(a[i]), sub = ts*(ts-1)/2 - pre;
            ans[i-1] = ans[i] - sub;
        }
    }
    rep(i, m) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 5104
class Position
  attr_reader :x, :y

  def initialize(x, y)
    @x = x
    @y = y
  end

  def +(other)
    @x += other.x
    @y += other.y
    self
  end
end

DIRECTIONS = {
  'N' => Position.new(0, 1),
  'E' => Position.new(1, 0),
  'S' => Position.new(0, -1),
  'W' => Position.new(-1, 0),
}

class PlanetField
  def initialize()
    @field = Array.new(21).map{Array.new(21,false)}
  end

  def put_gem(position)
    @field[position.x][position.y] = true
  end

  def pick_gem(position)
    @field[position.x][position.y] = false
  end

  def gem_remaining()
    @field.flatten.count(true)
  end
end

class Robot
  attr_reader :position

  def initialize(position)
    @position = position
  end

  def move(position)
    @position = @position + position
  end
end

while (gems = gets.to_i) != 0
  field = PlanetField.new
  robot = Robot.new(Position.new(10, 10))

  gems.times {
    field.put_gem(Position.new(*(gets.split.map &:to_i)))
  }

  orders = gets.to_i
  orders.times {
    direction, amount = gets.split
    amount.to_i.times {
      robot.move(DIRECTIONS[direction])
      field.pick_gem(robot.position)
    }
  }

  puts(field.gem_remaining == 0 ? 'Yes' : 'No')
end



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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    int s = to_string(i).length();
    if (s % 2 != 0)
      ans++;
  }
  cout << ans << endl;
}

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

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

    ans=1;
    for(int i=1; i<=N; i++){
        ans= ans*( (long) i);
        if( ans > 1e9 - 7 ){
            ans = ans%( (long) 1e9 + 7 );
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
I=lambda:map(int,input().split())
N=0xfffff
n,q=I()
c=list(I())
Q=[]
for i in range(q):l,r=I();Q.append(l<<40|r<<20|i)
Q.sort()
A=[[]for i in range(N)]
for i,x in enumerate(c):A[x].append(i)
B=[0]*N
def P(i,x):
	i+=1
	while i<=n:B[i]+=x;i+=i&-i
def G(i):
	s=0
	while i:s+=B[i];i-=i&-i
	return s
for i in A:
	if i:P(i[0],1);i.reverse()
t=0
o=[0]*q
for x in Q:
	l=x>>40
	r=x>>20&N
	i=x&N
	while t+1<l:
		b=A[c[t]]
		P(b[-1],-1)
		b.pop()
		if b:P(b[-1],1)
		t+=1
	o[i]=G(r)-G(l-1)
for i in o:print(i)

Measured memory_bytes: 248520
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        long N = Reader.Long(), S = Reader.Long();
        if (N == S) { Console.WriteLine(N + 1); return; }
        long ans = long.MaxValue;
        long sqrt = (long)Math.Sqrt(N);

        Func<long, long> F = b =>
        {
            long sum = 0;
            for (long t = N; t > 0; t /= b)
                sum += t % b;
            return sum;
        };
        for (int i = 1; i <= sqrt; i++)
        {
            if (i >= 2 && F(i) == S) ans = Math.Min(ans, i);

            // N = i*b + a
            // S = i + a
            if (S - i < 0) continue;
            long a = S - i;
            long b = (N - a) / i;
            if (b >= 2 && i < b && a < b && (N - a) % i == 0)
                ans = Math.Min(ans, b);
        }

        Console.WriteLine(ans == long.MaxValue ? -1 : ans);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

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

using namespace std;
typedef long long ll;
struct Point
{
    ll x,y;
    int id;
};
struct edge
{
    int a,b,w;
};
bool cmp1(Point a,Point b)
{
    return a.x<b.x;
}
bool cmp2(Point a,Point b)
{
    return a.y<b.y;
}
bool cmp3(edge a,edge b)
{
    return a.w<b.w;
}
int f[100005];
int bcj(int p)
{
    if(f[p]==p)
        return p;
    f[p]=bcj(f[p]);
    return f[p];
}
void join(int p,int q)
{
    int fp=bcj(p);
    int fq=bcj(q);
    if(fp!=fq)
        f[fp]=fq;
}

Point village[100005];
edge e[200005];
int main()
{
    int N;

    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        f[i]=i;
    }
    for(int i=0;i<N;i++)
    {
        scanf("%lld%lld",&village[i].x,&village[i].y);
        village[i].id=i;
    }

    int cnt=0;
    sort(village,village+N,cmp1);
    for(int i=0;i<N-1;i++)
    {
        e[cnt].a=village[i].id;
        e[cnt].b=village[i+1].id;
        e[cnt].w=village[i].x-village[i+1].x;
        if(e[cnt].w<0)
            e[cnt].w*=-1;
        cnt++;
    }
    sort(village,village+N,cmp2);
    for(int i=0;i<N-1;i++)
    {
        e[cnt].a=village[i].id;
        e[cnt].b=village[i+1].id;
        e[cnt].w=village[i].y-village[i+1].y;
        if(e[cnt].w<0)
            e[cnt].w*=-1;
        cnt++;
    }

    sort(e,e+cnt,cmp3);
    ll ans=0;
    int p=0;
    while(N-->1)
    {
        while(1)
        {

            if(bcj(e[p].a)!=bcj(e[p].b))
            {
                join(e[p].a,e[p].b);
                ans+=(ll)e[p].w;

                p++;
                break;
            }
            p++;
        }
    }
    printf("%lld",ans);



}


Measured memory_bytes: 5376
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void)
{
    int n;
    int i, j;
    char s[200000][11];
    int sCount[200001];

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%s", s[i]);

    qsort(s, n, 11, strcmp);

    int max = 0;
    sCount[0] = 1;
    for (i = 1; i < n; i++)
    {
        if (strcmp(s[i - 1], s[i]) == 0)
            sCount[i] = sCount[i - 1] + 1;
        else
        {
            sCount[i] = 1;
            if (sCount[i - 1] > max)
                max = sCount[i - 1];
        }
    }
    if (sCount[n - 1] > max)
        max = sCount[n - 1];

    for (i = 0; i < n; i++)
        if (sCount[i] == max)
            printf("%s\n", s[i]);

    return 0;
}

Measured memory_bytes: 4884
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
long long int GCD(long long int a,long long int b){
    if(b==0)return a;
    return GCD(b,a%b);
}
long long int LCM(long long int a,long long int b){
    return (a*b)/GCD(a,b);
}
int main(){
    long long int a[6];
    while(1){
        for(int i=0;i<6;i++)cin>>a[i];
        if(!a[0])break;
        long long int nowti[3]={1,1,1},n[3];
        for(int i=0;i<3;i++){
            for(int j=0;;j++){
                nowti[i]=nowti[i]*a[i*2]%a[i*2+1];
                if(nowti[i]==1){
                    n[i]=j+1;
                    break;
                }
            }
        }
        cout<<LCM(n[0],LCM(n[1],n[2]))<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

s = int(input())
mod = 10**9 + 7

n_max = s // 3
ans = 0

#組み合わせ（modで割ったあまり）
def nCk(n, k, mod=10 ** 9 + 7):
    if n < k:
        return 0
    k = min(k, n - k)
    numer = 1
    for x in range(n - k + 1, n + 1):
        numer = (numer * x) % mod
    denom = 1
    for x in range(1, k + 1):
        denom = (denom * x) % mod
    return numer * pow(denom, mod - 2, mod) % mod

for i in range(1, n_max + 1):
    m = s - 3 * i
    ans += nCk(m + i - 1, i - 1)
    ans %= mod

print(ans)

Measured memory_bytes: 67596
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] P = nextIntArray(sc, N);
		ArrayList<Integer>[] edge = new ArrayList[N+1];
		for (int i = 0; i < M; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			add(edge, x, y);
			add(edge, y, x);
		}
		int[] revP = new int[N+1];
		for (int i = 0; i < N; i++) {
			revP[P[i]] = i;
		}

		int color = 0;
		int[] colors = new int[N];
		for (int i = 0; i < N; i++) {
			if (colors[i] == 0) {
				color++;
				fill(colors, color, i, edge);
			}
		}
		int count = 0;
		for (int i = 0; i < N; i++) {
			int color1 = colors[i];
			int color2 = colors[revP[i + 1]];
			if (color1 == color2) count++;
		}
		System.out.println(count);
	}

	static void add(ArrayList<Integer>[] edge, int src, int dst) {
		if (edge[src] == null) {
			edge[src] = new ArrayList<>();
		}
		edge[src].add(dst);
	}

	static void fill(int[] colors, int color, int index, ArrayList<Integer>[] edge) {
		if (colors[index] != 0) return;
		colors[index] = color;

		if (edge[index + 1] != null) {
			for (int next : edge[index+1]) {
				fill(colors, color, next - 1, edge);
			}
		}
	}
}


Measured memory_bytes: 107144
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
	ll a, b, c;
	scanf("%lld%lld%lld", &a, &b ,&c);
	if(a >= b && a >= c){
		if(a % 2) printf("%lld\n", b * c);
		else printf("0\n");
	}else if(b >= a && b >= c){
		if(b % 2) printf("%lld\n", a * c);
		else printf("0\n");
	}else if(c >= a && c >= b){
		if(c % 2) printf("%lld\n", a * b);
		else printf("0\n");
	}
	return 0;
} 

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a;
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputDoubleArray(a,N) double a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
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; }

int main(){
  //input
  inputLong(N);
  
  vector<long long int> a(N,0), b(N,0);
  long long int sum = 0;
  for(int i=0; i<N; i++){
    cin >> a[i];
    b[i] = abs(a[i]);
    sum += b[i];
  }
  
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());//最も絶対値が小さいa[i]を走査。
  
  long long int minus = lower_bound(a.begin(),a.end(),0)-a.begin();
  long long int ans = 0;
  
  if(minus % 2 == 0 || b[0] == 0){//全て正の整数になる時
    //ans = accumulate(b.begin(),b.end(),0);
    ans = sum;
  }else{
    //ans = accumulate(b.begin(),b.end(),0) - b[0]*2;
    ans = sum - b[0]*2;
  }
  
  //output
  output(ans);
  
  return 0;
}



Measured memory_bytes: 1792
n = int(input())
L = list(map(int,input().split()))
from itertools import product
sum1 = 0
for i in product(L,repeat =2):
    #print(i)
    if i[0] != i[1]:
        sum1 += (i[0]*i[1])
#print(sum1//2)
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        #print(i,j)
        ans += L[i]*L[j]
print(ans)

Measured memory_bytes: 3064
N = gets.to_i
As = gets.split.map(&:to_i)

s = As.inject(:+)
bs = [s - 2*As.values_at(*1.step(N - 2, 2).to_a).inject(:+)]
(N - 1).times{|i| bs[i + 1] = 2*As[i] - bs[i]}
puts bs.join(' ')

Measured memory_bytes: 14524
// https://beta.atcoder.jp/contests/abc080
// status:

#define SUBMIT

#include <bits/stdc++.h>
using namespace std;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    auto s = std::string(R"(7 17 120
)");

    stringstream stream(s);
#endif
    int N, A, B;
    stream >> N >> A >> B;
    auto ans = min(A * N, B);
    cout << ans << endl;
    return 0;
}

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


int main(){
	int K;
	int N;
	int i;
	
	cin >> N >> K;;
	int H[N];
	bool isdef[N];
	bool isact[N];
	int temp=0;


	for(i=0;i<N;i++){
		cin >> H[i];
	}
	long long int s=0;

	sort(H,H+N,greater<>());
	for(i=K;i<N;i++){
		s += H[i];
	}
	cout << s;


}

Measured memory_bytes: 1024
a, b, c = map(int, input().split())
start_number = 0
sum_number = 0
for d in range(0, a+1, 1):
    for e in str(d):
        sum_number += int(e)
    if b <= sum_number <= c:
        start_number += d
        sum_number = 0
    else:
        sum_number = 0
print(start_number)

Measured memory_bytes: 9180