akhauriyash/Code-Regression huggingface dataset:
N = int(input())
S = [input() for _ in range(N)]
S.sort()

ans = []
counter = 1
memo = 0

for i in range(1, N):
    if S[i] == S[i-1]:
        counter += 1
    else:
        if counter == memo:
            ans.append(S[i-1])
        elif counter > memo:
            ans.clear()
            ans.append(S[i-1])
            memo = counter
        counter = 1
if counter == memo:
    ans.append(S[N-1])
elif counter > memo:
    ans.clear()
    ans.append(S[N-1])
    memo = counter
for a in ans:
    print(a)

Measured memory_bytes: 20676
import collections

N = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
ans = 0
tmp = c.most_common()[0][1]
tmp2 = c.most_common(999999)
for i in range(len(tmp2)):
    tmp3 = tmp2[i][1] + c[tmp2[i][0] + 1] + c[tmp2[i][0] + 2]
    tmp4 = tmp2[i][1] + c[tmp2[i][0] - 1] + c[tmp2[i][0] - 2]
    ans = max(ans,tmp3,tmp4)
print(str(ans))

Measured memory_bytes: 20996
while 1:
	a = raw_input()
	if a == ".": break
	a = "".join([i for i in a if i in "()[]"])
	while len(a) > 0:
		if   "()" in a: a = a.replace("()","")
		elif "[]" in a: a = a.replace("[]","")
		else: break
	print "yes" if len(a) == 0 else "no"

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

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}

double angle(int x, int y){
    int d = gcd(x,y);
    x/=d; y/=d;
    return double(y)/double(x);
}
using Event = pair<double,int>;
using P = pair<int,int>;
vector<Event> V;

char M[600][600];

int main(){
    int H,W;
    cin>>H>>W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>M[H-1-i][j];
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(M[i][j]=='#'){
                if(i+1==H||M[i+1][j]=='.'){
                    // cout<<j<<' '<<i<<'U'<<'('<<j<<", "<<i+1<<")-("<<j+1<<", "<<i+1<<')'<<endl;
                    double k1 = angle(j,i+1), k2 = angle(j+1,i+1);
                    if(k2<k1) swap(k1,k2);
                    V.emplace_back(k1,1);
                    V.emplace_back(k2,-1);
                }
                if(j+1==W||M[i][j+1]=='.'){
                    // cout<<j<<' '<<i<<'R'<<'('<<j+1<<", "<<i<<")-("<<j+1<<", "<<i+1<<')'<<endl;
                    double k1 = angle(j+1,i), k2 = angle(j+1,i+1);
                    if(k2<k1) swap(k1,k2);
                    V.emplace_back(k1,1);
                    V.emplace_back(k2,-1);
                }
            }else{
                if(i+1<H&&M[i+1][j]=='#'){
                    // cout<<j<<' '<<i<<'U'<<'('<<j<<", "<<i+1<<")-("<<j+1<<", "<<i+1<<')'<<endl;
                    double k1 = angle(j,i+1), k2 = angle(j+1,i+1);
                    if(k2<k1) swap(k1,k2);
                    V.emplace_back(k1,1);
                    V.emplace_back(k2,-1);
                }
                if(j+1<W&&M[i][j+1]=='#'){
                    // cout<<j<<' '<<i<<'R'<<'('<<j+1<<", "<<i<<")-("<<j+1<<", "<<i+1<<')'<<endl;
                    double k1 = angle(j+1,i), k2 = angle(j+1,i+1);
                    if(k2<k1) swap(k1,k2);
                    V.emplace_back(k1,1);
                    V.emplace_back(k2,-1);
                }
            }
        }
    }
    sort(V.begin(), V.end());
    int cnt = 0, ans = 0;;
    for(auto v:V){
        cnt+=v.second;
        // cout<<v.first<<' '<<v.second<<' '<<cnt<<endl;
        ans = max(cnt,ans);
    }
    ans = (ans+1)/2+1;
    cout<<ans<<endl;

    return 0;
}

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

int cnt, a[23][23];  //black : 0, red : 1

void dfs(int x, int y){
    cnt++;
    a[x][y] = 1;
    if(!a[x + 1][y]) dfs(x + 1, y);
    if(!a[x - 1][y]) dfs(x - 1, y);
    if(!a[x][y + 1]) dfs(x, y + 1);
    if(!a[x][y - 1]) dfs(x, y - 1);
    return;
}

