akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        boolean containsNine = false;
        for (char num : n.toCharArray()) {
            if (num == '9') containsNine = true;
        }
        if (containsNine) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22612
private class UnionFind(n: Int) {
    val parent = IntArray(n+1)
    val size = IntArray(n+1)

    init {
        repeat(n+1) {
            parent[it] = it
            size[it] = 1
        }
    }
    fun union(par: Int, chi: Int) {
        if (same(par, chi)) return
        val sz = size[root(chi)]
        parent[root(chi)] = par
        size[root(par)] += sz
    }
    fun root(r: Int): Int {
        if (r == parent[r]) return r
        val par = root(parent[r])
        parent[r] = par
        return par
    }
    fun same(a: Int, b: Int): Boolean {
        return root(a) == root(b)
    }
}

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }

    val friend = IntArray(n)

    val uf = UnionFind(n)

    repeat(m) {
        val (a, b) = readLine()!!.split(' ').map { ab -> ab.toInt() }
        friend[a-1] += 1
        friend[b-1] += 1
        uf.union(a, b)
    }
    println(uf.size.max())
}


Measured memory_bytes: 70352
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

using Edge = struct
{
    int to;
    int weight;
};
int p[100'000];

vector<Edge> adj[100'000];

void traverse(int curr)
{
    for (auto e = adj[curr].begin(); e != adj[curr].end(); e++)
    {
        if (p[e->to] == -1)
        {
            p[e->to] = (p[curr] + e->weight) % 2;
            traverse(e->to);
        }
    }
}

int main()
{
    int N;

    cin >> N;
    for (int i = 0; i < N - 1; i++)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;

        Edge e1, e2;
        e1.to = v;
        e1.weight = w;
        e2.to = u;
        e2.weight = w;

        adj[u].push_back(e1);
        adj[v].push_back(e2);
    }

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

    for (int i = 0; i < N; i++)
    {
        cout << p[i] << endl;
    }

    /*for (int i = 0; i < N; i++)
    {
        for (auto it = adj[i].begin(); it != adj[i].end(); it++)
        {
            cout << "edge " << i + 1 << ", " << it->to + 1 << ", " << it->weight << endl;
        }
    }*/

    return 0;
}

Measured memory_bytes: 7552
#include <stdio.h>

int main(){
  int A,B,C,D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
   while(A>0 && C>0){
    C=C-B;
    A=A-D;
   }
  if(C<=0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MD = 1e9+7;
long long n, a[1000005];
int main(){
	scanf("%lld", &n);
	a[1] = n; a[2] = (n*n + n) % MD; a[3] = 3*n*n % MD;
	for(int i = 4; i <= n; i++) a[i] = (a[i-1]*2 - a[i-2] + a[i-3] + 3 - i + n*(n-1)) % MD;
	printf("%lld\n", (a[n] - a[n-1] + MD) % MD);
}

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

typedef long long ll;
ll n, s;
vector<ll> v;

bool func(ll b){
	ll m = n, t = 0;
	while(m){
		t += m % b;
		m /= b;
	}
	return t == s;
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> s;
	if(n < s){
		cout << -1 << "\n";
		return 0;
	}
	if(n == s){
		cout << n+1 << "\n";
		return 0;
	}
	for(int b=2; (ll)b*b<=n; ++b){
		if(func(b)){
			cout << b << "\n";
			return 0;
		}
	}
	for(int p=1; (ll)p*p<n; ++p)
		if((n-s)%p == 0) v.push_back((n-s)/p+1);
	sort(v.begin(), v.end());
	for(int i=0; i<v.size(); ++i){
		if(func(v[i])){
			cout << v[i] << "\n";
			return 0;
		}
	}
	cout << -1 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == 5 && b == 5 && c == 7){
    cout << "YES" << endl;
  }
   else if(a == 5 && b == 7 && c == 5){
    cout << "YES" << endl;
}
   else if(a == 7 && b == 5 && c == 5){
    cout << "YES" << endl;
}
   else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3584
#include <stdio.h>
int main(void)
{
  int A,B;
  int sum=0,i;
  scanf("%d %d", &A, &B);
  for(i=0;i<2;i++){
    if(A>=B){
      sum+=A;
      A=A-1;
    }
    else{
      sum+=B;
      B=B-1;
    }
  }
    printf("%d", sum);
  return 0;
}

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


int main(){
  ll N, P = 1000000000 + 7;; 
  cin >> N;
  vector<ll> A(N), XA(N+1);
  for(ll i = 0; i < N; i++){
    cin >> A[i];
    XA[i+1] = XA[i] + A[i];
  }
  ll ans = 0;
  for(ll i = 0; i < N - 1; i++) {
    ans += (A[i] * ((XA[N] + P - XA[i+1]) % P)) % P;
    ans = ans % P;
  }
  cout <<ans << endl;
}


Measured memory_bytes: 6404
N = int(input())
H = list(map(int, input().split()))
flag = True

for i in range(N-1):
  if H[i] - H[i+1] == 1:
    H[i+1]+= 1
  elif H[i] - H[i+1] > 1:
    flag = False
    break

if flag:
  print("Yes")
else:
  print("No")
    
  

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

double S(double a, double b, double c, double d, double e, double f) {
	double ans;
	ans = abs((a*1000 - e*1000) * (d*1000 - f * 1000) - (b * 1000 - f * 1000) * (c * 1000 - e * 1000));
	return ans;
}

int main(){
	double x[4], y[4], s[3], SS, SSS;

	while(true){
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];
		if (cin.eof()) { break; }
		s[0] = S(x[0], y[0], x[1], y[1], x[3], y[3]);
		s[1] = S(x[0], y[0], x[2], y[2], x[3], y[3]);
		s[2] = S(x[1], y[1], x[2], y[2], x[3], y[3]);
		if(s[0] * s[1] * s[2] == 0){ 
			cout << "NO" << endl;
			continue;
		}
		SS = s[0] + s[1] + s[2];
		SSS = S(x[0], y[0], x[1], y[1], x[2], y[2]);

		if (SS == SSS) { cout << "YES" << endl; }
		else { cout << "NO" <<  endl; }
	}
	return 0;
}

Measured memory_bytes: 3156
#include<stdio.h>
long long int a[600000]={0};
#define mod 1000000007
int main()
{
	long long int n,i,j,s,ans,d;
	scanf("%lld",&n);
	for(i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		
	} 
	d=1;ans=0;
	for(i=0;i<60;i++)
	{
		s=0;
		for(j=1;j<=n;j++)
		{

			if(a[j]&1)
			s++;
			a[j]>>=1;
		}

		ans+=((s*(n-s)%mod)*d)%mod;
		d*=2;
		d%=mod;
	}
	printf("%lld\n",ans%mod);
 } 

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

int main()
{
  int H;
  int N;
  int A;

  cin >> H >> N;
  for (int i = 0; i < N; i++)
  {
    cin >> A;
    H -= A;
  }

  if (H <= 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
  int n;
  for(;cin>>n,n;)
    {
      int data[n][n];
      bool flag[2][n][n];
      memset(flag,false,sizeof(flag));
      for(int i=0;i<n;i++)
	{
	  int minnum=999999;
	  for(int j=0;j<n;j++)
	    {
	      cin>>data[i][j];
	      minnum=min(minnum,data[i][j]);
	    }
	  for(int j=0;j<n;j++)
	    {
	      if(minnum==data[i][j])
		flag[0][i][j]=true;
	    }
	}
      for(int j=0;j<n;j++)
	{
	  int maxnum=-1;
	  for(int i=0;i<n;i++)
	    maxnum=max(maxnum,data[i][j]);
	  for(int i=0;i<n;i++)
	    if(maxnum==data[i][j])
	      flag[1][i][j]=true;
	}

      int ans=0;
      for(int i=0;i<n;i++)
	  for(int j=0;j<n;j++)
	    {
	      if(flag[0][i][j]&&flag[1][i][j])
		{
		  ans=max(ans,data[i][j]);
		}
	    }
	      cout<<ans<<endl;
    }
}

Measured memory_bytes: 1172
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<int> P(N);
  rep(i,N) cin>>P[i];

  vector<int> num(N+1,0);
  for(int i=0;i<N;i++){
    if(P[i]==1) num[1]=1;
    else num[P[i]]=num[P[i]-1]+1;
  }

  int ma=1;
  for(int i=1;i<=N;i++) ma=max(ma,num[i]);
  cout<<N-ma<<endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;

/*?????????????´???????????????????*/

void trace(int A[], int N) {
    int i;
    for (i=0; i <N; i++){
        if(i >0){
            cout << " ";
        }
            cout << A[i];
    }
    cout << endl;
}

/*?????\????????????0?????????????????????*/

void insertionSort(int A[], int N) {
    int j, i, v;
    for ( i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A,N);
        
    }
}
int main(int argc, const char * argv[]) {
    
    int N;
    int A[100];
    
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    
    trace(A,N);
    insertionSort(A, N);
    
    return 0;
}

Measured memory_bytes: 3100
/*
   Author : tarang
*/
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
const int MOD = 1000000007;
#define PI = acos(-1)
using namespace std ;
int a[106];
vector<int> v[100005];
vector<int> vis(100005);
map<ll,ll> mp;
int gcd(int x, int y)
{                     
        return (x==0)? y : gcd(y % x, x);
}
void dfs(int node){
	 vis[node]= 1;
	 for(auto child : v[node]){
	 	if(!vis[child])
	 	   dfs(child);
	 }
}
int main(){
   int N , M ;
   cin >> N >> M ;
   for(int i = 0 ; i < M ; i++){
   	     int x , y ; 
		cin >> x >> y ;
   	    v[x].push_back(y);
   	    v[y].push_back(x);
   }
   ll count =0;
   for(int i = 1 ; i <=N ; i++){
   	   if(!vis[i])
   	   {
   	   	    dfs(i);
   	   	    count++;
		  }
   }
   cout << (count -1) << endl;
}


Measured memory_bytes: 9540
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	n := scanInt()
	m := scanInt()

	card := make([][]int,n)

	for i:=0; i<m; i++ {
		x := scanInt() - 1
		y := scanInt() - 1
		_ = scanInt()

		card[x] = append(card[x], y)
		card[y] = append(card[y], x)
	}

	ans := 0
	f := make([]bool,n)
	for i:=0; i<n; i++ {
		f[i] = false
	}

	for i:=0; i<n; i++ {
		if f[i] {
			continue
		}

		q := make([]int,0)
		q = append(q, i)

		f[i] = true
		for ;len(q)!=0; {
			a := q[0]
			q = q[1:]
			for _,e := range card[a] {
				if f[e] {
					continue
				}
				q = append(q, e)
				f[e] = true
			}
		}

		ans++
	}

	fmt.Println(ans)

}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int a,b;
  cin >> a >> b;
  cout <<( (a*b)&1 ? "Odd" : "Even" ) << endl;
  return 0;
}

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

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;

