akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

void perfecttree(int,int,int *);
void swapping(int *,int *);

int main(){
  int H,i,*A;

  scanf("%d",&H);
  A = (int *)malloc(sizeof(int) * (1 + H));
  A[0] = 99;
  for(i = 1;i < H + 1;i++){
    scanf("%d",&A[i]);
  }

  for(i = H / 2;i > 0;i--) perfecttree(i,H,A);

  for(i = 1;i < H + 1;i++) printf(" %d",A[i]);
    printf("\n");
  
  free(A);
  return 0;
}

void perfecttree(int i,int H,int *A){
  int big,left,right,j;
 
  left = 2 * i;
  right = 2 * i + 1;
  
  if(left < H + 1 && A[left] > A[i]) big = left;
  else big = i;
  if(right < H + 1 && A[right] > A[big]) big = right;
  
  if(big != i){
    swapping(&A[i],&A[big]);
    perfecttree(big,H,A);
  }
}

void swapping(int *a,int *b){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}



Measured memory_bytes: 3244
import itertools
N,M,X=map(int,input().split())
A=[0]*(N);C=[0]*(N);c=0;D=[0]*(M);m=10**5;n=0;x=[];z=0;R=[0]*N;f=-1;cost=10**7;p=0
for i in range(N):
  S=list(map(int,input().split()))
  C[i]=S[0]
  A[i]=S[1:len(S)]
#print(C)
#print(A)
for i in range(len(C)):
  x.append(i)

for i, _ in enumerate(x, 1):     
    for j in itertools.combinations(x, r=i):
        f=-1
        D=[0]*(M)
        for k in j:
          for l in range(M):
            D[l]=D[l]+A[k][l]
        for v in range(M):
          if D[v]<X:
            f=1
        if f!=1:
          for y in j:
            p=p+C[y]
          if p<cost:
            cost=p
          p=0
print(cost if cost!=10000000 else -1)

Measured memory_bytes: 9312
a,b = map(int,input().split())
if a<0 and b<0:
    if abs(a-b)%2==0:
        print("Negative")
    else:
        print("Positive")
elif (a<0 and b>=0) or a==0 or b==0:
    print("Zero")
else:
    print("Positive")

Measured memory_bytes: 3060
def main():
    card_num = int(input())
    cards = list(map(int, input().split(" ")))
    cards.sort(reverse=True)
    answer = 0
    for i in range(card_num):
        if i % 2:
            answer -= cards[i]
        else:
            answer += cards[i]
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.Scanner;

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

    int H = scanner.nextInt();
    int N = scanner.nextInt();
    int[] A = new int[N];
    int[] B = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = scanner.nextInt();
      B[i] = scanner.nextInt();
    }

    int[] dp = new int[H + 1];
    final int INF = 1_000_000_000;
    for (int i = 1; i <= H; i++) dp[i] = INF;

    for (int i = 1; i <= H; i++) {
      for (int j = 0; j < N; j++) {
        int p = i - A[j];
        if (p < 0) p = 0;
        dp[i] = Math.min(dp[i], dp[p] + B[j]);
      }
    }
    System.out.println(dp[H]);
  }
}


Measured memory_bytes: 26324
using System;

namespace AtCorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var slimeColor = Console.ReadLine();

            var result = 1;
            var currentColor = slimeColor[0];
            for (int i = 1; i < slimeColor.Length; i++)
            {
                if (slimeColor[i] != currentColor)
                {
                    currentColor = slimeColor[i];
                    result++;
                }
            }

            Console.WriteLine(result);
        }
    }
}



Measured memory_bytes: 13280
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std ;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define rep(i , a , b) for(int i = (a) ; i < (b) ; ++i)
#define repp(i , a , b) for(int i = (a) ; i >= b ; --i)
#define each(x , a) for(auto &x : a)
#define len(x)  (int)x.size()
#define all(x)  (x).begin() ,(x).end()
#define mem(x , a) memset(x , a , sizeof(x))
#define vi vector<int>
#define vl vector<LL>
#define pii pair<int,int>
#define Pll pair<LL,LL>
#define io ios::sync_with_stdio(0) ; cin.tie(0);

const ll MOD = 1e9 + 7 ;
const ll INF = 1e18 ;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds ;

