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

typedef struct{
    int value;
    int done;
}data;
/*
 * 
 */

int main(int argc, char** argv) {

    
    int n, track;
    scanf("%d",&n);
    int *A =(int*)malloc(n *sizeof(int));
    for(int a = 0; a < n; a++){
 
            scanf("%d",&A[a]);
    }

    int m;
    scanf("%d",&m);
    data *B = (data*)malloc(n * sizeof(data));
    for(int a = 0; a < m; a++){
        scanf("%d",&B[a].value);
        B[a].done = 0;
    }
    
    for(int a = 0; a < n; a++){
        for(int b = 0; b < m; b++){
            if((A[a] == B[b].value) && (B[b].done == 0)){
            track++;
            B[b].done=1;
            }
        }
    }
    
    free(A);
    free(B);
    printf("%d",track);
    printf("\n");
    
    return (0);
}



Measured memory_bytes: 2048
import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int a=sc.nextInt();
  int b=sc.nextInt();
  int c=sc.nextInt();
  int k=sc.nextInt();
  while(a>=b){b*=2;k--;}
  while(b>=c){c*=2;k--;}
  System.out.println((k<0)?"No":"Yes");
}

}

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

int main(void){
    int n, m;
    cin >> n >> m;
    
    bool p1[200001] = {false}, pn[200001] = {false};
    int bgn, end;
    int i;
    for(i = 1; i <= m; i++){
        cin >> bgn >> end;
        if(bgn == 1){
            p1[end] = true;
        }
        if(end == n){
            pn[bgn] = true;
        }
    }
    
    for(i = 2; i < n; i++){
        if(p1[i] && pn[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    
    cout << "IMPOSSIBLE" << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int n;
	cin>>n;
	int a[n];
	vi g;
	rep(i,n){
		cin>>a[i];
		g.pb(a[i]);
	}
	sort(all(g));
	int ans1=g[n/2-1],ans2=g[n/2];
	rep(i,n){
		if(a[i]<ans2){
			cout<<ans2<<endl;
		}
		else{
			cout<<ans1<<endl;
		}
	}
	re 0;
}

Measured memory_bytes: 3828
import java.util.*;

public class Main {

    public static void main(String args[]){

    	//B問題
    	Scanner scan = new Scanner(System.in);

    	//文字列格納用
    	String S;
    	S = scan.next();



    	while(S.length() >= 2){
        	//1文字削除
        	if(S != null && S.length() > 0){
        	    S = S.substring(0, S.length()-1);
        	}
        	//文字数が偶数ならば
        	if(S.length() % 2 == 0){
        		String sa = S.substring(0,S.length() / 2);
        		String sb = S.substring(S.length() / 2 ,S.length());
        		if(sa.equals(sb)){
        			System.out.println(S.length());
        			break;
        		}
        	}
    	}
    }
}


Measured memory_bytes: 21716
import statistics
import math
n = int(input())
a = list(map(int,input().split()))
ans1,ans2 = 0,0
a_avr1 = math.ceil((statistics.mean(a)))
a_avr2 = math.floor((statistics.mean(a)))
for i in range(n):
  ans1 += (a[i] - a_avr1)**2
  ans2 += (a[i] - a_avr2)**2
print(min(ans1,ans2))

Measured memory_bytes: 10900
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;

void PUNKS_NOT_DEAD() {
    int a, b;
    cin >> a >> b;
    string aa;
    for (int i = 0; i < b; i++) aa += (char)(a + '0');
    string bb;
    for (int i = 0; i < a; i++) bb += (char)(b + '0');
    if (aa < bb) cout << aa;
    else cout << bb;
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0);
    PUNKS_NOT_DEAD();
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#include<ctype.h>
int main(){
    int r, a;
    while(~scanf("%d", &r)){
    a=r*r;
    printf("%d\n", a/1);
    }
return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
  int t[3],i,j,min = 999999;
  scanf("%d %d %d\n",&t[0],&t[1],&t[2]);
  for(i = 0;i < 2;i++) {
    for(j = i + 1;j < 3;j++) {
      if(min > t[i] + t[j]) min = t[i] + t[j];
    }
  }
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <utility>
#include <cstdint>

using namespace std;

uint64_t N;
int8_t L[100000],_L[100000];

int main(void)
{
	cin >> N;
	int t;
	for(int i = 0;i < N;i++)
	{
		cin >> t;
		L[i] = t;
	}
	L[N] = -1;
	bool loop = true;
	uint64_t itr1 = 0,itr2 = 0;
	uint64_t result = 0;
	while(loop)
	{
		while(L[itr1] != L[itr1 + 1] && itr1 < N - 1)
		{
			itr1++;
		}
		itr2 = itr1 + 1;
		while(L[itr2] != L[itr2 + 1] && itr2 < N - 1)
		{
			itr2++;
		}
		memcpy(_L,L,sizeof(int8_t[100000]));
		for(uint64_t i = itr1 + 1;i <= itr2;i++)
		{
			if(L[i] == 0)
				_L[i] = 1;
			else if(L[i] == 1)
				_L[i] = 0;
		}
		uint64_t upper = itr1,downer = itr1,count = 1;
		while(upper > 0 && _L[upper] != _L[upper - 1])
		{
			upper--;
			count++;
		}
		while(downer < N - 1 && _L[downer] != _L[downer + 1])
		{
			downer++;
			count++;
		}
		result = max(result,count);
		itr1++;
		if(itr2 >= N - 1)
		{
			loop = false;
		}
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 3328
n, k, s = map(int, input().split())

if s != 10 ** 9:
    ans = [s for _ in range(k)] + [10 ** 9 for _ in range(n - k)]
    print(*ans)
else:
    ans = [s for _ in range(k)] + [10 ** 9 - 1 for _ in range(n - k)]
    print(*ans)

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

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

int main() {
  ll a,b,k;
  cin >> a >> b >> k;
  if(a>=k){
    cout << a-k << ' ' << b << endl;
  }
  else if(a<k&&a+b>=k){
    cout << 0 << ' ' << a+b-k << endl;
  }
  else{
    cout << 0 << ' ' << 0 << endl;
  }
  return 0;

}


Measured memory_bytes: 3464
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <utility>
using namespace std;

int main() {
	int N;
	cin >> N;
	long long A[N],B[N],C[N];
	for(int i=0; i<N; i++){
		cin>>A[i];
	}
	for(int i=0; i<N; i++){
		cin>>B[i];
	}
	for(int i=0; i<N; i++){
		cin>>C[i];
	}
	
	sort(A,A+N); sort(B,B+N); sort(C,C+N);
	
	long long ans=0;
	for(int i=0; i<N; i++){
		long long a,c;
		a=lower_bound(A,A+N,B[i])-A;
		c=N-(lower_bound(C,C+N,B[i]+1)-C);
		ans+=a*c;
		
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  vl A(N), B(N), C(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  rep(i, N) cin >> C[i];

  stable_sort(A.begin(), A.end());
  stable_sort(B.begin(), B.end());
  stable_sort(C.begin(), C.end());

  vl mid_bot(N, 0);
  ll sum = 0;
  
  rep_inv(i, N - 1, -1){
    auto it = lower_bound(C.begin(), C.end(), B[i] + 1);
    sum += (ll)(C.end() - it);
    mid_bot[i] = sum;
  }
  
  ll cnt = 0;

  rep(i, N){
    if(B[N - 1] <= A[i]) break;
    auto it = lower_bound(B.begin(), B.end(), A[i] + 1);
    ll ind = (ll)(it - B.begin());
    cnt += mid_bot[ind];
  }

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


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

#define forsn(i,s,n) for(int i = (int)s; i < (int) n;i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for(int i = (int)(n-1); i >= (int) s;i--)
#define dforn(i,n) dforsn(i,0,n)
#define si(a) ((int)(a).size())
#define all(a) a.begin(),a.end()
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
using pii = pair<int,int>;
using ll = long long int;
using vi = vector<int>;


int main(){
        fastio;

int mastrosisi;

        string s;
        cin >> s;
        ll white=0;
        ll res=0;
        dforn(i,si(s)){
            if(s[i]=='W')white++;
            else res+=white;
        }

        cout << res << endl;


        return 0; 
}

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

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

	vector<int> h(n), dp(n, INT_MAX);
	for (auto& a : h)
		cin >> a;

	dp[0] = 0;

	for (int i = 1; i < n; i++) {
		for (int j = 1; j <= k && i - j >= 0; j++) {
			dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
		}
	}

	cout << dp.back();
}

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

int main (){
	int n1,n2;

	for (n1=1; n1<=9; n1++){
		for (n2=1; n2<=9; n2++){
			cout << n1 << "x" << n2 << "=" << n1*n2 << "\n";
		}
	}
	return 0;
}

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

int n,ans=0;

map<int,bool> visited;
map<int,bool>::iterator it;

inline void get(int x)
{
	if (x==1)  return;
	
	int m=n;
	while (m%x==0)  m/=x;
	if (m%x==1) 
	{
		if (!visited[x])  visited[x]=1;
	}
}

signed main()
{
	cin>>n;
	for (int i=1;i*i<=n;i++)
	{
		if (n%i==0)  get(i),get(n/i);
	}
	for (int i=1;i*i<=n-1;i++)
	{
		if ((n-1)%i==0)  get(i),get((n-1)/i);
	}
	for (it=visited.begin();it!=visited.end();it++)  ans++;
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

int main() 
{
#ifdef DK
    freopen("in", "r", stdin);
#endif
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i)
        cin >> h[i];
    for (int i = 0; i + 1 < n; ++i) {
        if (h[i] > h[i + 1]) {
            h[i]--;
        } 
        else if (h[i] == h[i + 1]) {
            if (i) {
                if (h[i - 1] < h[i]) {
                    h[i]--;
                }
            }
        }
    }
    bool yes = true;
    for (int i = 0; i + 1 < n; ++i) {
        yes &= h[i] <= h[i + 1];
    }
    cout << (yes ? "Yes" : "No") << endl;
    return 0;
}



Measured memory_bytes: 768
import math

A, B, H, M = map(int, input().split())

c1 = 2*math.pi*(H/12 + 1/12*(M/60))
c2 = 2*math.pi*(M/60)

out = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(c1-c2))
print(out)

Measured memory_bytes: 9380
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }

int sol = 1;

vi adj[100001];
int n,k;

void dfs(int x, int p)
{
    int j = 0;
    for (int i = 0; i < adj[x].size(); ++i)
    {
        int y = adj[x][i];
        if (y == p) continue;
        j++;
        //cout << y _ k - j - (p != -1) << endl;
        muls(sol, k - j - (p != -1));
        dfs(y, x);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    muls(sol, k);
    dfs(1, -1);
    cout << sol;
}


Measured memory_bytes: 11648
import Control.Monad

main :: IO ()
main = do
  n1 <- readLn
  if n1 == 0
    then return ()
    else do
      ns <- replicateM 4 readLn
      let ns' = n1:ns
          ans = solve ns'
      mapM_ print ans
      main

solve :: [Int] -> [Int]
solve ns
  | allEq ns = [3,3,3,3,3]
  | allDif ns = [3,3,3,3,3]
  | not (elem 1 ns) = fix 1 ns
  | not (elem 2 ns) = fix 2 ns
  | not (elem 3 ns) = fix 3 ns
  where
    allEq :: [Int] -> Bool
    allEq ns = all ((==) (head ns)) ns

    allDif :: [Int] -> Bool
    allDif ns = (elem 1 ns) && (elem 2 ns) && (elem 3 ns)

    fix :: Int -> [Int] -> [Int]
    fix _ [] = []
    fix 1 (x:xs)
      | x == 2 = 1:(fix 1 xs)
      | otherwise = 2:(fix 1 xs)
    fix 2 (x:xs)
      | x == 1 = 2:(fix 2 xs)
      | otherwise = 1:(fix 2 xs)
    fix 3 (x:xs)
      | x == 1 = 1:(fix 3 xs)
      | otherwise = 2:(fix 3 xs)

Measured memory_bytes: 4104
using System;


public class Hello{
    public static void Main(){
        var n = int.Parse(Console.ReadLine());
        long result = 0;
        
        for (var i = 1; i <= n; i++){
            if(i % 3 == 0 && i % 5 == 0){
            }else if(i % 3 == 0){
            }else if (i % 5 == 0){
            }else{
                result += i;
            }
        }
        Console.WriteLine(result);
    }
}


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

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


Measured memory_bytes: 3052
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    int N;
    cin >> N;
    vector<ll> p(N);
    for(ll& x: p){cin >> x; x--;}

    vector<ll> a(N), b(N);
    for(int i=0; i<N; i++) a[i] = i+1;
    for(int i=0; i<N; i++) b[p[i]] = N+i-a[p[i]];

    for(int i=1; i<N; i++){
        if(a[i-1] < a[i] && b[i-1] > b[i]) continue;
        ll m = max(a[i-1] - a[i] + 1, b[i] - b[i-1] + 1);
        a[i] += m; b[i] -= m;
    }

    // cout << "---\n";
    // for(ll& x: a) cout << x << " "; cout << endl;
    // for(ll& x: b) cout << x << " "; cout << endl;
    // cout << "---\n";

    if(b[N-1] <= 0){
        for(int i=0; i<N; i++) b[i] += 1-b[N-1];
    }

    for(ll& x: a) cout << x << " "; cout << endl;
    for(ll& x: b) cout << x << " "; cout << endl;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    const int H_MAX = 300;
    const int W_MAX = 300;
    int H, W, D;
    int A[H_MAX][W_MAX];
    int Q;
    pii p[H_MAX * W_MAX + 1];
    int d[H_MAX * W_MAX + 1];
    cin >> H >> W >> D;
    REP(i, H) REP(j, W) {
        cin >> A[i][j];
        p[A[i][j]] = pii(i, j);
    }
    FOR(i, 1, D + 1) d[i] = 0;
    FOR(i, D + 1, H * W + 1) {
        pii p1, p2;
        p1 = p[i];
        p2 = p[i - D];
        d[i] = d[i - D] + abs(p1.first - p2.first) + abs(p1.second - p2.second);
    }
    cin >> Q;
    REP(i, Q) {
        int L, R;
        cin >> L >> R;
        cout << d[R] - d[L] << endl;
    }
    return 0;
}


Measured memory_bytes: 2560
n = int(input())
a=[]
for i in range(n):
    len_A = int(input())
    arr = []
    for j in range(len_A):
        x,y=map(int,input().split())
        x -= 1
        arr.append((x,y))
    a.append(arr)
def is_honest(i,j):
    return (i>>j)&1

def honest_cnt(i):
    ans = 0
    for j in range(n):
        ans += is_honest(i,j)
    return ans

ans = 0
for i in range(2**n):
    ok = True
    for j in range(n):
        if not is_honest(i,j):continue
        for (x,y) in a[j]:
            if y==0 and is_honest(i,x):ok = False
            if y==1 and not is_honest(i,x):ok = False
    if ok:
        ans=max(ans,honest_cnt(i))

#print(a)
#print(a[0])
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>

#define MAX 100000

typedef struct{
  char mark;
  int number;
}card;

int partition(card *,int,int);
void quicksort(card *,int,int);
int Stable(card *,card *,int);

int main()
{
  int n,i;
  card A[MAX],in[MAX];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++)
    {
      scanf(" %c %d",&A[i].mark,&A[i].number);
      in[i] = A[i];
    }
  
  quicksort(A,0,n-1);
  
  if(Stable(in,A,n)) printf("Stable\n");
  else printf("Not stable\n");

  for(i = 0 ; i < n ; i++)
    {    
      printf("%c %d\n",A[i].mark,A[i].number);
    }
  
  return 0;
}

int partition(card *A,int p,int r)
{
  int x,i,j;
  card change;

  x = A[r].number;

  i = p-1;

  for(j = p ; j < r ; j++)
    {
      if(A[j].number <= x)
	{
	  i++;
	  change = A[i];
	  A[i] = A[j];
	  A[j] = change;
	}
    }
  change = A[i+1];
  A[i+1] = A[r];
  A[r] = change;

  return i+1;
}

void quicksort(card *A,int p,int r)
{
  int q;
  if(p < r)
    {
      q = partition(A,p,r);
      quicksort(A,p,q-1);
      quicksort(A,q+1,r);
    }
  return;
}

int Stable(card *in,card *out,int n)
{
  int i,j,a,b;

  for(i = 0 ; i < n-1 ; i++)
    {
      for(a = 0 ; a < n ; a++)
	{
	  if(out[i].number == out[i+1].number)
	    {
		/* outの隣同士の数字が同じなら、inとoutの数字の一致する場所を探す */
		
	      if(in[a].number == out[i].number)
		{
		  /* 数字が一致する場所を見つけたら、絵が同じか調べる */
		    
		  if(in[a].mark == out[i].mark)
		    {
		      /* 絵も一致するなら今の所安定 */
		      
		       /* このペアはもう使わないので判断の邪魔にならない数字を代入 */
		      in[a].number = -1;
		      
		      break; /* inのループを脱出、次のoutの探索へ */
		    }
		  else return 0; /* 数字が一致するが絵が違うなら不安定 */
		}
	    }
	}
    
    }
  return 1;
}



Measured memory_bytes: 3308
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

//降順
int des(const void *a, const void *b)
{
  return *(int *)b - *(int *)a;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int a[n]; double sum = 0;
  for (int i=0; i<n; i++) {
    scanf("%d", a+i);
    sum += a[i];
  }
  sum /= 4*m;
  qsort(a, n, sizeof(int), des);
  for (int i=0; i<m; i++) {
    if (a[i] < sum) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m), y(m);
  map<int, vector<int>> mp;
  for (int i = 0; i < m; i++) {
    cin >> p[i] >> y[i];
    mp[p[i]].push_back(y[i]);
  }
  for (auto &e : mp) sort(e.second.begin(), e.second.end());
  for (int i = 0; i < m; i++) {
    int k = lower_bound(mp[p[i]].begin(), mp[p[i]].end(), y[i]) - mp[p[i]].begin();
    printf("%06d%06d\n", p[i], k + 1);
  }
  return 0;
}


Measured memory_bytes: 13184
//
// Created by Ильдар Ялалов on 14.01.2020.
//
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
typedef unsigned int uint;
#define pb push_back
#define eb emplace_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define mp make_pair
#define all(a) a.begin(),a.end()

#ifdef zxc

#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

bool debug = 0;
const int MAXN = 4e6 + 100;
const int LOG = 21;
const int mod = 1e9 + 7;
const int MX = (1e7 + 100);


void solve() {
    int a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0) {
        cout << "Zero\n";
        return;
    }
    if (a > 0) {
        cout << "Positive\n";
        return;
    }
    int cnt = (b - a + 1);
    cnt = abs(cnt);

    if (cnt % 2 == 0) {
        cout << "Positive\n";
        return;
    }
    cout << "Negative";


}


// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES ( n==1)
signed main() {
#ifdef zxc
    freopen("../input.txt", "r", stdin);
//    freopen("../output.txt", "w", stdout);
#else
#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(2);

    int t = 1;
    while (t--) {
        solve();
    }
    debug(1.0 * clock() / CLOCKS_PER_SEC);
}

Measured memory_bytes: 256
import bisect
from bisect import bisect_left
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
ans = 0

for i in range(n):
  for j in range(n-1, i, -1):
    s = l[i]+l[j]
    ans += bisect_left(l[j+1:n], s)

print(ans)


Measured memory_bytes: 51292
#include<iostream>
#include<string>
#include<algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
using namespace std;

int main(void) {
	int n, k;
	int sum = 0;
	int l[51];
	cin >> n >> k;
	FOR(i, 0, n) {
		cin >> l[i];
	}
	sort(l, l + n);
	for (int i = n - 1; i >= n - k; i--) {
		sum += l[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	int n, x; cin >> n >> x;
	int l[110];
	for (int i = 1; i <= n; ++i) {
		cin >> l[i];
	}
	int d[110];
	d[1] = 0;
	for (int i = 1; i <=n; ++i) {
		d[i + 1] = d[i] + l[i];
	}
	int cnt = 1;
	int i = 2;
	while (true) {
		if (d[i] <= x) {
			cnt++;
			i++;
		}
		else {
			break;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Program
{

    void Solve()
    {
        var r = io.Int;
        WriteLine(r * r);
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Program().Stream();
    private void Stream()
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}

class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput())
    {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };
    public SimpleIO()
    {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next()
    {
        if (_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == string.Empty) st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}

Measured memory_bytes: 11220
def gcd(m, n):
    while n:
        m, n = n, m % n
    return m
def lcm(m, n):
    return m // gcd(m, n) * n

def f(a, m):
    x = a
    cnt = 1
    while x != 1:
        x = x * a % m
        cnt += 1
    return cnt

while 1:
    a1, m1, a2, m2, a3, m3 = map(int, input().split())
    if a1 == 0:
        break
    t1 = f(a1, m1)
    t2 = f(a2, m2)
    t3 = f(a3, m3)
    print(lcm(t1, lcm(t2, t3)))



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

 

int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    cin>>k;
    for(int i=0;i<k;i++)
    {
    	cout<<"ACL";
    }

	return 0;

}

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

int main(){
  int x,n;
  cin>>x>>n;
  set<int>s;
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    s.insert(k);
  }
  int index;
  int mini=10000;
  for(int i=x;i>-1000;i--){
    if(s.count(i)==0){
      if(mini>abs(x-i)){
        mini=abs(x-i);
        index=i;
        break;
      }
    }
  }
  for(int i=x;i<1000;i++){
    if(s.count(i)==0){
      if(mini>abs(x-i)){
        mini=abs(x-i);
        index=i;
        break;
      }
    }
  }
  cout<<index;
  return 0;
}
    


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

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

	auto d = [](vector<int> a, vector<int> b) {
		return a.at(0) > b.at(0);
	};

	priority_queue<vector<int>, vector<vector<int>>, decltype(d)> jobs(d);
	priority_queue<int> availables;
	while (n--) {
		int a, b;
		cin >> a >> b;
		jobs.push( { a, b });
	}

	int result = 0;

	for (int i = 1; i <= m; i++) {
		while (jobs.size() && jobs.top()[0] <= i) {
			availables.push(jobs.top()[1]);
			jobs.pop();
		}
		if (availables.size()) {
			result += availables.top();
			availables.pop();
		}
	}

	cout << result << endl;
}


Measured memory_bytes: 7216
import heapq
import copy

N, K = map(int, input().split())
Vs = list(map(int, input().split()))

ans = 0
for kr in range(min(N, K) + 1):
    for kl in range(min(N - kr, K - kr) + 1):
        kp = min(K - kr - kl, kr + kl)
        # print(kr, kl, kp)
        if kr != 0:
            vs = Vs[-kr:] + Vs[:kl]
        else:
            vs = Vs[:kl]
        
        length = len(vs)
        if length == 0:
            continue
        vs = copy.deepcopy(vs)
        heapq.heapify(vs)
        # less than the number of outputs
        for i in range(min(kp, length)):
            if vs[0] < 0:
                heapq.heappop(vs)
            else:
                break
        value = sum(vs)
        ans = max(value, ans)

print(ans)



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


Measured memory_bytes: 26564
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const int mod=1e9+7;
const int inf=1e9+7;
   
const int maxn=1e5+5;

ll int a[maxn];

ll int b[maxn];


  
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    int n;
    
    while(cin>>n)
    {
    	for(int i=0;i<=n;i++)
    	{
    		cin>>a[i];
		}
		
		for(int i=0;i<n;i++)
		{
			cin>>b[i];
		}
		
		ll int ans=0,now;
		for(int i=0;i<n;i++)
		{
			now=b[i];
			
			if(now<a[i])
			{
				ans+=now;
				now=0;
			}
			else
			{
				ans+=a[i];
				now-=a[i];
				
				if(now>=a[i+1])
				{
					ans+=a[i+1];
					now=0;
					a[i+1]=0;
				}
				else
				{
					ans+=now;
					a[i+1]-=now;
					now=0;
				}
					
			}
		}
		
	
		cout<<ans<<endl;
		
	}
    
      
      
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k;
	char arr[100];
	cin >> k;
	scanf("%s", arr);
	if(strlen(arr) <=k){
		printf("%s", arr);
	}
	else{
		for(int i=0; i<k; ++i){
			cout << arr[i];
		}
		cout << "...";
	}
}


Measured memory_bytes: 3720
#include <cstdio>
#include <vector>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
struct state { long long a, b; };
inline bool operator<(const state& s1, const state& s2) { return s1.a < s2.a; }
int N; long long D, A[33], B[33];
int cnt1, cnt2; state vl[14348922], vr[14348922]; // meet-in-the middle
int que[14348922]; // searching deque
int main() {
	scanf("%d%lld", &N, &D);
	for (int i = 0; i < N; i++) scanf("%lld%lld", &A[i], &B[i]);

	// Meet-in-the-middle Algorithm
	int sep1 = (N >> 1), sep2 = N - sep1;
	vector<long long> sa1(1 << sep1), sb1(1 << sep1);
	vector<long long> sa2(1 << sep2), sb2(1 << sep2);
	for (int i = 0; i < sep1; i++) {
		int b1 = (1 << i), b2 = (1 << (i + 1));
		for (int j = b1; j < b2; j++) {
			sa1[j] = sa1[j - b1] + A[i];
			sb1[j] = sb1[j - b1] + B[i];
		}
	}
	for (int i = 0; i < sep2; i++) {
		int b1 = (1 << i), b2 = (1 << (i + 1));
		for (int j = b1; j < b2; j++) {
			sa2[j] = sa2[j - b1] + A[i + sep1];
			sb2[j] = sb2[j - b1] + B[i + sep1];
		}
	}
	cnt1 = 0;
	for (int i = 0; i < 1 << sep1; i++) {
		int r = (1 << sep1) - i - 1, j = r;
		do {
			// i -> remain, j -> anna, k -> bruno
			int k = r - j;
			vl[cnt1++] = state{ sa1[k] - sa1[j], sb1[k] - sb1[j] };
			j = (j - 1) & r;
		} while (j != r);
	}
	cnt2 = 0;
	for (int i = 0; i < 1 << sep2; i++) {
		int r = (1 << sep2) - i - 1, j = r;
		do {
			// i -> remain, j -> anna, k -> bruno
			int k = r - j;
			vr[cnt2++] = state{ sa2[k] - sa2[j], sb2[k] - sb2[j] };
			j = (j - 1) & r;
		} while (j != r);
	}
	sort(vl, vl + cnt1);
	sort(vr, vr + cnt2);

	// Searching with deque
	int cl = 0, cr = 0, dl = 0, dr = 0;
	long long ret = 0;
	for (int i = cnt2 - 1; i >= 0; i--) {
		while (cr < cnt1 && vl[cr].a + vr[i].a <= D) {
			while ((dr - dl) && vl[que[dr - 1]].b <= vl[cr].b) dr--;
			que[dr++] = cr++;
		}
		while (cl < cnt1 && vl[cl].a + vr[i].a < -D) {
			if ((dr - dl) && que[dl] == cl) dl++;
			cl++;
		}
		if (dr - dl) ret = max(ret, vr[i].b + vl[que[dl]].b);
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 457620
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 600000;
int n, k;
vector < vector < int > > a;
vector < int > b;
bool ok(int x, int y){
    int c = 1;
    int res = 0;
    for (int i = 1; i <= x; i++){
        c = c * k;
        res += c;
        if (res > 5 * y) return 1;
    }
    return (res > 5 * y);
}
int cnt(int x, int len){
    int res = 0;
    int y = 1;
    for (int i = 1; i <= len; i++){
        y *= x;
        res += y;
        //if (res > 1e15) return res;
    }
    return res;
}
int gen(int x, int len, int y){
    if (len == 0) return 0;
    if (y == 0) exit(0);
    for (int i = 1; i <= x; i++){
        int z = 1 + cnt(x, len - 1);
        if (y > z) y -= z; else{
            cout << i << " ";
            gen(x, len - 1, y - 1);
            break;
        }
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> k >> n;
    if (k == 1){
        for (int i = 1; i <= (n + 1) / 2; i++){
            cout << "1 ";
        }
        return 0;
    }
    if (k % 2 == 0){
        cout << k / 2 << " ";
        for (int i = 2; i <= n; i++) cout << k << " ";
        return 0;
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++){
        if (ok(n - i, cnt + 1)){
            cout << (k + 1) / 2 << " ";
            cnt++;
        } else break;
    }
    ll c = 1;
    ll z = 0;
    for (int i = cnt + 1; i <= n; i++){
        c = c * k;
        z += c;
    }
   // cout << cnt << endl;
    c = (z - cnt + 1) / 2;
   // cout << "c = " << c << endl;
    gen(k, n - cnt, c);
}


Measured memory_bytes: 2304
N,M = list(map(int,input().split()))
X = list(map(int,input().split()))

X = sorted(X)

d = []
for i in range(1,len(X)):
    d.append(abs(X[i]-X[i-1]))

d = sorted(d)

print(sum(d[:max(0,len(d)-N+1)]))

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

int main() {
    int N, p, q;
    cin>>N;
    vector<bool> Memo(N, 0);
    vector<vector<int>> T(N, vector<int>(0));
    vector<pair<int, int>> E(N-1,{0,0});
    REP(i, 0, N-1){
        cin>>p>>q;
        E[i].first = p-1;
        E[i].second = q-1;
        T[q-1].push_back(p-1);
        T[p-1].push_back(q-1);   
    }

    map<pair<int, int>, int> I;
    vector<int> CP(N, 0);
    int K = 0;

    Memo[0] = true;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int i = que.front(); que.pop();
        K = max(K, (int)T[i].size());
        int color = 1; 
        for(int x : T[i]){
            if(!Memo[x]){
                if(color == CP[i]) color++;
                CP[x] = color;
                I[make_pair(i, x)] = I[make_pair(x, i)] = color;
                Memo[x] = true;
                que.push(x);
                color++;                                
            }
        }
    }
    cout << K << endl;
    for(auto p: E) cout << I[p] << endl;
    return 0;
}

Measured memory_bytes: 19712
n = int(input())
a = list(map(int,input().split()))
l = [0]*n
l[0] = a[0]

for i in range(1,n):
    l[i] = l[i-1] + a[i]
sum = sum(a)
ans = 10**10+1
for i in range(len(l)-1):
    x = l[i]
    y = sum - l[i]
    tmp = abs(x-y)
    ans = min(ans,tmp)

print(ans)

Measured memory_bytes: 99988
char a[500][501];
int m[500][500];
main(i,j,k,x,y,r,M){
	for(;scanf("%d%d",&y,&x),x;printf("%d\n",r)){
		for(j=0;j<y;j++)scanf("%s",a[j]);
		for(j=0;j<y;j++)for(r=i=0;i<x;m[j][i]=r,i++)if(a[j][i]=='.')r++;else r=0;
		for(r=i=0;i<x;i++)for(j=0;j<y;j++)for(M=99999,k=j;k<y;k++){
			if(M>m[k][i])M=m[k][i];
			if(r<M*(k-j+1))r=M*(k-j+1);
		}
	}
exit(0);}

Measured memory_bytes: 1824
/*
 * VJUDGE B - Collatz Problem
 * author: roy4801
 * (C++)
 */
#include <bits/stdc++.h>

using namespace std;

#define PROB "B"
#define TESTC ""

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
#define F first
#define S second
#define INF 0x3f3f3f3f
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define N 1000000
bool arr[N+5];
int n, cnt; // s, times
int main()
{
	#ifdef DBG
	freopen("./testdata/" PROB TESTC ".in", "r", stdin);
	freopen("./testdata/" PROB ".out", "w", stdout);
	#endif
	while(cin >> n)
	{
		memset(arr, 0, sizeof(arr));
		cnt = 1;
		//
		while(true)
		{
			arr[n] = true;
			if(n & 1) // odd
			{
				n *= 3;
				n += 1;
			}
			else
			{
				n /= 2;
			}

			cnt++;
			if(arr[n])
				break;
		}

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

	return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  vector<pair<int, int>> ab(m);
  REP(i, m) {
    int temp1, temp2; cin >> temp1 >> temp2;
    ab[i].first = temp2; ab[i].second = temp1;
  }
  sort(ALL(ab));
  int ans = 0, right = -1;
  REP(i, m) {
    if (ab[i].second >= right) {
      ++ans;
      right = ab[i].first;
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 1024
template<class T>
bool isPrime(T n){
    if(n==2) return true;
    if(n<2 || n%2==0) return false;
    for(T i=3;i*i<=n;i+=2)
        if(n%i==0) return false;
    return true;
}

#include<iostream>
using namespace std;
int main(){
    int N;
    cin>>N;
    int a=0;
    for(int i=0;i<N;++i){
        int x;
        cin>>x;
        a+=isPrime(x);
    }
    cout<<a<<endl;
}

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

int main() {
  int input, s1, s2, s3;
  
  cin >> input;

  s1 = input / 100;
  s2 = input % 100 / 10;
  s3 = input % 100 % 10; 

  cout << s1 + s2 + s3 << endl;
}

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

using namespace std;
using ll = long long;


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

    int itr = 0;

    while(true){
        bool res = false;
        for(int i = 0; i < n; i++){
            if(a[i] & 1)res = true;
            else a[i]/= 2;
        }
        if(res)break;
        itr++;
    }
    cout << itr << endl;
}

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

using namespace std;

int main(int argc, char const* argv[])
{
	string data;
	string output;

START:
	while( cin >> data ){
		output.clear();
		if( data.size() % 2 ){
			cout << "NA" << endl;
			continue;
		}

		for( int i = 0;i < data .size() / 2;i++ ){
			int j = i * 2;
			data[j] -= '0';
			data[j + 1] -= '0';
			if( data[j] < 1 || data[j + 1] < 1 || data[j] > 6 || data[j + 1] > 5 ){
				cout << "NA" << endl;
				goto START;
			}
			if( data[j] == 6 && data[j + 1] > 1 ){
				if( data[j + 1] == 2 ) output.append(1,'.');
				else if( data[j + 1] == 3 ) output.append(1,'?');
				else if( data[j + 1] == 4 ) output.append(1,'!');
				else if( data[j + 1] == 5 ) output.append(1,' ');
			} else {
				char a = ( data[j] - 1 ) * 5 + data[j + 1] - 1 + 'a';
				output.append(1,a);
			}
		}
		cout << output <<  endl;
	}


	
	return 0;
}

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

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

    string s;
    cin >> s;

    int result = 0;
    for (int i = 0, j = s.size() - 1; i < j; i++, j--) {
        if (s[i] != s[j]) result++;
    }

    cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin>>n;
    vector<int>a(n),b(n);
    for(int i=0;i<n;i++)cin>>a[i];
    b=a;
    sort(b.begin(),b.end(),greater<int>());
    for(int i=0;i<n;i++){
        if(a[i]!=b[0]){
            cout<<b[0]<<endl;

        }
        else {
            cout<<b[1]<<endl;
        }
    }

}


Measured memory_bytes: 3200
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

// #[allow(unused_imports)]
// use std::cmp::*;
pub fn gcd<T>(x: T, y: T) -> T
where
    T: PartialEq + Copy + std::ops::Rem<Output = T> + std::convert::From<u8>,
{
    if y == T::from(0u8) {
        x
    } else {
        gcd(y, x % y)
    }
}

fn main() {
    input!(n: usize, vs: [usize; n]);
    let mut ls = vec![0usize; n + 1];
    let mut rs = vec![0usize; n + 1];

    for i in 0..n - 1 {
        ls[i + 1] = gcd(ls[i], vs[i]);
    }
    for i in (0..n).rev() {
        rs[i] = gcd(rs[i + 1], vs[i]);
    }

    let mut ans: usize = 0;
    for i in 0..n {
        let l = ls[i];
        let r = rs[i + 1];
        ans = max(ans, gcd(l, r));
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 3e5+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

ll fac[maxn], inv[maxn];
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll qpow(ll a,ll k){ll s=1;while(k){if(k&1)s=s*a%mod;a=a*a%mod,k>>=1;}return s;}
ll comb(int n, int m) {
    if(n<m||m<0||n<0) return 0;
    return fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int main() {
    fac[0]=fac[1]=inv[0]=inv[1]=1;
    for(int i=2; i<maxn; ++i) fac[i]=fac[i-1]*i%mod;
    for(int i=2; i<maxn; ++i) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    for(int i=2; i<maxn; ++i) inv[i]=inv[i]*inv[i-1]%mod;
    int n, m; cin>>n>>m;
    printf("%d\n", n*(n-1)/2+m*(m-1)/2);
}

Measured memory_bytes: 4992
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
  int N;
  cin >>N;
  vector<int> CARD = igets(N);
  DSORT(CARD);
  int a=0,b=0;
  for(int i=0;i<N;i+=2)a+=CARD[i];
  for(int i=1;i<N;i+=2)b+=CARD[i];
  
  cout << abs(b-a) << endl;  
}


int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

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

int main(){
    int h; //縦の長さ（行の個数）
    int w; //横の長さ（列の個数）
    cin >> h >> w;

    vector<string> s(h); //グリッド
    for(int i=0; i<h; i++) cin >> s[i];

    vector<vector<int>> l(h,vector<int>(w)); //左側
    vector<vector<int>> r(h,vector<int>(w)); //右側
    vector<vector<int>> d(h,vector<int>(w)); //下側
    vector<vector<int>> u(h,vector<int>(w)); //上側

    //左側の「.」の個数を数える
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[i][j]=='#'){
                l[i][j] = 0;
            }else{
                if(j > 0){
                    l[i][j] = l[i][j-1] + 1;
                }else{
                    l[i][j] = 1;
                }
            }
        }
    }

    //右側の「.」の個数を数える
    for(int i=0; i<h; i++){
        for(int j=1; j<=w; j++){
            if(s[i][w-j]=='#') r[i][w-j] = 0;
            else
                if(j > 1) r[i][w-j] = r[i][w-j+1] + 1;
                else r[i][w-j] = 1;
        }
    }

    //下側の「.」の個数を数える
    for(int i=0; i<w; i++){
        for(int j=1; j<=h; j++){
            if(s[h-j][i]=='#') d[h-j][i] = 0;
            else
                if(j > 1) d[h-j][i] = d[h-j+1][i] + 1;
                else d[h-j][i] = 1;
        }
    }

    //上側の「.」の個数を数える
    for(int i=0; i<w; i++){
        for(int j=0; j<h; j++){
            if(s[j][i]=='#') u[j][i] = 0;
            else
                if(j > 0) u[j][i] = u[j-1][i] + 1;
                else u[j][i] = 1;
        }
    }

    int ans = 0;
    for(int i=0; i<h; i++){
        //cout << i+1 << endl;
        for(int j=0; j<w; j++){
            ans = max(ans,l[i][j]+r[i][j]+d[i][j]+u[i][j]-3);
            //printf("%d列目  l:%d  r:%d  d:%d  u:%d\n",j+1,l[i][j],r[i][j],d[i][j],u[i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 67200
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    sc.close();
    long power=1;
    for(int i=0;i<n;i++){
      power*=(i+1);
      power%=(Math.pow(10,9)+7);
    }
    System.out.println(power);
  }
}

Measured memory_bytes: 23764