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

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

struct ya{
		long long p;
		int co;
};

int main(){
		long long n,m,a,i;
		scanf("%lld%lld",&n,&m);
		a=gcd(n,m);
		int c=0;
		struct ya y[100000];
		y[0].co=0;
		for(i=2;i*i<=a;i+=2){
				if(a%i==0){
						while(a%i==0){
								a/=i;
						}
	//					printf("%lld\n",a);
						c++;
				}
				if(i==2)i--;
		}if(a!=1)c++;
		printf("%d\n",c+1);
		return 0;
}


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

        if( x-r < 0 || x+r > W || y-r < 0 || y+r > H){
             System.out.println("No");
        }
        else System.out.println("Yes");
        
    }
}



Measured memory_bytes: 26416
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

ll ecd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	else {
		return ecd(b, a % b);
	}
}

ll pow(ll a, ll b) {
	vector<ll> d = vector<ll>((ll)(log(b)) + 2);
	d[0] = a;
	rep(i, 1, d.size()) d[i] = d[i - 1] * d[i - 1];
	ll ret = 1;
	rep(i, 0, log(b) + 1) {
		if (b & 1 << i) ret *= d[i];
	}
	return ret;
}


//D
int main(void) {
	ll N, W;
	cin >> N >> W;
	vector<ll> w = vector<ll>(N), v = vector<ll>(N);
	rep(i, 0, N) cin >> w[i] >> v[i];
	ll ans = 0;
	vector<vector<ll>> dp = vector<vector<ll>>(N+1, vector<ll>(W+1));
	rep(i, 0, W + 1)dp[N][i] = 0;
	for (ll i = N - 1; i >= 0; i--) {
		rep(j, 0, W+1) {
			if (j < w[i] ) dp[i][j] = dp[i + 1][j];
			else {
				dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
			}
		}
	}
	cout << dp[0][W] << endl;
}


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

using namespace std;

int main() {
	int N, L;
	cin >> N >> L;
	int applepie = 0;
	for (int i = 1; i <= N; i++) {
		applepie += L + i - 1;
	}
	int ans;
	int diff = abs(L + 1 - 1);
	for (int i = 2; i <= N; i++) {
		diff = min(diff, abs(L + i - 1));
	}
	for (int i = 1; i <= N; i++) {
		if (abs(L + i - 1) == diff) ans = applepie - (L + i - 1);
	}
	cout << ans << endl;
	return 0;
}

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

#define forn(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vii;


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);	
        int n,k;
        cin>>n>>k;
        vector<int>v(n);
        forn(i,n)cin>>v[i];
        vector<int>dp(k+1);
        for(int i=1;i<k+1;i++){
            for(int j=0;j<n;j++){
                if(v[j]<=i){
                    if(dp[i-v[j]]==0){
                        dp[i]=1;
                        break;
                    }
                }
                else break;
            }
        }
        if(dp[k])cout<<"First"<<endl;
        else cout<<"Second"<<endl;
}


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