string to_string(string s) {
	return '"' + s + '"';
}
string to_string(const char *s) {
	return to_string((string)s);
}
string to_string(bool b) {
	return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(x...) ;
#endif

int main() {
	io;
	//freopen("in.txt" ,"r" , stdin) ;
	string S , T ;
	cin >> S >> T ;
	int n = len(S) ;
	int m = len(T) ;
	int ans = INT_MAX ;
	rep(i , 0 , n - m + 1) {
		int cnt = 0 ;
		rep(j , 0 , m) {
			if (S[i + j] != T[j]) {
				cnt++ ;
			}
		}
		ans = min(cnt , ans) ;
	}
	cout << ans ;


}



Measured memory_bytes: 3612
#include <bits/stdc++.h>//solved by *ALIKHAN*
#define ll long long
#define ld long double
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define ppb pop_back
#define mp make_pair
#define all(n) n.begin(), n.end()
#define timefaster ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18;

int main(){
	timefaster;
	int n , m , a , sum = 0;
	cin >> m >> n;
	for(int i = 0;i < n;i ++){
	 	cin >> a;
	 	sum += a;
	}
	if(m <= sum) cout << "Yes" ;               	
	else cout << "No";
	}// Aksay sila

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        String n;
        Scanner scan = new Scanner(System.in);
        n = scan.next();
        int ans = 0;
        for(int i = 0; i < n.length();i++){
            if(n.charAt(i)=='+')ans++;
            else ans--;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b){
	return *(int *)b-*(int *)a;
}
int max(int a,int b){
	return a>b?a:b;
}
int main(void){
	int a[4],b[4],sum=0,i;
	for(i=0;i<4;i++)
		scanf("%d",&a[i]);
	for(i=0;i<2;i++)
		scanf("%d",&b[i]);
	qsort(a,4,sizeof(int),cmp);
	for(i=0;i<3;i++)
		sum+=a[i];
	sum+=max(b[0],b[1]);
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)


int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n), count(n);
    rep1(i, n) cin >> h[i];
    ll a, b;
    rep1(i,m){
        cin >> a >> b;
        if (h[a-1] < h[b-1]) count[a-1]++;
        if (h[a-1] > h[b-1]) count[b-1]++;
        if (h[a-1] == h[b-1]){
            count[a-1]++;
            count[b-1]++;
        } 
    }
    ll ans = 0;
    rep1(i,n){
        if (count[i] == 0) ans++;
    }
    cout << ans << endl;
}

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

int main(void){
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	int maxx, miny;
	for(int i = 0; i < n; ++i){
		int tmp;
		cin >> tmp;
		if(i==0){
			maxx = tmp;
		}else{
			maxx = max(tmp, maxx);
		}
	}
	for(int i = 0; i < m; ++i){
		int tmp;
		cin >> tmp;
		if(i==0){
			miny = tmp;
		}else{
			miny = min(miny, tmp);
		}
	}
	// maxx = max(maxx, x);
	// miny = min(miny, y);
	//cout << maxx << " " << miny << endl;
	if(miny - maxx > 0){
		int dif = miny - maxx;
		for(int i = 0; i < dif; ++i){
			if(x < i+maxx+1 && i+maxx+1 <= y){
				cout << "No War" << endl;
				return 0;
			}
		}
	}
	cout << "War" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var S = ReadLine();
            var cnt = 0L;//01010101
            for (var i = 0; i < S.Length; ++i)
            {
                if (i % 2 == 0 && S[i] == '0')
                    ++cnt;
                else if (i % 2 != 0 && S[i] == '1')
                    ++cnt;
            }
            WriteLine(Min(cnt, S.Length - cnt));
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 26264
x = int(input())
# n = 100
# cnt = 0
# dif = 1
# while n * 2 <= x:
#     cnt = cnt + 100
#     n = n * 2
#     dif = dif * 2
# while n < x:
#     n = n + dif
#     cnt = cnt + 1
# print(cnt)

# 100, 101, 102, ..., 199    1*100
# 200, 202, 204, ..., 298    2*50
# 300, 303, 306, ..., 399    3 * 34
# 402, 406, 410, ..., 498    4*25
# 502

n = 100
cnt = 0
while n < x:
    cnt = cnt + 1
    n = int(n * 1.01)
    # print(cnt, n)
print(cnt)


Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main() {
    int n;
    string a, b, c;
    while (cin >> n >> a >> b >> c) {
        int ans = 0;
        rep(i, n) {
            int cnt[256] = {};
            cnt[a[i]]++;
            cnt[b[i]]++;
            cnt[c[i]]++;
            int ma = *max_element(cnt, cnt + 256);
            ans += 3 - ma;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	string s;
	int q;
	cin >> s;
	cin >> q;
	for(int i=0; i<q; ++i){
		string od, p;
		int a, b;
		cin >> od >> a >> b;
		if(od=="replace"){
			cin >> p;
			s = s.replace(a, b-a+1, p);
		}
		else if(od=="print"){
			cout << s.substr(a, b-a+1) << endl;
		}
		else if(od=="reverse"){
			string tmp = s.substr(a, b-a+1);
			reverse(tmp.begin(), tmp.end());
			s = s.replace(a, b-a+1, tmp);	
		}
	}
	return 0;
}


Measured memory_bytes: 3168
N = int(input())
X = list(map(int, input().split()))

ans = 0
cnt = 0
cur = X[0]
for i in range(1, N):
    if cur < X[i]:
        ans = max(ans, cnt)
        cnt = 0
    else:
        cnt += 1
    cur = X[i]

print(max(ans, cnt))


Measured memory_bytes: 84804
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);

		int n=sc.nextInt();
		
		System.out.println((n+1)/2);
		sc.close();
	}
}


Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.Int;
            var K = consoleReader.Int;
            return consoleReader.Split.Int.OrderByDescending(i => i).Take(K).Sum();
        }

        #region いつもの
