akhauriyash/Code-Regression huggingface dataset:
<?php

$a = (int)trim(fgets(STDIN));

$i = 0;
$pairs = [];
for ($i = 1; $i <= $a / 2; $i++) {
    if ($a % $i === 0) {
        $pairs[] = $a / $i + $i;
    }
    if ($a / $i <= $i) {
        break;
    }
}

echo min($pairs) - 2;


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

// in-short-use macros

#define all(c) (c).begin(),(c).end()
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010



//main function here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll n,k;
    cin>>n>>k;
    ll sum=0;
    ll ne=0,ol=0;
    for(int i=0;i<k;i++)
    {
        ne=(ne+(n-i))%mod;
        ol=(ol+i)%mod;
    }  
    // cout<<ne<<" "<<ol<<"\n";
    for(int i=k;i<=n+1;i++)
    {
        sum = ((sum+ne-ol)+mod+1)%mod;
        ne=(ne+(n-i))%mod;
        ol=(ol+i)%mod;
    }  
    cout<<sum%mod<<"\n";
    return 0;
}

Measured memory_bytes: 3648
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0

for i in range(n):
    for j in range(1, n):
        for k in range(2, n):
            if i < j and j < k:
                if l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
                    if l[i] + l[j] > l[k]:
                        ans += 1

print(ans)

Measured memory_bytes: 9196
/**
 * author: BueVonHun 🐼🎋
 * More Info: https://github.com/Bue-von-hon
**/

#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <cstring>
#include <cmath>

typedef long long ll;
using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl '\n'
#define m_p make_pair
#define pii pair<int,int>
#define piii pair<int,pii>
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

template <class T> T _min(T a,T b){return (a<b ? a : b);}
template <class T> T _max(T a,T b){return (a>b ? a : b);}
template<class T> void read(T& x) {cin >> x;}

