akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
struct edge{
    int to,cost;
    edge(int a,int b){
        to=a;cost=b;
    }
    edge(){}
};
struct data{
    int stay,cost;
    data(int a,int b){
        stay=a;cost=b;
    }
    data(){}
    bool operator>(const data &d)const{
        return cost>d.cost;
    }
};
vector<vector<edge> >V;
int dijkstra(int Start,int End){
    int d[100];
    const int INF=1e9;
    priority_queue<data,vector<data>,greater<data> >Q;
    Q.push(data(Start,0));
    fill(d,d+100,INF);
    d[Start]=0;
    while(Q.size()){
        data a=Q.top();Q.pop();
        int stay=a.stay,cost=a.cost;
        if(d[stay]<cost)continue;
        d[stay]=cost;
        for(int i=0;i<V[stay].size();i++){
            edge e=V[stay][i];
            if(d[e.to]>d[stay]+e.cost)
                Q.push(data(e.to,d[stay]+e.cost));
        }
    }
    return (d[End]!=INF)?d[End]:-1;
}
int main(){
    int n,k;
    while(cin>>n>>k,n||k){
            V.clear();
        vector<int>ans;
        V.resize(n);
        while(k--){
            int f;
            cin>>f;
            if(f){
                int a,b,c;
                cin>>a>>b>>c;
                a--;b--;
                V[a].push_back(edge(b,c));
                V[b].push_back(edge(a,c));
            }
            else{
                int s,e;
                cin>>s>>e;
                s--;e--;
                //cout<<dijkstra(s,e)<<endl;
                ans.push_back(dijkstra(s,e));
            }
        }
        for(int i=0;i<ans.size();i++)cout<<ans[i]<<endl;
    }
    return 0;
}

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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;

#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

int main(){
    ll A,B;
    cin >> A >> B;
    ll x = A*B;
    if(A<B){
        swap(A,B);
    }
    ll r = A % B;
    while(r!=0){
        A = B;
        B = r;
        r = A%B;
    }
    cout << x/B << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
#define PII pair<int,int>
#define FF first
#define SS second
#define PB push_back
#define all(x) x.begin(), x.end()

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;	
#define vi vector<int> 
#define vl vector<ll> 
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define maxn 1000015
const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};
	
const int MAXN = 3*1e5+10;
const int NINF = -1e5;
const int INF = 20000000;

  
  
void solve()
{
	int n;
	cin>>n;
	cout<<0+(n==0)<<endl;
	return;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())

max1 = 0
max2 = 0
maxindex = -1

for i in range(n):
    a = int(input())
    if a >= max1:
        max2 = max1
        max1 = a
        maxindex = i
    elif a >= max2:
        max2 = a

out = [max1] * n
out[maxindex] = max2

for m in out:
    print(m)


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll N;
ll ans = 0;

void dfs(ll a, ll b, ll c, ll now){
    if(now > N) return;
    if(a==1 & b==1 & c==1) ans++;

    dfs(1, b, c, 10*now+3);
    dfs(a, 1, c, 10*now+5);
    dfs(a, b, 1, 10*now+7);
} 
int main()
{
    cout << fixed << setprecision(15);
    cin >> N;
    
    dfs(0, 0, 0, 0);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int c[4][4];
  for(int i=1; i<=3; ++i)
    for(int j=1; j<=3; ++j) 
      cin >> c[i][j];
  int a = c[1][1] - c[2][1], b = c[2][1] - c[3][1], k = c[3][1] - c[1][1];
  if((a != c[1][2] - c[2][2]) || (a!= c[1][3] - c[2][3]))
    cout << "No\n";
  else if((b != c[2][2] - c[3][2]) || (b != c[2][3] - c[3][3]))
    cout << "No\n";
  else if((k != c[3][2] - c[1][2]) || (k != c[3][3] - c[1][3]))
    cout << "No\n";
  else
    cout << "Yes\n";
  return 0; 
}



Measured memory_bytes: 384
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */



import java.util.* ;