#pragma warning disable
        private ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
    }
    static class Ext
    {
        public static Dictionary<TKey, int> GroupCount<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector) => source.GroupBy(keySelector).ToDictionary(g => g.Key, g => g.Count());
        public static Dictionary<TKey, int> GroupCount<TKey>(this IEnumerable<TKey> source) => source.GroupCount(i => i);
    }
    public class ConsoleReader { private string[] ReadLineSplit() => textReader.ReadLine().Split(Array.Empty<char>(), StringSplitOptions.RemoveEmptyEntries); private string[] line = Array.Empty<string>(); private int linePosition; private TextReader textReader; public ConsoleReader(TextReader tr) { textReader = tr; } public int Int => int.Parse(String); public long Long => long.Parse(String); public double Double => double.Parse(String); public string String { get { if (linePosition >= line.Length) { linePosition = 0; line = ReadLineSplit(); } return line[linePosition++]; } } public class SplitLine { private string[] splited; public SplitLine(ConsoleReader cr) { splited = cr.ReadLineSplit(); cr.line = Array.Empty<string>(); } public int[] Int => String.Select(x => int.Parse(x)).ToArray(); public int[] Int0 => String.Select(x => int.Parse(x) - 1).ToArray(); public long[] Long => String.Select(x => long.Parse(x)).ToArray(); public double[] Double => String.Select(x => double.Parse(x)).ToArray(); public string[] String => splited; } public SplitLine Split => new SplitLine(this); public class RepeatReader : IEnumerable<ConsoleReader> { ConsoleReader cr; int count; public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; } public IEnumerator<ConsoleReader> GetEnumerator() => Enumerable.Repeat(cr, count).GetEnumerator(); System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator(); public IEnumerable<string> String => this.Select(cr => cr.String); public IEnumerable<int> Int => this.Select(cr => cr.Int); public IEnumerable<int> Int0 => this.Select(cr => cr.Int - 1); public IEnumerable<long> Long => this.Select(cr => cr.Long); public IEnumerable<double> Double => this.Select(cr => cr.Double); } public RepeatReader Repeat(int count) => new RepeatReader(this, count); }
    #endregion
}


Measured memory_bytes: 13396
#include <stdio.h>
#include <string.h>
#define N 2000000

int a[N];
int size;

void MaxHeapify(int i){
  int l, r, x, largest;
  l = i*2;
  r = i*2+1;
  if(l <= size && a[l] > a[i]){
    largest = l;
  }else{
    largest = i;
  }
  if(r <= size && a[r] > a[largest]){
    largest = r;
  }
  if(largest != i){
    x = a[i];
    a[i] = a[largest];
    a[largest] = x;
    MaxHeapify(largest);
  }
}

void HeapIncreaseKey(int i, int key){
  int x;
  if(key < a[i]){
    fprintf(stderr, "新しいキーは現在のキーより小さい\n");
  }
  a[i] = key;
  while(i > 1 && a[i/2] < a[i]){
    x = a[i];
    a[i] = a[i/2];
    a[i/2] = x;
    i = i/2;
  }
}

void maxHeapInsert(int key){
  size = size + 1;
  a[size] = -2147483648;
  HeapIncreaseKey(size, key);
}

int HeapExtractMax(void){
  if(size < 1){
    fprintf(stderr, "ヒープアンダーフロー\n");
  }
  int max;
  max = a[1];
  a[1] = a[size];
  size = size-1;
  MaxHeapify(1);
  return max;
}