int main(){
    int x;
    cin >> x;
    int X = x;
    int sum = 0;
    while(X > 0){
        sum += X % 10;
        X /= 10;
    }
    if (x % sum == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
	int a,b,c,X,Y,Z;
	scanf("%d %d %d",&a,&b,&c);
	X=a+b;
	Y=b+c;
	Z=a+c;
	if(X == c || Y == a || Z == b) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include<bits/stdc++.h>
#define ll long long
#define read freopen("input/test (4).txt","r",stdin)
#define write freopen("output/test (4).txt","w",stdout)
#define fr first
#define sc second
#include <sstream>
#define ii pair < int , int >
using namespace std;
ll a,b;
ll sum1,sum2;
ll gcd(ll a,ll b)
{
    return (b==0 ? a : gcd(b,a%b));
}
int check(ll x)
{
    return (x*a >=sum1 && x*b>=sum2);
}
int main()
{
 int n;
 cin>>n;
sum1 = 1,sum2 = 1;
 for(int i=0;i<n;i++)
 {
     cin>>a>>b;
     ll s = 1 , E = 1e18/max(a,b);
     while(s < E)
     {
         ll mid = (E+s)/2;
         if(s == mid)
         {
             if(check(s))
             {
                 E = s;
             }
             else
             {
                 s = E;
             }
             break;
         }
         if(check(mid))
         {
            E = mid;
         }
         else
         {
             s = mid;
         }
     }
     sum1 = a*s;
     sum2 = b*s;
 }
 cout<<sum1+sum2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define int ll
#define Endl endl

signed main(){
    int N,M;
    pair<int,int> AB[114514];
    cin >> N >> M;
    int a,b;
    REP(i,N){
        cin >> a >> b;
        AB[i]={a,b};
    }
    sort(AB,AB+N);
    int Ans=0;
    REP(i,N){
        while(AB[i].second>0 && M>0){
            Ans+=AB[i].first;
            AB[i].second--;
            M--;
        }
        if(M==0)break;
    }
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		if(s.indexOf("AC") == -1) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 40+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

char c[maxn][maxn];
int n;
ll f[maxn][maxn][maxn];

ll dfs(int l,int r,int mid) {
    if(f[l][r][mid]!=-1) return f[l][r][mid];
    if(l==r) return 1;
    if(l==mid||r==mid) return 0;
    ll ans=0;
    for(int j=l;j<mid;j++)
        for(int k=mid+1;k<=r;k++) {
            if(c[j][k]=='0') continue;
            for(int s=j;s<mid;s++)
                for(int t=mid+1;t<=k;t++)
                    ans+=dfs(l,s,j)*dfs(t,r,k)*dfs(s+1,t-1,mid);
        }
    // printf("dfs :: %d %d %d %d\n",l,r,mid,ans);
    return f[l][r][mid]=ans;
}

int main() {
    read(n);n<<=1;for(int i=1;i<=n;i++) scanf("%s",c[i]+1);
    ll ans=0;memset(f,-1,sizeof f);
    for(int i=2;i<=n;i++) if(c[1][i]=='1') ans+=dfs(2,n,i);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	static int a,b;

	public static void main(String args[]){

		Scanner s=new Scanner(System.in);
		while(true){
			a=s.nextInt();
			b=s.nextInt();
			if(a==0)System.exit(0);
			int[][] map = new int[a+1][a+1];
			for(int i=1; i<=a; i++) {
				for(int j=1; j<=a; j++) {
					map[i][j] = 1<<25;
					if(i==j)map[i][j]=0;
				}
			}

			for(int n=0; n<b; n++) {
				int c = s.nextInt();
				if(c==1) {
					int p = s.nextInt();
					int q = s.nextInt();
					int w = s.nextInt();
					if(map[p][q]<=w)continue;
					map[p][q] =  w;
					map[q][p] = w;

					for(int k=1; k<=a; k++) {
						for(int i=1; i<=a; i++) {
							for(int j=1; j<=a; j++) {
								if(map[i][j]>map[i][k]+map[k][j]) {
									map[i][j]=map[i][k]+map[k][j];
								}
							}
						}
					}
				} else  {
					int x=s.nextInt();
					int y=s.nextInt();
					if(map[x][y]==1<<25) {
						System.out.println(-1);
					} else {
						System.out.println(map[x][y]);
					}
				}
			}
		}
	}

}



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

int main() {
int a,b,c; cin >> a >> b >> c;
multiset<int> s;
s.insert(a); s.insert(b); s.insert(c);

if(s.count(5) == 2 && s.count(7) == 1) cout <<"YES" << endl;
else cout <<"NO" <<endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,k,a[3],f[100001][3],b[100001];
char S[100001];
inline int other(int x,int y) {
	if(!y) return max(f[x][1],f[x][2]);
	if(y==1) return max(f[x][0],f[x][2]);
	return max(f[x][0],f[x][1]);
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k>>a[0]>>a[1]>>a[2]>>(S+1);
	for(res i=1;i<=n;++i) if(S[i]=='r') b[i]=0;else if(S[i]=='s') b[i]=1;else b[i]=2;
	for(res i=1;i<=k;++i) f[i][(b[i]+2)%3]=a[(b[i]+2)%3];
	for(res i=k+1;i<=n;++i)
	  for(res j=0;j<3;++j) if(j==(b[i]+2)%3) f[i][j]=a[j]+other(i-k,j);else f[i][j]=other(i-k,j);
	int tot=0;
	for(res i=n-k+1;i<=n;++i) tot+=max(max(f[i][0],f[i][1]),f[i][2]);
	cout<<tot<<'\n';
	cout<<flush;	
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 1920
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
#define M 1000000007

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    vector<ll>v(n);
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
    }
    map<ll,set<ll>>m1;
    for(ll i=0;i<m;i++)
    {
        ll a,b;
        cin>>a>>b;
        m1[a].insert(v[b-1]);
        m1[b].insert(v[a-1]);
    }
    
    int ans=0;
    for(auto &i:m1)
    {
        auto it = i.second.rbegin();
        if(v[i.first -1]>*it)
        {
        ans++;
        
        }
        //cout<<"1"<<" ";
        
    }
    cout<<ans+n-m1.size()<<endl;
}

Measured memory_bytes: 21400
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_TOWN_MAX		100005									// 最大街数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1MCnt[D_TOWN_MAX];									// モンスター数[街]
static int si1WCnt[D_TOWN_MAX];									// 討伐数[街]
static int siTCnt;												// 街数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
long long
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 街数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siTCnt);
	siTCnt++;

	// モンスター数 - 取得
	for (i = 0; i < siTCnt; i++) {
		fscanf(szpFpI, "%d", &si1MCnt[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 討伐数 - 取得
	for (i = 0; i < siTCnt - 1; i++) {
		fscanf(szpFpI, "%d", &si1WCnt[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 合計数 - 取得
	long long llSum = 0;
	for (i = 0; i < siTCnt - 1; i++) {

		// 自分の街
		if (si1MCnt[i] < si1WCnt[i]) {
			llSum += si1MCnt[i];
			si1WCnt[i] -= si1MCnt[i];
		}
		else {
			llSum += si1WCnt[i];
			si1WCnt[i] = 0;
		}

		// 先の街
		if (si1MCnt[i + 1] < si1WCnt[i]) {
			llSum += si1MCnt[i + 1];
			si1MCnt[i + 1] = 0;
		}
		else {
			llSum += si1WCnt[i];
			si1MCnt[i + 1] -= si1WCnt[i];
		}
	}

	return llSum;
}

// １回実行
int
fOne(
)
{
	long long llRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	llRet = fMain();

	// 出力
	sprintf(lc1Buf, "%lld\n", llRet);
	fOut(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

int main() {
    int A, B;

scanf("%d", &B);
scanf("%d", &A);

    if((A+B)>16) {
    printf(":(");
    }

    if (A>8 || B>8) {
        printf(":(");
    }
    else printf("Yay!");

    return 0;

}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)
input=sys.stdin.readline

n,q=map(int,input().split())
t=[[] for _ in range(n)]
c=[0 for _ in range(n)]

for i in range(n-1):
  a,b=map(int,input().split())
  t[a-1].append(b-1)
  t[b-1].append(a-1)

for i in range(q):
  p,x=map(int,input().split())
  c[p-1]+=x

def dsf(ci,pi):
  for i in t[ci]:
    if i != pi:
      c[i] += c[ci]
      dsf(i, ci)

dsf(0,-1)

print(*c)


Measured memory_bytes: 230932
str = input()
list = []
for x in range(len(str)):
    list.append(str[x])
list.sort()
if len(str) % 2 != 0: print("No")
else: 
    iscount = True
    for x in range(int(len(str) / 2)):
        if list[2 * x] != list[2 * x + 1]: iscount = False
    if iscount == True: print("Yes")
    else:print("No")
    

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    const ll M(10000);
    ll N, W;
    cin >> N >> W;
    vector<ll> v(N+10), w(M+10);
    rep(i,1,N+1) cin >> v[i] >> w[i];
   
    vector<vector<ll>> dp(N+10, vector<ll>(M+10, -1));   

    rep(i, 0, W+1)
        dp[0][i] = 0;

    rep(i,1,N+1)
    {
        rep(j,0,W+1)
        {
            if (j-w[i] >= 0 && j-w[i] <= W) 
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
            else
                dp[i][j] = dp[i-1][j];

            //for (auto k : dp)
            //{
            //    for (auto l: k)
            //        cout << ' ' << l;
            //    cout << endl;
            //}

        }
    }

    cout << dp[N][W] << endl;
 
    return 0;
}



Measured memory_bytes: 11596
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <functional>

#define rep(i,n) for(int i=0;i<n;i++)
#define scanInt(i) scanf("%d", &i)

using namespace std;

int main(){

	int n;
	scanInt(n);
	int	a[n];
	rep(i,n){
		scanInt(a[i]);
		a[i] -= 1;
	}
	int counter = 0;
	rep(i,n){
		if(a[a[i]] == i) counter++;
	}
	cout << counter/2 << endl;
	return 0;
}


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

int main () {
int x,y;
cin >> x >> y;
if (x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12){
	if (y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
} else if  (x==2) {
	if (y == 2) {cout << "Yes" << endl;}
	else {
	cout << "No"<< endl;
	}
}
else {
	if (y==4 || y==6 || y==9 || y==11){
	cout << "Yes" << endl;}
	 else { 
		cout << "No" << endl;
	}
}
}

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

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  int i,j;

  int n;
  scanf("%d\n",&n);
  for(int T=0; T<n; ++T){
    string s;
    getline(cin,s);

    string h="Hoshino";
    string r="Hoshina";

    if(h.size()<=s.size()){
      rep(i,s.size()-h.size()+1){
        if(s.substr(i,h.size())==h){
          s[i+h.size()-1]='a';
        }
      }
    }

    std::cout << s << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
 
using lli = long long int;
using ld=long double;
 
 
int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++)
    cin>>a[i];
    for(int i=0;i<n;i++)
    cin>>b[i];
    int sum=0;
    for(int i=0;i<n;i++){
        if(a[i]>b[i]){
            sum+=abs(a[i]-b[i]);
            //cout<<a[i]<<" "<<b[i]<<endl;
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		boolean flag =true;
		for(int i=0;i<=25;i++){
			int all = i*4;
			while(all<=100){
				if(n==all&&n!=0){flag=false;break;}
				all=all+7;
			}
			if(flag==false){break;}
		}
		if(flag){System.out.println("No");}
		else{System.out.println("Yes");}
		
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <functional>
#include <queue>
#include <cmath>
#include <cmath>
#include <string>
#include <deque>
using namespace std;

typedef long long ll;

ll ABS(ll a, ll b)
{
	if (a - b >= 0)return a - b;
	else return b - a;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	ll ans = 0;
	deque<ll>dq(n);
	deque<ll>dq2(n);
	for (int i = 0; i < n; i++) {
		cin >> dq[i];
		dq2[i] = dq[i];
	}
		
	sort(dq.begin(), dq.end());
	sort(dq2.begin(), dq2.end());
	deque<ll>a;
	deque<ll>b;
	a.push_back(dq[0]);
	dq.pop_front();
	while (!dq.empty()) {
		a.push_front(dq.back());//가장큰거 
		dq.pop_back();
		if (dq.empty())break;
		a.push_back(dq.back());
		dq.pop_back();
		if (dq.empty())break;
		a.push_front(dq.front());
		dq.pop_front();
		if (dq.empty())break;
		a.push_back(dq.front());
		dq.pop_front();
		if (dq.empty())break;
		
	}
	int t = a.size();
	for (int i = 1; i < t; i++)
		ans += ABS(a[i],a[i - 1]);
	b.push_back(dq2[dq2.size() - 1]);
	dq2.pop_back();
	while (!dq2.empty())
	{
		b.push_front(dq2.front());
		dq2.pop_front();
		if (dq2.empty())break;
		b.push_back(dq2.front());
		dq2.pop_front();
		if (dq2.empty())break;
		b.push_front(dq2.back());
		dq2.pop_back();
		if (dq2.empty())break;
		b.push_back(dq2.back());
		dq2.pop_back();
		if (dq2.empty())break;

	}
	int p = b.size();
	ll ans2 = 0;
	for (int i = 1; i < p; i++)
		ans2 += ABS(b[i], b[i - 1]);
	cout << max(ans, ans2);
}

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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007

void solve()
{	
	ll a,b,c,k,t,ans=0;
	cin>>a>>b>>c>>k;
	t=min(k,a);
	k-=t;
	ans+=t;
	t=min(k,b);
	k-=t;
	t=min(k,c);
	ans-=t;
	cout<<ans;
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pf push_front
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

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

int main(){
	//input
	ll N; cin>>N;

    if(N==1){
        cout<<0;
        return 0;
    }

	vector<ll> A(N+1);
    A[0]=-INF;
    vector<ll> B(N+1);
    B[0]=-INF;

    rep1(i,N){
        cin>>A[i];
        B[i]=-A[i];
    }
    sort(all(A));
    sort(all(B));

    ll ans;
    if(N%2==1){
        ll tmpA=0,tmpB=0;
        rep1(i,(N-1)/2){
            tmpA-=2*A[i];
            tmpB-=2*B[i];
        }
        FOR(i,(N+1)/2,(N+5)/2){
            tmpA+=A[i];
            tmpB+=B[i];
        }
        FOR(i,(N+5)/2,N+1){
            tmpA+=2*A[i];
            tmpB+=2*B[i];
        }
        ans=max(tmpA,tmpB);
    }
    else{
        ll tmpA=0,tmpB=0;
        rep1(i,(N-2)/2){
            tmpA-=2*A[i];
            tmpB-=2*B[i];
        }
        tmpA-=A[N/2];
        tmpB-=B[N/2];
        tmpA+=A[N/2+1];
        tmpB+=B[N/2+1];
        FOR(i,N/2+2,N+1){
            tmpA+=2*A[i];
            tmpB+=2*B[i];
        }
        ans=max(tmpA,tmpB);
    }

    cout<<ans;
}

Measured memory_bytes: 1920
import static java.lang.System.*;

import java.util.Scanner;

class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char c[] = new char[26];
		int count[] = new int[26];
		for(int ab = 0; ab < 26; ab++) {
			c[ab] = (char)('a' + ab);
		}
		while(sc.hasNextLine()) {
			String str = sc.nextLine();
			for(int a = 0; a < str.length(); a++) { // 文字数
				for(int b = 0; b < 26; b++) {       // アルファベット
					if(String.valueOf(str.charAt(a)).equalsIgnoreCase(String.valueOf(c[b]))) {       
						count[b] += 1;
					}
				}
			}
		}
		for(int a = 0; a < 26; a++) {
			out.println(c[a] + " : " + count[a]);
		}
	}
}


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

int main(){
  int n;
  cin >> n;
  vector<int> v(n, 0);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  int cnt = 0;
  for(int i = 1; i < n-1; i++){
    if(v[i-1] < v[i] && v[i] < v[i+1]){cnt++;}
    else if(v[i-1] > v[i] && v[i] > v[i+1]){cnt++;}
  }
  cout << cnt << endl;
}       

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, K;
ll A[200010];
ll S[1000010];
ll base = 500000;

void upd() {
  rep( i, 1000010 )
    S[i] = 0;

  rep( i, N ) {
    ++S[i+1-A[i]+base];
    --S[i+1+A[i]+1+base];
  }

  rep( i, 1000010 ) 
    S[i+1] += S[i];

  rep( i, N )
    A[i] = S[i+1+base];

  return;
}

int main() {
  std::cin >> N >> K;

  rep( i, N )
    std::cin >> A[i];

  rep( i, K ) {
    upd();

    bool fl = true;

    rep( i, N ) {
      fl &= A[i] == N;

      if( !fl )
        break;
    }

    if( fl )
      break;

    //rep( i, N )
      //std::cout << A[i] << (i==N-1?'\n':' ');
  }

  rep( i, N )
    std::cout << A[i] << (i==N-1?'\n':' ');

  return 0;
}

Measured memory_bytes: 13008
n = int(input())
a = list(map(int,input().split()))
max_l = set()
min_l = set()

for i in range(n):
    if 1 <= a[i] < 400:
        min_l.add(1)
    elif 400 <= a[i] < 800:
        min_l.add(2)
    elif 800 <= a[i] < 1200:
        min_l.add(3)
    elif 1200 <= a[i] < 1600:
        min_l.add(4)
    elif 1600 <= a[i] < 2000:
        min_l.add(5)
    elif 2000 <= a[i] < 2400:
        min_l.add(6)
    elif 2400 <= a[i] < 2800:
        min_l.add(7)
    elif 2800 <= a[i] < 3200:
        min_l.add(8)
    else:
        max_l.add(i)

min_v = max(1,len(min_l))
# if len(min_l)+len(max_l) > 8:
#     max_v = 8
# else:
max_v = len(min_l)+len(max_l)
        
print(min_v,max_v)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    string S,T; cin >> S >> T;
    string ans;
    rep(i,n){
        ans += S[i];
        ans += T[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    double ans=0;
    int n;cin>>n;
    rep(i,n){
        double x;cin>>x;
        ans+=1/x;
    }
    cout<<fixed<<setprecision(7);
    cout<<1/ans<<endl;
    
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int k, i=0;
  vector<int> a(5);
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;
  if(a[4]-a[0]>k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
        int ans = 0;
      
        for(int i = 1; i <= n; i++) {
          String[] list = ("" + i).split("");
          int count = 0;
          for(int index = 0; index < list.length; index++) {
            count += Integer.parseInt(list[index]);
          }
          if (a <= count && count <= b) {
            ans += i;
          }
        }
    
		// 出力
		System.out.println(ans);
	}
}

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

int main(void){

    string S;
    cin >> S;
    //S = "?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???";

    long long int dp[100100][13]={};
    dp[0][0] = 1;
    long long int n = S.size();

    for (int i = 0; i < n; ++i) {
        int c;
        if(S.at(i) == '?') c = -1;
        else c = S.at(i) - '0';

        for (long long int j = 0; j < 10; ++j) {
            if(c != -1 && c != j) continue;
            for (long long int k = 0; k < 13; ++k) {
                dp[i+1][(k*10+j) % 13] += dp[i][k];
            }
        }
        for (long long int j = 0; j < 13; ++j) {
            dp[i+1][j] %= 1000000007;
        }
    }
    cout<<dp[n][5]<<endl;
    return 0;
}

Measured memory_bytes: 10624
import std.stdio;
import std.algorithm;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{//try{
	auto tokens = split(my_readln());
	auto X = to!ulong(tokens[0]);

	if (X == 7 || X == 5 || X == 3)
		writeln("YES");
	else
		writeln("NO");
	stdout.flush();
/*}catch (Throwable e)
	{
		writeln(e.toString());
	}
readln();*/
}

Measured memory_bytes: 256
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    private[this] val top = (n - 3) / 2 + 1
    private[this] val sqrtLimit = (Math.sqrt(n).toInt - 3) / 2

    private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)
    def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0
    def notPrime(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    def next(i: Int): Int = if((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)

    def exec: Iterator[Int] = {
/*
      for{
        i <- 0 to sqrtLimit
        if isPrime(i)
        j <- Range(((2 * i + 3)*(2 * i + 3)-3)/2, top, (2 * i + 3))
      } notPrime(j)
*/
      /*
      (0 to sqrtLimit).map{ i =>
        val p = 2 * i + 3
        if(isPrime(i))Range((p*p-3)/2, top, p).map{notPrime}
      }
      */

      (0 to sqrtLimit).map { i =>
        if(isPrime(i)){
          val p = 2 * i + 3
          Range((p*p-3)/2, top, p).map(notPrime)
        }
      }

      if(n==2)Iterator.single(2)
      else Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) / 2)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 306508
#include <cstdio>
using namespace std;

int main(){

while(1){

  int m,n,s[203][2] = {0};
  scanf("%d",&m);
  
  if(m == 0) break;

  int kx,ky,da[1003][2]={0};

  scanf("%d%d",&kx,&ky);

  for(int i = 0;i < m-1;i++){
    int tx,ty;
    scanf("%d%d",&tx,&ty);
    s[i][0] = tx - kx;
    s[i][1] = ty - ky;
  }
  scanf("%d",&n);

  for(int i = 0;i < n;i++){
    int t1,t2;
    scanf("%d%d",&t1,&t2);
    da[i][0] = t1;
    da[i][1] = t2;
  }

  int ax,ay;

  for(int i = 0;i < n;i++){
    ax = da[i][0];
    ay = da[i][1];
    for(int j = 0;j < m-1;j++){
      int cx = ax + s[j][0];
      int cy = ay + s[j][1];
      if(cx < 0 || cy < 0 ){
	goto out;
      }
	  for(int k = 0;k < n;k++){
		if(da[k][0] == cx && da[k][1] == cy){
			goto hev;
		}
	  }
	  goto out;
	  hev:
	  ;
	}
    break;
  out:
    ;
  }

  printf("%d %d\n",ax-kx,ay-ky);
  
  }

  return 0;
}


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

int cmpnum(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2) {
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2) {
		return -1;
	}
	else {
		return 0;
	}
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long l[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &l[i]);
  }
  qsort(l, n, sizeof(long), cmpnum);
  long count = 0;
  for (long i = 0; i < n; i++) {
    for (long j = i+1; j < n; j++) {
      for (long k = j+1; k < n; k++) {
        if (l[i] != l[j] && l[i] != l[k] && l[j] != l[k]) {
          if (l[i]+l[j] > l[k]) {
            count++;
          }
        }
      }
    }
  }
  printf("%ld\n", count);

  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  cin >> N >> M >> K;
  ;
}
void solve() {
  if (N + M == K or M + K == N or N + K == M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  };
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
A =input()
pm = "+-"
ans = 0
for i in range(8):
    x = int(A[0])
    for j in range(3):
        if bin(i)[-(1+j)] == "1":
            x+=int(A[j+1])
        else:
            x-=int(A[j+1])
    if x == 7:
        ans = i
seven=A[0]
for j in range(3):
    if bin(ans)[-(1+j)] == "1":
        seven += "+"+A[j+1]
    else:
        seven += "-"+A[j+1]
print(seven+"=7")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>

struct AB
{
    long a;
    long b;

    AB(long A1, long B1)
    {
        a=A1;
        b=B1;
    }

    bool operator < (const AB &another) const
    {
        return a<another.a;
    }
};

int main()
{
    long N,K;
    std::cin >> N >> K;
    std::vector<AB> AB_gather;
    for(long i=0; i<N; i++){
        long a,b;
        std::cin >> a >> b;
        AB_gather.push_back(AB(a,b));
    }

    std::sort(AB_gather.begin(),AB_gather.end());

    long place=0;
    for(long i=0; i<N; i++){
        place+=AB_gather[i].b;
        if(K<=place){
            std::cout << AB_gather[i].a << std::endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 2420
#include<stdio.h>
#include<stdlib.h>
typedef long long ll;
ll max_cal(ll a,ll b)
{
  if(a>=b) return a;
  else return b;
}
void main(void)
{
  ll A,B,N,max=0,tmp=0;
  scanf("%lld%lld%lld",&A,&B,&N);
  ll i=N;
  if(N<(B-1)) printf("%lld",(A*N)/B);
  else printf("%lld",(A*(B-1))/B);

  //printf("%lld",max);
}

Measured memory_bytes: 1696
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 1e3 + 17;
ll cnt, ans, lnt, sum, n, l1, x, y, a[N], mx, b[N][N], m;
pair<ll,ll>pr[N];
vector<ll>v,v2,v3;
map<ll,ll>mp;
bool used[N], t1, t2;
vector<string>sv;

int main()
{
    cin >> n;
    for(ll i = 0; i < n; i ++)
    {
        cin >> a[i];
        sum += a[i];
        mx = max(a[i], mx);
    }
    for(ll i = 0; i < n; i ++)
    {
        if(mx < sum - mx)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


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

namespace ABC053_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int a = -1;
            int z = -1;
            for(int i = 0;i < s.Length; i++)
            {
                if(a == -1)
                {
                    if(s[i] == 'A')
                    {
                        a = i;
                    }
                }
                else
                {
                    if(s[i] == 'Z')
                    {
                        z = Math.Max(z, i);
                    }
                }
            }
            Console.WriteLine(z - a + 1);
            Console.Read();
        }
    }
}


Measured memory_bytes: 13280
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (int)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	int n;
	cin >> n;
	vector<int> arr(n), dp(n, INF);
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	dp[0] = 0;
	for(int i = 1; i < n; i++) {
		for(int j = max(0, i-2) ; j < i; j++) {
			dp[i] = min(dp[i], dp[j]+abs(arr[i]-arr[j]));
		}
	}
	cout << dp[n-1] << '\n';

	return 0;
 }


Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const ll mod=998244353,MAX=200001,INF=1<<30;

int main(){
  int a,b,c,d,e,f,g,h;cin>>a>>b>>c>>d>>e>>f>>g>>h;
  cout<<max(a+b+c+d,e+f+g+h)<<endl;
}



Measured memory_bytes: 3108
import java.awt.*;
import java.util.*;
import java.util.List;

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

        int h = sc.nextInt();
        int w = sc.nextInt();
        int m = sc.nextInt();


        Map<Point, Boolean> map = new HashMap<>();
        int[] hcount = new int[h];
        int[] wcount = new int[w];

        for (int i = 0; i < m; i++) {
            int h1 = sc.nextInt() - 1;
            int w1 = sc.nextInt() - 1;
            map.put(new Point(h1, w1), true);
            hcount[h1]++;
            wcount[w1]++;
        }


        int hmax = 0;
        for (int i = 0; i < h; i++) {
            hmax = Math.max(hmax, hcount[i]);
        }
        int wmax = 0;
        for (int i = 0; i < w; i++) {
            wmax = Math.max(wmax, wcount[i]);
        }

        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < w; i++) {
            if(wcount[i] == wmax){
                list.add(i);
            }
        }

        //System.out.println("hmax = " + hmax);
        //System.out.println("wmax = " + wmax);

        for (int i = 0; i < h; i++) {
            if(hcount[i] != hmax){
                continue;
            }
            for (int j = 0; j < list.size(); j++) {
                if(!map.containsKey(new Point(i, list.get(j)))){
                    System.out.println(hmax + wmax);
                    return;
                }
            }
        }

        System.out.println(hmax + wmax - 1);

    }

}


Measured memory_bytes: 91508
#include <stdio.h>

void pri(int [], int);
void reverse(int [], int, int);
void rotate(int [], int, int, int);

int main(void)
{
    int i, n, q, b, m, e, A[1000];

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", A + i);

    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d %d %d", &b, &m, &e);
        rotate(A, b, m, e);
    }

    pri(A, n);
    return 0;
}

void rotate(int A[], int b, int m, int e)
{
    reverse(A, b, m);
    reverse(A, m, e);
    reverse(A, b, e);
}

void reverse(int A[], int b, int e)
{
    int tmp;

    e--;
    while (b < e) {
        tmp = A[b];
        A[b] = A[e];
        A[e] = tmp;
        b++;
        e--;
    }
}

void pri(int A[], int N)
{
    int i;
    
    for (i = 0; i < N; i++) {
        if (i > 0) putchar(' ');
        printf("%d", A[i]);
    }
    putchar('\n');
}


Measured memory_bytes: 2088
// Problem : 1%
// Contest : Virtual Judge - AtCoder
// URL : https://vjudge.net/problem/AtCoder-abc165_b
// Memory Limit : 1048 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testcases \
    int tcc;      \
    cin >> tcc;   \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    fast_io;
    ll n; cin>>n;
    ll x=100;
    int cnt=0;
    while(x<n){
    	x+=x/100;
    	cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 3604
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

//const int mod = 1000000007;
const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, s;
    cin >> n >> s;
    vector<mint> made(s);
    mint ans = 0;
    rep(i, n) {
        made[0] += 1;
        int a;
        cin >> a;
        if(a > s) continue;
        ans += made[s-a]*(n-i);
        for(int j = s-a-1; j >= 0; j--) {
            made[j+a] += made[j];
        }
    }

    cout << ans << endl;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    ll n,a,b;
    cin>>n>>a>>b;

    vl x(n);
    REP(i,n){
        cin>>x[i];
    }

    vl edges(n-1);
    FOR(i,1,n){
        edges[i-1] = (x[i]-x[i-1]) * a;
        chmin(edges[i-1], b);
    }

    ll ans = accumulate(ALL(edges), 0LL);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"

using namespace std;

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

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

    int n,k;cin>>n>>k;
    ll res = 5*1e18;
    vector<P> v;
    vector<ll> xp,yp;
    for(int i=0;i<n;i++){
        ll x,y;cin>>x>>y;
        v.push_back(P(x,y));
        xp.push_back(x);
        yp.push_back(y);
    }
    sort(xp.begin(),xp.end());
    sort(yp.begin(),yp.end());
    for(int sx=0;sx<n;sx++){
        for(int gx=sx+1;gx<n;gx++){
            for(int sy=0;sy<n;sy++){
                for(int gy=sy+1;gy<n;gy++){
                    int cnt=0;
                    for(int i=0;i<n;i++){
                        if(xp[sx]<=v[i].first && v[i].first<=xp[gx] && yp[sy]<=v[i].second && v[i].second<=yp[gy]) cnt++;
                    }
                    if(cnt<k) continue;
                    res=min(res,(yp[gy]-yp[sy])*(xp[gx]-xp[sx]));
                    //cout<<i<<" "<<j<<endl;
                }
            }
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
map=[['.' for _ in range(W+2)] for _ in range(H+2)]
for i in range(H):
    s=list(input())
    map[i+1]=['.']+s+['.']
for i in range(H):
    for j in range(W):
        if map[i+1][j+1]=='.':
            cnt=0
            if map[i][j+1]=='#':
                cnt+=1
            if map[i][j+2]=='#':
                cnt+=1
            if map[i+1][j+2]=='#':
                cnt+=1
            if map[i+2][j+2]=='#':
                cnt+=1
            if map[i+2][j+1]=='#':
                cnt+=1
            if map[i+2][j]=='#':
                cnt+=1
            if map[i+1][j]=='#':
                cnt+=1
            if map[i][j]=='#':
                cnt+=1
            map[i+1][j+1]=str(cnt)
for i in range(H):
    for j in range(W):
        print(map[i+1][j+1],end='')
    print()

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

int main(void)
{
  using namespace std;
  int X, A, B;
  cin >> X >> A >> B;
  if(B-A <= 0)
  {
    cout << "delicious\n";
  }
  else if(B-A > X)
  {
    cout << "dangerous\n";
  }
  else
  {
    cout << "safe\n";
  }
}


Measured memory_bytes: 256