akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
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
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    S = input()
    print("x" * len(S))


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9860
#include <iostream>

using namespace std;
int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void solve()
{
	int month, day;
	while(cin >> month >> day)
	{
		if(!month && !day)
		{
			break;
		}
		int sum = 0;
		for(int i = 0; i < month - 1; ++i)
		{
			sum += days[i];
		}
		sum += day - 1;
		sum %= 7;
		switch(sum)
		{
		case 0: cout << "Thursday"  << endl; break;
		case 1: cout << "Friday"    << endl; break;
		case 2: cout << "Saturday"  << endl; break;
		case 3: cout << "Sunday"    << endl; break;
		case 4: cout << "Monday"    << endl; break;
		case 5: cout << "Tuesday"   << endl; break;
		case 6: cout << "Wednesday" << endl; break;
		}
	}
}

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

Measured memory_bytes: 0
N, K = list(map(int, input().split(' ')))
D = list(map(int, input().split(' ')))
#print(N, K)
#print(D)

obse_num = [0 for i in range(10)]
for i in range(K):
    obse_num[D[i]] = 1

pay_money = N

while 1:
    obse_flag = 1

    S = list(str(pay_money))
    for char in S:
        if obse_num[int(char)] == 1:
            obse_flag = 0
            break
    
    if obse_flag == 1:
        break
    
    pay_money += 1

print(pay_money)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	int A;
	int B;
	int C;
	cin >> A >> B >> C;
	int max = 0, mid, min = 100000;
	int sum = A + B + C;

	if (max < A){
		max = A;
	}

	if (max < B){
		max = B;
	}
	if (max < C){
		max = C;
	}

	if (min > A){
		min = A;
	}
	if (min > B){
		min = B;
	}
	if (min > C){
		min = C;
	}
	mid = sum - max - min;
	cout << min <<" "<< mid <<" "<< max << endl;
	return 0;
}



Measured memory_bytes: 3088
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int[] a;
    foreach (_; 0..5) a ~= readint;
    int k = readint;

    bool ans = cartesianProduct(a, a).all!(e => abs(e[0] - e[1]) <= k);
    writeln(ans ? "Yay!" : ":(");
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {


    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }




    public void execute(CustomReader in) throws IOException {
        int[] abt = in.readLineAsIntArray();
        int A = abt[0];
        int B = abt[1];
        int T = abt[2];
        System.out.println((T / A) * B);
    }


    static class CustomReader extends BufferedReader {
        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }


        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public long[] readLineAsLongArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            long[] longArray = new long[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                longArray[i] = Long.parseLong(strArray[i]);
            }
            return longArray;
        }


        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }
    }

}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);

	long long int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1)
	{
		c-=b;
		//cout<<c<<' ';
		if(c<=0)
			return cout<<"Yes",0;
		a-=d;
		//cout<<d<<' ';
		if(a<=0)
			return cout<<"No",0;
	
	}
	
	return 0;
}

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

int main(){
  long long X,K,D;
  cin >> X >> K >> D;
  X=abs(X);
  long long A=X/D;
  if(K<=A){
    cout << X-K*D << endl;
  }
  else{
    X=X-A*D;
    K-=A;
    if(K%2==0){
      cout << X << endl;
    }
    else{
      cout << abs(X-D) << endl;
    }
  }
}


Measured memory_bytes: 3588
#include "iostream"
#include "string"

int main()
{
	int r, c;
	int sum = 0;
	int sheet[101][101] = { 0 };
	std::cin >> r >> c;

	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			std::cin >> sheet[i][j];
			sheet[r][j] += sheet[i][j];
			sum += sheet[i][j];
		}
	}

	for (int j = 0; j < c; j++)
		for (int i = 0; i < r; i++)
			sheet[i][c] += sheet[i][j];

	sheet[r][c] = sum;

	for (int i = 0; i <= r; i++) {
		for (int j = 0; j <= c; j++) {
			if (j < c)
				std::cout << sheet[i][j] << " ";
			else
				std::cout << sheet[i][j];
		}
		std::cout << std::endl;
	}
    return 0;
}

Measured memory_bytes: 3108
#!/usr/bin/env python
# coding: utf-8


def main():
    n = int(input())
    k = int(input())
    xs = [int(x) for x in input().split()]
    move = 0
    for x in xs:
        move += 2 * min(x, abs(k-x))
    print(move)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
        cin>>d.at(i);
    }
    sort(d.begin(),d.end());
    
    int ans = d.at(N/2) - d.at(N/2-1);
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#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 <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
#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(long long i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
 
#define MOD 1000000007

long long month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