int main(){
  int i = 0, k, max;
  char c[10];
  char *a = "insert";
  char *b = "extract";
  char *d = "end";

  size = 0;
  while(1){
    scanf("%s", c);
    if(strcmp(c, a) == 0){
      scanf("%d", &k);
      maxHeapInsert(k);
    }else if(strcmp(c, b) == 0){
      max = HeapExtractMax();
      printf("%d\n", max);
    }else if(strcmp(c, d) == 0){
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 21
#endif // LOCAL
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
bool ask(int l,int r){
    printf("?");
    for(int i = l ;i <= r ;i ++)
    printf(" %d", i);
    printf("\n");
    fflush(stdout);
    char c[5];
    scanf("%s", c);
    if(c[0] == '-') throw;
    return c[0] == 'R';
}
bool ask(vector<int> &p){
    printf("?");
    for(int i: p)
        printf(" %d",i);
    printf("\n");
    fflush(stdout);
    char c[6];
    scanf("%s", c);
    if(c[0] == '-') throw;
    return c[0] == 'R';
}/// red greater than blue
char ans[nax];

int main(){
    scanf("%d", &n);
    bool o = ask(1 , n);
    int idx = -1;
    {
        int l = 2, r = n + 1, mid;
        while(l <= r){
            mid = l + r >> 1;
            bool now = ask(mid, mid + n - 1);
            if(now != o){
                idx = mid;
                r = mid - 1;
            }
            else l = mid + 1;
        }
    }
    /*for(int i = 2 ;i <= n + 1; i ++){
        bool now = ask(i , i + n - 1);
        if(now != o){
            idx = i;
            break;
        }
    }*/
    if(idx == -1) throw;
    vector<int> toAsk ;
    for(int i = idx ; i < idx + n -1; i++)
        toAsk.push_back(i);
    auto inrange = [&] (int x){
        return x >= idx & x <= idx + n - 1;
    };
    for(int i = 1 ;i <= 2 * n ; i++){
        if(!inrange(i)){
            toAsk.push_back(i);
            bool go = ask(toAsk);
            if(go)
                ans[i] = 'R';
            else
                ans[i] = 'B';
            toAsk.pop_back();
        }
    }
    toAsk.clear();
    int r = 0, b = 0;
    for(int i = 1 ;i <= 2 * n ; i ++){
        if(!inrange(i)) {
            toAsk.push_back(i);
            if(ans[i] == 'R') r ++;
            else if(ans[i] == 'B') b ++;
            else throw;
        }
    }
    for(auto it = toAsk.begin() ; it != toAsk.end() ; ++ it){
        if(r > b && ans[*it] == 'R'){
            toAsk.erase(it);
            break;
        }
        else if(b > r && ans[*it] == 'B'){
            toAsk.erase(it);
            break;
        }
    }
    for(int i = 1 ;i <= 2 * n ; i++){
        if(inrange(i)){
            toAsk.push_back(i);
            bool go = ask(toAsk);
            if(go) ans[i] = 'R';
            else ans[i] = 'B';
            toAsk.pop_back();
        }
    }
    printf("! ");
    for(int i = 1 ;i <= 2 * n ; i++)
        printf("%c", ans[i]);
    printf("\n");
    fflush(stdout);
}
/*
Fuck didn't have enough time to code
*/
/*
    Long time no see!
    Atcoder...
*/


Measured memory_bytes: 724
#include <iostream>

using namespace std;

int main()
{
    long long n, k, x, y;
    cin >> n >> k >> x >> y;
    if (n <= k)
        cout << x * n << endl;
    else
        cout << x * k + y * (n - k) << endl;
    //system("pause");
    return 0;
}

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

int main() {
  int num;
  int tmpCnt1,tmpCnt2;
  int Max1 = 0, Max2 = 0;
  string str1, str2;
  cin >> num >> str1 >> str2;
  
  if(str1 == str2){
    cout << num;
    return 0;
  }
  
  for(int i = 0; i < num; i++){
    tmpCnt1 = 0;
    
    if(str1.at(i) == str2.at(0)){
      for(int j = 0; j < num - i; j++){
        if(str1.at(i+j) == str2.at(j)) tmpCnt1++;
        else break;
      }
      Max1 = max(Max1, tmpCnt1);
    }
  }

  for(int i = 0; i < num; i++){
    tmpCnt2 = 0;
    
    if(str2.at(i) == str1.at(0)){
      for(int j = 0; j < num - i; j++){
        if(str2.at(i+j) == str1.at(j)) tmpCnt2++;
        else break;
      }
      Max2 = max(Max2, tmpCnt2);
    }
  }

  if(Max1 == 0 && Max2 == 0){
    cout << num * 2;
  }else if(Max1 >= Max2){
    cout << num + (num - Max1);
  }else{
    cout << num + (num - Max2);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N; cin>>N; std::vector<p> v;
    for(int i=0; i<N;i++){
      int aa; cin>>aa; v.push_back(make_pair(aa, i+1));
    }
    sort(v.begin(), v.end());
    for(int i=0; i<N;i++){
    cout<<v[i].second<<" ";
    }

    cout<<endl;
    return 0;
}


Measured memory_bytes: 2544
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int h, m, s, t;

    for(;;){
      h = sc.nextInt(); m = sc.nextInt(); s = sc.nextInt();
      if(h == -1 && m == -1 && s == -1)break;
      t = 7200 - (s + m * 60 + h * 3600);
      out.printf("%02d:%02d:%02d%n", t / 3600, (t / 60) % 60, t % 60);
      t *= 3;
      out.printf("%02d:%02d:%02d%n", t / 3600, (t / 60) % 60, t % 60);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

int main(){
    int n;
    cin >> n;
    map<ll, int> mp;
    rep(i, n) {
        ll a;
        cin >> a;
        ++mp[a];
    }

    vector<ll> ans_prob;
    vector<ll> ans_prob2;
    for ( auto tmp_mp : mp ) {
        if ( tmp_mp.second >= 2 ) {
            ans_prob.push_back(tmp_mp.first);
        }
        if ( tmp_mp.second >= 4 ) {
            ans_prob2.push_back(tmp_mp.first);
        } 
    }


    sort(ans_prob2.begin(), ans_prob2.end());
    sort(ans_prob.begin(), ans_prob.end());

    if ( ans_prob.size() < 2 && ans_prob2.size() == 0 ) {
        cout << 0 << endl;
    }
    else {
        ll ans2 = 0;
        ll ans1 = 0;
        if ( !ans_prob2.empty() ) {
            ans2 = ans_prob2[ans_prob2.size()-1] * ans_prob2[ans_prob2.size()-1];
        }
        if ( ans_prob.size() >= 2 ) {
            ans1 = ans_prob[ans_prob.size()-1] * ans_prob[ans_prob.size()-2];
        }
        cout << max(ans2, ans1) << endl;
    } 
    return 0;
}


Measured memory_bytes: 6528
import math

a, b, C = map(float, raw_input().split())
print a * b * math.sin(math.radians(C)) / 2
print a + b + math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(C)))
print (b * math.sin(math.radians(C)))

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

using namespace std;

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

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

int main()
{
    ll i, o, t, j, l, s, z;
    cin >> i >> o >> t >> j >> l >> s >> z;

    int I, J, L;
    I = i;
    J = j;
    L = l;

    ll res = 0;

    ll r_ = o;

    r_ += (i / 2) * 2;
    r_ += (j / 2) * 2;
    r_ += (l / 2) * 2;

    res = r_;

    r_ = o;

    if (i > 0 && j > 0 && l > 0)
    {
        r_ += 3;
        i--;
        j--;
        l--;

        r_ += (i / 2) * 2;
        r_ += (j / 2) * 2;
        r_ += (l / 2) * 2;

        res = max(r_, res);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func run() {
	n := nextInt()
	x := nextInt()
	for i := x - n + 1; i <= x+n-1; i++ {
		Printf("%d", i)
		if i == x+n-1 {
			Print("\n")
		} else {
			Print(" ")
		}
	}
}

// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024

func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}

func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}

func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = nextInt()
	}
	return res
}

func nextFloats(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = nextFloat()
	}
	return res
}