int main(){
    while(1){
        int i, j, w, h, si, sj;
        char in;
        cin >> w >> h;
        if(w == 0)break;
        
        cnt = 0;
        for(i = 0; i <= h + 1; i++){
            a[i][0] = a[i][w + 1] = 1;
        }
        for(j = 0; j <= w + 1; j++){
            a[0][j] = a[h + 1][j] = 1;
        }
       
        i = 1;
        j = 1;
        while(i <= h){
            while(j <= w){
                cin >> in;
                //cout << "~~" << endl;
                if(in == '.'){
                   a[i][j] = 0;
                   j++; 
                }else if(in == '#'){
                    a[i][j] = 1;
                    j++;
                }else if(in == '@'){
                    si = i;
                    sj = j;
                    a[i][j] = 1;
                    j++;
                }
                //cout << j << endl;
            
            
            
            }
            i++;
            j = 1;
        }
        dfs(si, sj);
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <cstdio>
#define X 1111
#define INF 1<<30
using namespace std;
int n,m;
int purimu(int cost[][X]);
int main(){
  int a,b,c;
  int ans=0;
  int cost[X][X];
  while(1){
    cin >> n;
    if(n==0)break;
    cin >> m;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cost[i][j]=INF;
      }
    } 
    for(int i=0;i<m;i++){
      scanf("%d,%d,%d",&a,&b,&c);
      cost[a][b]=c;
      cost[b][a]=c;
    }
    ans=purimu(cost);
    cout << ans/100-(n-1) << endl;
  }
}

int purimu(int cost[][X]){
  int mincost[X];
  bool used[X];
  for(int i=0;i<n;i++){
    mincost[i]=INF;//min関数での回避
    used[i]=false;//まだいっていないところ用
  }
  mincost[0]=0;//出発点のコストは0
  int res=0;
  while(1){
    int v=-1;//最初のために
    for(int i=0;i<n;i++){
      if(!used[i]/*調べていない*/ && (v==-1/*まだそこの場所から行くことができる場所を見つけていない。*/ || mincost[i]<mincost[v])){
	v=i;
      } 
    }
    if(v==-1)break;//全部見終わった
    used[v]=true;
    res+=mincost[v];
    for(int i=0;i<n;i++){
      mincost[i]=min(mincost[i],cost[v][i]);
    }
  }
  return res;
}
	
    

Measured memory_bytes: 3364
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
struct Node{
    vector<P> edges;
    bool done;
    ll cost;
};
ll V,E;
void dijkstra(vector<Node> &nodes,ll s){
    priority_queue<P,vector<P>,greater<P>> q;
    rep(i,V){
        nodes[i].cost = INF;
        nodes[i].done = false;
    }
    nodes[s].cost = 0;
    q.push(P(0,s));
    while(!q.empty()){
        P p = q.top();
        q.pop();
        ll v = p.second;
        if (nodes[v].done) continue;
        nodes[v].done = true;
        for (P e:nodes[v].edges){
            if(nodes[e.first].cost > nodes[v].cost + e.second){
                nodes[e.first].cost = nodes[v].cost + e.second;
                q.push(P(nodes[e.first].cost,e.first));
            }
        }
    }
}
int main(){
    ll s,t,u,v,a,b;
    cin >> V >> E >> s >> t;
    --s;--t;
    vector<Node> money(V),snuke(V);
    rep(i,E){
        cin >> u >> v >> a >> b;
        --u;--v;
        money[u].edges.push_back(P(v,a));
        money[v].edges.push_back(P(u,a));
        snuke[u].edges.push_back(P(v,b));
        snuke[v].edges.push_back(P(u,b));
    }
    dijkstra(money,s);
    dijkstra(snuke,t);
    ll d[V],ans[V];
    rep(i,V) d[i] = money[i].cost+snuke[i].cost;
    priority_queue<ll,vector<ll>,greater<ll>> q;
    rep(i,V){
        q.push(d[V-i-1]);
        ans[V-i-1] = INF-q.top();
    }
    rep(i,V) PRINT(ans[i]);
}