/**
 *
 * @author nai
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception{
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        String[] S = new String[N];
        
        for(int i = 0 ; i < N ; i++){
            S[i] = sc.next();
        }
        
        Arrays.sort(S);
        StringBuilder sb = new StringBuilder();
        for(int i = 0 ; i < N ; i++){
            sb.append(S[i]);
        }
        System.out.println(sb);
    }
  }
    



Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

vector<int> ans;
int n;
int p[2000];
int a[2000];
int r[2000];
vector<int> child[2000];
int del[2000];

void query(int x) {
    if (x == 0) return;
    ans.push_back(x);
    int v = a[0];
    vector<int> qs;
    for (int i = x; i > 0; i = p[i]) {
        qs.push_back(i);
    }
    for (int i = qs.size(); i--; ) {
        int j = qs[i];
        a[p[j]] = a[j];
    }
    a[x] = v;
    
    r[a[0]] = 0;
    for (int i = qs.size(); i--; ) {
        int j = qs[i];
        r[a[j]] = j;
    }
}

int getMax(int x, int p) {
    int mx = -1;
    for (int i : child[x]) {
        if (del[i]) continue;
        int ret = getMax(i, p);
        if (ret == -1) continue;
        if (mx < 0 || a[mx] < a[ret]) mx = ret;
    }
    if (mx < 0 && p < a[x]) return x;
    return mx;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i < n; ++i) {
        cin >> p[i];
        child[p[i]].push_back(i);
	}
	
	for (int i = 0; i < n; ++i) {
        cin >> a[i];
        r[a[i]] = i;
	}
	
	for (int i = n; i--; ) {
        while (a[0] != i) {
            int x = getMax(r[i], a[0]);
            query(x);
        }
        query(i);
        del[i] = 1;
	}
	
	printf("%d\n", (int)ans.size());
	for (int i : ans) {
        printf("%d\n", i);
	}
	return 0;
}


Measured memory_bytes: 640
import collections
N = int(input())
blue = [list(input().split()) for i in range(N)]
M = int(input())
red = [list(input().split()) for i in range(M)]
sum =0
for i in blue:
    score = blue.count(i) - red.count(i)
    if score>sum:
        sum = score
print(sum)

Measured memory_bytes: 3316
void main()
{
    string s = rdStr;

    long len = s.length;
    long l, r = len - 1;
    long cnt;
    while (l < r)
    {
        if (s[l] == s[r])
        {
            ++l, --r;
        }
        else
        {
            if (s[l] == 'x')
            {
                ++cnt;
                ++l;
            }
            else if (s[r] == 'x')
            {
                ++cnt;
                --r;
            }
            else
            {
                writeln(-1);
                return;
            }
        }
    }

    cnt.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 2428
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

int main() {
    ll n, k; cin >> n >> k;
    cout << min(n % k, abs(n % k - k)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }




int N, M;
long long X;
vector<long long> C;
vector<vector<long long> > A;
const long long INF = 1LL<<60;

int main() {
    while (cin >> N >> M >> X) {
        C.resize(N);
        A.assign(N, vector<long long>(M, 0));
        for (int i = 0; i < N; ++i) {
            cin >> C[i];
            for (int j = 0; j < M; ++j) cin >> A[i][j];
        }
        long long res = INF;
        for (int bit = 0; bit < (1<<N); ++bit) {
            bool ok = true;
            vector<long long> g(M, 0);
            long long score = 0;
            for (int i = 0; i < N; ++i) {
                if (bit & (1<<i)) {
                    score += C[i];
                    for (int j = 0; j < M; ++j) g[j] += A[i][j];
                }
            }
            for (int i = 0; i < M; ++i) {
                if (g[i] < X) ok = false;
            }
            if (ok) {
                chmin(res, score);
            }
        }
        cout << (res < INF ? res : -1) << endl;
    }
}

Measured memory_bytes: 3640
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char
import Data.Ord
import Data.Array.IO

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete



main = do
    ws <- words <$> getLine
    let freq = head $ maximumBy (comparing length) $ group $ sort ws
    let long = maximumBy (comparing length) $ ws
    putStrLn $ unwords [freq, long]

Measured memory_bytes: 3528
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  long L[n + 1];
  L[0] = 2;
  L[1] = 1;
  for(int i = 2; i <= n; i++) L[i] = L[i - 1] + L[i - 2];
  cout << L[n] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
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();
        int k = sc.nextInt();
        int sum = 0;
        sc.close();

            for(int i= 0; i < k; i++){
                
                if(a>0){
                    sum++;
                    a--;
                }else if(b>0){
                    b--;
                }else{
                    sum--;
                    c--;
                }
            }
            System.out.println(sum);

    } 
}

Measured memory_bytes: 27184
#include <bits/stdc++.h>
using namespace std;
const long long int INT=pow(10,9)+7;
 
int main() {
  long long int N;
  cin>>N;
  vector<long long int> primes={2};
  for(int i=3;i<=1000;i+=2){
    for(int j=2;j<i;j++){
      if(i%j==0){break;}
      if(j==i-1){primes.push_back(i);}
    }
  }
  vector<long long int> pd(1000);
  for(int i=2;i<=N;i++){
    for(int p:primes){
      long long int tmp=i;
      while(tmp%p==0){
        tmp/=p;
        pd.at(p)++;
      }
    }
  }
  long long int ans=1;
  for(int i=0;i<pd.size();i++){
    ans*=(pd.at(i)+1);
    ans%=1000000007;
  }
  cout<<ans%1000000007<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=2e5+5;
ll n,x,y;
vector<ll> v1,v2,v3,v4;
bool cmp(ll a,ll b){
    return a>b;
}
int main() {
	n=read();
	for(int i=1;i<=n;i++){
        x=read(),y=read();
        v1.push_back(x+y);
        v2.push_back(-x-y);
        v3.push_back(x-y);
        v4.push_back(-x+y);
	}
	sort(v1.begin(),v1.end(),cmp);
	sort(v2.begin(),v2.end(),cmp);
	sort(v3.begin(),v3.end(),cmp);
	sort(v4.begin(),v4.end(),cmp);
	printf("%lld\n",max(v1[0]+v2[0],v3[0]+v4[0]));
	return 0;
}


Measured memory_bytes: 9664
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
bool bad[100001];
int dp[100001];
int madd (int a, int b) {
  int sum = a + b;
  return sum >= MOD ? sum-MOD : sum;
}
int main() {
  int n,m,a;
  scanf ("%d %d",&n,&m);
  while (m--) {
    scanf ("%d",&a);
    bad[a] = 1;
  }
  dp[0] = 1;
  for (int x = 1; x <= n; x++) {
    if (bad[x]) continue;
    dp[x] = madd(dp[x-1],dp[x-2]);
  }
  printf ("%d\n",dp[n]);
  return 0;
}


Measured memory_bytes: 768
import numpy as np

stdin = np.fromstring(open(0).read(), np.int64, sep=' ')
N = stdin[0]
XL = stdin[1:].reshape(-1, 2).T
x = XL[0]
l = XL[1]
arg = np.argsort(x)
x = x[arg]
l = l[arg]
xleft = x - l
xright = x + l

count = 0
i = 0
while i < N - 1:
    for j in range(i + 1, N):
        if xright[i] > xright[j]:
            count += 1
            i = j
            break
        if xright[i] > xleft[j]:
            count += 1
            j = j + 1
        else:
            i = j
            break
    else:
        i = N - 1

print(N - count)

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

int main() {
  int N, tmp, cont;
  cin >> N;
  
  tmp = 0;
  for(int i=1; i<=9; i++) {
    cont = i*100 + i*10 + i;
    if(tmp<N && cont>=N) {
      cout << cont << endl;
      break;
    } else {
      tmp = cont;
    }
  }
  
  return 0;
}

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

int main() {
  std::map<std::string, int> st;
  int N;
  std::string S;
  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> S;
    ++st[S];
  }
  int mc = 0;
  for(auto s: st) mc = std::max(mc, s.second);
  std::vector<std::string> v;
  for(auto s: st) if(s.second == mc) v.push_back(s.first);
  std::sort(v.begin(), v.end());
  for(auto s: v) std::cout << s << std::endl;
  return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


typedef pair<int, int> p;

int main(){
  int h, w, n;
  scanf("%d %d %d", &h, &w, &n);

  vector<p> v;
  int a, b;
  REP (i, n) {
    scanf("%d %d", &a, &b);
    REP (j, 3) REP (k, 3) {
      if (1 <= a - j && a - j <= h - 2 && 1 <= b - k && b - k <= w - 2) {
        v.push_back(make_pair(a - j, b - k));
      }
    }
  }

  sort(v.begin(), v.end());

  LL ans[10];
  REP (i, 10) ans[i] = 0;

  int i = 0;
  int j = 0;
  while (i < int(v.size())) {
    if (v[i].first == v[j].first && v[i].second == v[j].second) j++;
    else {
      ans[j - i]++;
      i = j;
    }
  }

  LL sum = 0;
  REP (i, 10) sum += ans[i];

  ans[0] = (LL)(h - 2) * (LL)(w - 2) - sum;

  REP (i, 10) printf("%lld\n", ans[i]);
}


Measured memory_bytes: 10348
#include <stdio.h>

#define debug
#define NMAX 100010
#define NIL -1

int L[NMAX];
int R[NMAX];
int P[NMAX];
int D[NMAX];
int H[NMAX];

void setDepth(int i, int d) {
    if (i == NIL) {
        return;
    }
    D[i] = d;
    setDepth(L[i], d + 1);
    setDepth(R[i], d + 1);
}

int setHeight(int i) {
    int h1 = 0, h2 = 0;
    if (L[i] != NIL) {
        h1 = 1 + setHeight(L[i]);
    }
    if (R[i] != NIL) {
        h2 = 1 + setHeight(R[i]);
    }
    H[i] = (h1 > h2 ? h1 : h2);
    return H[i];
}

int main() {
    int n, id, left, right;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        P[i] = NIL;
        L[i] = NIL;
        R[i] = NIL;
    }
    for (int i = 0; i < n; i++) {
        scanf("%d %d %d", &id, &left, &right);
        if (left != NIL) {
            L[id] = left;
            P[left] = id;
        }
        if (right != NIL) {
            R[id] = right;
            P[right] = id;
        }
    }
    int root = 0;
    for (int i = 0; i < n; i++) {
        if (P[i] == NIL) {
            root = i;
            break;
        }
    }
    setDepth(root, 0);
    setHeight(root);
    for (int i = 0; i < n; i++) {
        printf("node %d: ", i);
        printf("parent = %d, ", P[i]);
        if (P[i] != NIL) {
            printf("sibling = %d, ", R[P[i]] == i ? L[P[i]] : R[P[i]]);
        } else {
            printf("sibling = -1, ");
        }
        int cnt = 0;
        if (L[i] != NIL)
            cnt++;
        if (R[i] != NIL)
            cnt++;
        printf("degree = %d, ", cnt);
        printf("depth = %d, ", D[i]);
        printf("height = %d, ", H[i]);
        if (P[i] == NIL) {
            printf("root");
        } else if (L[i] == NIL && R[i] == NIL) {
            printf("leaf");
        } else {
            printf("internal node");
        }
        printf("\n");
    }

    return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll a,b,v,w;
    ll t;
    cin >> a >> v >> b >> w;
    cin >> t;
    if(w >= v){
        cout << "NO" << endl;
    }else{
        if(abs(b-a) <= t*(v-w)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;

long long a,b,c,s;
int main(){
	cin>>a>>b>>c;
	while(!(a&1)&&!(b&1)&&!(c&1)){
		s++;
		int ta=a/2,tb=b/2,tc=c/2;
		a=tb+tc;b=ta+tc;c=ta+tb;
		if(s>1000000){
			puts("-1");
			return 0;
		}
	}
	cout<<s<<endl;
	return 0; 
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


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

class AAC {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);

        string s;
        cin >> s;

        if (s == "ABC"){
            cout << "ARC" ;
        }else{
            cout << "ABC" << endl;
        }
	}
};


int main() {
	AAC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int prime[1000];
bool is_prime[1001];
int sieve(int n){
	int p=0;
	for(int i=0;i<=n;i++)
		is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++]=i;
			for(int j=2*i;j<=n;j+=i)
				is_prime[j]=false;
		}
	}
	return p;
}
int mod_fact(int n,int p){
	if(n==0)
		return 0;
	int res=mod_fact(n/p,p);
	res+=n/p;
	return res;
}
int main(){
	int n;
	cin>>n;
	int p=sieve(n);
	long long ans=1;
	for(int i=0;i<p;i++)
		(ans*=mod_fact(n,prime[i])+1)%=mod;
	cout<<ans<<endl;
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

#define ID(x, y) ((y) * w + x)

struct Edge {
    ll to, cost;
};
vector<ll> dijkstra(const vector<vector<Edge>>& G, const ll s) {
    const ll n = G.size();
    vector<ll> dist(n, linf);
    dist[s] = 0;
    priority_queue<P, vector<P>, greater<P>> Q;
    Q.push({0, s});
    while ( !Q.empty() ) {
        P p = Q.top(); Q.pop();
        ll v = p.second;
        ll cost = p.first;
        if (cost > dist[v]) continue;
        each(e, G[v]) {
            if (dist[v] + e.cost < dist[e.to]) {
                dist[e.to] = dist[v] + e.cost;
                Q.push({dist[e.to], e.to});
            }
        }
    }
    return dist;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h, w; cin >> h >> w;
    char sc, tc; cin >> sc >> tc;
    vector<string> m(h); cin >> m;
    auto inRange = [&](ll x, ll y) {
        return 0 <= x && x < w && 0 <= y && y < h;
    };
    ll s, t;
    vector<vector<Edge>> G(w*h);
    auto add_edge = [&](ll a, ll b, ll c) {
        G[a].pb({b, c});
        G[b].pb({a, c});
    };
    rep(y, h) rep(x, w) {
        if (m[y][x] == sc) s = ID(x, y);
        if (m[y][x] == tc) t = ID(x, y);
        if (m[y][x] == '-') {
            add_edge(ID(x-1, y), ID(x, y), 0);
            add_edge(ID(x+1, y), ID(x, y), 0);
        }
        else if (m[y][x] == '|') {
            add_edge(ID(x, y-1), ID(x, y), 0);
            add_edge(ID(x, y+1), ID(x, y), 0);
        }
        else if ('A' <= m[y][x] && m[y][x] <= 'Z') {
            rep(dx, -1, 2) rep(dy, -1, 2) {
                if (dx != 0 || dy != 0) {
                    add_edge(ID(x+dx, y+dy), ID(x, y), 1);
                }
            }
        }
    }
    ll ans = dijkstra(G, s)[t];
    assert(ans % 2 == 0);
    cout << ans/2 << endl;
}



Measured memory_bytes: 3304
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int f(int k, int i, vector<int>& a) {
	if (i == k) return 0;
	if (a[i] % 10 == 0) return f(k, i + 1, a);
	int mini = INT_MAX;
	for (int j = i + 1; j <= k; j++) {
		for (int l = i + 1; l < j; l++)
			a[l] -= a[i];
		mini = min(mini, f(k, i + 1, a));
		for (int l = i + 1; l < j; l++)
			a[l] += a[i];
	}
	return mini + 1;
}

int main() {
	for (;;) {
		int k; cin >> k;
		if (k == 0) break;
		string s, t; cin >> s >> t;
		vector<int> a(k);
		for (int i = 0; i < k; i++)
			a[i] = t[i] - s[i];
		cout << f(k, 0, a) << endl;
	}
}

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

using namespace std;

int G[50][50];
vector<vector<int> > G_(50);
int seen[60];
int n, m;

void dfs(int v) {
    seen[v] = 1;
    
    for (int i = 0; i < n; i++) {
        if (!G[v][i] || seen[i])
            continue;
        else {
            dfs(i);
        }
    }
}

int main() {
    cin >> n >> m;
    int ans = 0;
    int *a = new int[m], *b = new int[m];
    for (int i = 0; i < m; i++) {
        int a_, b_;   cin >> a_ >> b_;
        G[a_-1][b_-1] = G[b_-1][a_-1] = 1;
        a[i] = a_-1;
        b[i] = b_-1;
        }

    for (int i = 0; i < m; i++) {
        G[a[i]][b[i]] = 0;
        G[b[i]][a[i]] = 0;
        for (int k = 0; k < n; k++) {
            seen[k] = 0;
        }
            
        dfs(0);
        for (int k = 0; k < n; k++) {
            if (seen[k] == 0) {
                ans++;
                break;
            }
        }
        G[a[i]][b[i]] = 1;
        G[b[i]][a[i]] = 1;
    }

    cout << ans << 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;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]) cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

constexpr int num = 26;
int D;
vector<int> c(num);

vector<vector<int>> s; 

int point(vector<int> &t){
	int res = 0;
	
	vector<int> last(num);
	
	for(int i = 0; i < D; i++){
		res += s[i][t[i]];
		
		for(int j = 0; j < num; j++){
			last[j]++;
		}
		
		last[t[i]] = 0;
		
		for(int j = 0; j < num; j++){
			res -= c[j] * last[j];
		}
	}
	
	return res + 1'000'000;
}

vector<int> solve(int Z){
	vector<int> t(D);
	
	vector<int> last(num);
	
	for(int i = 0; i < D; i++){
		for(int j = 0; j < num; j++){
			cin>>s[i][j];
			// s[i][j] = rand()%20000;
			
			if(s[i][t[i]] + last[t[i]] * last[t[i]]/Z * c[t[i]] < s[i][j] + last[j] * last[j]/Z * c[j]) {
				t[i] = j;
			}
		}
		
		for(int j = 0; j < num; j++){
			if(j == t[i]) {
				last[j] = 0;
			} else {
				last[j]++;
			}
		}
	}
	
	return t;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	vector<int> t;
	// srand(time(NULL));
	
	cin>>D;
	
	// D = 365;
	
	s.resize(D, vector<int>(num));
	t.resize(D, 0);
	
	for(int i = 0; i < num; i++){
		cin>>c[i];
		// c[i] = rand()%100;
	}
	
	int p;
	
	t = solve(1);
	
	p = point(t);
	// cout<<1<<" "<<p<<endl;
	
	for(int i = 2; i <= 100; i++){
		vector<int> nt;
		
		nt = solve(i);
		int np = point(nt);
		
		// cout<<i<<" "<<np<<endl;
		
		if(p < np) {
			t = nt;
			p = np;
		}
	}
	
	for(int i = 0; i < 10000; i++){
		int d = rand()%D, x = rand()%num, np;
		int tx;
		
		tx = t[d];
		
		t[d] = x;
		
		np = point(t);
		
		if(p < np) {
			np = p;
		} else {
			t[d] = tx;
		}
		
	}
	
	for(int i = 0; i < D; i++){
		cout<<t[i]+1<<endl;
	}
	
	// cout<<point(t)<<endl;
	
	return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
// #include <numeric>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(a,b) (x+y-1)/y
#define min(x,y)(x<y?x:y)
 
using namespace std;
typedef pair<long, int> P;


int main() {
	FAST;

	int N;
	ll a[3000];

	cin >> N;
	rep(i,N) {cin >> a[i];}

	ll sum=0;

	rep(i,N) {
		sum += (a[i] - 1);
	}

	cout <<  sum << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

string a, b, c;

int main()
{
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import copy
import queue

H,W = map(int, input().split())
def check(x,y):
    global W,H
    if x<0 or y<0 or x>=W or y>=H:
        return False
    return True

m = []
visit = []
for _ in range(H):
    S = list(input())
    m.append(S)
    l = [-1]*W
    visit.append(l)

visit_copy = copy.deepcopy(visit)
max = 0

for i in range(H):
    for j in range(W):
        sy = i
        sx = j
        q = queue.Queue()
        visit[sy][sx] = 0
        q.put([sy,sx])
        while not (q.empty()):
            y,x = q.get()
            if m[y][x]=="#":
                continue

            if check(x+1,y)==True:
                if visit[y][x+1]==-1 and m[y][x+1]==".":  
                    visit[y][x+1] = visit[y][x] + 1
                    if visit[y][x+1] > max:
                        max = visit[y][x+1]

                    q.put([y,x+1])
            if check(x,y+1)==True:
                if visit[y+1][x]==-1 and m[y+1][x]==".":  
                    visit[y+1][x] = visit[y][x] + 1
                    if visit[y+1][x] > max:
                        max = visit[y+1][x]

                    q.put([y+1,x])
            if check(x,y-1)==True:
                if visit[y-1][x]==-1 and m[y-1][x]==".":  
                    visit[y-1][x] = visit[y][x] + 1
                    if visit[y-1][x] > max:
                        max = visit[y-1][x]

                    q.put([y-1,x])
            if check(x-1,y)==True:
                if visit[y][x-1]==-1 and m[y][x-1]==".":  
                    visit[y][x-1] = visit[y][x] + 1
                    if visit[y][x-1] > max:
                        max = visit[y][x-1]

                    q.put([y,x-1])
        visit = copy.deepcopy(visit_copy)

print(max)

Measured memory_bytes: 4080
#include <iostream>
#include <string>
#include<math.h>
using namespace std;
string a,b,c;
int main() {
    cin>>a>>b;
if(a.size()>=b.size()){
    for(int i=0;i<a.size	()-b.size()+1;i++){
    c=a.substr(i,b.size());
if(c==b){
cout<<i<<endl;}}
}
	return 0;
}


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

int main(void){
  short pasta[100];
  unsigned long long int dp[100][3][2]; //[day][pasta][continuity],0-offset (input is 1-offset)
  unsigned long long int sum=0;
  const int mods=10000;
  int i,j,n,k,in1,in2;
  
  scanf("%d %d",&n,&k);
  memset(pasta,0,sizeof(pasta));
  while(k--){
    scanf("%d %d",&in1,&in2);
    pasta[in1-1]=in2;
  }

  /*set initial value*/
  if(pasta[0]==0){
    for(i=0;i<3;i++) dp[0][i][0]=1;
    for(i=0;i<3;i++) dp[0][i][1]=0;
  }else{
    for(i=0;i<3;i++) dp[0][i][0]=0;
    for(i=0;i<3;i++) dp[0][i][1]=0;
    dp[0][pasta[0]-1][0]=1;
  }

  /*calculation*/
  for(i=1;i<n;i++){
    if(pasta[i]==0){
      dp[i][0][0]=(dp[i-1][1][0]+dp[i-1][1][1]+dp[i-1][2][0]+dp[i-1][2][1])%mods;
      dp[i][1][0]=(dp[i-1][0][0]+dp[i-1][0][1]+dp[i-1][2][0]+dp[i-1][2][1])%mods;
      dp[i][2][0]=(dp[i-1][1][0]+dp[i-1][1][1]+dp[i-1][0][0]+dp[i-1][0][1])%mods;
      dp[i][0][1]=dp[i-1][0][0]%mods;
      dp[i][1][1]=dp[i-1][1][0]%mods;
      dp[i][2][1]=dp[i-1][2][0]%mods;
    }else{
      for(j=0;j<3;j++){
	if(j==pasta[i]-1){
	  dp[i][j][0]=(dp[i-1][0][0]+dp[i-1][0][1]+dp[i-1][1][0]+dp[i-1][1][1]+dp[i-1][2][0]+dp[i-1][2][1]-dp[i-1][j][0]-dp[i-1][j][1])%mods;
	  dp[i][j][1]=dp[i-1][j][0];
	}else{
	  dp[i][j][0]=dp[i][j][1]=0;
	}
      }
    }
  }
  
  sum=0;
  for(i=0;i<6;i++) sum+=dp[n-1][i%3][i%2];
  sum%=mods;
  printf("%llu\n",sum);
  
  return 0;
}

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