long long checkd(long long y, long long m, long long d){
  if(y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)){
    month[2] = 29;
  }
  else{
    month[2] = 28;
  }
  
  if(m < 1 || m > 12){
    return 0;
  }

  if(d >= 1 && d <= month[m]){
    return 1;
  }

  return 0;
}

long long f(long long y, long long m, long long d){
  long long y1=1;
  long long m1=1;
  long long d1=1;
  long long week=0;
  long long ret = 0;
  long long dd = y/2800;
  y%=2800;
  y+=2800;
  for(;;){
    if(d1==13&&week==4)ret++;
    if(y==y1&&m==m1&&d==d1)break;
    if(checkd(y1,m1,d1)==0){
      if(m1==12){
        y1++;
        m1=1;
        d1=1;
      }
      else{
        m1++;
        d1=1;
      }
      continue;
    }
    else{
      d1++;
      week++;
      week%=7;
    }
  }
  return ret+4816*(dd-1);
}

long long f2(long long y, long long m, long long d){
  long long y1=1;
  long long m1=1;
  long long d1=1;
  long long week=0;
  y%=2800;
  y+=2800;
  for(;;){
    if(y==y1&&m==m1&&d==d1)break;
    if(checkd(y1,m1,d1)==0){
      if(m1==12){
        y1++;
        m1=1;
        d1=1;
      }
      else{
        m1++;
        d1=1;
      }
      continue;
    }
    else{
      d1++;
      week++;
      week%=7;
    }
  }
  return week;
}

int main(){
  long long y1,m1,d1,y2,m2,d2;
  cin>>y1>>m1>>d1>>y2>>m2>>d2;
  long long a = 0;
  if(d1==13&&f2(y1,m1,d1)==4)a=1;
  cout << f(y2,m2,d2)-f(y1,m1,d1)+a << endl;
  return 0;
}


Measured memory_bytes: 1156
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		int num = Integer.parseInt(sc.nextLine());
		int[] e = new int[num];
		for (int i = 0; i < num; i++) {
			e[i] = i + 1;
		}
		
		int lim = Integer.parseInt(sc.nextLine());
		for (int i = 0; i < lim; i++) {
			String[] params = sc.nextLine().split(",");
			int l = Integer.parseInt(params[0]) - 1;
			int r = Integer.parseInt(params[1]) - 1;
			
			int tmp = e[l];
			e[l] = e[r];
			e[r] = tmp;
		}
		
		for (int i = 0; i < num; i++) {
			System.out.println(e[i]);
		}
	}
}

Measured memory_bytes: 25816
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

#define MOD 1000000007

