akhauriyash/Code-Regression huggingface dataset:
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);i--)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int r,d,x;
  cin >> r >> d >> x;

  REP(_,10){
    x = r*x-d;
    cout << x << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define INF 2001
#define NIL -1
#define WHITE 0
#define BLACK 1

main(){
	int n, i, j, u, cost=0, mincost;
	int **G, *tmp;
	int *flag;
	int *d, *pi;

	scanf("%d", &n);
	flag = (int*)malloc(sizeof(int) * n);
	d = (int *)malloc(sizeof(int)*n);
	pi = (int *)malloc(sizeof(int)*n);
	G = (int**)malloc(sizeof(int*) * n);
	tmp = (int*)malloc(sizeof(int) * n * n);
	for (i = 0; i < n; i++){
		G[i] = tmp + i * n;
	}

	for (i = 0; i < n; i++){
		flag[i] = WHITE;
		d[i]=INF;
		pi[i]=NIL;
		for (j = 0; j < n; j++){
			scanf("%d", &G[i][j]);
		}
	}

	// [0]を開始点
	u=0;
	d[u]=0;

	while(1){
	  mincost = INF;
	  for(i=0; i<n; i++){
	    if(flag[i]!=BLACK && d[i]<mincost){
	      mincost = d[i];
	      u=i;
	    }
	  }
	  if(mincost == INF) break;
	  flag[u] = BLACK;
	  //cost += mincost;

	  for(i=0; i<n; i++){
	    if(G[u][i]!=-1 && flag[i]!=BLACK && G[u][i]<d[i]){
	      d[i]=G[u][i];
	      pi[i] = u;
	    }
	  }  
	}

	cost =0;
	for(i=0; i<n; i++){
	  if(G[i][pi[i]] != -1)
	    cost += G[i][pi[i]];
	}

	printf("%d\n", cost);

	free(tmp);
	free(G);
	free(flag);
	free(d);
	free(pi);

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,a[102],color[10];
int main()
{
    cin>>n;
    int cnt=0,cnt1=0,mn=0,mx;
    memset(color,0,sizeof(color));
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>=1&&a[i]<=399)
        {
            color[1]++;
        }
        else if(a[i]>=400&&a[i]<=799)
        {
            color[2]++;
        }
        else if(a[i]>=800&&a[i]<=1199)
        {
            color[3]++;
        }
        else if(a[i]>=1200&&a[i]<=1599)
        {
            color[4]++;
        }
        else if(a[i]>=1600&&a[i]<=1999)
        {
            color[5]++;
        }
        else if(a[i]>=2000&&a[i]<=2399)
        {
            color[6]++;
        }
        else if(a[i]>=2400&&a[i]<=2799)
        {
            color[7]++;
        }
        else if(a[i]>=2800&&a[i]<=3199)
        {
            color[8]++;
        }
        else
            cnt++;
    }
    for(int i=1;i<=8;i++)
    {
        if(color[i]>0)
        {
            mn++;
        }
    }
    if(mn==0)
        cout<<1<<" "<<cnt<<endl;
    else
    {
        cout<<mn<<" "<<mn+cnt<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import 'dart:async';
import 'dart:io';
import 'dart:convert';
import 'dart:math';

Stream<String> get lineStream =>
    stdin.transform(utf8.decoder).transform(const LineSplitter());

Future<List<String>> readLines() async {
  final lines = <String>[];
  await for (var line in lineStream) {
    lines.add(line);
  }
  return lines;
}

void main() async {
  final lines = await readLines();
  final nd = lines[0].split(' ').map((e) => int.parse(e)).toList();
  var count = 0;
  for (var i = 0; i < nd[0]; i++) {
    final xy = lines[i + 1].split(' ').map((e) => int.parse(e)).toList();
    final d = sqrt(pow(xy[0], 2) + pow(xy[1], 2));
    if (d <= nd[1]) {
      count++;
    }
  }
  print('$count');
}

Measured memory_bytes: 90680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define umi2357 ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
const ll maxn=1e6+5;
char mp[11][maxn];
ll c[11],re,cnt;
ll h,w,k;
ll f(ll j,ll z){
    ll id=0;
    rep(0,i,h){
        c[id]+=mp[i][j]=='1';
        if(c[id]>k)return 0;
        if((z>>i)&1)id++;
    }
    return 1;
}
int main(void){
    // Your code here!
    umi2357;
    cin>>h>>w>>k;
    rep(0,i,h)cin>>mp[i];
    ll ans=100000;
    rep(0,i,(1<<h)-1){
        fill(c,c+h,0);re=1;
        cnt=__builtin_popcount(i);
        rep(0,j,w){
            if(!f(j,i)){
                fill(c,c+h,0);
                re=f(j,i);
                ++cnt; 
            }
        }
        if(re)ans=min(cnt,ans);
    }
    cout<<ans;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
map<char, ll> mp;
int main()
{
    int n;
    cin >> n;
    char c[5] = {'M', 'A', 'R', 'C', 'H'};
    rep(i, n)
    {
        string s;
        cin >> s;
        mp[s[0]]++;
    }
    ll ans = 0;
    for(int i = 0;i<3;i++){
        for(int j = i+1;j<4;j++){
            for(int k = j+1;k<5;k++){
                ans += mp[c[i]] * mp[c[j]] * mp[c[k]];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ull unsigned long long
using namespace std;

int main() {
  ull a,b,x;
  cin>>a>>b>>x;
  if(a==b) {
    if(a%x==0) {
      cout<<"1"<<endl;
    }
    else {
      cout<<"0"<<endl;
    }
  }
  else if(a%x!=0&&b%x!=0) {
    cout<<(ull)b/x-(ull)ceil(a/x)<<endl;
  }
  else if(a%x==0&&b%x!=0) {
    cout<<(ull)b/x-(ull)ceil(a/x)+1<<endl;
  }
  else if(a%x!=0&&b%x==0) {
    cout<<(ull)b/x-(ull)ceil(a/x)<<endl;
  }
  else if(a%x==0&&b%x==0) {
    cout<<(ull)b/x-(ull)ceil(a/x)+1<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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

int main(){
    long int n, d, a;
    cin >> n >> d >> a;
    P x[n];
    rep(i, n) cin >> x[i].first >> x[i].second;
    sort(x, x + n);
    queue<P> que;
    P p;
    p.first = x[0].first + d;
    long int attack;
    if(x[0].second % a == 0) attack = x[0].second / a;
    else attack = x[0].second / a + 1;
    p.second = attack;
    que.push(p);
    long int ans = attack;
    for (long int i = 1; i < n; i++){
        while (!que.empty() && que.front().first + d < x[i].first){
            attack -= que.front().second;
            que.pop();
        }
        long int hp = x[i].second - attack * a;
        if (!que.empty()){
            long int hp = x[i].second - attack * a;
            if (hp > 0){
                if(hp % a == 0) {
                    attack += hp / a;
                    que.push(P(x[i].first+d, hp/a));
                    ans += hp / a;
                }else {
                    attack += hp / a + 1;   
                    que.push(P(x[i].first+d, hp/a+1));
                    ans += hp / a + 1;
                }
            }
        }else{
            if(hp % a == 0) {
                attack += hp / a;
                que.push(P(x[i].first+d, hp/a));
                ans += hp / a;
            }else {
                attack += hp / a + 1;   
                que.push(P(x[i].first+d, hp/a+1));
                ans += hp / a + 1;
            }
        }
        // cout << hp << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5112
import java.util.Scanner;

public class Main{

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

        while(true){
    		double total = 0.0; //合計点
            double m = 0.0; //平均点
            double a = 0.0; //分散
            double stdev = 0.0;

            //学生の数
            int n = Integer.parseInt(sc.next());
        	if(n==0){
        		break;
        	}
        	//入力した分だけの配列内変数作成
        	int points[] = new int[n];

        	//合計
            for (int i=0; i<n; i++) {
                points[i] = Integer.parseInt(sc.next());
                total += points[i];
            }

            //平均
            m = total / n;

            //分散
            for (int i=0; i<n; i++) {
                a += ((points[i] - m)*(points[i] - m));
            }

            //標準偏差
            stdev = Math.sqrt(a/n);
            System.out.println(stdev);
        }
	}

}



Measured memory_bytes: 31304
x,y,z,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]
ab=[]
for i in range(x):
    for j in range(y):
        ab.append(a[i]+b[j])
ab=sorted(ab,reverse=True)[:3001]
abc=[]
for i in ab:
    for j in c:
        abc.append(i+j)
abc=sorted(abc,reverse=True)
for i in range(k):
    print(abc[i])

Measured memory_bytes: 140664
#include<iostream>
typedef long long LL;
using namespace std;
int main()
{
	LL n, m;
	ios::sync_with_stdio ( false );
	while ( cin >> n >> m )
	{
		if ( 2 * n == m )
			cout << n << endl;
		else
		{
			if ( m % 2 != 0 )
				m = m - 1;
			if ( 2 * n < m )
			{
				LL tmp = ( m - 2 * n ) / 4;
				cout << tmp + n << endl;
			}
			if ( 2 * n > m )
				cout << m / 2 << endl;
		}
	}
	return 0;
}


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

const int INF = 1145141919;
const long long INFL = 1LL<<60;

template<class T>
inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

int H, W;
int a[1100][1100];
long long int memo[1100][1100];

int rec(int x, int y)
{
	if(x == 0 || x > W || y == 0 || y > H || a[y][x])
	{
		return 0;
	}
	if(memo[y][x] != 0)
	{
		return memo[y][x];
	}
	// cout << x << " " << y << endl;
	if(x == W && y == H)
	{
		return 1;
	}
	int ans = 0;
	ans = rec(x+1, y) + rec(x, y+1);
	return memo[y][x] = ans % 1000000007;
}

int main()
{
	cin >> H >> W;
	char in;
	for (int i = 1; i <= H; ++i)
	{
		for (int j = 1; j <= W; ++j)
		{
			cin >> in;
			a[i][j] = (in == '.' ? 0 : 1);
		}
	}
	memo[H][W] = 1;
	for (int i = H; i > 0; --i)
	{
		for (int j = W; j > 0; --j)
		{
			if(!a[i][j])
			{
				memo[i][j] += memo[i+1][j] + memo[i][j+1];
				memo[i][j] %= 1000000007;
			}
		}
	}
	cout << memo[1][1] << endl;
	return 0;
}

Measured memory_bytes: 13952
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int d[]=sc.nextIntArray(n);
        sort(d);
        for (int i = 0; i+1 < d.length; i++) {
			if(d[i]==d[i+1])ret("NO");
		}
        
        out.println("YES");
     	out.flush();
    }
    
    static long rep(long h) {
    	if(h==0)return 0;
    	return 1+rep(h/2)*2;
    }

    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}


class P implements Comparable<P>{
    int p,h,f; long m;
    P(int p,int h, int f, long m) {
    	this.p=p;
    	this.h=h;
    	this.f=f;
    	this.m=m;
    }

    public int compareTo(P p){
    	if(this.p==p.p) {
    		if(this.f==-1) return 1;
    		return -1;
    	}
        return this.p-p.p;
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 51352
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#define ll long long
using namespace std;
int main(){
	string s;
	int n,x=0,max=-150;
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='I'){
			x++;
			if(x>max)
				max=x;
		}
		else if(s[i]=='D')
			x--;
	}
	if(max<0)
		max=0;
	cout<<max<<endl;
	return 0;
} 

Measured memory_bytes: 256
s = input()
if 'N' in s and 'S' not in s:
    print('No')
elif 'N' not in s and 'S' in s:
    print('No')
elif 'W' in s and 'E' not in s:
    print('No')
elif 'W' not in s and 'E' in s:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
#define sz(x)       int(x.size())
#define int         int64_t

using namespace std;

typedef pair<int, int> pii;
const int N = 5e2 + 5;
const int inf = (ll)1e18;

int f[N][N], n, c[N][N], cost[N][N];

int get(int x, int y, int u, int v) {
    if(x > u || y > v) return 0;
    return c[u][v] + c[x - 1][y - 1] - c[u][y - 1] - c[x - 1][v];
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n;
    for(int i = 1; i <= n + 1; ++i) {
        for(int j = 1; j <= n + 1; ++j) {
            if(i != j && i <= n && j <= n) cin >> c[i][j];
            c[i][j] += c[i - 1][j] + c[i][j - 1] - c[i - 1][j - 1];
        }
    }
    /// cost(i, j) = sum c[a][b] | i < a < b <= j
    for(int i = 0; i <= n + 1; ++i) {
        for(int j = i + 1; j <= n + 1; ++j)
            cost[i][j] = cost[i][j - 1] + get(i + 1, j, j - 1, j);
    }
    fill_n(&f[0][0], N * N, inf);
    for(int i = 1; i <= n + 1; ++i) f[0][i] = cost[0][i];
    auto minimize = [&](int& x, int y) {if(x > y) x = y;};
    for(int i = 0; i <= n; ++i) {
        for(int j = i + 1; j <= n + 1; ++j) {
            if(f[i][j] == inf) continue;
            for(int k = j + 1; k <= n + 1; ++k) {
                minimize(f[j][k], f[i][j] + cost[j][k] + get(k + 1, i + 1, n + 1, j));
            }
        }
    }
    int res = inf;
    for(int i = 0; i <= n; ++i) res = min(res, f[i][n + 1]);
    cout << res;
}


Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main(){
	int N;
	cin >> N;
	int m = 2*N;
	std::vector<ll> A(m+1,0);
	ll sum = 0;
	for (int i = 1; i <= N; i++)
	{
		cin >> A[i];
		sum += A[i];
	}

	std::vector<ll> x(N+1,0);
	ll asum = 0;
	for (int i = 2; i < N ; i=i+2)
	{
		asum += A[i];
	}
	x[1] = sum/2 - asum;

	for (int i = 2; i <= N; i++)
	{
		x[i] = A[i-1]- x[i-1];
	}

	for (int i = 1; i <= N; i++)
	{
		cout << 2*x[i] << endl;
	}



	return 0;
}

Measured memory_bytes: 3712
import java.io.*;

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(buf.readLine());
		int[][][] house = new int[4][3][10];
		String[] str;
		int building,floor,room,people;

		for(int i=0; i<4; i++){
			for(int j=0; j<3; j++){
				for(int k=0; k<10; k++){
					house[i][j][k] = 0;
				}
			}
		}
		for(int i=0; i<n; i++){
			str = buf.readLine().split(" ");
			building = Integer.parseInt(str[0]);
			floor = Integer.parseInt(str[1]);
			room = Integer.parseInt(str[2]);
			people = Integer.parseInt(str[3]);
			//?????°???????????????????????´???????????§???+=?????????
			house[building-1][floor-1][room-1] += people;
		}
		for(int i=0; i<4; i++){
			for(int j=0; j<3; j++){
				for(int k=0; k<10; k++){
					//printf???print???????????????????????????????????????
					System.out.print(" "+house[i][j][k]);
				}
				//if(!(i==3 && j==2))
					System.out.println();
			}
			if(i<3)
				System.out.println("####################");
		}

	}
}

Measured memory_bytes: 24612
n=int(input())
s=list(str(input()))
al=[chr(ord("a")+i) for i in range(26)]
c=[0 for i in range(n)]
for i in range(n):
    sl=s[:i]
    sr=s[i:]
    for j in al:
        if j in sl and j in sr:
            c[i]+=1
print(max(c))


Measured memory_bytes: 3060
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int N=10000;
const int INF=(1<<21);
struct edge{int w,v;};
struct path{int l,v;};
vector<edge>G[N];
int n,vis[N]={0},dis[N];
//priority_queue<path>pq;
path H[10*N];int h=0;
bool isempty(){return h==0;}
void insert(path p){
	int i=++h;
	H[i]=p;
	while(i>1&&H[i].l<H[i/2].l){
		swap(H[i],H[i/2]);
		i/=2;
	}
}
void heapify(int i){
	int les;
	if(i*2<=h&&H[i].l>H[2*i].l) les=2*i;
	else les=i;
	if(i*2+1<=h&&H[les].l>H[i*2+1].l) les=2*i+1;
	if(les!=i){
		swap(H[i],H[les]);
		heapify(les);
	}
}
path extract(){
	path p=H[1];
	H[1]=H[h--];
	if(h>1) heapify(1);
	return p;
} 
//
void dij(int s){
	for(int i=0;i<n;i++) dis[i]=INF;
	path p;
	dis[s]=0;
	p.l=0;p.v=0;
	insert(p);
	while(!isempty()){
		p=extract();
		int u=p.v;
		vis[u]=1;
		for(int i=0;i<G[u].size();i++){
			int v=G[u][i].v;
			int w=G[u][i].w;
			if(!vis[v]){
				if (dis[v]>dis[u]+w){
					p.l=dis[v]=dis[u]+w;
					p.v=v;
					insert(p);
				}
			}
		}
	}
}
int main(){
	scanf("%d",&n);
	int u,deg;edge e;
	for (int i=0;i<n;i++){
		scanf("%d%d",&u,&deg);
		for(int j=0;j<deg;j++){
			scanf("%d%d",&e.v,&e.w);
			G[u].push_back(e);
		}
	}
	dij(0);
	for (int i=0;i<n;i++) printf("%d %d\n",i,dis[i]);
	return 0;
}



Measured memory_bytes: 8132
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
int main()
{
	int vis[30];
	char a[MaxN ];
	bool flag = true;
	memset(vis,0,sizeof(vis));
	scanf("%s",a);
	for(int i = 0 ; i < strlen(a) ; i++)
		{
			int vis1 = a[i] - 'a';
			vis[vis1]++;
			}
	for(int i = 0 ; i < 26 ; i++)
		{
		if(vis[i] == 0)continue;
		if(vis[i] % 2 )flag = false;
		}
		if(flag)cout << "Yes" << endl;
		else cout << "No" << endl;
	return 0;
	}

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

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

typedef long long lint;

using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  if((A+B)%2){
    cout<<"IMPOSSIBLE"<<endl;
  }else{
    cout<<(A+B)/2<<endl;
  }
  return 0;
}


Measured memory_bytes: 3196
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools





def main():
    num = int(input())
    ans = ((1 + num) * num) // 2
    ans -= num
    print(ans)




if __name__ == '__main__':
    main()



Measured memory_bytes: 38580
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
long long a[200020],na[200020],c[200020],w[200020],ans;
int b[200020],nb[200020];
int st[200020],tp;
bool check(int x,int y,int z){return (w[z]-w[y])*(y-x)>=(w[y]-w[x])*(z-y);}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%lld",&a[i]);
	for(int i=1;i<=n;++i)scanf("%d",&b[i]);
	int p=1;
	for(int i=2;i<=n;++i)if(a[i]>a[p])p=i;
	for(int i=0,j=p;i<=n;++i,(++j)>n?j-=n:0)na[i]=a[j],nb[i]=b[j];
	for(int i=0;i<=n;++i)a[i]=na[i],b[i]=nb[i];
	// for(int i=0;i<=n;++i)printf("%lld ",a[i]);printf("\n");
	// for(int i=0;i<=n;++i)printf("%d ",b[i]);printf("\n");
	c[1]=0;
	for(int i=1;i<n;++i)c[i+1]=2*(c[i]+b[i])-c[i-1];
	// for(int i=0;i<=n;++i)printf("%lld ",c[i]);printf("\n");
	for(int i=0;i<=n;++i)
	{
		w[i]=a[i]-c[i];
		while(tp>=2&&check(st[tp-1],st[tp],i))--tp;
		st[++tp]=i;
	}
	// for(int i=1;i<=tp;++i)printf("%d %lld\n",st[i],w[st[i]]);
	for(int i=1;i<tp;++i)ans+=2*w[st[i]]*(st[i+1]-st[i])+(st[i+1]-st[i]+1)*(w[st[i+1]]-w[st[i]]);
	for(int i=1;i<=n;++i)ans+=2*c[i];
	printf("%.12lf",1.0*ans/n/2);
	return 0;
}

Measured memory_bytes: 10216
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, k;
	string s;
	cin >> s;
	cin >> k;
	n = s.length();
	
	int pre[n];
	pre[0] = s[0] - '0';
	for(int i = 1; i < n; i++)
	pre[i] = pre[i - 1] + (s[i] - '0');
	
	int ans = 0;
	if(k == 1) 
	ans = s[0] - '0' + 9 * (n - 1);
	else if(k == 2) {
		int i, j;
		
		int sr = s[0] - '0';
		for(int c1 = 1; c1 <= sr; c1++) {
			fo(i, 1, n) {
				int x = s[i] - '0';
				for(int c2 = 1; c2 < 10; c2++) {
					if(c1 == sr) {
						if(c2 <= x) ++ans;
						else {
							if(pre[i - 1] - pre[0] > 0)
							++ans;
						}
					}
					else ++ans;
				}
			}
		}
		--n;
		ans += ((n * (n - 1)) / 2) * 9 * 9;
	}
	else {
		int sr = s[0] - '0';
		int i, j;
		for(int c1 = 1; c1 <= sr; c1++) {
			fo(i, 1, n) {
				int x = s[i] - '0';
				fo(j, i + 1, n) {
					int y = s[j] - '0';
					
					for(int c2 = 1; c2 < 10; c2++) {
						for(int c3 = 1; c3 < 10; c3++) {
							if(c1 == sr) {
								if(c2 < x) ++ans;
								else if(c2 == x) {
									bool active = (pre[i - 1] - pre[0] > 0);
									if(active) ++ans;
									else {
										if(c3 <= y) ++ans;
										else if(pre[j - 1] - pre[i] > 0) ++ans;
									}
								}
								else if(pre[i - 1] - pre[0] > 0) ++ans;
							}
							else ++ans;
						}
					}
				}
			}
		}
		--n;
		ans += ((n * (n - 1) * (n - 2)) / 6) * 9 * 9 * 9;
	}
	cout << ans;
}


Measured memory_bytes: 256
N=int(input())
S=list(map(int, input().split()))
Alice=0
Bob=0
for i in range (N):
    if i%2==0:
        Alice+=max(S)
        S.remove(max(S))
    if i%2==1:
        Bob+=max(S)
        S.remove(max(S))
print(Alice-Bob)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;

namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            int N = int.Parse(Console.ReadLine());
            var ab = cin.SplitRead();
            var p = cin.SplitRead();
            int[] ans = { 0, 0, 0 };
            for (var i = 0; i < N; i++)
            {
                if (p[i] <= ab[0]) { ans[0]++; }
                else if (p[i] > ab[1]) { ans[2]++; }
                else { ans[1]++; }
            }
            Console.WriteLine(ans.Min());


            //Console.Out.Flush();
        }
        

        


    }
    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public long ModuloP(long value, long mod)
        {
            long r = value % mod;

            if (r * mod < 0)
            {
                r += mod;
            }
            return r;
        }

    }

   struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
   {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
   }

    


}






Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
using namespace std;

