akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n,k) for(int i=k; i<n; ++i)
using namespace std;

int main(){
  long long int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> ac;
  ac.resize(n);
  rep(i,n-1,0){
    if(s[i] == 'A' && s[i+1] == 'C') ac[i+1]++;
    ac[i+1] += ac[i];
  }
  rep(i,q,0){
    long long int l, r, ans = 0;
    cin >> l >> r;
    l--;
    r--;
    ans = ac[r] - ac[l];
    cout << ans << endl;
  }
}

Measured memory_bytes: 1408
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
def MAP(): return map(int, input().split())

ans = []
while 1:
	n = INT()
	if n == 0:
		break
	a = LIST()
	a.sort()
	min_ = 100000000
	for i in range(n-1):
		min_ = min(min_, abs(a[i] - a[i+1]))
	ans.append(min_)
for x in ans:
	print(x)



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

namespace AtCoderCs
{
    class Program
    {
        static void Main()
        {


            var Arg = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            long NumRed = Arg[0];
            long NumGreen = Arg[1];

            var RedApple = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var GreenApple = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var NonColorApple = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            Array.Sort(RedApple);
            Array.Sort(GreenApple);
            Array.Sort(NonColorApple);

            var ResultRedApple = new long[NumRed];
            var ResultGreenApple = new long[NumGreen];

            Array.Copy(RedApple, RedApple.Length - NumRed, ResultRedApple, 0, NumRed);
            Array.Copy(GreenApple, GreenApple.Length - NumGreen, ResultGreenApple, 0, NumGreen);
            Array.Reverse(NonColorApple);

            long SmallerRed = 0, SmallerGreen = 0;
            bool Routine = true;

            for (long i = 0; i < NonColorApple.Length && Routine; i++)
            {

                if (SmallerRed < ResultRedApple.Length)
                {
                    if (SmallerGreen >= ResultGreenApple.Length)
                    {

                        if (ResultRedApple[SmallerRed] <= NonColorApple[i]) ResultRedApple[SmallerRed] = NonColorApple[i];
                        else Routine = false;
                        SmallerRed++;

                    }
                    else if (ResultRedApple[SmallerRed] < ResultGreenApple[SmallerGreen])
                    {

                        if (ResultRedApple[SmallerRed] <= NonColorApple[i]) ResultRedApple[SmallerRed] = NonColorApple[i];
                        else Routine = false;
                        SmallerRed++;

                    }
                    else
                    {

                        if (ResultGreenApple[SmallerGreen] <= NonColorApple[i]) ResultGreenApple[SmallerGreen] = NonColorApple[i];
                        else Routine = false;
                        SmallerGreen++;

                    }
                }
                else if (SmallerGreen < ResultGreenApple.Length)
                {

                    if (ResultGreenApple[SmallerGreen] <= NonColorApple[i]) ResultGreenApple[SmallerGreen] = NonColorApple[i];
                    else Routine = false;
                    SmallerGreen++;

                }
                else Routine = false;

            }

            long Sum = ResultRedApple.Sum();
            Sum += ResultGreenApple.Sum();

            Console.WriteLine(Sum);

        }

    }
}


Measured memory_bytes: 42008
K = int(input())

if K < 10:
    print(K)
else:
    l, temp1, temp2, i, j = [[1]*10], K, 9, 1, 0
    while temp1 > temp2:
        temp1 -= temp2
        if j == 0:
            l.append([0]*10)
            l[i][j] = l[i-1][0] + l[i-1][1]
            temp2 = 0
            j += 1
        elif j == 9:
            l[i][j] = l[i-1][8] + l[i-1][9]
            temp2 = l[i][j]
            i += 1
            j = 0
        else:
            l[i][j] = l[i-1][j-1] + l[i-1][j] + l[i-1][j+1]
            temp2 = l[i][j]
            j += 1

    ans, p = j - 1, j - 1
    K = temp1
    for k in range(i)[::-1]:
        if p == 0:
            if K > l[k][0]:
                p, K = 1, K - l[k][0]
            else:
                p, K = 0, K
        elif p == 9:
            if K > l[k][8]:
                p, K = 9, K - l[k][8]
            else:
                p, K = 8, K
        else:
            if K > l[k][p-1] + l[k][p]:
                p, K = p+1, K - (l[k][p-1] + l[k][p])
            elif K > l[k][p-1]:
                p, K = p, K - l[k][p-1]
            else:
                p, K = p-1, K
        ans = ans*10 + p

    print(ans)

Measured memory_bytes: 3188
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <bitset>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 30031
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
int Scan() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
const int N=100005;
//Code begin...

