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

int main(){
  int A , B ;
  cin >> A >> B ;
  int ans = 0;
  for(int i=1;i<B;i++){
    if(((A-1)*i+1)>=B) {
      ans = i ;
      break ;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	boolean isok = true;
	if(s.length()<4) {
	    System.out.println("WA");
	    return;
	}
	if(s.charAt(0) != 'A') {
	    System.out.println("WA");
            return;
	}
	String miniS = s.substring(2, s.length()-1);
	String ms = miniS.replace("C", "");
	if(miniS.length() - ms.length() != 1) {
	    System.out.println("WA");
            return;
	}
	String lowcase = s.charAt(1) + ms.substring(0, ms.length()) + s.charAt(s.length()-1);
	if(!lowcase.equals(lowcase.toLowerCase())) {
	    System.out.println("WA");
            return;
	}
	System.out.println("AC");
    }
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) 
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#coding:utf-8

def main():
    b = input()
    b = b.upper()
    if b == "A":
        print("T")
    elif b == "T":
        print("A")
    elif b == "G":
        print("C")
    elif b == "C":
        print("G")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
n,x,m = map(int,input().split())

cnt = 0
s = set()
L = []
for i in range(n):
    if i == 0:
        x = x%m
    else:
        x = x**2%m
    #print(x)
    if x == 0:
        break
    else:
        cnt += x
        if x not in s:
            s.add(x)
            L.append(x)
        else:
            l = L.index(x)
            restN = n - (i+1)
            restL = len(L)-l
            a = restN%restL
            
            loopcnt = 0
            restcnt = 0
            for j in range(restL):
                loopcnt += L[l+j]
                #print('loop:'+ str(L[l+j]))
                if j > 0 and j <= a:
                    restcnt += L[l+j]
            #print(i,loopcnt,restN,restL,restcnt)
            cnt += loopcnt*(restN//restL) + restcnt
            break
                

print(cnt)


Measured memory_bytes: 12768
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main() {
    ll N,K;
    cin >> N >> K;
    ll pos;
    for(int i=0;i<N;i++){
        ll A;
        cin >> A;
        if(A==1){
            pos = i;
        }
    }
    ll ans=0;
    {
        ll temp =0;
        if(pos<K-1){
            pos = (K-1);
            temp++;
        }else{
            temp += (pos+K-2)/(K-1);
        }
        temp+= (N-1-pos+K-2)/(K-1);
        ans = temp;
    }
    {
        ll temp =0;
        if(N-1-pos>K-1){
            pos = N-K;
            temp++;
        }else{
            temp += (N-1-pos+K-2)/(K-1);
        }
        temp += (pos+K-2)/(K-1);
        ans = min(ans,temp);
    }
   
    cout << ans << endl;


    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int h, w;
    scanf("%d %d\n", &h, &w);
    char maze[h][w+1];
    for(int i=0; i<h; i++){
        scanf("%s\n", maze[i]);
    }
    
    int cnt = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(maze[i][j] == '.') cnt++;
        }
    }

    int d[h][w];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            d[i][j] = -1;
        }
    }
    d[0][0] = 0;
    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));

    int dxy[] = {0, 1, 0, -1, 0};
    while(!que.empty()){
        pair<int, int> p = que.front(); que.pop();
        int x = p.first;
        int y = p.second;
        for(int i=0; i<4; i++){
            int nx = x + dxy[i];
            int ny = y + dxy[i+1];
            if(nx<0 || h<=nx || ny<0 || w<=ny) continue;
            else if(maze[nx][ny]=='#') continue;
            else if(d[nx][ny]!=-1) continue;
            else if(nx==h-1 && ny==w-1){
                printf("%d\n", cnt - d[x][y] - 2);
                return 0;
            }
            d[nx][ny] = d[x][y] + 1;
            que.push(make_pair(nx, ny));
        }
    }
    printf("-1\n");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    long long ans = 0;
    int n;
    
    cin >> n;
    
    vector<int> b(n);
    for (int i = 0; i < n-1; i++)
    {
        cin >> b[i];
    }

    for (int i = 0; i < n - 1; i++)
    {
        if (i == 0)
            ans += b[i];
        else {
            if (b[i] > b[i-1]) ans += b[i-1];
            else ans += b[i];
        }
    }
    ans += b[n-2];
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using ll = int_fast64_t;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
                fac[i] = fac[i - 1] * i % MOD;
                inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
                finv[i] = finv[i - 1] * inv[i] % MOD;
        }
}