int main(void){
    int n;
    int a[10000];
    int i,j;
    
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];
    
    int ans=0;
    
    for(i=0;i<n;i++){
        j=2;
        int m=sqrt(a[i]);
        while(a[i]%j!=0&&j<=m){
            j++;
        }
        if(j>m)ans++;
    }
    
    cout<<ans<<endl;

	return 0;
}


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


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int               long long
#define endl              '\n'
#define ff                first
#define ss                second
#define mp                make_pair
#define pb                push_back
#define vii               vector<int> 
#define pii               pair<int,int>
#define vpii              vector< pii >
#define all(v)            v.begin(),v.end()
#define loop(i,s,e)       for(int i=s;i<e;i++)
#define rloop(i,e,s)      for(int i=e;i>=s;i--)
#define mset(a,f)              memset(a,f,sizeof(a))
#define M                 1000000007
#define fastio            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define prvec(v)          loop(i_u_j,0,v.size())cout << v[i_u_j] <<" "; cout << endl;
#define prarr(arr,n)      loop(i_u_j,0,n)cout << arr[i_u_j] << " "; cout << endl;
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)


template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //
const int N = 3e5 + 7;
int n;
int arr[N][3];
int dp[N][4];

int getans(int id, int p)
{           
      if( dp[id][p] != -1 ) return dp[id][p];
      if( id == n ) return 0;
      int ans = 0;
      if(p == 0)
      {
            int a1 = arr[id][1] + getans(id+1, 1);
            int a2 = arr[id][2] + getans(id+1, 2);
            ans =  max(a1, a2);
      }
      else if(p == 1)
      {
            int a1 = arr[id][0] + getans(id+1, 0);
            int a2 = arr[id][2] + getans(id+1, 2);
            ans =  max(a1, a2);
      }
      else if(p == 2)
      {
            int a1 = arr[id][1] + getans(id+1, 1);
            int a2 = arr[id][0] + getans(id+1, 0);
            ans =  max(a1, a2);
      }
      else
      {
            int a1 = arr[id][1] + getans(id+1, 1);
            int a2 = arr[id][0] + getans(id+1, 0);
            int a3 = arr[id][2] + getans(id+1, 2);
            ans =  max(a1, max(a3, a2) );
      }
      return dp[id][p] = ans;

}