int a[N*3];
LL sum1[N*3], sum2[N*3];
struct qnode1{
    int v;
    qnode1(int _v=0):v(_v){}
    bool operator<(const qnode1 &r)const{return v>r.v;}
};
struct qnode2{
    int v;
    qnode2(int _v=0):v(_v){}
    bool operator<(const qnode2 &r)const{return v<r.v;}
};
priority_queue<qnode1>que1;
priority_queue<qnode2>que2;
int main ()
{
    int n;
    qnode1 tmp1;
    qnode2 tmp2;
    scanf("%d",&n);
    FOR(i,1,3*n) scanf("%d",a+i);
    FOR(i,1,n) sum1[n]+=a[i], que1.push(qnode1(a[i]));
    FOR(i,n+1,2*n) {
        tmp1=que1.top();
        if (tmp1.v<a[i]) que1.pop(), que1.push(qnode1(a[i])), sum1[i]=sum1[i-1]+a[i]-tmp1.v;
        else sum1[i]=sum1[i-1];
    }
    for (int i=3*n; i>2*n; --i) sum2[2*n+1]+=a[i], que2.push(qnode2(a[i]));
    for (int i=2*n; i>=1; --i) {
        tmp2=que2.top();
        if (tmp2.v>a[i]) que2.pop(), que2.push(qnode2(a[i])), sum2[i]=sum2[i+1]+a[i]-tmp2.v;
        else sum2[i]=sum2[i+1];
    }
    LL ans=-(LL)1<<60;
    FOR(i,n,2*n) ans=max(ans,sum1[i]-sum2[i+1]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 5880
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		
		// 計算
		int result = 0;
		result = (n + max(h, w) - 1)/max(h, w);
		
		// 出力
		System.out.println(result);
	}
}




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