int test_case;
int main(void) {
    fast_cin();

    read(test_case);
    deque<char> v;
    int Rcount=0;
    for (int i = 0; i < test_case; i++) {
        char ch;
        cin >> ch;
        v.push_back(ch);
        if (ch=='R') Rcount++;
    }
    int size = v.size();
    int count = 0;
    int pos = 0, rear = size-1;
    for (int i = size-1; i >= 0; i--) {
        if (v[i]=='R') {rear=i; break;}
    }
    while (true) {
        if (pos >= rear || Rcount==0) break;
        if (v[pos]=='W') {
            swap(v[pos], v[rear]);
            pos++;
            count++;
            Rcount--;
            for (int i = rear; i >= 0; i--) {
                if (v[i]=='R') {rear=i; break;}
            }
        }
        else pos++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3744
uses math;
var
	ans,n,Ma,Mb,i,j,a,b,c,x,mp,mm:Longint;
	p,m:array[0..400]of Longint;
begin
	read(n,Ma,Mb);
	ans:=10000;
	for i:=1 to 400 do begin
		p[i]:=ans;
		m[i]:=ans;
	end;
	for i:=1 to n do begin
		read(a,b,c);
		x:=Ma*b-Mb*a;
		if x>0 then begin
			for j:=mp downto 0 do p[j+x]:=min(p[j+x],p[j]+c);
			mp:=min(mp+x,300);
		end else if x<0 then begin
			for j:=mm downto 0 do m[j-x]:=min(m[j-x],m[j]+c);
			mm:=min(mm-x,300);
		end else ans:=min(ans,c);
	end;
	for i:=1 to 300 do ans:=min(ans,p[i]+m[i]);
	if ans<10000 then writeln(ans)else writeln(-1);
end.

Measured memory_bytes: 128
using static System.Math;
using System;

public class hello
{
	public static void Main()
	{
		var a = new decimal[31];
		a[30] = (decimal)Pow(2, 23);
		for (int i = 29; i >= 0; i--)
			a[i] = a[i + 1] / 2m;
		var n = int.Parse(Console.ReadLine().Trim());
		for (int i = 0; i < n; i++)
		{
			var s = Console.ReadLine().Trim();
			var t = Convert.ToInt32(s, 16);
			Console.WriteLine(getAns(a, t));
		}
	}
	static string Format(string s)
	{
		var dp = s.IndexOf('.');
		var s1 = s.Substring(0, dp + 1);
		var s2 = s.Substring(dp + 1);
		var s3 = s2.ToCharArray();
		Array.Reverse(s3);
		var f = true;
		var wans = "";
		for (int i = 0; i < s2.Length; i++)
		{
			if (f && s3[i] == '0') continue;
			else if (f && s3[i] != '0') { f = false; wans += s3[i]; }
			else wans += s3[i];
		}
		if (wans == "") wans = "0";
		var s4 = wans.ToCharArray();
		Array.Reverse(s4);
		return s1 + new string(s4);
	}
	static string getAns(decimal[] a, int t)
	{
		var w = 0m;
		for (int i = 0; i < 31; i++)
			w += ((t >> i) & 1) * a[i];
		var ans = Format(w.ToString());
		if (((t >> 31) & 1) == 1) ans = "-" + ans;
		return ans;
	}
}



Measured memory_bytes: 20212
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define si3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld%lld%lld",&a,&b,&c)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define pY          printf("YES")
#define pN          printf("NO")
#define py          printf("Yes")
#define pn          printf("No")
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007



ll mx=1000000;
ll a[1000010];
vector<ll>p[1000005];
bool vis[1000005], m[1000005];
void prime_generate()
{
    for(ll i=2; i<=mx; i++)
    {
        if(!vis[i])
        for(ll j=i; j<=mx; j+=i)
        {
            vis[j]=1;
            p[j].pb(i);
        }
    }
}

int main()
{
    ll n;;

    prime_generate();
    sl(n);

    for(int i=1; i<=n; i++)
    {
        sl(a[i]);

    }

    bool f=0;
    for(int i=1; i<=n; i++)
    {
        for(auto x : p[a[i]])
        {
            //cout<<x<<endl;
            if(m[x])
            {
                f=1;
                break;
            }
            m[x]=1;
        }

        if(f)
            break;
    }

    ll g=a[1];
    for(int i=2; i<=n; i++)
    {
        g=__gcd(g, a[i]);

    }


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

}








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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  ll n, k; cin >> n >> k;

  ll ans = 0;
  FOR(b, k+1, n+1) {
    ans += n / b * (b - k) + max(0ll, n % b - max(0ll, k-1));
  }
  cout << ans << endl;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int m[10] = {};
  m[a] += 1;
  m[b] += 1;
  m[c] += 1;
  m[d] += 1;
  if (m[1] == 1 && m[9] == 1 && m[7] == 1 && m[4] == 1) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first

#if MYDEBUG
#define DBG(...) {string dst__=#__VA_ARGS__;dbgsplit(dst__);stringstream dss__; dss__<<dst__; debug(dss__,__VA_ARGS__);}
#else
#define DBG(...)
#endif
void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<'='<<f<<' '; debug(ds,r...);}
void dbgsplit(string &s){int l=s.length(),n=0;for(int i=0; i<l; ++i){if(s[i]=='(')++n;if(s[i]==')')--n;if(s[i]==','&&!n)s[i]=' ';}}
using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    LL s,c;
    cin >> s >> c;
    if(s*2>=c){
        cout << c/2 << endl;
    }else{
        LL ans =s;
        c-=s*2;
        ans+=c/4;
        cout << ans <<endl;
    }


    return 0;
}



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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long sum = accumulate(a.begin(), a.end(), 0ll);
  long long psum = (long long) n * (n + 1) / 2;
  if (sum % psum) {
    cout << "NO" << endl;
    return 0;
  }
  long long m = sum / psum;
  vector<int> c(n);
  for (int i = 0; i < n; ++i) {
    int d = a[i] - a[(i + n - 1) % n];
    if ((m - d) % n || m - d < 0) {
      cout << "NO" << endl;
      return 0;
    }
    c[i] = (m - d) / n;
  }
  long long cnt = accumulate(c.begin(), c.end(), 0ll);
  if (cnt != m) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    if len(s) == 2:
        if s[0] == s[1]:
            print(1, 2)
        else:
            print(-1, -1)
    else:
        q = collections.deque(list(s[:2]))
        c = collections.Counter(q)
        for i in range(2, len(s)):
            q.append(s[i])
            c = collections.Counter(q)
            if len(c) <= 2:
                print(i - 2 + 1, i + 1)
                exit()
            q.popleft()
        print(-1, - 1)


if __name__ == '__main__':
    solve()


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

const long long maxn = 1e5 + 5;

long long n;
pair<long long, long long> r[maxn];

bool comp(pair<long long, long long> p1, pair<long long, long long> p2) {
	return p1.second < p2.second;
}