void solve()
{
      cin >> n;
      loop(i,0,n)
      {
            cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
      }
      mset(dp,-1);
      cout << getans(0,3);
}

int32_t main() {
    fastio;

  
  int t = 1; 
  //cin>>t;
  
  while(t--) solve();
  
  


}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //















Measured memory_bytes: 20352
let solve a b c d =
  let l = a + b
  and r = c + d in
  if l > r then
    "Left"
  else if l < r then
    "Right"
  else
    "Balanced"

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ =
  match read_ints () with
  | [a; b; c; d] -> solve a b c d |> print_endline
  | _ -> ()

Measured memory_bytes: 2432
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		int M = GetInt();
		int K = GetInt();

		for(int h = 0; h <= N; h++)
		{
			for(int w = 0; w <= M; w++)
			{
				if((w * (N - h) + (M - w) * h) == K)
				{
					Console.WriteLine("Yes");
					return;
				}
			}
		}
		Console.WriteLine("No");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13140
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
t = ns()
n = len(s)
g = {}

for i in range(n):
    if s[i] not in g:
        g[s[i]] = [i]
    else:
        g[s[i]].append(i)

import bisect

a = 0
b = -1
for i in t:
    if i not in g or a >= n*(10**100):
        print(-1)
        exit()
    k = bisect.bisect_left(g[i],b)
    if k == len(g[i]):
        b = g[i][0]+1
        a += 1
    else:
        b = g[i][k]+1