Measured memory_bytes: 23036
/* Murad Eynizade */
#include <bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mp make_pair
using namespace std;
int main() {
	string a;
	cin>>a;
	for (int i = 0;i<a.length();i++) {
		if ((i+1)%2)cout<<a[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main() {
	char d[4];
	char op[3];
	for(int i = 0; i < 4; i++) cin >> d[i];
	for (int bit = 0; bit < 8; bit++)
	{
		int sum = d[0] - '0';
		for (int i = 0; i < 3; i++)
		{
			if(bit & (1<<i)) {
				sum += d[i+1] - '0';
				op[i] = '+';
			}
			else {
				sum -= d[i+1] - '0';
				op[i] = '-';
			}
		}
		if(sum == 7) {
			for (int i = 0; i < 3; i++)
			{
				cout << d[i] << op[i];
			}
			cout << d[3] << "=7" << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
//言語は「C++14(GCC 5.4.1)」
//AtCoder Beginner Contest 64-A

int main(void)
{
	int N, i, a[1000];
	int max, min;
	scanf("%d", &N);
	for (i = 0; i < N; i++)
	{
		scanf("%d", &a[i]);
	}
	max = a[0];
	min = a[0];
	for (i = 1; i < N; i++)
	{
		if (max <= a[i])
			max = a[i];
	}
	for (i = 1; i < N; i++)
	{
		if (min >= a[i])
			min = a[i];
	}
	printf("%d", max - min);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
	int n;   //数列の長さ
	int i;   //くり返し用
	int number[1000];   //数列
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &number[i]);
	}
	for (i = n - 1; i >= 0;i--)
	{
		printf("%d", number[i]);
		if (i != 0)
		{
			printf(" ");
		}
	}
	printf("\n");
	return 0;

}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N,M;
  cin >> N >> M;
  vector<long long> L(M);
  vector<long long> R(M);
  for(long long i = 0; i < M; i++){
    cin >> L[i] >> R[i];
  }
  long long check = 0;
  sort(L.begin(),L.end());
  sort(R.begin(),R.end());
  long long Lmax = L[M-1];
  long long Rmin = R[0];
  for(int i = 1; i < N+1; i++){
    if (i >= Lmax && i <= Rmin){
      check ++;
    }
  }
  cout << check;
}

Measured memory_bytes: 1792
import itertools
import sys
input = sys.stdin.readline

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

n = 0
for i in itertools.count(0):
    for j in range(1, 100):
        n += 1
        if n == N:
            ans = (100 * i + j) * 100**D
            print(ans)
            break
    else:
        continue
    break


Measured memory_bytes: 9168
package main

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

func main() {
	switch readLine() {
	case "Sunny":
		fmt.Println("Cloudy")
	case "Cloudy":
		fmt.Println("Rainy")
	case "Rainy":
		fmt.Println("Sunny")
	}
}

/////////////////////////////////////////
//func readBigLineInt() []int {
//	result := make([]int, 0)
//	for _, v := range strings.Split(readBigLine(), " ") {
//		i, _ := strconv.Atoi(v)
//		result = append(result, i)
//	}
//	return result
//}
//
//var reader = bufio.NewReaderSize(os.Stdin, 1e6)
//
//func readBigLine() string {
//	result := make([]byte, 0, 1e6)
//	for {
//		line, remains, e := reader.ReadLine()
//		if e != nil {
//			panic(e)
//		}
//		result = append(result, line...)
//		if !remains {
//			break
//		}
//	}
//	return string(result)
//}

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	//scanner.Split(bufio.ScanWords)
}
func readLine() string {
	scanner.Scan()
	return scanner.Text()
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int a = sc.nextInt();
        System.out.println(a*800-a/15*200);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

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

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


Measured memory_bytes: 32732
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
//		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int min = Math.min(a, b);
		int max = a+b - min;
		String ans = "";

		for(int i = 0; i < max; i++) {
			ans = ans + min;
		}

		System.out.println(ans);
        return;
    }

}



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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (a*b >= c*d) cout << a*b << endl;
    if (a*b < c*d) cout << c*d << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  int heights[n];
  bool table[n];
  int count = 0;

  for (int i = 0; i < n; i++)
  {
    table[i] = true;
    cin >> heights[i];
  }

  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;

    if (heights[a - 1] < heights[b - 1])
    {
      table[a - 1] = false;
    }
    else if (heights[a - 1] == heights[b - 1])
    {
      table[a - 1] = false;
      table[b - 1] = false;
    }
    else
    {
      table[b - 1] = false;
    }
  }

  for (int i = 0; i < n; i++)
  {
    if (table[i])
    {
      count++;
    }
  }

  cout << count;

  return 0;
}

Measured memory_bytes: 3680
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int n, k;
vector<int> dp, h;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    h.assign(n, 0);
    dp.assign(n, 0);
    F0R(i, n) cin >> h[i];
    FOR(i, 1, n)
    {
        dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]);
        FOR(j, 1, k + 1)
        {
            if(i - j >= 0) dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]));
        }
    }
    cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <array>
#include <bitset>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
	int n, m; CI n >> m;
	vector<vector<int>> sk(m);
	VI p(m);
	REP(i, m) {
		int k; CI k;
		REP(j, k) {
			int tmp; CI tmp;
			sk[i].push_back(tmp);
		}
	}
	CI p;

	int ans=0;
	vector<int> swi(n,0);
	REP(i, pow(2,n)) {
		bitset<10> a(i);
		bool flag = true;
		REP(j, m) {
			int tmp = 0;
			if (!flag)break;
			else flag = false;
			REP(k, sk[j].size()) {
				if (a[sk[j][k] - 1])
					tmp++;
			}
			if (p[j] && tmp % 2) flag = true;
			if (!p[j] && !(tmp % 2)) flag = true;
			
		}
		if (flag)ans++;
	}

	CO ans EN;

}

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