int main() {
    cin >> n;
    long long x, l;
    for (long long i=0; i<n; i++) {
        cin >> x >> l;
        r[i].first = x - l;
        r[i].second = x + l;
    }
    sort(r, r + n, comp);
    long long ans = 1, r1 = r[0].second;
    for (long long i=1; i<n; i++) {
    	long long l1 = r[i].first, r2 = r[i].second;
    	if (l1 >= r1) {
    		ans++;
    		r1 = r2;
    	}
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll n;
    cin >> n;
    vector<int>retu;
        for(ll i=2;i*i<=n;i++){
            int x=0;
            while(n%i==0){
                x++;
                n/=i;
            }
            retu.push_back(x);
        }
        if(n!=1)retu.push_back(1);
    ll ans =0;
    for(int i=0;i<retu.size();i++){
        int che =1;
        while(che<=retu.at(i)){
            ans++;
            retu.at(i)-=che;
            che++;
        }
    }
    cout<<ans<<endl;
}
    



Measured memory_bytes: 7352
import java.util.*;

public class Main {
    public static final long INF = 1 << 60;
    public static long[] dp = new long[100010];
    public static void main(String[] args) throws Exception {
    for(int i=0;i<100010;++i)dp[i] = INF;
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       long[] steps = new long[N + 10];
       for(int i=0;i<N;i++){
           steps[i] = sc.nextLong();
       }
       for(int i=0;i<N;i++){
           if(i == 0){
               dp[i] = 0;
           }else if(i == 1){
               dp[i] = height(steps[0],steps[1]);
           }else{
               dp[i] = chmin(dp[i-1] + height(steps[i],steps[i-1]) , dp[i-2] + height(steps[i] , steps[i-2]));
           }
       }
       System.out.println(dp[N - 1]);
    }
    
    public static long height(long h1,long h2){
        return Math.abs(h1 - h2);
    }
    
    public static long chmin(long a , long b){
        return Math.min(a,b);
    }
}


Measured memory_bytes: 58540
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%s", $a);
fscanf(STDIN, "%s", $b);
fscanf(STDIN, "%s", $c);
$m=0;
for($i=0;$i<$n;$i++){
  $j=0;
  $k=0;
  $l=0;
  (substr($a,$i,1)!=substr($b,$i,1))?$j++:"";
  (substr($b,$i,1)!=substr($c,$i,1))?$k++:"";
  (substr($c,$i,1)!=substr($a,$i,1))?$l++:"";
  if($j==0 && $k==0 && $l==0) continue;
  if($j==1 && $k==1 && $l==1) {$m=$m+2;continue;}
  if($j==1 && $k==1 && $l==0) {$m++;continue;}
  if($j==0 && $k==1 && $l==1) {$m++;continue;}
  if($j==1 && $k==0 && $l==1) {$m++;continue;}
}
echo $m."\n";
?>

Measured memory_bytes: 3700
#include<stdio.h>
int x[300000],y[300000],z[300000],w[300000];
int abs(int k){
	if (k<0) return -k; else return k;
}
int dis(int i,int j){
	return abs(x[i]-x[j])+abs(y[i]-y[j]);
}

int main(){
	int n,i;int max,min,ans;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d %d",&x[i],&y[i]);
		z[i]=x[i]+y[i];
		w[i]=x[i]-y[i];
	}
	max=z[1];
	for (i=1;i<=n;i++)
	  if (z[i]>max) max=z[i];
	min=z[1];
	for (i=1;i<=n;i++)
	  if (z[i]<min) min=z[i];
	ans=max-min;
   	max=w[1];
	for (i=1;i<=n;i++)
	  if (w[i]>max) max=w[i];
	min=w[1];
	for (i=1;i<=n;i++)
	  if (w[i]<min) min=w[i];
	if (ans<max-min) ans=max-min;
	printf("%d",ans);

}

Measured memory_bytes: 4844
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        String[] s = new String[n];
        List<String> li = new ArrayList<String>();
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
            li.add(s[i]);
        }
        Collections.sort(li);
        for (int i = 0; i < n; i++) {
            System.out.print(li.get(i));
        }
        System.out.println();

        sc.close();
    }
}

Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int n;
int a[500], b[500];
long long ans;
long long dp[60][60];
vector<int> used;

