akhauriyash/Code-Regression huggingface dataset:
/**
 * @author aviral0807
 * IIT (BHU) Varanasi
 */

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define	endl        '\n'
#define pi          pair<int, int>
#define pii         pair<int, pi>
#define vi          vector<int>
#define vpi         vector<pi>
#define si          set<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define inv(i,a,b)  for(int i=a;i>=b;i--)
#define mp          make_pair
#define isp(x, i)   ((x).find(i)!=x.end())

using namespace std;

#define N  100005

int a[3*N], in[2*N], out[2*N];


void solve() {
	int n; cin >> n;
	rep(i,1,3*n+1) {
		cin >> a[i];
	}
	multiset<int> s1;

	int sum = 0;
	rep(i,1,n+1) {
		s1.insert(a[i]);
		sum += a[i];
	}
	in[0] = sum;
	for(int i=n+1; i<=2*n; i++) {
		sum += a[i];
		s1.insert(a[i]);

		sum -= *s1.begin();
		s1.erase(s1.begin());

		in[i-n] = sum;
	}

	multiset<int, greater<int>> s2;
	sum = 0;
	rep(i,2*n+1,3*n+1) {
		s2.insert(a[i]);
		sum += a[i];
	}
	out[0] = sum;
	for(int i=2*n; i>=n+1; i--) {
		sum += a[i];
		s2.insert(a[i]);

		sum -= *s2.begin();
		s2.erase(s2.begin());

		out[2*n-i+1] = sum;
	}

	int ans = -1e18;
	for(int i=0; i<=n; i++) {
		ans = max(ans, in[i] - out[n-i]);
	}

	cout << ans;
}

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

	int t=1;
	// cin>>t;
	while (t--) {
		solve();
	}
	return 0;
}

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

int main (){
    int N;
    cin >> N;
    char color[N];
    int count =0;
    for (int i = 0; i < N; i++){
        cin >> color[i];
        if (color[i] == 'R'){
            count++;
        }
    }
    if (count > N-count){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n, sum = 0;
	char a[50];
	scanf("%d", &n);
	scanf("%s", a);
	for (int i = 0; i < n - 2; i++)
	{
		if (a[i] == 'A')
		{
			if (a[i + 1] == 'B' && a[i + 2] == 'C')
			{
				sum++;
				i = i + 2;
				continue;
			}
		}
	}
	printf("%d", sum);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct edge{
    int to,a,b;
};
vector<edge> e[50];
ll d[300000]={},cc[50],dd[50];

using U=ll;
inline void dkstr(int n,int s,U inf){
    fill(d,d+n*6000,inf);
    chmin(s,5999);
    d[s]=0;
    priority_queue<pair<U,int>,vector<pair<U,int>>,greater<pair<U,int>>> pq;
    pq.emplace(0,s);
    while(!pq.empty()){
        pair<U,int> p=pq.top();pq.pop();
        U D=p.first;
        int I=p.second;
        int i=I/6000,j=I%6000;
        if(d[I]<D) continue;
        if(d[i*6000+min(5999ll,j+cc[i])]>D+dd[i]){
            d[i*6000+min(5999ll,j+cc[i])]=D+dd[i];
            pq.emplace(D+dd[i],i*6000+min(5999ll,j+cc[i]));
        }
        for(auto[to,a,b]:e[i]){
            if(a>j) continue;
            if(d[to*6000+j-a]<=D+b) continue;
            d[to*6000+j-a]=D+b;
            pq.emplace(D+b,to*6000+j-a);
        }
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,s;
    cin>>n>>m>>s;
    fr(i,m){
        int u,v,a,b;
        cin>>u>>v>>a>>b;
        --u,--v;
        e[u].push_back(edge{v,a,b});
        e[v].push_back(edge{u,a,b});
    }
    fr(i,n) cin>>cc[i]>>dd[i];
    dkstr(n,s,1ll<<60);
    vector<ll> ans(50,1ll<<60);
    Fr(i,n-1){
        fr(j,6000) chmin(ans[i],d[i*6000+j]);
        cout<<ans[i]<<'\n';
    }

}

Measured memory_bytes: 9728
using System;
using System.Collections.Generic;

class ABC_127_B
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int r = int.Parse(input[0]);
        int D = int.Parse(input[1]);
        int x = int.Parse(input[2]);

        for (int i = 0; i < 10; i++)
        {
            x = r * x - D;

            Console.WriteLine(x);
        }
    }
}

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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

const int dx[]={1,-1,0,0},
		  dy[]={0,0,1,-1};

const int inf=1e9;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans,sz[N];

char s[N];

void IO(){
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

int main(){
	//IO();
	ll ans=0;
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	for(int i=0;i<n-k;i++)
		ans+=a[i];
	printf("%lld\n",ans);
}


Measured memory_bytes: 4352
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))
from collections import defaultdict


