akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A = N%1110;
  int B = N%1000;
  if(A <= 10){
    cout << "Yes" <<endl;
  }
  else if(B%111 == 0){
        cout << "Yes" <<endl;
  }
  else{
        cout << "No" <<endl;
  }
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 n, a[101];
void solve(){
	cin >> n;
	i64 sum = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	
	i64 ans = 0;
	bool b = 1;
	while(b){
		b = 0;
		for(int i = 0; i < n; i++){
			i64 c = a[i]/n;
			if(!b) b = c;
			a[i] %= n;
			ans += c;
			for(int j = 0; j < n; j++){
				if(i == j) continue;
				a[j] += c;
			}
		}
	}
	
	cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    map<ll, ll> mp;
    REP(i,N){
        int a, b;
        cin >> a >> b;
        mp[a] += b;
    }
    ll cnt = 0;
    for(auto x : mp){
        cnt += x.second;
        if(cnt >= K){
            cout << x.first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4224
if __name__ == "__main__":
	N,W = map(int,input().split(" "))
	dp = [[0] * (W+1) for _ in range(N+1)]

	w_lis = [0] * N
	v_lis = [0] * N

	for i in range(N):
		v,w = map(int,input().split(" "))
		w_lis[i] = w
		v_lis[i] = v



	for i in range(1,N+1):
		for w in range(0,W+1):
			if w >= w_lis[i-1]:
				dp[i][w] = max([dp[i-1][w - w_lis[i-1]] + v_lis[i-1],dp[i-1][w]])

			else:
				dp[i][w] = dp[i-1][w]


	print(dp[N][W])

Measured memory_bytes: 41892
n,q = map(int,input().split())
s = input()

array = [0]*len(s)

for i in range(1,len(s)):
  if( s[i-1:i+1] == "AC" ):
    array[i] = array[i-1] + 1
  else:
    array[i] = array[i-1]
      

for i in range(q):
  l,r = map(int,input().split())
  l -= 1
  r -= 1
  ans = array[r] - array[l]
  print(ans)

 

Measured memory_bytes: 77072
H,W=map(int,input().split())
 
M=[[c%2==1 for c in map(int,input().split())] for i in range(H)]
 
LIST=[]
 
for i in range(H):
    for j in range(W):
        if M[i][j]:
            if j < W-1:
                LIST.append((i+1,j+1,i+1,j+2))
                M[i][j+1] ^= True
            elif i < H-1:
                LIST.append((i+1,j+1,i+2,j+1))
                M[i+1][j] ^= True
                
print(len(LIST))
 
for c in LIST:
    print(*c)

Measured memory_bytes: 26592
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#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 rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{
  ll a,b,n;
  cin>>a>>b>>n;
  cout<<a*min(b-1,n)/b<<endl;
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/
 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

Measured memory_bytes: 3800
n, m = map(int, input().split())
*a, = map(int, input().split())

b = 0
c = {0: 1}
cnt = 0
for a in a:
    b = (b + a) % m
    cnt += c.get(b, 0)
    c[b] = c.get(b, 0) + 1
print(cnt)

Measured memory_bytes: 62576
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
string s1,s2;
inline bool reversed(){int sx((s1.length()/2)-1);for(register int i(0);i<=sx;i++){swap(s1[i],s1[s1.length()-i-1]);}return (s1!=s2);}
inline void check(){puts(((s1.length()-s2.length())?("NO"):((reversed())?("NO"):("YES"))));return;}
int main()
{
	cin>>s1>>s2;
	check();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=200005;
int n,a[N];
map <int,int> Map;
int main(){
	n=read();
	for (int i=1;i<=n;i++)
		a[i]=read();
	sort(a+1,a+n+1);
	Map.clear();
	for (int i=1;i<=n;i++)
		Map[a[i]]++;
	int ans=0;
	for (int i=n;i>=1;i--){
		if (Map[a[i]]>0){
			for (int t=1;t<=30;t++){
				if (Map[(1<<t)-a[i]]>0){
					if ((1<<t)-a[i]==a[i]&&Map[a[i]]<2)
						continue;
					Map[a[i]]--;
					Map[(1<<t)-a[i]]--;
					ans++;
					break;
				}
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 290816
n = list(map(str, input().split()))
n = n[0]
#print(n)
rls = [[0,0]]
flag = 2

for i in range(len(n)):
    #print(rls)
    if(flag == 2 and n[i]=='R'):
        rls[-1][0]+=1
    elif(flag == 2 and n[i]=='L'):
        flag = 1
        rls[-1][1]+=1
    elif(flag == 1 and n[i]=='R'):
        flag = 2
        rls.append([1,0])
    elif(flag == 1 and n[i]=='L'):
        rls[-1][1]+=1


prev = 0
ans = [0 for j in range(len(n))]
#print(len(rls))
for i in range(len(rls)):
    temp = rls[i]
    right = temp[0]//2 + temp[1]//2 + temp[1]%2
    left = temp[1]//2 + temp[0]//2 + temp[0]%2
    ans[prev+temp[0]-1]=left
    ans[prev+temp[0]]=right
    prev += temp[0]+temp[1]
#print(rls)

print(' '.join(map(str, ans)))

Measured memory_bytes: 55604
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#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);

    ll n, k;
    cin>>n>>k;
    vector<ll> h(n+110, 0);
    vector<ll> dp(n+110, LL_MAX);
    
    rep(i,0,n) cin>>h[i]; 

    dp[0] = 0;

    rep(i,0,n-1)
    {
        rep(j,1,k+1)
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
    }

    //rep(i,0,n) cout << dp[i] << endl; 

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1792
import sys
import numpy as np 

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n = I[0]
f = I[1:1+10*n].reshape(n, 10)
p = I[1+10*n:].reshape(n, 11)

def main():
    schedules = np.arange(1, 2**10)[:, None] >> np.arange(10) & 1

    res = f & schedules[:, None]
    res = np.sum(res, axis=2)

    res = p[np.arange(n), res]
    res = np.sum(res, axis=1)

    ans = np.amax(res)
    return ans
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 21480
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void){
  int a,b,c;
  
  scanf("%d %d %d",&a,&b,&c);
  
  if(a+b==c||abs(a-b)==c){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

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

        int n = sc.nextInt();
        String[] S = new String[n];
        for (int i = 0; i < S.length; ++i) {
            S[i] = sc.next();
        }

        System.out.println(solve(S));

        sc.close();
    }

    static String solve(String[] S) {
        int[] counts = new int[26];
        Arrays.fill(counts, Integer.MAX_VALUE);

        for (String Si : S) {
            int[] c = new int[26];
            for (char ch : Si.toCharArray()) {
                ++c[ch - 'a'];
            }

            for (int i = 0; i < counts.length; ++i) {
                counts[i] = Math.min(counts[i], c[i]);
            }
        }

        StringBuilder result = new StringBuilder();
        for (int i = 0; i < counts.length; ++i) {
            for (int j = 0; j < counts[i]; ++j) {
                result.append((char) ('a' + i));
            }
        }

        return result.toString();
    }
}

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

int main() 
{
	unsigned long long h,t=0,c=1,c0=1;
	cin>>h;
	
	if(h/2==0)
	{
		cout<<"1";
		return 0;
	}
	
	while(h/2!=0)
	{
		h=h/2;
		//cout<<h<<endl;
		if(c0==1)
		{
			NULL;
		}
		else
		{

			c=c+c0;
		}
		c0=c0*2;
		//cout<<"c="<<c<<endl;
		//cout<<"c0="<<c0<<endl;
		
	}

	t=c0+c;
	cout<<t;
	
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, M;
  cin >> N >> M;
  map<int,int> cnt;
  rep(i,N){
    int K;
    cin >> K;
    rep(j,K){
      int a;
      cin >> a;
      cnt[a]++;
    }
  }

  int ret = 0;
  FOR(it,cnt){
    if(it->second == N) ret++;
  }

  cout << ret << endl;
  
  return 0;
}



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

int main() {
    int N; cin >> N;
    vector<int64_t> A(N), B(N);
    for(int i = 0; i < N; ++i) cin >> A[i] >> B[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    int l = N / 2 - 1, r = l + 1;
    if(N % 2 == 0) {
        for(int i = 0; i < N; ++i) {
            A[i] *= 2, B[i] *= 2;
        }
        int64_t mn = (A[l] + A[r]) / 2;
        int64_t mx = (B[l] + B[r]) / 2;
        cout << mx - mn + 1 << '\n';
    } else {
        int64_t m = (N + 1) / 2 - 1;
        cout << B[m] - A[m] + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 6360
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		for (int i = 0; i < 3; i++) {
			int h1 = scanner.nextInt();
			int m1 = scanner.nextInt();
			int s1 = scanner.nextInt();
			int h2 = scanner.nextInt();
			int m2 = scanner.nextInt();
			int s2 = scanner.nextInt();

			int hms1 = h1 * 3600 + m1 * 60 + s1;
			int hms2 = h2 * 3600 + m2 * 60 + s2;
			int ans = hms2 - hms1;
			int h = ans / 3600;
			int m = ans / 60 % 60;
			int s = ans % 60;
			System.out.println(h + " " + m + " " + s);
		}
	}
}

Measured memory_bytes: 17172
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m = map(int,input().split())
H = list(map(int,input().split()))
good = [True] * n
for i in range(m):
  a,b = map(int,input().split())
  a-=1;b-=1
  if H[a] >= H[b]:
    good[b] = False
  if H[b] >= H[a]:
    good[a] = False
for gi in good:
  if gi:
    ans += 1
print(ans)

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

bool a[100000];
int n, m, cnt = 0;

int dfs(int k) {
	if (k >= n - 1) {
		if (a[k - n + 1])return -1;
		return k - n + 1;
	}
	int l = dfs(k * 2 + 1), r = dfs(k * 2 + 2);
	if (l == -1 && r == -1)return -1;
	if (l == -1)return r;
	if (r == -1)return l;
	cnt++; return l;
}
int main(){
	scanf("%d%d", &n, &m);
	rep(i, m) {
		int b; scanf("%d", &b);
		a[b] = 1;
	}
	dfs(0);
	printf("%d\n", cnt);
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define x first
#define y second

int main()
{
	ios_base::sync_with_stdio(0);
	int x;
	cin >> x;
	cout << (x / 500) * 1000 + ((x % 500) / 5) * 5;
}


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

// Common file
#include <ext/pb_ds/assoc_container.hpp>
// Including tree_order_statistics_node_update
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>



#define pb push_back
#define F first
#define S second
#define rep(i,n) for(int i = 0; i < (n); i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
            y = y>>1;
            x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
    return(m == 0)?1:n*nCr(n-1,m-1)/m;
}

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

int main()
{
    ll n;
    string ans;
    cin >> n;

    while(n > 0) {
        n -= 1;
        ans += char(97 + (n % 26));
        n /= 26;
    }

    reverse(ans.begin() , ans.end());

    cout << ans << "\n";

    return 0;
}


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

using namespace std;

const int maxn = 505;

int n, m, a[maxn][maxn], s, ans, x[maxn * maxn], y[maxn * maxn], x2[maxn * maxn], y2[maxn * maxn];

inline int read(){
	char ch = getchar(); int u = 0, f = 1;
	while(!isdigit(ch)){if(ch == '-')f = -1; ch = getchar();}
	while(isdigit(ch)){u = u * 10 + ch - 48; ch = getchar();} return u * f; 
}

int main(){
	n = read(); m = read();
	for(register int i = 1; i <= n; i++)
		for(register int j = 1; j <= m; j++)
			a[i][j] = read() % 2;
	for(register int i = 1; i <= n; i++){
		if(i & 1)
			for(register int j = 1; j <= m; j++){
				if(a[i][j] == 0 || (j == m && i == n))continue;
				ans++;
				x[ans] = i; y[ans] = j;
				if(j != m)
					x2[ans] = i, y2[ans] = j + 1, (a[i][j + 1] += a[i][j]) %= 2;
				else 
					x2[ans] = i + 1, y2[ans] = j, (a[i + 1][j] += a[i][j]) %= 2;
			}
		else 
			for(register int j = m; j >= 1; j--){
				if(a[i][j] == 0 || (j == 1 && i == n))continue;
				ans++;
				x[ans] = i; y[ans] = j;
				if(j != 1)
					x2[ans] = i, y2[ans] = j - 1, (a[i][j - 1] += a[i][j]) %= 2;
				else 
					x2[ans] = i + 1, y2[ans] = j, (a[i + 1][j] += a[i][j]) %= 2;
			}
	}
	cout << ans << endl;
	for(register int i = 1; i <= ans; i++)
		cout << x[i] << " " << y[i] << " " << x2[i] << " " << y2[i] << endl;
	return 0;
}

Measured memory_bytes: 6016
using System;
using System.Linq;
using static System.Math;

class D
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var s = new long[n + 1];
		for (int i = 0; i < n; i++) s[i + 1] = s[i] + a[i];

		var r = long.MaxValue;
		for (int i = 2; i < n - 1; i++)
		{
			long s1 = s[i], s2 = s[n] - s1;
			long sh1 = (s1 + 1) / 2, sh2 = s1 + (s2 + 1) / 2;

			var i1 = Array.BinarySearch(s, sh1);
			if (i1 < 0) i1 = ~i1;
			if (i1 == i || sh1 - s[i1 - 1] <= s[i1] - sh1) i1--;
			long M1 = Max(s[i1], s1 - s[i1]), m1 = s1 - M1;

			var i2 = Array.BinarySearch(s, sh2);
			if (i2 < 0) i2 = ~i2;
			if (i2 == n + 1 || sh2 - s[i2 - 1] <= s[i2] - sh2) i2--;
			long M2 = Max(s[i2] - s1, s[n] - s[i2]), m2 = s2 - M2;

			r = Min(r, Max(M1, M2) - Min(m1, m2));
		}
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 34012
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

typedef vector<vector<pair<ll,int>>> wgraph;
typedef pair<ll,int> pli;

vector<ll> bfs(wgraph v,int x){
  priority_queue<pli,vector<pli>,greater<pli>> q;
  vector<ll> dist(v.size(),longinf);
  dist[x]=0;
  q.push({0LL,x});
  
  while(q.size()){
    pli p=q.top(); q.pop();
    ll d=p.F, now=p.S;
    if(dist[now]<d){ continue; }
    for(auto to:v[now]){
      if(dist[to.S]>d+to.F){
        dist[to.S] = d+to.F;
        q.push({dist[to.S], to.S});
      }
    }
  }
  return dist;
}

int main(){
  int n,m,R;
  cin >> n >> m >> R;
  vector<int> r(R);
  rep(i,R){ cin >> r[i]; r[i]--; }
  wgraph v(n);
  rep(i,m){
    int x,y,c;
    cin >> x >> y >> c; x--; y--;
    v[x].push_back({c,y});
    v[y].push_back({c,x});
  }
  
  vector<vector<ll>> data(n, vector<ll>(n));
  rep(i,n){
    data[i]=bfs(v,i);
  }
  
  sort(r.begin(),r.end());
  ll ans=longinf;
  do{
    ll cur = 0;
    for(int i=1; i<R; i++){
      cur += data[r[i-1]][r[i]];
    }
    ans = min(ans,cur);
  }while(next_permutation(r.begin(), r.end()));
  
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 2120
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>
#include<cstdio>
#include<climits>
#include<cstring>

using namespace std;

int main(){

	int N;

	cin >> N;

	vector<int>a(N,0);

	int sum = 0;
    int cnt = 0;

	for(int i = 0;i < N;i++){
		int s;
		cin >> s;
		a[i] = s;
		if(s%10 == 0){
			cnt++;
		}
		sum += s;
	}

	if(cnt == N){
		cout << 0 << endl;
	}

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

	if(sum%10 != 0){
		cout << sum << endl;
	}else{
		for(int i = 0;i<N;i++){
		   if(a[i]%10 != 0){
			  cout << sum  - a[i] << endl;
			  return 0;
		   }
		}
	}


	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll x,y;
int main(){
	scanf("%lld%lld",&x,&y);
	puts(llabs(x-y)<=1?"Brown":"Alice");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		StringBuilder sb = new StringBuilder();
		String ls = System.lineSeparator();
		int numA = 0;
		int numB = 0;
		int h = 0;
		int w = 100;
		while(numA<a-50) {
			sb.append(".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#");
			sb.append(ls);
			sb.append("####################################################################################################");
			sb.append(ls);
			h += 2;
			numA += 50;
		}
		if((a-1)%50!=0) {
			while(numA<a-1) {
				sb.append(".#");
				numA++;
			}
			while(numA%50!=0) {
				sb.append("##");
				numA++;
			}
			sb.append(ls);
			h++;
		}
		sb.append("####################################################################################################");
		sb.append(ls);
		sb.append("....................................................................................................");
		sb.append(ls);
		h += 2;
		
		while(numB<b-50) {
			sb.append(".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#");
			sb.append(ls);
			sb.append("....................................................................................................");
			sb.append(ls);
			h += 2;
			numB += 50;
		}
		if((b-1)%50!=0) {
			while(numB<b-1) {
				sb.append(".#");
				numB++;
			}
			while(numB%50!=0) {
				sb.append("..");
				numB++;
			}
			sb.append(ls);
			h++;
		}
		
		
		System.out.println(h+" "+w);
		System.out.println(sb.toString());
		in.close();
	}

}


Measured memory_bytes: 23764
import java.util.Scanner;

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

		int A = sc.nextInt();
		int B = sc.nextInt();

		int ans = -1;
		for (int i=0; i<10; i++) {
			int x = B*10 + i;
			if (x * 8 / 100 == A) {
				ans = x;
				break;
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        System.out.println( solve(H, W) );
    }

    private static int solve(int H, int W) {
        int tate3 = calcTate3(H, W);
        int yoko3 = calcTate3(W, H);
        int tateYoko = calcTateYoko(H, W);
        int yokoTate = calcTateYoko(W, H);

        return Math.min(Math.min(tate3, yoko3), Math.min(tateYoko, yokoTate));
    }

    private static int calcTate3(int H, int W) {
        if( W < 3 ) return Integer.MAX_VALUE;

        if( W % 3 == 0 ) {
            return 0;
        } else {
            return H;
        }
    }

    // 縦に切った後、横に切る
    private static int calcTateYoko(int H, int W) {
        // 余りを割り振る
        int hq = H / 3;
        int hr = H % 3;

        int h1;
        if( hr == 0 ) {
            h1 = hq;
        } else if( hr == 1 ) {
            h1 = hq;
        } else {
            h1 = hq + 1;
        }
        int h2 = H - h1;

        int wq = W / 2;
        int wr = W % 2;

        int w1 = wr == 1 ? wq + 1 : wq;
        int w2 = W - w1;

        int c1 = h1 * W;
        int c2 = h2 * w1;
        int c3 = h2 * w2;

        int max = Math.max(Math.max(c1, c2), c3);
        int min = Math.min(Math.min(c1, c2), c3);
        return max - min;
    }
}


Measured memory_bytes: 23760
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
  int A;
  cin >> A;
  int z = A % 2;
  int x = floor(A / 100);
  int y = (A - x*100 - z)/10;
  cout << z+x+y << endl;   
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>
 
int main(void){
    char W[11],T[1000];
    int i,count=0;
     
    scanf("%s",W);
    while(scanf("%s",T),strcmp(T,"END_OF_TEXT")){
        for(i=0;T[i]!='\0';i++){
            T[i]=tolower(T[i]);
        }
         
        if(strcmp(W,T)==0) count+=1;
    }
     
    printf("%d\n",count);
     
    return 0;
}


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

int main(){
    int n,A,B;
    cin>>n;
    vector<int>R(n);
    for(int i=0;i<n;i++){
        cin>>R[i];
    }
    B=R[0];
    A=R[1]-R[0];
    for(int i=1;i<n-1;i++){
        B=min(B,R[i]);
        A=max(A,R[i+1]-B);
       // cout<<A<<" "<<B<<endl;
    }
    cout<<A<<endl;
}



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

int main() {
    int n; cin >> n;
    n %= 10;
    if(n == 3) cout << "bon" << endl;
    else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include<string.h>

int main()
{
int a[101][101];
int b[101];
int n,m;
scanf("%d %d",&n,&m);
for(int i=0;i<n;i++){
	for(int j=0;j<m;j++){
		scanf("%d",&a[i][j]);
	}
}
for(int i=0;i<m;i++){
	scanf("%d",&b[i]);
}
for(int i=0;i<n;i++){
	int ans=0;
	for(int j=0;j<m;j++){
		ans+=a[i][j]*b[j];
	}
	printf("%d\n",ans);
}
}


Measured memory_bytes: 2100
#include <stdio.h>
#include <math.h>

char prime[1000000];

int main(void)
{
	int i, n;
	
	prime[2] = 1;
	for (i = 3; i < 1000000; i += 2){
		prime[i] = 1;
	}
	while (scanf("%d", &n) != EOF){
		int count = 0;
		for (i = 3; i < sqrt(n); i++){
			if (prime[i]){
				int j;
				for (j = i * 2; j <= n; j += i){
					prime[j] = 0;
				}
			}
		}
		for (i = 2; i <= n; i++){
			count += prime[i];
		}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 1572
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  S.size()==6;
  cin>>S;
    if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)){
      cout<<"Yes"<<endl;
    }
      else{
        cout<<"No"<<endl;
      }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

int n, a[210];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++) scanf("%d", a + i);
	int c[3], cnt = 0;
	for(int i = 2; i < n; i ++) {
		c[0] = a[i - 1]; c[1] = a[i]; c[2] = a[i + 1];
		sort(c, c + 3);
		if(c[1] == a[i]) {
			cnt ++;
		}
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int a,b;
int main(void){
  cin >> a >> b;
  if(a <= 0 && 0 <= b)
    cout << "Zero" << endl;
  else if((min(0,b+1) - min(0,a))%2)
    cout << "Negative" << endl;
  else
    cout << "Positive" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll HMAX, WMAX;

bool isin(ll x, ll y) {
  return x >= 0 && x < WMAX && y >= 0 && y < HMAX;
}

void solve() {
  const ll MAX = 2 * 30;
  while (true) {
    ll W, H;
    cin >> W >> H; cin.ignore();

    if (W==0 && H==0) break;

    HMAX = 2*H-1, WMAX = 2*W-1;
    vector<string> grid(HMAX);
    rep(i, HMAX) {
      getline(cin, grid[i]);
      if (grid[i].size() < WMAX) grid[i] += ' ';
    }

    // debug2(HMAX, WMAX);

    queue<ll> qx, qy, qc;
    qx.push(0); qy.push(0); qc.push(0);
    ll mins[MAX][MAX] = {{}};
    rep(i, MAX)rep(j, MAX) mins[i][j] = INF;
    mins[0][0] = 0;

    bool ok = false;
    while (!qx.empty()) {
      ll x = qx.front(); qx.pop();
      ll y = qy.front(); qy.pop();
      ll c = qc.front(); qc.pop();

      // debug3(x, y, c);

      if (x == WMAX-1 && y == HMAX-1) {
        outl(c+1);
        ok = true;
        break;
      }

      rep(i, 4) {
        ll nx = x + dx[i];
        ll ny = y + dy[i];
        ll nnx = nx + dx[i];
        ll nny = ny + dy[i];
        if (isin(nx, ny) && grid[ny][nx] == '0' && isin(nnx, nny) && c+1 < mins[nny][nnx]) {
          qx.push(nnx);
          qy.push(nny);
          qc.push(c+1);
          mins[nny][nnx] = c+1;
        }
      }
    }
    if (!ok) outl(0);
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}



Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);
    private static int N;
    private static String s;

    public static void main(String[] args) {
	N = Integer.parseInt(scan.next());
	s = scan.next();

	String ans = check(true, true);
	if(ans.equals("-1")) ans = check(true, false);
	if(ans.equals("-1")) ans = check(false, true);
	if(ans.equals("-1")) ans = check(false, false);

	System.out.println(ans);
	scan.close();
    }

    private static boolean next(boolean p, boolean c, char say) {
	boolean state = (say == 'o' ? p : !p);
	return c ? state : !state;
    }

    private static String check(boolean p, boolean c) {
	boolean[] state = new boolean[N+1];
	state[0] = p;
	state[1] = c;

	for (int i = 1; i < N; i++) {
	    state[i+1] = next(state[i-1], state[i], s.charAt(i));
	}

	String ans = "-1";
	if(state[N] == state[0] && next(state[N-1], state[0], s.charAt(0)) == state[1]) {
	    StringBuilder str = new StringBuilder(N);
	    for (int i = 0; i < N; i++) {
		str.append(state[i] ? 'S' : 'W');
	    }
	    ans = str.toString();
	}
	return ans;
    }
}


Measured memory_bytes: 25620
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007ll //998244353ll
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n, ans=0;
    cin>>n;
    for(int i=1;i<n;i++)
    {
        int r=(n-1)/i;
        ans+=max(0ll, r);
    }
    cout<<ans;

}

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>

int main(){
  int a;
  char input[4];
  int ac = 0, wa = 0, tle = 0, re = 0;
  scanf("%d", &a);
  getchar();
  for(int i = 0; i < a; i++){
    gets(input);
    if(strcmp(input, "AC") == 0)
      ac++;
    else if(strcmp(input, "WA") == 0)
      wa++;
    else if(strcmp(input, "TLE") == 0)
      tle++;
    else if(strcmp(input, "RE") == 0)
      re++;
  }
  
  printf("AC x %d\n", ac);
  printf("WA x %d\n", wa);
  printf("TLE x %d\n", tle);
  printf("RE x %d\n", re);
  
  return 0;
}

Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n)
    {
        cin >> h[i];
    }
    bool f = true;
    int ans = 0;
    while (f)
    {
        f = false;
        rep(i, n)
        {
            if (h[i] > 0)
            {
                f = true;
                ans++;
                for (int j = i; j < n; j++)
                {
                    if (h[j] > 0)
                    {
                        h[j]--;
                    }
                    else
                    {
                        break;
                    }
                }
                i--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
a = int(input())
b = []
for i in range(a):
    c = input()
    if len(b) == 0:
        b.append(c)
    else:
        d = b[i-1]
        if c not in b and d[-1] == c[0]:
            b.append(c)
        else:
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define N 100005
vector<int> g[N];
int ans,n,du[N],pos;
bool is[N];
void dfs(int p,int fa){
	is[p]=0;
	if(g[p].size()>2)is[p]=1;
	for(auto i:g[p])
	if(i!=fa){
		dfs(i,p);
		is[p]|=is[i];
	}
}
int main(){
	scanf("%d",&n);
	pos=-1;
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);x++;y++;
		g[x].pb(y);
		g[y].pb(x);
		du[x]++;du[y]++;
		if(du[x]>2)pos=x;
		if(du[y]>2)pos=y;
	}
	if(pos==-1){
		puts("1");
		return 0;
	}
	dfs(pos,0);
	for(int i=1;i<=n;i++)if(is[i]){
		int num=0;
		for(auto j:g[i])if(!is[j])num++;
		if(num)ans+=num-1;
	}
	printf("%d\n",max(1,ans));
	return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define fi first
#define se second

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    rep(i,n-1)sum+=a[i];
    if(a[n-1]<sum)Cout("Yes");
    else Cout("No");
    return 0;
}


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

#define ll long long
#define db double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;



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

	int n, m;
	cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1) / 2;
}


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++)
#define P pair<ll,ll>

int main(){
  string s;
  cin>>s;
  if(s[s.size()-1]=='s') s=s+"es";
  else s=s+'s';
  cout<<s<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define pii pair<int,int>

using namespace std;

const int nax = 2e5 + 5;

int sz[nax];
int par[nax];

int f(int v)
{
    if(par[v] == v) return v;
    return par[v] = f(par[v]);
}

void u(int a,int b)
{
    a = f(a);
    b = f(b);
    if(a==b) return;
    if(sz[a] > sz[b]) swap(a,b);
    par[a] = b;
    sz[b] += sz[a];
    return;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin>>n;
    for(int i=1;i<=n;i++)
    {
        sz[i] = 1;
        par[i] = i;
    }
    int m; cin>>m;
    for(int i=1;i<=m;i++)
    {
        int x,y; cin>>x>>y;
        u(x,y);
    }
    int ans = 0;
    for(int i=1;i<=n;i++) ans = max(ans,sz[i]);
    cout<<ans;


    return 0;
}


Measured memory_bytes: 5208
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    long a = Integer.parseInt(sc.next());
    long b = Integer.parseInt(sc.next());
    pw.println(a * b / BigInteger.valueOf(a).gcd(BigInteger.valueOf(b)).longValue());
  }
}


Measured memory_bytes: 23248
#include<bits/stdc++.h>
using namespace std;
#define BeatMeScanf ios_base::sync_with_stdio(false)
#define ll long long
#define sz 1000005

int main(){
    BeatMeScanf;
    string s,t;
    cin>>s>>t;
    cout<<t+s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;

    long long ac = 0;
    long long wa = 0;

    vector<long long> wrong(n, 0);
    vector<bool> isac(n, 0);

    for(int i = 0; i < m; ++i) {
        int p;
        string s;
        cin >> p >> s;
        --p;
        if(!isac[p]) {
            if(s == "AC") {
                isac[p] = true;
                wa += wrong[p];
                ac++;
            } else {
                wrong[p]++;
            };
        };
    }
    cout << ac << " " << wa << endl;
    return 0;
}


Measured memory_bytes: 1024
N=int(input())
A=[int(i) for i in input().split()]
if min(A)>=0:
  A.sort()
  print(sum(A)-2*A[0])
  k=A[0]
  for i in range(1,N-1):
    print(k,A[i])
    k-=A[i]
  print(A[N-1],k)
  exit()
if max(A)<=0:
  A.sort()
  print(-sum(A)+2*A[N-1])
  k=A[N-1]
  for i in range(1,N-1)[::-1]:
    print(k,A[i])
    k-=A[i]
  print(k,A[0])
  exit()
A.sort()
A_=list(map(abs,A))
print(sum(A_))
for i in range(1,N-1):
  if A[i]<0:
    print(A[N-1],A[i])
    A[N-1]-=A[i]
  else:
    print(A[0],A[i])
    A[0]-=A[i]
print(A[N-1],A[0])

    



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

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mod 1000000007
#define inf 1e18
#define endl "\n"

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main()
{
    fastio
    int test=1,n;

    // cin >> test;

    while(test--)
    {
        cin >> n ;

        int t = n%1000;

        if(t)
            t = 1000-t;
        
        cout << t << endl;
    }


    return 0;
}

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

ll gcd(ll x, ll y)
{
  if (x > y) return gcd(y,x);
  ll r = y % x;
  if (r==0) return x;
  return gcd(r,x);
}

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

int main()
{
  ll a,b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end(),greater<ll>());
  ll res=0;
  queue<ll> que;
  que.push(a[0]);
  for(ll i=1;i<n;i++){
    ll point =que.front();
    res+=point;
    que.pop();
    rep(j,2){
      que.push(a[i]);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 6404
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int s,k; cin >>k>>s;

    int count = 0;
    for (int x = 0; x < k+1; x++) {
        for (int y = 0; y < k+1; y++) {
            int z = s - (x + y);
            if (0 <= z && z <= k) {
                count++;
            } 
        }
    }

    cout << count << endl;
    return 0;
}




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

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

signed main(){
	int N, A, i, j, ans = 0;
	scanf("%lld", &N);
	vector<int> Anum(0);
	for(i = 0; i < N; i++){
		scanf("%lld", &A);
		while(Anum.size() <= A) Anum.push_back(0);
		Anum[A]++;
	}
	int Amax = Anum.size();
	vector<int> inv(Amax, 1);
	for(i = 2; i < Amax; i++) inv[i] = MOD(-(p / i) * inv[p % i]);
	vector<int> B(Amax, 0);
	for(i = Amax - 1; i >= 1; i--){
		for(j = i; j < Amax; j += i){
			B[i] += j * Anum[j];
		}
		B[i] = MOD(MOD(B[i]) * MOD(B[i]));
		for(j = 2 * i; j < Amax; j += i){
			B[i] -= B[j];
		}
		ans = MOD(ans + MOD(B[i]) * inv[i] - Anum[i] * i);
	}
	printf("%lld\n", MOD(ans * inv[2]));
	return 0;
}

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

using namespace std;

string button[9] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

int main(void){
  int n;
  string s;

  cin >> n;
  for(int i=0; i<n; i++){
    vector<char> v;
    cin >> s;

    int count = 0;
    for(int j=0; j<s.size(); j++){
      if(s[j] == '0'){
        if(j == 0 || s[j-1] == '0')
          continue;

        v.push_back(button[(s[j-1]-'0')-1][(count-1)%button[(s[j-1]-'0')-1].size()]);
        count = 0;
      } else {
        count++;
      }
    }

    for(int j=0; j<v.size(); j++){
      cout << v[j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1232
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.D_Challenge
{
    class ABC_061
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            var edges = new int[m, 3];
            for (int i = 0; i < m; i++)
            {
                int[] abc = ReadInts();
                edges[i, 0] = abc[0] - 1;
                edges[i, 1] = abc[1] - 1;
                edges[i, 2] = -abc[2];
            }
            long dist = BellmanFord(n, edges, 0, n - 1);
            Console.WriteLine(dist == long.MinValue
                ? "inf" : (-dist).ToString());
        }

        static long BellmanFord(int n,int[,] edges, int start,int goal)
        {
            int m = edges.GetLength(0);
            var distances = new long[n];
            for (int i = 0; i < n; i++)
            {
                distances[i] = long.MaxValue;
            }
            distances[start] = 0;

            for (int i = 0; i < n - 1; i++)
            {
                for (int v = 0; v < m; v++)
                {
                    int a = edges[v, 0];
                    int b = edges[v, 1];
                    long c = edges[v, 2];
                    if (distances[a] != long.MaxValue
                        && distances[b] > distances[a] + c)
                    {
                        distances[b] = distances[a] + c;
                    }
                }
            }

            //negative check
            var negative = new bool[n];
            for (int i = 0; i < n; i++)
            {
                for (int v = 0; v < m; v++)
                {
                    int a = edges[v, 0];
                    int b = edges[v, 1];
                    long c = edges[v, 2];
                    if (distances[a] != long.MaxValue
                        && distances[b] > distances[a] + c)
                    {
                        distances[b] = distances[a] + c;
                        negative[b] = true;
                    }
                    if (negative[a]) negative[b] = true;
                }
            }

            return negative[goal] ? long.MinValue : distances[goal];
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}

Measured memory_bytes: 13268
#include<iostream>

using namespace std;

int main(){
  int a[]= {1, 3, 5, 7, 8, 10, 12};
  int b[]= {4, 6, 9, 11};
  int c[]= {2};
  
  int x, y;
  cin >> x >> y;
  
  char check_x, check_y;
  for(int i=0;i < 7;i++){
    if(x == a[i])
      check_x='a';
    if(y == a[i])
      check_y='a';
  }
  for(int i=0;i < 4;i++){
    if(x == b[i])
      check_x='b';
    if(y == b[i])
      check_y='b';
  }

  if(x == c[0])
    check_x='c';
  if(y == c[0])
    check_y='c';
  
  if(check_x == check_y)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n")[0];

  
  console.log(Math.round(input / 2))
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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



int main()
{
    string S, T;
    int A, B;
    string U;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if( S==U )
        --A;
    else if( T==U)
    {
        --B;
    }

    cout << A << " " << B << endl;
    
    return 0;
}

Measured memory_bytes: 256