akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
 
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
 
const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;
 
void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
 
int main(){
  FAST();
 
  /*MY METHOD (wrong - WHY?):
  string str;
  cin >> str;
  string x(str.begin(), str.begin() + 2);
  string y(str.begin() + 2, str.end());
 
  if((x == "00" || y == "00") || (x >= "13" && y >= "13"))
    cout << "NA\n";
  if((x > "00" && x < "13") && (y > "00" && y < "13"))
    cout << "AMBIGUOUS\n";
  else if(x > "00" && x < "13")
    cout << "MMYY\n";
  else if(y > "00" && y < "13")
    cout << "YYMM\n";
  */
 
  //EDITORIAL METHOD:
  int str;
  cin >> str;
  int x = str / 100;
  int y = str % 100;
  if(x > 0 && x < 13){
    if(y > 0 && y < 13)
      cout << "AMBIGUOUS\n";
    else
      cout << "MMYY\n";
  }
 
  else{
    if(y > 0 && y < 13)
      cout << "YYMM\n";
    else
      cout << "NA\n";
  }
 
  return 0;
}

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

vector<int> dp;

int q(int x) {
	if (dp[x]) return dp[x];
	cout << x << endl;
	string s; cin >> s;
	if (s == "Vacant") exit(0);
	if (s == "Male") return dp[x] = -1;
	return dp[x] = 1;
}

bool f(int s, int t) {
	int o = (s - t) & 1;
	if (o) return q(s) == q(t);
	return q(s) != q(t);
}

int main() {
	int N;cin >> N;
	dp.resize(N);
	vector<int> v(2*N);
	for (int i = 0; i < N; i++) v[i] = v[i+N] = i;
	int s = 0, t = N / 2;
	if (!f(s, t)) swap(s, t);
	for (;;) {
		int m = s > t ? v[(s+t+N)/2] : (s+t)/2;
		if (f(s, m)) t = m;
		else s = m;
	}
}

Measured memory_bytes: 2128
import itertools
N = int(input())
N_list = [i+1 for i in range(N)]
cumsum = list(itertools.accumulate(N_list))
aa = cumsum[-1]
t_list = [i for i in N_list if i%3 == 0 or i%5 == 0]
if len(t_list) != 0:
    acumsum = list(itertools.accumulate(t_list))[-1]
else:
    acumsum = 0
print(aa - acumsum)

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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