func nextStrings(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = next()
	}
	return res
}

func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}


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

long long n, x;
long long a[100005] = {0};

long long solve();

int main() {
  cin >> n >> x;
  for(long long i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0, now;
  for(int i = 1; i < n; ++i) {
    now = a[i] + a[i - 1];
    if(now > x) {
      a[i] -= (now - x);
      ans += (now - x);
    }
    if(a[i] < 0) {
      a[i - 1] -= a[i];
      a[i] = 0;
    }
  }
  return ans;
}

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

template <class InputIterator1, class InputIterator2>
bool dictionary_compare(InputIterator1 first1, InputIterator1 last1,
                             InputIterator2 first2, InputIterator2 last2)
{
    for (; first1 != last1 && first2 != last2; ++first1, ++first2) {
        if (*first1 < *first2) return true;
        if (*first1 > *first2) return false;
    }
    return first1 == last1 && first2 != last2;
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;
    int m; cin >> m;
    vector<int> b(m);
    for (int &bi: b) cin >> bi;
    cout << dictionary_compare(begin(a), end(a), begin(b), end(b)) << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int i;
    int num[n];
    int check =1;
    int counter =0;
    for (i=0;i<n;i++)
        cin >> num[i];
    while(check){
        for(i=0;i<n;i++){
            if(num[i]%2 == 1){
                check=0;
                break;
            }
            num[i] = num[i]/2;
        }
        counter++;
    }
    cout << counter-1 << endl;        
        
    }

Measured memory_bytes: 3584
#include <iostream>
using namespace std;
typedef long long ll;
ll a, b, c;
int main(void){
    // Your code here!
    cin >> a >> b >> c;
    if (a % 2 && b % 2 && c % 2) {
        cout << min(a * b, min(b * c, c * a)) << endl;
    } else {
        cout << 0 << endl;
    }
}


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo;
#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#define debug(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#define debug(...) __VA_ARGS__
#endif
const int N = 81;

const int mid = 80*80 + 8;
bitset<2 * mid + 32> dp[N][N];
int a[N][N];
int b[N][N];

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int h, w;
    cin >> h >> w;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            cin >> a[i][j];
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            cin >> b[i][j];

    dp[0][1][mid] = 1;
    dp[1][0][mid] = 1;

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            int d = abs(a[i][j] - b[i][j]);
            dp[i][j]  = dp[i-1][j] << d;
            dp[i][j] |= dp[i-1][j] >> d;
            dp[i][j] |= dp[i][j-1] << d;
            dp[i][j] |= dp[i][j-1] >> d;
        }
    }

    debug(
        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                auto& x = dp[i][j];
                debugf("[%d %d %d %d %d %d %d] ", !!x[mid+3], !!x[mid+2], !!x[mid+1], !!x[mid], !!x[mid-1], !!x[mid-2], !!x[mid-3]);
            }
            debugf("\n");
        }
    )

    for (int i = 0; i < mid; i++) {
        if (dp[h][w][mid+i] || dp[h][w][mid-i]) {
            cout << i << endl;
            return 0;
        }
    }

    assert(false);

    return 0;
