akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
int N,M;
vector<int>G[1000];
vector<int>id;
int used[1000];
bool dfs(int u,int d)
{
	used[u]=d;
	for(int v:G[u])
	{
		if(used[v]||dfs(v,d+1))return true;
	}
	used[u]=0;
	return false;
}
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int u,v;cin>>u>>v;
		u--,v--;
		G[u].push_back(v);
	}
	for(int i=0;i<N;i++)id.push_back(i);
	bool flag=false;
	int ps;
	for(int i:id)
	{
		if(dfs(i,1))
		{
			flag=true;
			ps=i;
			break;
		}
	}
	if(!flag)
	{
		cout<<-1<<endl;
		return 0;
	}
	while(true)
	{
		vector<int>nxtid;
		for(int i:id)
		{
			if(used[i])
			{
				nxtid.push_back(i);
				vector<int>nxt;
				for(int v:G[i])if(used[v])nxt.push_back(v);
				G[i]=nxt;
			}
		}
		id=nxtid;
		int s=-1,t;
		for(int i:id)
		{
			for(int v:G[i])
			{
				if(used[i]+1!=used[v]&&v!=ps)
				{
					s=i;
					t=v;
					break;
				}
			}
			if(s>=0)break;
		}
		if(s<0)
		{
			cout<<id.size()<<endl;
			for(int i:id)cout<<i+1<<endl;
			return 0;
		}
		for(int i:id)used[i]=0;
		used[s]=1;
		dfs(t,2);
		ps=s;
	}
}

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

int main(){
	int n;
	ll power = 1;
	ll large = 1000000007;
	cin >> n;
	for(int i = 1; i <=n; i++){
		power = power*i%large;
	}
	cout << power << endl;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cassert>
#include <iostream>
#include <stdio.h>
#include <time.h>
 
using namespace std;

typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
 
#define MOD 998244353

#define N_MAX (1<<19)

struct segsum{
  long long nn;
  long long dat1[(2 * N_MAX) - 1];
  long long dat2[(2 * N_MAX) - 1];

  void init(long long n1){
    nn = 1;

    while(nn < n1)nn *= 2;

    for(long long i = 0; i < 2 * nn - 1; i++){
      dat1[i] = 0;
      dat2[i] = 0;
    }
  }

  void add(long long a, long long b, long long x, long long k, long long l, long long r) {
    x %= MOD;
    if (a <= l && r <= b) {
      dat1[k] += x;
      dat1[k] %= MOD;
    }
    else if (l < b && a < r) {
      dat2[k] += (min(b, r) - max(a, l)) * x;
      dat2[k] %= MOD;
      add(a, b, x, k * 2 + 1, l, (l + r) / 2);
      add(a, b, x, k * 2 + 2, (l + r) / 2, r);
    }
  }

  long long sum(long long a, long long b, long long k, long long l, long long r){
    if (b <= l || r <= a)return 0LL;
    else if (a <= l && r <= b) {
      return (dat1[k] * (r - l) + dat2[k])%MOD;
    }
    else {
      long long ret;
      ret = (min(b, r) - max(a, l)) * dat1[k];
      ret %= MOD;
      ret += sum(a, b, k * 2 + 1, l, (l + r) / 2);
      ret += sum(a, b, k * 2 + 2, (l + r) / 2, r);
      return ret%MOD;
    }
  }

  void add(long long a, long long b, long long x){
    add(a, b, x, 0, 0, nn);
  }

  long long sum(long long a, long long b){
    return sum(a,b,0,0,nn);
  }
}segsum1;


int main(){
  segsum1.init(400100);
  ll n,k;
  cin>>n>>k;
  vector<pair<ll,ll> > vp;
  rep(i,0,k){
    ll a,b;
    cin>>a>>b;
    vp.pb(mp(a,b));
  }
  segsum1.add(10,10+1,1);
  rep(i,0,n){
    ll a = segsum1.sum(i+10,i+10+1);
    a %= MOD;
    rep(j,0,vp.sz){
      ll l = i+vp[j].fi;
      ll r = i+vp[j].se;
      segsum1.add(l+10,r+10+1,a);
    }
  }
  cout << (segsum1.sum(10+n-1,10+n))%MOD << endl;
  return 0;
}

Measured memory_bytes: 20016
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        UnionFind uf = new UnionFind(N);
        for (int i = 0; i < M; i++) {
            int A = scan.nextInt()-1;
            int B = scan.nextInt()-1;
            uf.unite(A, B);
        }
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < N; i++) {
            set.add(uf.parent(i));
        }
        System.out.println(set.size() - 1); 
    }
    class UnionFind {
        int[] parent;
        int[] size;
        UnionFind(int N) {
            int[] parent = new int[N]; 
            int[] size = new int[N];
            Arrays.fill(size, 1);
            for (int i = 0; i < N; i++) {
                parent[i] = i;
            }
            this.size = size;
            this.parent = parent;
        }
        int parent(int x) {
            if (this.parent[x] == x) {
                return x;
            }
            return this.parent[x] = this.parent(this.parent[x]);
        }
        void unite(int x, int y) {
            int px = this.parent(x);
            int py = this.parent(y);
            if (px == py) {
                return;
            }
            int sx = this.size[px];
            int sy = this.size[py];
            if (sx < sy) {
                this.size[py] += this.size[px];
                this.size[px] = 0;
                this.parent[px] = py;
                return;
            }
            this.size[px] += this.size[py];
            this.size[py] = 0;
            this.parent[py] = px;
        }
    }
}


