akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

void get_distribution(vector<char> &S_v, map<int, int> &S_dis) {
  for (int i = 0; i < S_v.size(); ++i) {
    char ref = S_v[i];
    int j = 1;
    while (i + j < S_v.size() and ref == S_v[i + j]) {
      j += 1;
    }
    auto itr = S_dis.find(j);
    if (itr != S_dis.end()) {
      S_dis[j] += 1;
    } else {
      S_dis[j] = 1;
    }
    i = i + j - 1;
  }
}

int main() {
  string S, T;
  cin >> S >> T;

  vector<char> S_v(S.begin(), S.end());
  sort(S_v.begin(), S_v.end());
  vector<char> T_v(T.begin(), T.end());
  sort(T_v.begin(), T_v.end());

  map<int, int> S_dis;
  map<int, int> T_dis;
  get_distribution(S_v, S_dis);
  get_distribution(T_v, T_dis);
  if (S_dis == T_dis) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
int main(){
int N,D,X;
scanf("%d",&N);
scanf("%d%d",&D,&X);
int i;
int temp;
int sum=0;
for(i=0;i<N;i++){
scanf("%d",&temp);
sum+=(int)((D-1)/temp)+1;
}
printf("%d\n",sum+X);
return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

namespace Solver
{
    class Program
    {
        const int M = 1000000007;
        static void Main()
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            var sc = new Scan();
            while (true)
            {
                int n = sc.Int;
                if (n == 0)
                    break;
                var set = new HashSet<int>();
                var people = new long[4001];
                for (int i = 0; i < n; i++)
                {
                    var arr = sc.IntArr;
                    set.Add(arr[0]);
                    people[arr[0]] += (long)arr[1] * arr[2];
                }
                bool exi = false;
                foreach (var i in set)
                {
                    if (people[i] >= 1000000)
                    {
                        exi = true;
                        sw.WriteLine(i);
                    }
                }
                if (!exi)
                    sw.WriteLine("NA");
            }
            sw.Flush();
        }
    }
    class Scan
    {
        public int Int { get { return int.Parse(Console.ReadLine().Trim()); } }
        public long Long { get { return long.Parse(Console.ReadLine().Trim()); } }
        public string Str { get { return Console.ReadLine().Trim(); } }
        public int[] IntArr { get { return Console.ReadLine().Trim().Split().Select(int.Parse).ToArray(); } }
        public long[] LongArr { get { return Console.ReadLine().Trim().Split().Select(long.Parse).ToArray(); } }
        public double[] DoubleArr { get { return Console.ReadLine().Split().Select(double.Parse).ToArray(); } }
        public string[] StrArr { get { return Console.ReadLine().Trim().Split(); } }
        public List<int> IntList { get { return Console.ReadLine().Trim().Split().Select(int.Parse).ToList(); } }
        public List<long> LongList { get { return Console.ReadLine().Trim().Split().Select(long.Parse).ToList(); } }
        public void Multi(out int a, out int b) { var arr = IntArr; a = arr[0]; b = arr[1]; }
        public void Multi(out int a, out int b, out int c) { var arr = IntArr; a = arr[0]; b = arr[1]; c = arr[2]; }
        public void Multi(out long a, out long b) { var arr = LongArr; a = arr[0]; b = arr[1]; }
        public void Multi(out string a, out string b) { var arr = StrArr; a = arr[0]; b = arr[1]; }
    }
}

Measured memory_bytes: 6732
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int H,W; cin>>H>>W;
  vector<vector<string>> S(H,vector<string>(W));
  rep(i,0,H){
    rep(j,0,W) cin>>S[i][j];
  }
  rep(i,0,H){
    rep(j,0,W){
      if(S[i][j]=="snuke"){
        cout<<(char)(j+'A')<<i+1<<endl;
        break;
      }
    }
  }
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x << 1) + (x << 3) + (ch ^ 48);
    return x * fh;
}

const int N = 1e5 + 1e3;
queue<int> Q;
int dig[N], Mod;
bitset<N> inq;

void Spfa() {
	inq.reset();
	Set(dig, 0x3f);
	
	For (i, 1, 9) 
		inq[i] = true, dig[i] = i, Q.push(i);

	while (!Q.empty()) {
		int u = Q.front(); inq[u] = false; Q.pop();
		For (i, 0, 9) {
			int v = (u * 10 + i) % Mod;

			if (chkmin(dig[v], dig[u] + i) && !inq[v])
				inq[v] = true, Q.push(v);
		}
	}
}

void File() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}