def main():
    n, m = map(int, input().split())
    a = []
    for _ in range(n):
        a.append(list(map(int, input().split())))
    
    if m==1:
        print(n)
        return
    
    sports = [1 for _ in range(m)]
    ans = 10**18
    for _ in range(m-1):
        sdic = defaultdict(lambda: 0)
        for _al in a:
            for _a in _al:
                if sports[_a-1] == 1:
                    sdic[_a] += 1
                    break
        tmp = list(sorted(sdic.items(), key=lambda x: x[1]))[-1]
        ans = min(ans, tmp[1])
        sports[tmp[0]-1] = 0
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 47580
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int N, L;
	cin >> N >> L;

	vector<string> S(N);

	for (int i = 0; i < N;i++) {
		cin >> S.at(i);
	}

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

	for (int i = 0; i < S.size();i++) {
		cout << S.at(i);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << "-- " << __LINE__ << " --" << endl
#define MOD 1000000007
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
template <typename T> string to_string(const vector<T> &xs) {string s="["; for(int i=0;i<xs.size();i++) s += (i>0 ? " " : "") + to_string(xs[i]); return s + "]";}



ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}






int main(void){
	
	int r; cin >> r; cout << r * r << endl;


    return 0;
}

Measured memory_bytes: 256
//--- pC ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	int n, m;
	int[][] score_arr;
	int best;
	int[] selected;
	Map<String, Integer> map_score;
	int q;
	// List<Integer> list;
	private void run_case() {
		n = reader.ni();
		m = reader.ni();
		q = reader.ni();

		map_score = new HashMap<>();
		// list = new ArrayList<>();

		selected = new int[15];
		Arrays.fill(selected, 0);

		best = 0;
		score_arr = new int[q+5][5];

		for (int i=0; i<q; i++) {
			score_arr[i+1][0] = reader.ni();
			score_arr[i+1][1] = reader.ni();
			score_arr[i+1][2] = reader.ni();
			score_arr[i+1][3] = reader.ni();
			int t = score_arr[i+1][2];

			int a = score_arr[i+1][0];
			int b = score_arr[i+1][1];
			int c = score_arr[i+1][2];
			int d = score_arr[i+1][3];

			String key = String.valueOf(a) + "_" + String.valueOf(b) + "_" +
			String.valueOf(c);
			map_score.putIfAbsent(key, 0);
			map_score.put(key, map_score.get(key) + d);
		}

		dfs(1, 0);

		out.println(best);

		return;
	}

	private void dfs(int cur, int sel) {
		if (sel == n) {
			getScore();
			return;
		}
		if (cur > m) return;
		for (int i=cur; i<=m; i++) {
			// if (selected[i]) continue;
			// selected[i] = true;
			selected[i] ++;
			dfs(i, sel + 1);
			selected[i] --;
		}
	}

	private void getScore() {
		int[] arr = new int[n];
		int idx = 0;
		int res = 0;
		for (int i=1; i<=m; i++) {
			// if (selected[i]) arr[idx++] = i;
			if (selected[i] > 0) {
				for (int j=0; j<selected[i]; j++) arr[idx++] = i;
			}
		}
		// Map<String, Integer> map_cnt = new
		for (int i=1; i<=q; i++) {
			if (arr[score_arr[i][1]-1] - arr[score_arr[i][0]-1] == score_arr[i][2]) {
				res += score_arr[i][3];
			}
		}
		// for (int i=0; i<n; i++) {
		// 	for (int j=0; j<n; j++) {
		//
		// 	}
		// }
		best = Math.max(best, res);
		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 43704
import java.util.Arrays;
import java.util.Scanner;
import java.util.HashMap;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    HashMap<String, Long> s = new HashMap<>();
    long count = 0;

    for (int i = 0; i < n; ++i) {
      char[] ci = sc.next().toCharArray();
      Arrays.sort(ci);
      String si = new String(ci);
      s.put(si, s.getOrDefault(si, 0L) + 1);
    }

    for (long v : s.values()) {
      count += v * (v - 1) / 2;
    }

    System.out.println(count);

  }
}

Measured memory_bytes: 55276
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		
		int K=sc.nextInt();
		int N=sc.nextInt();
		int[] A=new int[N];
		int[] B=new int[N];
		
		for(int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		
		B[0]=A[0]+(K-A[N-1]);
		
		for(int i=1;i<N;i++) {
			B[i]=A[i]-A[i-1];
		}
		
		int sum=0;
		
		Arrays.sort(B);
		
		for(int i=0;i<N-1;i++) {
			sum+=B[i];
		}
		
		System.out.print(sum);
		
		sc.close();
	}
}