Measured memory_bytes: 60188
#include<bits/stdc++.h>
using namespace std;
typedef string::const_iterator State;
class ParseError{};

int expr(State& begin);
int term(State& begin);
int number(State& begin);
int fact(State& begin);

int number(State& begin){
    int res = 0;
    while(isdigit(*begin)){
        res *= 10;
        res += *begin - '0';
        begin++;
    }
    return res;
}

int term(State& begin){
    int res = fact(begin);
    while(true){
        if(*begin == '*'){
            begin++;
            res *= fact(begin);
        }else if(*begin == '/'){
            begin++;
            res /= fact(begin);
        }else{
            break;
        }
    }
    return res;
}

int expr(State& begin){
    int res = term(begin);
    while(true){
        if(*begin == '+'){
            begin++;
            res += term(begin);
        }else if(*begin == '-'){
            begin++;
            res -= term(begin);
        }else{
            break;
        }
    }
    return res;
}

int fact(State& begin){
    if(*begin == '('){
        begin++;
        int res = expr(begin);
        begin++;
        return res;
    }
    return number(begin);
}

int main(){
    int n;
    cin >> n;
    for(int i = 0;i < n;i++){
        string s;
        cin >> s;
        s = s.substr(0,s.size()-1);
        State begin = s.begin();
        cout << expr(begin) << endl;
    }
}


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


int main(int argc, char const *argv[])
{
    int A;
    int B;
    char op;
    cin>>A>>op>>B;
    int C=A+B;
    int D=A-B;

    if (op=='+') {
        cout<<C;
    }
    else
    {
        cout<<D;
    }
    
    

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N = int(input())
    a_list = list(sorted(list(map(int, input().split()))))
    print(sum([a_list[-i * 2 - 2] for i in range(0, N)]))


if __name__ == '__main__':
    main()


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

int main() {
	int a, b, c, x, ans = 0;
	std::cin >> a >> b >> c >> x;
	for (int i = 0; i <= a; ++i) {
		for (int j = 0; j <= b; ++j) {
			for (int k = 0; k <= c; ++k) {
				if (x == 500 * i + 100 * j + 50 * k) { ans += 1; }
			}
		}
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
void printhoge(set<int> v) {
	ALL(it, v) {
		cout << *it << " ";
	}
	cout << endl;

}



int main() {
	int n, m, q;
	cin >> n >> m >> q;
	vector<vector<int>> dp(501, vector<int>(501));
	vector<vector<int>> ruiseki(501, vector<int>(501));
	rep(i, 501)
		rep(k, 501)
		dp[i][k] = 0;

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		dp[a][b]++;
	}

	rep(i, 501) {
		int tmp = 0;
		rep(k, 501) {
			tmp += dp[i][k];
			ruiseki[i][k] = tmp;
		}
	}

	rep(i, q) {
		int l, r;
		cin >> l >> r;
		int result = 0;
		For(k, l, 501) {
			result += ruiseki[k][r] - ruiseki[k][l - 1];
		}
		cout << result << endl;
	}
	return 0;

}



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

int main(){
  int N,W;
  cin >> N >> W;
  int v[N],w[N];
  for(int i=0; i<N; i++)
    cin >> v[i] >> w[i];

  int DP[N+1][W+1];

  for(int j=0; j<=W; j++)
    DP[0][j] = 0;

  for (int i=1; i<=N; i++)
    for(int j=0; j<=W; j++)
      if(j<w[i-1])
        DP[i][j] = DP[i-1][j];
      else{
        if(DP[i-1][j]>DP[i][j-w[i-1]]+v[i-1])
          DP[i][j] = DP[i-1][j];
        else
          DP[i][j] = DP[i][j-w[i-1]]+v[i-1];
      }

  cout << DP[N][W] << endl;
  return 0;
}



Measured memory_bytes: 7024
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < N; ++i) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            ans += (r - l + 1);
        }
        _out.println(ans);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 23892
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f3f;
const int maxn = 1e5+500;
ll T,n,m;
vector<ll> num(maxn);
vector<double> t(maxn);
priority_queue<double, vector<double>, greater<double>> q;
int main() {
   cin>>n;
   for(int i=0;i<n;i++){
   	cin>>num[i];
   	q.push(num[i]);
   }
   while(!q.empty()){
   		double t1 = q.top();
   		q.pop();
   		if(q.empty()){
   			printf("%.6f\n",t1);
   			return 0;
		}
		else {
			double t2 = q.top();
			q.pop();
			q.push((t1+t2)/2.0);
		}
   }
}



Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;