template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return 1;} return 0;}
const long long INF = 1LL << 60;

int main(){
  int N; cin >> N;
  vector<long long> h(N + 1), dp(N + 1);
  for(int i = 1; i <= N; i++){
    cin >> h[i];
  }
  for(int i =0; i <= N; i++){
    dp[i] = INF;
  }
  dp[1] = 0;
  for(int i = 2; i <= N; i++){
    chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[N] << endl;
}

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

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)
#define pb push_back



using namespace std;
using namespace std::chrono;

char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const ll MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };



void solve() {

    ll n;
    cin>>n;
    ll total=0;
    
    for(ll i=1; i<n; i++){
        ll temp=n/i;
        if(n%i==0) temp--;
        total+=temp;
    }
    cout<<total<<endl;
}


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

        
        solve();


    return 0;
}

Measured memory_bytes: 3648
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))



N = str(input())
if N[0] == N[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 10776
#include"bits/stdc++.h"
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

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

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF= 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();

int main() {
  LL n,q;cin>>n>>q;
  vector<PLL> ab(n-1);REP(i,n-1)cin>>ab[i].first>>ab[i].second;
  vector<PLL> ope(q);REP(i,q)cin>>ope[i].first>>ope[i].second;
  REP(i,n){
    ab[i].first--;
    ab[i].second--;
  }
  REP(i,q)ope[i].first--;
  VLL counter(n);
  REP(i,q)counter[ope[i].first]+=ope[i].second;
  SORT(ab);
  REP(i,n-1){
    counter[ab[i].second]+=counter[ab[i].first];
  }
  //REP(i,n-1)cout<<ab[i].first<<' '<<ab[i].second<<endl;
  REP(i,n)cout<<counter[i]<<' ';
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}


Measured memory_bytes: 10240
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main(){
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vector<long long> p(A);
    for(int i=0; i<A; ++i) cin >> p[i];
    vector<long long> q(B);
    for(int i=0; i<B; ++i) cin >> q[i];
    vector<long long> r(C);
    for(int i=0; i<C; ++i) cin >> r[i];

    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());

    multiset<long long> s;

    for(int i=A-1; i>(A-1)-X; --i){
        s.insert(p[i]);
    }

    for(int i=B-1; i>(B-1)-Y; --i){
        s.insert(q[i]);
    }

    int num = min(A+B, C);
    for(int i=C-1; i>(C-1)-num; --i){
        long long smallest = *s.begin();
        if(r[i] > smallest){
            s.erase(s.find(smallest));
            s.insert(r[i]);
        }
    }

    long long sum = 0;
    for(long long i : s) sum += i;
    cout << sum << endl;
}

Measured memory_bytes: 11008
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll A, B;
vector<ll> p;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> A >> B;
    for (ll i = 2; i*i <= A; i++) {
        if (A%i == 0){ 
            p.push_back(i);
            while(A%i == 0) A /= i;
        }
    }
    if (A != 1) p.push_back(A);
    ll cnt = 0;
    rep(i,p.size()) {
        if (B%p[i] == 0) cnt++;
    }
    cout << cnt+1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define maxn 200050
using namespace std;

int n,d[maxn];
int m,t[maxn];
bool vis[maxn];

