akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/14  Problem: 062_arc_a / Link: https://arc062.contest.atcoder.jp/tasks/arc062_a?lang=en  ----- */
/* ------問題------

シカのAtCoDeerくんは選挙速報を見ています。
選挙には二人の候補高橋くんと青木くんが出ています。
速報では、現在の二人の得票数の比が表示されていますが、得票数そのものは表示されていません。
AtCoDeerくんは N 回画面を見て、 i(1≦i≦N) 回目に見たときに表示されている比は Ti:Ai でした。
ここで、AtCoDeerくんが選挙速報の画面を1回目に見た段階で既にどちらの候補にも少なくとも一票は入っていたことがわかっています。 
N 回目に画面を見たときの投票数(二人の得票数の和)として考えられるもののうち最小となるものを求めてください。
ただし、得票数が途中で減ることはありません。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

/*最大公約数を求める関数(再帰版ユーグリッドの互除法)*/
long long  gcd(long long  a, long long  b) { return b ? gcd(b, a%b) : a; }

/*最小公倍数を求める関数。最小公倍数の性質( a×b÷[aとbの最大公約数] )を利用。*/
long long  lcm(long long  a, long long  b) { return a / gcd(a, b) * b; }

LL N;

LL ans = 0LL;

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

	cin >> N;
	LL A = 1, T = 1;
	FOR(i, 0, N) {
		LL t, a; cin >> t >> a;
		if (i == 0)A = a, T = t;
		else {
			LL x = max((A+a-1)/a,(T+t-1)/t);
			A = a*x;
			T = t*x;
		}
		
	}
	ans = A + T;
	cout << ans << "\n";

	return 0;
}


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

vector<vector<int>> adj;
vector<int> dp;

int longestPath(int node) {
    if(dp[node] >= 0) return dp[node];
    dp[node] = 0;
    for(int neigh : adj[node])
        dp[node] = max(longestPath(neigh) + 1, dp[node]);
    return dp[node];
}

int main() {
    int n, m;
    cin>>n>>m;
    adj.resize(n + 1);
    dp.resize(n + 1, -1);
    for(int i=1; i<=n; i++) adj[0].push_back(i);
    while(m--) {
        int u, v;
        cin>>u>>v;
        adj[u].push_back(v);
    }
    cout<< longestPath(0) - 1 <<endl;
    return 0;
}


Measured memory_bytes: 8568
N,A,B = map(int, input().split())

total = 0
for i in range(1,N+1):
    
    flag = True
    res = 0
    j = i
    while(flag):
        res = res + j%10
        j = int(j/10)
        if(j==0):
            flag = False
    if(A<=res & res<=B):
        total = total + i
print(total)

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

char a[105], b[105];


int main(void) {

	int i;

	int lena, lenb;

	scanf("%s", a);
	scanf("%s", b);

	lena = strlen(a);
	lenb = strlen(b);

	if (lena > lenb) {
		printf("GREATER\n");
		return 0;
	}
	else if (lena < lenb) {
		printf("LESS\n");
		return 0;
	}
	else
	{
		for (i = 0; i <=lena-1; i++) {
			if (a[i] > b[i]) {
				printf("GREATER\n");
				return 0;
			}
			else if (a[i] < b[i]) {
				printf("LESS\n");
				return 0;
			}
		}

	}

	printf("EQUAL\n");


	return 0;

}

Measured memory_bytes: 128
/*
AizuOnline A1159
Title Next Mayor
13/3/23 TE
*/
#include <stdio.h>
// Select Below
#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int m,p,cp,cs;
int stone[50];
int step;
//
main()
{
  int i,nin,winp;

  //m=10;p=4;//scanf
  while(EOF!=scanf("%d %d ",&m,&p) && (m||p)){
    //printf("mp= %d %d\n",m,p);
  cs=p;
  cp=0;step=0;nin=0;
  memset(stone,0,200);
  while((nin!=1) || cs)
    {
    if(cs)
      {
	for(i=0;i<cs;i++)
	  stone[(cp+i)%m]++;
	cp=(cp+cs)%m;
	cs=0;
      }
    else
      {
	cs+=stone[cp];
	stone[cp]=0;
	cp=(cp+1)%m;
      }
    nin=0;
    for(i=0;i<m;i++)
      if(stone[i])
	{
	nin++;
	winp=i;
	}
#if DEBUG
    for(i=0;i<m;i++)
      printf("%d ",stone[i]);
    printf(":%d (%d)\n",cs,nin);
#endif
    }
    printf("%d\n",winp);
  }
return(0);
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main()
{
    int n,x,ans;
    cin>>n>>x;
    ans=n;
    vector<int> m(n);
    
    for(int i = 0; i < n; i++)
    {
        cin>>m[i];
        x-=m[i];
    }
    sort(all(m));
    ans += x/m[0];

    cout <<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', (line) => {
    // ここで入力を処理する
    lines.push(line);
});
var sub_fn = (ary)=>{
  
}
reader.on('close', () => {
  var x = 1*lines[0].split(' ')[0]
  var min = 1*lines[0].split(' ')[1]
  var max = 1*lines[0].split(' ')[2]
  var a_ary = [];
  for (i = 1; i <= x; i++){
    var n = 0;
    var n_ary = (" " + i).split("")
    for(var j in n_ary){
      n += 1*n_ary[j]
    }
    if(n >= min && n <= max){
      a_ary.push(i)
    }
  }
 // console.log(a_ary)
  var ans = 0;
  for(var k in a_ary){
    ans += a_ary[k]
  }


  console.log(ans)
});

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