int h,w,n;
char board[1005][1005];
int x[10],y[10];
bool check(int i, int j) {
	return (i >= 1) && (i <= h) && (j >= 1) && (j <= w) && (board[i][j] == '.');
}
int d[1005][1005];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(void){
    int n,a,b;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    int num = 0,numb=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='a'){
            if(num<a+b){
                cout<<"Yes"<<endl;
                num++;
            }
            else cout<<"No"<<endl;
        }
        else{
            if(s[i]=='c')cout<<"No"<<endl;
            else{
                if(num<a+b){
                    if(numb<b){
                        cout<<"Yes"<<endl;
                        numb++;
                        num++;
                    }
                    else cout<<"No"<<endl;
                }
                else cout<<"No"<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 896
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from decimal import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

a,b,c = list(map(int, stdin.readline().rstrip().split()))
getcontext().prec = 100
aa = Decimal(a).sqrt()
bb = Decimal(b).sqrt()
cc = Decimal(c).sqrt()
# print(a,b,c)
if(a + b + 2*aa*bb < c):
	print('Yes')
else:
	print('No')


Measured memory_bytes: 5624
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

const int f=40;
int main (){
    long long n,k;
    int onecnt[f] = {}, zerocnt[f] = {};
    cin >> n >> k;
    for(int i=0;i<(int)n;i++){
        long long buf;
        cin >> buf;
        for(int j=0;j<f;j++){
            if(buf&1){
                onecnt[j]++;
            } else {
                zerocnt[j]++;
            }
            buf >>= 1;
        }
    }
    long long tmp=0;
    long long ans=0;
    for(int i=f-1;i>=-1;i--){
        if(i>=0&&!(k&(1LL<<i))){
            continue;
        }
        tmp=0;
        for(int j=0;j<f;j++){
            long long e = 1LL << j;
            if(j<i){
                tmp += e * max(onecnt[j], zerocnt[j]);
            } else if(j==i){
                tmp += e * onecnt[j];
            } else {
                if(k&e){
                    tmp += e * zerocnt[j];
                } else {
                    tmp += e * onecnt[j];
                }
            }
        }
        ans = max(ans,tmp);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 数値
		String s = sc.next();
		boolean ok = false;
		if (s.equals((new StringBuilder(s).reverse()).toString())) {

			String ss = s.substring(0, (s.length() - 1) / 2);
			if (ss.equals((new StringBuilder(ss).reverse()).toString())) {
				String sss = s.substring((s.length() + 3) / 2 - 1, s.length());
				if (sss.equals((new StringBuilder(sss).reverse()).toString())) {
					ok = true;
				}
			}
		}
		if (ok) {
			out("Yes");
		} else {
			out("No");
		}

	}

	/*
	 * 以下メソッド集
	 */

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

}


Measured memory_bytes: 22996
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func stdioText(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

func stdioNum(s *bufio.Scanner) int {
	num, _ := strconv.Atoi(stdioText(s))
	return num
}

func stdioNums(s *bufio.Scanner) []int {
	var nums []int
	for _, v := range strings.Split(stdioText(s), " ") {
		i, _ := strconv.Atoi(v)
		nums = append(nums, i)
	}
	return nums
}

func a()  {
	s := bufio.NewScanner(os.Stdin)
	nums := stdioNums(s)
	fmt.Println(nums[2] / nums[0] * nums[1])
}

func b() {
	s := bufio.NewScanner(os.Stdin)
	num := stdioNum(s)
	gems := stdioNums(s)
	cost := stdioNums(s)

	max := 0
	for i := 0; i < num; i++ {
		if gems[i] > cost[i] {
			max += gems[i] - cost[i]
		}
	}

	fmt.Println(max)
}

func main() {
	//a()
	b()
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<tuple>
#include<algorithm>
using namespace std;
string S; tuple<int, int, int>dp[2100][2100];
int solve(int s, int t) {
	if (s > t)return 0;
	if (get<0>(dp[s][t]) != -1)return get<0>(dp[s][t]);
	if (s == t) { dp[s][t] = make_tuple(1, -1, -1); return 1; }
	if (t - s == 1) {
		if (S[s] == S[t]) { dp[s][t] = make_tuple(2, -1, -1); return 2; }
	}
	int c1 = solve(s, t - 1);
	int c2 = solve(s + 1, t);
	int c3 = solve(s + 1, t - 1); if (S[s] == S[t])c3 += 2;
	if (c1 >= c2 && c1 >= c3) { dp[s][t] = make_tuple(c1, s, t - 1); return c1; }
	if (c2 >= c1 && c2 >= c3) { dp[s][t] = make_tuple(c2, s + 1, t); return c2; }
	if (c3 >= c1 && c3 >= c2) { dp[s][t] = make_tuple(c3, s + 1, t - 1); return c3; }
}
int main() {
	while (cin >> S) {
		for (int i = 0; i < S.size(); i++) { for (int j = 0; j < S.size(); j++)dp[i][j] = make_tuple(-1, 0, 0); }
		solve(0, S.size() - 1);
		string V, W; int F = 0, G = S.size() - 1;
		while (F + G >= 0) {
			int H = get<1>(dp[F][G]), I = get<2>(dp[F][G]);
			if (H == -1 || ((H - F) + (G - I)) == 2) {
				V += S[F]; if (F != G)W += S[F];
			}
			F = H; G = I;
		}
		reverse(W.begin(), W.end());
		cout << V + W << endl;
	}
	return 0;
}

Measured memory_bytes: 52512
#include <iostream>
#include <iomanip>

constexpr auto PI = 3.14159'26535'89793'23846'26433'83279'5028;

int main()
{
    int R;
    std::cin >> R;

    std::cout << std::setprecision(10) << 2 * R * PI << std::endl;

    return 0;
}

Measured memory_bytes: 3780
import numpy as np

N = int(input())
a_list = list(map(int, input().split()))

ans = 0
now_number = 1

for i in range(N):
  if a_list[i]!= now_number:
    ans += 1
  else:
    now_number += 1
    
if ans == N:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 34072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

int main() {
    ll A, B, C, D;  cin >> A >> B >> C >> D;

    ll rc = B / C - (A-1) / C;
    ll rd = B / D - (A-1) / D;
    ll rcd = B / __lcm(C, D) - (A-1) / __lcm(C, D);

    print(B - A + 1 - (rc + rd - rcd));
}


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

int main() {
  string S,T;
  int A=0;
  cin>>S>>T;
  rep(i,S.size()){if(S.at(i)==T.at(i)){A++;}}
  cout<<S.size()-A<<endl;
}


Measured memory_bytes: 3912
n=int(input())
t,a=map(int,input().split())
H=list(map(int,input().split()))
dif=9999
ans=0
for i in range(n):
  tmp=abs(a-(t-0.006*H[i]))
  if tmp<dif:
    dif=tmp
    ans=i+1
print(ans)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

int ans=9;
map<vector<int>,int> memo;

void make(vector<int> &a,int d){
	const int n=a.size();
	
	if(memo.find(a)==end(memo)) memo[a]=d;
	chmin(memo[a],d);

	if(d==4) return;
	rep(j,n)rep(i,j){
		reverse(begin(a)+i,begin(a)+j+1);
		make(a,d+1);
		reverse(begin(a)+i,begin(a)+j+1);
	}
}


void dfs(vector<int> &a,int d){
	const int n=a.size();
	if(memo.find(a)!=end(memo)) chmin(ans,d+memo[a]);

	if(d==4) return;
	rep(j,n)rep(i,j){
		reverse(begin(a)+i,begin(a)+j+1);
		dfs(a,d+1);
		reverse(begin(a)+i,begin(a)+j+1);
	}
}



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

	vector<int> in(n);	
	rep(i,n) cin >> in[i];
	make(in,0);

	vector<int> init(n);
	iota(begin(init),end(init),1);
	dfs(init,0);

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

Measured memory_bytes: 34968
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s, t;
    for(int i = 0; i < n; i++)
    {
        cin >> s >> t;
        int dp[1100][1100] = {};
        for(int i = 0; i < s.size(); i++)
        {
            for(int j = 0; j < t.size(); j++)
            {
                if(s[i] == t[j])
                {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                }
                else 
                {
                    dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
                }
            }
        }
        cout << dp[s.size()][t.size()] << endl;
    }
	return 0;
}




Measured memory_bytes: 7956
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n, k;
	cin >> n >> k;
	map<pair<long long int, long long int>, int> m;
	vector<long long int> x, y;
	for(int i = 0; i < n; i++){
		long long int a, b;
		cin >> a >> b;
		m[make_pair(a, b)] = 1;
		x.push_back(a);
		y.push_back(b);
	}
	x.push_back(-mod);
	y.push_back(-mod);
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	int cnt[60][60] = {};
	for(int i = 1; i < x.size(); i++){
		for(int j = 1; j < y.size(); j++){
			cnt[i][j] = cnt[i][j - 1] + cnt[i - 1][j] - cnt[i - 1][j - 1];
			if(m.find(make_pair(x[i], y[j])) != m.end()) cnt[i][j]++;
		}
	}
	long long int ans = (long long int)4 * mod * mod;
	for(int i = 1; i < x.size(); i++){
		for(int j = 1; j < y.size(); j++){
			for(int p = i + 1; p < x.size(); p++){
				for(int q = j + 1; q < y.size(); q++){
					if(cnt[p][q] - cnt[i - 1][q] - cnt[p][j - 1] + cnt[i - 1][j - 1] < k) continue;
					ans = min(ans, (x[p] - x[i]) * (y[q] - y[j]));
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
long long const mod = 1000000007;
long long mod_fact(int x){
    static vector<long long> fact = {1, 1};
    if(x < 0)return 0; //
    if(x < fact.size())return fact[x];
    for(int i = fact.size(); i <= x; i++){
        fact.push_back((fact[i-1] * i) % mod);
    }
    return fact[x];
}

long long mod_Montmort_number(int x){
    static vector<long long> mont = {1, 0};
    if(x < 0)return 0; //
    if(x < mont.size())return mont[x];
    for(int i = mont.size(); i <= x; i++){
        mont.push_back(((i-1) * (mont[i-1] + mont[i-2])) % mod);
        //mont.push_back((i * mont[i-1] + ((i%2 == 0) ? 1 : -1)) % mod);
    }
    return mont[x];
}

long long mod_pow(long long a, long long b){
    long long res = 1;
    a %= mod;
    while(b > 0){
        if(b%2 == 1) res = (res * a) % mod;
        a = (a * a) % mod;
        b /= 2;
    }
    return res;
}

long long mod_inv(long long a){
    return mod_pow(a, mod-2);
}

long long mod_comb(int a, int b){
    if(b < 0 || a < b)return 0;
    if(b > a/2)return mod_comb(a, a-b);
    return (((mod_fact(a) * mod_inv(mod_fact(a-b))) % mod) * mod_inv(mod_fact(b))) % mod;
}
/*
long long mod_comb(long long a, long long b){
    if(b < 0 || a < b)return 0;
    if(b > a/2)return mod_comb(a, a-b);
    long long res = 1;
    for(long long i = 0; i < b; i++){
        res = (res * ((a-i)%mod)) % mod;
        res = (res * mod_inv(b-i)) % mod;
    }
    return res;
}
*/
int main(void){
    int n, k;
    cin >> n >> k;
    if(k == 1){
        // XD
    }
    k = min(k, n-1);
    long long ans = 0;
    for(int z=0;z<=k;z++){
        long long t = mod_comb(n, z) * mod_comb(n-1, z);
        ans += t%mod;
    }
    cout << ans%mod << endl;
}


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

int main(){
    int A,B,C,N;
    cin >> A >> B;
  C = 1;
  N = 0;
 if (B == 1){
 cout << 0 << endl;
 }
  else if (B <= A){
  cout << 1 << endl;
  }
  else if(B > A) {while (C < 21){
    
  N = A + (A-1) * (C-1);
    
  if(B <= N){
    cout << C << endl;
    break;
  }
    C++;
}
                  }  
}


Measured memory_bytes: 3592
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> num(N);
  
  for(int i = 1; i < N; i++){
    int A;
    cin >> A;
    num[A-1]++;
  }
  
  for(int i = 0; i < N; i++)
    cout << num[i] << endl;
  
  return 0;
  
}

Measured memory_bytes: 4036
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    int a, b, c;
    a = z;
    b = x;
    c = y;
    cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define N 100005
set<int>s[N];
map<int,int>mat[N];
queue<pair<int,int> >q;
int n,x,y,ans,f[N];
int find(int k){
	if (k==f[k])return k;
	return f[k]=find(f[k]);
}
void add(int x,int y){
	s[x].insert(y);
	s[y].insert(x);
	if (x>y)swap(x,y);
	if (++mat[x][y]==2){
		q.push(make_pair(x,y));
		mat[x][y]=0;
	}
}
void merge(int x,int y){
	if (s[x].size()>s[y].size())swap(x,y);
	f[x]=y;
	for(set<int>::iterator it=s[x].begin();it!=s[x].end();it++){
		int z=find(*it);
		if (y==z)continue;
		add(y,z);
		s[z].erase(x);
	}
	s[x].clear();
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)f[i]=i;
	for(int i=1;i<2*n-1;i++){
		scanf("%d%d",&x,&y);
		add(x,y);
	}
	while (!q.empty()){
		ans++;
		merge(find(q.front().first),find(q.front().second));
		q.pop();
	}
	if (ans==n-1)printf("YES");
	else printf("NO");
}

Measured memory_bytes: 38400
fn main(){
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let n = s.trim().parse::<u32>().unwrap();
	let mut c = 0;
	for i in 0..n as usize {
		let mut s = String::new();
		std::io::stdin().read_line(&mut s).unwrap();
		let vec: Vec<&str> = s.trim().split(' ').collect();
		c += vec[1].parse::<i32>().unwrap() - vec[0].parse::<i32>().unwrap() + 1;
	}
	println!("{}", c);
}


Measured memory_bytes: 4352
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n, m;
    cin >> n >> m;

    cout << (n == m ? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 888
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;


class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x[] = new int [n];
    for(int i = 0;i < n;i++){
      x[i] = sc.nextInt();
    }

    int a[] = new int [n];
    a = x.clone();
    Arrays.sort(a);
    for(int i = 0;i < n;i++){
      if(x[i] < a[n/2]){
        System.out.println(a[n/2]);
      }else{
        System.out.println(a[n/2 - 1]);
      }
    }
  }
}

Measured memory_bytes: 89468
#biscuits
n,p=map(int,input().split())
odd=0
even=0
lists=list(map(int,input().split()))
for some in lists:
    if some%2==0:
        even+=1
    else:
        odd+=1
ans=2**even
dp=[1 for i in range(51)]
for i in range(1,51):
    dp[i]=dp[i-1]*i
def combi(n,k):
    return dp[n]//(dp[k]*dp[n-k])
if p%2==0:
    #oddはeven枚数
    sub=0
    for i in range(odd+1):
        if i%2==0:
            sub+=combi(odd,i)
    print(ans*sub)
      
else:
    sub=0
    for i in range(odd+1):
        if i%2!=0:
            sub+=combi(odd,i)
    print(ans*sub)
    

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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int s, w;
	cin >> s >> w;
	if (w >= s) cout << "unsafe";
	else cout << "safe";
	cout << '\n';
	return 0;
}

Measured memory_bytes: 3632
#pragma warning(disable: 4996)
#define _USE_MATH_DEFINES
#include <iostream>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
using namespace std;

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

	int A, B;
	cin >> A >> B;
	if (A > 9 || B > 9) cout << -1;
	else cout << A * B;
	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int h, w;
    cin >> h >> w;
    vector<pair<int, int>> a;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c;
            cin >> c;
            if (c == '#') {
                a.push_back(make_pair(i, j));
            }
        }
    }
    sort(all(a));
    for (int i = 0; i < a.size() - 1; i++) {
        if (a[i + 1].first != a[i].first && a[i].second > a[i + 1].second) {
            cout << "Impossible" << endl;
            return 0;
        }
    }
    cout << "Possible" << endl;
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	bool ok = false;
	for (int i = 1; i < b; i++) {
		if ((a * i) % b == c) ok = true;
	}
	if (ok) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3600
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD (LL)(1e9+7)

int A[500][500];

void solve(int l, int r, int s){
	if(r-l == 2){
		A[l][l+1] = s;
		A[l+1][l] = s;
		return;
	}
	if(r-l < 2) return;
	solve(l, (l+r)/2, s+1);
	solve((l+r)/2, r, s+1);
	for(int i=l; i<(l+r)/2; i++){
		for(int j=(l+r)/2; j<r; j++){
			A[i][j] = s;
			A[j][i] = s;
		}
	}
}

int main(){
	int N;
	cin >> N;
	solve(0, N, 1);
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			if(j != i+1) cout << " ";
			cout << A[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define N 100003

int main(void) {
	int x, y, a, b, c, i, p[N], q[N], r[N], pn, qn, rn;
	vector<ll> v;

	cin >> x >> y >> a >> b >> c;

	for (i = 0; i < a; i++) cin >> p[i];
	for (i = 0; i < b; i++) cin >> q[i];
	for (i = 0; i < c; i++) cin >> r[i];

	sort(p, p + a, greater<int>());
	sort(q, q + b, greater<int>());
	sort(r, r + c, greater<int>());

	for (i = 0; i < x; i++) v.push_back(p[i]);
	for (i = 0; i < y; i++) v.push_back(q[i]);
	for (i = 0; i < c; i++) v.push_back(r[i]);

	sort(v.begin(), v.end(), greater <ll>());

	ll ans = 0;
	for (i = 0; i < x + y; i++) ans += v[i];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7024
def main():
    n=int(input())
    p=list(map(int,input().split()))
    x=list(map(int,input().split()))
    
    child=[[] for _ in [0]*n]
    for i,j in enumerate(p):
        child[j-1].append(i+1)
    
    other=[0]*n
    
    for i in range(n-1,-1,-1):
        if child[i]==[]:
            continue
        dp=[-1]*(x[i]+1)
        dp[0]=0
        xx=x[i]
        for j in child[i]:
            dp2=[-1]*(xx+1)
            m=x[j]
            o=other[j]
            for k,l in enumerate(dp):
                if l==-1:
                    continue
                if k+m<=xx:
                    if dp2[k+m]!=-1:
                        dp2[k+m]=min(dp2[k+m],l+o)
                    else:
                        dp2[k+m]=l+o
                if k+o<=xx:
                    if dp2[k+o]!=-1:
                        dp2[k+o]=min(dp2[k+o],l+m)
                    else:
                        dp2[k+o]=l+m
            dp=dp2
        k=[j for j in dp if j!=-1]
        if k!=[]:
            other[i]=min(k)
        else:
            print("IMPOSSIBLE")
            break
    else:
        print("POSSIBLE")

if __name__ == '__main__':
	main()


Measured memory_bytes: 44508
#include <stdio.h>
#include <string.h>
int main(){
  int f=1;
  char s[1001];
  scanf("%s",s);
  if(strchr(s,'N'))if(!(strchr(s,'S')))f=0;
  if(strchr(s,'S'))if(!(strchr(s,'N')))f=0;
  if(strchr(s,'W'))if(!(strchr(s,'E')))f=0;
  if(strchr(s,'E'))if(!(strchr(s,'W')))f=0;
  puts(f?"Yes":"No");
  return 0;
}

Measured memory_bytes: 128
from collections import Counter
from math import factorial
n = int(input())
a = list(map(int, input().split()))
s = [0]
for i in a:
    s.append(s[-1]+i)
a = Counter(s)
ans = 0
for v in a.values():
    ans += v * (v-1) // 2 if v > 1 else 0
print(ans)

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

#include <boost/range/adaptors.hpp>
#include <boost/range/combine.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    int64_t n4 = 0, n2 = 0;
    for (auto i : irange(0L, n)) {
        int64_t a;
        cin >> a;

        if (a % 4 == 0) {
            ++n4;
        } else if (a % 2 == 0) {
            ++n2;
        }
    }

    if ((n2 == 0 && n / 2 <= n4) || ((n - n2) + 1) / 2 <= n4) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T Gcd(T a, T b){
    if( b==0 ) return a;
    return Gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/Gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h,w,d; cin >> h >> w >> d;
    vector<vector<int>> a(h,vector<int>(w));
    vector<int> x(h*w+1);
    vector<int> y(h*w+1);
    rep(i,h) rep(j,w){
        cin >> a[i][j];
        x[a[i][j]] = i;
        y[a[i][j]] = j;
    }
    vector<int> s(h*w+10);
    for(int i = d+1; i<h*w+1; i++){
        s[i] = s[i-d] + abs(x[i]-x[i-d]) + abs(y[i]-y[i-d]);
    }
    int q; cin >> q;
    rep(i,q){
        int l,r;
        cin >> l >> r;
        cout << s[r] - s[l] << endl;
    }
}

Measured memory_bytes: 2560
#include"bits/stdc++.h"
using namespace std;
#define int int64_t
#define mp make_pair
#define f first
#define s second
#define mod 1000*1000*1000+7
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a,b;cin>>n>>a>>b;
    if(abs(a-b)%2==0)
    {
        cout<<abs(a-b)/2<<"\n";
    }
    else
    {
        int temp=min(a,b);
        b=max(a,b);
        a=temp;
        int t1=a;
        int tb=b-a;
        t1+=(tb-1)/2;
        int t2=n-b+1;
        a+=(n-b+1);
        t2+=(n-a)/2;
       // cout<<t1<<" "<<t2<<"\n";
        cout<<min(t1,t2)<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*********************************************START**************************************************************************/



int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	int T = 1;
	//int T;
	//cin >> T;
	// cin.ignore(); //must be there when using getline(cin, s)
	while (T--)
	{
		ll a, b; cin >> a >> b;
		cout << (a*b)/__gcd(a,b) << endl; 
	}
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

template<class T>
struct Vec2
{
	Vec2(){}
	Vec2(T _x, T _y) : x(_x), y(_y) {}

	Vec2 operator+(const Vec2& rhs) const { return Vec2(x + rhs.x, y + rhs.y); }
	Vec2 operator-(const Vec2& rhs) const { return Vec2(x - rhs.x, y - rhs.y); }
	T sqlength() const { return x*x + y*y; }

	T x, y;
};

typedef Vec2<double> Vec;
typedef long long ll;

static int Rand()
{
	static int r = 123456789;
	r = r ^ (r << 13);
	r = r ^ (r >> 17);
	r = r ^ (r << 5);
	return r;
}

inline static ll Cell(const Vec& p, double w)
{
	return  (ll(p.x / w) << 32) + ll(p.y / w);
}

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

	vector<Vec> P;
	P.reserve(n);
	for (int i = 0; i < n; i++) {
		double x, y;
		scanf("%lf%lf", &x, &y);
		P.push_back(Vec(x+200,y+200));
	}

	int ip = Rand()%P.size();
	double w = 1000000.0;
	for (size_t i = 0; i < P.size(); i++) {
		if (i != ip) {
			double d = (P[i] - P[ip]).sqlength();
			w = min(w,d);
		}
	}
	w = sqrt(w) * 1.01;

	unordered_map<ll, vector<size_t>> grid;
	for (size_t i = 0; i < P.size(); i++) {
		grid[Cell(P[i], w)].push_back(i);
	}

	double ans = 1000000.0;
	for (size_t i = 0; i < P.size(); i++) {
		const ll c = Cell(P[i], w), X = ll(1)<<32;
		const ll neighbors[9] = { c - X - 1, c - X, c - X + 1, c - 1, c, c + 1, c + X - 1, c + X, c + X + 1 };
		vector<size_t> v;
		for (int j = 0; j < 9; j++) {
			auto it = grid.find(neighbors[j]);
			if (it == grid.end()) continue;
			for (const auto& k : it->second) {
				if (k != i) {
					double d = (P[k] - P[i]).sqlength();
					ans = min(ans, d);
				}
			}
		}
	}
	printf("%.10f\n", sqrt(ans));
	return 0;
}


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

using ll = long long;
int h, w;
int a[1005][1005];

bool good(int i, int j) {
    return (i >= 0 && i < h && j >= 0 && j < w && a[i][j] == 0);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--, cw--, dh--, dw--;
    
    for(int i=0; i<h; i++) {
        string s;
        cin >> s;
        for(int j=0; j<w; j++) {
            if(s[j] == '#') a[i][j] = 1;
            else a[i][j] = 0;
        }
    }
    
    int res = -1, val = 0;
    set<pair<int, int>> go;
    if(good(ch, cw)) go.insert({ch, cw});
    
    while(go.size() > 0 && res == -1) {
        //cout << go.size() << endl;
        queue<vector<int>> q;        
        for(auto [x, y] : go) {
            if(a[x][y] == 1) continue;
            a[x][y] = 1;
            q.push({x, y});
            //cout << x << " " << y << endl;
        }
        go.clear();
        
        while(q.size()) {
            auto node = q.front();
            q.pop();
            int x = node[0], y = node[1];
            if(x == dh && y == dw) {
                res = val;
                break;
            }
            for(int dx : {-1, 0, 1}) {
                for(int dy : {-1, 0, 1}) {
                    if(abs(dx) + abs(dy) != 1) continue;
                    int new_x = x + dx, new_y = y + dy;
                    if(good(new_x, new_y)) {
                        a[new_x][new_y] = 1;
                        q.push({new_x, new_y});
                    }
                }
            }
            for(int dx : {-2, -1, 0, 1, 2}) {
                for(int dy : {-2, -1, 0, 1, 2}) {
                    int new_x = x + dx, new_y = y + dy;
                    if(good(new_x, new_y))
                        go.insert({new_x, new_y});
                }
            }
        }
        val++;
    }
    cout << res << endl;    

    return 0;
}

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

int main(){
  int n,k,a[8888],dp[8888];

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

  int ans = 0;
  for(int i=0;i<n;i++){
    if(a[i]<i)continue;
    for(int j=0;j<n;j++)dp[j] = 1e8;
    for(int j=i;j<a[i];j++){
      if(a[i]<a[j])*lower_bound(dp,dp+n+1,a[j]) = a[j];
    }
    ans = max(ans, (int)(lower_bound(dp,dp+n+1,1e8) - dp));
  }
  printf("%d\n",min(ans+1+k,n/2));
}

Measured memory_bytes: 1260
while True:
    c=0
    x, y = map(int, input().split())
    if x == 0 and y== 0:
        break
    for i in range(1, x+1):
        for j in range(i+1, x+1):
            for k in range(j+1, x+1):
                if i+j+k == y:
                    c += 1
    print (c)


Measured memory_bytes: 5596