akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
	int R[MAX], n;

	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++) cin >> R[i];

	int maxv = -2000000000;
	int minv = R[0];

	for (int i = 1; i < n; i++){
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;
	return 0;
}



Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

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


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int maxn = 3e5 + 5;
int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int ret =0 ;
    for(int i = 1; i < a; i ++){
        for(int j = 1; j <= month[i]; j ++){
            if(i == j)ret ++;
        }
    }
    for(int i = 1; i <= b; i ++){
        if(i == a)ret ++;
    }
    cout << ret << endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>

const int length = 10;

int main(){
    int n;
    std::cin >> n;
    long long cnt = 0;
    std::map<std::string, long long> mp;
    for(int i = 0; i < n; i++){
        std::string S;
        std::cin >> S;
        std::sort(S.begin(), S.end());
        mp[S]++;
    }

    for(auto m : mp){
        cnt += m.second * (m.second - 1) / 2;
    }

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


Measured memory_bytes: 11136
#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
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String concat = sc.next() + sc.next();
        long result = Math.round(Math.sqrt(Integer.parseInt(concat)));
        if (result * result == Integer.parseInt(concat)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int n,a,b;cin>>n>>a>>b;
    int ans=0;
    repi(i,1,n+1){
        string s=to_string(i);
        int tmp=0;
        rep(j,s.size())tmp+=s[j]-'0';
        if(tmp>=a&&tmp<=b)ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main (){
	int n;cin>>n;
	int a[100001];
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	int ma=a[0];
	for(int i=1;i<n;i++){
		ma=max(ma,a[i]);
		if(ma-a[i]>=2){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 640
n,m=map(int,input().split())
inf=float("inf")
l=[tuple(map(int,input().split())) for i in range(m)]
 
d=[inf]*n
d[0]=0

for i in range(n):
  for a,b,c in l:
    a,b,c=a-1,b-1,-c
    if d[a]!=inf and d[b]>d[a]+c:
      d[b]=d[a]+c
      if i==n-1 and b==n-1:
        print("inf")
        exit()
print(-d[-1])

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d){
    cout << "Left" << endl;
  }
  else if (a + b < c + d){
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

ll square_rep_mod(ll a,ll n,ll m){
    if(n==0) return 1;
    if(n%2==0){
        ll t = square_rep_mod(a,n/2,m);
        return t*t% m;
    }
    return a*square_rep_mod(a,n-1,m)%MOD;
}

ll calcPartialFractional_mod(ll n,ll k,ll mod) {
    if(n==k) return 1;
    else return calcPartialFractional_mod(n-1,k,mod)*n%mod;
}


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

    ll a_tmp = calcPartialFractional_mod(n, n-a, MOD)*square_rep_mod(calcPartialFractional_mod(a, 0, MOD), MOD-2, MOD)%MOD;
    ll b_tmp = calcPartialFractional_mod(n, n-b, MOD)*square_rep_mod(calcPartialFractional_mod(b, 0, MOD), MOD-2, MOD)%MOD;
    ll ans = (square_rep_mod(2, n, MOD) - a_tmp - b_tmp - 1)%MOD;
    while(ans<0) ans += MOD;
    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 6528
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, C, X, Y = map(int, readline().split())

ans = 10 ** 10
for c in range(2 * 10 ** 5 + 1):
    a = X - c // 2
    b = Y - c // 2
    if a < 0:
        a = 0
    if b < 0:
        b = 0
    ans = min(ans, A * a + B * b + C * c)
print(ans)





Measured memory_bytes: 71916
import java.util.*;

class Main{
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    ArrayList<Integer> list;
    ArrayList<Integer> list2;

    list = new ArrayList<>();
    list2 = new ArrayList<>();
    int pre = 1;
    int n = 1;
    while((pre = n*(n+1)*(n+2)/6)<1000000) {
      n++;
      if(pre%2==1) list.add(pre);
      list2.add(pre);
    }
    int input = 0;

    int[] dp2 = new int[1000001];
    int[] dp = new int[1000001];
    while((input=scan.nextInt())!=0) {
      System.out.print(calc(input,dp2,list2)+" ");
      System.out.println(calc(input,dp,list));
    }
  }

  static int calc(int sum, int[] dp, ArrayList<Integer> list) {
    if(sum==0) return 0;
    if(dp[sum]>0) return dp[sum];
    int max = 0;
    int count = 999999;
    int res = 0;
    for(int i = list.size()-1; i >= 0; i--) {
      max = list.get(i);
      if(max==sum) {
        res = 1;
        break;
      }
      if(max<sum) {
        res = 1 + calc(sum-max,dp,list);
        count = Math.min(res, count);
      }
    }
    count = Math.min(res, count);
    dp[sum] = count;
    return count;
  }
}

Measured memory_bytes: 34676
import Data.Char

f::String->Int->Int->Bool
f m a b=let c=sum (map digitToInt m)
        in a<=c && c<=b
  

main = do
       e<-getLine
       let (n:a:b:[])=map read (words e)::[Int]
       putStrLn $ show $ sum $ [m|m<-[1..n],f (show m) a b] 

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
#define fi first
#define se second
#define lc T[p].l
#define rc T[p].r
//#define mid (l+r>>1)
#define lson lc,l,mid
#define rson rc,mid+1,r
#define sum T[p].val
#define pii pair<int,int>
const int MX=2e6+7;
const int mod=998244353;
const double pi=3.1415926535897932384;
double isp=1e-13;
using namespace std;
ll qpow(ll a,ll b,ll MOD=mod){for(ll ans=1;;a=a*a%MOD,b>>=1){if(b&1)ans=ans*a%MOD;if(!b)return ans;}}
ll inv(ll a,ll MOD=mod){return qpow(a,MOD-2,MOD);}//要求MOD为质数
ll exgcd(ll a,ll b,ll &x,ll &y){if(b==0){x=1,y=0;return a;}ll ret=exgcd(b,a%b,y,x);y-=a/b*x;return ret;}
ll getInv(int a,int mod){ll x,y;ll d=exgcd(a,mod,x,y);return d==1?(x%mod+mod)%mod:-1;}//求a在mod下的逆元，不存在逆元返回-1，不要求MOD为质数
double A[MX];
int n;
bool check(int k,double l)
{
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        double res=A[i]/l;
        int t=res;
        if(res-t>isp)t++;
        t--;
        ans+=t;
    }
    if(ans<=k)return true;
    else return false;
}
void solve()
{
   int k;
   cin>>n>>k;
   double l=0,r=1e9;
   for(int i=1;i<=n;i++)
   {
       cin>>A[i];
   }
   double ans=0;
   while(r-l>1e-6)
   {
       double mid=(r+l)/2;
       if(check(k,mid))
       {
           ans=mid;
           r=mid;
       }
       else l=mid;
   }
  // cout<<ans<<endl;
   int x=ans+0.999999;

   cout<<x<<endl;
   return ;

}
int main()
{
  ios::sync_with_stdio(0),cin.tie(0);
  int t;
 // cin>>t;
  t=1;
  while(t--)
  {
      solve();
  }
}


Measured memory_bytes: 5252
#include "bits/stdc++.h"
using namespace std;
int dp[100001];
int main()
{
	for(int i = 1; i <= 100000; dp[i++] = 1 << 30){}
	int n, w;
	scanf("%d%d", &n, &w);
	for(int i = 0, j, k; i < n; ++i)
	{
		scanf("%d%d", &j, &k);
		for(int l = 100000 - k; l >= 0; --l)
		{
			if(dp[l] + j <= w)
			{
				dp[l + k] = min(dp[l + k], dp[l] + j);
			}
		}
	}
	for(int i = 100000; ; --i)
	{
		if(dp[i] <= w)
		{
			printf("%d\n", i);
			return 0;
		}
	}
}

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

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N);
	for (ll i = 0; i < N; ++i) cin >> A[i];

	ll sum{0}, r{0}, res{0};

	for (ll l = 0; l < N; ++l)
	{
		while (r < N && (sum + A[r] == (sum ^ A[r])))
		{
			sum += A[r];
			++r;
		}
		res += r - l;

		if (r == l) ++r;
		else sum -= A[l];
	}
	std::cout << res << std::endl;
}

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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=12;
ll m,n;
string s,t;
ll dp[12][N][2][2];
//code for all the nummbers divisible by m
ll digitdp(ll zero,ll last,ll idx,ll lt,ll rt){ // lt=0(fixed) lt=1(free)
    if(idx==n) return 1;
    if(dp[last][idx][lt][rt]!=-1) return dp[last][idx][lt][rt];
    ll &curr=dp[last][idx][lt][rt];
    curr=0;
    ll mi=0,mx=9;
    if(!lt) mi=s[idx]-'0';
    if(!rt) mx=t[idx]-'0';
    rep(i,mi,mx){
        ll nlt=(lt|(i>s[idx]-'0'));
        ll nrt=(rt|(i<t[idx]-'0'));
        if(idx>=1){
            if(abs(last-i)<=1 || (zero==idx)) {
               if(i!=0) curr=(curr+digitdp(zero,i,idx+1,nlt,nrt));
               else curr=(curr+digitdp(zero+1,i,idx+1,nlt,nrt));
            }
        }
        else {
            if(i!=0)
            curr=(curr+digitdp(zero,i,idx+1,nlt,nrt));
        else curr=(curr+digitdp(zero+1,i,idx+1,nlt,nrt));
        }
    }
    return curr;
}
ll check(ll num){
    s="";
    t="";
    while(num!=0){
        t.pb((char)(num%10+'0'));
        s.pb('0');
        num/=10;
    }
    reverse(all(t));
    // cout<<s<<" "<<t<<endl;
    n=sz(t);
    // cout<<n<<" ";
    memset(dp,-1,sizeof(dp));
    ll fin=digitdp(0,0,0,0,0);
    // cout<<fin<<endl;
    return fin-1;
}
void solve(){
    ll k;
    cin>>k;
    ll lo=1,hi=3234566667;
    ll ans=-1;
    while(lo<=hi){
        ll mid=(lo+hi)/2;
        // cout<<mid<<endl;
        if(check(mid)>=k){
            ans=mid;
            hi=mid-1;
        }
        else lo=mid+1;
    }
    // cout<<check(32)<<endl;
    cout<<ans;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 N PICTURE 99999.
       01 K PICTURE 99999.
       01 X PICTURE 99999.
       01 Y picture 99999.
       01 REN PICTURE 9(20).
       01 RE PIC Z(20).
       PROCEDURE DIVISION.
       MAIN.
        ACCEPT N.
        ACCEPT K.
        ACCEPT X.
        ACCEPT Y.
        IF N<=K THEN
         COMPUTE REN=X*N
        ELSE 
         COMPUTE REN=X*K
         COMPUTE N=N - K
         COMPUTE REN=REN+N*Y
        END-IF.
        MOVE REN TO RE.
        DISPLAY RE.
      	STOP RUN.

Measured memory_bytes: 384
#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>;

int main(){
    int N; cin >> N;
    vector<int> stocks(N);
    vector<int> action(N); // 0 Nothing, 1 buy, 2 sell
    rep(i, N){
        cin >> stocks[i];
    }
    bool up = false;
    rep(i, N-1){
        if(stocks[i] < stocks[i+1]){ // up
            if(!up){
                action[i] = 1;
                up = true;
            }
        }else if(stocks[i] > stocks[i+1]){ // down
            if(up){
                action[i] = 2;
                up = false;
            }
        }
    }
    action[N-1] = 2;

    ll money = 1000;
    ll stk = 0;
    rep(i, N){
        if(action[i] == 1){
            stk = money / stocks[i];
            money = money % stocks[i];
        }
        if(action[i] == 2){
            money = stk * stocks[i] + money;
            stk = 0;
        }
        //cout << action[i] << " money: " << money << " stk: " << stk << endl;
    }
    cout << money << endl;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int[] intArray;
		intArray = new int[x];
		int temp = 0;
		int total = 0;
		for(int i = 0; i < x; i++){
			intArray[i] = sc.nextInt();
		}
		for (int i = 0; i < x; i++) {
			for (int j = 1; j < x; j++) {
				if(intArray[i] < intArray[j]) {
					temp = intArray[i];
					intArray[i] = intArray[j];
					intArray[j] = temp;
				}
			}
		}
		for(int i = 0; i < x; i++){
			if(i == 0){
				total = total + intArray[i] / 2; 
			} else{
				total = total + intArray[i];
			}
		}
		System.out.println(total);
	}
}

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

int main() {
  int a, b, t;
  cin >> a >> b >> t;

  int n     = 0;
  int index = 1;
  int res   = 0;
  while ((t + 0.5) > n) {
    n += a;
    if ((t + 0.5) < n) break;
    res += b;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import itertools
# math.factorial()

N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))
V = [i for i in range(1,N+1)]

cnt_p = 0
cnt_q = 0
cnt = 0

for v in itertools.permutations(V, N):
    cnt += 1
    if P == v:
        cnt_p = cnt
    if Q == v:
        cnt_q = cnt

print(abs(cnt_p - cnt_q))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define INF 0x3f3f3f3f 
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i , a , b) for(int i = a ; i <= b ; i ++)
#define P pair<int,int>
#define  sc(a) scanf("%d",&a)
#define pf(a) printf("%d ",a)
using namespace std;
signed main()
{
	ll a, b, c;
	c = 0;
	b = 1;
	cin >> a;
	while (a)
	{
		c += b;
		b *= 2;
		a = a / 2;
	}c += a;
	cout << c;
}











Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef pair<int,int> pair;
#define F first
#define S second
#define pb push_back
#define PB pop_back
#define MP make_pair
#define rep(i,a,b) for (i = a; i < b; i++)
bool isPrime(int n) 
{ 
    
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
ll binaryToDecimal(ll n) 
{ 
    ll num = n; 
    ll dec_value = 0; 
  
    
    ll base = 1; 
  
    ll temp = num; 
    while (temp) { 
        ll last_digit = temp % 10; 
        temp = temp / 10; 
  
        dec_value += last_digit * base; 
  
        base = base * 2; 
    } 
  
    return dec_value; 
}    

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
	
	 int n;
	 cin>>n;
	 string s,t;
	 cin>>s>>t;
	 for(int i=0;i<n;i++){
	 	cout<<s[i]<<t[i];
	 }
	 return 0;
	}

Measured memory_bytes: 256
#include <stdio.h>
int getSecondsStandard(int h,int m, int s){
	return (120 * 60 -( h * 3600 + m * 60 + s));

}
int getSecondsThreeTimes(int h,int m, int s){
	return (120 * 60 - (h * 3600 + m * 60 + s)) * 3;

}
void printTime(int sec){
	int h = sec / 3600;
	int m = sec % 3600 / 60;
	int s = sec % 60;
	if(h < 10){putchar('0');}
	printf("%d:",h);
	if(m < 10){putchar('0');}
	printf("%d:",m);
	if(s < 10){putchar('0');}
	printf("%d\n",s);

} 
int main(void){
	int h,m,s;
	while(1){
		scanf("%d%d%d",&h,&m,&s);
		if(h == -1 && m == -1 && s == -1){
			break;
		}
		printTime(getSecondsStandard(h,m,s));
		printTime(getSecondsThreeTimes(h,m,s));
	}
	return 0;
}

Measured memory_bytes: 0
n = list(input())
if n[-1] == '3':
    print('bon')
elif n[-1] == '0':
    print('pon')
elif n[-1] == '1':
    print('pon')
elif n[-1] == '6':
    print('pon')
elif n[-1] == '8':
    print('pon')
else:
    print('hon')





Measured memory_bytes: 9112
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
    int H, W, D;
    cin >> H >> W >> D;
    string dic = "RYGB";
    for(int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << dic[((i + j) / D) % 2 + (((i - j + 1000 * D) / D) % 2) * 2];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define M 100

int count=0;

void bubbleSort(int *A,int N){

  int y,i,j,flag = 1;
  
  while(flag==1){
    flag=0;
    for(j=N-1;j>0;j--){
      if(A[j] < A[j-1]){
	y = A[j];
	A[j] = A[j-1];
	A[j-1] = y;
	flag = 1;
	count++;
      }
    }
  }
    
  for(i=0;i<N;i++){
    if(i==N-1) printf("%d",A[i]);
    else printf("%d ",A[i]);
  }
  printf("\n");
  printf("%d\n",count);

}

int main(){
  
  int x,i,j,A[M],B[M];

  scanf("%d",&x);

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

  bubbleSort(A,x);


  return 0;
}

  



Measured memory_bytes: 2124
#include <stdio.h>
int main(){
    int m,f,r;
    
    while(1)
    {
        scanf("%d%d%d",&m,&f,&r);
        if(m==-1&&f==-1&&r==-1)
            break;
        else if(m==-1||f==-1)
            printf("F\n");
        else if(m+f>=80)
            printf("A\n");
        else if(m+f>=65&&m+f<80)
            printf("B\n");
        else if(m+f>=50&&m+f<65)
            printf("C\n");
        else if(m+f>=30&&m+f<50){
            if(r>=50)
                printf("C\n");
            else
                printf("D\n");
        }
        else if(m+f<30)
            printf("F\n");
        
        
    }
    
}



Measured memory_bytes: 2124
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&k)

	if a > k {
		a = a - k
	} else {
		if (a + b - k) > 0 {
			b = a + b - k
			a = 0
		} else {
			a = 0
			b = 0
		}
	}
	fmt.Println(a)
	fmt.Println(b)

}