int main(){
	int n,x,c;
	while(5){
		cin>>n>>x;
		c=0;
		if(n==0&&x==0)break;
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++)
				for(int k=j+1;k<=n;k++)
					if(i+j+k==x)c++;
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
for q in range(int(input())):
  A,B = sorted(map(int,input().split()))
  if B-A<=1:
    print(2*A-2)
  else:
    X = int((A*B)**.5)
    X -= A*B == X*X
    print(2*X-1-(X*(X+1)>=A*B))

Measured memory_bytes: 9392
def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x
            x = x ** 2
            n = (n - 1) // 2
        else:
            x = x ** 2
            n = n // 2

    return K * x


input_num = int(input())
divide_num = pow_k(10, 9) + 7

all_comb = pow_k(10, input_num)

zero_comb = pow_k(9, input_num) - pow_k(8, input_num)

else_comb = pow_k(8, input_num)

result_comb = all_comb - (zero_comb * 2 + else_comb)


print(result_comb % divide_num)


Measured memory_bytes: 97072
import copy
N , M = map(int,input().split())
x_y_z = []
for i in range(N):
	x_y_z.append(list(map(int,input().split())))
temp_ans = [0] * 8
num = 0
for i in range(2):
	x_minusplus = (-1)**i
	for j in range(2):
		y_minusplus = (-1)**j
		for k in range(2):
			temp_x_y_z = []

			z_minusplus = (-1)**k
			temp_x_y_z = copy.deepcopy(x_y_z)
			temp_sum = []

			for l in range(N):
				temp_x_y_z[l][0] *= x_minusplus
				temp_x_y_z[l][1] *= y_minusplus
				temp_x_y_z[l][2] *= z_minusplus
				temp_sum.append(sum(temp_x_y_z[l]))

			temp_sum.sort(reverse = True)
			for l in range(M):
				temp_ans[num] += temp_sum[l]
			
			num += 1
				
				

print(max(temp_ans))

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 998244353;
const int INF = 1 << 30;
const int MAX = 210000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;

    COMinit();

    lint res = 0;

    for (int z = n-k; z <= n; z++) {
        lint t = COM(n-1, z-1);

        t *= m;
        t %= MOD;
        t *= modpow(m-1, z-1);
        t %= MOD;
        
        res += t;

        res %= MOD;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8532
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)
using namespace std;
ll l,r,d,ans=0;
int main(){
	ll i;
	fast;itt;now;
	cin>>l>>r>>d;
	for(i=l;i<=r;i++)
	{
		if(i%d==0)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3648
/*________________________Bismillahir Rahmanir Rahim___________________
|                                                                      |
|                    /\     |     | |\    |     /\     |-------        |
|                   /  \    |     | | \   |    /  \    |               |
|                  /----\   |-----| |  \  |   /----\   |-----          |
|                 /      \  |     | |   \ |  /      \  |               |
|                /        \ |     | |    \| /        \ |               |
|                     14th batch CSE , ID : 12008029                   |
|                     Comilla University                               |
|                     Email : sheikhahnafshifat@gmail.com              |
|______________________________________________________________________*/
#include<bits/stdc++.h>
#include<string>
#include<iostream>
using namespace std;
#define ll                      long long
#define MAX                     1000007
#define pb(x)                   push_back(x)
#define mp(x,y)                 make_pair(x,y)
#define vii                     vector<int>
#define vll                     vector<long long>
#define vp                      vector<pair<ll, ll> >
#define v_min(a)                *min_element(a.begin(),a.end())
#define v_max(a)                *max_element(a.begin(),a.end())
#define v_sum(a)                accumulate(a.begin(),a.end(),0)
#define un(a)                   a.erase(unique(a.begin(),a.end()),a.end())
#define SORT(a)                 sort(a.begin(),a.end())
#define AHNAF                   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define gcd(a,b)                __gcd(a,b)
#define lcm(a,b)                ((a)*(b))/gcd(a,b)
#define YES                     cout<<"Yes"<<endl
#define NO                      cout<<"No"<<endl
#define testcase(t)             int t;cin>>t;while(t--)
#define reverse(a)              reverse(a.begin(),a.end())
#define ff                      first
#define ss                      second
#define print(a)                for(auto it: a) cout<<it<<" "
#define all(a)                  a.begin(),a.end()
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

int main()
{
    AHNAF;
    int cnt=0,ans=0;string s;cin>>s;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='R') cnt++;
        else ans=max(ans,cnt), cnt=0;
    }
    ans=max(ans,cnt);
    cout<<ans<<endl;
}



Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long mmin(long long &a,long long b) {
	a = min(a, b);
	return a;
}
long long mmax(long long &a,long long b) {
	a = max(a, b);
	return a;
}
int nibu(vector<int> &v, int tan) {
	int up = v.size()-1;
	int lo = 0;
	if (tan <= v[0]) {
		return 0;
	}
	while (up - lo > 1) {
		int mi = (up + lo) / 2;
		if (tan <= v[mi]) {
			up = mi;
		}
		if (v[mi] < tan) {
			lo = mi;
		}
	}
	return up;
}
int main() {
	int w, h; cin >> w >> h;
	while (w != 0) {
		vector<vector<vector<int> > > c(5, vector<vector<int> >(h, vector<int>(w, 0)));//uu,um,mu,mm
		c[1][1][0] = 1;
		c[4][0][1] = 1;
		for (int di = 2; di <= h + w - 2; di++) {
			for (int i = 0; i < h; i++) {
				int j = di - i;
				if (j >= 0 and w > j) {
					if (i > 0) {
						c[1][i][j] = (c[1][i - 1][j] + c[3][i - 1][j]) % 100000;
						c[3][i][j] = c[4][i - 1][j];
					}
					if (j > 0) {
						c[4][i][j] = (c[4][i][j - 1] + c[2][i][j - 1]) % 100000;
						c[2][i][j] = c[1][i][j - 1];
					}
				}
			}
		}
		int n = h - 1; int m = w - 1;
		cout << (c[1][n][m] + c[2][n][m] + c[3][n][m] + c[4][n][m]) % 100000 << endl;
		cin >> w >> h;
	}
}


Measured memory_bytes: 3308
import bisect
N=input()

A=list(map(int,raw_input().split()))
B=list(map(int,raw_input().split()))
C=list(map(int,raw_input().split()))
A.sort()
B.sort()
C.sort()

sum=0
for val_b in B:
	sum+=bisect.bisect_left(A, val_b)*( N-bisect.bisect_right(C, val_b) )
			
print sum

Measured memory_bytes: 17916
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

int n;

void solve(){
    cin >> n;
    ll ans=0;
    Rep(a,1,n){
        for(int b=1;a*b<n;b++){
            ans+=1;
        }
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3660
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;

template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int N, opt[(int)1e5 + 5][3], val[(int)1e5 + 5][3];

int main(){
  FAST_IO  
  cin >> N;
  for(int rep = 0; rep < N; ++rep){
    for(int itr = 0; itr < 3; ++itr){
      cin >> val[rep][itr];
      opt[rep][itr] = 0;
    }
  }

  opt[0][0] = val[0][0], opt[0][1] = val[0][1], opt[0][2] = val[0][2];

  for(int day = 0; day < N - 1; ++day){
    for(int c = 0; c < 3; ++c){
      for(int rep = 1; rep < 3; ++rep){
        max_self(opt[day + 1][(c + rep) % 3],
                 opt[day][c] + val[day + 1][(c + rep) % 3]);
      }
    }
  }

  cout << max({opt[N - 1][0], opt[N - 1][1], opt[N - 1][2]});
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)



int main() {
	ll N, K;
	cin >> N >> K;
	bool m = true;

	vector<vector<ll>> A(100, vector<ll>(N + 1));
	vector<vector<ll>> kara(100, vector<ll>(N + 1));
	vector<vector<ll>> made(100, vector<ll>(N + 1));
	rep(i, N) {
		cin >> A.at(0).at(i);
	}
	if (N == 1) {
		cout << 1 << endl; return 0;
	}
	
	if (K >= 95) {
		K = 95;
	}
	ll ka = 0;
	while (ka <= K) {
		rep(i, N) {
			kara.at(ka).at(max(i - A.at(ka).at(i), ll(0)))++;
			made.at(ka).at(min(A.at(ka).at(i) + i, N - 1))++;


		}
		A.at(ka + 1).at(0) = kara.at(ka).at(0);
		for (ll i = 1; i < N; i++) {
			A.at(ka + 1).at(i) = A.at(ka + 1).at(i - 1) + kara.at(ka).at(i) - made.at(ka).at(i - 1);
		}

		
		ka++;

	}
	rep(i, N) {
		cout << A.at(K).at(i) << " ";
	}
}


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

bool palindrome(string s, int start, int end) {
    for (int i = start; i < end; i++) {
        if (s[i] != s[end - i - 1])
            return false;
    }

    return true;
}

int main()
{
    string S;
    cin >> S ;
    int N = S.length();

    if (palindrome(S, 0, N) 
        && palindrome(S, 0, (N - 1) / 2) 
        && palindrome(S, (N + 3) / 2 - 1, N)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

using namespace std;

#define ll long long 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SIZE 100005

int main()
{
	
	int a,b;
	
	cin >> a >>b;
	if(a <= 2*b) cout << 0 << endl;
	else cout << a-2*b << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
const string el = "\n";
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
int out(bool f,string s){
    cout << ( f ? s : "UNRESTORABLE") << endl;
    return 0;
}
bool valid(string&s, string&t){
    bool f = true;
    rep(i,s.size()){
        if(s[i] != t[i]){
            if( t[i] != '?') f = false;
        }
    }
    return f;
}
signed main(){
    fast_io();
    string s,t; cin >> s >> t;
    string ans = s;
    if(t.size() > s.size())return out(false,""s);
    vector<string>cnd;
    int tl = t.size();
    string tmp;
    for(int i = 0; i + tl <= s.size(); ++i){
        string u = s.substr(i,tl);
        if(valid(t,u)){
            string e = tmp + t;
            if(e.size() < s.size()){
            cnd.emplace_back(tmp + t + s.substr(i + tl));
            } else {
                cnd.emplace_back(e + s.substr(e.size()));
            }
        }
        tmp.push_back(s[i]);
    }
    for(auto &s : cnd){
        for(auto & c : s){
            if(c == '?') c = 'a';
        }
    }
    sort(all(cnd));
    if(cnd.size()){
        cout << cnd.front() << endl;
    }else {
        out(false,""s);
    }
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
dict = {}

for i in a:
  if i not in dict:
    dict[i] = 1
  else:
    dict[i] += 1
  
dictlis = sorted(dict.items())
count = 0
ans = 1


for i in range(len(dictlis)):
  if dictlis[len(dictlis) -1 -i][1] >= 4 and ans == 1: 
    print((dictlis[len(dictlis) -1 -i][0])**2)
    exit()
  elif  dictlis[len(dictlis) -1 -i][1] >= 2:
    count += 1
    ans = dictlis[len(dictlis) -1 -i][0]*ans
    if count == 2:
      print(ans)
      exit()
      
print(0)
    

Measured memory_bytes: 21384
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+100;
const int mod = 1e9+7;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll llINF = 0x3f3f3f3f3f3f3f3f;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
inline bool read(ll &num) {
  char in;bool IsN=false;
  in=getchar();
  if(in==EOF) return false;
  while(in!='-'&&(in<'0'||in>'9')) in=getchar();
  if(in=='-'){ IsN=true;num=0;}
  else num=in-'0';
  while(in=getchar(),in>='0'&&in<='9'){
      num*=10,num+=in-'0';
  } 
  if(IsN) num=-num;
  return true;
}
int main(){
  long long a,b,c;
  cin>>a>>b>>c;
  long long s=a+b+c;
  if(s>=22){
    cout<<"bust"<<endl;
  }else{
    cout<<"win"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
//pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };
const ll mod = 1e9 + 7;
const ll N = 2e5 + 7;


int main() {
	fastIO;
	int n;
	cin >> n;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		v.push_back(x);
	}

	sort(v.begin(), v.end());
	ll res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			int st = j+1, en = n-1, mid, ans1 = -1, ans2 =  -1;
			while(st <= en) {
				mid = (st+en)/2;
				if (v[mid] > abs(v[j]-v[i])) {
					ans1 = mid;
					en = mid-1;
				}
				else {
					st = mid+1;
				}
			}
			st = j+1, en = n-1;
			while (st <= en) {
				mid = (st+en)/2;
				if (v[mid] < v[i]+v[j]) {
					ans2 = mid;
					st = mid+1;
				}
				else {
					en = mid-1;
				}
			}
			if (ans1 == -1 || ans2 == -1)
				continue;
			res += ans2 - ans1 + 1;
		}
	}
	cout << res;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, a, b, cnt = 0;
	int sum1, sum2, sum3, sum4, sum5;
	cin >> n >> a >> b;
	int sum;
	for (int i = 1; i <= n; i++) {
		sum1 = i / 10000;
		sum2 = (i % 10000) / 1000;
		sum3 = (i % 1000) / 100;
		sum4 = (i % 100) / 10;
		sum5 = i % 10;
		sum = sum1 + sum2 + sum3 + sum4 + sum5;
		if (sum >= a && sum <= b) {
			cnt += i;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a, b, c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a < b && b < c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return	0;
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> AC(n+1,0);
  vector<int> WA(n+1,0);
  vector<pair<int,string>> p(m);
  for(int i=0;i<m;i++){
    cin >> p[i].first >> p[i].second;
    if(p[i].second=="AC")
      AC[p[i].first]=1;
    else
      if(AC[p[i].first]==0)
        WA[p[i].first]++;
  }
  int a=0,b=0;
  for(int i=0;i<n+1;i++){
    a +=AC[i];
  }
  for(int i=0;i<n+1;i++){
    if(AC[i]==1)
      b +=WA[i];
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[20005];
ll a[1005];
ll b[1005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll h,n;
    cin>>h>>n;
    ll ans=1e18;
    for(int i=1;i<=n;i++)
        cin>>a[i]>>b[i];
    for(int i=1;i<=20004;i++)
      dp[i]=1e18;
    for(int i=1;i<=n;i++)
    {

        for(int j=a[i];j<=h+10000;j++)
        {

            dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
        }
    }
    for(int i=h;i<=h+10000;i++)
    {

        ans=min(ans,dp[i]);
    }


    cout<<ans<<'\n';


}












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

using bstype = std::bitset<1000>;
int vis[1000];
bstype bs[1000];
bstype bs2[1000];
bstype bs3[1000];
std::pair<int,int> p[200003];
int n,m;
int q[1000],qa,qb;
int vis1[1000],vis2[1000];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i = 0;i < m;++i) {
		int a,b;
		scanf("%d%d",&a,&b);--a,--b;
		p[i].first = a;p[i].second = b;
		bs[a][b] = 1;
	}
	for(int i = 0;i < n;++i) {
		q[0] = i;qa = 0;qb = 1;bs2[i][i] = 1;
		while(qa < qb) {
			int cur = q[qa++];
			bstype nex = ~bs2[i]&bs[cur];
			bs2[i] |= nex;
			for(int j = 0;j < n;++j) if(nex[j]) q[qb++] = j;
		}
	}
	// 0->2?
	for(int i = 0;i < n;++i) {
		memset(vis1,-1,sizeof(vis1));
		memset(vis2,-1,sizeof(vis2));
		bstype v1, v2;
		for(int j = 0;j < n;++j) if(bs[i][j] && vis1[j] == -1) {
			q[0] = j;qa = 0;qb = 1;vis1[j] = j;v1[i] = v1[j] = true;
			while(qa < qb) {
				int cur = q[qa++];
				bstype res = ~v1&bs[cur];
				v1 |= res;
				for(int k = 0;k < n;++k) if(res[k]) {
					vis1[k] = j;
					q[qb++] = k;
				}
			}
		}
		for(int j = n-1;j >= 0;--j) if(bs[i][j] && vis2[j] == -1) {
			q[0] = j;qa = 0;qb = 1;vis2[j] = j;v2[i] = v2[j] = true;
			while(qa < qb) {
				int cur = q[qa++];
				bstype res = ~v2&bs[cur];
				v2 |= res;
				for(int k = 0;k < n;++k) if(res[k]) {
					vis2[k] = j;
					q[qb++] = k;
				}
			}
		}
		for(int j = 0;j < n;++j) if(vis1[j] != vis2[j]) bs3[i][j] = 1;
	}
	for(int i = 0;i < m;++i) {
		int a = p[i].first, b = p[i].second;
		if(bs2[b][a] == bs3[a][b]) {
			printf("same\n");
		} else {
			printf("diff\n");
		}
	}
}


Measured memory_bytes: 3200
#include <stdio.h>
#define Max 100000
#define max 50000
main(){

  int n[Max],q[max];
  int a,b,i,j,k,count=0,left,right,mid;

  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&n[i]);
  }

  scanf("%d",&b);
  for(j=0;j<b;j++){
    scanf("%d",&q[j]);
  }




  for(k=0;k<b;k++){
    left=0;
    right=a;
    while(left<right){
      mid = (left+right)/2;
      if(n[mid]==q[k]){
	count++;
	break;
      }
      else if(q[k]<n[mid])
	right=mid;
      else
	left = mid+1;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

cat mod = 1000000007;

struct fin {
	vector<cat> T;
	fin(int N) : T(N+10, 0) {}

	int lastone(int x) {return x&(x^(x-1));}

	void put(int pos, cat val) {
		for(int i = pos+1; i < (int)T.size(); i += lastone(i)) {
			T[i] += val;
			if(T[i] >= mod) T[i] -= mod;
		}
	}

	cat get(int pos) {
		cat ret = 0;
		for(int i = pos+1; i > 0; i -= lastone(i)) ret += T[i];
		return ret % mod;
	}
};

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, M;
	cin >> N >> M;
	vector<int> R(N);
	set<int> E;
	for(int i = 0; i < N; i++) cin >> R[i];
	for(int i = 0; i < M; i++) {
		int x;
		cin >> x;
		E.insert(x);
	}

	vector< pair<int, int> > dist;
	for(int i = 0; i < N; i++) {
		auto it = E.lower_bound(R[i]);
		if(it == end(E) || it == begin(E)) continue;
		auto jt = it;
		jt--;
		dist.push_back({*it-R[i], -(R[i]-*jt)});
	}
	sort(begin(dist), end(dist));
	int sz = unique(begin(dist), end(dist)) - begin(dist);
	dist.resize(sz);
	map<int, int> X;
	for(int i = 0; i < sz; i++) {
		dist[i].ss *= -1;
		X[dist[i].ss] = 0;
	}
	int mx = 0;
	ALL_THE(X, it) it->ss = mx++;
	for(int i = 0; i < sz; i++) dist[i].ss = X[dist[i].ss];

	vector<cat> cnt(sz, 1);
	fin F(mx);
	cat ans = 1;
	for(int i = 0; i < sz; i++) {
		cnt[i] += F.get(dist[i].ss-1);
		if(cnt[i] >= mod) cnt[i] -= mod;
		F.put(dist[i].ss, cnt[i]);
		ans += cnt[i];
		if(ans >= mod) ans -= mod;
	}
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 8440
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
#include <map>

using namespace std;

typedef long long LL;

const int N = 2e5;

LL n, m;
LL a[N+5];
LL b[N+5];
LL ans;

bool Pan(LL x)
{
	LL p = m;
	for(register int i=1; i<=n; i++)
	{
		LL tmp = a[i]-x/b[n-i+1];
		tmp = max(0ll, tmp);
		p -= tmp;
	}
	return p >= 0;
}


int main()
{
	scanf("%lld %lld", &n, &m);
	
	for(register int i=1; i<=n; i++)
		scanf("%lld", &a[i]);
	for(register int i=1; i<=n; i++)
		scanf("%lld", &b[i]);
	
	sort(a+1, a+n+1);
	sort(b+1, b+n+1);
	
	LL l=-1, r=a[n]*b[n];
	while(l+1 < r)
	{
		LL mid = (l+r)>>1;
		if(Pan(mid))
			r = mid;
		else
			l = mid;
	}
	
	printf("%lld", r);
	return 0;
}

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

using namespace std;

int main()
{
    int n, h, x, amax=0;
    cin>>n>>h;
    int b[n];
    for(int i = 0; i < n; i++)
    {
        cin>>x>>b[i];
        amax = max(amax, x);
    }
    sort(b, b+n, [](const int &a, const int &b) -> bool
    {
        return a > b;
    });
    int ans = 0;
    int sum = 0;
    for (int i=0; i<n; i++)
    {
        if (b[i] < amax || sum >= h)
            break;
        sum += b[i];
        ans += 1;
    }

    while (sum < h)
    {
        sum += amax;
        ans += 1;
    }
    cout<<ans;
    return 0;
}



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

int main(){
    long long A,B,K;

    cin >> A >> B >> K;

    if(A >= K){
        cout << A - K << " " << B;
        
    }else if(A < K && B + A > K){
        cout << 0 << " " << B - (K - A);
        
    }else if(A + B <= K ){
        cout << 0 << " " << 0;
    }
}

Measured memory_bytes: 256
from bisect import bisect_left

A, B, Q = map(int, input().split())
INF = 10**18
S = [int(input()) for _ in range(A)] + [INF, INF, -INF, -INF]
T = [int(input()) for _ in range(B)] + [INF, INF, -INF, -INF]

S.sort()
T.sort()

for _ in range(Q):
    x = int(input())

    s = bisect_left(S, x)
    ls = S[s - 1]
    rs = S[s]

    t = bisect_left(T, x)
    lt = T[t - 1]
    rt = T[t]

    ans = min(
        abs(ls - rt) + min(abs(x - ls), abs(x - rt)),
        abs(lt - rs) + min(abs(x - lt), abs(x - rs)),
        max(abs(x - ls), abs(x - lt)),
        max(abs(x - rs), abs(x - rt))
    )

    print(ans)


Measured memory_bytes: 12816
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>

#include <cassert>
using namespace std;

const long long INF = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];

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

    long long minDiff = INF;

    do {
        int x = (a[2] >> 1);
        int y = a[2] - x;

        minDiff = min(minDiff, 1LL * a[0] * a[1] * abs(x - y));
    } while (next_permutation(a.begin(), a.end()));

    cout << minDiff << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>//..1..2..3:Correct:Solved by F2tekkz:)
#define ll long long
#define str string
#define sonic ios_base::sync_with_stdio(0)
using namespace std;
ll n , m , k , i , j , t , q , cnt , cnt1 , cnt2 , cnt3;
ll cnt4 , cnt5 , ans , ans1 , ans2 , ans3 , sum , sum1 , sum2;
ll mini = 1e9 , maxi = -999;
int main(){
	sonic;
	cin >> n >> m;
	for(ll i = 0 ; i <= n ; i ++){
		if(n <= m * i){
			cout << i;
			return 0;
		}
	}
}
//     *    *  *  ****    *    *   *
//    *	*   * *   *      * *   *   *
//   *****  **    ****  *****  *****
//   *   *  * *      *  *   *      *
//   *   *  *  *  ****  *   *  *****

//   *  *  *****  *
//   * *     *    *
//   **      *    *
//   * *     *    *
//   *  *    *    ****

//   ****  ****  *       *
//   *      **   *      * *
//   ****   **   *     *****
//      *   **   *     *   *
//   ****  ****  ****  *   *


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

using namespace std;

const long long MOD = 998244353;

long long bin_pow(long long a, long long n, long long m)
{
    if(n == 0)
        return 1;
    long long p = bin_pow(a, n / 2, m);
    if(n % 2 == 0)
        return (p * p) % m;
    else
        return (((a * p) % m) * p) % m;
}

int main()
{
    long long n, k;
    cin >> n >> k;
    cout << min(n % k, abs(n % k - k));
    return 0;
}


Measured memory_bytes: 256
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,cos,radians,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

a,b,h,m=MI()
rad=radians(6*m-m/2-30*h)
print(sqrt(a**2+b**2-2*a*b*cos(rad)))

Measured memory_bytes: 9812
import java.util.*;
public class Main
{
  public static void main(String []args){
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int y=sc.nextInt();

    if(x<=9 && y<=9){
      System.out.println(x*y);
    }else{
      System.out.println("-1");
    }
  }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define int long long

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> plli;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1e9 + 7;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true) {
        cin >> n;
        if (n == 0) break;
        int group[n] = {};
        int color[n];
        fill(color, color + n, -1);
        int group_idx = -1;
        int pre = -1;
        rep(i, n) {
            int c;
            cin >> c;
            if (pre == c) group[group_idx]++;
            else {
                pre = c;
                if (i % 2 == 0) {
                    group_idx++;
                    group[group_idx]++;
                    color[group_idx] = c;
                }
                else {
                    if (group_idx == 0) {
                        group[0]++;
                        color[0] = c;
                    }
                    else {
                        group[group_idx - 1] += group[group_idx] + 1;
                        group[group_idx] = 0;
                        group_idx--;
                    }
                }
            }
        }
        int ans = 0;
        rep(i, n) if (color[i] == 0) ans += group[i];
        cout << ans << endl;
    }
}

Measured memory_bytes: 4684
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<string>
#include<set>
#include<queue>
#include<cmath>
#include<tuple>
#include<utility>
#include<functional>
#include<algorithm>

#define LL long long
#define trio tuple<int,int,int>

using namespace std;

int a,b,c;

int main() {
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<' '<<b<<' '<<c<<endl;
	return 0;
}



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

int main() {
  int n, m;
  cin >> n >> m;

  vector<bool> v(n);
  v.front() = true;

  vector<int> c(n, 1);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;

    if (v[x])
      v[y] = true;
    c[y]++;
    c[x]--;
    if (c[x] == 0)
      v[x] = false;
  }

  int cnt = 0;
  for (int i = 0; i < n; ++i)
    if (v[i])
      ++cnt;

  cout << cnt << endl;
}

Measured memory_bytes: 768
import numpy as np

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

a.sort()


def get_nearest_value(arr, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(arr) - num).argmin()

    return arr[idx]


first = a[-1]
second = get_nearest_value(a, first / 2)

print(first, second)


Measured memory_bytes: 38388
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int ans = 0;
    for(int i = a; i <= b; i++){
        if(c % i == 0)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3124
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)

    # divisors.sort()
    return divisors

N=int(input())
divisors = make_divisors(N)

distance = [ i - 1 + int(N / i) - 1 for i in divisors]
print(min(distance))

Measured memory_bytes: 3424
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_iroha_easy(void) {
	int l, n;
	string s[100];
	string ans = "";
	cin >> n >> l;
	for (int i = 0; i < n; i++) cin >> s[i];
	sort(s, s + n);
	for (int i = 0; i < n; i++) ans += s[i];
	cout << ans << endl;
}

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

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define int long long
main()
{
	int n;
	cin>>n;
	int a[n];
	for (int i=0;i<n;i++) cin>>a[i];
	int dp[3005][3005];
	for (int i=n-1;i>=0;i--)
	for (int j=i;j<n;j++)
	{
		if (i==j) dp[i][j]=a[i];
		else dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
	}
	cout<<dp[0][n-1];
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;


int main (){
  int n, m;
  cin >> n >> m;
  vector<pair<bool, int>> v(n+10, make_pair(false,1));
  bool f = true;
  v[1].first = true;

  for(int i = 0; i < m; i++){
    int x, y;
    cin >> x >> y;
    v[x].second--;
    v[y].second++;
    if(v[x].first){v[y].first = true;}
    if(v[x].second == 0){v[x].first = false;}
  }
  int cnt = 0;
  for(int i = 1; i <= n; i++){
    if(v[i].first){cnt++;}
  }
  cout << cnt << endl;
}

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

using namespace std;
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define fwr(x) { cout << x << '\n'; }

typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int inf = 1e9 + 7;
const ll linf = 1ll * inf * inf;
const int N = 1000000 + 7;
const int M = 1600;
const int multipleTest = 0;
const double pi = acos(-1);

int n, a, b;

void solve() {
    cin >> n >> a >> b;
    
    if ((b - a) & 1) {
        cout << "Borys";
    } else cout << "Alice";
}

int main() {
#ifdef _LOCAL_
    freopen("inp.txt", "r", stdin);
    //    freopen("out.txt", "w", stdout);
#endif
    
    int Test = 1;
    if (multipleTest)
        cin >> Test;
    
    for(int i = 0; i < Test; ++i) {
        //        printf("Case #%d: ", i + 1);
        solve();
    }
#ifdef _LOCAL_
    cout<< "\n" << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
#endif
}


Measured memory_bytes: 256
local read = setmetatable({}, {__index = function(t, k) return function() local a = {} for i=1,#k do table.insert(a, string.sub(k, i, i)) end return io.read(table.unpack(a)) end end})
local A, B, C = read.nnn()
local m = math.max(A,B,C)
local s = A+B+C
s = s - m + m*10
print(s)


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int x = 1,y = 1;

    while (1) {
        scanf("%d", &x);
        scanf("%d", &y);

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

        if (x > y)
            printf("%d %d\n", y, x);
        else
            printf("%d %d\n", x, y);
    }

    return 0;
}


Measured memory_bytes: 1728
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2000

#include <iostream>
#include <algorithm>
#include <cassert>
using namespace std;

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

int dir(char c) {
  int a = -1;
  switch(c) {
  case 'N': a=0; break;
  case 'E': a=1; break;
  case 'S': a=2; break;
  case 'W': a=3; break;
  }
  assert(a != -1);
  return a;
}

int main() {
  int N;
  while (scanf("%d", &N) != EOF && N) {
    int x, y;
    bool F[21][21];
    fill(&F[0][0], &F[0][0]+21*21, false);
    for (int i=0; i<N; i++) {
      scanf("%d%d", &x, &y);
      F[x][y] = true;
    }
    int cx = 10;
    int cy = 10;
    int ans = 0;
    if (F[cx][cy]) {
      ans++;
      F[cx][cy] = false;
    }
    int M;
    scanf("%d", &M);
    char c;
    int l;
    for (int i=0; i<M; i++) {
      scanf(" %c%d", &c, &l); // %cの場合は改行コードも読み取ってしまう。それを防ぐために先頭に空白を入れる。
      // cerr << "c " << c << endl;
      int d = dir(c);
      for (int j=0; j<l; j++) {
	cx += dx[d];
	cy += dy[d];
	if (F[cx][cy]) {
	  // cerr << "get x = " << cx << ", y = " << cy << endl;
	  ans++;
	  F[cx][cy] = false;
	}
      }
      // cerr << "now x = " << cx << ", y = " << cy << endl;
      /*cerr << "---- Walk for " << c << " to " << l << " ----" << endl;
      for (int k=0; k<21; k++) {
	for (int j=0; j<21; j++) {
	  if (k == 10 && j == 10) {
	    cerr << 3 << " ";
	  } else if (k == cx && j == cy) {
	    cerr << 2 << " ";
	  } else if (F[k][j]) {
	    cerr << 1 << " ";
	  } else {
	    cerr << 0 << " ";
	  }
	}
	cerr << endl;
	}*/
    }
    if (ans == N) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
}

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


using namespace std;


int main() {
    int n; cin >> n;
    vector<int> L(n);
    for (int i = 0; i < n; i++) cin >> L[i];
    sort(L.begin(), L.end());

    int ans = 0;
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
          int ab = L[i] + L[j];
          int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
          int l = j+1;
          ans += r-l;
        }
    }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;
const int mod = 1e9+7;
int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int lcs(string a, string b) {
  int n = a.size(), m = b.size();
  int dp[2][m+1];
  for(int i = 0;i <= n;i++) {
    for(int j = 0;j <= m;j++) {
      if(i==0||j==0) dp[i%2][j] = 0;
      else {
        if(a[i-1] == b[j-1]) dp[i%2][j] = 1 + dp[1-i%2][j-1];
        else dp[i%2][j] = max(dp[i%2][j-1], dp[1-i%2][j]);
      }
    }
  }
  return dp[n%2][m];
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

bool equal(string s) {
  for(int i = 0,j = s.size()/2;j < s.size();i++,j++) {
    if(s[i] != s[j]) return false;
  }
  return true;
}

ll fact(int n) {
  ll ans = 1;
  fr(i,2,n+1) ans = (ans*i)%mod;
  return ans;
}

ull f(ll a, ll x) {
  if(a < 0) return 0;
  return (a/x+1);
}

int main() {
  int w,h,n;
  cin>>w>>h>>n;
  int minx = 0, maxx = w, miny = 0, maxy = h; // white area
  while(n--) {
    int x,y,a;
    cin>>x>>y>>a;
    if(a==1) {
      minx = max(minx, x);
    }else if(a==2) {
      maxx = min(maxx, x);
    }else if(a==3) {
      miny = max(miny,y);
    }else if(a==4){
      maxy = min(maxy,y);
    }
  }
  if(minx > maxx && miny > maxy)
  {
    cout<<0;nl;return 0;
  }
  int ans = max(0,(maxx-minx)*(maxy-miny));
  cout<<ans;
}



Measured memory_bytes: 256