int main(){
    int N, L;
    string S[110];

    cin >> N >> L;
    rep(i,N) cin >> S[i];

    sort(S, S + N);

    rep(i,N){
        cout << S[i];
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    double x;
    double a,b;
    cin>>a>>b;
    x=(a+b)/2;

    int A=x;
    if(x-A!=0){
        A++;
        cout <<A<<endl;
    }
    else cout<<x<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int minNumCoin[50050];

int main(void)
{
    string s;
    cin >> s;
    bool flag = false;
    rep(i, s.size()) if(s[i] == '7') flag = true;
   
    (flag)?puts("Yes"):puts("No");
    return 0;
}

Measured memory_bytes: 3624
/****************************************************************************************************
                                        SUBMITTED BY-

                                            AISH_07

****************************************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll long long
#define sl set<ll>
#define vs vector<string>
#define pb push_back
#define vl vector<ll>
#define vi vector<int>
#define PI  3.14159265
#define mod 998244353
int main()
{
   string s;
   cin>>s;

   string q=s.substr(0,4);
   string d=s.substr(5,2);
   string n=s.substr(8,2);


   int y=stoi(q);
   int mm=stoi(d);
   int dd=stoi(n);

   if(y>2019)
      cout<<"TBD\n";
   else
   {
       if(mm>4)
        cout<<"TBD\n";
       else
         cout<<"Heisei\n";
   }
   return 0;
}


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

int main(void)
{
	double a, b, x, i, m, n;

	while (scanf("%lf %lf", &a, &b) != EOF){
		m = a;
		n = b;
		while (1){
			x = fmod(a, b);
			a = b;
			b = x;

			if (x == 0){
				break;
			}
		}
		x = (m*n) / a;
		printf("%.0f %.0f\n", a, x);
	}
	return 0;
}

Measured memory_bytes: 644
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;
const int inf = 1e9 + 10;

int a[N], dp[N];

bool isVal(int x, int y)
{
    return (y <= dp[x]);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i ++)
        cin >> a[n - i];
    for (int i = 1; i <= n; i ++)
        a[i] = -a[i];
    fill(dp, dp + N, -inf);
    dp[0] = 0;
    dp[1] = a[1];
    for (int i = 2; i <= n; i ++)
    {
        int l = 0, r = n + 1;
        while (r - l > 1)
        {
            int mid = (l + r) / 2;
            if (isVal(mid, a[i]))
                l = mid;
            else
                r = mid;
        }
        dp[l + 1] = a[i];
    }
    int ans = 1;
    for (int i = 1; i <= n; i ++)
        if (dp[i] != -inf)
            ans = i;
    cout << ans;
    return 0;
}


Measured memory_bytes: 1152
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let (n,x) = {
        let t = read_vec::<i64>();
        (t[0],t[1])
    };
    let xn = read_vec::<i64>();
    let xn:Vec<i64> = xn.into_iter()
        .map(|a| (x-a).abs())
        .collect();
    let mut ans = xn[0];
    for v in xn {
        ans = gcd(std::cmp::max(ans, v),std::cmp::min(ans,v));
    }
    println!("{}",ans );
}
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

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

int main(){
    stack<int>st;
    int x;
    while(cin >> x){
        if(x==0){
            cout << st.top() <<endl;
            st.pop();
        }else{
            st.push (x);
        }
    }    
    return 0;
}

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

int main(){
	long long a,b,c,numa,numb,numc,more=0x7fffffffff,ans=0;
	cin>>a>>b>>c>>numa>>numb;
	if((a+b)>c*2){  //套装价格便宜
		long long num=max(numb,numa)*2;
		more=num*c;
		numc=min(numa,numb)*2;
		if(numa>numb){
			numa-=numb;
			ans=numc*c+numa*a;
		}else{
			numb-=numa;
			ans=numc*c+numb*b;
		}
	}else{           //分开购买便宜
		ans=a*numa+b*numb;
	}
	cout<<min(ans,more);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
using Graph =vector<vector<int>>;
//xor


int main(){
  string s;cin>>s;
  if(s[2]==s[3]){
    if(s[4]==s[5]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

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

int N,dist[200000],res[200000];
queue<int>que[3];
vector<int>v[200000];

void dfs(int x,int from){
	for(int i:v[x]){
		if(i==from)continue;
		dist[i]=dist[x]+1;
		dfs(i,x);
	}
}

int main(){
	cin>>N;
	for(int i=1;i<N;i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(0,0);
	for(int i=1;i<=N;i++){
		que[i%3].push(i);
	}
	vector<int>v[2];
	for(int i=0;i<N;i++){
		v[dist[i]&1].push_back(i);
	}
	if(v[0].size()<=N/3){
		for(int i:v[0]){
			res[i]=que[0].front();
			que[0].pop();
		}
		for(int i:v[1]){
			for(int j=0;j<3;j++){
				if(!que[j].empty()){
					res[i]=que[j].front();
					que[j].pop();
					break;
				}
			}
		}
	}
	else if(v[1].size()<=N/3){
		for(int i:v[1]){
			res[i]=que[0].front();
			que[0].pop();
		}
		for(int i:v[0]){
			for(int j=0;j<3;j++){
				if(!que[j].empty()){
					res[i]=que[j].front();
					que[j].pop();
					break;
				}
			}
		}
	}
	else{
		for(int i:v[0]){
			if(!que[1].empty()){
				res[i]=que[1].front();
				que[1].pop();
			}
			else{
				res[i]=que[0].front();
				que[0].pop();
			}
		}
		for(int i:v[1]){
			if(!que[2].empty()){
				res[i]=que[2].front();
				que[2].pop();
			}
			else{
				res[i]=que[0].front();
				que[0].pop();
			}
		}
	}
	for(int i=0;i<N;i++){
		cout<<res[i]<<' ';
	}
	cout<<endl;
}


Measured memory_bytes: 20724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;

  int ans = 0;

  for (int i = 0; i <= 3000; i++) {
    for (int j = 0; j <= 3000; j++) {
      // for (int k = 1; k < 3000; k++) {
      int m = n - (r * i + g * j);
      if (m >= 0 && m % b == 0) ans++;
      // }
    }
  }

  cout << ans << endl;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long INTEGER;
typedef double FLOAT;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

const int MM = 100;
int cost[MM][MM];
int toki[MM][MM];

int main() {

entry:;
  int n, m; cin >> m >> n;
  if (n + m == 0) return 0;

  rep (i, n) {
    rep (j, n) {
      cost[i][j] = INF;
      toki[i][j] = INF;
    }
    cost[i][i] = 0;
    toki[i][i] = 0;
  }

  rep (i, m) {
    int a, b, c, t;
    cin >> a >> b >> c >> t;
    --a; --b;
    cost[a][b] = cost[b][a] = c;
    toki[a][b] = toki[b][a] = t;
  }

  rep (k, n) {
    rep (i, n) {
      rep (j, n) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
        toki[i][j] = min(toki[i][j], toki[i][k] + toki[k][j]);
      }
    }
  }

  //rep (i,n) { rep(j,n) { cout << cost[i][j] << ' '; } cout << endl; }

  int k; cin >> k;
  rep (i, k) {
    int a, b, t;
    cin >> a >> b >> t;
    --a; --b;
    if (t) {
      cout << toki[a][b] << endl;
    } else {
      cout << cost[a][b] << endl;
    }
  }

  goto entry;

  return 0;
}

Measured memory_bytes: 1236
def aaa(a_list):
    ans = 1
    for i in a_list:
        ans = ans * i
        if ans > 10**18:
            return -1
    return ans

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

if 0 in a:
    print(0)
else:
    print(aaa(a))

Measured memory_bytes: 21568
#include <bits/stdc++.h>
using namespace std;
#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()
typedef long long lint;
template <class T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
/* templates */ /* templates */ /* templates */ /* templates */ /* templates */

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

    int N;
    cin >> N;
    vector<double> x(N);
    vector<string> u(N);
    rep(i, N) { cin >> x[i] >> u[i]; }
    double ans = 0;
    rep(i, N) {
        if(u[i] == "JPY") {
            ans += x[i];
        } else {
            ans += 380000 * x[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,ans;
    ans=0;
    cin>>a;
    Fr(i,a){
        ans+=a/i*(i+a/i*i)/2;
    }
    cout<<ans;
}

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

int main()
{
    int n;  cin >> n;
    vector<int> h(n);
    rep(i,n)  cin >> h[i];

    int count = 0;
    int ans = 0;

    rep(i,n) {
        if (i < n - 1) {
            if (h[i] >= h[i+1])  ++count;
            else  count = 0;
            ans = max(count, ans);
        } else {
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    q,h,s,d=map(int, input().split())
    n=int(input())
    s=min(4*q,2*h,s)
    if 2*s<=d:
        print(n*s)
    else:
        a,b=divmod(n,2)
        print(a*d+b*s)
resolve()

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

/**
 * Problem F: FizzBuzz
 */
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while (!(line = br.readLine()).equals("0 0")) {
			int m = Integer.parseInt(line.substring(0, line.indexOf(' ')));
			int n = Integer.parseInt(line.substring(line.indexOf(' ') + 1));

			ArrayDeque<Integer> players = new ArrayDeque<Integer>();
			boolean[] says = new boolean[n];

			for (int i = 1; i <= m; i++) {
				players.add(i);
			}
			for (int i = 1; i <= n; i++) {
				says[i - 1] = fizzBuzz(i, br.readLine());
			}

			for (int i = 0; i < n; i++) {
				if (players.size() == 1) {
					break;
				}
				Integer player = players.poll();
				if (says[i]) {
					players.offer(player);
				}
			}

			//頭出し
			while (true) {
				players.offer(players.poll());
				if (players.peekFirst() <= players.peekLast()) {
					break;
				}
			}
			StringBuilder sb = new StringBuilder();
			sb.append(players.poll());
			for (Integer player : players) {
				sb.append(" " + player);
			}
			System.out.println(sb.toString());
		}
	}

	public static boolean fizzBuzz(int idx, String say) {
		boolean ret = false;
		if (idx % 15 == 0) {
			if (say.equals("FizzBuzz")) {
				ret = true;
			}
		} else if (idx % 3 == 0) {
			if (say.equals("Fizz")) {
				ret = true;
			}
		} else if (idx % 5 == 0) {
			if (say.equals("Buzz")) {
				ret = true;
			}
		} else if (say.equals(String.valueOf(idx))) {
			ret = true;
		}
		return ret;
	}
}

Measured memory_bytes: 39616
from collections import deque
from itertools import combinations
class Dinic:
    def __init__(self, N):
        self.N=N
        self.G=[[]for _ in range(N)]
    def add_edge(self,fr,to,cap):
        forward=[to,cap,None]
        forward[2]=backward=[fr,0,forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)
    def add_multi_edge(self,v1,v2,cap1,cap2):
        edge1=[v2,cap1,None]
        edge1[2]=edge2=[v1,cap2,edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)
    def bfs(self,s,t):
        self.level=level=[None]*self.N
        deq=deque([s])
        level[s]=0
        G=self.G
        while deq:
            v=deq.popleft()
            lv=level[v]+1
            for w,cap,_ in G[v]:
                if cap and level[w]is None:
                    level[w]=lv
                    deq.append(w)
        return level[t]is not None
    def dfs(self,v,t,f):
        if v==t:return f
        level=self.level
        for e in self.it[v]:
            w,cap,rev=e
            if cap and level[v]<level[w]:
                d=self.dfs(w,t,min(f,cap))
                if d:
                    e[1]-=d
                    rev[1]+=d
                    return d
        return 0
    def flow(self,s,t):
        flow=0
        INF=10**9+7
        G=self.G
        while self.bfs(s,t):
            *self.it,=map(iter,self.G)
            f=INF
            while f:
                f=self.dfs(s,t,INF)
                flow+=f
        return flow
INF=10**9+7
t,*a=open(0)
h,w=map(int,t.split())
d=Dinic(h+w+3)
add=d.add_multi_edge
for i,s in enumerate(a,1):
    for j,t in enumerate(s[:-1],h+1):
        if t!='.':
            if t=='S':
                add(0,i,INF,INF)
                add(0,j,INF,INF)
            elif t=='T':
                add(i,h+w+2,INF,INF)
                add(j,h+w+2,INF,INF)
            add(i,j,1,1)
a=d.flow(0,h+w+2)
print(-(a>=INF)or a)

Measured memory_bytes: 5492
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
using namespace std;

int main() {

    int N;

    cin >> N;

    unordered_map<string, int> items;

    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        items[s]++;
    }

    int ans = 0;
    for (auto item: items){
        ans++;
    }    

    cout << ans << endl;

    return 0;
}


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

int count=0;
void searchComb(int n, int s, int minimum);

int main()
{
    int n,s;

    while (cin >> n >> s)
    {
        count=0;
        if(n==0 && s==0)
        {
            break;
        }
        searchComb(n, s, 0);
        cout << count << endl;
    }
    return 0;
}


void searchComb(int n, int s, int minimum)
{
    if(n<=0)
    {
        if(s==0)
        {
            count++;
        }

        return;
    }

    for(int i= minimum; i<10; i++)
    {
        if(s-i >= 0)
        {
            searchComb(n-1, s-i, i+1);
        }
    }
}

Measured memory_bytes: 3004
def main():
    from fractions import gcd
    def lcm(c,d):return c//gcd(c,d)*d
    mod=10**9+7
    n=int(input())
    a=[int(i) for i in input().split()]
    l=a[0]
    for i in range(1,n):l=lcm(l,a[i])
    ans=0
    for i in range(n):ans+=l//a[i]
    print(ans%mod)
main()


Measured memory_bytes: 6100
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__);
#define input(x) x; cin >> x;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

int main(){
  int input(sx) int input(sy) int input(ex) int input(ey);

  rep(y, ey - sy) {
    p("U");
  }
  rep(x, ex - sx) {
    p("R");
  }
  rep(y, ey - sy) {
    p("D");
  }
  rep(x, ex - sx) {
    p("L");
  }
  p("D");
  rep(x, ex - sx + 1) {
    p("R");
  }
  rep(x, ey - sy + 1) {
    p("U");
  }
  p("L")
  p("U");
  rep(x, ex - sx + 1) {
    p("L");
  }
  rep(x, ey - sy + 1) {
    p("D");
  }
  p("R")
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
int X(int Y){
  return Y>=0?Y:-Y;
}
signed main(){
  int N,L;
  cin>>N>>L;
  int ans=0,sum=MOD;
  rep(i,0,N){
    ans+=L+i;
    if(X(sum)>X(L+i)) sum=L+i;
  }
  cout<<ans-sum<<endl;
}




Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=1000000007;
const ll M=100005;
bool isPrime(long long x){
  if(x == 1)return 0;
  for(long long i = 2; i*i <= x; i++) if(x%i == 0) return 0;
  return 1;
}
int main(){
  ll n;cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  vector<ll> sum(n);
  sum=a;
  map<ll,ll> cnt;
  rep(i,n-1){
    sum[i+1]+=sum[i];
  }
  rep(i,n){
    cnt[sum[i]]++;
  }
  ll ans=0;
  for(auto p:cnt){
    if(p.first==0){
      ans+=p.second;
    }
    if(p.second>=2){
       ans+=p.second*(p.second-1)/2;
    }
  }
  cout << ans << endl;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;

const int INF = 1001001001;

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

  int n, x, y; cin >> n >> x >> y;
  --x; --y;
  vector<int> ans(n);
  
  rep(i, n) {
    vector<int> dist(n, INF);
    queue<int> s;
    auto yo_push = [&](int v, int d) {
		  if(dist[v] != INF) return;
		  dist[v] = d;
		  s.push(v);
		};
    
    yo_push(i, 0);
    while(!s.empty()) {
      int v = s.front();
      s.pop();
      int d = dist[v];
	
      if(v-1 >= 0) yo_push(v-1, d+1);
      if(v+1 < n) yo_push(v+1, d+1);
      if(v == x) yo_push(y, d+1);
      if(v == y) yo_push(x, d+1);
    }
    rep(j, n) ans[dist[j]]++;
  }
  rep(i, n) ans[i]/=2;
  rep(i, n-1) {
    cout << ans[i+1] << endl;
  }
}
      


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

int main(void) {
  int x;
  int i, j;
  int max = 1;
  
  scanf("%d", &x);
  
  for (i = 2; i <= sqrt(x); i++) {
    for (j = 1; pow(i, j) <= x; j++) {
      max = max < pow(i, j) ? pow(i, j) : max;
    }
  }
  
  printf("%d", max);
  
  return 0;
}

Measured memory_bytes: 128
=begin
1, 1 ~ 9 の配列を作ってそれぞれ判定する(to_a = i)
2, n / i < 10 かつ n % i　== 0　に数値を any? で判定する
  2.1, any? は 全ての要素が 真 の時に true を返し、それ以外は false を返す
3, 三項演算子で 結果を 出力する
=end

n = gets.to_i

puts (1..9).to_a.any?{|i| n / i < 10 && n % i == 0} ? "Yes" : "No"

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
using namespace std;
int main(){
    string s,ans;
    cin>>s;
    rep(i,0,(int)s.length()){
        switch(s[i]){
            case 'B':
                if(ans.length()>0)ans.pop_back();
                break;
            default:
                ans.push_back(s[i]);
                break;
        }
    }
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n,k = [int(v) for v in input().split()]
p = [int(v) for v in input().split()]

excepted = [(v*(v+1) / 2) / v for v in p]

left = 0
right = 0

ans = 0
tmp = 0

while True:
    ans = max(tmp,ans)
    if left == n : break
    if right - left < k and right != n:
        tmp += excepted[right]
        right += 1
    else:
        tmp -= excepted[left]
        left += 1

print(ans)


Measured memory_bytes: 25188
#include <iostream>

using namespace std;

long a[2000];
    long m[2000][2000];

int main(){
    int N, x;
    cin >> N >> x;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    long ans = __LONG_MAX__;
    for(int i = 0; i < N; i++){
        m[i][0] = a[i];
        for(int j = 1; j < N; j++){
            if(i >= j) m[i][j] = min(m[i][j-1], a[i-j]);
            else m[i][j] = min(m[i][j-1], a[i-j+N]);
        }
    }
    for(int i = 0; i < N; i++){
        long tmp = 0;
        for(int j = 0; j < N; j++){
            tmp += m[j][i];
        }
        ans = min(ans, tmp+x*i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 31488
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  printf("%d %d %d\n", c, a, b);
}

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

int main()
{
  int n, k;
  cin >> n >> k;

  vi a(n); 
  rep(i, n) cin >> a[i];

  vl s(n+1, 0);
  rep(i, n) s[i+1] = s[i] + a[i];

  vl b;
  repi(i, 1, n+1) repi(j, i, n+1){
    b.pb(s[j]-s[i-1]);
  }

  vl lis;
  ll ans = 0;
  for(int i = 60; i >= 0; i--){
    if(lis.empty()){
      for(auto j : b){
        if(j>>i & 1){
          lis.pb(j);
        }
      }
      if(lis.size() < k) lis.clear();
      else ans = 1LL<<i;
    }else{
      vl tmp;
      for(auto j : lis){
        if(j>>i & 1){
          tmp.pb(j);
        }
      }
      if(tmp.size() >= k){
        lis = tmp;
        ans += 1LL<<i;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6388
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int a, b, r;
    cin >> a >> b;
    if(a < b){
        swap(a, b);
    }

    while(true){
        if(b == 0){
            cout << a << endl;
            return 0;
        }
        r = a % b;
        a = b;
        b = r;
    }
}

Measured memory_bytes: 0
N= int(input())
s = list()
for i in range(N):
    s.append(input())

M= int(input())
t = list()
for i in range(M):
    t.append(input())

    
max_count = 0
for i in range(N):
    for j in range(M):
        B = s.count(s[i]) - t.count(s[i])
        C = s.count(t[j]) - t.count(t[j])
        
        if B > C:
            E = B
        else:
            E = C
               
        if E > max_count:
            max_count = E
    
print(max_count)


Measured memory_bytes: 3064
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

void dfs(vector<vector<llong> > &graph, vector<bool> &seen, vector<llong> &color, llong node, llong now_color){
    if(seen[node]){
        return;
    }
    seen[node] = true;
    color[node] = now_color;
    for(int i=0; i<graph[node].size(); i++){
        dfs(graph, seen, color, graph[node][i], now_color);
    }
}

int main(){
    llong n,m;
    llong s,t;
    llong now_color=0;
    scanf("%lld %lld", &n, &m);
    vector<vector<llong> > graph(n);
    vector<bool> seen(n, false);
    vector<llong> color(n, 0);

    for(int i=0; i<m; i++){
        scanf("%lld %lld", &s, &t);
        graph[s].push_back(t);
        graph[t].push_back(s);
    }
    for(int i=0; i<n; i++){
        if(seen[i]){
            continue;
        }
        dfs(graph, seen, color, i, now_color);
        now_color++;
    }
    llong q;
    cin >> q;
    for(int i=0; i<q; i++){
        cin >> s >> t;
        if(color[s]==color[t]){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 15300
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q;
    cin >> q;
    set<int> se;
    while(q--) {
        int t;
        cin >> t;
        if(t) {
            int x;
            cin >> x;
            set<int>::iterator itr = se.find(x);
            cout << (itr != se.end()) << '\n';
        } else {
            int x;
            cin >> x;
            se.insert(x);
            cout << se.size() << '\n';
        }
    }
}


Measured memory_bytes: 12508
/* AtCoder Beginner Contest 060. Task C - Sentou, by Abreto <m@abreto.net>. */
#include <stdio.h>

int mymin(int a, int b)
{
    return (a<b)?a:b;
}

int main(void)
{
    int i = 0;
    int N = 0, T = 0;
    int t1 = 0, t2 = 0;
    int tot = 0;

    scanf("%d %d", &N, &T);
    scanf("%d", &t1);
    for(i = 1;i < N;++i)
    {
        scanf("%d", &t2);
        tot += mymin(T, t2-t1);
        t1 = t2;
    }
    tot += T;

    printf("%d\n", tot);
    return 0;
}


Measured memory_bytes: 128
import sys
import numpy as np
n = int(input())
s = list(map(str, input().rstrip()))

ss = s.count("#")
sd = s.count(".")

if ss == 0 or sd == 0:
    print(0)
    sys.exit()

s = np.array([x == "#" for x in s])

dp = np.zeros([2, n], dtype=int)

# dp0は黒の数、dp0は白の数
dp[0] = s
dp[1] = ~s

dp = dp.cumsum(axis=1)

# 白の数は「それ以降の」と読み替える
dp[1] = dp[1].max() - dp[1]

print(min((dp[0] + dp[1]).min(), ss, sd))

Measured memory_bytes: 19068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define n_l '\n'
#ifndef ONLINE_JUDGE
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl
#endif
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef double db;
typedef vector<vi> vvi;
const ll mod=1000000007;
const ll N=2000005; //check this
const ll inf = 1e15;
ll powmod(ll a,ll b) {if(b<0)b=mod-1+b;ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powb(ll a,ll b) {ll res=1;a ; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	int k;cin>>k;
	ll ans=0;
	for(int i=1;i<=k;i++)
		for(int j=1;j<=k;j++)
			for(int l=1;l<=k;l++)
				ans+=__gcd(__gcd(i,j),l);
	cout<<ans;
}


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

using namespace std;

int main(){

  int a,b,c;

  cin>>a>>b>>c;

  int time = 0;
  int cnt = 100;

  while(cnt!=0){
	time+=a;
	if(time>=c)
	  break;
	time+=b;
	if(time>=c)
	  c+=60;

	cnt--;
	if(cnt==0){
	  cout<<-1<<endl;
	  return 0;
	}
	
	}
  
  cout<<c<<endl;
  
}



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

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

  int a, b;

  cin >> a >> b;

  int sum = a + b;

  if (sum % 3 == 0 || a % 3 == 0 || b % 3 == 0) {
    cout << "Possible";
  } else {
    cout << "Impossible";
  }
  cout << endl;
}

Measured memory_bytes: 256
import sys

N = int(input())
if N == 0:
	print('0')
	sys.exit()

numList = list()

for i in range(N):
	numList.append(int(input()))
	
numList.sort()

wordCount = 0
i = 0

while i < N:
	if i < N-1 and numList[i] == numList[i+1]:
		i += 2
	elif i == N-1:
		wordCount += 1
		break
	else:
		wordCount += 1
		i += 1
		
print(wordCount)

Measured memory_bytes: 7384
#include <stdio.h>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <iterator>

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

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

constexpr int inf = 1e9;
constexpr int N = 2e5;
char str[N+10];
constexpr int ALPHA_SIZE = 'z' - 'a' + 1;
// A[i][j] = [0, i)の中の char<'a'+ j>の個数の偶奇
std::array<std::bitset<ALPHA_SIZE>, N+1> A;
std::array<int, N+1> DP;

int main(void){
    scanf("%s", str);
    const int n = strlen(str);
    REP(i, n){A[i+1] = A[i]; A[i+1].flip(str[i] - 'a');}

    std::map<int, int> minDist; minDist[0] = 0; DP[0] = 0;
    for(int i = 1; i <= n; ++i){
        DP[i] = DP[i-1] + 1;
        int v = A[i].to_ulong();
        std::map<int, int>::iterator itr; 
        REP(j, ALPHA_SIZE){
            int nv = v ^ (1 << j);
            itr = minDist.find(nv);
            if(itr != minDist.end()) chmin(DP[i], itr->second + 1);
        }
        itr = minDist.find(v);
        if(itr == minDist.end()) minDist[v] = DP[i];
        else if(DP[i] > itr->second + 1) DP[i] = itr->second + 1;
        else if(DP[i] < itr->second)     minDist[v] = DP[i];
    }
    printf("%d\n", DP[n]);
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    int w, h, n;
    cin >> w >> h >> n;
    int x1 = 0, x2 = w, y1 = 0, y2 = h;
    rep(i, n) {
        int x, y, a;
        cin >> x >> y >> a;
        if(a == 1) {
            x1 = max(x1, x);
        } else if(a == 2) {
            x2 = min(x2, x);
        } else if(a == 3) {
            y1 = max(y1, y);
        } else {
            y2 = min(y2, y);
        }
    }

    int ans = max(0, -x1+x2) * max(0, -y1+y2);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.math.BigInteger;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      BigInteger bda = new BigInteger(sc.next());
      BigInteger bdb = new BigInteger(sc.next());
      BigInteger gcd = bda.gcd(bdb);
      BigInteger lcm = bda.multiply(bdb).divide(gcd);
      System.out.println(gcd+" "+lcm);
    }
  }
}

Measured memory_bytes: 11000
import java.io.IOException;

public class Main {

	public static void main(String[] args) throws IOException {
		int count = 0;
		int res = 0;
		for (int i = 0; i < 3; i++) {
			char data = (char) System.in.read();
			if (data == 'R') {
				count++;
			}
			if (data == 'S') {
				count = 0;
			}
			if (count > res) {
				res = count;
			}
		}
		System.out.println(res);
	}

}


Measured memory_bytes: 32308
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"basic.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
#endif

struct Node{
    vector<pair<Node*, int>> dests;
    void add(Node* n, int c){
        dests.emplace_back(n, c);
    }
    void add2(Node* n, int c){
        add(n, c);
        n->add(this, c);
    }
    void dfs(Node* from = nullptr){
        for(auto p : dests){
            Node* d = p.first;
            if(d == from){ continue; }
            d -> dfs(this);
        }
    }
};

struct pqElem{
    int c;
    Node *node;
    vector<pair<Node*, Node*>> froms;
    pqElem(int c, Node* d, const vector<pair<Node*, Node*>>& fs, pair<Node*, Node*> f = {}): c(c), node(d), froms(fs){
        if(f != pair<Node*, Node*>()){
            froms.push_back(f);
        }
    }
    bool operator < (const pqElem& p) const{
        return c > p.c;
    }
};

int main(){
    int n, m; cin >> n >> m;
    vector<Node> nodes(n);
    set<pair<Node*, Node*>> used;
    for(int i=0;i<m;i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        nodes[a].add2(&nodes[b], c);
    }
    for(int i=0;i<n;i++){
        // for(int j=i + 1;j<n;j++){
            priority_queue<pqElem> pq;
            pq.emplace(0, &nodes[i], vector<pair<Node*, Node*>>{});
            map<Node*, int> visited;
            int ans = M;
            while(pq.size()){
                auto e = pq.top(); pq.pop();
                int c = e.c;
                // if(ans < c){ break; }
                Node* n = e.node;
                prints("top", e.c, n, n - &nodes[0]);
                prints(visited);
                if(visited.count(n) && visited[n] < c){ continue; }
                prints("top", e.c);
                visited[n] = c;
                prints(ans, c);
                // prints(i, j, n - &nodes[0]);
                // if(n == &nodes[j]){
                    ans = c;
                    auto& froms = e.froms;
                    for(auto& f : froms){
                        if(f.first){
                            // prints(f - &nodes[0]);
                            if(f.first > f.second){ swap(f.first, f.second); }
                            used.insert(f);
                        }
                    }
                    // continue;
                // }
                for(auto p : n->dests){
                    prints("emplace", c + p.second, "from", n - &nodes[0], "to", p.first - &nodes[0]);
                    pq.emplace(c + p.second, p.first, e.froms, make_pair(n, p.first));
                }
            }
        // }
    }
    int ans = m - used.size();
    prints([&nodes](ostream& out, Node* n){ out << n - &nodes[0]; }, used);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 808
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int MAX = 40;
const int MOD = 1000000007;
const int NIL = -1;
const double pi = 3.141592653589;
/* global variables */
struct Node {
    int parent,
        left,
        right;
};
Node T[MAX];
vector<int> Pre(MAX), In(MAX), Post;
int pos = 0;

/* function */
void reconstruction(int l, int r);
void postorder(int u);

/* main */
int main(){

    int n; cin >> n;
    for (int i = 0; i <= n; i++)
        T[i].parent = T[i].left = T[i].right = NIL;

    for (int i = 0; i < n; i++)
        cin >> Pre[i];
    for (int i = 0; i < n; i++)
        cin >> In[i];

    reconstruction(0, n);

    for (int i = 0; i < n; i++) {
        if (i) cout << ' ';
        cout << Post[i];
    }cout << '\n';
    return 0;
}

void reconstruction(int l, int r) {
    if (l >= r) return;
    int root = Pre[pos++];
    vector<int>::iterator itr = find(In.begin(), In.end(), root);
    int m = distance(In.begin(), itr);
    reconstruction(l, m);
    reconstruction(m+1, r);
    Post.push_back(root);
}



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

int main (void){
    string S;
    cin >> S;
    if(S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3560
/* � Ashiq Uddin Pranto
   Department of Computer Science and Engineering
   BATCH 27
   University Of Rajshahi,Bangladesh
*/
#include<bits/stdc++.h>

#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define matrix(x) vector<vector<x>>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 1000000007
#define MOD(a,b) (a%b + b)%b

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    //fastio
    ll n,x,y;
    sfl(n);
    ll mxxplusy = INT_MIN,minxplusy = INT_MAX,mxxminusy = INT_MIN,minxminusy = INT_MAX;
    while(n--)
    {
        sffl(x,y);
        mxxplusy = max(mxxplusy,x+y);
        minxplusy = min(minxplusy,x+y);
        mxxminusy = max(mxxminusy,x-y);
        minxminusy = min(minxminusy,x-y);
    }
    cout<<max(mxxplusy-minxplusy,mxxminusy-minxminusy)<<endl;

    return 0;
}

Measured memory_bytes: 3740
str = input()
q = int(input())
for i in range(q):
    method, a, b, *p = input().split()

    if method == "print":
        print(str[int(a) : int(b) + 1])
    elif method == "reverse":
        pre = str[: int(a)]
        reverse = str[int(a) : int(b) + 1][::-1]
        after = str[int(b) + 1 :]
        str = pre + reverse + after
    elif method == "replace":
        pre = str[: int(a)]
        after = str[int(b) + 1 :]
        str = pre + "".join(p) + after



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

int main(void) {
  long long N, sum=0;
  cin >> N;

  for(long i=0; i<=N; i++){
    if(i%3!=0 && i%5!=0)
      sum += i;
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 3588