Measured memory_bytes: 512
#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++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__);
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////

int32_t main() {
    string s; cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i += 2) {
        if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') quit("No");
    }
    for (int i = 1; i < n; i += 2) {
        if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') quit("No");
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

int main(void)
{
	int N;
	std::cin >> N;
   
  double price = 0;
  for(int i = 0; i < N; i++)
  {
    double x;
    std::string u;
    std::cin >> x >> u;
    price += (u == "JPY") ? x : x * 380000;
  }
  std::cout << price;
}


Measured memory_bytes: 256
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	string s;
	cin >> s;

	ll ans = 0;
	int A = 0;
	for (int i=0; i < (int)s.size() - 2; i++) {
		if (s[i] == 'A') A++;
		else A = 0;

		if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
			ans += A;
			s[i] = 'B';
			s[i+1] = 'C';
			s[i+2] = 'A';
			if (A >= 2) {
				A = A - 2;
				s[i+1] = 'A';
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int N,Q; string s;
char t[200020],d[200020];
int check(int x){
    for (int i = 0; i < Q; i++){
        if (s[x] == t[i]){
            if (d[i] == 'R') x++;
            else x--;
        }
        if (x == -1) return -1;
        if (x == N) return 1;
    }
    return 0;
}

int main(){
    cin >> N >> Q;
    cin >> s;
    
    for (int i = 0; i < Q; i++){
        cin >> t[i] >> d[i];
    }
    int l = -1,r = N,mid;
    while (l < r-1){
        mid = (l+r)/2;
        if (check(mid) == -1){
            l = mid;
        } else {
            r = mid;
        }
    }
    int ch1 = l;
    l = -1,r = N;
    while (l < r-1){
        mid = (l+r)/2;
        if (check(mid) == 1) r = mid;
        else l = mid;
    }
    cout << r - ch1 - 1 << endl;

    //check L
}

Measured memory_bytes: 900
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
int n;
cin>>n;
int s[n];
int sum=0;
REP(i, n) {
  cin>>s[i];
  sum += s[i];
}
if(sum%10!=0){
  cout<<sum<<endl;
  return 0;
}
sort(s, s+n);
REP(i, n){
  if(s[i]%10==0) continue;
  cout << sum-s[i] << endl;
  return 0;
}

cout<<0<<endl;


  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
alis = sorted(list(map(int,input().split())))
BC = []
clis = []

for x in range(m):
    b,c = map(int,input().split())
    BC.append((b,c))
BC = sorted(BC,reverse=True,key=lambda x:x[1])
bk_flg = 1
for b,c in BC:
    for x in range(b):
        if len(clis) > n:
            bk_flg = 0
            break
        clis.append(c)
    if bk_flg == 0:break;

for i in range(min(len(clis),n)):
    if alis[i] < clis[i]:
        alis[i] = clis[i]
print(sum(alis))


Measured memory_bytes: 23260
#include<cmath>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxs 4000005

int n,sum;
bitset<maxs> f;

inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read(); f[0]=1;
	for (int i=1,x;i<=n;i++) f|=f<<(x=read()),sum+=x;
	for (int i=(sum+1)>>1;;i++) if (f[i]){cout<<i<<endl; return 0;}
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
const int N=1e7+5;
bool cmp(int x,int y){
	return x>y;
}
int a[N]; 
int main()
{
	int n,k,l=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	} 
	sort(a,a+n+1,cmp);
	for(int i=0;i<k;i++) l+=a[i];
	cout<<l;
	return  0;
}


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

int main(){
  vector<int> A={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin>>K;
  cout<<A.at(K-1)<<endl;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{

  int a, b,k;
  cin >> a >> b>>k;
  int count = 0;
  for (int i = min(a,b); i>=1; i--)
  {
    if(a%i==0&&b%i==0)count++;
    if(count==k){
      cout << i << endl;
      break;

    }
  }

    return 0;
}


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

int main()
{
   string s,t;
   cin >> s >> t;
   bool ok = false;
   for(int i = s.size() -t.size(); i >= 0 ; i--)
   {
      if(s[i] == '?' || s[i] == t[0])
      {
         ok = true;
         rep(j,t.size())
         {
            if(s[i + j] == t[j] || s[i + j] == '?') continue;
            else ok = false;
         }
         if(ok) 
         {
            rep(j,t.size()) s[i + j] = t[j]; 
            break;
         }
      }
   }
   if(!ok) {
      cout << "UNRESTORABLE" << endl;
      return 0;
   }
   rep(i,s.size()){
      if(s[i] == '?') s[i] ='a';
   }
   cout << s << endl;
}

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

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int           ll;
typedef unsigned long long int  llu;

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

    ll p = __gcd(a,b);

    cout << (a*b)/p << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n , k;
cin>>n>>k;
map<int , int> m;
while(k--){
  int sz;
  cin>>sz;
  for(int i = 0 ; i < sz ; i++){
   int x;
   cin>>x;
   m[x]++;
  }
}
cout<<n-m.size()<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define rep(i,n) for(int i=0;i<n;i++)
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n,w;
int a[110],b[110];
int dp[110][100010];
signed main(){
	cin>>n>>w;
	rep(i,n)cin>>a[i]>>b[i];
	rep(i,n+1){
		rep(j,100010)dp[i][j]=INF;
	}
	dp[0][0]=0;
	rep(i,n){
		rep(j,100010){
			dp[i+1][j+b[i]]=min(dp[i+1][j+b[i]],dp[i][j]+a[i]);
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
		}
	}
	int ans=0;
	rep(i,n+1){
		rep(j,100010){
			if(dp[i][j]<=w)ans=max(ans,j);
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 80128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

long long cnt;

void print(vector<int> &data){
	for (int i = 0; i < data.size(); ++i){
		cout << data[i] << endl;
	}
}

void insertSort(vector<int> &data, int d){
	int n = data.size();
	for (int i = d; i < n; ++i) {
		int v = data[i];
		int j = i - d;
		while (j >= 0 && data[j] > v) {
			data[j + d] = data[j];
			j -= d;
			cnt++;
		}
		data[j + d] = v;
	}
}

void shellSort(vector<int> &data){
	vector<int> dist;
	for (int i = 1; i <= data.size(); i = 3 * i + 1)
		dist.push_back(i);

	int n = dist.size();
	cout << n << endl;

	for (int i = n - 1; i >= 0; --i)
	{
		insertSort(data, dist[i]);
		cout << dist[i];
		if (i != 0) cout << " ";
		else cout << endl;
	}
	cout << cnt << endl;
	print(data);
}


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

	shellSort(data);

	return 0;
}

Measured memory_bytes: 6668
#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>
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 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;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
vector<P> v[600000];
int hum[200000];
int seat[200000];
int main() {
	priority_queue<P, vector<P>, greater<P>> q;
	int n, m; cin >> n >> m;
	rep(i, n) {
		int l, r; cin >> l >> r; l--; r--;
		v[r].push_back({ m + l,i });
		v[r + m].push_back({ 2 * m + l,i });
		if(l>=0)q.push({ l,i });
	}
	fill(hum, hum + n, -1);
	rep(i, 3 * m) {
		int len = v[i].size();
		rep(j, len) {
			q.push(v[i][j]);
		}
		if (seat[i%m])continue;
		while(!q.empty()){
			P x = q.top(); q.pop();
			int y = x.second;
			if (i > x.first)continue;
			int z = x.first%m;
			if (hum[y] >= 0) {
				if ((i%m > z&&(i%m < hum[y] || hum[y] <= z+m)) || (i%m <= z && i%m < hum[y] && hum[y] <= z)) {
					seat[hum[y]] = 0;
					hum[y] = i % m;
					seat[hum[y]] = 1;
				}
				else continue;
			}
			else {
				hum[y] = i % m;
				seat[i%m] = 1;
			}
			break;
		}
	}
	int out = 0;
	rep(i, m) {
		if (seat[i]) {
			out++;
		}
	}
	cout << n-out << endl;
	return 0;
}

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <math.h>

int main() {

    string s;
    cin >> s;

    for ( long long int i = 0; i < s.size(); i++ ) {
        if ( s[i] != '?' ) continue;
        s[i] = 'D';
    }

    cout << s << endl;

    return 0;

}


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

using namespace std;

#define ll long long

signed main() {
	int n; cin >> n;
	string s; cin >> s;
	for (int i = 0; i < s.length(); ++i)
		s[i] = (char)((s[i] - 'A' + n) % 26 + 'A');
	cout << s << endl;
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

const int N = 321;
const int inf = 2e9;

long long a[N][N];
bool important[N][N];

void solve() {
	int n; scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			scanf("%lld", a[i]+j);
			important[i][j] = 1;
		}
	}
	long long sum = 0;
	for (int k = 0; k < n; ++k) {
		for (int i = 0; i < n; ++i) {
			if (i == k) continue;
			for (int j = 0; j < n; ++j) {
				if (j == i || j == k) continue;
				if (a[i][j] > a[i][k]+a[k][j]) {
					printf("-1");
					return;
				}
				if (a[k][i] == a[k][j]+a[j][i]) important[k][i] = 0;
			}
			if (important[k][i]) sum += a[k][i];
		}
	}

	printf("%lld", sum/2);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
int main(void){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a==5&&b==7&&c==5||a==7&&b==5&&c==5||a==5&&b==5&&c==7)
puts("YES");
else puts("NO");
return(0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);    
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    if ('a' <= s1[0] && s1[0] <= 'z')
        cout << char(s1[0] + 'A' - 'a');
    else
        cout << s1[0];
    if ('a' <= s2[0] && s2[0] <= 'z')
        cout << char(s2[0] + 'A' - 'a');
    else
        cout << s2[0];
    if ('a' <= s3[0] && s3[0] <= 'z')
        cout << char(s3[0] + 'A' - 'a');
    else
        cout << s3[0];                
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#define STACK_SIZE 100

int stack[STACK_SIZE];
int sp;

void
stack_push(int a)
{
	stack[sp++] = a;
}

void
stack_pop()
{
	sp--;
}

int
stack_front()
{
	return stack[sp - 1];
}

int
main(int argc, char** argv)
{
	int n;
	int i;

	sp = 0;
	while (scanf("%d", &n) != EOF)
	{
		if (n == 0)
		{
			i = stack_front(); stack_pop();
			printf("%d\n", i);
		}
		else
			stack_push(n);
	}

	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;



public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = Integer.parseInt(sc.nextLine());
		String s = sc.nextLine();
		if(i < s.length()) {
			System.out.println(s.substring(0,i) + "...");
		}else {

			System.out.println(s);
		}

	}
}


Measured memory_bytes: 38488
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}
ll pw(ll a , ll b)  { return (!b ? 1 : (b & 1 ? a * pw(a * a , b / 2) : pw(a * a , b / 2))); }

const int MAXN = 1e6 + 10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e18;

ll v[MAXN];

ll dp[MAXN];

ll Abs(ll x){
    if(x < 0)return - x;
    return x;
}

int main(){
    fast_io;
    //cout << fixed << setprecision(15);
    //scanf("%d %d %f %lld %s %c", &x);
    //printf("%d %d %f %lld %s %c", x);
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> v[i];
    }
    dp[1] = 0;
    for(ll i = 2; i <= n; i++){
        ll ANS = 1e18;
        for(ll j = max(i - k, 1ll); j < i; j++){
            ANS = min(ANS, dp[j] + Abs(v[i] - v[j]));
        }
        dp[i] = ANS;
    }
    cout << dp[n];
    return 0;
}




Measured memory_bytes: 5120
#include <iostream>
using namespace std;
int main(){
	int a[10];
	for(int i=0;i<10;i++){
		cin>>a[i];
	}
	for(int s=0;s<10-1;s++){
		for(int t=s+1;t<10;t++){
			if(a[t]>a[s]){
				int p=a[t];
				a[t]=a[s];
				a[s]=p;
			}
		}
	}
	for(int j=0;j<3;j++){
		cout<<a[j]<<endl;
	}
}

Measured memory_bytes: 1160
mod=10**9+7
l,a,b=map(int,input().split())
def C(n,k,m):
  g=k
  f=n
  for i in range(1,k):
    n=n*(f-i)%m
    k=k*(g-i)%m
  return (n*pow(k,m-2,m))%m
ans=pow(2,l,mod)-1
ca=C(l,a,mod)
cb=C(l,b,mod)
print((ans-ca-cb)%mod)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){

    char b;
    scanf("%c",&b);

    if(b == 'A'){
        printf("T\n");
    } else if(b == 'T'){
        printf("A\n");
    } else if(b == 'C'){
        printf("G\n");
    } else if(b == 'G'){
        printf("C\n");
    }

    return 0;

}

Measured memory_bytes: 128
#include <stdio.h>

int	main(void)
{
	int x = 0;
	int y = 0;
	int z = 0;
	int i = 0;
	int j;
	int n, yen;
	scanf("%d%d",&n, &yen);
	// if (n * 1000 == yen)
	// {
	// 	printf("%d %d %d\n", x, y, n);
	// 	return (0);
	// }
	// else if (n * 5000 == yen)
	// {
	// 	printf("%d %d %d\n", x, n, z);
	// 	return (0);
	// }
	// else if (n * 10000 == yen)
	// {
	// 	printf("%d %d %d\n", n, y, z);
	// 	return (0);
	// }
	while (i <= n)
	{
		j = 0;
		while (j <= n)
		{
			if ((yen - ((10000*i) + (5000*j)) == (n-(i+j)) * 1000) && (n-(i+j)) >= 0)
			{
				x = i;
				y = j;
				z = n - (i+j);
				break ;
			}
			j++;
		}
		i++;
	}
	if (x + y + z != n)
	{
		x = -1;
		y = -1;
		z = -1;
		printf("%d %d %d\n", x, y, z);
	}
	if (x + y + z == n)
		printf("%d %d %d\n", x, y, z);
	return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int n,tmp=0,cnt=0;
    cin >> n;
    if(n==1){
        cnt++;
    }
    else{
        int a[n];
        for(int i=0;i<n;i++){
            cin >> a[i];
        }
        sort(a,a+n);
        for(int i=1;i<n;i++){
            if(a[i-1]==a[i]){
                tmp++;
            }
            else{
                if(tmp%2==0){
                    cnt++;
                }
                tmp=0;
            }
            if(i==n-1){
                if(tmp%2==0){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int main()
{
    int A, B;
    if (scanf("%d%d", &A, &B) < 2) return 0;

    printf("%d\n", A + B >= 24 ? A + B - 24 : A + B);
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<queue>
using namespace std;
typedef long long LL;
priority_queue<int> Q2;
priority_queue<int,vector<int>,greater<int> > Q1;
int main()
{
	int N;LL opop=0,q1=0,q2=0;scanf("%d",&N);
	for(int i=1;i<=N;++i)
	{
		int a;scanf("%d",&a);
		if(a&1)
		{
			int b,c;scanf("%d%d",&b,&c);
			opop+=c;
			if(Q2.empty()||b<Q2.top()) Q2.push(b),q2+=b;
			else Q1.push(b),q1+=b;
			if(Q2.size()<Q1.size()) Q2.push(Q1.top()),q2+=Q1.top(),q1-=Q1.top(),Q1.pop();
			else if(Q2.size()==Q1.size()+2) Q1.push(Q2.top()),q1+=Q2.top(),q2-=Q2.top(),Q2.pop();
		}
		else
		{
			printf("%d %lld\n",Q2.top(),opop+q1-q2+(Q2.size()>Q1.size())*Q2.top());
		}
	}
	return 0;
}

Measured memory_bytes: 3452
#include<cstdio>
using namespace std;
int min(int a,int b){return(a < b)?a:b;}
int main(){
	int n;
	scanf("%d",&n);
	int num = 99999,fish = 0;
	for(int i = 0; i < n; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		if(fish <= y){
			if(fish == y)num = min(num,x);
			else num = x;
			fish = y;
		}
	}
	printf("%d %d\n",num,fish);
	return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int scale = sc.nextInt();

		double[] num = new double[scale];

		String[] letter = new String[scale];

		double answer =0;

		for(int i=0; i<scale; i++) {
			num[i] = sc.nextDouble();
			letter[i] = sc.next();
		}

		for(int i=0; i<scale; i++) {
			if(letter[i] .equals( "JPY")) answer = answer + num[i];
			else if(letter[i] .equals( "BTC")) answer = answer + num[i]*380000.0;


		}

		System.out.print(answer);
	}

}


Measured memory_bytes: 23252
ns = gets.chomp.split(//).map(&:to_i)
a = []
t = []
prev = nil
ns.each_with_index do |n, i|
  if i == 0
    prev = n
    t << prev
    next
  end
  if prev == n
    t << n
    prev = n
  else
    a << t
    t = []
    prev = n
    t << prev
  end
end
a << t

counts = a.map(&:count)
puts(counts.any? { |e| e >= 3 } ? 'Yes' : 'No')

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

int main(void){
  int n,k;cin >> n >> k;
  string s; cin >> s;
  if(s.at(k-1) == 'A') s.at(k-1) = 'a';
  else if(s.at(k-1) == 'B') s.at(k-1) ='b';
  else s.at(k-1) = 'c';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256