akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
class Processe{
	String processesName;
	int Times;
	int endtime;
}
public class Main{
	public static void main(String[] args){
		Queue<Processe> queue = new  LinkedList<Processe>();
		Queue<Processe> queue2 = new  LinkedList<Processe>();
		int n;
		int q;
		int endtime = 0;
		Scanner scanner = new Scanner(System.in);
		String string;
		string = scanner.nextLine();
		
		String [] strings = string.split(" ");
		n = Integer.parseInt(strings[0]);
		q= Integer.parseInt(strings[1]);
		
		Processe[] processes = new Processe [n];
		
		Processe processe  = new Processe();
		
		for(int i=0; i<n; i++){
			string = scanner.nextLine();
			strings = string.split(" ");
			processes[i] = new Processe();
			processes[i].processesName = strings[0];
			processes[i].Times = Integer.parseInt(strings[1]);
			queue.add(processes[i]);
		}
		while(!queue.isEmpty()){
			processe = queue.poll();
			if(processe.Times <= q){
				endtime += processe.Times;
				processe.endtime = endtime;
				queue2.add(processe);
			}else{
				endtime  += q;
				processe.Times -= q;
				queue.add(processe);
			}
		}
		while(!queue2.isEmpty()){
			processe = queue2.poll();
			System.out.println(processe.processesName + " " + processe.endtime);
		}
	}
}

Measured memory_bytes: 110680
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, K; cin >> N >> K;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    ll ans = INF;
    rep(i, N){
        if(i + K - 1 >= N)continue;
        ll tmp = abs(0 - a[i]) + abs(a[i] - a[i + K - 1]);
        ans = min(ans, tmp);
        tmp = abs(0 - a[i + K - 1]) + abs(a[i + K - 1] - a[i]);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
using namespace std;
//using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX 500003
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >
//#define endl "\n"
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int mod=998244353;
int power(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a);
        }
        a=(a*a);
        b>>=1;
    }
    return ans;
}

int32_t main()
{
    fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        int l,r,d;
        cin>>l>>r>>d;

        int ans=0;

        repa(i,l,r)
        {
            if(i%d==0) ans++;
        }
        cout<<ans<<endl;
    }
}   


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

int A[10][10];
int a[10][10] = {};
int N;
int b[110];