#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define int long long
#define sz(v) (int)v.size()
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define f(i,l,r) for(long long i=l;i<=r;i++)
#define rf(i,r,l) for(long long i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }


const int N=1e5+5,mod=1e9+7,bit=61;


signed main()
{
    fast;

    int t=1;
    //cin>>t;
    f(tc,1,t)
    {
        ll d,tm,s;
        cin>>d>>tm>>s;
        ll dc=tm*s;
        if(dc>=d)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
from collections import Counter
N=int(input())
A=Counter(sorted(list(map(int,input().split()))))
A=[[i,A[i]] for i in A if A[i]>=2]
A.sort(reverse=True)
try:
    if A[0][1]>=4:
        print(A[0][0]**2)
    else:
        print(A[0][0]*A[1][0])
except:
    print(0)


Measured memory_bytes: 70040
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod 1000000007
int main() {
    fio;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    if (n < 1000) {
        cout << 1000 - n;
    }
    else if (n % 1000 != 0) {

        ll x = n / 1000;
        cout << (x + 1) * 1000 - n;
    }
    else {
        cout << "0";
    }
}

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

#define int long long

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n; cin>>n;
    vector<pair<int, int> > adj[n+3];
    for (int i = 0; i < n-1; i++)
    {
        int a, b, c; cin>>a>>b>>c;
        adj[a].push_back({b,c});
        adj[b].push_back({a,c});
    }

    int q, k; cin>>q>>k;

    // dfs
    stack<int> s;
    int dist[n+3] = {};
    dist[k] = 1;
    s.push(k);
    while (!s.empty())
    {
        int x = s.top(); s.pop();
        for (auto y: adj[x])
        {
            if (!dist[y.first])
            {
                dist[y.first] = dist[x] + y.second;
                s.push(y.first);
            }
        }
    }

    while (q--)
    {
        int x, y; cin>>x>>y;
        cout<<dist[x] + dist[y] - 2<<endl;
    }
}


Measured memory_bytes: 12060
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define endl '\n'
#define mod 1000000007
#define mod1 1000000009
#define line cout<<"----------------------"<<endl
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll   mx=100009;
int  main()
{
    int d;
    cin>>d;
    double ans=d/3.0;
    ans=ans*ans*ans;
    printf("%.10f\n",ans);

}


Measured memory_bytes: 256
N,K = map(int, input().split())
MOD = 10**9 + 7

def pow_mod(x, n):
    if n == 0:
        return 1
    elif n % 2 == 0:
        return pow_mod(x * x % MOD, n // 2) % MOD
    else:
        return x * pow_mod(x * x % MOD, n // 2) % MOD

fact = [1]
for i in range(1,N+1):
    fact.append( (fact[i-1] * i) % MOD )
inv = [1] * (N+1)
inv[N] = pow_mod(fact[N], MOD-2)
for i in range(N, 1, -1):
    inv[i-1] = inv[i] * (i) % MOD

def cmb_mod(n,r):
    if n == r == 0:
        return 1
    elif n < r:
        return 0
    else:
        return fact[n] * inv[r] * inv[n-r] % MOD

for i in range(1, K+1):
    ans = cmb_mod(N-K+1, i) * cmb_mod(K-1, i-1) % MOD
    print(ans)


Measured memory_bytes: 42736
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        StringBuilder str = new StringBuilder();
        while (scanner.hasNext()) {
            String s = scanner.nextLine();
            //System.out.println(s);
            str.append(s.toUpperCase());
        }
        System.out.println(str);
    }
}

Measured memory_bytes: 17124
function main()
  
  (N, K) = map(x -> parse(Int, x), split(readline()))
  D = collect(replace(chomp(readline()), " ", ""))
  
  check = Set(D)
  
  ans = N
  ans_check = Set(collect(string(N)))
  
  while intersect(ans_check, check) != Set([])
    
    ans += 1
    ans_check = Set(collect(string(ans)))
    
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 153480
#include<cstdio>
#include<queue>
using namespace std;
int f[200050],a[200050],n;
bool inq[200050];
inline int lst(int x){return x-1==0?n:x-1;}
inline int nxt(int x){return x+1>n?1:x+1;}
struct node{
	int p;
	node(){}
	node(int p):p(p){}
};
queue<node> Q;
inline bool check(int i){return a[i]>f[i]&&a[i]-f[i]>=a[lst(i)]+a[nxt(i)];}
int main(){
	int i,t1,t2;
	long long ans=0ll;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",f+i);
	for(i=1;i<=n;++i){
		scanf("%d",a+i);
		if(a[i]<f[i]){
			puts("-1");
			return 0;
		}
	}
	for(i=1;i<=n;++i)if(check(i))Q.push(node(i)),inq[i]=1;
	while(!Q.empty()){
		i=Q.front().p;Q.pop();inq[i]=0;
		t1=a[i]-f[i];
		t2=a[lst(i)]+a[nxt(i)];
		ans+=t1/t2;
		a[i]=f[i]+t1%t2;
		if(!inq[lst(i)]&&check(lst(i)))Q.push(lst(i)),inq[lst(i)]=1;
		if(!inq[nxt(i)]&&check(nxt(i)))Q.push(nxt(i)),inq[nxt(i)]=1;
	}
	for(i=1;i<=n;++i)if(f[i]!=a[i]){
		puts("-1");
		return 0;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2432
n=int(input())
b=input().split()
s=b[:]
for i in range(n):
    for j in range(n-1,i,-1):
        if b[j][1]<b[j-1][1]:b[j],b[j-1]=b[j-1],b[j]
    m=i
    for j in range(i,n):
        if s[m][1]>s[j][1]:m=j
    s[m],s[i]=s[i],s[m]
print(*b)
print('Stable')
print(*s)
print(['Not stable','Stable'][b==s])

Measured memory_bytes: 7648
#include<bits/stdc++.h>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
#define gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define VI vector<int>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
ll n,k;
int main(){
    cin>>n>>k;
    if(n%k==0)cout<<0<<endl;
    else if(n<k)cout<<min(n,k-n);
    else cout<<min(n%k,k-(n%k));
	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 1000000 + 10;

int arr[nax];
int main()
{
    ios::sync_with_stdio(0);
    ll n, t;
    cin >> n >> t;

    ll ans = 0;
    ll curans = 0;
    ll prev;
    for(int i = 1; i <= n; i++)
    {
      cin >> arr[i];
    }
    for(int i =1 ; i <= n; i++)
    {
        int start = arr[i];
        while(arr[i] + t >= arr[i + 1] && i < n)
            i++;
        ans += arr[i] + t - start;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, p, ans;
  vector<int> v;
  cin >> n;

  for(int i=0;i<n;i++){
    cin >> p;
    v.push_back(p);
  }
  sort(v.begin(), v.end());
  ans = v[n-1]/2;
  for(int i=0;i<n-1;i++){
    ans += v[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
main(){
//Si la distancia entre Alice y Borys en impar, Borys gana.
//Esto es porque al iniciar Alice, la distancia impar le permite
//"Empujar" a Borys hasta uno de los bordes del tablero

	int s,a,b;
	cin>>s>>a>>b;
	cout<<((b-a)%2?"Borys":"Alice");

}


Measured memory_bytes: 256
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
if a+b+c+d == 7:
    print(s[0]+'+'+s[1]+'+'+s[2]+'+'+s[3]+'=7')
    exit()
if a+b+c-d == 7:
    print(s[0]+'+'+s[1]+'+'+s[2]+'-'+s[3]+'=7')
    exit()
if a+b-c+d == 7:
    print(s[0]+'+'+s[1]+'-'+s[2]+'+'+s[3]+'=7')
    exit()
if a+b-c-d == 7:
    print(s[0]+'+'+s[1]+'-'+s[2]+'-'+s[3]+'=7')
    exit()
if a-b+c+d == 7:
    print(s[0]+'-'+s[1]+'+'+s[2]+'+'+s[3]+'=7')
    exit()
if a-b+c-d == 7:
    print(s[0]+'-'+s[1]+'+'+s[2]+'-'+s[3]+'=7')
    exit()
if a-b-c+d == 7:
    print(s[0]+'-'+s[1]+'-'+s[2]+'+'+s[3]+'=7')
    exit()
if a-b-c-d == 7:
    print(s[0]+'-'+s[1]+'-'+s[2]+'-'+s[3]+'=7')
    exit()

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using console=System.Console;
namespace AtCoderTemplate
{
    public class App
    {
        public static void Main(string[] args)
        {
            args=new string[2];
            args[0] = console.ReadLine();
            if(args[0].Count()==26)
            {
                 var q = 25 - args[0].Skip(1).Zip(args[0],(a,b)=>a-b).Reverse().TakeWhile(i=>i<0).Count();
                 if(q==0)
                 console.WriteLine(-1);
                 else
                 {
                 var s = args[0].Take(q).ToArray();
                 s[q-1]=args[0].Last(c=>c>s[q-1]);
                 console.WriteLine(s);
                 }
            }
            else
                console.WriteLine(args[0] +(char)('a'+ args[0].OrderBy(c=>c).Where((c,i)=>c-i=='a').Count()));
        }
    }
}

Measured memory_bytes: 13396
L = []
for i in range(10):
    a = int(input())
    L.append(a)
    N = sorted(L)
A = (N[len(N) - 1]) + (N[len(N) - 2]) + (N[len(N) - 3])

l = []
for i in range(10):
    b = int(input())
    l.append(b)
    M = sorted(l)
B = (M[len(M) - 1]) + (M[len(M) - 2]) + (M[len(M) - 3])

print( A , end = " ")
print( B )


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N; cin >> N;
	vector<string> s(N);
	vector<int> t(N);

	REP(i,N) cin >> s[i] >> t[i];
	string X; cin >> X;

	bool ap = false;
	int ans = 0;
	REP(i,N){
		if(ap) ans += t[i];
		if(s[i] == X) ap = true;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> multi_vector(size_t a){return vector<T>(a);}template<class T, class... Ts>auto multi_vector(size_t a, Ts... ts){return vector<decltype(multi_vector<T>(ts...))>(a, multi_vector<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

ll dfs(ll l, ll s){
  ll tmp{};
  if(l == 1){
    if(s == 1) return 0;
    if(s == 2) return 1;
    if(s == 3) return 2;
    if(s == 4) return 3;
    if(s == 5) return 3;
  }
  if(s > pow(2,l+2)-4) return pow(2,l+1)-1;
  if(s>0 && pow(2,l+1)-2>=s) tmp += dfs(l-1, min((ll)pow(2,l+1)-3, s-1));
  if(s>pow(2,l+1)-2) tmp += pow(2,l);
  if(s>pow(2,l+1)-1) tmp += dfs(l-1, s-pow(2,l+1)+1);
  // cout << l << sp <<tmp << rt;
  return tmp;
}

int main(){
  fastio;
  ll N, X;
  cin >> N >> X;
  cout << dfs(N, X) << rt;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B ;
  int ans;
  if (A > B) {
    ans = A + (A-1);
  }
  else if (B > A){
    ans = B + (B-1);
  }
  else {
    ans = A + B;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int dx=x2-x1,dy=y2-y1;
  int y4=dx+y1;
  int x4=-dy+x1;
  int x3= x4+dx;
  int y3=y4+dy;
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3548
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

std::string S;

const int MAX_N = 1e5 + 10;

std::vector<int> vec;
int num[MAX_N];

int main(int argc, char **argv) {
    std::cin >> S;

    rep (i, 0, S.size() - 1) {
        if (S[i] == 'R' && S[i+1] == 'L') {
            vec.push_back(i);
        }
    }

    for (int i : vec) {
        int j = 0;
        while (0 <= i - j && S[i - j] == 'R') {
            num[i + (j % 2)]++;
            j++;
        }
        j = 1;
        while (i + j < S.size() && S[i + j] == 'L') {
            num[i + (j % 2)]++;
            j++;
        }
    }

    rep (i, 0, S.size() - 1) {
        std::cout << num[i] << " ";
    }

    std::cout << std::endl;


    
    
    

    return 0;
}

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

int main(){

string s;
cin>>s;

for(int i=0,j=s.length()-1;i<j;i++,j--)
if( s[i]!=s[j] ){
    cout<<"No"<<endl;
    return 0;
}

cout<<"Yes"<<endl;
return 0;
}


Measured memory_bytes: 256
/*
 * 17-1-7_ABC051_A.cpp
 *
 *  Created on: 2017/01/07
 *      Author: ryoma
 */

#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

string ans;
int main(){
	for(int i=0;i<19;i++){
		char c;
		cin >> c;
		if(c==',')
			c=' ';
		ans += c;
	}
	cout << ans <<endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::min;
using std::max;
using std::fill;

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

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const long long MOD = 1e9 + 7;

const long long inf = 1e18;
const long long infsmart = 1e12;

ll n, k;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    S s;
    cin >> s;
    sort(all(s));
    if (s == "abc")
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}


Measured memory_bytes: 256
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int R,G;cin >> R >>G;
    cout << 2*G - R << endl;
  
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,d,e,f,i,j,x[3001]={0},y[3001]={0},m,n;
  double p=-1;
  scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);a*=100;b*=100;f++;
  for(i=0;i*a<f;i++)for(j=0;i*a+b*j<f;j++)x[i*a+j*b]=1;
  for(i=0;i*c<f;i++)for(j=0;i*c+d*j<f;j++)y[i*c+j*d]=1;
  for(i=1;i<f;i++)if(x[i])for(j=0;j<=e*i/100;j++)if(y[j]&&p<(double)j/(i+j)&&i+j<f){p=(double)j/(i+j);m=i+j;n=j;}
  printf("%d %d",m,n);
}


Measured memory_bytes: 1728
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000
#define NMAX 52
#define MMAX 52

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef long long ll;
typedef pair<int ,int > P;

struct edge{
  int to,cost;
};
int A[MMAX],B[MMAX],C,N,M,W,H,ans = 0,dp[HMAX][WMAX];
string S;
vector<int> g[NMAX];
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

bool judge(int a){
	int yet[NMAX] = {};
	int s = A[a], f = B[a];
	queue<int> que;
	que.push(s);
	while(!que.empty()){
		int q = que.front();que.pop();
		for (int i = 0; i < g[q].size(); ++i)
		{
			if((q != s || g[q][i] != f) && yet[g[q][i]] == 0){
				if(g[q][i] == f){
					return true;
				}
				que.push(g[q][i]);
				yet[g[q][i]] = 1;
			}
		}
	}
	return false;
}

void solve(){
	for (int i = 0; i < M; ++i)
	{
		if(!judge(i)) ans++;
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N >> M;
	for (int i = 0; i < M; ++i)
	{
		cin >> A[i] >> B[i];
		g[A[i]].push_back(B[i]);
		g[B[i]].push_back(A[i]);
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

const string YES = "Yes";
const string NO = "No";

void func(long long N, long long A, long long B, std::string S){

    lli a=0,b=0;

    REP(i,0,S.size()){
        if(S.at(i)=='a'){
            if((a+b)< (A+B)){
                cout<<"Yes"<<endl;
                a++;
            }
            else cout<<"No"<<endl;
        }
        else if(S.at(i)=='b'){
            if( (a+b)<(A+B) && (b<B)){
                cout<<"Yes"<<endl;
                b++;
            }
            else cout<<"No"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    std::string S;
    std::cin >> S;
    func(N, A, B, S);
    return 0;
}


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

int main()
{
	int r,c;
	cin >> r >> c;

	string matrix[r];
	for (int i = 0; i < r; ++i)
	{
		cin >> matrix[i];
	}	

	for (int i = 0; i < r; ++i)
	{
		for (int j = 0; j < c; j++)
		{
			if (matrix[i][j] == '#')
				cout << '#';
			else
			{
				int count = 0;
				if (i-1 >= 0)
				{
					matrix[i-1][j] == '#' ? count++ : count;
					if (j-1 >= 0)
						matrix[i-1][j-1] == '#' ? count++ : count;
					if (j+1 < c)
						matrix[i-1][j+1] == '#' ? count++ : count;
				}
				if (j-1 >= 0)
				{
					matrix[i][j-1] == '#' ? count++ : count;
				}
				if (j+1 < c)
				{
					matrix[i][j+1] == '#' ? count++ : count;
				}
				if (i+1 < r)
				{
					matrix[i+1][j] == '#' ? count++ : count;
					if (j-1 >= 0)
						matrix[i+1][j-1] == '#' ? count++ : count;
					if (j+1 < c)
						matrix[i+1][j+1] == '#' ? count++ : count;
				}
				cout << count;
			}
			
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
while true do
   inputs = gets.split
   if inputs[1] == '?'
      break
   else
      a = inputs[0].to_i
      op = inputs[1]
      b = inputs[2].to_i
      case op
      when '+' then
         puts "#{a + b}"
      when '-' then
         puts "#{a - b}"
      when '*' then
         puts "#{a * b}"
      when '/' then
         puts "#{(a / b).floor}"
      end
   end
end

Measured memory_bytes: 8640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[10];
	for(int b=0;b<10;b++)
	cin>>a[b];
	for(int i=0;i<10000000;i++)sort(a,a+10);
	for(int c =9;c>=7;c--)
	cout<<a[c]<<endl;
	}

Measured memory_bytes: 3116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		int[] unsortArray = initArray();
		//int[] unsortArray = new int[]{5,2,4,6,1,3};
		sort(unsortArray);
	}

	private static void sort(int[] unsortArray) {
		int sortedIndex = 0;
		for (int i=0; i < unsortArray.length; i++) {
			int newValue = unsortArray[i];
			int checkIdx = i;
			for (int j=0; j <= sortedIndex; j++) {
				int sortedValue = unsortArray[j];
				if (newValue < sortedValue) {
					while(checkIdx > j) {
						unsortArray[checkIdx] = unsortArray[checkIdx-1];
						checkIdx--;
					}
					unsortArray[j] = newValue;
					break;
				}
			}
			sortedIndex = i;
			dumpArray(unsortArray);
		}

	}

	private static void dumpArray(int[] array) {
		StringBuilder builder = new StringBuilder();
		for(int i=0; i<array.length; i++) {
			if (i != 0) {
				builder.append(" ");
			}
			builder.append(array[i]);
		}
		System.out.println(builder.toString());
	}
	private static int[] initArray() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String numStr = br.readLine();
		int arrayNum = Integer.parseInt(numStr);
		if (arrayNum < 0 || arrayNum > 100) {
			throw new IllegalArgumentException("0 <= num <= 100");
		}
		String arrayStr = br.readLine();
		String[] values = arrayStr.split(" ");

		int[] unsortArray = new int[arrayNum];

		if (values.length !=  arrayNum) {
			throw new IllegalArgumentException("input line is illegal");
		}

		for (int i=0; i< arrayNum; i++) {
			int value = Integer.parseInt(values[i]);
			validateValue(value);
			unsortArray[i] = value;
		}
		return unsortArray;
	}
	private static void validateValue(int value) {
		if (value < 0 || value > 1000) {
			throw new IllegalArgumentException("value is invalid");
		}
	}
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    ll n = s.length();
    bool c = false, f = false;

    rep(i, n) {
        if (!c) {
            if (s[i] == 'C') {
                c = true;
            }
        } else {
            if (s[i] == 'F') {
                f = true;
            }
        }
    }
    if (c && f) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>
int main(void) {
	int n, m;
	char ans[11], str[11], snuke[11] = "snuke";
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			scanf("%s", str);
			if (!strcmp(str, snuke)) {
				ans[0] = j - 1 + 'A';
				ans[1] = i;
			}
		}
	}
	printf("%c%d", ans[0], ans[1]);
}

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

#define ll long long
#define pb push_back

vector<int>g[100003];
vector<int>v(100003);
queue<int>q;

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









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

#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)

int n, a;
int p[3][100];
int s[200] = {};

int main() {
	ios::sync_with_stdio(false);
	
	cin>>n;
	rep(i, n) {
		rep(j, 3) {
			int a;
			cin>>a;
			a--;
			if(p[j][a]==0)p[j][a]=i+1;
			else if(p[j][a]>0)p[j][a]=-1;
		}
	}
	
	rep(i, 100) {
		rep(j, 3) {
			if(p[j][i]>0)s[p[j][i]-1]+=i+1;
		}
	}
	rep(i, n)cout<<s[i]<<endl;
	
	return 0;
}

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

#define MOD (1000000000+7)

int main() {
	int N, M;

	cin >> N >> M;
	vector<int> a( N + 1 );
	for( int i = 0; i < M; i++ ) {
		int j;
		cin >> j;
		a[j]++;
	}

	vector<long long> dp( N + 1 );
	dp[0] = 1;
	for( int i = 0; i < N; i++ ) {
		for( int j = i + 1; j <= min( i + 2, N ); j++ ) {
			if( a[j] == 0 ) {
				dp[j] += dp[i];
				dp[j] %= MOD;
			}
		}
	}
	long long ans = dp[N];

	cout << ans << endl;

	return 0;
}


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

int main() {
	int n;
	cin >> n;
	int p[100] = {};

	for (int i = 0;i < n*(n - 1) / 2;i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		if (c > d)p[a - 1] += 3;
		else if (c < d)p[b - 1] += 3;
		else {
			p[a - 1]++;
			p[b - 1]++;
		}
	}
	int ans[100];
	for (int i = 0;i < n;i++) {
		int a = 0;
		for (int j = 0;j < n;j++) {
			if (p[i] < p[j])a++;
		}
		ans[i] = a + 1;
	}
	for (int i = 0;i < n;i++)cout << ans[i] << endl;
	return 0;
}

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

int main() {
	int a,b,c=0,i,n,m,l,x,y;
	cin>>a>>b;
	for(i=a;i<=b;i++){
		n=i%10;
		m=(i/10)%10;
		l=(i/100)%10;
		x=(i/1000)%10;
		y=i/10000;
		if(n==y&&m==x)c++;
	}
	cout<<c;
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

signed main() {
    int n, m;
    cin>>n>>m;
    vi a(n);
    int sum = 0;
    rep(i,n) {
        cin>>a[i];
        sum += a[i];
    }
    sort(a.rbegin(), a.rend());
    if(a[m-1] * 4 * m >= sum) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        long n = in.ni(), k = in.ni();
        long ans = 1;
        for (long i = k; i <= n; i++) {
            ans += i*(n-i+1)+1;
            ans %= mod;
        }
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll n,m,q;
	cin >> n >> m >> q;

	string st[n];
	rep(i,n) cin >> st[i];

	ll s[n][m];
	rep(i,n) rep(j,m) s[i][j] = (st[i][j] == '1' ? 1 : 0);

	ll b[n+1][m+1] = {};
	rep(i,n){
		rep(j,m){
			b[i+1][j+1] = b[i+1][j] + b[i][j+1] - b[i][j] + s[i][j];
		}
	}

	ll v[n+1][m+1] = {};
	FOR(i,1,n){
		rep(j,m){
			v[i+1][j+1] = v[i+1][j] + v[i][j+1] - v[i][j] + (s[i][j] & s[i-1][j]);
		}
	}

	ll h[n+1][m+1] = {};
	rep(i,n){
		FOR(j,1,m){
			h[i+1][j+1] = h[i+1][j] + h[i][j+1] - h[i][j] + (s[i][j] & s[i][j-1]);
		}
	}

	rep(i,q){
		ll x1,y1,x2,y2;
		cin >> x1 >> y1 >> x2 >> y2;

		ll bb = b[x2][y2] - b[x1-1][y2] - b[x2][y1-1] + b[x1-1][y1-1];
		ll vv = v[x2][y2] - v[x1][y2] - v[x2][y1-1] + v[x1][y1-1];
		ll hh = h[x2][y2] - h[x1-1][y2] - h[x2][y1] + h[x1-1][y1];

		cout << (bb - vv - hh) << endl;
	}

}

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

int main()
{
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int max = -1, min = 10000, sum = 0, score = 0, ans = 0;
        for(int i = 0; i < n; i++){
            cin >> score;
            sum += score;
            if(score > max) max = score;
            if(score < min) min = score;
        }
        sum -= max + min;
        ans = sum / (n - 2);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160