struct r {
	ll index;
	string city;
	ll point;
};

bool f(r a, r b) {
	return ( (a.city == b.city) ? (a.point > b.point) : (a.city < b.city) );
}

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;

	vector<r> sp(n);
	rep(i, n) {
		cin >> sp[i].city >> sp[i].point;
		sp[i].index = i + 1;
	}

	sort(sp.begin(), sp.end(), f);

	rep(i, n) {
		cout << sp[i].index << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import sys
from math import factorial
def main():
    packages, remainder = receiveInputData()

    packages.countOddAndEven()

    even_ways = packages.calculateEvenWays()
    odd_ways_remainder0, odd_ways_remainder1 = packages.calculateOddWays()

    if remainder.isZero():
        print(even_ways * odd_ways_remainder0)
        return

    print(even_ways * odd_ways_remainder1)






class Package():
    def __init__(self, packages_list, packages_num):
        if not isinstance(packages_list, list):
            print('Package Class argument error')
            sys.exit(1)

        # 問題の制約では、1以上50以下である
        if packages_num < 1 or packages_num > 50:
            print('Package Class Restriction error')
            print(packages_num)
            sys.exit(1)

        self.packages = packages_list
        self.packages_num = packages_num

    # 中に入っているビスケットの数が偶数の袋、奇数の袋それぞれ数える
    def countOddAndEven(self):
        self.packages_num_of_odd_biscuits  = 0
        self.packages_num_of_even_biscuits = 0
        for pack_i, biscuits_num in enumerate(self.packages):
            if biscuits_num % 2 == 0:
                self.packages_num_of_even_biscuits += 1
            else:
                self.packages_num_of_odd_biscuits += 1

    # 偶数個含まれる袋の選び方は何通りかを返す
    # 袋ごとに　食べる　食べない　の２通りなので
    # m袋あれば　2^m通り
    def calculateEvenWays(self):
        return 2 ** self.packages_num_of_even_biscuits

    def calculateOddWays(self):
        count_combination_list = self.calculateCombination(self.packages_num_of_odd_biscuits)

        # あまりPが0の場合
        # 奇数個含まれる袋は、偶数個選ばなければならない
        selected_even_odds = sum(count_combination_list[::2])

        # あまりPが1の場合
        # 奇数個含まれる袋は、奇数個選ばなければならない
        selected_odd_odds = sum(count_combination_list[1::2])

        return selected_even_odds, selected_odd_odds

    def calculateCombination(self,n):
        # i番目にはnCi
        select_ways_of_odd = [1]
        for select_num in range(1,n + 1):
            n_C_i = factorial(n) // (factorial(select_num) * factorial(n - select_num))
            select_ways_of_odd.append(n_C_i)
        return select_ways_of_odd











class Remainder():
    def __init__(self, remainder_0or1):
        if not isinstance(remainder_0or1, int):
            print('Remainder Class argument error')
            sys.exit(1)

        # 問題の制約では、0か1
        if remainder_0or1 != 0 and remainder_0or1 != 1:
            print('Remainder Class Restriction error')
            sys.exit(1)

        self.remainder = remainder_0or1


    def isZero(self):
        if self.remainder == 0:
            return True
        return False


def receiveInputData():

    N, P = map(int, input().split())
    A = list(map(int,input().split()))

    return Package(A, N), Remainder(P)

if __name__ == '__main__':
    main()


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

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >>d;
	if (abs(c - a) <= d || ((abs(b - a) <= d && abs(c - b) <= d)))
		cout << "Yes";
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll cnt[66][2];
int main(){
	int n;cin>>n;
	for(int i=0;i<n;i++){
		ll a;cin>>a;
		int bit=0;
		while(a){
			if(a&1){
				cnt[bit][1]++;
			}else cnt[bit][0]++;
			a/=2;
			bit++;
		}
		for(int j=bit;j<=64;j++)cnt[j][0]++;
	}
	ll ans=0;
	for(int i=0;i<=62;i++){
		ll p=(1LL<<i);p%=mod;
		ll hano=cnt[i][0]*cnt[i][1];
		hano%=mod;
		ans+=(p*hano);
		ans%=mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3604
n = int(input())
s = [input() for _ in range(n)]

base = sum(x.count('AB') for x in s)

same_pattern = a_n = b_n = 0
for x in s:
    b = x[0]
    a = x[len(x)-1]
    if b == 'B':
        b_n += 1
    if a == 'A':
        a_n += 1
    if a == 'A' and b == 'B':
        same_pattern += 1

if same_pattern > 0 and same_pattern == max(a_n, b_n):
    print(base + max(a_n, b_n) - 1)
else:
    print(base + min(a_n, b_n))

Measured memory_bytes: 3700
import copy
import heapq


class Node:
    def __init__(self):
        self.value = -1

    def __repr__(self):
        return "<v: {}>".format(self.value)


N = int(input())

adjs = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = [int(i) for i in input().split()]
    adjs[a-1].append(b-1)
    adjs[b-1].append(a-1)
adjs_copy = [copy.copy(adj) for adj in adjs]

C = [int(i) for i in input().split()]

cq = []
for c in C:
    heapq.heappush(cq, c)


nodes = [Node() for _ in range(N)]
changed = True
while changed:
    changed = False
    for i in range(N):
        if len(adjs[i]) == 1:
            nodes[i].value = heapq.heappop(cq)

            neighbor = adjs[i][0]
            adjs[i] = []
            adjs[neighbor].remove(i)

            changed = True
for node in nodes:
    if node.value == -1:
        node.value = heapq.heappop(cq)
        break


score = 0
for i in range(N):
    adj = adjs_copy[i]
    for ad in adj:
        score += min(nodes[i].value, nodes[ad].value)
score = score // 2

print(score)
print(*[str(node.value) for node in nodes])


Measured memory_bytes: 59864
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s1,s2;
	int flag=0;
	cin>>s1>>s2;
	if(s2.size()!=(s1.size()+1)){
		cout<<"No";
		flag=1;
	}
	if(flag==0){
		while(s1[0]==' '){
			s1.erase(s1.begin());
		}
		while(s2[0]==' '){
			s2.erase(s2.begin());
		}
		const string::size_type cols = s1.size();
		
	for(long unsigned int i=0;i<cols;i++){
		if(s1[i]!=s2[i]){
			cout<<"No";
			return 0;
		}
	}
    }
	cout<<"Yes";
}

Measured memory_bytes: 3624
numbers = [int(i) for i in input().split()]

if numbers[0] > numbers[1]:
    tmp = numbers[0]
    numbers[0] = numbers[1]
    numbers[1] = tmp

if numbers[1] > numbers[2]:
    tmp = numbers[1]
    numbers[1] = numbers[2]
    numbers[2] = tmp


if numbers[0] > numbers[1]:
    tmp = numbers[0]
    numbers[0] = numbers[1]
    numbers[1] = tmp

str_numbers = list(map(str, numbers))
print(' '.join(str_numbers))


Measured memory_bytes: 5600
#include <iostream>
#include <vector>

using namespace std;

void PrintRectangle(vector<vector<int>> data){

    for ( vector<int> elem : data) {
        for (int i = 0; i < elem[0]; i++) {
            for (int j = 0; j < elem[1]; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}

int main(){
    // ---------------------------
    // ITP_1_5_A: Print a Rectangle
    int w, h;
    std::vector<std::vector<int>> data;
    while (true){
        std::cin >> h >> w;
        if (h == 0 && w ==0)
            break;
        data.push_back({h, w});
    }
    PrintRectangle(data);
    // ---------------------------

    // ---------------------------
    // ITP_1_5_B: Print a Frame
    // ---------------------------

    // ---------------------------
    // ITP_1_5_C: Print a Chessboard
    // ---------------------------

    // ---------------------------
    // ITP_1_5_D: Structured Programing
    // ---------------------------

    return 0;
}


Measured memory_bytes: 3172
#include<iostream>
#include<deque>
using namespace std;
int N,M;
string s[100];
int d[100][100];
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
main()
{
	while(cin>>M>>N,N)
	{
		for(int i=0;i<N;i++)
		{
			cin>>s[i];
			for(int j=0;j<M;j++)d[i][j]=i==0||j==0||i==N-1||j==M-1?0:1e9;
		}
		deque<pair<int,int> >P;
		for(int i=0;i<N;i++)P.push_back(make_pair(i,0)),P.push_back(make_pair(i,M-1));
		for(int j=1;j<M-1;j++)P.push_back(make_pair(0,j)),P.push_back(make_pair(N-1,j));
		while(!P.empty())
		{
			int x=P.front().first,y=P.front().second;
			P.pop_front();
			for(int r=0;r<4;r++)
			{
				int tx=x+dx[r],ty=y+dy[r];
				if(tx<0||ty<0||tx>=N||ty>=M)continue;
				int cost=s[x][y]=='#'&&(s[tx][ty]=='.'||s[tx][ty]=='&')?1:0;
				if(d[x][y]+cost>=d[tx][ty])continue;
				d[tx][ty]=d[x][y]+cost;
				if(cost==1)P.push_back(make_pair(tx,ty));
				else P.push_front(make_pair(tx,ty));
			}
		}
		for(int i=0;i<N;i++)for(int j=0;j<M;j++)if(s[i][j]=='&')cout<<d[i][j]<<endl;
	}
}



Measured memory_bytes: 3248
#include<bits/stdc++.h>
#define ll long long
#define INF 100000000000
using namespace std;
int main()
{
    vector<vector<ll> >dp(101,vector<ll>(100001,INF));
    vector<ll>val(101);
    vector<ll>w(101);
    ll a,b,c,d,e,f,g,h,n,m,t,W,ans=0;
    ios_base::sync_with_stdio(false);
    cin>>n>>W;
    for(int i=1;i<=n;i++)cin>>w[i]>>val[i];
    //for(int i=0;i<=100;i++)dp[i][0]=0;
    //for(int i=0;i<=100000;i++)dp[0][i]=0;
    m=n*1000;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            a=w[i];
            b=dp[i-1][j];
            /**/if(val[i]<j)a=dp[i-1][j-val[i]]+w[i];
            dp[i][j]=min(a,b);
        }
    }
    for(int i=1;i<=n;i++){
        for(ll j=1;j<=m;j++){
            if(dp[i][j]>W||dp[i][j]==0)continue;
            ans=max(ans,j);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
typedef long long  int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

ll n;
vector <ll> ss;
ll m;
vector <ll> ts;
vector <vector <ll>> memo;
ll d = 1e9 + 7;

ll count_same(ll s_idx, ll t_idx){
    if (s_idx >= n){
        return 0;
    }
    if (t_idx >= m){
        return 0;
    }
    if (memo[s_idx][t_idx] >= 0){
        return memo[s_idx][t_idx];
    }
    ll val = 0;
    val += count_same(s_idx, t_idx+1);
    val += count_same(s_idx+1, t_idx);
    val += d - count_same(s_idx+1, t_idx+1);
    if (ss[s_idx] == ts[t_idx]){
        val += 1 + count_same(s_idx+1, t_idx+1);
    }
    val = val % d;
    memo[s_idx][t_idx] = val;
    return val;
}



int main(void){
    cin >> n;
    cin >> m;
    ll s;
    REP(i, n){
        cin >> s;
        ss.push_back(s);
    }
    ll t;
    REP(i, m){
        cin >> t;
        ts.push_back(t);
    }
    REP(i, n){
        vector <ll> v;
        REP(j, m){
            v.push_back(-1);
        }
        memo.push_back(v);
    }
    cout << count_same(0, 0)+1 << endl;
    return 0;
}

Measured memory_bytes: 32000
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main(void){
    int a, b, c, k;
    std::cin >> a >> b >> c >> k;
    if(a >= k) std::cout << k << std::endl;
    else if(b + a >= k) std::cout << a << std::endl;
    else std::cout << a - (k - b - a) << std::endl;

    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        long checkNum;
        long blueBall;
        long redBall;

        Scanner scanner = new Scanner(System.in);
        String inputData = scanner.nextLine();
        scanner.close();

        String[] editedInputData = inputData.split(" ");
        checkNum = Long.parseLong(editedInputData[0]);
        blueBall = Long.parseLong(editedInputData[1]);
        redBall = Long.parseLong(editedInputData[2]);

        long blueAndRed = blueBall + redBall;
        long countBall = checkNum % blueAndRed;
        long blueAndRedBallSet = checkNum / blueAndRed;
        
        long totalBlueBall = blueAndRedBallSet * blueBall;

        if (countBall <= blueBall) {
            totalBlueBall += countBall;
        } else {
            totalBlueBall += blueBall;
        }

        System.out.println(totalBlueBall);

    }
}

Measured memory_bytes: 22996
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int a,b;
    a = sc.nextInt();
    b = sc.nextInt();

    System.out.println(a * b + " " + (a + a + b + b));
/*fin*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17152
N=int(input())
S=input()
S=list(S)
for i in range(len(S)):
    count=0
    for j in range(i,len(S)-1):
        if S[j]==S[j+1]:
            count+=1
        else:
            break
    #print(count)
    if count>0:
        del S[i+1:i+count+1]
    #print(S)
    if i==len(S)-1:
        break
#print(S)
print(len(S))

Measured memory_bytes: 4644
fun main() {
  val (N, K) = readInts()
  val V = readInts()

  var max = 0
  for (l in 0..K) {
    for (r in 0..K) {
      if (l + r > K) continue
      if (l + r > N) continue
      val ope = K - l - r
      var value = 0
      val negaValues = mutableListOf<Int>()
      for (i in 0 until l) V[i].let { v -> if (v < 0) negaValues.add(v) else value += v }
      for (i in 0 until r) V[N - i - 1].let { v -> if (v < 0) negaValues.add(v) else value += v }
      negaValues.sort()
      value += negaValues.drop(ope).sum()
//      println("$l $r $value")
      max = kotlin.math.max(max, value)
    }
  }
  println(max)
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readStrings() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


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

public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String test = br.readLine();
		String[] result = test.split(" ");
		System.out.println(Integer.parseInt(result[0]) *Integer.parseInt(result[1]) + " " + (Integer.parseInt(result[0]) +Integer.parseInt(result[1]))*2); 
	}

}

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

int gcd_two(int a, int b){
    int r = a%b;
    while(r != 0){
        a = b;
        b = r;
        r = a%b;
    }
    return b;
}

int gcd_three(int a,int b, int c){
    return gcd_two(gcd_two(a,b),gcd_two(b,c));
}

int K,sum=0;
int main(){
    cin >> K;
    for(int a=1;a<K+1;a++){
        for(int b=1;b<K+1;b++){
             for(int c=1;c<K+1;c++){
                sum += gcd_three(a,b,c);
             }
        }
    }
    cout << sum << endl;
    return 0;  
}

Measured memory_bytes: 3620
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    let a: u64;
    let b: u64;
    let c: u64;
    let mut k: u64;
    let mut x: u64;
    let mut sum: i64 = 0;

    input! {
        a: u64,
        b: u64,
        c: u64,
        k: u64,
    }

    if k < a {
        println!("{}", k);
    } else {
        sum = a as i64;
        x = k - a;
        if b < x {
            x = x - b;
            sum -= x as i64;
            println!("{}", sum)
        } else {
            println!("{}", sum)
        }
    }
}


Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll N, K; cin >> N >> K;
	ll mod = N%K;
	cout << min(mod, K-mod);
}


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

using namespace std;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    // 操作をK回
    string s;
    int K;
    cin >> s >> K;
    vector<int> cnts(s.size());
    ll tmp = K;
    rep(i, s.size()){
        cnts[i] = (26 - (s[i] - 'a')) % 26;
        if(cnts[i] <= tmp){
            tmp -= cnts[i];
            s[i] = 'a';
        }
    }
    s[s.size() - 1] = (s[s.size() - 1] + tmp - 'a') % 26 + 'a';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N;
string S;
ll t[5001], f[5001], t2[5001], f2[5001];
vector<pair<pair<pair<int,int>, int>, int>>v;
int res;

int main() {
	cin >> N >> S;
	f[0] = f2[0] = 1;
	for (int i = 1; i <= 5000; ++i) {
		f[i] = f[i - 1] * 30 % mod;
		f2[i] = f2[i - 1] * 30 % mod998;
	}
	for (int i = 1; i <= N; ++i) {
		t[i] = (t[i - 1] * 30 + S[i - 1] - 'a' + 1) % mod;
		t2[i] = (t2[i - 1] * 30 + S[i - 1] - 'a' + 1) % mod998;
	}
	for (int i = 1; i <= N; ++i) {
		for (int j = i; j <= min(i + N / 2, N); ++j) {
			v.push_back(mkp(mkp(mkp((t[j] - t[i - 1] * f[j - i + 1] % mod + mod) % mod, (t2[j] - t2[i - 1] * f2[j - i + 1] % mod998 + mod998) % mod998), j - i + 1), i));
		}
	}
	sort(v.begin(), v.end());
	pair<pair<pair<int, int>, int>, int>P = mkp(mkp(mkp(-1, -1), -1), -1);
	for (int i = 0; i < v.size(); ++i) {
		if (P.first == v[i].first) {
			if (P.second + P.first.second <= v[i].second) {
				res = max(res, P.first.second);
			}
		}
		else {
			P = v[i];
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 264672
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

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

int h,w;
vector<vector<char>> d(410, vector<char>(410,'?'));
vector<vector<bool>> used(410, vector<bool>(410,false));

ll bfs(int x, int y){
  ll wh=0,bl=0;
  queue<P> q;
  q.push({x,y});
  used[x][y]=true;

  while(!q.empty()){
    P p = q.front(); q.pop();
    if(d[p.F][p.S]=='.'){ wh++; } else { bl++; }
    rep(i,4){
      int nx = p.F+dx[i], ny = p.S+dy[i];
      if(nx<0 || h<=nx || ny<0 || w<=ny) continue;
      if(used[nx][ny]) continue;
      if(d[p.F][p.S]==d[nx][ny]) continue;
      q.push({nx,ny});
      used[nx][ny] = true;
    }
  }
  return wh*bl;
}

int main() {
  cin >> h >> w;
  rep(i,h)rep(j,w) cin >> d[i][j];

  ll ans = 0;
  rep(i,h)rep(j,w)if(d[i][j]=='#' && !used[i][j]){
    ans += bfs(i,j);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
import sys
import collections

sys.setrecursionlimit(10**6)
input = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    H, W, M = map(int, input().split())
    bombs = []
    for _ in range(M):
        h, w = map(int, input().split())
        bombs.append((h, w))
    bombs_set = set(bombs)
    g = list(zip(*bombs))
    g0 = collections.Counter(g[0])
    g1 = collections.Counter(g[1])
    g0items = list(g0.items()); g0items.sort(key=lambda x: x[1], reverse=True)
    g1items = list(g1.items()); g1items.sort(key=lambda x: x[1], reverse=True)
    x = g0items[0][0];countx = g0items[0][1]
    y = g1items[0][0];county = g1items[0][1]
    for xx, s in g0items:
        if s != countx:
            continue
        for yy, t in g1items:
            if t != county:
                break
            if (xx, yy) not in bombs_set:
                x, y = xx, yy
                break
    ans = countx + county - ((x, y) in bombs)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 132356
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <stack>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

vector<ll> D;
bool dpx[8001][16001], dpy[8001][16001];

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

    string s;
    ll x, y;
    cin >> s;
    cin >> x >> y;

    for (ll i = 0, n = 0; i < s.size(); i++) {
        if (s[i] == 'F') {
            n++;
        } 
        if (s[i] == 'T' || i == s.size() - 1) {
            D.push_back(n);
            n = 0;
        }
    }

    dpx[0][8000] = dpy[0][8000] = true;
    dpx[1][D[0] + 8000] = true;

    for (ll i = 2; i <= D.size(); i++) {
        for (ll j = -8000; j <= 8000; j++) {
            if (i % 2 == 0) {
                dpx[i][j + 8000] = dpx[i - 1][j + 8000];
                continue;
            }

            bool b = false;
            if (j - D[i - 1] >= -8000) {
                b |= dpx[i - 1][j + 8000 - D[i - 1]];
            }
            if (j + D[i - 1] <= 8000) {
                b |= dpx[i - 1][j + 8000 + D[i - 1]];
            }
            dpx[i][j + 8000] = b;
        }
    }

    for (ll i = 1; i <= D.size(); i++) {
        for (ll j = -8000; j <= 8000; j++) {
            if (i % 2) {
                dpy[i][j + 8000] = dpy[i - 1][j + 8000];
                continue;
            }

            bool b = false;
            if (j - D[i - 1] >= -8000) {
                b |= dpy[i - 1][j + 8000 - D[i - 1]];
            }
            if (j + D[i - 1] <= 8000) {
                b |= dpy[i - 1][j + 8000 + D[i - 1]];
            }
            dpy[i][j + 8000] = b;
        }
    }

    if (dpx[D.size()][x + 8000] && dpy[D.size()][y + 8000]) {
        cout << "Yes" << endl;
        return 0;
    }

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



Measured memory_bytes: 250240
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int a[3];
int main(){
    rep(i,3) cin >> a[i];
    int ct = 0;
    while(a[0] != a[1] || a[1] != a[2] || a[2] != a[0]){
        ct++;
        sort(a,a+3);
        if(a[0] != a[1]) a[0] += 2;
        else a[0]++, a[1]++;
    }
    cout << ct << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,x;
int p[200001]={0};
int a[200001]={0};
int gcd(int u,int v)
{
	if(v==0)
	 return u;
	else
	 gcd(v,u%v);
}
int main()
{
	cin>>n>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]<x)
		{
			a[i]=x-a[i];
		}
		if(a[i]>x)
		{
			a[i]-=x;
		}
		if(a[i]==x)
		{
			a[i]=1;
		}
	}
	for(int i=2;i<=n;i++)
	{
		a[i]=gcd(a[i],a[i-1]);
	}
	cout<<a[n];
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define endl '\n'
using ll=long long;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=100005;
const int mod=1e9+7;
const ll oo=1e18+5;
			

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	int n,m;
	cin>>n>>m;
	vector<int> check(n+1);
	vector<int> cnt_wa(n+1);
	int ans=0,pen=0;
	while(m--){
		int p;
		string s;
		cin>>p>>s;
		if(!check[p]){
			if(s=="WA"){
				++cnt_wa[p];
			}
			else{
				++ans;
				pen+=cnt_wa[p];
				check[p]=1;
			}
		}
	}
	cout<<ans<<" "<<pen<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int r;
  cin >> r;
  cout<<3*r*r<<endl;
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    long double n, m, d;
    cin >> n >> m >> d;
    long double ans;
    if (d != 0)
        ans = 2.0 * (m - 1) * (n - d) / (n * n);

    else
        ans = (m - 1) / (n);
    cout << setprecision(10) << ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int[]l = new int[n];

    int cou = 1;
    int d = 0;
    int a = 0;
    for(int i=0; i<n; i++) {
    	l[i] = sc.nextInt();
    	if(d+l[i] <= x ) {
    		d += l[i];
    		cou++;
    	}else {
    		break;
    	}
    }
    System.out.print(cou);
    }
}


Measured memory_bytes: 35992
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#define MAX_INT 2100000000
using namespace std;
typedef long long int ll;
//#include "Header.h"
int main()
{
	string s;
	int i, ans1=0, ans2=0;
	cin >> s;
	for (i = 0; i < s.length(); i++)
	{
		if (i % 2)
		{
			if (s[i] == '1') ans1++;
			else ans2++;
		}
		else {
			if (s[i] == '1') ans2++;
			else ans1++;
		}
	}
	cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include<bitset>
#include <type_traits>
#include <vector>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n - 1); i >= 0; --i)
#define mod 100000
#define INF 93193111451418101
#define MIN -933111451418101
#define EPS 1e-9
#define pb push_back
using namespace std;
typedef pair<ll, ll> P;
typedef pair<double, double> dop;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
	for (auto &i : arr) {
		fill_all(i, v);
	}
}
//------------------変数-----------------------//
ll n;
double dp[30000][309]; // [time,speed]
std::vector<ll> t, v;
ll speed[114514];//[time]=speed
//-------------------関数----------------------//

int main() {
	cin >> n;
	ll maxtime = 0;//合計の時間
	REP(i, n) {
		ll h;
		cin >> h;
		t.pb(h);
		maxtime += h;
	}
	REP(i, n - 1) { t[i + 1] += t[i]; }//imos
	REP(i, n) {
		ll h;
		cin >> h;
		v.pb(h);
	}
	ll itr = 0;
	REP(i, maxtime) {
		if (t[itr] == i) {
			itr++;
		}
		speed[i] = v[itr];//その時のspeed
	}
	fill_all(dp, (double)-1919191919);
	dp[0][0] = 0;
	REP(i, maxtime) {//time
		REP(j, 301) {//speed
			if (dp[i][j] == -1919191919) { continue; }
			for (ll k = -1; k < 2; k++) {//-1=down,0= straight,1= up
				if (j + k > speed[i + 1] || j + k < 0) {//speedが上限を超えているor0より下
					continue;
				}
				if (k == 1 && j  == speed[i]) {//上がっていく際に、はみ出してしまったらだめ（配列の作り方から考えてこうなる
					continue;
				}
				dp[i + 1][j + k] = max(dp[i + 1][j + k], dp[i][j] + j + k * 0.5);
			}
			if (speed[i] > j&&speed[i+1]>=j) {
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + 0.25 + j);
			}
		}
	}
	printf("%.10f\n", dp[maxtime][0]);
}


Measured memory_bytes: 72832
import sys
input = sys.stdin.readline

n, q = map(int, input().split())

Len = (n-1).bit_length()
size = 2**Len
tree = [0]*(2*size)
lazy = [0]*(2*size)
INF = 2**31 -1

def gindex(l,r):
    box = []
    L = (l+size)>>1;R=(r+size)>>1
    lc = 0 if l & 1 else (L&-L).bit_length()
    rc = 0 if r & 1 else (R&-R).bit_length()
    for i in range(Len):
        if rc <= i:
            box.append(R)
        if L < R and lc <= i:
            box.append(L)
        L >>= 1; R >>= 1
    return box
        
        

def propagates(ids):
    for i in reversed(ids):
        v = lazy[i]
        if v is None:
            continue
        lazy[2*i] += v
        tree[2*i] += v
        lazy[2*i+1] += v
        tree[2*i+1] += v
        lazy[i]=0

def update(l,r,x):
    L = size+l
    R = size+r
    while L<R:
        if R&1:
            R -= 1
            lazy[R] += x
            tree[R] += x
        if L&1:
            lazy[L] += x
            tree[L] += x
            L+=1
        L>>=1;R>>=1
    ids = gindex(l,r)
    for i in ids:
        if 2*i+1<size*2:
            tree[i]= min(tree[i*2],tree[i*2+1]) + lazy[i]
        
def query(l, r):
    ids = gindex(l, r)
    propagates(ids)
    L = size + l
    R = size + r
    s = INF
    while L<R:
        if R&1:
            R-=1
            s =min(s, tree[R])
        if L&1:
            s =min(s, tree[L])
            L+=1
        L>>=1;R>>=1
    return s

ans = []
for i in range(q):
    a, *b = map(int, input().split())
    if a:
        ans.append(query(b[0],b[1]+1))
    else:
        update(b[0],b[1]+1,b[2])
        
print('\n'.join(map(str,ans)))


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

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    
    rep(i,n) {
        cin >> c[i];
        rep(j,m) {
            cin >> a[i][j];
        }
    }
    
    int ans = 0;
    rep(i,1<<n) {
        int d = 0;
        bool tf = true;
        vector<int> s(m);
        rep(j,n) {
            if(i>>j&1) {
                d += c[j];
                rep(k,m)
                    s[k] += a[j][k];
            }
        }
        rep(j,m) {
            if(s[j] < x) {
                tf = false;
                break;
            }
        }
        if(tf) {
            if(ans == 0)
                ans = d;
            else
                ans = min(d,ans);
        }
    }
    
    if(ans == 0)
        cout << -1 << endl;
    else
        cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
	int a[1000] = { 0 }, n, x[1000] = { 0 };
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
           scanf("%d", &a[i]);
	}
	for (int j = n-1; j >=0; j--)
	{
		x[j] = a[j];
        printf("%d", x[j]);
		if (j == 0)
			break;
		printf(" ");
	}
	printf("\n");
		return 0;
}

Measured memory_bytes: 2676
#include<bits/stdc++.h>
using namespace std;
#define Jewel ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    Jewel;
    int n, a, ok=1, i;
    cin>>n;
    while(n--)
    {
        cin>>a;
        if(a%2==0)
        {
            if(a%3 && a%5)
                ok = 0;
        }
    }
    if(ok)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    d = defaultdict(int)
    free = 0
    for i in range(N):
        if 1<=A[i]<400:
            d['gray'] += 1
        elif 400<=A[i]<800:
            d['brown'] += 1
        elif 800<=A[i]<1200:
            d['green'] += 1
        elif 1200<=A[i]<1600:
            d['light_blue'] += 1
        elif 1600<=A[i]<2000:
            d['blue'] += 1
        elif 2000<=A[i]<2400:
            d['yellow'] += 1
        elif 2400<=A[i]<2800:
            d['orange'] += 1
        elif 2800<=A[i] < 3200:
            d['red'] += 1
        else:
            free += 1
    ans_min = max(len(d.keys()), 1)
    ans_max = len(d.keys())+free
    print(ans_min, ans_max)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,a,i,j;
    cin>>n;
    int ex=0,rank[8]={0};
    for (i=0;i<n;i++)
    {
        cin>>a;
        if (a>=3200)
            ex++;
        else
            rank[a/400]++;
    }
    int ctr=0;
    for (i=0;i<8;i++)
    {
        if (rank[i]>0)
            ctr++;
    }
    cout<<max(1,ctr)<<" "<<ctr+ex<<endl;
}

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

int main(){
	int n;
	cin >> n;
	vector<tuple<string, int, int>> list;

	for(int i = 1; i <= n; i++){
		string s;
		int p;
		cin >> s >> p;
		p *= -1;
		list.emplace_back(tie(s, p, i));
	}
		sort(list.begin(), list.end());

		rep(i, n){
			string s;
			int id, p;
			tie(s, p, id) = list.at(i);
			cout << id << endl;
		}
		return 0;

}

Measured memory_bytes: 256
module.exports=function(t){var e={};function i(r){if(e[r])return e[r].exports;var s=e[r]={i:r,l:!1,exports:{}};return t[r].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(r,s,function(e){return t[e]}.bind(null,s));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";var r=i(1);i(2)(r.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,i){"use strict";var r=i(3),s=i(5);t.exports=function(t){var e=new r(t);s(e)}},function(t,e,i){"use strict";var r=i(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new r(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,i){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,i){"use strict";var r=i(6);t.exports=function(t){for(var e=t.in(),i=t.in(),s=new r,n=0;n<e;n++){var o=t.in();s.pushItem(o)}for(var h=0;h<i;h++){var a=s.getTop();s.removeTop(),s.pushItem(Math.floor(a/2))}for(var u=0,p=s.getValuesList(),f=0;f<e;f++)u+=p[f];console.log(u)}},function(t,e,i){"use strict";function r(t,e){return t<=e}function s(t,e){return t>=e}t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;this.cf=e?r:s,i&&(this.cf=i),this.heap=t,this.size=this.heap.length,this.heapify()}heapify(){for(var t=0,e=this.size;2*t+1<=e;)t=2*t+1;for(var i=t-1;i>=0;)2*i+1>e-1?i--:(this.downHeap(i),i--)}downHeap(t){for(var e=this.size,i=t;2*i+1<e;){var r=this.heap[2*i+1],s=2*i+2<e?this.heap[2*i+2]:r,n=this.cf(s,r)?r:s,o=this.cf(s,r)?2*i+1:2*i+2;if(this.cf(n,this.heap[i]))break;var h=n;this.heap[o]=this.heap[i],this.heap[i]=h,i=o}}upHeap(t){for(var e=t;0!=e;){var i=Math.floor((e-1)/2);if(this.cf(this.heap[e],this.heap[i]))break;var r=this.heap[i];this.heap[i]=this.heap[e],this.heap[e]=r,e=i}}pushItem(t){this.size+=1,this.heap.push(t),this.upHeap(this.size-1)}getTop(){return this.heap[0]}removeTop(){return 0!=this.size&&(1==this.size?(this.size=0,this.heap=[],!0):(this.size-=1,this.heap[0]=this.heap.pop(),this.downHeap(0),!0))}getValuesList(){return this.heap}}}]);

Measured memory_bytes: 27676
#include <iostream>

using namespace std;

int main(){
	char str[1000];
	int i=0;
	cin>>str;
	while(str[i]){
		if(str[i]<=67){
			str[i]+=23;
		} else {
			str[i]-=3;
		}
		i++;
	}
	cout<<str<<endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

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

	ll N; cin >> N; N--;

	ll ans = 0;
	for (ll A = 1; A <= N; A++) {
		ans += N / A;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3664
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

// ref: http://prd-xxx.hateblo.jp/entry/2017/10/13/004256
struct BipartileGraph {
    vi colors;
    vvi edges;
    BipartileGraph(int n) : colors(n, -1), edges(n) {}
    void addEdge(int f, int t) {
        edges[f].emplace_back(t);
        edges[t].emplace_back(f);
    }
    bool build(int s, int color = 0) {
        colors[s] = color;
        for (auto &e : edges[s]) {
            if (colors[e] == color)
                return false;
            if (colors[e] == -1 && !build(e, color ^ 1))
                return false;
        }
        return true;
    }
};

int main() {
    ll n, m;
    cin >> n >> m;
    BipartileGraph gr(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        gr.addEdge(a, b);
    }
    bool bipartile = gr.build(0);
    if (bipartile) {
        ll col1 = 0;
        ll col2 = 0;
        for (int i = 0; i < n; ++i) {
            if (gr.colors[i] == 1)
                col1++;
            else if (gr.colors[i] == 0)
                col2++;
        }
        assert(col1 + col2 == n);
        cout << col1 * col2 - m << "\n";
    } else {
        cout << n * (n - 1) / 2 - m << "\n";
    }
    return 0;
}

Measured memory_bytes: 6272