vector<int> ask(int x)
{
    vector<int> mark(51);
    mark[x] = 1;
    for (int i = 0; i < used.size(); i++) for (int num = 0; num <= 50; num++) if (mark[num]) mark[num % used[i]] = 1;
    vector<int> res;
    for (int i = 0; i < 51; i++) if (mark[i]) res.push_back(i);
    return res;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i <= 50; i++) for (int j = 0; j <= 50; j++) dp[i][j] = -1;
    for (int i = 0; i <= 50; i++) dp[i][i] = 0;
    for (int j = 0; j <= 50; j++)
    {
        for (int i = j + 1; i <= 50; i++)
        {
            for (int k = j + 1; k <= i; k++)
            {
                if (dp[i % k][j] > -1)
                {
                    dp[i][j] = k;
                    break;
                }
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (dp[a[i]][b[i]] == -1)
        {
            cout << -1;
            return 0;
        }
    }
    for (int k = 50; k >= 1; k--)
    {
        int t = 0;
        for (int i = 0; i < n; i++)
        {
            vector<int> alpha = ask(a[i]);
            int need = 0, can = 0;
            for (int j = 0; j < alpha.size(); j++)
            {
                if (dp[alpha[j]][b[i]] > k) continue;
                if (dp[alpha[j]][b[i]] == k) need++;
                if (dp[alpha[j]][b[i]] != -1) can++;
            }
            if (need == can)
            {
                t = 1;
            }
        }
        if (t == 1) used.push_back(k);
        if (t == 1) ans += 1LL << k;
        //if (t == 1) cout << k << endl;
    }
    cout << ans;
}


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

int pcnt(int x) {
    return __builtin_popcount(x);
}

int f(int x) {
    if (x == 0) return 0;
    return f(x%pcnt(x))+1;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> x(n);
    rep(i,n) x[i] = s[i]-'0';
    int pc = 0;
    rep(i,n) pc += x[i];
    vector<int> ans(n);
    rep(b,2) {
        int npc = pc;
        if (b == 0) npc++; else npc--;
        if (npc <= 0) continue;
        int r0 = 0;
        rep(i,n) {
            r0 = (r0*2)%npc;
            r0 += x[i];
        }
        int k = 1;
        for (int i = n-1; i >= 0; i--) {
            if (x[i] == b) {
                int r = r0;
                if (b == 0) r = (r + k)%npc;
                else r = (r -k+npc)%npc;
                ans[i] = f(r)+1;
            }
            k = (k*2)%npc;
        }
    }
    rep(i,n) cout << ans[i] << endl;
}


Measured memory_bytes: 5132
import sys
input = lambda: sys.stdin.buffer.readline()

n = int(input())
a = list(map(int, input().split()))
a.sort()

m = 10**6+10
d = [False] * (m+1)
ans = 0
for i in range(n):
    same = (i > 0 and a[i] == a[i-1]) or (i < (n-1) and a[i] == a[i+1])
    x = a[i]
    if not d[x] and not same: ans += 1
    
    if (i > 0 and a[i] == a[i-1]): continue
    for j in range(x, m+1, x):
        d[j] = True
    
print(ans)


Measured memory_bytes: 120152
import java.util.Scanner;

public class Main 
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext())
		{
			double ax=sc.nextDouble();
			double ay=sc.nextDouble();
			double bx=sc.nextDouble();
			double by=sc.nextDouble();
			double cx=sc.nextDouble();
			double cy=sc.nextDouble();
			double dx=sc.nextDouble();
			double dy=sc.nextDouble();

			double inx1 = ax-bx;
			double iny1 = ay-by;
			double inx2 = cx-dx;
			double iny2 = cy-dy;

			if((inx1*inx2+iny1*iny2)==0)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pi = pair<int, int>;
template <typename T>
using Pq = priority_queue<T>;
template <typename T>
using pQ = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
vector<T> divisor(T &n) {
    vector<T> res;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    return res;
}

signed main() {
    INIT;
    cin >> N;
    vi a(N);
    vector<map<int, int>> dp(N);
    dp[N - 1][0] = 0;
    cin >> a;
    RREP(i, N) {
        if (i == 0)
            continue;
        int tmp = N - 1 - i;
        auto v = divisor(tmp);
        REP(j, v.size()) {
            if ((i % v[j] == 0 && tmp >= i) || i - v[j] <= 0)
                continue;
            dp[i][v[j]] = (i + v[j] == N - 1 ? 0 : dp[i + v[j]][v[j]]) + a[i] + a[tmp];
            if (chmax(ans, dp[i][v[j]])) {
                dump(ans, i, i - v[j], v[j]);
            }
        }
    }
    dump(dp);
    cout << ans << endl;
}

Measured memory_bytes: 70792
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int MaxN = 100;
int f[MaxN + 5][MaxN + 5];
int vis[15];

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	/*
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++) 
			if(i == j) f[i][j] = 0;
			else f[i][j] = 1 << 30;
	for(int i = 1; i <= m; i++) {
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		f[u][v] = min(f[u][v], w);
	}
	*/
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			scanf("%d", &f[i][j]);
	int bb;
	for (int i = 1; i <= n; i++)
		for (int j =1 ; j <= m; j++){
			scanf("%d", &bb);
			if (bb != -1)
				vis[bb]++;
		}
	for(int k = 0; k <= 9; k++)
		for(int i = 0; i <= 9; i++)
			for(int j = 0; j <= 9; j++)
				if(f[i][j] > f[i][k] + f[k][j])
					f[i][j] = f[i][k] + f[k][j];
/*	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) printf("%d ", f[i][j]);
		printf("\n");
	}
	*/
	int ans = 0;
	for (int i = 0; i <= 9; i++){
		if (i != 1 && vis[i] != 0)
			ans = vis[i] * f[i][1] + ans;
	}
	cout <<ans <<endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int ans = 0, max = 0;
			for (int i = 0; i < n; i++) {
				int p = int.Parse(Console.ReadLine());
				ans += p;
				max = Math.Max(max, p);
			}
			ans -= max / 2;
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>

#define PI 3.141592653589
using namespace std;

int main(){
	int a, b;
	char op;
	cin >> a >> op >> b;
	while (1){
		if (op == '+'){
			cout << a + b;
		}
		else if (op == '-'){
			cout << a - b;
		}
		else if (op == '*'){
			cout << a * b;
		}
		else if (op == '/'){
			cout << a / b;
		}
		else if (op == '?'){
			break;
		}
		cout << endl;
		cin >> a >> op >> b;
	}
	return 0;
}

Measured memory_bytes: 1164
# ABC137D - Summer Vacation
import sys
from heapq import heappop, heappush

readline = sys.stdin.buffer.readline
heappop_max = lambda heap: -heappop(heap)
heappush_max = lambda heap, x: heappush(heap, -x)


def main():
    N, M = map(int, readline().split())
    all_jobs = tuple(tuple(map(int, readline().split())) for _ in range(N))
    available_jobs = [[] for _ in range(M + 1)]
    for waiting_days, reward in all_jobs:
        if waiting_days <= M:
            available_jobs[waiting_days].append(reward)
    heap = []
    max_rewards = 0
    for jobs in available_jobs[1:]:
        for job in jobs:
            heappush_max(heap, job)
        if heap:
            max_rewards += heappop_max(heap)
    print(max_rewards)


if __name__ == "__main__":
    main()


Measured memory_bytes: 29504
#include<bits/stdc++.h>
    #define LL long long
    #define db long double
     
    using namespace std;
    const int N=3e5+10;
    int rd()
    {
    	int x=0,w=1;char ch=0;
    	while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    	return x*w;
    }
    int to[N<<1],nt[N<<1],hd[N],tot=1;
    void adde(int x,int y)
    {
    	++tot,to[tot]=y,nt[tot]=hd[x],hd[x]=tot;
    	++tot,to[tot]=x,nt[tot]=hd[y],hd[y]=tot;
    }
    int n,m,sq[N],ff[N],st[N],tp;
    LL a[N],b[N],f[N],g[N];
    bool vs[N];
    bool cmp(int aa,int bb){return a[aa]-b[aa]<a[bb]-b[bb];}
    int findf(int x){return ff[x]==x?x:ff[x]=findf(ff[x]);}
     
    int main()
    {
    	n=rd(),m=rd();
    	for(int i=1;i<=n;++i) a[i]=rd(),b[i]=rd(),sq[i]=ff[i]=i;
    	sort(sq+1,sq+n+1,cmp);
    	for(int i=1;i<=m;++i) adde(rd(),rd());
    	for(int i=1;i<=n;++i)
    	{
    		int x=sq[i];
    		g[x]=b[x],vs[x]=1;
    		for(int j=hd[x];j;j=nt[j])
    		{
    			int y=findf(to[j]);
    			if(!vs[y]||y==x) continue;
    			ff[y]=x,g[x]+=g[y],st[++tp]=y;
    		}
    		if(!tp) f[x]=max(a[x],b[x]);
    		else
    		{
    			f[x]=1ll<<50;
    			while(tp)
    			{
    				int y=st[tp--];
    				f[x]=min(f[x],-g[y]+max(f[y],max(a[x]-b[x],0ll)));
    			}
    			f[x]+=g[x];
    		}
    	}
    	printf("%lld\n",f[sq[n]]);
    	return 0;
    }

Measured memory_bytes: 17536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, a[100010], b[100010], one, two, ans;
ll taken[100010], taken2;
ll am;
vector<pair<ll, ll> > sorted;
pair<ll, ll> insorted[100010];
ll amwith(ll n, ll i)
{
	ll ans = n;
	if (insorted[i].first >= n) ans++;
	if (insorted[i].second >= n) ans++;
	return ans;
}
ll cumsum[200010];
int main()
{
	scanf("%lld", &n);
	for (ll i = 0; i < n; i++) scanf("%lld%lld", &a[i], &b[i]);
	for (ll i = 0; i < n; i++) one += a[i], two += b[i];
	for (ll i = 0; i < n; i++) sorted.emplace_back(a[i], i), sorted.emplace_back(b[i], i), insorted[i].first = -1;
	sort(sorted.begin(), sorted.end());
	for (ll i = 0; i < 2*n; i++)
	{
		if (insorted[sorted[i].second].first == -1) insorted[sorted[i].second].first = i;
		else insorted[sorted[i].second].second = i;
		cumsum[i] = sorted[i].first;
		if (i) cumsum[i] += cumsum[i-1];
	}
	ans = 1e15;
	for (int i = 0; i < n; i++)
	{
		ll reqam = n;
		while (amwith(reqam, i) > n) reqam--;
		while (amwith(reqam, i) < n) reqam++;
		ll am = cumsum[reqam-1];
		if (insorted[i].first >= reqam) am += min(a[i], b[i]);
		if (insorted[i].second >= reqam) am += max(a[i], b[i]);
		ans = min(ans, am);
	}
	ans = min(ans, one);
	ans = min(ans, two);
	printf("%lld\n", ans);
}

Measured memory_bytes: 10352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
//#define mp make_pair

int a[101010], b[101010], n, h, mx, ans=0;
vi v;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

cin >> n >> h;

rep(i, 1, n){
cin >> a[i] >> b[i];
}

sort(a+1, a+1+n);
mx = a[n];

rep(i, 1, n){
if(b[i]>mx)v.pb(b[i]);
}
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
int k = v.size()-1;
rep(i, 0, k){
    if(h>0){
        h-=v[i];
        ans++;
    }
}

if(h>0){
    ans+= (h+mx-1)/mx;
}

cout << ans << endl;

return 0;}


Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	string s, t;
	cin >> s >> t;
	int ans = (int)s.size();
	for (int i = 0; i + (int)t.size() <= (int)s.size(); i++) {
		int c = 0;
		for (int j = 0; j < (int)t.size(); j++) {
			c += (t[j] != s[i + j]);
		}
		ans = min(ans, c);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
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 long long INF = 1LL << 60;
using Graph=vector<vector<int>>;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int x,y;
  bool is=false;
  cin>>x>>y;

  for(int i=0;i<=100;i++){
    for(int j=0;j<=100;j++){
      if(i*2+j*4==y&&i+j==x&&i+j<=x){
        is=true;
      }
    }
  }

  if(is){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(void){
    // Your code here!
 int a[3];
 cin >> a[0] >> a[1] >> a[2];
 sort(a,a+3);
 if((a[0]==a[1] && a[1]!=a[2]) || (a[0]!=a[1] && a[1]==a[2]))
 cout << "Yes";
 else
 cout << "No";
 return 0;   
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

typedef long long ll;

#define rep(i, n) for(ll i=0; i<n; ++i)

//--------------------

int main() {

  int n;
  cin >> n;
  int p[n];
  rep(i, n) cin >> p[i];

  int res = 0;
  rep(i, n) {
    if(p[i]!=(i+1)) ++res;
  }

  if(res<=2) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const MAX = 1000;
  const c = Array.from(Array(MAX + 1), () => []);

  let i, j, X, Y, xlen, ylen, maxlen;
  while ((X = lines.shift()) && (Y = lines.shift())) {
    xlen = X.length;
    ylen = Y.length;
    for (i = 0; i <= xlen; i++) c[i][0] = 0;
    for (j = 0; j <= ylen; j++) c[0][j] = 0;

    for (i = 1; i <= xlen; i++) {
      for (j = 1; j <= ylen; j++) {
        if (X[i - 1] === Y[j - 1]) c[i][j] = c[i - 1][j - 1] + 1;
        else c[i][j] = Math.max(c[i - 1][j], c[i][j - 1]);
      }
    }
    console.log(c[xlen][ylen]);
  }
})();



Measured memory_bytes: 35932
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7


x = ri()
for a in range(150):
    for b in range(-150, a):
        if a**5 - b**5 == x:
            print(a, b)
            exit()








Measured memory_bytes: 27124
#python3
from math import floor
def main():
    a, b = map(int, input().split())
    for i in range(1, 1200):
        x1 = floor(i*0.08)
        x2 = floor(i*0.1)
        if x1 == a and x2 == b:
            print(i)
            return
    print('-1')
main()


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  int n;
  ll dp[100000],h[100000];
  cin >> n;
  REP(i,n){
    cin >> h[i];
  }
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  FOR(i,2,n){
  dp[i]=min( ( dp[i-1] + abs(h[i]-h[i-1] ) ) ,
             ( dp[i-2] + abs(h[i]-h[i-2] ) ) );
  }
  cout << dp[n-1] <<endl;
    return 0;
}


Measured memory_bytes: 5136
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(sc.nextInt());
		}
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			Collections.reverse(list.subList(sc.nextInt(), sc.nextInt()));
		}
		StringBuilder sb = new StringBuilder();
		for (int num : list) {
			sb.append(num + " ");
		}
		String str = sb.toString();
		str = str.substring(0, str.length() - 1);
		System.out.println(str);
	}
}