int main () {
	File();
	Mod = read();
	Spfa();
	printf ("%d\n", dig[0]);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 2e5+6;
string g[444];
int n,m; 
bool ch(int x, int y){
	return (x>=0 and x<n and y<m and y>=0);
}
bool vis[444][444];
int clr[444][444];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll cnt[404*404][2];
void dfs(int x, int y){
	vis[x][y] = true;
	if (g[x][y]=='.')cnt[clr[x][y]][0]++;
	else cnt[clr[x][y]][1]++;
	for(int i=0;i<4;i++){
		int nx = x+dx[i];
		int ny = y+dy[i];
		if(!ch(nx,ny))continue;
		if(vis[nx][ny])continue;
		if(g[x][y]==g[nx][ny])continue;
		clr[nx][ny] = clr[x][y];
		dfs(nx,ny);
	}
}
void solve(){
	cin>>n>>m; 
	for(int i=0;i<n;i++){
		cin>>g[i];
	}
	int tmp = 1;
	ll ans = 0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(vis[i][j]==false){
				clr[i][j] = tmp;
				dfs(i,j);
				ans+=cnt[tmp][0]*cnt[tmp][1];
				tmp++;
			}
		}
	}
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


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

using namespace std;
typedef long long ll;

#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(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

class Solution
{
public:
    string odd_even(int a, int b)
    {
        int multi = a * b;
        return (multi % 2 == 0) ? "Even" : "Odd";
    }
};

int main()
{
    int a, b;
    cin >> a >> b;
    Solution s;
    cout << s.odd_even(a, b) << endl;
    return 0;
}


Measured memory_bytes: 3560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author zhangyong
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.next();
            int len = 0;
            for (int i = str.length() / 2 - 1; i >= 0; i--) {
                if (str.substring(0, i).equals(str.substring(i, 2 * i))) {
                    len = 2 * i;
                    break;
                }
            }
            out.print(len);
        }

    }
}



Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<cstdlib>
#include<algorithm>
#include<climits>
#include<queue>
#include<stack>
#include<cmath>
#include<iterator>
typedef long long ll;
using namespace std;
#define rep(x, y)   for (ll i = x; i <= y; i ++)
#define repi(x, y)  for (ll i = x; i >= y; i --)
priority_queue< ll > cancel;
ll arr[100005][3];
ll brr[200005];
ll dp[100005][3];
int main()
{
    ll test=1;
    // cin>>test;
    for(ll z=0;z<test;z++)
    {
        ll n,k;
        cin>>n;
        for(ll i=1;i<=n;i++)
        {
            for(ll j=0;j<3;j++)
            {
                cin>>arr[i][j];            
            }
        }
        dp[1][0]=arr[1][0];
        dp[1][1]=arr[1][1];
        dp[1][2]=arr[1][2];
        for(ll i=2;i<=n;i++)
        {
            dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
            dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
            dp[i][2]=arr[i][2]+max(dp[i-1][0],dp[i-1][1]);
        }
        cout<<max(max(dp[n][0],dp[n][1]),dp[n][2])<<endl;
    }
}

Measured memory_bytes: 8268
import sys
for a,b,c,d,e,f,g,h in[map(float,l.split()) for l in sys.stdin]:print["NO","YES"][((c-a)*(d-h)-(d-b)*(c-g)>0)==((e-c)*(f-h)-(f-d)*(e-g)>0)==((a-e)*(b-h)-(b-f)*(a-g)>0)]

Measured memory_bytes: 4240
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n,A[123456],s2,s4;
int main()
{
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&A[i]);
		if(A[i]%4==0)s4++;
		else if(A[i]%2==0)s2++;
	}
	if(s2==n){puts("Yes");return 0;}
	if(s2)
	{
		n-=s2;
		if((n-1)/2>s4-1)puts("No");
		else puts("Yes");
	}
	else
	{
		if(n/2>s4)puts("No");
		else puts("Yes");
	}
}