%>

Measured memory_bytes: 10496
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

struct DATA{
	int i;
	int j;
	int k;
};

int safe[301];

int main(){
	int a,b,c;
	while(~scanf("%d %d %d",&a,&b,&c)){
		int N;
		scanf("%d",&N);
		vector<DATA> valid;
		vector<DATA> invalid;
		
		fill((int*)safe,(int*)safe + 301,2);

		for(int n=0;n<N;n++){
			int i,j,k,r;
			//i:battery,j:moter,k:cable,r:1ok
			scanf("%d %d %d %d",&i,&j,&k,&r);
			DATA data = {i,j,k};
			if(r) valid.push_back(data);
			else invalid.push_back(data);
		}

		for(int i=0;i<valid.size();i++){
			safe[valid[i].i] = 1;
			safe[valid[i].j] = 1;
			safe[valid[i].k] = 1;
		}

		for(int i=0;i<invalid.size();i++){
			if(safe[invalid[i].i] == 1
			 && safe[invalid[i].j] == 1)
			{
				safe[invalid[i].k] = 0;
			}

			else if(safe[invalid[i].j] == 1
			 && safe[invalid[i].k] == 1)
			{
				safe[invalid[i].i] = 0;
			}

			else if(safe[invalid[i].i] == 1
			 && safe[invalid[i].k] == 1)
			{
				safe[invalid[i].j] = 0;
			}
		}

		for(int i=1;i<=a;i++){
			printf("%d\n",safe[i]);
		}

		for(int i=a+1;i<=a+b;i++){
			printf("%d\n",safe[i]);
		}

		for(int i=a+b+1;i<=a+b+c;i++){
			printf("%d\n",safe[i]);
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define ull         unsigned long long
#define ll          long long
#define M           1000000007
#define pb          push_back
#define p_q         priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp          make_pair
#define lb          lower_bound
#define ub          upper_bound
#define F           first
#define S           second
#define rep(i, begin, end) for (int i=begin;i<end;i++)
#define repd(i, begin, end) for (int i=end-1;i>=begin;i--)
#define ini(a,n,b)  for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)     __builtin_popcountll(a)

#define hell        1000000007
#define re          resize


int powm(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1) 
		res=(res*a)%M;
	    a=(a*a)%M;
	    b>>=1;
	}

	return res;
}

int findMMI_fermat(int n,int m)
{
    return powm(n,m-2);
}





signed main(void)
{ios
    

    vi arr(1e6+5,1);
    vi v(1e6+5,0);
    for(int i=2;i<=1e6;i++)
    {
    	if(!v[i])
    	{
    		arr[i]=i;
    		v[i]=1;
    		for(int j=i*i;j<=1e6;j+=i)
    		{
    			arr[j]=i;
    			v[j]=1;
    		}
    	}
    }


    vi vis(1e6+5,0);
    int n;
    cin>>n;
    vi a(n);

    rep(i,0,n) cin>>a[i];
    int f=1;
    int g=a[0];
    rep(i,1,n) g=gcd(g,a[i]);

    rep(i,0,n)
    {
    	int num=a[i];
    	set<int> s;
    	while(num>1)
    	{ 
            //cout<<num<<' '<<arr[num]<<"   ";
            s.insert(arr[num]);
    		if(vis[arr[num]]) {f=0;}
    		num/=arr[num];

    		
    	}

    	for(auto j:s)
    	{
    		vis[j]=1;
    	}

    	if(!f) break;


    }


    if(f) cout<<"pairwise coprime"<<endl;
    else if(g==1) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
    




}

Measured memory_bytes: 34616
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

long long n;

//int maxNum;
//int p[20];
//int maxP[20];
//bool isUsed[20];
//
//void doSearch(int depth)
//{
//	if (depth > n)
//	{
//		int curSum = 0;
//		for (int i = 1 ; i <= n ; i++)
//		{
//			curSum = curSum + i % p[i];
//		}
//		
//		if (curSum > maxNum)
//		{
//			maxNum = curSum;
//			for (int i = 1 ; i <= n ; i++)
//				maxP[i] = p[i];
//		}
//	}
//	else
//	{
//		for (int i = 1 ; i <= n ; i++)
//		{
//			if (isUsed[i])
//				continue;
//				
//			isUsed[i] = true;
//			p[depth] = i;
//			doSearch(depth + 1);
//			isUsed[i] = false;
//		}
//	}
//}

int main()
{
	scanf("%lld", &n);
	
	long long sum = 0;
	n--;
	sum = (n + 1) * n / 2;
	printf("%lld\n", sum);
	
	
	
//	maxNum = -1;
//	
//	for (int i = 1 ; i <= n ; i++)
//		isUsed[i] = false;
//		
//	doSearch(1);
//	
//	printf("%d\n", maxNum);
//	for (int i = 1 ; i <= n ; i++)
//		printf(" %d", maxP[i]);

	return 0;
}


Measured memory_bytes: 128
S = input()

if S == 'SAT':
    print(1)
if S == 'SUN':
    print(7)
if S == 'MON':
    print(6)
if S == 'TUE':
    print(5)
if S == 'WED':
    print(4)
if S == 'THU':
    print(3)
if S == 'FRI':
    print(2)

    
    

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


def main():
    b = input()
    if b == 'A': print('T')
    elif b == 'T': print('A')
    elif b == 'C': print('G')
    elif b == 'G': print('C')


if __name__ == "__main__":
    main()


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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  string ans="";
  ans+=toupper(a.front());
  ans+=toupper(b.front());
  ans+=toupper(c.front());
  cout << ans << endl;
  return 0;
}


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