Measured memory_bytes: 33384
N = int(input())
Alist = [0] + list(map(int, input().split())) + [0]
value_list = [abs(Alist[i] - Alist[i + 1]) for i in range(N + 1)]
max_value = sum(value_list)
for i in range(N):
    print(max_value - (value_list[i] + value_list[i + 1]) + abs(Alist[i] - Alist[i + 2]))


Measured memory_bytes: 14048
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;
 
int main() {
    ll a, ans;
    int tmp;
    char b[5];
    scanf("%lld %s", &a, b);
    char bd[3];
    rep(i, 3) bd[i] = '\0'; 
    bd[0] = b[0];
    tmp = atoi(bd);
    bd[0] = b[2];
    bd[1] = b[3];
    ans = a * atoi(bd);
    ans /= 100;
    ans += a * tmp;
    printll(ans);
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  string s;
  cin>>s;
  if(s=="ABC")
    cout<<"ARC"<<endl;
  else
    cout<<"ABC"<<endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

class Main {
  public static void main(String args[]){
    int A;
    int B;
//ここから標準入力のやつ
    Scanner sc = new Scanner(System.in);

    A = sc.nextInt();
    B = sc.nextInt();
//ここまで標準入力のやつ
    if(A > 8 || B >8){
      System.out.println(":("); //AかBのどっちかが8より大きいとダメ
    }else{
      System.out.println("Yay!"); //そうでなければ大丈夫
    }
  }
}


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

using namespace std;

int main(void)
{
	int a,b,c,data[3];
	int ans=0;

	cin>>a>>b>>c;

	data[0]=a;
	data[1]=b;
	data[2]=c;

	sort(data,data+3);

	ans+=(data[1]-data[0]);
	ans+=(data[2]-data[1]);

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n - i + 1):
    k = n - i - j
    if 10000 * i + 5000 * j + 1000 * k == y:
      print(i, j, k)
      exit(0)
print(-1, -1, -1)

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

#define	mp	make_pair

using namespace std;

typedef	pair<int,int>	pii;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
char field[100][101];
int w,h,memo[100][100];

int main(){
	for(;scanf("%d%d",&w,&h),w;){
		for(int i=0;i<h;i++)	scanf("%s",field[i]);

		int sx,sy;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++){
			if(field[i][j]=='&')	sy=i,sx=j,field[i][j]='.';
			memo[i][j]=1<<30;
		}

		int ans;
		memo[sy][sx]=0;
		priority_queue< pair<int,pii> > pq;	pq.push(mp(0,mp(sy,sx)));
		while(1){
			pair<int,pii> a=pq.top();	pq.pop();
			int cost=-a.first,x=a.second.second,y=a.second.first;
			if(x==0 || x==w-1 || y==0 || y==h-1){ ans=cost; break; }
			for(int i=0;i<4;i++){
				int xx=x+dx[i],yy=y+dy[i],nextcost;
				if(0<=xx && xx<w && 0<=yy && yy<h){
					if(field[y][x]=='.' && field[yy][xx]=='#')	nextcost=cost+1;
					else	nextcost=cost;
					if(nextcost<memo[yy][xx]){
						memo[yy][xx]=nextcost;
						pq.push(mp(-nextcost,mp(yy,xx)));
					}
				}
			}
		}

		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 0
import java.math.BigInteger;
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int res = 0;
        if(k<a) System.out.println(k);
        else {
            res+=a;
            k-=a;
            if (k<b) System.out.println(res);
            else {
                k-=b;
                System.out.println(res-k);
            }
        }
        //x+a*t == y - b * t
        //a*t+b*t == y - x
        //(a+b)*t == y - x
        // a + (a*2(k-1) = n*2/k
        // a+(a+2k-2)=2a+2k-2=n*2/k
    }

    private static int[] prefix_function(String s) {
        int n = s.length();
        int[] res = new int[n];
        for (int i = 1; i < n; i++) {
            int j = res[i-1];
            while (j > 0 && s.charAt(i) != s.charAt(j)) {
                j = res[j-1];
            }
            if (s.charAt(i)==s.charAt(j)) {
                j++;
            }
            res[i] = j;
        }
        return res;
    }

    private static boolean check(String s) {
        char cc = s.charAt(0);
        for (char c : s.toCharArray()) {
            if (c!=cc) return false;
        }
        return true;
    }

    private static int[] isPrime(int num) {
        for (int i = 2; i <= (int)Math.sqrt(num); i++) {
            if (num % i == 0) return new int[]{i, num/i};
        }
        return null;
    }

    private static int sign(long num) {
        if (num < 0) return -1;
        return 1;
    }

    private static class Pair {
        int x;
        int y;
        public Pair(int x, int y) {
            this.x=x;
            this.y=y;
        }
    }




    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

/**
 * 7 3
 * 3 1 5
 * 9 6 5
 *
 * i = 1: 1
 * i = 2: 2
 * i = 3: 3
 *
 *
 * 1 2 3 3 3 3 3
 */


/**
 *
 *  1+1
 **/

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

double mem[301][301][301];

double rec(int n,int one, int two, int three)
{
  if(one==0&&two==0&&three==0)
    return 0;
  if(mem[one][two][three]!=0)
    return mem[one][two][three];
  double ans=n;
  if(one>0)
  	ans+=one*rec(n,one-1,two,three);
  if(two>0)
    ans+=two*rec(n,one+1,two-1,three);
  if(three>0)
    ans+=three*rec(n,one,two+1,three-1);
  ans=(double)ans/(one+two+three);
  mem[one][two][three]=ans;
  return ans;
    
}

int main(){
  int n;
  cin>>n;
  int a[n];
  int one=0,two=0,three=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]==1)
      one++;
    if(a[i]==2)
       two++;
    if(a[i]==3)
       three++;
  }
  /*double dp[310][310][310];
  dp[0][0][0]=0;
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=n;j++)
    {
      for(int k=0;k<=n;k++)
      {
        double curr=n;
        if(k>0)
          curr+=k*dp[k-1][j][i];
        if(j>0)
          curr+=j*dp[k+1][j-1][i];
        if(i>0)
          curr+=i*dp[k][j+1][i-1];
        if((i+j+k)!=0)
       	  dp[k][j][i]=(double)curr/(i+j+k);
      }
    }
  }
  cout<<fixed<<setprecision(10)<<dp[one][two][three];*/
  
  
  memset(mem,0,sizeof(mem));
  cout<<fixed<<setprecision(10)<<rec(n,one,two,three);
  
  
}