#define req(x, y) for (int i = (x); i < (y); i++)

typedef long long ll;

using namespace std;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx, dy = ty - sy;

    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx, 'L');
    cout << 'L' << string(dy+1, 'U') << string(dx+1, 'R') << 'D';
    cout << 'R' << string(dy+1, 'D') << string(dx+1, 'L') << 'U';

    return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def find_divisor(n):
    return [i for i in range(1,n+1) if n%i == 0]

a, b, k = map(int, input().split())

if (a<b):
    a,b = b,a

gcd = gcd(a,b)
cd_list = find_divisor(gcd)[::-1]

print(cd_list[k-1])

Measured memory_bytes: 3064
#include"bits/stdc++.h"
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,m,n) for(int i=(m);i<(n);i++)
#define ALL(x) x.begin(),x.end()
using namespace std;

const double EPS = 1e-9;
typedef complex<double> point;
namespace std {
	bool operator<(const point &a, const point &b) {
		return real(a) != real(b) ? real(a)<real(b) : imag(a)<imag(b);
	}
}
struct Line :public vector<point> {
	Line(const point &a, const point &b) {
		push_back(a); push_back(b);
	}
};
double cross(const point &a, const point &b) {
	return real(a)*imag(b) - imag(a)*real(b);
}
double dot(const point &a, const point &b) {
	return real(a)*real(b) + imag(a)*imag(b);
}
int ccw(point a, point b, point c) {
	b -= a, c -= a;
	if (cross(b, c)>EPS)return +1;
	if (cross(b, c)<-EPS)return -1;
	if (dot(b, c)<-EPS) return +2;
	if (norm(b)<norm(c))return -2;
	return 0;
}