long long COM(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
        COMinit();
        int n, k;
        scanf("%d %d", &n, &k);
        std::vector<int> a(n);
        for(int i=0; i<n; i++) scanf("%d", &a[i]);
        std::sort(a.begin(), a.end(), std::greater<int>());
        std::vector<int> b(a);
        std::reverse(b.begin(), b.end());

        ll ans = 0;
        for(int i=0; i<n; i++){
                ans = (ans + a[i] * COM(n-1-i, k-1) % MOD) % MOD;
                ans = (ans - b[i] * COM(n-1-i, k-1) % MOD) % MOD;
        }
        if(ans<0) ans += MOD;

        printf("%ld\n", ans);
        return 0;
}

Measured memory_bytes: 12928
use text_io::*;
use std::process::exit;
use im_rc::*;
use std::cmp::*;

fn main(){
    let mut n:usize = read!();
    let mut s:usize = 0;
    let mut v:Vec<usize> = Vec::new();
    for i in 0..n {
        let x:usize = read!();
        v.push(x);
    }
    v.sort();
    for i in 0..n {
        for j in i..n {
            for k in j..n {
                if v[i]!=v[j]&&v[j]!=v[k] {
                    if v[i]+v[j]>v[k]{
                        s+=1;
                    }
                }
            }
        }
    }
    println!("{}",s);
}

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

lli n;