Measured memory_bytes: 85956
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var s = nextCharArray();
  var sLen = s.length;
  var t = nextCharArray();
  var tLen = t.length;
  var isBreak = false;
  for(var i = sLen - tLen; i >= 0; i--){
    if(s[i] == t[0] || s[i] == "?"){
       myerr("1文字目がヒット");
       var isOK = true;
       for(var j = 0; j < tLen; j++){
         if(s[i + j] != t[j] && s[i + j] != "?"){
            isOK = false;
            break;
         }
       }
       if(isOK){
          isBreak = true;
          for(var j = 0; j < tLen; j++){
           	s[i + j] = t[j];
       	  }
       }
    }
    if(isBreak){
       break;
    }
  }
  
  for(var i = 0; i < sLen; i++){
    if(s[i] == "?"){
       s[i] = "a";
    }
  }
  if(isBreak){
     myout(myconv(s,0));
  }else{
     myout("UNRESTORABLE");
  }
}

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

using namespace std;

int main(){
    int H, W, K;
    while(cin >> H >> W >> K){
        vector<string> a(H);
        for(auto& s : a) cin >> s;
        vector<vector<int>> res(H, vector<int>(W, -1));
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(a[i][j] == '#'){
                    res[i][j] = K;
                    --K;
                }
            }
        }
        for(int i=0;i<H;i++){
            for(int j=1;j<W;j++){
                if(res[i][j] != -1) continue;
                res[i][j] = res[i][j-1];
            }
        }
        for(int i=0;i<H;i++){
            for(int j=W-2;j>=0;j--){
                if(res[i][j] != -1) continue;
                res[i][j] = res[i][j+1];
            }
        }
        for(int i=1;i<H;i++){
            for(int j=0;j<W;j++){
                if(res[i][j] != -1) continue;
                res[i][j] = res[i-1][j];
            }
        }
        for(int i=H-2;i>=0;i--){
            for(int j=0;j<W;j++){
                if(res[i][j] != -1) continue;
                res[i][j] = res[i+1][j];
            }
        }
        for(auto& v : res){
            cout << v[0];
            for(int i=1;i<W;i++) cout << " " << v[i];
            cout << endl;
        }
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define MOD 1000000007
#define int long long

signed main(){
    int n,x;cin>>n>>x;
    int m=MOD,ans=n;
    rep(i,n){
        int c;cin>>c;
        x-=c;
        m=min(m,c);
    }
    ans+=x/m;
    cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  int n;cin>>n;
  int p[n][n];
  rep(i,0,n)rep(j,0,n)p[i][j]=-1;
  rep(i,0,n){
    int a;cin>>a;
    rep(j,0,a){
      int b,c;cin>>b>>c;
      --b;
      p[i][b]=c;
    }
  }
  ll ans=0;
  rep(bit,0,(1<<n)){
    vector<int> d(n);
    rep(i,0,n)if(bit>>i&1){
      d[i]=1;
    }
    bool ok=true;
    ll count=0;
    rep(i,0,n){
      if(d[i]){
        count++;
        rep(j,0,n){
          if(p[i][j]==-1)continue;
          if(p[i][j]!=(d[j]))ok=false;
        }
      }
    }
    if(ok)ans=max(ans,count);
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;

int main()
{
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <climits>
#include <set>
#include <queue>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {

	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";

    return out;

}


int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);


	int n, i;
	cin >> n >> i;
	int j = n;
	for (int l = 1; l <= n; ++l) {
		if (l == i) {
			cout << j << "\n";
			break;
		}
		--j;
	}


	return 0;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll mod = 1000000007;
    ll N,K;
    cin >> N >> K;
    ll out = 0;
    for(ll i=K;i<=N+1;i++){
        ll min = (i*(i-1)/2);
        ll max = ((N+N-i+1)*i/2);
        out = (out+(max-min+1))%mod;
    }
    cout << out << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  vector<int> x(N);
  int count = 0;
  bool can = false;
  
  for(int i=1; i<N; i++){
     x.at(i) = a.at(x.at(i-1)) -1;
     count++;
   // cout << x.at(i) << endl;
    if(x.at(i) == 1){
      can = true;
      break;}
  }
  if(can!=true){ count = -1;}
  
  cout << count <<endl;
  return 0;
} 
    
    

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

int main()
{
        int i,n,m=0,a[26]={0};
        char w[101];
        scanf("%s",w);

        n=strlen(w);
        for(i=0;i<n;i++)
                a[w[i]-'a']++;

        for(i=0;i<26;i++)
                if(a[i]%2==1)m++;
        if(m==0)printf("Yes\n");
        else printf("No\n");
        return 0;
}


Measured memory_bytes: 1632
import java.util.Scanner;