print(n*a+b)

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

int main()
{
	string s,t;
	cin>>s>>t;
	int arr[s.size()+1][t.size()+1];
	int len[s.size()+1][t.size()+1];
	memset(arr,0,sizeof(arr));
	memset(len,0,sizeof(len));
	for(int i=1;i<=s.size();i++)
	{
		for(int j=1;j<=t.size();j++)
		{
			if(s[i-1]==t[j-1])
				{
					len[i][j]=len[i-1][j-1]+1;
					arr[i][j]=2;
				}
			else
			{
				if(len[i-1][j]>len[i][j-1])
				{
					len[i][j]=len[i-1][j];
					arr[i][j]=3;
				}
				else
				{
					len[i][j]=len[i][j-1];
					arr[i][j]=1;
				}
			}
		}
	}
	int index = len[s.size()][t.size()]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = s.size(), j =t.size(); 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (s[i-1] == t[j-1]) 
      { 
          lcs[index-1] = s[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (len[i-1][j] > len[i][j-1]) 
         i--; 
      else
         j--; 
   }
   cout<<lcs; 
	return 0;
}

Measured memory_bytes: 70656
import           Control.Monad (replicateM)
import           Data.Function (on)
import           Data.List     (groupBy, sortOn)

main :: IO ()
main = do
  [_n, m] <- map read . words <$> getLine
  pys <- replicateM m $ (\[p, y] -> (p, y)) . map read . words <$> getLine
  mapM_ putStrLn $ f pys

type Prefecture = Int
type Year = Int

f :: [(Prefecture, Year)] -> [String]
f =
  map (\(_i, p, j) -> pad6 (show p) ++ pad6 (show j)) .
  sortOn (\(i, _p, _j) -> i) .
  concatMap (zipWith (\j (i, (p, _y)) -> (i, p, j)) [1 :: Int ..]) .
  groupBy ((==) `on` (\(_i, (p, _y)) -> p)) .
  sortOn snd .
  zip [1 :: Int ..]
-- sortOn ではなく sortBy comparing を使ってしまうと C022_scrambled 以降 TLE

pad6 :: String -> String
pad6 = reverse . take 6 . (++ repeat '0') . reverse


Measured memory_bytes: 128380
from math import ceil, floor
H, W = map(int,input().split())
sum = 0
if H == 1 or W == 1:
  sum = 1
else:
  if H % 2 == 0:
    sum = W * H / 2
  else:
    if W % 2 == 0:
      sum = ceil(H / 2) * W / 2 + floor(H / 2) * W / 2
    else:
      sum = ceil(H / 2) * ceil(W / 2) + floor(H / 2) * floor(W / 2)
print(int(sum))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <set>
using namespace std;
typedef pair <int,int> pii;
int N, M;
pii jobs[100005]; //val, time
set <int> times;
set <int>::iterator it;
typedef long long ll;
ll ans = 0;

bool cmp(pii a, pii b){
    if (a.first == b.first) return a.second < b.second;
    return a.first > b.first;
}

int main() {
    cin >> N >> M;
    for (int i=1; i<=N; i++){
        scanf("%d %d", &jobs[i].second, &jobs[i].first);
    }
    sort(jobs+1, jobs+1+N, cmp);
    for (int i=0; i<M; i++) times.insert(i);
    for (int i=1; i<=N; i++){
        it = times.upper_bound(M-jobs[i].second);
        if (it != times.begin()){
            it--;
            ans += jobs[i].first;
            times.erase(it);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    using namespace std;
    unsigned long T_1, T_2, A_1, A_2, B_1, B_2;
    cin >> T_1 >> T_2 >> A_1 >> A_2 >> B_1 >> B_2;
    if(A_1 < B_1){
        swap(A_1, B_1);
        swap(A_2, B_2);
    }
    A_1 *= T_1;
    A_2 *= T_2;
    B_1 *= T_1;
    B_2 *= T_2;
    auto t_1 = A_1 - B_1;
    if(A_1 + A_2 > B_1 + B_2)return 0 & puts("0");
    if(A_1 + A_2 == B_1 + B_2)return 0 & puts("infinity");
    auto t_2 = B_1 + B_2 - (A_1 + A_2);
    cout << 2 * ((t_1 - 1) / t_2) + (t_1 % t_2 == 0) + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Pair<Integer, Integer>> townList = new ArrayList<>();
		
		int[] num = new int [N];
		double ans = 0;
				
		for(int i = 0; i < N; i++) {
			num[i] = i;
			int x = sc.nextInt();
			int y = sc.nextInt();
			Pair pair = new Pair (x,y);
			townList.add(pair);
		}
		
		ans = permutation(num, townList, ans);

		int c = 1;
		for(int i = N; i > 0; i--) {
			c *= i;
		}
		System.out.println(ans / c);
		sc.close();
	}
	
	private static class Pair<first, second> {
	    public final int first;
	    public final int second;

	    Pair (int first, int second) {
	        this.first = first;
	        this.second = second;
	    }
	}
	
    private static double permutation(int[] seed, ArrayList<Pair<Integer, Integer>> townList, double ans) {
        int[] perm = new int[seed.length];
        boolean[] used = new boolean[seed.length];
        ArrayList<Double> ansList = new ArrayList<>();
        buildPerm(seed, perm, used, 0, townList, ansList);
        for(double num :ansList) {
        	ans += num;
        }
        return ans;
    }

    private static ArrayList<Double> buildPerm(int[] seed, int[] perm, boolean[] used, int index, ArrayList<Pair<Integer, Integer>> townList, ArrayList<Double> ansList) {
    	if (index == seed.length) {
        	for(int i = 0; i < perm.length - 1; i++) {
    			Pair p1 = townList.get(perm[i]);
    			Pair p2 = townList.get(perm[i + 1]);
    			double temp = Math.pow((p2.first - p1.first), 2) + Math.pow((p2.second - p1.second), 2) ;
    			ansList.add(Math.sqrt(temp));
    		}
        	return ansList;
        }

        for (int i = 0; i < seed.length; ++i) {
            if (used[i]) continue;
            perm[index] = seed[i];
            used[i] = true;
            buildPerm(seed, perm, used, index + 1, townList, ansList);
            used[i] = false;
        }
        return ansList;
    }

}

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

int main() {
    int_fast64_t N;
    cin >> N;

    vector<int_fast64_t> B(N);
    for(int_fast64_t i = 0, k; i < N; ++i){
        cin >> k;
        B[k - 1] = 1 + i + N * (N - k);
    }
    for(int_fast64_t i = 0; i < N; ++i)cout << i * N + 1 << (i ^ N - 1 ? " " : "\n");
    for(int_fast64_t i = 0; i < N; ++i)cout << B[i] << (i ^ N - 1 ? " " : "\n");
    cout << flush;
    return 0;
}

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

#define l long
#define ll long long
#define pb push_back
#define vb vector<bool>
#define vi vector<int>
#define vll vector<ll>
#define MOD 1000000007
#define MAX_TIME 1e9
#define nl "\n"
#define sp " "
#define gcd __gcd
#define pf printf
#define sf scanf

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int a,b;
    cin>>a>>b;
    cout<<a*b<<nl;
}

Measured memory_bytes: 3628
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 2e5 + 10;

char S[MR], T[MR];

int main()
{
	int H, W, N, sr, sc;
	scanf("%d%d%d%d%d%s%s", &H, &W, &N, &sr, &sc, S, T);

	{
		// L - wywalaj w lewo, bron na prawo
		int ileLS = 0, ileRT = 0;
		REP(i, N)
		{
			ileLS += S[i] == 'L';

			if (sc - ileLS + ileRT <= 0)
			{
				printf("NO\n");
				return 0;
			}

			ileRT += T[i] == 'R';
			if (sc - ileLS + ileRT > W)
				ileRT--;
		}
	}

	{
		// R - wywalaj w prawo, bron na lewo
		int ileRS = 0, ileLT = 0;
		REP(i, N)
		{
			ileRS += S[i] == 'R';

			if (sc + ileRS - ileLT > W)
			{
				printf("NO\n");
				return 0;
			}

			ileLT += T[i] == 'L';
			if (sc + ileRS - ileLT <= 0)
				ileLT--;
		}
	}

	{
		// U - wywalaj w gore, bron w dol
		int ileUS = 0, ileDT = 0;
		REP(i, N)
		{
			ileUS += S[i] == 'U';

			if (sr - ileUS + ileDT <= 0)
			{
				printf("NO\n");
				return 0;
			}

			ileDT += T[i] == 'D';
			if (sr - ileUS + ileDT > H)
				ileDT--;
		}
	}

	{
		// D - wywalaj w dol, bron w gore
		int ileDS = 0, ileUT = 0;
		REP(i, N)
		{
			ileDS += S[i] == 'D';

			if (sr + ileDS - ileUT > H)
			{
				printf("NO\n");
				return 0;
			}

			ileUT += T[i] == 'U';
			if (sr + ileDS - ileUT <= 0)
				ileUT--;
		}
	}

	printf("YES\n");

	return 0;
}

// FOR GNU C++ use the following pattern:
// Uncomment the code below and change your main into main2
// It does not build in MS C++
// But it does increase the stack size from 256 MB on CF and uses GNU C++

//#include <Processthreadsapi.h>
//#include <iostream>
//#include <Synchapi.h>
//#include <windows.h>
//#include <process.h>
//
//DWORD WINAPI MyThreadFunction(LPVOID lpParam) {
//    main2(nullptr);
//    return 0;
//}
//int main() {
//    auto h = CreateThread(nullptr, 1024 << 20, MyThreadFunction, nullptr, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
//    WaitForSingleObject(h, INFINITE);
//}

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

using namespace std;

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mod 998244353 
#define N 10000000
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>

const int inf = 100000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =100005;

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

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};
string to_string(char x){
	string s(1,x);
	return s;
}