int main(){
	int N; string S; cin>>N>>S;
	map<char,int> c;
	rep(i, N) c[S[i]]++;
	long long ans = (long long)c['R'] * c['G'] * c['B'];
	rep(i, N-2)
		for(int j=i+1,k=i+2; k<N; k+=2,j++)
			if(S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) ans--;
	cout<< ans <<endl;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <cmath>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

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

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
vector<int> G[200010];
vector<int> c(10010, 0);
int num[200010];
bool used[200010];
int now_c = 0;

int dfs(int s) {
    if (used[s]) {
        return 0;
    } else {
        used[s] = true;
    }

    num[s] = c[now_c];
    now_c++;

    for (int i = 0; i < G[s].size(); i++) {
        dfs(G[s][i]);
    }
    return 0;
}

int main() {
    lli N; cin >> N;

    cout << N*(N-1)/2 << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

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

const int N = 1e5 + 5;

ll n, a[N], b[N], c[N], dp[N][3];

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

    cin >> n;

    for (int i = 1; i <= n; ++i)
        cin >> a[i] >> b[i] >> c[i];

    for (int i = 1; i <= n; ++i) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }

    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}

Measured memory_bytes: 4992
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N,M,ans,r,a,b,c,C[100002];

pair<LL, LL>bc;
vector<pair<LL, LL>>BC;
int main() {
	vector<LL> A;
	cin >> N;
	LL F[100][10];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j< 10; j++) {
			cin >> F[i][j];
		}
	}
	LL P[100][10];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j< 11; j++) {
			cin >> P[i][j];
		}
	}
	ans = -100000000000;
	for (int x = 1; x <1024; x++){
		LL a = 0;
		for (int i = 0; i < N; i++){
			int c = 0;
			for (int j = 0; j < 10; j++) {
				if ((x >> j & 1) && F[i][j]) c++;
			}
			a += P[i][c];
		}
		if (ans < a) ans = a;
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
K = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
i = int(input())
print(K[i-1])


Measured memory_bytes: 2940
from collections import Counter

n = int(input())
A = [i for i in input().split()]
c = Counter(A)
ans = 0

if len(A) % 2 == 0:
    if all(v == 2 for v in c.values()):
        ans = 2**(n//2)
        
else:
    if c['0'] == 1 :
        if len(A) == 1:
            ans = 1
        del c['0']
        if all(v == 2 for v in c.values()):
            ans = 2**((n-1)//2)

print(ans % (10**9+7))

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

long long x, y;

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> x >> y;
	long long mx = gcd(x, y);
	set<long long> fac;
	for(long long i = 2; i * i <= mx; i++)
		while(mx % i == 0){
			fac.insert(i);
			mx /= i;
		}
	if(mx > 1) fac.insert(mx);
	cout << (int)fac.size() + 1 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include<string>
#include <set>
#include <map>
#include <queue>
#include <limits.h>
#include <bitset>
#include <cmath>

using namespace std;

#define rip(i,n,s) for (int i=(s);i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
typedef long long ll;

struct BIT{
    vector<ll> li;
    int size;
    BIT (int n){
        li=vector<ll>(n+1,LLONG_MIN);
        size=n;
    }
    ll maxim (int i){
        if(i==0){
            return -1000000000000000;
        }
        ll s=0;
        while(i>0){
            s = max(s,li[i]);
            i-=i & -i;
        }
        return s;
    }
    void add(int i, ll x){
        if(i==0){
            return;
        }
        while(i<=size){
            li[i] = max(li[i],x);
            i+=i & -i;
        }
    }
};

int main(){
    ll n,c;
    cin >> n >> c;
    vector<ll> x(n+1,0),v(n+1,0);
    rip(i,n,0){
        cin >> x[i+1] >> v[i+1];
    }
    vector<ll> sumo(n+1,0);
    rip(i,n+1,1){
        sumo[i]=sumo[i-1]+v[i];
    }
    ll ans=0;
    rip(i,n+1,1){
        ans=max(sumo[i]-x[i],ans);
        ans=max(sumo.back()-sumo[i-1]-c+x[i],ans);
    }
    BIT mo(n),ba(n);
    rip(i,n+1,1){
        mo.add(i,sumo[i]-x[i]);//mo 1 to i
        ba.add(n-i+1,sumo.back()-sumo[i-1]-c+x[i]);
    }
    rip(i,n+1,1){
        ans=max(sumo[i]-x[i]*2+ba.maxim(n-i),ans);
        //cout << ans << endl;
        ans=max(sumo.back()-sumo[i-1]-c*2+x[i]*2+mo.maxim(i-1),ans);
        //cout << ans << endl;
    }
    cout << ans << endl;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  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 = x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  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->parent=y->parent;

  if(y->parent==NIL)root=x;
  else if(y==y->parent->left)y->parent->right=x;
  else y->parent->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->parent=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);
  }
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


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: 25160
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
  	long a=0;
  	long b=0;
    for(long c=1;(c*c)<=n;c++){
    if(n%c==0){
    a=n/c;
    b=c;
    }
    }
    
     System.out.println(a+b-2);
    
    }
}