public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
 
        int[][] array1 = new int[n][m];
        int[][] array2 = new int[m][l];
 
        for (int i = 0; i < array1.length; i++) {
            for (int j = 0; j < array1[i].length; j++) {
                array1[i][j] = sc.nextInt();
            }
        }
 
        for (int i = 0; i < array2.length; i++) {
            for (int j = 0; j < array2[i].length; j++) {
                array2[i][j] = sc.nextInt();
            }
        }
         
        sc.close();
        long[][] array3 = new long[n][l];
 
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                for (int j2 = 0; j2 < m; j2++) {
                    array3[i][j] += array1[i][j2]*array2[j2][j];
                }
            }
        }
         
        for (int i = 0; i < array3.length; i++) {
            for (int j = 0; j < array3[i].length; j++) {
                System.out.print(array3[i][j]);
                if(j != l -1){
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }
 
}


Measured memory_bytes: 53860
R = lambda: map(int, input().split())
M = 10**9 + 7
n, m = R()
a = [-1] + [int(input()) for _ in range(m)]
s, t = 0, 1
for i in range(n - 1, -1, -1):
    if i == a[-1]:
        a.pop()
        s, t = t, 0
    else:
        s, t = t, (s + t) % M
print(t)


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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
//const ll M = 1000000000+7;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
   return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(ll n){
  if(n==0) return 1;
  mint ans = f(n/2);
  ans *= ans;
  if(n%2==1) ans*= 2;
  return ans;
}

mint choose(ll n, ll k){
  mint x=1, y=1;
  rep(i,k){
    x *= (n-i);
    y *= (i+1);
  }
  return x / y;
}

struct BIT {
  private:
   vector<ll> bit;
   ll N;
 
  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(ll a, ll w) {
     for (ll x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(ll a) {
     ll ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
 
ll fff(ll n, vector<ll>& v, ll i, ll j, ll rl){
  ll can = 0;
  ll can_i = 0;

  cout << v[0]<<endl;
  
  // right
  if(rl == 0){
    rep(k, n){
      if(v[k]*(j-k)>can){
	can = v[k]*(j-k);
	can_i = k;
      }
      //cout << can<<endl;
    }
    v[can_i] = 0;
    return can;
  }
  // left
  else{
    rep(k, n){
      if(v[k]*(k-i)>can){
	can = v[k]*(k-i);
	can_i = k;
      }
      //cout << can<<endl;

    }
    v[can_i] = 0;
    return can;
  }
  
}


int main(){
  ll n,a,b;

  cin>>n>>a>>b;

  ll ans=0;
  ll x1,x;
  cin >> x1;
  rep(i, n-1){
    cin>>x;
    ans += min(b, a*(x-x1));
    x1 = x;
  }
  
  cout << ans<<endl;
  
  
}


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

int calculation(int a){
  if(a % 2 == 1)return 3 * a + 1;
  else return a / 2;
}

int main(void){
  int a[1000000],s;
  cin >> s;
  if(s == 4 || s == 2 || s == 1){
    cout << 4;
    return 0;
  }
  a[0] = s;
  for(int i = 1; i < 1000000; i++){
    a[i] = calculation(a[i - 1]);
    if(a[i] == 4){
      cout << i + 4;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)
#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)
#define mem(a,n) memset( a, n, sizeof(a))

typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;

int main() {
    int N;
    cin>>N;
    
    if(N==1){
        cout1("Hello World");
    }else{
        int a,b;cin>>a>>b;
        cout1(a+b);
    }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            int[] A = in.Int(N);

            long sum = IntStream.of(A).asLongStream().sum();
            Map<Integer, Integer> map = new HashMap<>();
            for (int a : A) {
                map.put(a, map.getOrDefault(a, 0) + 1);
            }

            int Q = in.Int();
            for (int i = 0; i < Q; i++) {
                int B = in.Int();
                int C = in.Int();
                if (map.containsKey(B)) {
                    int cnt = map.get(B);
                    if (cnt > 0) {
                        sum += ((long) C * cnt) - ((long) B * cnt);
                        map.put(C, map.getOrDefault(C, 0) + cnt);
                        map.put(B, 0);
                    }
                }
                out.println(sum);
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

        public int[] Int(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Int();
            }
            return a;
        }

    }
}



Measured memory_bytes: 60796
n=int(input())
a=list(map(int,input().split()))
# 奇数列、偶数列でそれぞれ最大と2番目を調べる
a_odd = dict()
a_even = dict()
for i,x in enumerate(a):
  if i%2:
    a_odd[x] = 1 + (a_odd[x] if x in a_odd else 0)
  else:
    a_even[x] = 1 + (a_even[x] if x in a_even else 0)
# リストをソート
odd_l = sorted(a_odd.items(), reverse=True, key=lambda x:x[1])
even_l = sorted(a_even.items(), reverse=True, key=lambda x:x[1])
odd_l.append((0,0))
even_l.append((0,0))

if odd_l[0][0] != even_l[0][0]:
  # 最頻値が異なる場合はそれぞれの最頻値以外を全書き換え
  print(n - odd_l[0][1] - even_l[0][1])
elif odd_l[0][1] > even_l[0][1]:
  # 最頻値一致/奇数列の方が頻度が高い場合はeven_lは2番目を残す
  print(n - odd_l[0][1] - even_l[1][1])
elif odd_l[0][1] < even_l[0][1]:
  # 逆
  print(n - odd_l[1][1] - even_l[0][1])
else:
  # 最頻値の回数が一致する場合は2番目を比べる
  if odd_l[1][1] < even_l[1][1]:
  	print(n - odd_l[0][1] - even_l[1][1])
  else:
    # 逆(1,2番目両方一致の場合はどちらでも一緒
    print(n - odd_l[1][1] - even_l[0][1])
#print(*odd_l)
#print(*even_l)

Measured memory_bytes: 25264
lis = [int(input()) for i in range(4)]
if lis[0] > lis[1]:
    print(lis[1]*lis[2]+(lis[0]-lis[1])*lis[3]) 
else:
    print(lis[1]*lis[2]+(lis[0]-lis[1])*lis[2])
    

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

public class Main {

    private static Character[] VOWELS = {'a', 'i', 'u', 'e', 'o'};

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char c = scanner.next().charAt(0);
        scanner.close();

        if (Arrays.asList(VOWELS).contains(c)) {
            System.out.println("vowel");
        } else {
            System.out.println("consonant");
        }
    }
}


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

using namespace std;

char ch[4] = {'R', 'Y', 'G', 'B'};
int n, m, d, sz;

int main()
{
	int i, j, x, y;
	
	scanf("%d%d%d", &n, &m, &d);
	
	if(d & 1){
		for(i=0; i<n; i++){
			for(j=0; j<m; j++){
				printf("%c", ch[i + j & 1]);
			}
			printf("\n");
		}
	}
	else{
		for(i=0; i<n; i++){
			for(j=0; j<m; j++){
				x = ((i - j + d * m * 4) / d % 4 + 4) % 4;
				y = (i + j + d * 2) / d % 4;
				if((x - y + 4) % 4 < 2) printf("%c", ch[(x + y) % 4]);
				else printf("%c", ch[(x + y + 2) % 4]);
			}
			printf("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 512
n = int(input())
a = [int(input()) for _ in range(n)]

m, m2 = 0,0
for ai in a:
    if ai > m:
        m, m2 = ai, m
    elif ai > m2:
        m2 = ai

for ai in a:
    if ai == m:
        print(m2)
    else:
        print(m)


Measured memory_bytes: 12532
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cmath>
#include<stack>
#include<vector>

using namespace std;

int L[109];

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> L[i];
	}

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

	int sum = -L[indexOfMax];
	for (int i = 0; i < N; i++)
	{
		sum += L[i];
	}

	if (L[indexOfMax] < sum)
	{
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split();
        int K = int.Parse(input[0]);
        int X = int.Parse(input[1]);
        if (500 * K >= X) { Console.WriteLine("Yes"); }
        else { Console.WriteLine("No"); }
    }
}

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

int main(){
    long n;
    cin >> n;
    int a, b, c, d;
    string str;
    a = b = c = d = 0;

    while(n--){
        cin >> str;
        if (str == "AC")
            a++;
        else if (str == "WA")
            b++;
        else if (str == "TLE")
            c++;
        else if (str == "RE")
            d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}

Measured memory_bytes: 3624
def func():
    N, M, C = map(int, input().split())

    B = list(map(int, input().split()))
    count = 0

    for _ in range(N):
        A = list(map(int, input().split()))
        sum = 0
        for i in range(M):
            sum += A[i] * B[i]

        if sum + C > 0:
            count += 1

    print(count)


if __name__ == '__main__':
    func()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,n;
    cin >> h >> w >> n;
    vector<int>A(n);
    REP(i,n) cin >> A[i];
    ll cnt= A[0];
    ll col= 1;
    REP(i, h){
        if(i%2==0){
            REP(j, w){
                if(cnt==0){
                    cnt= A[col];
                    col++;
                }
                cout << col << ((j==w-1)?"":" ");
                cnt--;
    
            } cout << endl;
        }else{
            string s="";
            for(ll j=w-1; j>=0; j--){
                if(cnt==0){
                    cnt= A[col];
                    col++;
                }
                s= ((j==0)?"":" ")+to_string(col)+s;
                
                cnt--;

            } cout << s << endl;
        }

    }
    // vector<vector<ll>> map(h,vector<ll>(m,0));

    

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
static auto faster_iostream = []() { ios::sync_with_stdio(0); cin.tie(0); return 0; }();
typedef long long ll; typedef long double db;
const int N = 1e6 + 5, M = 1e9 + 7;

int a[N], b[N];

int main() {
  string s;
  cin >> s;
  int n = s.size();
  a[0] = s[0] - '0';
  b[0] = 10 - (s[0] - '0') + 1;
  for (int i = 1; i < n; i++) {
    int t = s[i] - '0';
    a[i] = min(a[i-1], b[i-1]) + t;
    b[i] = min(a[i-1] + 10 - t + 1, b[i-1] + 10 - t - 1);
  }
  cout << min(a[n-1], b[n-1]);
}


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


int main() {
    int n; cin >> n;
    vector<ll> v(n);
    rep(i,n){
        cin >> v.at(i);
    }
    vector<bool> b(n-1);
    rep(i,n-1){
        if(v.at(i)>=v.at(i+1)){
            b.at(i)=1;
        }
    }
    int ans=0,cnt=1;
    rep2(i,n-1){
        if(b.at(i)){
            cnt++;
            if(cnt>ans) ans=cnt;
        }
        else{
            cnt=0;
        }
    }
    cout << ans;
}

Measured memory_bytes: 1024
n = int(input())
A = list(map(int, input().split()))
ratelist = [1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
rate = [0] * n
count = 0
for i in range(n):
    rate[i] = sum([A[i] >= j for j in ratelist])
    if rate[i] == 9:
        count += 1
ans = len(set(rate))
if count > 0:
    ans -= 1
print('{} {}'. format(max(1, ans), ans + count))

Measured memory_bytes: 3064
//TO CHANGE THE WORLD
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define L first
#define R second

const int maxn=1e5+10;

vector <int> adj[maxn];
vector <pair<int, int> > ed;
bool mark[maxn];
int h[maxn], up[maxn], par[maxn];

void dfs(int x)
{
    up[x]=h[x];
    mark[x]=true;
    for(int i=0; i<adj[x].size(); i++)
    {
        int child=adj[x][i];
        if(!mark[child])
        {
            par[child]=x;
            h[child]=h[x]+1;
            dfs(child);
            up[x]=min(up[x],up[child]);
        }
        else if(child!=par[x])
            up[x]=min(up[x],h[child]);
    }
}

int main()
{
    int n,m;
    vector <pair <int, int> > ans;
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int fi,se;
        cin>>fi>>se;
        adj[fi].pb(se);
        adj[se].pb(fi);
        if(fi>se)
            swap(fi,se);
        ed.pb(mp(fi,se));
    }
    dfs(0);
    for(int i=0; i<m; i++)
    {
        int fi=ed[i].L, se=ed[i].R;
        if(h[fi]>h[se])
            swap(fi,se);
        if(up[se]>=h[se])
            ans.pb(mp(min(fi,se), max(fi,se)));
    }
    sort(ans.begin(), ans.end());
    for(int i=0; i<ans.size(); i++)
        cout<<ans[i].L<<" "<<ans[i].R<<endl;
    return 0;
}

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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

pair<int,int> sneak(int k, int W) {
  int y = k / W;
  int x = (y % 2 == 0) ? (k % W) : (W - 1 - (k % W));
  return make_pair(y, x);
}

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<int>> a(H, vector<int> (W));
  REP(i,H)REP(j,W) cin >> a[i][j];

  vector<int> ret;
  REP(i, H * W - 1) {
    auto p = sneak(i, W);
    auto pn = sneak(i + 1, W);
    if(a[p.first][p.second] % 2) {
      --a[p.first][p.second];
      ++a[pn.first][pn.second];
      ret.push_back(i);
    }
  }

  cout << ret.size() << endl;
  for(int i: ret) {
    auto p = sneak(i, W);
    auto pn = sneak(i + 1, W);
    cout << p.first + 1 << " " << p.second + 1 << " " << pn.first + 1 << " " << pn.second + 1 << endl;
  }
  return 0;
}



Measured memory_bytes: 3704
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    pass


if __name__ == "__main__":
    main()


def bellman_ford(edges, N, start, goal):
    dist = [float("inf") for _ in range(N)]
    dist[start] = 0

    # 辺の情報を見ることを1ループとすると
    # 最低でも1つの頂点について，スタートからの最短距離が求まる
    # つまり，スタートからの距離は，スタートを除いた頂点の数である
    # (N-1)回のループで求まる．
    for i in range(N * 2):
        for fro, to, cost in edges:
            if dist[to] > dist[fro] + cost:
                dist[to] = dist[fro] + cost
                # N回目に頂点の更新があると，負の経路がある
                if i == N - 1:
                    dist[to] = -float("inf")

    return -dist[goal]


N, M = map(int, input().split())

edges = []
for _ in range(M):
    a, b, c = map(int, input().split())
    edges.append((a - 1, b - 1, -c))

cost = [float("inf") for _ in range(N)]
start = 0
goal = N - 1
ans = bellman_ford(edges, N, start, goal)
if ans == float("inf"):
    print(ans)
else:
    print(ans)


Measured memory_bytes: 3444
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner stdln = new Scanner(System.in);
		int a = stdln.nextInt();
		int b = stdln.nextInt();
		int c = a*b;
		int d = 2*(a+b);
		System.out.println( c + " " + d );
	}
}

Measured memory_bytes: 26080
n=int(input())
h=list(map(int,input('').split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(abs(h[i-1]-h[i])+dp[i-1],abs(h[i-2]-h[i])+dp[i-2])
print(dp[-1])


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

using namespace std;

const int MAX = 100001;
int alltime = 0;

class pro
{
public:
	string name;
	int time;
	void input(string, int);
	void print();
	pro& operator=(const pro);
};

void pro::input(string name, int time)
{
	pro::name = name;
	pro::time = time;
}

void pro::print()
{
	cout << name << " " << alltime << endl;
}

pro& pro::operator=(const pro pro)
{
	name = pro.name;
	time = pro.time;
	return *this;
}

class queue
{
private:
	pro s[MAX];
	int head;
	int tail;
public:
	queue();
	void initialize();
	bool empty();
	bool full();
	void enqueue(pro);
	pro dequeue();
	void rein(int);
};

queue::queue()
{
	head = tail = 0;
}

void queue::initialize()
{
	head = tail = 0;
}

bool queue::empty()
{
	return head == tail;
}

bool queue::full()
{
	if (tail + 1 == MAX)return head == 0;
	else return head == tail + 1;
}

void queue::enqueue(pro x)
{
	if (full())return;
	s[tail] = x;
	tail++;
	if (tail == MAX)tail = 0;
}

pro queue::dequeue()
{
	if (empty()){pro a;a.input("a",0);return a;}
	pro v = s[head];
	head++;
	if (head == MAX)head = 0;
	return v;
}

void queue::rein(int q)
{
	int a;
	if (tail == 0)a = MAX - 1;
	else a = tail - 1;
	s[a].time -= q;
}

int main()
{
	queue queue;
	pro now;
	int n, q, i, time;
	string str;
	cin >> n >> q;
	for (i = 0; i < n; i++)
	{
		cin >> str >> time;
		now.input(str, time);
		queue.enqueue(now);
	}
	while (!queue.empty())
	{
		now = queue.dequeue();
		if (now.time <= q)
		{
			alltime += now.time;
			now.print();
		}
		else
		{
			alltime += q;
			queue.enqueue(now);
			queue.rein(q);
		}
	}
    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int[] array = new int[10];
			for (int i = 0; i < 10; i++) {
				array[i] = sc.nextInt();
			}

			Arrays.sort(array);

			System.out.println(array[9]);
			System.out.println(array[8]);
			System.out.println(array[7]);
		}
	}
}

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

int main(){
    int n; cin>>n;
    vector<int> h(n);

    int ma = 0;

    for(int i=0; i<n; i++){
        cin>>h[i];
        ma = max(ma,h[i]);
    }

    vector<int> af(n,0);

    int count=0;   

    while(1){
        int i=0,ama = 0;

        for(int j=0; j<n; j++)ama = max(af[j],ama);

        if(ama == ma) break;

        while(i < n){
            if(af[i] == h[i]) i++;
            else{
                while(i<n && af[i] != h[i]){
                    af[i]++;
                    i++;
                }
                count++;
            }
        }

    }

    cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
	public class Main { 
		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			String ans = ":(";
            if(Math.abs(a - b) <= 1){
                ans = "Yay!";
            }
			System.out.println(ans);
	     }
	}

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


int main(){
	char inp_text ='0';

	std::string text_A = "A";
	std::string text_a = "a";

	std::cin >> inp_text;

	//あえて文字列文字コードで指定Z=0x5A
	if ('A'<= inp_text && inp_text <='Z') {
		std::cout << text_A << std::endl;
		return 0;
	}
	std::cout << text_a << std::endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  vector<int> v1(n, -1), v2(n, -1);
  int count = 1;
  for (int i = 0; i < int(s.size()); ++i) {
    if(s[i] == 'x') continue;
    v1[i] = count;
    count++;
    if(count == k+1) break;
    i += c;
  }

  // count = 1;
  count--;
  for (int i = int(s.size()) - 1; i >= 0; i--) {
    if(s[i] == 'x') continue;
    v2[i] = count;
    count--;
    if(count == 0) break;
    i -= c;
  }
  // print(v1);
  // print(v2);
  for (int i = 0; i < int(s.size()); ++i) {
    if(v1[i] == -1) continue;
    if(v1[i] == v2[i]) cout << i + 1 << endl;
  }
}


Measured memory_bytes: 3348
#include<iostream>
using namespace std;
//Minimum Cost Flow O(FE log V)
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<limits>
template<typename T>
struct MCF{
	struct edge{
		int to,rev,cap;
		T cost;
	};
	vector<vector<edge> >G;
	vector<T>h,d;
	vector<int>pv,pe;
	MCF(int n_=0):G(n_),h(n_,0),d(n_),pv(n_),pe(n_){}
	void add_edge(int from,int to,int cap,T cost)
	{
		G[from].push_back({to,(int)G[to].size(),cap,cost});
		G[to].push_back({from,(int)G[from].size()-1,0,-cost});
	}
	T min_cost_flow(int s,int t,int f)//ans or -1
	{
		T ret=0;
		while(f>0)
		{
			priority_queue<pair<T,int>,vector<pair<T,int> >,greater<pair<T,int> > >P;
			fill(d.begin(),d.end(),numeric_limits<T>::max());
			d[s]=0;
			P.push(make_pair(0,s));
			while(!P.empty())
			{
				pair<T,int>p=P.top();P.pop();
				if(d[p.second]<p.first)continue;
				for(int i=0;i<G[p.second].size();i++)
				{
					edge&e=G[p.second][i];
					if(e.cap>0&&d[e.to]>d[p.second]+e.cost+h[p.second]-h[e.to])
					{
						d[e.to]=d[p.second]+e.cost+h[p.second]-h[e.to];
						pv[e.to]=p.second;
						pe[e.to]=i;
						P.push(make_pair(d[e.to],e.to));
					}
				}
			}
			if(d[t]==numeric_limits<T>::max())return -1;
			for(int u=0;u<G.size();u++)h[u]+=d[u];
			int d=f;
			for(int u=t;u!=s;u=pv[u])d=min(d,G[pv[u]][pe[u]].cap);
			f-=d;
			ret+=d*h[t];
			for(int u=t;u!=s;u=pv[u])
			{
				G[pv[u]][pe[u]].cap-=d;
				G[u][G[pv[u]][pe[u]].rev].cap+=d;
			}
		}
		return ret;
	}
};
main()
{
	int N;
	while(cin>>N,N)
	{
		MCF<int>mf(366);
		for(int i=0;i<N;i++)
		{
			int L,R,M;cin>>L>>R>>M;
			mf.add_edge(L-1,R,1,-M);
		}
		for(int i=0;i<365;i++)mf.add_edge(i,i+1,2,0);
		cout<<-mf.min_cost_flow(0,365,2)<<endl;
	}
}



Measured memory_bytes: 3240
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<utility>
#include<vector>
#include<climits>
#include<queue>
#include<random>
#include<map>

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

using namespace std;

int main(int argc, char const *argv[]) {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int cnt=0;
    int ccnt = 0;
    rep(i,3){
        if(a[i] == 5)cnt++;
        if(a[i] == 7)ccnt++;
    }
    if(cnt == 2 && ccnt == 1){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define rreps(i,n) for(int i = (int)(n); i > 0; i--)
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
template <class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = INT_MAX;
const int MOD = 1000000007;

int main() {
    int N, K;
    cin >> N >> K;
    vi H(N);
    rep(i, N) cin >> H[i];
    sort(all(H));
    ll ans = 0;
    rep(i, max(N-K, 0)) {
        ans += H[i];
    }
    cout << ans << endl;
}

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

int main(void){
    // Your code here!
    int n;
    cin >> n;
    vector<pair<int,int>  > P;
    FOR(i,1,n) {
        int a,b;
        cin >>  a >> b;
        P.push_back(make_pair(a+b,a-b));
    }
    sort(P.begin(),P.end());
    int count = 1;
    int index = 0;
    for (int i = 1;i < n;i++) {
        if ( P.at(index).first <= P.at(i).second){
            count++;
            index =i;
        }
    }
    cout << count << endl;
}

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

typedef long long ll;
typedef vector<int> VI;
#define rep(i,n) for(int i=0;i<(n);++i)

//example rep(i,n) cin >> h[i];

int main (){

int s,t;
  cin>>s;

if(s<10){
    cout<<"Yes"<<endl;

exit(0);
}
else{
for(int i=2;i<10;i++){
  if(s%i==0){
     t=s/i;
 
	for(int j=2;j<10;j++){
      if(t/j==1&&t%j==0){
        cout<<"Yes"<<endl;
        exit(0);
    }
  }
} 
}

}
cout<<"No"<<endl;
  
  

  //sort(vec.begin(),vec.end());
  //reverse(vec.begin(),vec.end());

  
 return 0; 
}

Measured memory_bytes: 256