Measured memory_bytes: 213376
import math
x,y,r = 0,0,90
while True:
  m,n = map(int,input().split(','))
  if (m,n) == (0,0):
    break
  y += m * math.sin(math.radians(r))
  x += m * math.cos(math.radians(r))
  r -= n
print(int(x))
print(int(y))

Measured memory_bytes: 7844
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>

#define div 1000000000+7

typedef long long ll;

using namespace std;

void solve() {
    string s[3];
    for(int i = 0; i < 3; i++){
        cin >> s[i];
    }
    cout << "A" << s[1][0] << "C" << endl;
}

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


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

int main() {
  int x,y,ans = 0;
  cin >> x >> y;
  if(x < y) swap(x,y);
  while(x%y != 0) {
    x = x % y;
    swap(x,y);
  }
  cout << y << endl;
  return 0;
}



Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N; cin >> N;
    int ans = 0;
    REP(i,N.length()){
        ans +=(N[i]-'0');
    }
    if(ans == 1) ans = 10;

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int r, D, x;
	cin >> r >> D >> x;
	x = r * x - D;
	cout << x << endl; //01
	x = r * x - D;
	cout << x << endl; //02
	x = r * x -D;
	cout << x << endl; //03
	x = r * x - D;
	cout << x << endl; //04
	x = r * x - D;
	cout << x << endl; //05
	x = r * x - D;
	cout << x << endl; //06
	x = r * x - D;
	cout << x << endl; //07
	x = r * x - D;
	cout << x << endl; //08
	x = r * x - D;
	cout << x << endl; //09
	x = r * x - D;
	cout << x << endl; //10

}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#define ll long long int
#define pb push_back
using namespace std;