Measured memory_bytes: 640
#include<stdio.h>
#include<bitset>
int main()
{
	const int N=151201;
	int x,y,i,j;
	std::bitset<N>b;
	for(i=0;x=i*i*i,x<N;++i)
		for(j=0;y=j*(j+1)*(j+2)/6,x+y<N;++j)
			b[x+y]=1;
	while(scanf("%d",&x),x)
	{
		while(!b[x])--x;
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,m;
struct node{
	int a[15],k;
}l[15];
int p[15],cho[15],ans;
bool calc(){
	for(int i=1;i<=m;i++){
		int sum=0;
		for(int j=1;j<=l[i].k;j++){
			sum+=cho[l[i].a[j]];
		}
		sum%=2;
		if(sum!=p[i])return false;
	}
	return true;
}
void dfs(int now){
	if(now==n+1){
		if(calc()){
			ans++;
		}
		return ;
	}
	cho[now]=0;
	dfs(now+1);
	cho[now]=1;
	dfs(now+1);
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=m;i++){
		l[i].k=read();
		for(int j=1;j<=l[i].k;j++)l[i].a[j]=read();
	}
	for(int i=1;i<=m;i++)p[i]=read();
	dfs(1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define REP(i, a, b, c) for(int i = a; i <= b; i+=c)
#define pb push_back
#define int long long int
#define MOD 1000000007
using namespace std;

/*class Graph {

  map<int, list<pair<int, int> > > l;

public:
  void addEdge(int x, int y, int cost) {
    l[x].pb(make_pair(y, cost));
    l[y].pb(make_pair(x, cost));
  }

  int dfs_helper(int n, int node, map<int, int> &vis, map<int, int> &count, int &ans) {
    //cout << node << " " ;
    vis[node] = 1;
    count[node] = 1;
    for (auto m : l[node]) {
      if (!vis[m.F]) {
        vis[m.F] = 1;
        count[node] += dfs_helper(m.F, vis, count, ans);
        ans += 2 * min(count[node], n - count[node]) * m.S.S;
      }
    }
    return count[node];
  }

  void dfs() {
    map<int, int> vis;
    map<int, int> count;
    int ans = 0;
    dfs_helper(0, vis, count, ans);
    cout << ans << endl;
  }

};*/

int dp[100005];

int f(int a[], int n, int k)
{
  //cout << i << endl;
  dp[1] = 0;
  for (int i = 2; i <= n; i++) {
    dp[i] = INT_MAX;
    for (int j = i - 1; j >= 1 and (i - j) <= k; j--)
      dp[i] = min(dp[i], abs(a[i] - a[j]) + dp[j]);
  }
  return dp[n];
}


int32_t main()
{
  ios :: sync_with_stdio(false); cin.tie(0);
  int t = 1;
  //cin >> t;
  for (int i9 = 1; i9 <= t; i9++)
  {
    /* Graph G;
     int n, x, y, cost;
     cin >> n;
     while (n--) {
       cin >> x >> y >> cost;
       G.addEdge(x, y, cost);
     }
     G.dfs();*/
    //freopen("ouputnew.txt", "w", stdout);
    //flclose(stdout);
    memset(dp, 0 , sizeof (dp));
    int n, k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 0; i < n; i++)
      cin >> a[i + 1];
    cout << f(a, n, k);
  }
}



Measured memory_bytes: 5156
<?php
fscanf(STDIN, '%d %d', $n, $m);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$lcm = lcmAll($a);
for ($i = 0; $i < $n; ++$i) {
    if ($lcm / $a[$i] % 2 === 0) {
        echo (0) . PHP_EOL;
        exit;
    }
}
$ans = floor((2 * $m + $lcm) / (2 * $lcm));
echo $ans . PHP_EOL;

// 最大公約数（2つ）
function gcd($m, $n)
{
    if (!$n) return $m;
    return gcd($n, $m % $n);
}

// 最大公約数（3つ以上）
function gcdAll($arr)
{
    $gcd = $arr[0];
    for ($i = 0; $i < count($arr); $i++) {
        $gcd = gcd($gcd, $arr[$i]);
    }
    return $gcd;
}

// 最小公倍数（2つ）
function lcm($m, $n)
{
    return $m * $n / gcd($m, $n);
}

// 最小公倍数（3つ以上）
function lcmAll($arr)
{
    $lcm = $arr[0];
    for ($i = 0; $i < count($arr); $i++) {
        $lcm = lcm($lcm, $arr[$i]);
    }
    return $lcm;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	int ans = 1;
	for (int i = 1; i <= N; i++) {
		if (ans > K) {
			ans = ans + K;
		}
		else {
			ans = ans * 2;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
import math
## 素数判定 O (√n)

n = I()
ans = 0
yaku = [1] *(10**7+1)
yaku[0] = 0
yaku[1] = 1
for i in range(1,n+1):
    for j in range(i*2,n+1,i):
        yaku[j] += 1
for i in range(1,n+1):
    y = yaku[i]
    ans += i * y
print(ans)


Measured memory_bytes: 151332
#include <iostream>
#include <string>
using namespace std;
int main(){
		string L("qwertasdfgzxcvb");
		string R("yuiophjklnm");
		string P;
		int fraga =0;
		int fragb =0;
		int left=L.length();
	while(1){
		int counter = 0;
		cin >>P;
		int length = P.length();
		if (P=="#")break;
		for(int i =0;i<length;i++){
			for(int j = 0;j<left;j++){
				if(P[i]==L[j]) {
					fraga=0;
					break;
				}
				else fraga=1;
			}
			if((fraga!=fragb)&&(i!=0)) counter+=1;
			fragb = fraga;
		}
		cout << counter<<endl;


	}


	return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
using namespace std;
typedef long long int llint;
int main() {
	llint n;
	cin >> n;
	llint ans = 0;
	ans += 2 * (n / 11);
	n %= 11;
	if (n == 0) {
	}
	else if (n <= 6) {
		ans += 1;
	}
	else {
		ans += 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a,i,n,max=0,min=0;
	unsigned long sum=0;
	scanf("%d",&n);
	scanf("%d",&a);
	max = a;
	min = a;
	sum = a;
	for(i=2;i<=n;i++){
		scanf("%d ",&a);
		if(max < a) max = a;
		if(min > a) min = a;
		sum += a;
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 604
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=2e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

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

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

int main(){
	fastio;

	int n, q; 
	cin>>n>>q;

	dsu d(n);
	forn(i,q){
		int c; cin>>c;
		int u, v; cin>>u>>v;
		if(c == 0){
			d.merge(u,v);
		}
		else{
			if(d.same(u,v)) cout<<1<<ln;
			else cout<<0<<ln;
		}
	}

	return 0;
}

Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int x[n];
  vector<int>v[m];
  for(int i=0;i<n;i++){
    cin>>x[i];
    v[x[i]%m].push_back(x[i]);
  }
  for(int i=0;i<m;i++)sort(v[i].begin(),v[i].end());
  int ans=0;
  for(int i=0;i<=m/2;i++){
    if(i*2==m||i==0){
      ans+=v[i].size()/2;
    }
    else{
    int t=m-i;
    int is=v[i].size();
    int ts=v[t].size();
    if(is==ts){
      ans+=is;
    }
    else if(is>ts){
      for(int j=0;j<v[i].size()-1;){
        if(v[i][j]==v[i][j+1]){
          ans++;
          is-=2;
          j+=2;
        }
        else j++;
        if(is<=ts)break;
      }
      ans+=min(ts,is);
      
    }
    else if(is<ts){
      for(int j=0;j<v[t].size()-1;){
        if(v[t][j]==v[t][j+1]){
          ans++;
          ts-=2;
          j+=2;
        }
        else j++;
        if(ts<=is)break;
      }
      ans+=min(is,ts);
      
    }
    //cout<<ans<<endl;
    }
  }
  cout<<ans<<endl;
}
      
        
  

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    vec a(3); cin >> a;
    Sort(a);
    Out(a[0] + a[1]);

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7


def main():
    N, K = MAP()
    A = LIST()

    for i in range(K, N):
        if A[i]/A[i-K] > 1.0:
            print("Yes")
        else:
            print("No")
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 94012
#include<iostream>
using namespace std;
int main(){
    while(1){
        int a,b;
        cin>>a>>b;
        if(cin.eof())break;
        int sum=a+b;
        unsigned count=1;
        while(sum/10!=0){
            sum/=10;
            count++;
        }
        cout<<count<<endl;
    }
    return 0;
}


Measured memory_bytes: 3096
def main():
    N = int(input())
    print(solve(N))


def count(n, start, end):
    """n以下の数字でsで始まりeで終わる数字の個数
    732, 1, 2 -> 12, 102, 112, 122, ... , 192 = 11
    Examples:
        >>> count(732, 1, 2)
        11
        >>> count(25, 1, 1)
        2
        >>> count(25, 3, 3)
        1
        >>> count(100, 1, 2)
        1
        >>> count(102, 1, 2)
        2
    """

    if n <= 9:
        return 1 if start == end and start <= n else 0
    if n <= 99:
        one_digit = 1 if start == end else 0
        two_digit = 1 if start * 10 + end <= n else 0
        return one_digit + two_digit
    digit_length = len(str(n))
    # digit_length桁以下
    ret1 = count(10 ** (digit_length - 1) - 1, start, end)
    # digit_length桁
    min_cand = start * (10 ** (digit_length - 1)) + end
    if min_cand > n:
        return ret1
    ret2 = min((n-min_cand) // 10 + 1, 10 ** (digit_length - 2))
    return ret1 + ret2


def solve(n):
    """n以下の組で, (213, 382)のような末尾と先頭が等しい数の個数"""
    result = 0
    for i in range(1, 10):
        for j in range(i + 1, 10):
            result += 2 * count(n, i, j) * count(n, j, i)
    for i in range(1, 10):
        result += count(n, i, i) * count(n, i, i)
    return result


if __name__ == "__main__":
    main()


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

//貰うDPを配るdpにして高速化、で式変形orBITor累積和によってまとめる,式変形はj-1を代入
int n,k;
vector<ll> a;
ll dp[110][100010];


ll modpow(ll a,ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * a%mod;
        a = a*a%mod;
    n >>=1;
    }
    return res;
}
ll modMinus(ll val,ll m){
    ll res = val % m;
    if(res < 0) res += m;
        return res;
}
 ll modAdd(ll &a,ll b){
a += b;
if(a >= MOD) a-= MOD;
return a;
}



int main(){
 cin >> n >> k;
 a.resize(n);
 for(int i = 0; i < n; ++i) cin >> a[i];
 for(int i = 0; i <= n; ++i) dp[i][0] = 1; //i人目までに0個配る方法は1通り

 for(int i = 1; i <= n; ++i){
   for(int j = 1; j <= k; ++j){
     dp[i][j] = (dp[i - 1][j] + dp[i][j - 1])%MOD;
     if(j - a[i - 1] - 1 >= 0){
       dp[i][j] = (dp[i][j] + MOD - dp[i - 1][j - a[i - 1] - 1])%MOD;
     }
   }
 }
 cout << dp[n][k] << endl;
 return 0;
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5&&b==5&&c==7)
    {
        cout<<"YES"<<endl;
    }
    else if(a==5&&b==7&&c==5){
        cout<<"YES"<<endl;
    }
    else if(a==7&&b==5&&c==5){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 3576
<?php
$input_line = trim(fgets(STDIN));
$input_line = explode(' ', $input_line);

$n = $input_line[0];
$a = $input_line[1];
$b = $input_line[2];

$ans_sum = 0;

for ($i = 1; $i <= $n; $i++) {
  $sum = 0;
  $num_strlen = str_split(strval($i));
  foreach ($num_strlen as $v) {
    $sum += intval($v);
  }
  if ($sum >= $a && $sum <= $b) {
    $ans_sum += $i;
  }
}

print $ans_sum;

Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int n;
string s[101];
set<string>se;
void ch(int p){
  string t=s[p],y;
  int x=0;
  while(1)
    if(t[x]==':')break;
    else y+=t[x],x++;
  x++;
  if(se.count(y)||p==0){se.erase(y),y="";
    for(;x<t.size();x++)
      if(t[x]==','||t[x]=='.')se.insert(y),y="";
      else y+=t[x];
  }
}
int main(){
  while(cin>>n,n){
    se.clear();
    r(i,0,n)cin>>s[i];
    ch(0);
    r(i,1,n+2)r(j,1,n)ch(j);
    cout<<se.size()<<endl;
  }
}

Measured memory_bytes: 3112
import java.util.Scanner

import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val r = mutable.ArrayBuffer.fill(n)(sc.nextInt())

    var count = 0

    (0 until n).foreach { i =>
      var minj = i
      (i until n).foreach { j =>
        if (r(minj) > r(j)) minj = j
      }

      if (i != minj) {
        val ri = r(i)
        val rj = r(minj)
        r(i) = rj
        r(minj) = ri
        count += 1
      }
    }

    println(r.mkString(" "))
    println(count)

  }

}



Measured memory_bytes: 45164
a = list(input())
b = list(input())
c = list(input())

l = 'a'
while True:
	if l == 'a':
		if len(a) == 0:
			print('A')
			break
		l = a.pop(0)
	elif l == 'b':
		if len(b) == 0:
			print('B')
			break
		l = b.pop(0)
	else:
		if len(c) == 0:
			print('C')
			break
		l = c.pop(0)



Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
int max_(int x,int y)
{
  return x>y?x:y;
}
main()
{
  int a,b,max;
  scanf("%d %d",&a,&b);
  max=max_(a-b,max_(a+b,a*b));
  printf("%d",max);
}


Measured memory_bytes: 128
#include <iostream>
#include <deque>
#include <algorithm>
#include <vector>

using namespace std;

int n;
deque<int> d;

int main() {
    cin >> n;
    d.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    vector<pair<int,int>> v;
    while (d.size() > 2) {
        int k = d.size();
        if (d[0] <= 0 && d[k-1] >= 0) {
            if (d[1] <= 0) {
                v.push_back({d[k-1],d[0]});
                d[k-1] -= d[0];
                d.pop_front();
            } else {
                v.push_back({d[0],d[k-1]});
                d[0] -= d[k-1];
                d.pop_back();
            }
        } else {
            if (d[k-1] < 0) {
                v.push_back({d[k-1],d[k-2]});
                d[k-2] = d[k-1]-d[k-2];
                d.pop_back();
            } else {
                v.push_back({d[0],d[1]});
                d[1] = d[0]-d[1];
                d.pop_front();
            }
        }
    }
    if (d[0]-d[1] > d[1]-d[0]) {
        v.push_back({d[0],d[1]});
        cout << d[0]-d[1] << "\n";
    } else {
        v.push_back({d[1],d[0]});
        cout << d[1]-d[0] << "\n";
    }
    for (auto x : v) {
        cout << x.first << " " << x.second << "\n";
    }
}

Measured memory_bytes: 3192
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
ll N;
ll a2, a5;

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

  cin >> N;
  if (N%2!=0) {
    cout << 0 << "\n";
    return 0;
  }
  ll wari = 10ll;
  ll ans = 0ll;
  while(wari <= N) {
    ans+=N/wari;
    wari*=5ll;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n;
    cin >> n;
    int d = 0;
    bool ok = true;
    rep(i,n){
        char c;int k;
        cin >> c >> k;
        if(c=='(') d+=k;
        else d-=k;
        if(d < 0) ok = false;
    }
    puts(!ok || d ? "NO" : "YES");
}

Measured memory_bytes: 1108
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int i, n, mi, ma, A;
  int *R;
  while(1){
  scanf("%d", &n);
  if(n >= 2 && n <= 200000)   break;
  }
  R = (int*)malloc(sizeof(int) * n);
  for(i=0; i<n; i++){
    while(1){
      scanf("%d", &R[i]);
      if(R[i]>=1 && R[i]<=1000000000)break;
    }
  }
  mi = R[0];
  ma = R[1] - mi;
  for(i=1 ;i<n; i++){
    if(ma<R[i]-mi)      ma=R[i]-mi;
    if(mi>R[i])         mi=R[i];
  }
  printf("%d\n", ma);
  free(R);
  return 0;
}



Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,k;cin>>n>>k;
    vector<double> a(n);rep(i,n)cin>>a[i];
    double l=0.0;double r=1e9+0.0;double m;ll sum;
    rep(i,100){
        sum=(ll)0;
        m=(l+r)/2;
        rep(i,n)sum+=(ll)ceil(a[i]/m)-(ll)1;
        if(sum>k)l=m;
        else r=m;
    }
    ll ans=(ll)ceil(r);
    cout<<ans<<endl;
}

Measured memory_bytes: 4748
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for (int i = m; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int k, x;
    cin >> k >> x;
    
    vector<int> v;
    rep2 (i, x-k+1, x + k-1+1) {
        if (-1000000 <= i && i <= 1000000) {
            v.push_back(i);
        }
    }
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? "" : " ");
    cout << endl;

    return 0;
}

Measured memory_bytes: 3572
using System;

namespace ABC128_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int m = 0;
            int n = 0;
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int p = int.Parse(array[1]);
            m = a * 3 + p;
            n = m / 2;
                Console.WriteLine(n);
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;cin>>n;
    vector <int> N(n+1),Q(n+1);
    for(int i=1;i<=n;i++) cin>>N[i];
    int sm=0;
    for(int i=1;i<=n;i++) sm+=N[i],Q[i]=sm;
    int sum=0;
    for(int i=1;i<n;i++)
    {
        sum= ( sum+ ( N[i] * ((Q[n]-Q[i])%mod) ) %mod )%mod;
    }
    cout<<sum<<endl;
    return 0;
}
/*


*/



Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
 
#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
 #define PI acos(-1)
 #define MOD ((int)1e9+7)
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-
 
 

 
const int N=2e5+100;
ll visited[100005];
//ll a[200000];
 

#define lop(i,n) for(int i=0;i<n;++i)
//ll n,m,mod;

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

const int MAX = 2e5 + 10 ;
void finis(){cout<<-1;}


int main()
{  ios::sync_with_stdio(0);
    cin.tie(0);
ll ans=0;
  ll n,k;
     cin>>n>>k;ll a[n];
     for(int i=0;i<n;i++){cin>>a[i];}
     sort(a,a+n);
     for(int i=0;i<k;i++){ans+=a[i];}
 cout<<ans;
 
    
 
 
 
}


Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include <sstream>


using namespace std;

int main()
{
  int n;
  cin>>n;
  for(;n--;)
    {
      string s1;
      cin>>s1;
      string s2=s1;
      for(int i=0;i<s1.size();i++)
	for(int j=0;j<s1.size();j++)
	  {
	    if(s1[i]<s1[j])
	      {
		char a;
		a=s1[i];
		s1[i]=s1[j];
		s1[j]=a;
	      }
	    if(s2[i]>s2[j])
	      {
		char a;
		a=s2[i];
		s2[i]=s2[j];
		s2[j]=a;
	      }
	  }
      stringstream istr(s1);
      int i,j;
      istr >>i;
      istr.clear();
      istr.str(s2);
      istr>>j;
      //      cout<<s1<<endl;
      //  cout<<s2<<endl;
      cout<<j-i<<endl;
    }
  
}

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

int main() {
	int N, AC = 0, WA = 0, TLE = 0, RE = 0;
	scanf("%d", &N);
	
	for(int i = 0; i < N; i++) {
		char str[10];
		scanf("%s", str);
		
		if(strcmp(str, "AC") == 0) {
			AC++;
		} else if(strcmp(str, "WA") == 0){
			WA++;
		} else if(strcmp(str, "TLE") == 0){
			TLE++;
		} else if(strcmp(str, "RE") == 0) {
			RE++;
		}
	}
	
	printf("AC x %d\n", AC);
	printf("WA x %d\n", WA);
	printf("TLE x %d\n", TLE);
	printf("RE x %d\n", RE);
	return 0;
}

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

int main()
{
    int N;
    int A[100005];
    vector < int > data;
    int cnt = 0;
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(i > 0 && A[i] == A[i - 1]) {
            data.push_back(cnt);
            cnt = 1;
        } else {
            cnt++;
        }
    }
    data.push_back(cnt);
    int maxv = 0;
    int sum = 0;
    for(int i = 0; i < data.size(); i++) {
        sum += data[i];
        if(i >= 3) sum -= data[i - 3];
        maxv = max(maxv, sum);
    }
    cout << maxv << endl;
    return (0);
}


Measured memory_bytes: 3544
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007

class UnionFind
{
private:
	vector<int> v;

public:
	UnionFind(int n)
	{
		v = vector<int>(n, -1);
	}

	int getparent(int x)
	{
		if(v[x] == -1) return x;
		return v[x] = getparent(v[x]);
	}

	bool add(int x, int y)
	{
		x = getparent(x);
		y = getparent(y);
		if(x == y) return false;
		if(x > y) swap(x, y);
		v[y] = x;
		return true;
	}
};

int main()
{
	int n;
	cin >> n;
	map<int, vector<int> > m[2];
	for(int i = 0; i < n; i++){
		int tmpx, tmpy;
		cin >> tmpx >> tmpy;
		if(m[0].find(tmpx) == m[0].end()) m[0][tmpx] = vector<int>();
		m[0][tmpx].push_back(i);
		if(m[1].find(tmpy) == m[1].end()) m[1][tmpy] = vector<int>();
		m[1][tmpy].push_back(i);
	}
	priority_queue<pair<int, pair<pair<int, int>, int> > > qu;
	for(int j = 0; j < 2; j++){
		for(auto i = m[j].begin(); i != m[j].end(); i++){
			qu.push(make_pair(0, make_pair(make_pair((*i).first, (*i).first), j)));
			auto tmp = i;
			tmp++;
			if(tmp == m[j].end()) break;
			int kyori = (*i).first - (*tmp).first;
			qu.push(make_pair(kyori, make_pair(make_pair((*i).first, (*tmp).first), j)));
		}
	}
	UnionFind uf(n);
	long long int ans = 0;
	while(!qu.empty()){
		int cost = -(qu.top()).first;
		int tmp1 = (((qu.top()).second).first).first;
		int tmp2 = (((qu.top()).second).first).second;
		int isx = ((qu.top()).second).second;
		qu.pop();
		int node1, node2;
		node1 = m[isx][tmp1][0];
		for(int i = 0; i < m[isx][tmp2].size(); i++){
			node2 = m[isx][tmp2][i];
			if(uf.add(node1, node2)) ans += cost;
		}
		node2 = m[isx][tmp2][0];
		for(int i = 0; i < m[isx][tmp1].size(); i++){
			node1 = m[isx][tmp1][i];
			if(uf.add(node1, node2)) ans += cost;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 32492
//# define FLAG
///delet....................................
# include <iostream>
# include <cstring>
# include <cstdlib>
# include <cstdio>
# include <string>
# include <cmath>
# include <ctime>
# include <set>
# include <map>
# include <queue>
# include <stack>
# include <bitset>
# include <vector>
# include <fstream>
# include <algorithm>
using namespace std;
# define eps 1e-8
# define pb push_back
# define pi acos(-1.0)
# define bug puts("H");
# define mem(a,b) memset(a,b,sizeof(a))
# define IOS ios::sync_with_stdio(false);
# define FO(i,n,a) for(int i=n; i>=a; --i)
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define INF 0x3f3f3f3f
# define MOD 1000000007
///           123456789
//# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef unsigned long long ULL;
typedef long long LL;
inline int Scan(){
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
///coding...................................

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

int main()
{
    IOS;
#ifdef FLAG
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif /// FLAG
    int t;
    LL num,c;
    cin>>t>>num;
    FOR(i,2,t) {
        cin>>c;
        num=num/gcd(num,c)*c;
    }
    cout<<num<<endl;
    return 0;
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int d;
	while(~getI(d)){
		if(d==25) puts("Christmas");
		else if(d==24) puts("Christmas Eve");
		else if(d==23) puts("Christmas Eve Eve");
		else puts("Christmas Eve Eve Eve");
	}
}


Measured memory_bytes: 256
# input
n, k = map(int, input().split())
X = list(map(int, input().split()))

# 飛び飛びで塗ることはない -> X[i] ~ X[i + k - 1] を全て塗る
# i = 1, ..., n - k + 1 について所要時間を調べる
# 原点 -> X[i] -> X[i + k - 1] or 原点 -> X[i + k - 1] -> X[i]
D = []
for i in range(n - k + 1):
    t1 = abs(X[i]) + (X[i + k - 1] - X[i])
    t2 = abs(X[i + k - 1]) + (X[i + k - 1] - X[i])
    D.append(min(t1, t2))

print(min(D))


Measured memory_bytes: 14380
#include <iostream>
#include <string>

using namespace std;

string s, t;
int a, b;
string u;

int main(){
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if ( u == s) {
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }
   return 0;
}

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

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

  if(a == b) {
    cout << 1 << endl;
    return 0;
  }

  int r = 60;
  ll one = 1;
  while((a & (one << (r-1))) == (b & (one << (r-1)))) r--;

  a &= (one << r) - 1;
  b &= (one << r) - 1;

  ans = (one << r) - a;

  int k = r - 1;
  while(k > 0 && !(b & (one << (k-1)))) k--;

  if(a > (one << k)) ans -= a - (one << k);

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


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

int n, a[N];

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i)
        scanf("%d", a + i);
    bool check = 0;
    if (a[1] > 0) check = 1;
    for (int i = 2; i <= n; ++i)
        if (a[i] - a[i - 1] > 1) check = 1;
    long long ans = 0;
    if (check) puts("-1");
    else {
        for (int i = 2; i <= n; ++i)
            if (a[i] == a[i - 1] + 1) ++ans;
            else ans += a[i];
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

L = [0]*26

v = 0
ans = [0]*D
import copy
for i in range(1, D+1):
    max_score = v
    max_idx = 0
    for j in range(26):
        temp = v
        temp += S[i-1][j]
        L_ = copy.copy(L)
        L_[j] = i
        for k in range(26):
            temp -= C[j]*(i-L_[k])
        if temp >= max_score:
            max_score = temp
            max_idx = j
    v = max_score
    ans[i-1] = max_idx+1
print(*ans, sep='\n')


Measured memory_bytes: 74756
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#include<string.h>
int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);                    
    cout.tie(NULL);
   	ll n,m,k,cnt=0;
   	cin>>n>>m>>k;
   	ll arr[n+1],brr[m+1],suma[n+1],sumb[m+1];
   	suma[0]=0;
   	sumb[0]=0;
   	for(int i=1;i<=n;i++) {
   		cin>>arr[i];
   		if(i>0)suma[i]=arr[i]+suma[i-1];
   	}
   	for(int j=1;j<=m;j++){
   	 cin>>brr[j];
   	 if(j>0)sumb[j]=brr[j]+sumb[j-1];
   	}
   	ll min,max,mid,ans=0;
   	ll i=1;
   	for(i=1;i<=n;i++){
   		min=1;
   		max=m;
   		mid;
   		if(min==max){
   			if(suma[i]+sumb[min]<=k) ans=(ans<(i+min)?i+min:ans);
   			//if(suma[i]+sumb[max]<=k) ans=(ans<(i+max)?i+max:ans);
   			if(suma[i]<=k) ans=(ans<(i)?i:ans);
   		}
   		else{
   			while((min+1)!=max){
   				mid=(min+max)/2;
   				if(suma[i]+sumb[mid]>=k) max=mid;
   				else min=mid;
   			}
   			if(suma[i]+sumb[min]<=k) ans=(ans<(i+min)?i+min:ans);
   			if(suma[i]+sumb[max]<=k) ans=(ans<(i+max)?i+max:ans);
   			
   		}
   		
   		if(suma[i]>=k) break;
   	}
   	for(i=1;i<=n;i++) if(suma[i]>k) break;
   	if(i>n) ans=(ans<(n)?n:ans);
   else ans=(ans<(i-1)?(i-1):ans);
   	for(i=1;i<=m;i++) if(sumb[i]>k)break; 
   	if(i>m) ans=(ans<(m)?m:ans);
   	else  ans=(ans<(i-1)?i-1:ans);
   	cout<<ans;
   	return 0; 
}

Measured memory_bytes: 9884
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int X, A, B;
    scanf("%d %d %d", &X, &A, &B);
    int sum1 = abs(X - A);
    int sum2 = abs(X - B);
    if(sum1 < sum2){
        printf("A\n");
    }
  if(sum2 < sum1){
    printf("B\n");
  }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

// Returns LCM of array elements 
ll findlcm(ll arr[], ll N) 
{ 
    // Initialize result 
    ll ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < N; i++) 
        ans = (((arr[i] * ans)) / 
                (__gcd(arr[i], ans))); 
  
    return ans; 
}

ll cnt[200020];

int main() {
  ll n,m;
  cin >> n >> m;
  ll a[n];
  rep(i,n){
    cin >> a[i];
    a[i]/=2;
    ll temp=a[i];
    while(temp%2==0){
      temp/=2;
      cnt[i]++;
    }
  }
  ll mini=longinf,maxi=-longinf;
  rep(i,n){
    mini=min(mini,cnt[i]);
    maxi=max(maxi,cnt[i]);
  }
  if(mini!=maxi){
    cout << 0 << endl;
    return 0;
  }
  cout << (m/findlcm(a,n)+1)/2 << endl;
return 0;}

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

using namespace std;

void solve() {
    double a, b, x;
    cin >> a >> b >> x;
    double l;
    l = 2 * x / a / b;
    double t, ans;
    if (l <= a)
    {
        t = b / l;
    }
    else
    {
        t = (2 * a * a * b - 2 * x) / a / a / a;
    }
    ans = atan(t) * 180 / M_PI;
    cout << fixed << setprecision(15)<< ans << endl;
}

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

Measured memory_bytes: 4084
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
let sp = input.split("\n");
for( let i = 0; sp[i] !== "0 0"; i++ ) {
  let hw = sp[i].split(" ").map(Number);
  let h = hw[0]; w = hw[1];
  for( let hh = 0; hh < h; hh++ ) {
    let row = "";
    for( let ww = 0; ww < w; ww++ ) {
      row += "#";
    }
    console.log(row);
  }
  console.log();
}

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

#define ll long long
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
    int N,M;
    cin >> N >> M;
    int d[150];
    for(int i=0;i<2*M;i++){
        cin >> d[i];
    }
    
    int num[150] = {0};
    for(int i=0;i<2*M;i++){
        num[d[i]]++;
    }
    
    for(int i=1;i<=N;i++){
         cout << num[i] <<endl;
    }
    
   
}

Measured memory_bytes: 256