bool intersectSS(const Line &s, const Line &t) {
	return ccw(s[0], s[1], t[0])*ccw(s[0], s[1], t[1]) <= 0 &&
		ccw(t[0], t[1], s[0])*ccw(t[0], t[1], s[1]) <= 0;
}

point crosspoint(const Line &l, const Line &m) {
	double A = cross(l[1] - l[0], m[1] - m[0]);
	double B = cross(l[1] - l[0], l[1] - m[0]);
	if (abs(A)<EPS&&abs(B)<EPS)return m[0];
	if (abs(A)<EPS)assert(false);
	return m[0] + B / A * (m[1] - m[0]);
}

double xa, ya, xb, yb;
void solve() {
	cin >> xa >> ya >> xb >> yb;
	int N; cin >> N;
	point A(xa, ya), B(xb, yb);
	vector<Line>segments;
	vector<int>positions;
	//cout<<A<<" "<<B<<endl;
	REP(i, N) {
		double x1, y1, x2, y2;
		int o, l;
		cin >> x1 >> y1 >> x2 >> y2;
		cin >> o >> l;
		int pos;
		point ps(x1, y1), pt(x2, y2);
		if (o == 1)pos = l;
		else pos = (l + 1) % 2;
		segments.push_back(Line(ps, pt));
		positions.push_back(pos);
	}
	vector<pair<point, int>>v;
	Line a_b(A, B);
	int idx=0;
	REP(i, N) {
		if (intersectSS(a_b, segments[i])) {
			point cross_p = crosspoint(a_b, segments[i]);
			v.push_back({ cross_p,positions[i] });
		}
	}
	sort(ALL(v));
	int M = v.size();
	//cerr<<"number of crosspoints:"<<M<<endl;
	int ans = 0;
	// REP(i,M){
	// 	cerr<<v[i].first<<" "<<v[i].second<<endl;
	// }
	FOR(i, 1, M) {
		if (v[i].second != v[i - 1].second)ans++;
	}
	cout << ans << endl;
}
signed main() {
	int q; cin >> q;

	while (q--)solve();
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;

void solve() {
  ll A, B, K;
  cin >> A >> B >> K;
  ll ans_A = max(0LL, A - K);
  ll ans_B = max(0LL, B - (K - (A - ans_A)));
  cout << ans_A << ' ' << ans_B << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
S = input()
if len(S) % 2 == 1 :
    S = S[0 : len(S) - 1]
for i in range(len(S) - 2, 0, -2) :
    if S[0 : int(i / 2)] == S[int(i / 2) : i] :
        print(i)
        exit()


Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

long long gcd(long long a,long long b){
	if(max(a,b)%min(a,b)==0){
		return min(a,b);
	}else{
		return gcd(max(a,b)%min(a,b) , min(a,b));
	}
}

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

//A以上B以下で、CでもDでも割り切れない物の個数

int main(){
	long long A,B,C,D;
	cin >> A >> B >> C >> D;
	long long left=(A-1)-((A-1)/C)-((A-1)/D)+((A-1)/lcm(C,D));
	long long right=B-(B/C)-(B/D)+(B/lcm(C,D));
	long long ans=right-left;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


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

    if N < B:
        res = (A * N) // B
        return print(res)

    x = (N // B) * B - 1
    res = (A * x) // B - A * (x // B)
    print(res)


if __name__ == '__main__':
    main()


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

#define INF 1000000000;
long dp[100005];

long min(long a,long b);

int main(void){
  int N,K,h[100005],i,j;
  char str[1000000],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  N=atoi(p);
  p=strtok(NULL," \n");
  K=atoi(p);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  h[1]=atoi(p);
  for(i=2;i<N+1;i++){
    p=strtok(NULL," \n");
  	h[i]=atoi(p);
  }
  
  for(i=2;i<N+1;i++){
    dp[i]=INF;
    for(j=1;j<K+1;j++){
      if(i-j>0){
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
      }
    }
  }
  
  printf("%ld\n",dp[N]);
  
  
  return 0;
}

long min(long a,long b){
  if(a<=b){
    return a;
  }else{
    return b;
  }
}


Measured memory_bytes: 1920
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] day = {0,2,0,1,0,1,0,0,1,0,1,0};
            int[] S = Input.ScanIntArray();
          Console.WriteLine((day[S[0]-1] == day[S[1]-1]) ? "Yes" : "No");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <set>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;


int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9)
    {
        cout << a * b << endl;
    }
    else
    {
        cout << -1 << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<=(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double Pi = acos(-1);
const ll mod=1e9+7;

int main(){
    int n;
    cin >>n;
    int a;
    map<ll,ll> mp;
    rep(i,n) {
        cin >>a;
        mp[a]++;
    }
    int q;
    cin >>q;
    int bb[q],cc[q];
    rep(i,q) cin >>bb[i]>>cc[i];
    mp[cc[0]] += mp[bb[0]];
    mp[bb[0]] =0;
    ll ans=0;
    for(auto iter =mp.begin(); iter != mp.end(); iter++){
        ans += iter->first * iter->second;
    }
    cout << ans <<endl;
    rrep(i,q-1){
        int b = bb[i], c= cc[i];
        int tmp=mp[b];
        ans += c*tmp-b*tmp;
        mp[b]=0;
        mp[c] += tmp;
        cout << ans <<endl;
    }
    return 0;
}

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

#define N 100

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int d[ N + 1 ] = { 0 };
  int a, b;
  int cc;
  int i;

  for ( cc = !!( scanf ( "%d%d", &a, &b ) == 2 ); cc;
        cc = !!( scanf ( "%d%d", &a, &b ) == 2 ) )
  {
    if ( !( a | b ) )
    {
      int v = 0;

      for ( i = 3; i <= N; ++i ) v = v || d[ i ];
      puts ( d[ 1 ] && d[ 2 ] && !v
           ? "OK" : "NG" );

      memset ( d, 0, sizeof ( d ) );
      continue ;
    }

    d[ a ] = !d[ a ];
    d[ b ] = !d[ b ];
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <stdio.h>
int main(){
    int N,flag=1,A[100],count,t,j,i,a;
    scanf("%d",&N);
    for(t=0;t<N;t++){
        scanf("%d",&A[t]);
        }
        i=0;
    while(flag==1){
        flag=0;
    for(j=N-1;j>i;j--){
            if(A[j]<A[j-1]){
                a=A[j-1];
                A[j-1]=A[j];
                A[j]=a;
                count++;
                flag=1;
            }
        }
        i++;
    }
        for(j=0;j<N;j++){
            printf("%d",A[j]);
            if(j<N-1)
                printf(" ");
        }
        printf("\n");
        printf("%d\n",count);
        return 0;
}


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

double mincovski(std::vector<double> x, std::vector<double> y, double p){
    double D;
    for(int i=0; i<x.size(); i++){
        D += std::pow(std::abs(x[i]-y[i]),p);
    }
    return std::pow(D, 1/p)<1e-10 ? 0.0 :  std::pow(D, 1/p);
}

int main(){
    int n;
    std::cin >> n;
    
    std::vector<double> x, y;
    double tmp;
    while(n--){
        std::cin >> tmp;
        x.push_back(tmp);
    }
    n = x.size();
    while(n--){
        std::cin >> tmp;
        y.push_back(tmp);
    }
    std::cout << std::setprecision(10);
    std::cout << mincovski(x, y, 1) << std::endl;
    std::cout << mincovski(x, y, 2) << std::endl;
    std::cout << mincovski(x, y, 3) << std::endl;
    double max = 0;
    for(int i=0; i<x.size(); i++){
        max = std::abs(x[i]-y[i])>max ? std::abs(x[i]-y[i]) : max;
    }
    std::cout << max << std::endl;
}


Measured memory_bytes: 3460
#include <iostream>

using namespace std;

/** Problem0054 : Sum of Nth decimal places **/
int main()
{
	int a, b, n, s;
	
	while (cin >> a >> b >> n) {
		s = 0;
		a*=10;
		for (int i=0; i<n; i++) {
			s += (a/b)%10;
			a %= b;
			a *= 10;
		}
		cout << s << endl;
	}
}

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(abs(a - c) <= d || (abs(b - c) <= d && abs(a - b) <= d)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
 long long int n,k;
  cin>>n>>k;
  n=n%k;
  for(int i=0;i<1000;i++){
    n= min(abs(n-k),n);
  }
  
  
  cout<<n<<endl;
  
  
  
  

}

Measured memory_bytes: 256
using System;

namespace AtCoderProblems
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = a % 10;

            if(b == 2 || b == 4 || b == 5 || b == 7 || b == 9)
            {
                Console.WriteLine("hon");
            }
            if(b == 0 || b == 1 || b == 6 || b == 8)
            {
                Console.WriteLine("pon");
            }
            if(b == 3)
            {
                Console.WriteLine("bon");
            }


        }
    }

}

Measured memory_bytes: 27520