int main(){
    char s[100001];
    scanf("%s", s);
    int len = strlen(s);
    int dp[len+1][13];
    rep(i, 0, len+1){
        rep(j, 0, 13){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    rep(i, 1, len+1){
        if(s[i-1] == '?'){
            rep(j, 0, 13){
                rep(k, 0, 10){
                    dp[i][(j*10 + k) % 13] += dp[i-1][j];
                    dp[i][(j*10 + k) % 13] %= MOD;
                }
            }
        }else{
            rep(j, 0, 13){
                dp[i][(j*10 + (s[i-1]-'0')) % 13] += dp[i-1][j];
                dp[i][(j*10 + (s[i-1]-'0')) % 13] %= MOD;
            }
        }
        rep(j, 0, 13){
            dp[i][j] %= MOD;
        }
    }
    printf("%d", dp[len][5]);

    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <iomanip>

#define maxn 200010

using namespace std;



int main() {
    ios_base::sync_with_stdio(false);
    int n;
    string s, t;
    cin >> n >> s >> t;
    
    int ans = 0;
    for (int i = 0; i <= t.length(); ++i) {
        bool ok = true;
        for (int j = 0; j < i; ++j) {
            if (s.length()-i+j < 0 || t[j] != s[s.length()-i+j])
                ok = false;
        }
        if (ok) {
            ans = s.length() + t.length() - i;
        }
    }
    ans = max(ans, n);
    cout << ans;
}

Measured memory_bytes: 256
import collections
N,Q=map(int,input().split())
lc=[[] for i in range(N)]#二重リストで木を表現
for i in range(N-1):
    a,b=map(int,input().split())
    lc[a-1].append(b-1)
    lc[b-1].append(a-1)
lv=[0 for i in range(N)]#値のリスト
for i in range(Q):
    p,x=map(int,input().split())
    lv[p-1]+=x
lf=[0 for i in range(N)]#訪れたかどうか
#d=collections.deque([0])
#lp=[0]
lp=collections.deque([0])
lf[0]=1
#for i in range(N):
while len(lp)>0:
    #p=lp[-1]
    #p=lp.pop()
    p=lp.popleft()
    for c in lc[p]:
        if lf[c]==0:
            lv[c]+=lv[p]
            lf[c]=1
            lp.append(c)
for i in range(N-1):
    print(lv[i],end=" ")
print(lv[N-1])
#スタックだとリストかデキューかは関係ない


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

int main()
{
	int a, b;

	cin >> a >> b;

	if (b%3==0||a%3==0||(a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}

	else {
		cout << "Impossible" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,f[100][10],p[100][11],m[100],b=-1000000000;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            cin>>f[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<11;j++){
            cin>>p[i][j];
        }
    }
    for(int i=1;i<(1<<10);i++){
        for(int j=0;j<n;j++){
            m[j]=0;
        }
        for(int j=0;j<10;j++){
            if((1&(i>>j))==1){
                for(int k=0;k<n;k++){
                    if(f[k][j]==1){
                        m[k]++;
                    }
                }
            }else{
            }
        }
        int a=0;
        for(int j=0;j<n;j++){
            a+=p[j][m[j]];
        }
        b=max(a,b);
    }
    cout<<b<<endl;
}


Measured memory_bytes: 256
N = int(input())
count = [0,1]
if N == 1:
  print(1)
  exit()
for i in range(2,N+1):
  digit = len(str(i))
  head = int(str(i)[0])
  tail = int(str(i)[-1])
  plus = 0
  if digit == 1:
    plus=1
  elif digit == 2:
    if head == tail:
      plus = 3
    elif head>tail and tail>0:
      plus = 2
  elif tail>0:
    for j in range(digit-2):
      plus += 10**j*2
    if head == tail:
      mid = str(i)[1:-1]
      while len(mid)>1 and mid[0]=='0':
        mid = mid[1:]
      mid = int(mid)
      plus += 2*mid+1
      plus += 2
    elif head > tail:
      plus += 10**(digit-2)*2
  count.append(count[-1]+plus)
print(count[N])
      


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

int main(){
    long long int x;
    cin>>x;
    long long int ans=0;
    ans+=(x/11)*2;
    if(x%11==0){

    }
    else if(x%11<=6){
        ans+=1;
    }
    else{
        ans+=2;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
	
	int sum{0};
	string s;
	cin>>s;
	for(auto &i:s){
		sum+=i-'0';
	}
	if(sum%9){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3732
#include <cstdio>
#include <utility>
using namespace std;

int main(){
    int H,W;
    scanf("%d%d",&H,&W);

    char A[H][W];
    int bph[H*W];
    int bpw[H*W];
    int rp = -1;
    int count = 0;
    int dx[4] = {1,0,-1,0};
    int dy[4] = {0,1,0,-1};

    for(int i =0;i <H;i++){
        for(int j = 0;j <W;j++){
            scanf(" %c",&A[i][j]);
            if(A[i][j] == '#'){
                rp++;
                bph[rp] = i;
                bpw[rp] = j;
            }
        }
    }

    while(rp >= 0){
        int nbph[H*W];
        int nbpw[H*W];
        int nrp = -1;
        
        for(int i = 0;i <= rp;i++){
//            printf("bph = %d,bpw =%d\n",bph[i],bpw[i]);
            for(int j = 0;j < 4;j++){
                int nx = bph[i] + dx[j];
                int ny = bpw[i] + dy[j];
                if(0 <= nx && nx < H && 0 <= ny && ny < W ){
                    if(A[nx][ny] == '.'){
                        nrp++;
                        A[nx][ny] = '#';
                        nbph[nrp] = nx;
                        nbpw[nrp] = ny;
                    }
                }
            }
        }
        /*
        for(int i = 0;i<H;i++){
            for(int j = 0;j <W;j++){ 
                printf("%c",A[i][j]);
            }
            printf("\n");
        }
        */
        if(nrp == -1)break;
        rp = nrp;
        for(int i = 0;i <= rp;i++){
            bph[i] = nbph[i];
            bpw[i] = nbpw[i];
 //           printf("%d,%d\n",nbph[i],nbpw[i]);
        }
 //       printf("\n");
        count++;
    }

    printf("%d",count);

    return 0;
}



Measured memory_bytes: 13824
#include <iostream>
#include <stack>
#include <map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <string.h>

using namespace std;

// NG

int N, M;
int cut_max;

int main(int argc, char** argv) {
    cin >> M >> N;
    vector<pair<int, int>> ba(N);
    for (int i=0;i<N;i++) {
        pair<int, int> aa;
        cin >> aa.second;
        cin >> aa.first;
        ba[i] = aa;
    }
    sort(ba.begin(), ba.end());
    cut_max = -1;
    int ans = 0;
    for (int i=0;i<N;i++) {
        pair<int, int> aa = ba[i];
        int a = aa.second;
        int b = aa.first;
        if (cut_max < a)
        {
            cut_max = b - 1;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        Map<Integer, Integer> m = new HashMap<>();
        m.put(a, m.getOrDefault(a, 0) + 1);
        m.put(b, m.getOrDefault(b, 0) + 1);
        m.put(c, m.getOrDefault(c, 0) + 1);

        if (m.getOrDefault(5, 0) == 2 && m.getOrDefault(7, 0) == 1) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
inline int msbp(int x) {return 31-__builtin_clz(x);}
inline int msb(int x) {return 1 << msbp(x);}
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
// const int INF = 0x3f3f3f3f;
// const int INF = INT_MAX;
// const int nINF = INT_MIN;
// const ll INF = LLONG_MAX;
// const ll nINF = LLONG_MIN;

/////////////////////////////////////////////////////////////////////

const int N = 5e3+10;

int n, p[N], id[N];
ll dp[N][N], a, b;
// dp[i][j] - min cost to sort elts 1..i and leave elt i at [j-1, j)
// dp[i][j] = (min(dp[i-1][k]), k <= j) + (a when j <= id[i], 0 when j == id[i]-1, b when j > id[i])

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    memset(dp, INF, sizeof(dp));
    cin >> n >> a >> b;
    REP(i, n) {
    	cin >> p[i];
    	id[p[i]] = i;
    }
    FOR(i, 0, n) dp[0][i] = 0;
    FOR(i, 1, n) {
    	ll mn = INF;
    	int cur_id = id[i];
    	FOR(j, 0, n) {
    		mn = min(mn, dp[i-1][j]);
    		ll cost;
    		if(cur_id == j-1) cost = 0;
    		else if(cur_id > j-1) cost = b;
    		else cost = a;
    		dp[i][j] = mn+cost;
    	}
    }
    ll ans = INF;
    FOR(i, 0, n) ans = min(ans, dp[n][i]);
    cout << ans << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE) CHECK IF IT SHOULD BE 2*N!!!!
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - negative arithmetic, ceiling division, modulo (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting max to 0 instead of -INF/min to 0 instead of INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)
// - round announcements (WA)
// - multiset::erase (WA)
// - forgetting to rename recursive call when copy/pasting recursive function (WA)
// - not clearing DS between test cases EVEN FOR INPUT (WA, RTE, TLE, MLE)


Measured memory_bytes: 199760
import java.util.Scanner;

class Main{
	public static void main(String[] ag) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		long[][] chkp=new long[M][2];
		long[][] hito=new long[N][2];

		for(int i=0; i<N; i++) {
			hito[i][0]=sc.nextLong();
			hito[i][1]=sc.nextLong();
		}

		for(int i=0; i<M; i++) {
			chkp[i][0]=sc.nextLong();
			chkp[i][1]=sc.nextLong();
		}

		long dist_min=114514810114514810L;
		long tmp=0;
		int kekka=0;
		for(int i=0; i<N; i++) {
			dist_min=114514810114514810L;
			for(int j=0; j<M; j++) {
				tmp=Math.abs(chkp[j][0]-hito[i][0])+Math.abs(chkp[j][1]-hito[i][1]);
				if(tmp<dist_min) {
					dist_min=tmp;
					kekka=j+1;
				}
			}
			System.out.println(kekka);
		}
	}
}

Measured memory_bytes: 22608
#include <iostream>


int euclidGCD (long a, long b) {
    if (b == 0) return a;
    return euclidGCD(b, a%b);
}

long long lcm(long long a, long long b) {
    return (a * b)/euclidGCD(a, b);
}

int main() {
    long long a, b;
    std::cin >> a >> b;
    std::cout << lcm(a, b) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using ll = long long;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

struct edge { ll from, to, cost; };
edge es[500005];
ll d[1005],n,m;

int main() {
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        cin >> es[i].from >> es[i].to >> es[i].cost;
        es[i].cost = -es[i].cost;
    }

    for (int i = 1; i <= n; i++) d[i] = LLINF;
    d[1] = 0;

    for (int i = 1; i <= n - 1; i++) {
        for (int j = 1; j <= m; j++) {
            edge e = es[j];
            if (d[e.from] == INF) continue;
            if (d[e.to] > d[e.from] + e.cost) d[e.to] = d[e.from] + e.cost;
        }
    }
    
    ll ans = d[n];

    bool negative[1005];
    for (int i = 0; i <= n; i++) negative[i] = false;

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            edge e = es[j];
            if (d[e.from] == INF) continue;
            if (d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                negative[e.to] = true;
            }
            if (negative[e.from] == true) negative[e.to] = true;
        }
    }

    if (negative[n]) cout << "inf"<<endl;
    else cout << -ans << endl;
    return 0;
}


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

int main(){
  int a,b,c,m;
  scanf("%d %d %d",&a,&b,&c);
  m=a;
  if(m<b) m=b;
  if(m<c) m=c;
  if(a+b+c==2*m) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 1628
from fractions import gcd
import math
def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    x =input()
    n = len(x)
    s = 0
    ans = 0
    for i in range(n):
        if x[i] == 'S':
            s +=1
        elif s > 0:
            s -= 1
            ans += 1
    print(n-ans*2)

main()


Measured memory_bytes: 5624
/*
 * FileName:     unique
 * CreatedDate:  2020-06-09 13:55:12 +0900
 * LastModified: 2020-06-09 14:00:33 +0900
 */

#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n;scanf("%d",&n);
    int *a = malloc(n*sizeof(int));
    int *box = malloc(n*sizeof(int)),count=0;
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
        if(i==0){
            box[count++]=a[0];
        }
        if(i>0){
            if(a[i]!=a[i-1]){
                box[count++]=a[i];
            }
        }
    }
    printf("%d",a[0]);
    for(int i=1;i<count;i++)printf(" %d",box[i]);
    printf("\n");
    return 0;
}



Measured memory_bytes: 2504
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
const ll mo = 1e10 +7;
const int M = 100+50;
const ll mod = 998244353;
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	printf("%d\n",a*b/2);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
    size_t N, T;
    scanf("%zu %zu", &N, &T);

    map<int, size_t> d;
    int min_=1e9+7;
    for (size_t i=0; i<N; ++i) {
        int A;
        scanf("%d", &A);

        if (min_ > A)
            min_ = A;

        if (min_ != A)
            ++d[A-min_];
    }

    printf("%zu\n", d.rbegin()->second);
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/



int main()
{
	ll a, b, c;
	cin >> a >> b >> c;
	if (b >= c) {
		s = "delicious";
	} else if (a + b >= c) {
		s = "safe";
	} else {
		s = "dangerous";
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int a,b;
    cin >> a >>b;
    cout << a/b << endl;
    cout << a%b << endl;
    CST(8) << double(a)/b << endl;
    return 0;
}


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

int main(void){
    ll N;
    cin >> N;
    string S[N+10];
    rep(i,N) cin >> S[i];
    int c1=0,c2=0,c3=0,c4=0;
    rep(i,N){
        if(S[i] == "AC") c1++;
        if(S[i] == "WA") c2++;
        if(S[i] == "TLE") c3++;
        if(S[i] == "RE") c4++;
    }
    cout << "AC x " << c1 << endl;
    cout << "WA x " << c2 << endl;
    cout << "TLE x " << c3<<endl;
    cout << "RE x " << c4 << endl;
    return 0;
}

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

int main(void){
  int s, x;
  vector<int> a;
  cin >> s;
  a.push_back(s);

  for(int i = 2;; i++){
    if(s%2 == 0) x = s/2;
    else x = 3*s+1;

    if(count(a.begin(), a.end(), x) >= 1){
      cout << i << endl;
      return 0;
    }

    a.push_back(x);
    s = x;
  }
}


Measured memory_bytes: 256
#include<cstdio>

long x;
long fv[200];

long fi(int x) {
    return static_cast<long>(x) * x * x * x * x;
}

int main() {
    scanf("%ld", &x);
    for (int i = 0; i < 200; i++) fv[i] = fi(i);
    int a = 0, b = 0;
    for (int i = 1; i < 200; i++) {
        if (fv[i] * 2 < x) continue;
        int l = -i, r = i;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            long y = (mid < 0) ? -fv[-mid] : fv[mid];
            if (fv[i] - y >= x) l = mid;
            else r = mid;
        }
        long y = (l < 0) ? -fv[-l] : fv[l];
        if (fv[i] - y == x) {
            a = i;
            b = l;
            break;
        }
    }
    printf("%d %d\n", a, b);
    return 0;
}


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

int main() {
  int TH, TA, AH, AA;
  cin >> TH >> TA >> AH >> AA;
  
  int i = 0;
  while(i < 101) {
    AH -= TA;
    if(AH <= 0) {
      cout << "Yes" << endl;
      break;
    }
    TH -= AA;
    if(TH <= 0) {
      cout << "No" << endl;
      break;
    }
    i++;
  }
}

Measured memory_bytes: 3588
/* ex3_4
   offNaria */
#include <stdio.h>

int main(void){
  int N, judge; //整数N,judgeを定義
  judge = 0;
  scanf("%d", &N); //入力を変数に代入
  for(int i = 1; i < 10; i++){
    for (int j = 1; j < 10; j++)
    {
      if(N == i * j){
        judge = 1;
        break;
      }
    }
  }
  if(judge == 1){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

max_digit = (10**12).to_s(2).size
digit = m.to_s(2).size
upper = max_digit + 1 - digit
dp = Array.new(max_digit + 1) { Array.new(2) { 0 } }
one_count = Array.new(max_digit) { 0 }
a.each { |e| max_digit.times { |i| one_count[i] += e[max_digit - 1 - i] } }

max_digit.times do |i|
  0.upto(i < upper ? 0 : 1) do |j|
    d = m[max_digit - 1 - i]
    0.upto(j == 0 ? d : 1) do |k|
      tmp = k == 0 ? one_count[i] : n - one_count[i]
      idx = j == 1 || k < d ? 1 : 0
      dp[i + 1][idx] = [dp[i + 1][idx], dp[i][j] + tmp * 2**(max_digit - 1 - i)].max
    end
  end
end

puts [dp[max_digit][0], dp[max_digit][1]].max


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

int main(){
	int x, y;


	while (1){
		cin >> x >> y;

		if (x == 0 && y == 0)
			break;

		if (x < y)
			cout << x << " " << y << endl;
		else
			cout << y << " " << x << endl;


	}
	return 0;
}

Measured memory_bytes: 1160
import sys

# 文字列の読み込み&変換
st = input()
fl = [ int(x) for x in st]

N = len(st)

# 奇数番目の総和と偶数番目の総和を計算
sgn = 1
# sgn = 0 even 0, 2, 4,  
# sgn = 1 odd 1, 3, 5,
fl_sum = [0.0, 0.0]
len_sum = [0, 0]

for i in range(N):
  sgn = int(sgn - (-1)**float(i)) 
  fl_sum[sgn] += fl[i]
  len_sum[sgn] += 1

# 総和の小さい方をすべて0に変える
# 総和の大きい方をすべて1に変える
# のに必要な手数を計算
if fl_sum[0] <= fl_sum[1]:
  x = 0
  y = 1
else:
  x = 1
  y = 0
# すべてを
num = int(fl_sum[x] + (len_sum[y] - fl_sum[y]))
print(num)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        int temp = a;
        a = b;
        b = temp;
    }
    for (int i = 0; i < b; i++) {
        cout << (char)('0' + a);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3624
S = input()
ans = 0
tmp = {"A","C","G","T"}
for i in range(len(S)):
    for j in range(i+1,len(S)+1):
        part = S[i:j]
        for s in set(part):
            if s not in tmp:
                break
        else:
            if len(part) > ans:
                ans = len(part)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> bs(n);
    for(int i=0; i<n; ++i){
        cin >> bs[i];
        if(bs[i]>i+1){
            cout << -1 << endl;
            return 0;
        }
    }
    vector<int> ans(n);
    for(int i=n-1; i>=0; --i){
        int k;
        for(int j=i; j>=0; --j){
            if(bs[j]==j+1){
                k=j;
                break;
            }
        }
        ans[i]=bs[k];
        for(int j=k; j<i; ++j){
            bs[j]=bs[j+1];
        }
    }
    for(int i=0; i<n; ++i){
        cout << ans[i] << endl;
    }
    return 0;
}


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

int main(){
  int n, k; cin >> n >> k;
  vector<int> a(n); rep(i, n) cin >> a[i];
  a.push_back(0); a.push_back(1000000010);
  sort(a.begin(), a.end());
  int low = 0; int high = n+1;
  while(high - low > 1){
    int mid = (high + low) / 2;
    bool dp[5010][5010];
    rep(i, 5010)rep(j, 5010) dp[i][j] = false;
    dp[0][0] = true;
    rep(i, n+2)rep(j, k){
      dp[i+1][j] = dp[i][j] || dp[i+1][j];
      if(i != mid && j+a[i] < k) dp[i+1][j+a[i]] = dp[i][j];
    }
    bool flag = false;
    if(a[mid] >= k) flag = true;
    else{
      For(j, k-a[mid], k)if(dp[n+2][j]){
        flag = true;
        break;
      }
    }
    if(flag) high = mid;
    else low = mid;
  }
  cout << high - 1 << endl;
}

Measured memory_bytes: 24832
#include <iostream>

using namespace std;

int n, a[105];
bool ans;
int main()
{
    cin >> n;
    for(int i =0;i < n; i++)
    {
        cin >> a[i];
    }
    ans = true;
    for(int i =0; i < n; i++)
    {
        if(a[i] % 2 == 0)
        {
            if(a[i] % 3 !=0 && a[i] % 5 != 0)
            {
                ans = false;
                break;
            }
        }
    }
    if (ans)
    {
        cout << "APPROVED" << endl;
    }
    else cout << "DENIED" << endl;
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if( a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int v[2010][2010];
int p[2010][2010];
int main(){
  //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    int N,M;
    cin>>N>>M;
    string a;
    for(int i=0;i<N;i++){
      cin>>a;
      int o=0;
      for(int j=0;j<M;j++){
        if(a[j]=='#'){
          v[i][j]=0;
          o=0;
        }else{
            o++;
          v[i][j]=o;
        }
      }
      int prec=0;
      for(int j=M-1;j>=0;j--){
        if(v[i][j]==0){
          prec=0;
          continue;
        }
        v[i][j]=max(prec,v[i][j]);
        prec=v[i][j];
      }
    }
    for(int i=0;i<M;i++){
        int o=0;
        for(int j=0;j<N;j++){
            if(v[j][i]>0)o++;
            else o=0;
            p[j][i]=o;
        }
    }
    for(int i=0;i<M;i++){
        int prec=0;
        for(int j=N-1;j>=0;j--){
            if(p[j][i]==0)prec=0;
            p[j][i]=max(p[j][i],prec);
            prec=p[j][i];
        }
    }
    int ma=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            if(v[i][j]+p[i][j]>ma)ma=v[i][j]+p[i][j];
        }
    }
    cout<<ma-1;
    return 0;
}


Measured memory_bytes: 31744
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i <= r; i++){
        if(i % d == 0) ans++;
    }

    cout << ans << endl;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3192
#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>;

vector<vector<int>> a(0, vector<int>(0));
vector<vector<int>> b(0, vector<int>(0));
int zre(int n){
    a.push_back({1});
    rep(ii, n-1){
    int k = a.size();
    int l = a.at(0).size();
    rep(i, k) a.at(i).push_back(l+1);
    rep(i, k){
      rep(j, l+1){
        b.push_back({});
        rep(m, l+1) b.at(i*(l+1)+j).push_back(a.at(i).at((m+j)%(l+1)));
      }
    }
    while(a.size() != 0){
      a.pop_back();
    }
    rep(i, b.size()) a.push_back(b.at(i));
    while(b.size() != 0){
      b.pop_back();
    }
  }
  sort(a.begin(), a.end());
  return 0;
}

int main(){
    int n;
    cin >> n;
    zre(n);
    vector<vector<int>> za(n, vector<int>(2));
    rep(i, n) cin >> za.at(i).at(0) >> za.at(i).at(1);
    long double kyo = 0;
    long double sig = 0;
    rep(i, a.size()){
        kyo = 0;
        rep(j, n-1){
            kyo += sqrt(pow(za.at(a.at(i).at(j)-1).at(0) - za.at(a.at(i).at(j+1)-1).at(0), 2) + pow(za.at(a.at(i).at(j)-1).at(1) - za.at(a.at(i).at(j+1)-1).at(1), 2));
        }
        sig += kyo;
    }
    sig /= a.size();
    cout << fixed << setprecision(10) << sig << endl;
    return 0;
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;
using namespace atcoder;

typedef long long ll;

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; }

ll op(ll a, ll b){ return max(a, b);};
ll e(){ return -1ll;};

ll v;
ll f(ll x){ return x < v;};

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

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

	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	segtree<ll, op, e> seg(a);
	rep(i, q){
		int t;
		cin >> t;
		if(t == 1){
			ll x;
			cin >> x >> v;
			x--;
			seg.set(x, v);
		}else if(t == 2){
			ll l, r;
			cin >> l >> r;
			l--; r--;
			cout << seg.prod(l, r + 1) << endl;
		}else{
			ll x;
			cin >> x >> v;
			x--;
			cout << seg.max_right(x, f) + 1 << endl;
		}
	}
}


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

int main() {
  char c;
  cin >> c;

    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'  ) {
      cout << "vowel" << endl;
    }
    else {
      cout << "consonant" << endl;
    }
  }

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

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if(x->right != NIL) return treeMinimum(x->right);
  Node y;
  y = x->p;
  while(y !=NIL && x == y->right){
    x = y;
    y = y->p;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->p = y->p;

  if(y->p == NIL) root = x;
  else if(y == y->p->left) y->p->left = x;
  else y->p->right = x;

  if(y != z) z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->p = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u)
{
  if(u != NIL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
  else return;
}

void preorder(Node u){
  if(u != NIL){
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
  }
  else return;
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20492
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    cout << pow(n,3);

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    """Function."""
    n = int(input())
    a = list(map(int, input().split()))

    o_count, e_count = 0, 0
    for i in range(n):
        if a[i] % 2 == 0:
            e_count += 1
        else:
            o_count += 1

    if o_count == 0:
        print("YES")
    elif e_count == 0:
        if o_count % 2 == 0:
            print("YES")
        else:
            print("NO")
    else:
        if o_count % 2 == 0:
            print("YES")
        else:
            print("NO")


if __name__ == "__main__":
    main()


Measured memory_bytes: 14108
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
bool compare(pair<int,int>a,pair<int,int>b){
    if(a.first==b.first)return a.second<b.second;
    else return a.first<b.first;
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
    }
    sort(a.begin(),a.end(),compare);
    int count=1;
    priority_queue<int> que;
    for(int i=0;i<m;i++){
        que.push(0);
    }
    int sum=0;
    int buf=0;
    for(int i=1;i<=m;i++){
        for(int j=buf;a[j].first<=i;j++){
            que.push(a[j].second);
            buf++;
        }
        sum+=que.top();
        que.pop();
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 2168
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]
ans = []

for i in range(N):
    index = 0
    lowest = pow(10, 8) * 4
    for j in range(M):
        dist = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if lowest > dist:
            lowest = dist
            index = j
    print(index + 1)


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

int main(){
  int seisu[3];
  cin >> seisu[0] >> seisu[1] >> seisu[2];
  sort(seisu,seisu+3);
  cout << seisu[0] << " " << seisu[1] << " " << seisu[2] << endl; 
  return 0;
}
  

Measured memory_bytes: 1180
# coding:utf-8


def main():
    N = int(input())
    A = list(map(int, input().split()))

    mul = 1
    for Ai in A:
        mul *= Ai

    mulA = []
    sumA = 0
    for Ai in A:
        temp = mul/Ai
        mulA.append(mul/Ai)
        sumA += temp

    ans = mul/sumA
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy



bool IsDistInt(const ll* a, const ll* b, int size){
  ll sum = 0;
  F0R(i,size) sum += (a[i] - b[i])*(a[i] - b[i]);
  int x = sqrt(sum);
  return x*x == sum;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n,d;
    cin >> n >> d ;
    ll a[n][d];
    F0R(i,n)
      F0R(j,d)
        cin >> a[i][j];
    int res = 0;
    F0R(i,n)
      FOR(j,i+1,n)
        if(IsDistInt(a[i],a[j],d))
          ++res;
    cout << res;





    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
 
#define IS_DEBUG true
 
#define DEBUG_OUTPUT(X) if (IS_DEBUG) cout << X << endl
#define RESULT_OUTPUT(X) cout << X << endl
 
int main()
{
	int N;
	cin >> N;
 
  	vector<int> A;
	for (int i = 0; i < N; i++)
    {
      int a;
      cin >> a;
      A.push_back(a);
    }
  
  int now = 1;
  for (int i = 1; i <= N; i++)
  {
    now = A[now - 1];
    if (now == 2)
    {
      RESULT_OUTPUT(i);
      return 0;
    }
  }
 
  RESULT_OUTPUT(-1);
  
	if (IS_DEBUG)
	{
		int end;
		cin >> end;
	}
	return 0;
}

Measured memory_bytes: 892
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int count=0;
        int n=sc.nextInt();
        int mini=200001;
        for(int i=0;i<n;i++){
            int p=sc.nextInt();
            if(mini>=p)count++;
            mini=(int)Math.min(p,mini);
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 62872
let rec aux n k =
  if n mod k = 0
  then aux (n / k) k
  else n

let rec solve n k ans =
  if n = k * k
  then ans + 1
  else if n < k * k
  then ans
  else
    solve n (k + 1) @@
    ans +
    if n mod k = 0
    then (if aux n k mod k = 1 then 1 else 0) + (if aux n (n / k) mod (n / k) = 1 then 1 else 0)
    else if (n - 1) mod k = 0
    then 1 + (if n - 1 = k * k || n mod ((n - 1) / k) = 0 && aux n ((n - 1) / k) mod ((n - 1) / k) <> 1 then 0 else 1)
    else 0
let solve = function
  | 2 -> 1
  | n -> solve n 2 2

let () = Printf.printf "%d\n" @@ Scanf.scanf "%d" solve

Measured memory_bytes: 2432