bool solve()
{
	int tot=1;
	for(int i=1;i<=n;i++)
	{
		if(d[i]==t[tot] && vis[i]==0)
		{
			if(tot==m)return true;
			tot++;
			vis[i]=1;
		}
		if(i==n && d[i]!=t[tot])
			return false;
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&d[i]);
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
		scanf("%d",&t[i]);
	sort(d+1,d+n+1);
	sort(t+1,t+m+1);
	if(solve())printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 2048
fun main() = abc165c()

@OptIn(ExperimentalStdlibApi::class)
fun abc165c() {
    data class Abcd(val a: Int, val b: Int, val c: Int, val d: Int)

    val (n, m, q) = readLine()!!.split(' ').map { it.toInt() }
    val abcdList = (1..q).map {
        readLine()!!.split(' ').map { it.toInt() }.let { Abcd(it[0] - 1, it[1] - 1, it[2], it[3]) }
    }

    var answer = 0

    fun dfs(list: List<Int>) {
        if (list.size < n) return (list.last()..m).forEach { dfs(list + it) }
        val filter = abcdList.filter { (a, b, c) -> list[b] - list[a] == c }
        answer = Math.max(answer, filter.sumBy { it.d })
    }

    dfs(listOf(1))

    println(answer)
}


Measured memory_bytes: 55616
class Dice:
  def __init__(self, top=1, front=2, left=4, right=3, back=5, bottom=6):
    self.d = {"TOP":top, "FRONT":front, "LEFT":left, "RIGHT":right, "BACK":back, "BOTTOM":bottom}

  def roll_x(self):
    self._roll("TOP", "FRONT", "BOTTOM", "BACK")
  
  def roll_y(self):
    self._roll("FRONT", "LEFT", "BACK", "RIGHT")
  
  def roll_z(self):
    self._roll("TOP", "LEFT", "BOTTOM", "RIGHT")
  
  def _roll(self, a, b, c, d):
    self.d[a], self.d[b], self.d[c], self.d[d] = \
    self.d[b], self.d[c], self.d[d], self.d[a]
  
  def all_rolls(self):
    ret = []
    for i in range(6):
      if i%2:
        self.roll_x()
      else:
        self.roll_y()
      for j in range(4):
        self.roll_z()
        t = self.d.copy()
        ret.append(t)
    return ret

  def equivalent(self, dice):
    for i in range(6):
      if i%2:
        self.roll_x()
      else:
        self.roll_y()
      for j in range(4):
        self.roll_z()
        t = self.d.copy()
        if t==dice.d:
          return True
    return False

d1 = list(map(int, input().split()))
dd1 = Dice(d1[0], d1[1], d1[3], d1[2], d1[4], d1[5])
d2 = list(map(int, input().split()))
dd2 = Dice(d2[0], d2[1], d2[3], d2[2], d2[4], d2[5])
if dd1.equivalent(dd2):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 5604
def solve()
  s = gets.chomp.split("")
  odd_ans = ["R", "U", "D"]
  even_ans = ["L", "U", "D"]
  res = true
  (0..s.length-1).each do |i|
    if (i % 2).zero?
      if odd_ans.include?(s[i]) == false
        return "No"
      end
    elsif (i % 2).nonzero?
      if even_ans.include?(s[i]) == false
        return "No"
      end
    end
  end
  return "Yes"
end
print(solve())



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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	int t = 0;
	for (auto& e : a) cin >> e, t ^= e;
	for (int i = 0; i < n; ++i) {
		if (i) cout << " ";
		cout << (t ^ a[i]);
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 4044
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val xy = (0 until n).map { sc.next().toDouble() to sc.next().toDouble() }
    val ml : MutableList<Int> = mutableListOf()
    val p = permutation((0..n-1).toList(),ml)
    //println(xy)
    //println(p)
    
    var fact = 1
    var distsum = 0.0
    for(i in 2 until n+1) fact *= i
    p.forEach {
        for (j in 1 until n) {
            val dx = Math.pow(xy[it[j]].first - xy[it[j-1]].first,2.0)
            val dy = Math.pow(xy[it[j]].second - xy[it[j-1]].second,2.0)
            distsum += Math.sqrt(dx + dy)
        }
    }
    println(distsum / fact)
}

fun permutation(q:List<Int>,ans: MutableList<Int>) : MutableList<MutableList<Int>> {
    // Base Case
    val ret :MutableList<MutableList<Int>> = mutableListOf()
    if(q.size <= 1) {
        ans.add(q[0])
        ret.add(ans)
        //println(ans)
    }
    // General Case
    else {
        for (i in 0 until q.size ) {
            //print(i)
            //print(q)
            //println(ans)
            val n = ans.toMutableList()
            n.add(q[i])
            //println(n)
            ret.addAll(permutation(q.subList(0,i).plus(q.subList(i+1,q.size)),n))
        }
    }
    return ret
}

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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;

int main() {
    fast;
    cin.tie(0);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w" , stdout);
#endif*/
    lld n, k, i, j;
    cin >> n >> k;
    set<lld> s;
    lld a[n];
    for (i = 0; i < n; i++) {
        cin >> a[i];
        s.insert(i);
    }
    vector<lld> adj[n];
    for (i = 0; i < k; i++) {
        lld x, y;
        cin >> x >> y;
        x--;
        y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    lld cnt = 0;
    for (i = 0; i < n; i++) {
        lld mx = a[i];
        bool flag = true;
        for (auto it : adj[i]) {
            if (a[it] >= mx) {
                flag = false;
                break;
            }
        }
        if (flag) cnt++;
    }

    cout << cnt << endl;

}

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


N, T = map(int, input().split())
AB = []
for _ in range(N):
    a, b = map(int, input().split())
    AB.append([a,b])

# Aを昇順にソート
AB.sort(key=lambda x:x[0])

# 残りのうち(j+1番目以降)で最も美味しいもの
bmax_res = [0]*N
bmax = -1
for i in range(N-1, 0, -1):
    a, b = AB[i]
    bmax = max(bmax, b)
    bmax_res[i-1] = bmax

# DPで解く
# DP[i][j] = i番目までの料理でj分以内に完食できる美味しさの合計の最大値
DP = [[0] * (T+1) for _ in range(N+1)]

res = 0
# update
for i in range(1,N+1):
    a, b = AB[i-1]
    for j in range(1,T+1):
        if a <= j:
            DP[i][j] = max(DP[i-1][j-a] + b, DP[i-1][j])
        else:
            DP[i][j] = max(DP[i-1][j], DP[i][j])
    res = max(res, DP[i][T-1]+bmax_res[i-1])
print(res)

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

#define ll long long
#define REP(i, a, b) for (int i = a; i <= b; ++i)

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a[5];
	for(int i = 0; i < 5; ++i) {
		cin >> a[i];
	}
	for(int i = 0; i < 5; ++i) {
		if(a[i] == 0) {
			cout << i + 1; 
			break;
		}
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
const int P=1000000007;
int n,k;
long long ans=1;
vector<int>G[100001];
void dfs(int x,int f,int res){
	ans*=(k-res);ans%=P;int cnt=0;
	for(unsigned i=0;i<G[x].size();i++){
		int y=G[x][i];
		if(y==f)continue;
		if(x==1)dfs(y,x,1+cnt);
		else dfs(y,x,2+cnt);
		cnt++;
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1,a,b;i<n;i++){
		scanf("%d%d",&a,&b);
		G[a].push_back(b),G[b].push_back(a);
	}
	dfs(1,0,0);
	printf("%lld",ans);
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int MOD = 1e9+7;
const int MAXN = 2e5+10;

void solve()
{
	int n,m;
	string v;
	vector<int> a[MAXN];
	cin>>n>>m;
	ll ans1= 0, ans2 =0;
	int tmp;
	for(int i = 0; i < m; i++){
		cin>>tmp>>v;tmp--;
		if(v == "AC"){
			a[tmp].push_back(1);
		}
		else{
			a[tmp].push_back(0);
		}
	}
	for (int i = 0; i < n; ++i)
	{
		int attempts = 0;
		for (int j = 0; j < a[i].size(); ++j)
		{
			if(a[i][j] == 1){
				ans1+=attempts;
				ans2++;
				break;
			}
			attempts++;
		}
	}
	cout<<ans2<<" "<<ans1<<endl;
}
int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;

}
    

Measured memory_bytes: 8064
#include <stdio.h>
#include <math.h>

using namespace std;
#define dTolerance 1.0e-10

int main(){
    int n;
    scanf("%d", &n);
    double x[n+1],y[n+1];
    for (int i = 0; i < n; i++){
        scanf("%lf %lf", &x[i], &y[i]);
    }
    x[n] = x[0];
    y[n] = y[0];

    int ixMin = 0;
    int ixMax = 0;
    for (int i = 0; i < n; i++){
        if(x[i] < x[ixMin]){    
            ixMin = i;
        }
        if(fabs(x[i] - x[ixMin]) < dTolerance && y[i] > y[ixMin]){    //x座標最小のもののなかでy座標最大のものにしておく
            ixMin = i;
        }
        if(x[i] > x[ixMax]){  
            ixMax = i;
        }
        if(fabs(x[i] - x[ixMax]) < dTolerance && y[i] < y[ixMax]){    //x座標最大のもののなかでy座標最小のものにしておく
            ixMin = i;
        }
    }
    
    double dDiameter = sqrt( (x[ixMax] - x[ixMin]) * (x[ixMax] - x[ixMin]) + (y[ixMax] - y[ixMin]) * (y[ixMax] - y[ixMin]) );

    int i = ixMin;
    int j = ixMax;
    
    while(j != ixMin || i != ixMax){
        if( (x[j+1] - x[j]) * (y[i+1] - y[i]) - (x[i+1] - x[i]) * (y[j+1] - y[j]) >= 0 ) {;    //j番目の辺(向き付)から見てi番目の辺(向き付)のなす角が反時計回り
            i++;
        } else {    //時計回り
            j++;
        }
        i %= n;    //nを越えないようにしておく
        j %= n;
        if (dDiameter < sqrt( (x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]) )){
            dDiameter = sqrt( (x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]) );
        }
    }

    printf("%lf", dDiameter);
    
    return 0;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug cout<<"Reached\n";

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n,k;

    cin>>n>>k;

    map<li,li> m;

    f(i,0,k-1)
    {
        li d;

        cin>>d;

        li tp;

        f(i,0,d-1)  
        {
            cin>>tp;

            m[tp]=1;
        }
    }   

    cout<<n-(li)m.size();   

    return 0;
}

Measured memory_bytes: 3660
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

const ll INF = 1LL << 50;

int main() {
  ll n;
  cin >> n;

  ll sum = 0;
  ll i0 = 0;
  vll ans;
  for (ll i = 1; i <= n; i++) {
    if (sum + i >= n) {
      i0 = i;
      ans.push_back(i0);
      break;
    }
    sum += i;
  }
  n -= i0;
  for (ll i = i0 - 1; i >= 1; i--) {
    if (n == 0) break;
    if (n < i) continue;
    n -= i;
    ans.push_back(i);
  }

  rep(i, (ll)ans.size()) cout << ans[i] << endl;

  return 0;
}


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

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

  int min = 2020;

  if(R-L > 673){
    cout << 0 << endl;
  } else {
    for (int i = L; i < R; i++){
      for (int j = i+1; j < R+1; j++){
        int is = i%2019;
        int js = j%2019;
        if( (is * js)%2019 < min){
          min = (is * js)%2019;
        }
      }
    }
    cout << min << endl;
  }

  return 0;
}


