akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (N, X, Y) = Scanner.Scan<int, int, int>();
            var counts = new int[N];

            for (var i = 1; i <= N; i++)
            {
                for (var j = i + 1; j <= N; j++)
                {
                    counts[Math.Min(j - i, Math.Abs(X - i) + Math.Abs(Y - j) + 1)]++;
                }
            }

            for (var i = 1; i < N; i++)
            {
                Console.WriteLine(counts[i]);
            }
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28444
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<functional>
#include<map>
using namespace std;
#pragma warning(disable: 4996)
int n, m;
int main() {
	cin >> n >> m;
	int z = n * 100 + m * 1800;
	cout << z*(1 << m) << endl;
	return 0;
}

Measured memory_bytes: 764
from __future__ import division
import math


def get_min(w, h):
    m = 1e11
    for x in [w // 3, w // 3 + 1]:
        if x == 0: continue
        a = [x*h, (w-x)*(h//2), (w-x)*(h - h//2)]
        print a
        m = min(m, max(a) - min(a))
    return m

digits = raw_input()
a, b = [int(x) for x in digits.split(' ')]
m = []
for i in range(a):
    s = raw_input()
    m.append(s)
print ''.join(['#'] * (b + 2))
for i in range(a):
    print '#' + m[i] + '#'
print ''.join(['#'] * (b + 2))


Measured memory_bytes: 2696
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int m = 0;
		HashMap<String, Integer> s = new HashMap<String, Integer>();
		int ans = 0;

		for (int i = 0; i < n; i++) {
			String a = sc.next();
			if (s.get(a) != null) {
				s.put(a, s.get(a) + 1);
			} else {
				s.put(a, 1);
			}
		}

		m = sc.nextInt();

		for (int i = 0; i < m; i++) {
			String a = sc.next();
			if (s.get(a) != null) {
				s.put(a, s.get(a) - 1);
			} else {
				s.put(a, -1);
			}
		}

		for (String i : s.keySet()) {
			if (s.get(i) > ans) {
				ans = s.get(i);
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 21844
//Classic
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define endl "\n"
#define debug(x) cout<<"AA Baju Smit------> "<<#x<<" -> "<<x<<endl
#define all(x) x.begin(),x.end()
#define mint map<int,int>
#define mod 1000000007
#define ciN cin

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


void solve() {
	string a; cin >> a;
	ll ans = 0;
	For(i, 0, a.size()) {
		ans += a[i] - '0';
	}
	if (ans % 9 == 0) {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
}




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


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

//	int t; cin >> t;
//	while (t--)
	solve();

	return 0;
}





///////////////////////////////////////////////////////////////////////////////////////////
//Kai baju bhai???



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


int main() {

    int n, m, x;
    cin >> n >> m >> x;
    int cnt = 0;
    rep(i, m) {
        int a; cin >> a;
        if (x < a) ++cnt;
    }
    cout << min(cnt, m - cnt) << 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 N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int result = 0;
		
		int[] B = new int[M];
		for (int i = 0; i < M; i++) {
			B[i] = sc.nextInt();
		}
		
		for (int i = 0; i < N; i++) {
			int sum = C;
			for (int j = 0; j < M; j++) {
				int A = sc.nextInt();
				sum += A*B[j];
			}
			if (sum > 0) {
				result++;
			}
		}
		
    	System.out.println(result);
    }
  
}


Measured memory_bytes: 24276
n = int(input())
if(n==1):
    print(0)
    exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5//1)+10 ):
        if(temp%i == 0):
            count=0
            while( temp%i == 0):
                count += 1
                temp = temp // i
            arr.append([i, count])

    if(temp != 1):
        arr.append([temp, 1])

    if(len(arr)==0):
        arr.append([n, 1])

    return arr

arr = factorization(n)

ans = 0
for i,j in arr:
    for k in range(1,100):
        j -= k
        if(j<0):
            break
        ans += 1

print(ans)

Measured memory_bytes: 63444
#include <stdio.h>
#include <time.h>

int main(){
	//char a[100000];
	
	int a,b,c,d;
	int q;
	
	
	
	//scanf("%s",a);
	scanf("%d %d",&a,&b);
	scanf("%d %d",&c,&d);
	
	
	
	
	printf("%d",(a-c)*(b-d));
	//printf("%s",b);
	
	return 0;
}

Measured memory_bytes: 128
n, d = map(int, input().split())
x = [[0]*d for i in range(n)]
count = 0
sum_ = 0
for i in range(n):
    x[i] = list(map(int, input().split()))

for i in range(n-1):
    for j in range(i+1,n):
        for k in range(d):
            
            sum_ = sum_ + (x[i][k]-x[j][k])**2
        
        if int(sum_**0.5)**2 ==sum_:
            count = count + 1
        sum_ = 0
    
print(count)            

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(size_t i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(size_t i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF INT_MAX/2
#define ShowAll(collection) for(auto i:collection){out(i);}
template<typename T> pair<vector<T>,int> getAuto() {int N; cin >> N; pair<vector<T>, int> rt;rt.first.resize(N);rt.second = N;REP(i, N) cin >> rt.first[i];return rt;}
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }

int main(){
	int N;
	cin >> N;
	ll ans = 1;
	REP(i, N) {
		ans = mod(ans*(i+1));
	}
	ans = mod(ans);
	out(ans);
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int len = Integer.parseInt(br.readLine());
		StringTokenizer tokenizer = new StringTokenizer(br.readLine(), " ");

		int[] arr = new int[len];
		int i = 0;
		while (tokenizer.hasMoreElements()) {
			arr[i++] = Integer.parseInt((String) tokenizer.nextElement());
		}

		sort(arr);
	}

	public static void sort(int[] arr) {
		printArr(arr);

		for (int i = 1; i < arr.length; i++) {
			for (int j = i; j >= 1; j--) {
				int current = arr[j];
				int prev = arr[j - 1];
				
				if (current < prev) {
					swap(arr, j - 1, j);
				} else {
					break;
				}
			}
			
			printArr(arr);
		}
	}
	
	public static void swap(int[] arr, int from, int to) {
		int temp = arr[from];
		arr[from] = arr[to];
		arr[to] = temp;
	}
	
	public static void printArr(int[] arr) {
		String msg = "";
		for (int i = 0; i < arr.length; i++) {
			msg += arr[i];
			if (i == arr.length - 1) {
				break;
			}
			msg += " ";
		}
		System.out.println(msg);
	}

}

Measured memory_bytes: 57852
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
vector<vector<int> > g;
vector<int> A;
vector<int> dp[5001][2];
int N;
vector<int> ndp[2];
void amin(int &a, const int &b) {
	a = min(a, b);
}
const int INF = (int)1 << 60;
int dfs(int a, int p) {
	if (A[a] < 0) {
		dp[a][1].push_back(A[a]);
	}
	else {
		dp[a][0].push_back(A[a]);
	}
	for (int b : g[a]) {
		if (b != p) {
			dfs(b, a);
			int mx1 = max(dp[a][0].size(), dp[a][1].size());
			int mx2 = max(dp[b][0].size(), dp[b][1].size());
			ndp[0].clear();
			ndp[0].resize(mx1 + mx2,INF);
			ndp[1].clear();
			ndp[1].resize(mx1 + mx2,INF);
			for (int i = 0; i < dp[a][0].size(); i++) {
				for (int j = 0; j < dp[b][0].size(); j++) {
					amin(ndp[0][i + j], dp[a][0][i] + dp[b][0][j]);
					if (dp[b][0][j] < INF) {
						amin(ndp[0][i + j + 1], dp[a][0][i]);
					}
				}
				for (int j = 0; j < dp[b][1].size(); j++) {
					amin(ndp[1][i + j], dp[a][0][i] + dp[b][1][j]);
					if (dp[b][1][j] < 0) {
						amin(ndp[0][i + j + 1], dp[a][0][i]);
					}
				}
			}
			for (int i = 0; i < dp[a][1].size(); i++) {
				for (int j = 0; j < dp[b][0].size(); j++) {
					amin(ndp[1][i + j], dp[a][1][i] + dp[b][0][j]);
					if (dp[b][0][j] < INF) {
						amin(ndp[1][i + j + 1], dp[a][1][i]);
					}
				}
				for (int j = 0; j < dp[b][1].size(); j++) {
					amin(ndp[1][i + j], dp[a][1][i] + dp[b][1][j]);
					if (dp[b][1][j] < 0) {
						amin(ndp[1][i + j + 1], dp[a][1][i]);
					}
				}
			}

			swap(ndp[0], dp[a][0]);
			swap(ndp[1], dp[a][1]);
		}
	}
}

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

	cin >> N;
	A.resize(N);
	g.resize(N);

	int res = 0;
	int a, b;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N - 1; i++) {
		cin >> a >> b; a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0, -1);
	res = INF;
	for (int i = 0; i < dp[0][0].size(); i++) {
		if (dp[0][0][i] < INF) {
			res = min(res, i);
		}
	}
	for (int i = 0; i < dp[0][1].size(); i++) {
		if (dp[0][1][i] < 0) {
			res = min(res, i);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 164096
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const int mod = 100000003;

string s;
ll result=0;

void serch(ll current, int index, ll sum) {
	if (index == s.size() - 1) {
		current = current * 10 + s[index]-'0';
		sum += current;
		result += sum;
		return ;
	}
	current = current * 10 + s[index]-'0';
	serch(current, index + 1, sum);
	serch(0, index + 1, sum + current);
}

int main() {
	cin >> s;
	serch(0, 0, 0);
	print(result);
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())

    st = [N + 1]  # (1,N)
    d = 2
    while d * d <= N:
        if N % d == 0:
            st.append(d + N // d)  # (d, N // d)
        d += 1

    print(min(st) - 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

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

const int maxn = 5000;

bool a[maxn];
bool c[maxn];

int main() {
	ll A,B,C,D,E,F; cin>>A>>B>>C>>D>>E>>F; fill(a,a+maxn,false); fill(c,c+maxn,false);
	for (int i = 0; i <= F; i++) {
		for (int j = 0; j <= F; j++) {
			ll cc = C*i + D*j;
			if (cc <= F) c[cc] = true;
			ll aa = A*i + B*j;
			if (100*aa <= F) a[aa] = true;
		}
	}

	ll ba = 1, bc = 0;

	for (int i = 0; i < maxn; i++) {
		for (int j = 0; j < maxn; j++) {
			if (!a[i] || !c[j]) continue;
			int aa = i, cc = j;
			if (100*aa + cc > F) continue;
			if (cc > E*aa) continue;
			if (bc * aa <= ba * cc) { ba = aa; bc = cc; }
		}
	}

	cout<<(100*ba + bc)<<" "<<bc<<endl;	
}


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


int main(){
	int fh, oh, fif, target, result = 0;
	cin >> fh >> oh >> fif >> target;
	int start = target / 500;
    if (start > fh)start = fh;
	for (int i = start; i > -1; i--) {
        int mini_target = target - (500 * i);
		for (int j = oh; j > -1; j--) {
			int mini_mini_target = mini_target - 100 * j;

			if ((mini_mini_target > 50 * fif) 
				|| mini_mini_target < 0)continue;
			result++;
		}
	}
	cout << result << endl;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
ans = len(make_divisors(N-1))-1
a = make_divisors(N)[1:]
for x in a:
    n = N
    while n%x == 0:
        n //= x
    if n%x == 1:
        ans += 1
print (ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    string s, t;
    cin >> s >> t;
    cout << t + s << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
   return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;
#define ASCII 48
int main() {
	int a, b;
	cin >> a >> b;
	
	int ans[3];

	ans[0] = a + b;
	ans[1] = a - b;
	ans[2] = a * b;

	int max = ans[0];

	if (ans[1] > max)max = ans[1];
	if (ans[2] > max)max = ans[2];

	cout << max << endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	string s, t;
	cin >> s >> t;
	if (s == t)
		puts("H");
	else
		puts("D");
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val c = sc.nextInt()

    val stc = Array(n) { Triple(sc.nextInt(), sc.nextInt(), sc.nextInt()) }

    val p = stc.groupBy { it.third }
            .map { it.value.sortedBy { it.first } }
            .flatMap {
                it.fold(mutableListOf()) { acc: List<Triple<Int, Int, Int>>, tri ->
                    val last = acc.lastOrNull() ?: return@fold acc + tri

                    if (last.second == tri.first)
                        acc.dropLast(1) + last.copy(second = tri.second)
                    else
                        acc + tri
                }
            }

    var cur = 0
    val ret = (p.map { it.first to true } + p.map { it.second to false })
            .sortedBy { it.first }
            .map {
                if (it.second) {
                    cur += 1
                } else {
                    cur -= 1
                }
                cur
            }
            .max()

    println(ret)
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(ll i=x;i<y;i++)
#define frr(i,x,y) for(ll i=x-1;i>=y;i--)
#define inf 10000000000000000
const ll mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

void solve()
{
    ll k,a,b;
    cin>>k>>a>>b;
    fr(i,a,b+1)
    {
        if(i%k==0)
        {
            cout<<"OK\n";
            return;
        }
    }
    cout<<"NG\n";
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll t=1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }
	return 0;
}

Measured memory_bytes: 3640
N=int(input())
A=[]
total=0
for i in range(N):
    A.append(list(map(str,input().split())))
for i in range(N):
    if A[i][1]=='BTC':
        total+=float(A[i][0])*380000.0
    else:
        total+=float(A[i][0])
print(total)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>



int cmp(const void* a, const void* b) {
	return *(long*)b - *(long*)a;
}

int main(void) {
	long a[300000];
	long n, i;
	long long ans = 0;
	scanf("%ld", &n);
	for (i = 0; i < 3 * n; i++) {
		scanf("%ld", &a[i]);
	}
	qsort(a, 3 * n, sizeof(long), cmp);
	for (i = 0; i < n; i++) {
		ans += (long long)a[i * 2 + 1];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4860
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int k = sc.nextInt();
        long ans = 0;

        for (int i = 1; i <= n; i++) {
            // bの値を動かす
            if (i - 1 < k) {
                continue;
            }
            long setCount = n / i;
            int canUse = i - k;
            ans += setCount * canUse;
            if (n % i - k >= 0) {
                ans += (n % i) - k + 1;
            }
        }
        if (k == 0) {
            ans = n * n;
        }
        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 23636
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

// �ő���񐔂����߂�֐�
long long gcd(long long a, long long b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

// �ŏ����{�������߂�֐�
long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

int main() {

	long long N;
	cin >> N;

	vector<long long> T(N, 0);
	for (long long i = 0; i < N; i++) {
		cin >> T[i];
	}

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

	long long ans = T[0];
	long long v_max = 0;
	long long v_min = 0;
	long long v_gcd = 0;

	for (long long i = 1; i < N; i++) {
		v_max = max(ans, T[i]);
		v_min = min(ans, T[i]);
		if (0 != v_max % v_min) {
			v_gcd = gcd(v_max, v_min);
			v_max = v_max / v_gcd;
			v_min = v_min / v_gcd;
			ans = v_max * v_min * v_gcd;
		}
		else {
			ans = v_max;
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    long N;
    cin >> N;
    vector<long> v;
    for(long i=0;i<N;i++){
        long a;
        cin >> a;
        v.push_back(a-(i+1));
    }
    sort(v.begin(),v.end());
    long sum = 0;
    long b=v.at(N/2);
    for(auto it=v.begin();it!=v.end();it++)
        sum += abs(*it-b);

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2420
///*
#include<iostream>
using namespace std;

int main() {

	int ball, human;
	cin >> ball >> human;
	
	if (human == 1 || ball == human) {
		cout << "0" << endl;
	}
	else if (ball < human) {
		cout << "1" << endl;
	}
	else {
		cout << ball - human << endl;

	}


	return 0;
}
//*/

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

int main() {
  vector<vector<int>> b(3, vector<int>(3));
  cin >> b[0][0] >> b[0][1] >> b[0][2];
  cin >> b[1][0] >> b[1][1] >> b[1][2];
  cin >> b[2][0] >> b[2][1] >> b[2][2];
  int n;
  cin >> n;
  vector<int> m(n);
  for(int i=0;i<n;i++){
    cin >> m.at(i);
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(m.at(i) == b[j][k]){
          b[j][k] = 1000;
        }
      }
    }
  }
  if(b[0][0]+b[0][1]+b[0][2]==3000){
    cout << "Yes";
    return 0;
  }else if(b[1][0]+b[1][1]+b[1][2]==3000){
    cout << "Yes";
    return 0;
  }else if(b[2][0]+b[2][1]+b[2][2]==3000){
    cout << "Yes";
    return 0;
  }else if(b[0][0]+b[1][0]+b[2][0]==3000){
    cout << "Yes";
    return 0;
  }else if(b[0][1]+b[1][1]+b[2][1]==3000){
    cout << "Yes";
    return 0;
  }else if(b[0][2]+b[1][2]+b[2][2]==3000){
    cout << "Yes";
    return 0;
  }else if(b[0][0]+b[1][1]+b[2][2]==3000){
    cout << "Yes";
    return 0;
  }else if(b[0][2]+b[1][1]+b[2][0]==3000){
    cout << "Yes";
    return 0;
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
using namespace std;

int main() {
  ll n, a;
  cin >> n >> a;
  cout << (n % 500 > a ? "No" : "Yes") << endl;
}


Measured memory_bytes: 256
X = int(input())
v = X % 100

f = v // 5
v -= f * 5

e = v // 4
v -= e * 4

d = v // 3
v -= d * 3

c = v // 2
v -= d * 2

b = v // 1
v -= b

a = (X - (101 * b + 102 * c + 103 * d + 104 * e + 105 * f)) // 100
print(1 if 0 <= a else 0)

Measured memory_bytes: 38384
#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/STACK: 20000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define vec vector
#define all(x) x.begin(), x.end()
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    string s; cin>>s;
    int n=s.size();
    int ans=INF;
    for(int i=0;i<n-2;i++){
        int sum=0;
        for(int j=i;j<i+3;j++){
            sum*=10;
            sum+=s[j]-'0';
        }
        // cout<<sum<<endl;
        ans=min(ans,abs(sum-753));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
  int m[6];
} DICE;

void diceroll(DICE *,char);
int judge(DICE *,DICE *);

int main(){
  DICE dice[2], tmp;
  int i, j, k;
  
  //input dice
  for(i=0;i<6;i++) scanf("%d",&dice[0].m[i]);
  for(i=0;i<6;i++) scanf("%d",&dice[1].m[i]);

  for(i=0;i<4;i++){
    diceroll(&dice[0],'S');
    
    for(j=0;j<5;j++){
      diceroll(&dice[0],'E');
   
      if(judge(&dice[0],&dice[1])==0){
	printf("Yes\n");
	return 0;
      }
    }
    
  }


  for(i=0;i<4;i++){
    diceroll(&dice[0],'E');
    
    for(j=0;j<5;j++){
      diceroll(&dice[0],'S');
   
      if(judge(&dice[0],&dice[1])==0){
	printf("Yes\n");
	return 0;
      }
    }
    
  }

  for(i=0;i<4;i++){
    diceroll(&dice[0],'W');
    
    for(j=0;j<5;j++){
      diceroll(&dice[0],'N');
   
      if(judge(&dice[0],&dice[1])==0){
	printf("Yes\n");
	return 0;
      }
    }
    
  }

  for(i=0;i<4;i++){
    diceroll(&dice[0],'N');
    
    for(j=0;j<5;j++){
      diceroll(&dice[0],'W');
   
      if(judge(&dice[0],&dice[1])==0){
	printf("Yes\n");
	return 0;
      }
    }
    
  }

  
  
  printf("No\n");
  return 0;
}



void diceroll(DICE *dice,char c){
  int tmp;
  tmp=dice->m[0];
  
  if(c=='N'){
    dice->m[0]=dice->m[1];
    dice->m[1]=dice->m[5];
    dice->m[5]=dice->m[4];
    dice->m[4]=tmp;
  }
  
  else if(c=='S'){
    dice->m[0]=dice->m[4];
    dice->m[4]=dice->m[5];
    dice->m[5]=dice->m[1];
    dice->m[1]=tmp;
  }
  
  else if(c=='E'){
    dice->m[0]=dice->m[3];
    dice->m[3]=dice->m[5];
    dice->m[5]=dice->m[2];
    dice->m[2]=tmp;
  }
  
  else if(c=='W'){
    dice->m[0]=dice->m[2];
    dice->m[2]=dice->m[5];
    dice->m[5]=dice->m[3];
    dice->m[3]=tmp;
  }

  else return;
}

int judge(DICE *d1, DICE *d2){
  int i;

  for(i=0;i<6;i++){
    if(d1->m[i]!=d2->m[i]) return 1;
  }
  
  return 0;
}



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

using namespace std;
using ll = long long;

class Fast_Factorization {
private:
	int n;
	vector<int> factor;
public:
	Fast_Factorization(int _n):n(_n) {
		factor.assign(n, 0);
		iota(factor.begin(), factor.end(), 0);
		for(int i = 2; i < n; i++) {
			if(factor[i] != i)continue;
			for(int j = i + i; j < n; j += i) factor[j] = i;
		}
	}

	//v < nが要求される
	map<int, int> sieve(int v) {
		map<int, int> ret;
		while(v != factor[v]) {
			ret[factor[v]]++;
			v /= factor[v];
		}
		if(v != 1)ret[v]++;
		return ret;
	}


};
const int M = 1000001;
Fast_Factorization fact(M);


int main()
{
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++)cin >> a[i];
	vector<int> v(M);

	for(int i = 0; i < n; i++) {
		auto mp = fact.sieve(a[i]);
		for(auto j : mp)v[j.first]++;		
	}

	int cnt = count_if(v.begin(), v.end(), [](int a){return a > 1;});
	int GCD = accumulate(a.begin(), a.end(), 0, [](int a, int b){return gcd(a, b);});
	cerr << GCD << endl;

	if(cnt == 0) {
		cout << "pairwise coprime" << endl;
	} else if(GCD == 1) {
		cout << "setwise coprime" << endl;
	} else {
		cout << "not coprime" << endl;
	}
	
}

Measured memory_bytes: 14876
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            while (a[i] % 2 == 0) {
                ans++;
                a[i] = a[i] / 2;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 37564
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
int mod = 1000000007;
int mod1 = 998244353;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void u(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb]){
            v[ra] = v[rb];
            sz[rb]+=sz[ra];
        }else{
            v[rb]=v[ra];
            sz[ra]+=sz[rb];
        }
    }
    bool f(int a,int b){
        //same set
        return (root(a)==root(b));
    }
   
    
};
vector<int> matmul(vector<int> a,vector<int> b){
    vector<int> c(4,0);
    c[0] = (a[0]%mod*b[0]%mod + a[1]%mod*b[2]%mod)%mod;
    c[1] = (a[0]%mod*b[1]%mod + a[1]%mod*b[3]%mod)%mod;
    c[2] = (a[2]%mod*b[0]%mod + a[3]%mod*b[2]%mod)%mod;
    c[3] = (a[2]%mod*b[1]%mod + a[3]%mod*b[3]%mod)%mod;
    return c;
}
vector<int> id={1,0,0,1};

int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
	int n;
  	cin>>n;
  	vector<pair<int,int> > v(n);
  	for(int i=0;i<n;i++){
    	int a,b;
      	cin>>a>>b;
      	v[i]={b,a};
    }
  	sort(all(v));
  	int t=0;
  	for(int i=0;i<n;i++){
    	int nt = t+v[i].second;
      	if(nt>v[i].first){
         	cout<<"No";
          	exit(0);
        }
      	t = nt;
    }
  	cout<<"Yes";
}


Measured memory_bytes: 9076
#include<cstdio>

int row, col;
int n, i , j;

int c[105][105];
int num[10005];

int main()
{
	while (~scanf("%d%d", &row, &col))
	{
		int cnt = 1;
		scanf("%d", &n);
		for (i = 1; i <= n; i++) scanf("%d", &num[i]);

		for (i = 1; i <= row; i++)
		{
			if (i & 1)
			{
				for (j = 1; j <= col; j++)
				{
					if (num[cnt])
					{
						c[i][j] = cnt;
						num[cnt]--;
					}
					else
					{
						cnt++;						
						c[i][j] = cnt;
						num[cnt]--;
					}
				}
			}
					
			else
			{
				for (j = col; j >= 1; j--)
				{
					if (num[cnt])
					{
						c[i][j] = cnt;
						num[cnt]--;
					}
					else
					{
						cnt++;						
						c[i][j] = cnt;
						num[cnt]--;
					}
				}
			}
		}

		for (i = 1; i <= row; i++)
		{
			for (j = 1; j <= col; j++)
			{
				printf("%d", c[i][j]);
				if (j != col) printf(" ");
				else printf("\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
n,k,q = [int(i) for i in input().split()]
ans = [0]*n
judge = []

for _ in range(q):
    a = int(input())
    ans[a-1] += 1
    
for i,x in enumerate(ans):
    if k+x > q:
        judge.append("Yes")
    else:
        judge.append("No")

for i,v in enumerate(judge):
    print(v)

Measured memory_bytes: 5504
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;

vector<bool> can_reach;

void dfs(int src, int count, map<int, vector<int>> &map){
  if(count < 0) return;
  if(can_reach[src]) return;

  count--;
  can_reach[src] = true;
  for(int dst: map[src]){
    dfs(dst, count, map);
  }
}

int main() {
  int N, M;
  cin >> N >> M;

  map<int, vector<int>> map;
  for (int i = 0; i < N; ++i) {
    map[i] = vector<int>();
  }

  int a, b;
  for (int i = 0; i < M; ++i) {
    scanf("%d %d", &a, &b);
    a--; b--;
    if(a > b) swap(a, b);
    map[a].push_back(b);
  }

  //
  can_reach.resize(N);
  fill(can_reach.begin(), can_reach.end(), false);
  dfs(0, 2, map);

  //
//  priority_queue<int, vector<int>, greater<int>> q;
//  vector<bool> can_reach(N, false);
//  q.push(0);
//  while(!q.empty()){
//    int src = q.top();
//    q.pop();
//
//    if(can_reach[src]) continue;
//    can_reach[src] = true;
//
//    for(int dst: map[src]){
//      if(can_reach[dst]) continue;
//      q.push(dst);
//    }
//  }

  //
  if(can_reach[N-1]) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;

  return 0;
}



Measured memory_bytes: 19456
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

ll dp[3010][3010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n;
  string s;
  cin >> n >> s;

  REP(i, n) dp[0][i] = 1;
  FOR(i, 1, n) {
    if(s[i-1] == '<') {
      dp[i][0] = dp[i-1][0];
      FOR(j, 1, n-i) {
        dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % MOD;
      }
    } else {
      dp[i][n-i-1] = dp[i-1][n-i];
      for(ll j=n-i-2; j>=0; --j) {
        dp[i][j] = (dp[i][j+1] + dp[i-1][j+1]) % MOD;
      }
    }
  }

  ll ans = 0;
  REP(i, n) (ans += dp[n-1][i]) %= MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 70016
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<ctime>
#include<iostream>
typedef long long LL;
using namespace std;
const int maxn = 1e6;
int main()
{
	int a,b;
	while( cin >> a >> b ){
		int t = a;
		if( b < a )	t -= 1;
		cout << t << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int n,m,k,a[305][305],row[305],col[305];

string s[305];

int main()
{ios_base::sync_with_stdio(false);
cin>>n>>m>>k;

int ptr=1;

rep(i,0,n-1)cin>>s[i];

rep(i,0,n-1)rep(j,0,m-1)if(s[i][j]=='#')row[i]++,col[j]++;

rep(i,0,n-1)
{
	rep(j,0,m-1)
	{
		if(s[i][j]=='.')
		continue;
		int x1=0,y1=0,x2=n-1,y2=m-1;
		ren(ii,i-1,0)
		{
			if(s[ii][j]=='#')
			{
				x1=i;
				break;
			}
		}
		rep(ii,i+1,n-1)
		{
			if(s[ii][j]=='#')
			{
				x2=ii-1;
				break;
			}
		}
		ren(jj,j-1,0)
		{
			if(col[jj])
			{
				y1=j;
				break;
			}
		}
		rep(jj,j+1,m-1)
		{
			if(col[jj])
			{
				y2=jj-1;
				break;
			}
		}
		rep(ii,x1,x2)rep(jj,y1,y2)a[ii][jj]=ptr;
		ptr++;
	}
}
rep(i,0,n-1)
{
	rep(j,0,m-1)
	{
		ol(a[i][j]);os;
	}
	on;
}
return 0;
}



Measured memory_bytes: 1280
S = input()
N = len(S)
A = [0] * (N + 1)
B = [0] * (N + 1)
for i in range(N):
    if S[i] == "<":
        A[i+1] = A[i] + 1
    else:
        A[i+1] = 0

for i in range(N-1, -1, -1):
    if S[i] == ">":
        B[i] = B[i+1] + 1
    else:
        B[i] = 0

print(sum([max(A[i], B[i]) for i in range(N + 1)]))

Measured memory_bytes: 33192
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
A = LI()

ans = 0

max_ = 0
for i in range(N):
    if A[i] < max_:
        ans += max_-A[i]
    else:
        max_ = A[i]

print(ans)

Measured memory_bytes: 94396
#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>
#include <cctype>
#include <utility>

using namespace std;

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


static const double EPS = 1e-8;

char stage[20][20];

int tx[] = {-1,0,1,0};
int ty[] = {0,1,0,-1};

bool isPrime[300001];



int main()
{
	int N;
	while(~scanf("%d",&N)){
		if(N==1) break;

		bool isPrime[300001];
		memset(isPrime,-1,sizeof(isPrime));

		printf ("%d:",N);
		for(int i=2;i<=N;i++){
			if(!isPrime[i]) continue;
			if((N % 7 == 1 || N % 7 == 6)
				&& (i % 7 == 1 || i % 7 == 6)
				&& N % i == 0 && ((N / i) % 7 == 1 || (N / i) % 7 == 6) ){
					for(int j=i+i;j<=300000;j+=i){
						isPrime[j] = false;
					}
					printf(" %d",i);
			}
		}
		printf("\n");
	}

}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s, t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());

    if(s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
string s;
int N,x[14];
ll X;
ll inf=1e14;
ll dp[2][9*14+1][25606][3];
vector<ll> ash;
int nxt[25606][10];
int main(){
	cin>>s;
	N=s.size();
	rep(i,N) x[i]=s[i]-'0';
	rep(i,N) X=X*10+x[i];
	rep(a,43) rep(b,29) rep(c,15) rep(d,15){
		ll v=1;
		rep(i,a) v=min(inf+1,v*2);
		rep(i,b) v=min(inf+1,v*3);
		rep(i,c) v=min(inf+1,v*5);
		rep(i,d) v=min(inf+1,v*7);
		if(v<=inf) ash.pb(v);
	}
	sort(all(ash));
	int M=ash.size();
	rep(i,M) rep(j,10){
		ll x=ash[i]*(j+1);
		if(x<=inf) nxt[i][j]=lower_bound(all(ash),x)-ash.begin();
		else nxt[i][j]=-1;
	}
	dp[0][0][0][1]=1;
	rep(i,N){
		rep(j,9*i+1) rep(k,M) rep(l,3) dp[1-i%2][j][k][l]=0;
		rep(j,9*i+1) rep(k,M) rep(l,3){
			if(dp[i%2][j][k][l]==0) continue;
			rep(d,10){
				int nk=nxt[k][d];
				if(nk<0) continue;
				int nl=l;
				if(nl==1){
					if(d<x[i]) nl=0;
					if(d>x[i]) nl=2;
				}
				dp[1-i%2][j+d][nk][nl]+=dp[i%2][j][k][l];
			}
		}
	}
	ll ans=0;
	int J=accumulate(x,x+N,0);
	ll val=1;
	rep(i,N) val*=(x[i]+1);
	int K=lower_bound(all(ash),val)-ash.begin();
	rep(j,9*N+1) rep(k,M) rep(l,3){
		if(j<J||(j==J&&k<K)||(j==J&&k==K&&l==0)) ans+=dp[N%2][j][k][l];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 140800
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;


class maki {
	//最大公約数
	static long gcd(long x,long y){
    	if(y==0){
    		return x;
    	}
    	return gcd(y,x%y);
    }

    static void Main(string[] args) {
        var cin=Console.ReadLine().Split().Select(long.Parse).ToArray();
        //int n = int.Parse(Console.ReadLine());
        //string s=Console.ReadLine();
 
        long a=cin[0];
        long b=cin[1];
        long c=cin[2];
        long d=cin[3];
        long e=c*d/gcd(c,d);//最小公倍数
        a--;
        long ans= b-((b/c)+(b/d)-(b/e));//b以下について
        ans-= a-((a/c)+(a/d)-(a/e));//a未満(a-1以下)の数を引く
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

ll twoRow(ll a, ll b, ll mod)
{
	ll ret = 1;
	for(ll i = 1 ;i <= a+b;++i)
	{
		ret *= i;
		ret %= mod;
	}
	for(ll i = 1 ;i <= a;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	for(ll i = 1 ;i <= b;++i)
	{
		ret *= div2mul(i,mod);
		ret %= mod;
	}
	return ret;
}

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return (ret);
}

int main()
{
	ll N,M,T=0;
	ll i,j,k;
	ll K,X,Y;
	ll A[512]={0};
	ll B[512]={0};
	ll px = 0;
	ll ans = 0;
	cin>>N>>M;
	for(i=0;i<N;++i)
	{
		cin>>A[i];
		T += A[i];
	}
	vector< ll > v;
	for(i = 1; i * i <= T; i++) {
		if(T % i == 0) {
			v.push_back(i);
			if(i * i != T) v.push_back(T / i);
		}
	}
	sort(v.begin(), v.end());
	int v_len = v.size();
	for(i=v_len-1;i>=0;--i)
	{
		K = v[i];
		X = 0;
		for(j=0;j<N;++j)
		{
			k = A[j]-(ll)(A[j]/K)*K;
			X += k;
			B[j] = k;
		}
		sort(B,B+N);
		k = N - X/K;
		X = 0;
		for(j=0;j<k;++j)
		{
			X += B[j];
		}
		if(X <= M)
		{
			ans = K;
			break;
		}
	}

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




















Measured memory_bytes: 256
def solve(N, M, sc):
    ans = 0
    digits = [-1] * N
    for s, c in sc:
        _digits = N - s
        if digits[_digits] == -1:
            digits[_digits] = c
        elif digits[_digits] != c:
            ans = -1
            break

    if digits[-1] == 0 and N > 1:
        ans = -1

    if digits[-1] == -1:
        digits[-1] = 1 if N > 1 else 0

    for d in range(N):
        digits[d] = 0 if digits[d] == -1 else digits[d]

    if ans != -1:
        ans = sum([digits[i] * (10 ** i) for i in range(N)])

    print(ans)


if __name__ == '__main__':
    N, M = map(int, input().split())
    sc = []
    for _ in range(M):
        sc.append(tuple(map(int, input().split())))
    solve(N, M, sc)


Measured memory_bytes: 3188
# AOJ 0109 Smart Calculator
# Python3 2018.6.18 bal4u

INF = 1000000010
LEFT  = INF+1
RIGHT = INF+2
PLUS  = INF+3
MINUS = INF+4
MUL   = INF+5
DIV   = INF+6
token = { '+':PLUS, '-':MINUS, '*':MUL, '/':DIV }
rank = { PLUS:2, MINUS:2, MUL:3, DIV:3, LEFT:1, RIGHT:1 }

S, top = [0]*200, 0
Q, end = [0]*200, 0

def getInt():
	global id
	global buf
	k = ''
	while buf[id] >= '0' and buf[id] <= '9':
		k += buf[id]
		id += 1
	return int(k)

n = int(input())
for i in range(n):
	buf = list(input())
	id, f, top, end = 0, True, 0, 0
	while True:
		if buf[id] == '=':
			while top > 0:
				top -= 1
				Q[end] = S[top]
				end += 1
			break;
		if buf[id] == '-' and f and buf[id+1] >= '0' and buf[id+1] <= '9':
			id += 1
			Q[end] = -getInt()
			end += 1
			f = False
			continue
		
		f = False
		if buf[id] >= '0' and buf[id] <= '9':
			Q[end] = getInt()
			end += 1
		elif buf[id] == ')':
			while S[top - 1] != LEFT:
				top -= 1
				Q[end] = S[top]
				end += 1
			top -= 1
			id += 1
		elif buf[id] == '(':
			S[top] = LEFT
			top += 1
			id += 1
			f = True
		else:
			k = token[buf[id]]
			id += 1
			while top > 0:
				if rank[k] <= rank[S[top-1]]:
					top -= 1
					Q[end] = S[top];
					end += 1
				else: break
			S[top] = k;
			top += 1

	top = 0
	for i in range(end):
		k = Q[i]
		if k > INF:
			d1, d2 = S[top-1], S[top-2]
			top -= 2
			if k == PLUS: d2 += d1
			elif k == MINUS: d2 -= d1
			elif k == MUL: d2 *= d1
			else:
				if (d2 > 0 and d1 < 0) or (d2 < 0 and d1 > 0):
					d2 //= -d1
					d2 = -d2
				else: d2 //= d1
			S[top] = d2
		else: S[top] = k
		top += 1
	print(S[top-1])


Measured memory_bytes: 5628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define rrep(i,a,b) for(int i = a; i >= b; i--)
#define allof(a) (a).begin(), (a).end()
#define INF (1<<30)
#define INFLL (1ll << 60)

const ll mod = 1e9 + 1;

// 型による変数のオーバーフローに気をつけろ！！

int main() {
	int n, m;
	cin >> n >> m;
	vector<ll> x(n);
	vector<ll> y(n);
	vector<ll> z(n);
	rep(i, 0, n) {
		cin >> x[i] >> y[i] >> z[i];
	}

	// 絶対値の和が最大
	// O(n^2)いける
	// +と-を含んだ8通りを考える
	priority_queue<ll> pq;
	vector<ll> sum(n, 0);
	rep(bit, 0, 1 << 3) { // 000 001 011のように 1なら+ 0なら-
		ll total = 0;
		ll a, b, c;
		rep(i, 0, n) sum[i] = 0;
		rep(i, 0, n) {
			if (bit & (1 << 0)) sum[i] += x[i];
			else sum[i] -= x[i];
			if (bit & (1 << 1)) sum[i] += y[i];
			else sum[i] -= y[i];
			if (bit & (1 << 2)) sum[i] += z[i];
			else sum[i] -= z[i];
		}
		sort(allof(sum),greater<ll>());
		rep(i, 0, m) total += sum[i];
		pq.push(total);
		//cout << total << endl;
	}

	cout << pq.top() << endl;

	return 0;
}

Measured memory_bytes: 256