int main()
{
    fio;
    string s;cin>>s;
    if(s[2]==s[3] && s[4]==s[5])cout<<"Yes\n";
    else cout<<"No\n";
}



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

#define ll long long int
#define mod (1000000007)

int main()
{
    ll n;
    cin>>n;
    ll ar[n+1];
    ll ans=0,sum=0;
    for(ll i=1;i<=n;i++)
    {
        cin>>ar[i];
        sum+=ar[i];
    }
    for(int i=1;i<=n;i++)
    {
        sum-=ar[i];
        ans+=(sum%mod*ar[i]%mod)%mod;
        ans%=mod;
    }
    cout<<ans%mod<<endl;
    return 0;
}


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

long long Gcd(long long a, long long b) {
  if (b == 0)
    return a;
  return Gcd(b, a % b);
}

int main() {
  long long A, B;
  cin >> A >> B;

  long long C = Gcd(A, B);
  map<int, int> p;
  for (long long i = 2; i * i <= Gcd(A, B); ++i)
    while (C % i == 0)
      ++p[i], C /= i;
  if (C != 1)
    ++p[C];

  cout << p.size() + 1 << endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	int K, X;
  	cin >> K >> X;
  	if(500*K>=X) puts("Yes");
  	else puts("No");
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int i,j,k;
        long sum;
        int[][] A = new int[101][101];
        int[][] B = new int[101][101];
        int[] n = new int[990];
        String[] str = new String[990];
        StringBuilder out = new StringBuilder();
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        str = in.readLine().split(" ");
        for(i=0;i<3;i++){
            n[i]=Integer.parseInt(str[i]);   
        }
        for(i=0;i<n[0];i++){
            str = in.readLine().split(" ");
            for(j=0;j<n[1];j++){
                A[i][j]=Integer.parseInt(str[j]);
            }
        }
        for(i=0;i<n[1];i++){
            str = in.readLine().split(" ");
            for(j=0;j<n[2];j++){
                B[i][j]=Integer.parseInt(str[j]);
            }
        }
        for(i=0;i<n[0];i++){
            for(j=0;j<n[2];j++){
                sum=0;
                for(k=0;k<n[1];k++){
                    sum += B[k][j]*A[i][k];             
                }
                if(j!=0) out.append(" ");
                out.append(sum);
            }
            out.append("\n");
        }   
        System.out.print(out);   
        System.out.flush();
    }
}

Measured memory_bytes: 32880