int main(void){
  ll n,a,b;
  cin>>n>>a>>b;

  ll res;
  res=(b-a)*(n-2)+1;
  if(res>0) cout<<res<<endl;
  else  cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
xx = gets()
yy = gets()
while xx 
x = xx.split()
y = yy.split()
a1 = x[0].to_i
a2 = x[1].to_i
a3 = x[2].to_i
a4 = x[3].to_i
b1 = y[0].to_i
b2 = y[1].to_i
b3 = y[2].to_i
b4 = y[3].to_i
s = [a1,a2,a3,a4]
t = [b1,b2,b3,b4]

h = 0
f = 0
 
i = 0
while i < 4
 if s[i] == t[i]
  h += 1
 elsif s.include?(t[i])
  f += 1
 end
 i += 1
end

puts "#{h} #{f}"
xx = gets()
yy = gets()
end


Measured memory_bytes: 6860
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << " " << max(0, A + B - N) << endl;
    return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;
 
public class Main{
    Scanner sc = new Scanner(System.in);
     
    void run(){
        while(sc.hasNext()){
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(String.valueOf(a+b).length());
        }
    }
     
    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 26256
# Red or Not

a = int(input())
s = input()

if a < 2800 or 5000 <= a:
    print('数値が範囲外です')
if len(s) < 1 or 10 < len(s):
    print('文字数が範囲外です')
elif a < 3200:
    print('red')
else:
    print(s)

Measured memory_bytes: 9168
#include <iostream>
using namespace std;
int main(void){
    int n;
    char str[100000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> str[i];
    }
    int sum = n;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j< n; j++) {
            if(str[i] == str[j]){
                
                sum--;
                if(sum == 0) sum =1;
            }
            break;
        }
    }
    cout << sum << endl;
    
}


Measured memory_bytes: 384