int main() {
    rep(i, 3) {
        rep(j, 3) {
            cin >> A[i][j];
        }
    }
    cin >> N;
    rep(i, N) cin >> b[i];
    rep(i, N) {
        rep(j, 3) {
            rep(k, 3) {
                if (b[i] == A[j][k]) a[j][k] = true;
            }
        }
    }

    bool ans = false;

    rep(i, 3) {
        rep(j, 3) {
            if (!a[j][i]) break;
            else if (j == 2) ans = true;
        }
        rep(j, 3) {
            if (!a[i][j]) break;
            else if (j == 2) ans = true;
        }
    }
    rep(i, 3) {
        if (!a[i][i]) break;
        else if (i == 2) ans = true;
    }
    rep(i, 3) {
        if (!a[2 - i][i]) break;
        else if (i == 2) ans = true;
    }
    /*
    rep(i, 3) {
        rep(j, 3) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
    */
    cout << Yes(ans) << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>
#include<stack>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 1005

int main(){

    while(true){
        string s;
        getline(cin,s);
        if(s == "."){
            break;
        }
        stack<char> stk;
        bool exist = true;
        REP(i,s.size()){

            if(s[i] == '('){
                stk.push('(');
            }
            if(s[i] == '['){
                stk.push('[');
            }
            if(s[i] == ')'){
                if(stk.empty() || stk.top() != '('){
                    //空か(がないか
                    exist = false;
                    break;
                }else{
                    stk.pop();
                }
            }
             if(s[i] == ']'){
                if(stk.empty() || stk.top() != '['){
                    //空か[がないか
                    exist = false;
                    break;
                }else{
                    stk.pop();
                }
            }
        }
        if(exist && stk.empty()){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }

  


    return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

int main() {
    // 山の数は1つで, 取れる石の数が決まってる
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    int dp[100001] = {0};
    rep3(i, 1, k + 1) {
        rep(j, sz(a)) {
            if (i - a[j] < 0) continue;
            dp[i] |= (dp[i - a[j]] == 0); // 1つでも遷移元に0があれば
        }
    }
    // rep(i, k + 1) cout << dp[i] << " "; cout << '\n';
    cout << (dp[k] == 0 ? "Second" : "First") << '\n';
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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; }

bool a[10][10];
int p[10];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    rep(i,m){
    	int k;
    	cin >> k;
    	rep(j,k){
    		int x;
    		cin >> x;
    		a[i][x-1] = true;
    	}
    }
    rep(i,m) cin >> p[i];
    int ans = 0;
    rep(i,(1 << n)){
    	int tmp = 0;
    	rep(l,m){
    		int cnt = 0;
	    	rep(j,n){
	    		if(((i >> j) & 1) && a[l][j]) cnt++;
	    	}
	    	if(cnt%2 == p[l]) tmp++;
		}
		if(tmp == m) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const ll INF = 1e18;
ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
ll n;
ll d,a[2000005];
struct Node
{
	ll v;
	ll x;
	Node(ll _v=0,ll _x=0)
	{
		v=_v;x=_x;
	}
};
bool operator<(Node a,Node b)
{
	return a.v<b.v;
}
struct Seg
{
	ll l,r,lc,rc,pos;
	Node p[5];
}tr[2000005];
ll tot;
void up(ll x)
{
	ll lc=tr[x].lc,rc=tr[x].rc;
	for(ll i=0;i<5;i++)
	{
		if(tr[lc].p[i]<tr[rc].p[i])
		{
			tr[x].p[i]=tr[lc].p[i];
			if(i==4)
			{
				tr[x].pos=tr[lc].pos;
			}
		}
		else
		{
			tr[x].p[i]=tr[rc].p[i];
			if(i==4)
			{
				tr[x].pos=tr[rc].pos;
			}
		}
	}
	if(tr[lc].p[2].v!=INF and tr[rc].p[1].v!=INF)
	{
		ll t=tr[lc].p[2].v+tr[rc].p[1].v;
		if(t<tr[x].p[4].v)
		{
			tr[x].p[4]=Node(t,tr[lc].p[2].x),tr[x].pos=tr[rc].p[1].x;
		}
	}
	if(tr[lc].p[0].v!=INF and tr[rc].p[3].v!=INF)
	{
		ll t=tr[lc].p[0].v+tr[rc].p[3].v;
		if(t<tr[x].p[4].v)
		{
			tr[x].p[4]=Node(t,tr[rc].p[3].x),tr[x].pos=tr[lc].p[0].x;
		}
	}
}
void build(ll l,ll r)
{
	ll x=++tot;
	tr[x].l=l;tr[x].r=r;
	for(ll i=0;i<5;i++)
	{
		tr[x].p[i]=Node(INF,0);
	}
	if(l==r)
	{
		if(l!=1)
		{
			tr[x].p[0]=Node(a[l]-(ll)l*d,l);
			tr[x].p[1]=Node(a[l]+(ll)l*d,l);
			tr[x].p[2]=tr[x].p[3]=tr[x].p[4]=Node(INF,0);
		}
		else
		{
			tr[x].p[0]=tr[x].p[1]=tr[x].p[4]=Node(INF,0);
			tr[x].p[2]=Node(a[l]-(ll)l*d,l);
			tr[x].p[3]=Node(a[l]+(ll)l*d,l);
		}		
		return;
	}
	ll mid=l+r>>1;
	tr[x].lc=tot+1,build(l,mid);
	tr[x].rc=tot+1,build(mid+1,r);
	up(x);
}
void modify(ll x,ll p)
{
	for(ll i=0;i<5;i++)
	{
		tr[x].p[i]=Node(INF,0);
	}
	if(tr[x].l==tr[x].r)
	{
		ll l=tr[x].l;
		tr[x].p[0]=tr[x].p[1]=tr[x].p[4]=Node(INF,0);
		tr[x].p[2]=Node(a[l]-(ll)l*d,l);
		tr[x].p[3]=Node(a[l]+(ll)l*d,l);
		return;
	}
	ll mid=tr[x].l+tr[x].r>>1,lc=tr[x].lc,rc=tr[x].rc;
	if(p<=mid)
	{
		modify(lc,p);
	}
	else
	{
		modify(rc,p);
	}
	up(x);
}
int main()
{
	cin>>n>>d;
	for(ll i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	build(1,n);
	ll m=n-1;
	ll ans=0;
	while(m--)
	{
		ans+=tr[1].p[4].v;
		modify(1,tr[1].pos);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 237952
#include <bits/stdc++.h>
using namespace std;
 int main() {
   int N, K;
   cin >> N >> K;
   vector<int> ans(1);
   for(int i = 0; i < K; i++){
     int P;
     cin >> P;
     for(int j = 0; j < P; j++) {
       int X;
       cin >> X;
       ans.push_back(X);
     }
   }
   ans.push_back(N+1);
   sort(ans.begin(),ans.end());
   int Q;
   Q = ans.size();
   int pls = 0;
   for(int i = 1; i < Q; i++) {
     if( ans.at(i)  > 1 + ans.at(i - 1)) {
       pls += ans.at(i) - ans.at(i-1) - 1;
     }
   }
   cout << pls << endl;
 }
   


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

int main() {
	int n;
	scanf("%d",&n);
	for(int i=1; i<=9; i++) {
		if(n%i == 0) {
			if(n/i < 10) {
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder.BeginnersSelections
{
    class Test
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split('/');
            str[0] = "2018";
            Console.WriteLine(str[0] + "/" + str[1] + "/" + str[2]);
        }
    }
}

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



int main(){
    int n;
    cin >> n;
    vector<P> mp;
    vector<int> v[n];
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        mp.push_back(make_pair(a,b));
        v[a].push_back(b);
        v[b].push_back(a);
    }

    map<P,int> ans;
    queue<int> que;

    bool ed[n];
    memset(ed,0,sizeof(ed));

    que.push(0);
    ed[0]=true;
    int num=0;
    int cs[n];
    memset(cs,0,sizeof(cs));

    while(!que.empty()){
        int q = que.front();
        que.pop();
        int c=1;
        if(v[q].size()>num) num=v[q].size();
        for(auto x:v[q]){
            if(ed[x]==true){
                continue;
            }
            if(cs[q]==c) c++;
            cs[x]=ans[P(q,x)]=ans[P(x,q)]=c;
            c++;
            que.push(x);
            ed[x]=true;
        }
    }

    cout << num << endl;
    rep(i,n-1){
        cout << ans[mp[i]] << endl;
    }

    

}

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

int main(){
    int N, M, C;
    cin >> N >> M >> C;

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

    int cnt = 0;
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum = C;
        for(int j = 0; j < M; j++){
            sum += A[i][j] * B[j];
        }
        if(sum > 0){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;

}

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

constexpr long M = 2*1000+1;
int b[2000][1000];
int s[2001][1001];

inline long calc(long x, long y, long w, long h){
    return s[x+w][y+h] - s[x+w][y] - s[x][y+h] + s[x][y];
}

int main(void){
    long n, k;
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> k;
    for(long i=0; i<n; i++){
        int x, y;
        char c;
        cin >> x >> y >> c;
        //scanf("%d %d %c", &x, &y, &c);
        y %= 2*k;
        if(c=='W'){
            x += k;
        }
        if(y>=k){
            y-=k;
            x+=k;
        }
        x %= 2*k;
        b[x][y]++;
    }
    s[1][1] = b[0][0];
    for(long i=1; i<2*k; i++){
        s[i+1][1] = s[i][1] + b[i][0];
    }
    for(long i=1; i<k; i++){
        s[1][i+1] = s[1][i] + b[0][i];
    }
    for(long x=1; x<2*k; x++){
        for(long y=1; y<k; y++){
            s[x+1][y+1] = b[x][y] + s[x][y+1] + s[x+1][y] - s[x][y];
        }
    }
    long max = 0;
    for(long x=0; x<k; x++){
        for(long y=0; y<k; y++){
            long t = calc(x, y, k, k-y);
            t += calc(0, 0, x, y);
            t += calc(x+k, 0, k-x, y);
            t = t<n/2 ? n-t : t;
            max = t>max ? t : max;
        }
    }
    cout << max;
    return 0;
}


Measured memory_bytes: 15872
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;


class Main{
    /**
     * A data structure to represent the shape of the diagram
     */
    static class Pair{
        int pos, area;
        Pair(int pos, int area){
            this.pos = pos;
            this.area= area;
        }
    }

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));
        // convert the diagram representation to a list of char
        char[] diagram = br.readLine().toCharArray();

        Stack<Integer> a = new Stack<>();
        Stack<Pair> b = new Stack<>();



        //ArrayDeque<Integer> a = new ArrayDeque();
        //ArrayDeque<Pair> b = new ArrayDeque<>();

        int ans = 0; // the sum of flood area
        for (int i = 0; i < diagram.length; i++) {
            if (diagram[i] == '\\') a.push(i);
            if (diagram[i] == '/' && !a.isEmpty()){
                int j = a.pop();
                int area2 = i - j;
                ans += area2;
                while (!b.isEmpty() && b.peek().pos > j)
                    area2 += b.pop().area;
                b.push(new Pair(j, area2));
            }
        }
        Stack<Integer> areas = new Stack<>();
        while(!b.isEmpty()) areas.push(b.pop().area);
        System.out.println(ans);
        System.out.print(areas.size());
        while(!areas.isEmpty()) System.out.print(" " + areas.pop());
        System.out.println();
    }
}



Measured memory_bytes: 26832
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define absl(v) labs((v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp;
  int a[LIMIT2]={0};
  char s[LIMIT1],t[LIMIT1];
  
  scanf("%s",s);
  scanf("%s",t);
  n = strlen(s);
  m = strlen(t);
  result=-1;
  rep(i,n-m+1){
    tmp=1;
    j=0;
    rep(j,m){
      //printf("%c %c\n",s[i+j],t[j]);
      if(s[i+j]!=t[j] && s[i+j]!='?'){
        tmp=0;
        break;
      }
    }
    if(tmp==1) result = max(result,i);
  }
  if(result>=0){
    for(i=result;i<result+m;i++){
      s[i]=t[i-result];
    }
    rep(i,n) printf("%c",(s[i]=='?' ? 'a' : s[i]));
  }else{
    printf("UNRESTORABLE");
  }
  
  return 0;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
ans = 0
for a in range(1,n+1):
    ans += (n-1)//a
print(ans)

Measured memory_bytes: 63012
n = int(input())
arr = list(map(int,input().split()))
addarr = [i+1+arr[i] for i in range(n)]
diffarr = [i+1-arr[i] for i in range(n)]

from collections import Counter
cnt = Counter([addarr[0]])
ans = 0

for i in range(1,n):
    tmp = diffarr[i]
    ans += cnt[tmp]
    cnt.update([addarr[i]])

print(ans)

Measured memory_bytes: 50328
/*
  Sk arman Hossain
  University of Barisal

 Problem name : 1412 - Visiting Islands
 Algorithm : BFS
*/

#include<bits/stdc++.h>
#define nl printf("\n");
#define N 200001
#define PR pair<int,int>
#define sf(n) scanf("%d", &n)
#define sff(n, m) scanf("%d %d",&n,&m)
#define sfl(n) scanf("%lld", &n)
#define sfu(n) scanf("%llu", &n)
#define sffl(n, m) scanf("%lld %lld",&n,&m)
#define pfn(n) printf("%d\n",n)
#define pf(n) printf("%d ",n)
#define pfl(n) printf("%lld ",n)
#define pfln(n) printf("%lld\n",n)
#define pfu(n) printf("%llu\n",n)
#define pfs(s) printf("%s",s)
#define YES printf("YES\n")
#define NO printf("NO\n")
#define PB push_back
#define PI 3.1415926536
#define VST(v) sort(v.begin(),v.end())
#define fori(i,n) for(;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define MP make_pair
int dx[]= {0,0,1,-1};
int dy[]= {1,-1,0,0};
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
vector<int>edge[100010];
vector<PR>V;
int main(){
    string s,s2;
    int ans=0;
    cin>>s>>s2;
    for(int i=0;i<3;i++){
        if(s[i]==s2[i])
            ans++;
    }
    cout<<ans<<endl;


///*****************************  ALHAMDULILLAH  *****************************/
}


Measured memory_bytes: 2560
import sys

point = []

for i in range(5):
  point.append(int(input()))

k = int(input())


for i in range(0, len(point)):
  for j in range(i + 1, len(point)):
    if abs(point[i] - point[j]) > k:
      print(":(")
      sys.exit()



print("Yay!")



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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

template<typename T> using V = vector< T >;
using Vi = V<int>;

template<typename T>
T SUM(V<T> v, T init_val=0){return accumulate(ALL(v),T(init_val));}

int main(){
    int n,m;
    cin>>n>>m;
    Vi p(m),s(m,0);
    REP(i,m){
        string tmp;
        cin>>p[i]>>tmp;
        p[i]--;
        if(tmp == "AC"){
            s[i] = 1;
        }
    }

    int AC_num=0;
    Vi WA_num(n,0);
    int penalty=0;
    V<bool> AC_flags(n,false);

    REP(i,m){
        if(AC_flags[p[i]]) continue;
        if(s[i] == 0){
            WA_num[p[i]]++;
        }else{
            AC_num++;
            penalty += WA_num[p[i]];
            AC_flags[p[i]] = true;
        }
    }

    cout<<AC_num<<" "<<penalty<<endl;

    return 0;
}

Measured memory_bytes: 1408
fn main() {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    println!("{}", solve(&input));
}

const MODULO: i64 = 1_000_000_007;

fn solve(input: &str) -> String {
    let mut iter = input.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();
    let mut a: Vec<i64> = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect();
    if k == 1 {
        return "0\n".to_string();
    }
    a.sort();
    let mut factorials: Vec<i64> = vec![0; n - 1];
    factorials[0] = 1;
    for i in 1..n - 1 {
        factorials[i] = factorials[i - 1] * (i as i64) % MODULO;
    }
    let factorial_inverses: Vec<i64> = factorials
        .iter()
        .map(|f| {
            let mut acc = 1;
            let mut base = *f;
            let mut exponent = MODULO - 2;
            while exponent != 0 {
                if exponent & 1 != 0 {
                    acc = acc * base % MODULO;
                }
                base = base * base % MODULO;
                exponent >>= 1;
            }
            acc
        })
        .collect();
    let mut choose: Vec<i64> = vec![0; n];
    for i in 0..n {
        if i < k - 1 {
            choose[i] = 0;
        } else {
            let mut c = factorials[(i - 1)];
            c *= factorial_inverses[(i - 1) - (k - 2)];
            c %= MODULO;
            c *= factorial_inverses[k - 2];
            c %= MODULO;
            choose[i] = c;
        }
    }
    for i in 1..n {
        choose[i] += choose[i - 1];
        choose[i] %= MODULO;
    }
    let mut ans = 0;
    for i in 0..n {
        ans += (choose[i] - choose[n - 1 - i]) * a[i];
        ans %= MODULO;
    }
    format!("{}\n", ans)
}

Measured memory_bytes: 10492
//                          VIVEK UPADHYAY
//                         MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                         TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl ;
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 1e5+ 10 ;
const int MAX = 1e7 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;
int x[] = {1,1,1,-1,-1,-1,0,0};
int y[] = {0,1,-1,0,-1,1,1,-1};
struct Node{
    ll x , y , h ;
} ;
int main() {
    
    ll N , M ;
    cin >> N >> M ;
    ll gcd = 1;
    for(ll i=1;i<=sqrt(M);i++){
        if(M%i==0){
            if(M/i >= N){
                gcd=max(gcd,i) ;
                if(i>=N) gcd=max(gcd,M/i) ;
            }
        }
    }
    cout<<gcd<<endl;
    return  0 ;
}


Measured memory_bytes: 256
package main

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

func main() {
	var (
		min = 1000000.
		max = -1000000.
		sum = 0.
		ai  = 0.
		a   = bufio.NewScanner(os.Stdin)
	)

	a.Split(bufio.ScanWords)
	a.Scan()
	n, _ := strconv.Atoi(a.Text())
	for i := 0; i < n; i++ {
		a.Scan()
		ai, _ = strconv.ParseFloat(a.Text(), 64)
		min = math.Min(min, ai)
		max = math.Max(max, ai)
		sum += ai
	}
	fmt.Println(int(min), int(max), int(sum))
}



Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
//型名省略
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<long long>> vvl;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rep2(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define all(A) A.begin(), A.end()
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}


//main関数
int main() {
    ll a,b,c,d; cin >> a >> b >> c >> d;

    while(true){
        c -= b;
        if(c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0){
            cout <<"No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line,result="";
            boolean first=true;
            int sum=0,n=0,i=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("-"))break;
            	if(first){
            		result=line;
            		n=Integer.parseInt(br.readLine());
            		i=0;
            		first=false;
            	}else{
            		int a=Integer.parseInt(line);
            		result=result.substring(a,result.length())+result.substring(0,a);
            		i++;
            		if(i==n){
            			System.out.println(result);
            			first=true;
            		}
            	}
            }
        }
    }


}

Measured memory_bytes: 24232
// Charan Sriramula

#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;

const ll logx=30;
const ll N=1e6+5;
const ll INF=1e18+5;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%intd",&n)
#define longp(n) printf("%intd\n",n)

inline ll mul(ll a, ll b, ll p){ return (a * 1ll * b) % p; }
inline ll sub(ll a, ll b, ll p){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll add(ll a, ll b, ll p){ ll c = a + b; if(c > p) c -= p; return c; }

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1ll;x=(x*x)%m;}return ans%m;}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

ll n,a[N],dp1[(1<<19)][20],dp2[(1<<19)][20];

ll F(ll mask,ll idx)
{
  ll res=-1;
  if(idx==-1){return a[mask];}
  if(dp1[mask][idx]!=-1){return dp1[mask][idx];}
  if(mask&(1<<idx))
  {
    res=max(res,F(mask,idx-1));
    res=max(res,F(mask^(1<<idx),idx-1));
  }
  else{res=max(res,F(mask,idx-1));}
  return dp1[mask][idx]=res;
}

ll Q(ll mask,ll idx)
{
  ll res=-1;
  ll set=mask&(1<<idx);
  ll val=mask&((1<<idx)-1);
  if(val==0&&set)
  {
    ll maxi=-1;
    maxi=max(maxi,dp1[mask][idx-1]+dp1[mask^(1<<idx)][idx-1]);
    return maxi;
  }
  if(idx==-1){return 0;}
  if(dp2[mask][idx]!=-1){return dp2[mask][idx];}
  if(mask&(1<<idx))
  {
    res=max(res,Q(mask,idx-1));
    res=max(res,Q(mask^(1<<idx),idx-1));
    res=max(res,dp1[mask][idx-1]+dp1[mask^(1<<idx)][idx-1]);
  }
  else
  {
    res=max(res,Q(mask,idx-1));
  }
  return dp2[mask][idx]=res;
}

int main()
{
  fast;
  cin>>n;
  ms(dp1,-1);
  ms(dp2,-1);
  ll maxi=-1;
  for(ll i=0;i<(1<<n);i++){cin>>a[i];}
  for(ll mask=0;mask<(1<<19);mask++){dp1[mask][19]=F(mask,19);dp1[mask][-1]=a[mask];}
  for(ll mask=0;mask<(1<<19);mask++){dp2[mask][19]=Q(mask,19);}
  for(ll mask=1;mask<(1<<n);mask++)
  {
    maxi=max(maxi,dp2[mask][19]);
    cout<<maxi<<endl;
    //cout<<mask<<" "<<dp2[mask][19]<<endl;
  }
}

Measured memory_bytes: 171136
#include<stdio.h>

void insertionSort(int A[101],int N) // N個の要素を含む0-オリジンの配列A
{
int v;
   for(int i=0;i<N;i++)
 {    v = A[i];
  int   j = i - 1;
     while (j >= 0 &&A[j] > v)
{
       A[j+1] = A[j];
       j--;
     A[j+1] = v;
}
for(int k=0;k<N-1;k++)
printf("%d ",A[k]);
printf("%d\n",A[N-1]);
}
}

int main(){
int N,x;
int A[101]={};
scanf("%d",&N);
for(int i=0;i<N;i++){
scanf("%d",&x);A[i]=x;}
insertionSort(A,N);
return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
#define maxn 505050

using namespace std;
const int M=1000000007;
int n,m,dp[1005][1005];
char s[1005][1005];

int main(){
    cin >> n >> m;
    for (int i=1;i<=n;i++) scanf("%s",s[i]+1);
    if (s[1][1]!='#') dp[1][1]=1;
    for (int i=1;i<=n;i++)
    for (int j=1;j<=m;j++) if (i+j>2){
        if (s[i][j]=='#') continue;
        if (i>1) (dp[i][j]+=dp[i-1][j])%=M;
        if (j>1) (dp[i][j]+=dp[i][j-1])%=M;
    }
    cout << dp[n][m];
    return 0;
}


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

int main()
{
	long long n;
	char nm[11];
	long long ct[5] = { 0, 0, 0, 0, 0 };
	long long k;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> nm;
		
		switch (nm[0])
		{
		case 'M':
			ct[0]++;
			break;
		case 'A':
			ct[1]++;
			break;
		case 'R':
			ct[2]++;
			break;
		case 'C':
			ct[3]++;
			break;
		case 'H':
			ct[4]++;
			break;
		}
	}

	k = ct[0] * ct[1] * ct[2] + ct[0] * ct[1] * ct[3] + ct[0] * ct[1] * ct[4]
		+ ct[0] * ct[2] * ct[3] + ct[0] * ct[2] * ct[4] + ct[0] * ct[3] * ct[4]
		+ ct[1] * ct[2] * ct[3] + ct[1] * ct[2] * ct[4] + ct[1] * ct[3] * ct[4]
		+ ct[2] * ct[3] * ct[4];

	cout << k << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

void printArray(int *A,int N){
  for(int i=0;i<N;i++) {
    printf("%d",A[i]);
    if(i<N-1)
      putchar(' ');
    else
      putchar('\n');
  }
}

void insertionSort(int* A, int N){
  int v,j;
  printArray(A,N);
  for(int 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;
    printArray(A,N);
  }
}

int main(){
  int n,*p;

  scanf("%d\n",&n);

  p=(int *)malloc(n*sizeof(int));

  for(int i=0;i<n;i++){
    scanf("%d ",&p[i]);
  }

  insertionSort(p,n);
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll   = long long;
using P    = pair<int, int>;
const ll M = 1e18;
int main() {
    int n;
    cin >> n;
    ll ans  = 1;
    bool ng = false;
    rep(i, n) {
        ll a;
        cin >> a;
        if(a == 0) {
            cout << 0 << endl;
            return 0;
        }
        if(ng || M / ans < a) {
            ng = true;
        }
        ans *= a;
    }
    if(ng)
        cout << -1 << endl;
    else
        cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  V<tuple<int, int, bool>> events;
  REP(i, n) {
    int a, b;
    cin >> a >> b;
    events.emplace_back(a, b, true);
  }
  REP(i, n) {
    int c, d;
    cin >> c >> d;
    events.emplace_back(c, d, false);
  }
  sort(events.begin(), events.end());
  set<int> s;
  int cnt = 0;
  for (auto [x, y, is_red] : events) {
    if (is_red) {
      s.insert(y);
    } else {
      auto it = s.lower_bound(y);
      if (it == s.begin()) continue;
      --it;
      ++cnt;
      s.erase(it);
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3616
from collections import deque

n = int(input())
S = input()
slimes = deque(list(S))

remaining_slimes = []
remaining_slimes.append(slimes.popleft())
while len(slimes) > 0:
    if remaining_slimes[-1] == slimes[0]:
        slimes.popleft()
    else:
        remaining_slimes.append(slimes.popleft())
print(len(remaining_slimes))


Measured memory_bytes: 4980
#include<iostream>
using namespace std;
int main()
{
	int N;
	cin >> N;
	int a[N];
	for(int i=0;i<N;i++)
		cin >> a[i];
	int result = 0;
	int cp=0;
	while(cp<N-1)
	{
		if(a[cp]!=a[cp+1])
		{
			cp++;
			continue;
		}
		result++;
		a[cp+1]=0;
		if(cp==N-2)				break;
		if(a[cp+1]==a[cp+2])	cp+=2;
		if(a[cp+1]!=a[cp+2])	cp+=1;
	}
	cout << result << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {
  int N; std::cin >> N;
  std::vector<std::pair<int,int>> d(N);
  std::vector<std::vector<int>> T(N);

  for(int i=0; i<N-1; i++) {
    int a, b; std::cin >> a >> b;
    d[i].first  = a-1;
    d[i].second = b-1;
    T[a-1].push_back(b-1);
    T[b-1].push_back(a-1);
  }

  std::vector<int> c(N);
  for(int i=0; i<N; i++) std::cin >> c[i];
  std::sort(c.begin(), c.end(), [] (int &x, int &y) { return x > y; } );

  int k = 0;
  std::queue<int> q;
  std::vector<int> value(N, -1);
  q.push(0);
  value[0] = c[0]; k++;
  while(!q.empty()){
    int cur = q.front(); q.pop();
    for(int t=0; t<T[cur].size(); t++){
      int next = T[cur][t];
      if ( value[next] != -1 ) continue;
      value[next] = c[k]; k++;
      q.push(next);
    }
  }

  long long ans = 0;
  for(int i=0; i<N-1; i++) ans += std::min(value[d[i].first], value[d[i].second]);

  std::cout << ans << std::endl;
  for(int i=0; i<N; i++) std::cout << value[i] << " ";
  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 1152
#include <cstdio>

long long min(long long a, long long b)
{
  if (a < 0 && b < 0)
  {
    return 1e18;
  }
  if (a < 0) return b;
  else if (b < 0) return a;
  return a < b ? a : b;
}

long long valid(long long a)
{
  if (a < 0) return 1e18;
  else return a;
}

int main()
{
  long long x, y;
  scanf("%lld%lld", &x, &y);
  long long a = min(y - x, 1 + valid(y - (-x)));
  long long b = min(valid(-y - x) + 1, 1 + valid(-y - (-x)) + 1);
  printf("%lld\n", min(a, b));
  return 0;
}

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

using namespace std;

int main() {
  string s1;
  string s2;
  cin >> s1 >> s2;

  int cnt = 0;
  for (size_t i = 0; i < 3; ++i) {
    if (s1[i] == s2[i]) ++cnt;
  }

  cout << cnt << endl;
}


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

int main() {
	int a,b;
	cin >> a >> b;
	if ( a < b ) {
		cout <<"a < b" << endl;
	}else if( a > b) {
		cout <<"a > b" << endl;
	}else {
		cout <<"a == b" << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();		
		int count = r.ri();
		int[] arr = r.ria();
		Arrays.sort(arr);
		reverse(arr);
		int a = 0;
		int b = 0;
		for(int i = 0; i<count; i++) {
			if((i%2)==0) a+=arr[i];
			else b+=arr[i];
		}
		print(a-b);
	}
	
	public static int getDigitSum(int n) {
		String str = ""+n;
		int sum = 0;
		for(int i = 0; i<str.length();i++) {
			sum += Integer.parseInt(""+str.charAt(i));
		}
		return sum;
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 21332
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		Long[] mns = new Long[n];
		int k = sc.nextInt();
		Long ans = 0l;

		for(int i=0;i<n;i++){
			mns[i] = sc.nextLong();
		}

		Arrays.sort(mns);

		for(int m=0;m<n-k;m++){
			ans += mns[m];
		}

		System.out.println(ans);

		}
	}

Measured memory_bytes: 65312
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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 = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

void solver(int n, int k, vector<int> p, vector<int> c) {
  REP(i,n) p[i]--; // 0-index

  ll ans = -LINF;

  REP(i,n) {
    ll cycle_sum = 0;
    int cycle_cnt = 0, v = i;
    while(1) {
      cycle_cnt++;
      cycle_sum += c[p[v]];
      v = p[v];
      if (v == i) break;
    }

    ll path = 0;
    int cnt = 0;

    while(1) {
      cnt++;
      path += c[p[v]];
      if (cnt > k) break;

      int num = (k - cnt) / cycle_cnt;
      ll score = path + max(0ll, cycle_sum) * num;
      chmax(ans, score);
      v = p[v];
      if (v == i) break;
    }
  }

  COUT(ans);
  return;
}

int main() {
  IOS;
  int n, k; cin >> n >> k;
  vector<int> p(n),c(n);
  REP(i,n) cin >> p[i];
  REP(i,n) cin >> c[i];

  solver(n,k,p,c);

  return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(int argc, char const *argv[]) {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int k,sum=0;
    cin>>k;
    for(int i=1;i<=k;i++) {
        for(int j=1;j<=k;j++) {
            for(int p=1;p<=k;p++) {
                int gcd=__gcd(i,j);
                sum+=__gcd(gcd,p);
            }

        }
    }
    cout<<sum<<endl;

}


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

public class Main {

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

		int N = sc.nextInt();

		int x=0, y=0, z=0;
		int i = 0;

		int[] ans = new int[N+1];
		Arrays.fill(ans, 0);

		double maxVal = Math.sqrt(10000);

		for(x=1; x <= maxVal; x++) {
			for(y=1; y <= maxVal; y++) {
				for(z=1; z <= maxVal; z++) {
					i = x*x + y*y + z*z + x*y + y*z + z*x;

					if(i > N) {
						continue;
					} else {
						ans[i] += 1;
					}

				}
			}
		}

		for(i=1; i<=N; i++) {
			System.out.println(ans[i]);
		}

	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}

Measured memory_bytes: 38924
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <string>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;
using ll = long long;

const int maxN = 10123;
char k[maxN];
const int MOD = 1e9 + 7;

void add_self(int & a, int b) {
    a += b;
    if (a > MOD) {
        a -= MOD;
    }
}

int main(int argc, char *argv[]) {
    cin >> k;
    int D;
    cin >> D;
    int n = strlen(k);
    vector<vector<int> > dp(D, vector<int>(2));
    dp[0][0] = 1;
    for (int where = 0; where < n; ++where) {
        vector<vector<int> > new_dp(D, vector<int>(2));
        for (int sum = 0; sum < D; ++sum) {
            for (bool sm_already: {false, true} ) {
                for (int digit = 0; digit < 10; ++digit) {
                    if (digit > k[where] - '0' && !sm_already)
                        break;
                    add_self(new_dp[(sum + digit)%D][sm_already || digit < k[where] - '0'],
                             dp[sum][sm_already]);
                }
            }
        }
        dp = new_dp;
    }
    int ans = dp[0][true] + dp[0][false];
    ans--;
    if (ans < 0) {
        ans += MOD;
    }
    printf("%d\n", ans);
    return 0;
}

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

 int num[3];

int main() {   
    for (int i = 0; i < 6; ++i) {
        int a; cin >> a; --a;
        num[a]++;
    }
    bool ok = true;
    for (int i = 0; i < 4; ++i) {
        if (num[i] == 0) ok = false;
        if (num[i] == 3) ok = false;
    }
    if (ok) puts("YES");
    else puts("NO");
}
        


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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int i;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++){
        if(s[i]=='?')
            s[i]='D';
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 3748