Measured memory_bytes: 23764
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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

const ll mod=1e9+7;

int main(){
    vector<vector<char>> c(2,vector<char>(3));
    rep(i,2){
        rep(j,3){
            cin >> c[i][j];
        }
    }
    bool ok=true;
    rep(i,3){
        if(c[0][i]!=c[1][2-i]) ok=false;
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
using namespace std;

int main(){
  long long N, D, A;
  cin >> N >> D >> A;
  vector<pair<long long,long long>> E;
  for(int i = 0; i < N; ++i){
    long long x, h;
    cin >> x >> h;
    E.emplace_back(x,h);
  }
  sort(E.begin(), E.end());
  queue<pair<long long,long long>> pq;
  long long d = 0, ans = 0;
  for(int i = 0; i < N; ++i){
    while(pq.size() and pq.front().first < E[i].first){
      d -= pq.front().second;
      pq.pop();
    }
    E[i].second -= d*A;
    E[i].second = max(E[i].second,0LL);
    long long t = (E[i].second+A-1)/A;
    // cerr << E[i].first << " " << t << endl;
    ans += t;
    d += t;
    pq.emplace(E[i].first+2*D,t);
  }
  cout << ans << endl;
}


Measured memory_bytes: 6764
import string
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

N,M = nums()
A = nums()
sum_v = sum(A)
ans = 0
for i in A:
    if i >= sum_v / (4*M):
        ans += 1
if ans >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3768
require "numo/narray"

n = gets.to_i
h = Numo::Int64.parse(gets).reshape!(nil)
dp = Numo::Int64.new(n+10).fill(Numo::Int64::MAX)
dp[0] = 0

n.times do |i|
  1.upto(2) do |j|
    next unless i + j < n
    cost = (h[i+j] - h[i]).abs
    if dp[i+j] > dp[i] + cost
      dp[i+j] = dp[i] + cost
    end
  end
end
pp dp[n-1]

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

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


Measured memory_bytes: 256