int main(void){
	cin >> n;
	vector<lli> h(n);
	rep(i, n)cin >> h[i];
	lli ans = h[0];
	rep(i, n-1){
		if(h[i] < h[i+1]) ans+=h[i+1]-h[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define maxn 100001
#define pb push_back
using namespace std;
void solve(){
    ll m,n,d,x,y,c=0;
    cin>>n>>d;
    d*=d;
    while(n--){
        cin>>x>>y;
        m=(x*x)+(y*y);
        if(m<=d)
        c++;
    }
    cout<<c;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
 
static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;
 
class Point {
public:
    double x,y;
 
    Point(double x=0,double y=0):x(x),y(y) {}
    Point operator + (Point p) {return Point(x+p.x,y+p.y);}
    Point operator - (Point p) {return Point(x-p.x,y-p.y);}
    Point operator * (double a) {return Point(a*x,a*y);}
    Point operator / (double a) {return Point(x/a,y/a);}
 
    double abs() {return sqrt(norm());}
    double norm() {return x*x+y*y;}
 
    bool operator<(const Point &p) const {
        return x!=p.x ? x<p.x : y<p.y;
    }
    bool operator==(const Point &p) const {
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
};
 
typedef Point Vector;
struct Segment {Point p1,p2;};
typedef Segment Line;
 
class Circle {
public:
    Point c;
    double r;
    Circle(Point c=Point(),double r=0.0): c(c),r(r) {}
};
 
double dot(Vector a,Vector b) {
    return  a.x*b.x+a.y*b.y;
}
 
double cross (Vector a,Vector b) {
    return a.x*b.y-a.y*b.x;
}
 
double getDistance(Point a,Point b) {
    return (a-b).abs();
}
 
double getDistanceLP(Line l,Point p) {
    return abs(cross(l.p2-l.p1,p-l.p1)/(l.p2-l.p1).abs());
}
 
double getDistanceSP(Segment s,Point p) {
    if(dot(s.p2-s.p1,p-s.p1)<0.0) return (p-s.p1).abs();
    if(dot(s.p1-s.p2,p-s.p2)<0.0) return (p-s.p2).abs();
    return getDistanceLP(s,p);
}
 
int ccw(Point p0,Point p1,Point p2) {
    Vector a=p1-p0;
    Vector b=p2-p0;
    if(cross(a,b)>EPS) return COUNTER_CLOCKWISE;
    if(cross(a,b)<EPS) return CLOCKWISE;
    return ON_SEGMENT;
}
 
bool intersect(Point p1,Point p2,Point p3,Point p4) {
    return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 && ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}
 
bool intersect(Segment s1,Segment s2) {
    return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}
 
double getDistance(Segment s1,Segment s2) {
    if(intersect(s1,s2)) return 0.0;
    return min(min(getDistanceSP(s1,s2.p1),getDistanceSP(s1,s2.p2)),min(getDistanceSP(s2,s1.p1),getDistanceSP(s2,s1.p2)));
}
 
int main(void) {
    int q;cin>>q;
    while(q) {
        Segment s1,s2;
        cin>>s1.p1.x>>s1.p1.y>>s1.p2.x>>s1.p2.y>>s2.p1.x>>s2.p1.y>>s2.p2.x>>s2.p2.y;
        printf("%.10f\n",getDistance(s1,s2));
        q--;
    }
    return 0;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)
 
 
#define ll long long int
#define ld long double
 
#define fr first
#define se second
 
 
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) (int)v.size()
#define sunq(v) sort(all(v));v.resize(distance(v.begin(),unique(all(v))))
 
 
#define pb push_back
#define mp make_pair
 
 
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define emla(a, val) memset(a, val, sizeof(a))
#define easm(a, b) (a + b - 1) /b 
 
#define PI 3.141592653589793238
 
 
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
 
 
//bool valid(int i, int j){return i >= 0 && i < n && j >= 0 && j < m;}
 
int a, b, c, vis[111];


int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  //clock_t z = clock();
  cin >> a >> b >> c;
  int x = c % b;
  int cc = 0;
  for(int i = 1;; i++){
    cc += a;
    if(cc%b == c%b){
      cout << "YES\n";
      return 0;
    }
    if(vis[cc%b])break;
    vis[cc%b] = 1;
  } 
  cout << "NO\n";
  //debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
  /*
  *try tricky test cases:
    -bounds
    -small input (0, 1)
    -big input
    -random tests
  */
  return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let n = read_one::<usize>();
    let ans = (1..=n)
        .filter(|&x| x % 2 != 0)
        .filter(|&x| divisors(x) == 8)
        .count();
    println!("{}", ans);
}

fn divisors(n: usize) -> usize{
    let mut ret = Vec::new();
    for i in 1..=n {
        if n % i == 0 { ret.push(i); }
    }
    ret.len()
}

#[allow(unused)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}


#[allow(unused)]
fn read_one<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 2140
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

struct edge {
	int to, len, cost;
	edge() {};
	edge(int a, int b, int c)
	{
		to = a; len = b; cost = c;
	}
};
typedef pair<int, int>node;

const int INF = 0x3f3f3f3f;
const int MAX = 10000 + 10;
int n, m;
vector<edge>g[MAX];
int d[MAX];

void dijkstra()
{
	for (int i = 0; i < MAX; i++)
		d[i] = INF;
	d[1] = 0;
	priority_queue<node, vector<node>, greater<node> >pq;
	pq.push(node(0, 1));
	while (pq.size())
	{
		int v = pq.top().second, dis = pq.top().first;
		pq.pop();
		if (dis > d[v])continue;
		for (int i = 0; i < g[v].size(); i++)
		{
			edge e = g[v][i];
			if (d[e.to] > dis + e.len)
			{
				d[e.to] = dis + e.len;
				pq.push(node(d[e.to], e.to));
			}
		}
	}
}

int main()
{
	while (cin >> n >> m)
	{
		if (n == 0 && m == 0)break;
		int s, e, c1, c2;
		for (int i = 0; i < MAX; i++)
			g[i].clear();
		for (int i = 0; i < m; i++)
		{
			cin >> s >> e >> c1 >> c2;
			g[s].push_back(edge(e, c1, c2));
			g[e].push_back(edge(s, c1, c2));
		}
		dijkstra();
		int sum = 0, minn = INF;
		for (int i = 2; i <= n; i++)
		{
			minn = INF;
			for (int j = 0; j < g[i].size(); j++)
			{
				edge e = g[i][j];
				if (d[i] == d[e.to] + e.len)
					minn = min(minn, e.cost);
			}
			sum += minn;
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 5068
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
int H, W;
vector<vector<char>>field;
void dfs(int _i, int _j) {
	vector<int>dxy={0,1,0};
	field[_i][_j]='.';
	if(_i==H-1&&_j==W-1)return;

	for(int i=0; i<2; ++i) {
		int ty=_i+dxy[i], tx=_j+dxy[i+1];
		if(ty>=0&&ty<H&&tx>=0&&tx<W&&field[ty][tx]=='#')
			return dfs(ty, tx);
	}
}
int main() {
	cin>>H>>W;
	field=vector<vector<char>>(H,vector<char>(W));
	for(auto& e:field)
	for(auto& c:e)
		cin>>c;
	
	int cnt=0;
	for(int i=0; i<H; ++i)
	for(int j=0; j<W; ++j){
		if(field[i][j]=='#') {
			dfs(i,j);
			++cnt;
		}
	}

	if(cnt==1)cout<<"Possible";
	else cout<<"Impossible";
	cout<<endl;

	return 0;
}

Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
L = []
P = list(map(int, input().split()))
P.sort(reverse=True)
L += P[:X]
Q = list(map(int, input().split()))
Q.sort(reverse=True)
L += Q[:Y]
L += list(map(int, input().split()))
L.sort(reverse=True)
print(sum(L[:X + Y]))


Measured memory_bytes: 25632
#include <bits/stdc++.h>
using namespace std;
//Sunny, , Rainy
int main() {
  string weather,next;
  cin >> weather;
  if (weather=="Sunny"){
        next= "Cloudy";
  }
  else if (weather=="Cloudy"){
        next= "Rainy";
  }
  else if (weather=="Rainy"){
        next= "Sunny";
  }
  cout << next << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  cout<<(min((x>y?(x-y)*a:(y-x)*b)+min(x,y)*2*c,min(a*x+b*y,max(x,y)*2*c)))<<endl;
}

Measured memory_bytes: 256
"use strict";

function main(arg) {
    arg = arg.split("\n")[0].split(" ").map(n=>parseInt(n));
    const A = arg[0];
    const B = arg[1];
    const X = arg[2];
    
    console.log(A <= X && B >= Math.abs(A-X) ? "YES" : "NO");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

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

  if (a=='H') {
    if (b=='H') cout <<'H' <<endl;
    else cout <<'D' <<endl;
  } else if (b=='H') cout <<'D' <<endl;
  else cout <<'H' <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define rep(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, m;
	cin >> n >> m;
	int maxi = 1, mini = 100000;
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		maxi = max(maxi, l);
		mini = min(mini, r);
	}
	if (mini < maxi)
		cout << 0 << endl;
	else
		cout << (mini - maxi + 1) << endl;
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define maxn 505
using namespace std;
typedef long long ll;
int a[maxn][maxn];
int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    while (m--){
        int l, r;
        cin >> l >> r;
        ++a[l][r];
    }
    for (int i = n; i >= 1; --i){
        for (int j = 1; j <= n; ++j){
            a[i][j] += a[i + 1][j] + a[i][j - 1] - a[i + 1][j - 1];
        }
    }
    while (q--){
        int l, r;
        cin >> l >> r;
        cout << a[l][r] << endl;
    }
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int k, s;
    cin >> k >> s;
    int cnt = 0, x, y, z;
    for (x = 0; x <= k;x++){
        for (y = 0; y <= k;y++){
            z = s - x - y;
            if(0<=z&&z<=k)
                cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define ll long long
#define lb(x) ((x)&(-x))
#define pii pair<int,int>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define de(x) cout<<x<<" x"<<endl
#define LCAFA rep(i,1,20)rep(j,1,n+1)fa[j][i]=fa[fa[j][i-1]][i-1]
#define all(x) x.begin(),x.end()
#define ls(x) x<<1
#define rs(x) x<<1|1
using namespace std;
const int N=2e5+9;
const ll mod=998244353;
pair<int,int> g[N];
ll dp[N][40];
int a[N],b[N],p[N];
int cnt,cnt2;
void upd(ll &a,ll b){
	if(a>b)a=b;
}
bool cmp(pii x,pii y){
	return (ll)(x.fi-1)*y.se>(ll)(y.fi-1)*x.se;
}
int main(){
//	freopen("text.in","r",stdin);
	int n,t;
	scanf("%d%d",&n,&t);
	++t;
	rep(i,1,n+1){
		scanf("%d%d",&a[i],&b[i]);
		++a[i],++b[i];
		if(a[i]>1)g[++cnt]={a[i],b[i]};
		else p[cnt2++]=b[i];
	}
	sort(g+1,g+1+cnt,cmp);
	sort(p,p+cnt2);
	rep(i,0,N)rep(j,0,40)dp[i][j]=1e12;
	dp[0][0]=1;
	rep(i,1,cnt+1){
		rep(j,0,40){
			if(dp[i-1][j]<=t)upd(dp[i][j],dp[i-1][j]);
			if(j&&dp[i-1][j-1]<=t&&dp[i-1][j-1]*g[i].fi+g[i].se<=t)upd(dp[i][j],dp[i-1][j-1]*g[i].fi+g[i].se);
		}
	}
	ll sum=0;
	int pos=0,ans=0;
	per(j,0,40){
		if(dp[cnt][j]>t)continue;
	//	cout<<cnt<<' '<<j<<' '<<dp[cnt][j]<<"dp\n";
		while(pos<cnt2&&dp[cnt][j]+sum+p[pos]<=t)sum+=p[pos++];
	//	cout<<cnt2<<' '<<pos<<"pos\n";
		ans=max(ans,pos+j); 
	}
	cout<<ans;
} 


Measured memory_bytes: 65920
#include<bits/stdc++.h>
using namespace std;
int main() {
	int ans=6000;
	string a,b,c;
	vector<bool>ab(16001,1),ac(16001,1),bc(16001,1);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b>>c;
	for(int i=0;i<a.size();i++)
		for(int j=0;j<b.size();j++)
			if(a[i]!='?'&&b[j]!='?'&&a[i]!=b[j])
				ab[i-j+8000]=0;
	for(int i=0;i<a.size();i++)
		for(int j=0;j<c.size();j++)
			if(a[i]!='?'&&c[j]!='?'&&a[i]!=c[j])
				ac[i-j+8000]=0;
	for(int i=0;i<b.size();i++)
		for(int j=0;j<c.size();j++)
			if(b[i]!='?'&&c[j]!='?'&&b[i]!=c[j])
				bc[i-j+8000]=0;
	for(int i=-4000;i<=4000;i++)
		for(int j=-4000;j<=4000;j++)
			if(ab[i+8000]&&ac[j+8000]&&bc[j-i+8000])
				ans=min(ans,max((int)a.size(),max((int)b.size()+i,(int)c.size()+j))-min(0,min(i,j)));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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 T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int N;
int X,Y;

int main() {
  cin >>N >>X >>Y; X--; Y--;
  Graph G(N);
  rep(i, N-1){
    G[i].push_back(i+1);
    G[i+1].push_back(i);
  }
  G[X].push_back(Y); G[Y].push_back(X);
  vector<int> distance(N);
  vector<int> dist(N, -1);
  rep(i, N-1){
    dist.assign(N, -1);
    dist[i] = 0;
    queue<int> que;
    que.push(i);
    while (!que.empty()){
      int v = que.front(); que.pop();
      for (int nv : G[v]){
        if (dist[nv] != -1) continue;
        dist[nv] = dist[v] + 1;
        if (i < nv) distance[dist[nv]]++;
        que.push(nv);
      }
    }
  }
  for (int i=1; i<N; i++){
    cout <<distance[i] <<endl;
  }
}

/*
0 1 2 3 4 5 6 7 8

*/

Measured memory_bytes: 384
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = [0] + [int(input()) for _ in range(N)]
    pushed = [False] * (N + 1)
    pushed[0] = True
    now = 1
    cnt = 0
    while now != 2:
        now = A[now]
        cnt += 1
        if pushed[now]:
            print(-1)
            return
        pushed[now] = True
    print(cnt)



if __name__ == "__main__":
    main()


Measured memory_bytes: 78032
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
//#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
	int a, b;
	cin >> a >> b;
	int m = (a + b) / 2;
	if ((a + b) % 2 == 1) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << m << endl;
	}
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int a,b; cin >> a >> b;
    out((a+b+1)/2);
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_N = 200000+10;
int N,Q;

vector<int> V[max_N];
Int score[max_N];
Int ans = 0;

void dfs(int v,int p=-1) {
    
    for(auto u: V[v]) {
        if(u == p)
            continue;
        score[u] += score[v];
        dfs(u, v);
    }

}


int main(void) {
    cin>>N>>Q;
    for(int i = 1;i <= N-1;i++) {
        int a,b;
        cin>>a>>b;
        V[a].push_back(b);
        V[b].push_back(a);
    }

    for(int i = 1;i <= Q;i++) {
        Int p,x;
        cin>>p>>x;
        score[p] += x;
    }

    dfs(1, -1);
    for(int i = 1;i <= N;i++) {
        cout<<score[i]<<" ";
    }
    cout<<endl;

    return 0;
}


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

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

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

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

    int n = 1;
    int count = 0;
    while (count < b) {
        count = a * (n + 1) - n;
        ++n;
    }

    cout << n << endl;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int max_len = 0;
    vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (s[i-1] == s[j-1]) {
                int len = min(dp[i-1][j-1]+1, j-i);
                dp[i][j] = len;
                if (len > max_len) {
                    max_len = len;
                }
            }
        }
    }
    cout << max_len << "\n";
    return 0;
}


Measured memory_bytes: 98176
#include <iostream>
using namespace std;
int main(){
  int a ,n ,i ,ice[10]={};
  while(  cin >> n ){
    if( n == 0 ){
      break;
    }
    
    for( i=0 ; i<n ; i++ ){
      cin >> a;
      ice[a]++;
    }
    
    for( i=0 ; i<10 ; i++ ){
      if( ice[i] == 0 ){
	cout << '_';
      }

      for( int j=0 ; j<ice[i] ; j++ ){
	cout << '*';
      }
      cout << endl;
      }
    for( i=0 ; i<10 ; i++ ){
      ice[i] = 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1148
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main() {
    string N;
    cin >> N;
    
    unsigned long len = N.size();
    int j = -1;
    int k = -1;
    
    for (int i = 0; i < len; ++i) {
        if (N[i] != '9') {
            if (j == -1) {
                j = i;
            } else {
                k = i;
                break;
            }
        }
    }
    if (j == -1) {
        cout << len * 9;
    } else if (j == 0) {
        if (k == -1) {
            cout << N[0] - '0' + 9 * (len - 1);
        } else {
            cout << (N[0] - '1') + 9 * (len - 1);
        }
    } else {
        cout << 9 * len - 1;
    }
    
    cout << endl;
    
    return 0;
}


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

using namespace std;

const int MAXN = 2e5+5;

int n, t, niz[MAXN], sol, until;

int main()
{
	cin >> n >> t;
	for(int i = 0; i < n; i++)
		cin >> niz[i];
	for(int i = 0; i < n - 1; i++)
	{
		if(niz[i] + t < niz[i + 1])
			sol += t;
		else
			sol += niz[i + 1]-niz[i];
	}
	cout << sol + t;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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 <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int h, w, k;
	bool ans = false;
	cin >> h >> w >> k;

	int a;
	int b = 0;
	ans   = (k % h == 0 and k / h <= w)or(k%w==0 and k/w<=h);
	
	for (int i = 0; i <= h; i++) {
		a = -h * w + k + w * i;
		b = -h + 2 * i;
	//	clog << i <<" : "<<a<<" "<<b<< endl;
		if (b == 0) continue;
		ans = (ans or ((a % b == 0) and (a / b >= 0 and a/b <= w)));
		if (ans) {
			clog << " " << a / b << endl;
			break;
		}
	}
	cout << solve(ans) << endl;
}
/*
h:a+b , w:c+d  ac+(h-a)(w-c)==k -> 2ac-k+hw+-hc-wa=0 -> hw-k-wa=c(h-2a)
c=(hw-k-wa)/(h-2a) oooxx oooxx oooxx oooxx xxxoo xxxoo
*/

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

signed main() {
    int N;
    cin >> N;
    vector<int> A(N + 1);
    vector<int> B(N);
    for (int& x : A) cin >> x;
    for (int& x : B) cin >> x;

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int t = min(A[i], B[i]);
        A[i] -= t;
        B[i] -= t;
        ans += t;

        if (B[i] == 0) continue;

        t = min(A[i + 1], B[i]);
        A[i + 1] -= t;
        B[i] -= t;
        ans += t;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 100 + 5;

int main(){
	ll t = 100;
	ll x,z = 0;
	cin >> x;
	while(t < x){
		t += (t/100);
		z++;
	}
	cout << z << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
using namespace std;

int main() {
	string a, b;
	cin >> b >> a >> b;
	cout << "A" << a[0] << "C" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
int main() {
  int a,b,ans=0,c;
  cin>>a>>b;
  rep(i,a){
    cin>>c;
    if(c>=b) ans++;
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

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

    int ac = 0, wa = 0, tle = 0, re = 0;
    rep(_, n) {
        string s;
        cin >> s;

        if (s == "AC") ac++;
        else if (s == "WA") wa++;
        else if (s == "TLE")tle++;
        else if (s == "RE") re++;

    }


    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ac, wa, tle, re);

}


Measured memory_bytes: 3728
#include <iostream>
 using namespace std ;
 int main()
{
 int a,b, c, d,e;
 cin>>a;
cin>>b;
 c=(a*2-1);
 d=(b*2-1);
 e=(a+b);
 if (a > b)
 {
   cout<<c<<endl;
 }
 if  (a < b)
 {
   cout<<d<<endl;
 }
  if (a == b)
{
  cout<<e<<endl;
}
return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    if (a[0] < 0 && a[n - 1] < 0) {
        cout << a[n - 1] - accumulate(a, a + n - 1, 0) << endl;
        int x = a[n - 1];
        for (int i = 0; i < n - 1; i++) {
            cout << x << ' ' << a[i] << endl;
            x -= a[i];
        }
    } else if ( a[0] > 0 && a[n - 1] > 0) {
        cout << accumulate(a + 1, a + n, 0) - a[0] << endl;
        int x = a[0];
        for (int i = 1; i < n - 1; i++) {
            cout << x << ' ' << a[i] << endl;
            x -= a[i];
        }
        cout << a[n - 1] << ' ' << x << endl;
    } else {
        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += (a[i] < 0) ? -a[i] : a[i];
        }
        cout << ans << endl;
        int x = a[n - 1], y = a[0];
        for (int i = 1; i < n - 1; i++) {
            if (a[i] < 0) {
                cout << x << ' ' << a[i] << endl;
                x -= a[i];
            } else {
                cout << y << ' ' << a[i] << endl;
                y -= a[i];
            }
        }
        cout << x << ' ' << y << endl;
    }
    return 0;
}



Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,W;
  cin >>N>>W;
  vector<string> vec(N+2);
  for (int i=0;i<N;i++){
    cin >> vec.at(i+1);
  }
  char a;
  a='#';
  for(int i=0;i<N;i++){
    vec.at(i+1)=a+vec.at(i+1)+a;
  }
  for(int i=0;i<W+2;i++){
    vec.at(0)+=a;
    vec.at(N+1)+=a;
  }
  for(int i=0;i<N+2;i++){
    cout <<vec.at(i)<<endl;
  }
}
    

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
    int i;
    int n;
    scanf("%d", &n);
    int *a = malloc(sizeof(int) * n);
    for (i = 0; i < n;i++){
        scanf("%d", &a[i]);
    }

        int cnt = 0;
    for (i = 0; i < n;i+=2){
        if((a[i]%2)==1){
            cnt++;
        }
    }
    printf("%d", cnt);
    return 0;
}

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

double T, A;
double H[1000];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N >> T >> A;

	for(int i = 0; i < N; i++){
		cin >> H[i];
	}
	double mind = 1e9;
	int ans = -1;
	for(int i = 0; i < N; i++){
		double a = T - H[i] * 0.006;
		if(mind > abs(A - a)){
			mind = abs(A - a);
			ans = i;
		}
	}
	cout << ans + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
cin >> a >> b >> c >> d;
 if (a+b < c+d){
     cout << "Right" << endl;
 }
 else if (a+b > c+d){
     cout << "Left" << endl;
 }
 else{
     cout << "Balanced" << endl;
 }
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

ll gcd(ll a,ll b){
if(a==0||b==0)return max(a,b);
if(b>a)swap(a,b);
 while(1){
        if(a%b!=0){
            ll tmp=b;b=a%b;
            a=tmp;
        }else{
            return b;
        }
    }
}
int main(){


ll a,b;
cin>>a>>b;
ll ans = a*b/gcd(a,b);
cout<<ans<<endl;

    
return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, A, B = inm()


def solve():
    if A > B:
        return 0
    if N == 1:
        return 0 if A != B else 1
    a = A * (N - 1) + B
    b = B * (N - 1) + A
    return b - a + 1


print(solve())


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  string s,t,u;
  cin>>s>>t;
  cin>>a>>b;
  cin>>u;
  if(s == u) 
    a--;
  else
    b--;
  
  cout<<a<<" "<<b;
  return 0;
}

Measured memory_bytes: 3576
#include <iostream>

using namespace std;

int main(void){
    int life,n,d,a;
    cin >> life >> n;
    d=0;
    for(;n>0;n--){
        cin >> a;
        d+=a;
    }
    if(d>=life)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))

kion = list(map(float, list(map(lambda x: t-x*0.006, h))))
sub = list(map(float, list(map(lambda x: abs(a-x), kion))))

temp = sub.copy()
temp.sort()
index = sub.index(temp[0])

print(index+1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
//vector<ll> vll;
ll num[ten52];
ll path[ten52];

int main(void)
{
    //double ans=0.0,d,d1,d2;
    long long int m,n,i,j,k=0,h,save;
    long long int a,a1,a2,a3,sum;
    string s,s1,s2;
    //char c,c1;
    sum=a=a1=a2=a3=0;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='?') cout<<'D';
        else cout<<s[i];
    }
    return 0;
}





Measured memory_bytes: 3752
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
ll T;
vector<ll> A;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N >> T;
    A = fetch_vec<ll>(N);
}

int solve(){
    ll sell,buy;
    sell = buy = A[0];
    unordered_map<ll,ll> cnt;
    for (int i = 0; i < N; i++)
    {
        if(A[i]>sell){
            sell = A[i];
            cnt[sell-buy]++;
        }
        else if(A[i]<buy){
            sell = buy = A[i];
        }
    }
    auto itr = max_element(cnt.begin(),cnt.end(),[](pll a,pll b){return a.first < b.first;});
    cout << itr->second << endl;
    
    return 0;
}   

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


Measured memory_bytes: 5156
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
using lint = long long;

int main()
{
    lint n;
    scanf("%lld", &n);

    std::vector<lint> fact_num(1001, 0);

    std::vector<lint> prime;
    prime.push_back(2);
    prime.push_back(3);

    lint num = 5;

    while (num <= 1000)
    {
        bool is_prime = true;
        for (auto p : prime)
        {
            if (p > sqrt(num) + 1)
                break;
            if (num % p == 0)
            {
                is_prime = false;
                break;
            }
        }
        if (is_prime)
            prime.push_back(num);
        num++;
    }

    for (int i = n; i >= 1; --i)
    {
        lint tmp = i;
        for (auto p : prime)
        {
            if (p > i)
                break;
            while (tmp % p == 0)
            {
                tmp /= p;
                fact_num[p]++;
            }
        }
    }

    lint ans = 1;
    lint mod = 1e9 + 7;

    for (auto num : fact_num)
    {
        if (num == 0)
            continue;
        if (num > n)
            break;
        ans = ans * (num + 1);
        ans %= mod;
    }

    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
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; }


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    for (size_t i = 1; i < s.size(); ++i) {
        if (s[i] == s[i - 1]) {
            ans++;
            if (s[i] == '0') s[i] = '1';
            else s[i] = '0';
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
// working example: std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int w,a,b;
  cin >> w >> a >> b;
  if((a >= b && a <= b + w) || (a + w >= b && a + w <= b + w) ){
    cout << 0 << endl;
    return 0;
  } else {
    int ans = min(abs(b-(a+w)), abs(b+w-a)) ;
    cout << ans << endl;
  }
  
  return 0;
}

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

int main(){
	int a , b , k , i;
	scanf( "%d%d%d" , &a , &b , &k );

	for( i = 1 ; i <= k ; ++i ){
		if( i&1 ){
			if( a&1 && a > 0 ) --a;
			b += (a/2);
			a /= 2;
		}
		else{
			if( b&1 && b > 0 ) --b;
			a += (b/2);
			b /= 2;	
		}
	}

	printf( "%d %d\n" , a , b );
	return 0;
}

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() {
  int X, i=1;
  cin >> X;
  while(1){
    if(X*i%360==0) break;
    i++;
  }
  cout << i << endl;
}

Measured memory_bytes: 3604
object Main {
  def main(args: Array[String]): Unit = {
    val str = io.StdIn.readLine()
    var k = io.StdIn.readLine().toLong

    val newStr = for (i <- 0 to (str.length - 1)) yield {
      val d = if (str(i) > 'a') 'z' + 1 - str(i) else 0
      if (d <= k) { k = k - d; 'a' }
      else str(i)
    }

    val lastChar = {
      val c = newStr.last + (k % 26)
      if (c > 'z') c - 26
      else         c
    }

    val ans = newStr.slice(0, newStr.length - 1).mkString + lastChar.toChar
    println(ans)
  }
}



Measured memory_bytes: 32016