Measured memory_bytes: 888
/*
[abc122] D - We Like AGC
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 100;
const ll MOD = 1e9 + 7;
// const char cs[4] = {'A', 'C', 'G', 'T'};

int N;
ll dp[MAX_N + 4][4][4][4];

vector<int> to_arr(int p) {
    return {p & 3, (p >> 2) & 3, (p >> 4) & 3, (p >> 6) & 3};
}

bool is_ok(int p) {
    vector<int> s = to_arr(p);
    for (int i = 0; i < 4; i++) {
        if (i > 0) {
            swap(s[i - 1], s[i]);
        }
        for (int j = 0; j < 2; j++) {
            if (s[j] == 0 && s[j + 1] == 2 && s[j + 2] == 1) {
                return false;
            }
        }
        if (i > 0) {
            swap(s[i - 1], s[i]);
        }
    }

    return true;
}

ll solve() {
    dp[0][3][3][3] = 1;
    for (int i = 1; i < N + 4; i++) {
        for (int p = 0; p < 256; p++) {
            if (is_ok(p)) {
                vector<int> s = to_arr(p);
                (dp[i][s[1]][s[2]][s[3]] += dp[i - 1][s[0]][s[1]][s[2]]) %= MOD;
            }
        }
    }

    return dp[N + 3][3][3][3];
}

int main() {
    cin >> N;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void trance(int A[], int N){
	int i;
	for( i =0; i < N; i++ ){
		if( i > 0 ) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N){
	int i, j, v;
	for( i = 1; i < N; i++ ){
		v = A[i];
		j = i - 1;
		while( j >= 0 && A[j] > v ){
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trance(A, N);
	}
}

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

Measured memory_bytes: 600
#ika tako
n, k = map(int, input().split())
ppp = list(map(int, input().split()))
tot = sum(ppp[:k])#まず、先頭K個の合計を求める
ans = tot#仮の答としておく
for i in range(k, n):#for文で0-indexでk+1番目から最後までチェック
    tot += ppp[i] - ppp[i - k]#新しくi番目を足して、一番古いものを引く
    ans = max(ans, tot)#新しい答が大きいなら更新する
print((ans + k) / 2)#K個分のサイコロの期待値を出力する

Measured memory_bytes: 71792
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    int n, q;
    std::cin >> n >> q;

    std::vector<std::vector<int>> edges(n);

    for (int i = 0; i < n - 1; i++) {
        int a, b;
        std::cin >> a >> b;
        a--;
        b--;

        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    std::vector<long long> values(n, 0);

    for (int i = 0; i < q; i++) {
        int p, x;
        std::cin >> p >> x;
        p--;

        values[p] += x;
    }
    auto dfs = [&](auto f, int current, int parent) -> void {
        for (auto idx : edges[current]) {
            if (parent == idx) {
                continue;
            }
            values[idx] += values[current];
            f(f, idx, current);
        }
    };

    dfs(dfs, 0, -1);

    for (int i = 0; i < n; i++) {
        std::cout << values[i] << std::endl;
    }
}


Measured memory_bytes: 21888
#include<stdio.h>

int main(void){
	int i,j,ss,array[100]={0};
	//printf("??°?????°");
	scanf("%d",&ss);
	//printf("???:");
	for(i=0;i<ss;i++){
		scanf("%d",&array[i]);
	}
	for(j=ss-1;j>=0;j--){
		printf("%d",array[j]);
		if(j!=0){
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}

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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

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

    ll h,w;
    cin >> h >> w;

    ll x,y;
    cin >> x >> y;

    cout << (h-x)*(w-y)<< endl;
}


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

int n, m;
string s;
int ans = 0;
int main()
{
  while(true){
    cin >> n;
    if(!n)
      break;

    cin >> m >> s;
    ans = 0;

    int times = 0;
    for(int i = 0; i < m; i++){
      if(s[i] == 'O'){
	if(times % 2)
	  times++;
	else
	  times = 0;
      }
      else{
	if(!(times % 2))
	  times++;
	else
	  times = 1;
      }
      if(times % 2 && times / 2 >= n)
	ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2100
#include <stdio.h>
#include <stdlib.h>
 
 
int main()
{
    int n,i,x;
    scanf("%d %d",&n,&x);
    long long ans=0,sum,a,b;
    scanf("%lld",&a);
    if(a>x)
    {
       ans+=a-x;
       a=x; 
    }
 
    for( i=1; i<n; i++)
    {
        scanf("%lld",&b);  
        sum=a+b;
        if(sum>x)
        {
            ans+=sum-x;
            a=b-sum+x;   
        }
        else a=b;       
    }                   
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N >> M;
	vector<long long int>by(M + 1, 1);
	vector<long long int>rev(M + 1, 1);
	for (int i = 2; i <= M; i++) {
		by[i] = by[i - 1] * i%MOD;
		rev[i] = power(by[i], MOD - 2, MOD);
	}
	vector<long long int>num(N + 1);
	long long int ans = by[M] * rev[M - N] % MOD;
	for (int i = 1; i <= N; i++) {
		num[i] = by[N] * rev[i] % MOD*rev[N - i] % MOD;
		num[i] *= by[M - i] * rev[M - N] % MOD;
		num[i] %= MOD;
		if (i & 1)ans += MOD - num[i];
		else ans += num[i];
		ans %= MOD;
	}
	cout << ans * by[M] % MOD*rev[M - N] % MOD << endl;
}

Measured memory_bytes: 15032
#include <iostream>
#include <stdio.h>
#include<string>
#include<math.h>
#include<map>
using namespace std;
int main()
{
	int N ,n,ans;
	
	cin >> N;
	n = N / 15;
	ans = 800 * N - n * 200;
	cout << ans;
	
	
}


Measured memory_bytes: 256
a, b = map(int, input().split())
slist = []
if (a > b):
    c = a%b
    d = b
    while (c != 0 and d != 0):
        if (c < d):
            d = d%c
        elif (c > d):
            c = c%d
    if(c == 0):
        print(d)
    elif(d == 0):
        print(c)
        
    
elif(a < b):
    c = a
    d = b%a
    while (c != 0 and d != 0):
        if (c < d):
             d = d%c
        elif (c > d):
            c = c%d
    if(c == 0):
        print(d)
    elif(d == 0):
        print(c)
        
else:
    print(a)
        


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

public class Main{
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        int N = nextInt();
        
        int[] postion = new int[N+1];
        int[] cnt = new int[N+1];
 
        for (int i=2; i<=N; i++) {
            postion[i] = nextInt();
        }

        // Every member has exactly one immediate boss with a smaller ID number.
        for (int i=N; i>=1; i--) {
            cnt[postion[i]] ++;
        }

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

        
    }

    public static int gcd(int a, int b) {
        if(b==0) return a;

        return gcd(b, a%b);
    }
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  int M;
  cin >> N >> M;
  vector<vector<ll>> v(8, vector<ll>(N, 0));
  for(int i = 0; i < N; i++){
    ll a,b,c;
    cin >> a >> b >> c;
    v.at(0).at(i) =  a+b+c;
    v.at(1).at(i) = -a+b+c;
    v.at(2).at(i) =  a-b+c;
    v.at(3).at(i) = -a-b+c;
    v.at(4).at(i) =  a+b-c;
    v.at(5).at(i) = -a+b-c;
    v.at(6).at(i) =  a-b-c;
    v.at(7).at(i) = -a-b-c;
  }

  ll max_val = 0;
  for(int i = 0; i < 8; i++){
    sort(v.at(i).rbegin(), v.at(i).rend());
    ll tmp = 0;
    for(int j = 0; j < M; j++){
      tmp += v.at(i).at(j);
    }
    max_val = max(tmp, max_val);
  }

  cout << max_val << endl;

  

}


Measured memory_bytes: 256