akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();

            long ans = 0;
            for (int x = 1; x <= N; x++) {
                long y = N / x;
                ans += y * (y + 1) * x / 2;
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 32964
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 3e5+10, mod = 998244353;
int n,cnt[3],p[N];
char s[N];

inline int Get(char c){
	if (c=='R') return 0;
	if (c=='G') return 1;
	return 2;
}

int main(){
	n=read()*3,scanf("%s",s+1);
	int ans=1,tot=0;
	For(i,1,n){
		int c=Get(s[i]);
		if (c==0){
			if (cnt[1]&&cnt[2]){
				--cnt[1],--cnt[2];
				p[i]=3;
			} else {
				if (cnt[0]>=max(cnt[1],cnt[2])){
					p[i]=1;
				} else {
					p[i]=2;
				}
				++cnt[0];
			}
		}
		if (c==1){
			if (cnt[0]&&cnt[2]){
				--cnt[0],--cnt[2];
				p[i]=3;
			} else {
				if (cnt[1]>=max(cnt[0],cnt[2])){
					p[i]=1;
				} else {
					p[i]=2;
				}
				++cnt[1];
			}
		}
		if (c==2){
			if (cnt[0]&&cnt[1]){
				--cnt[0],--cnt[1];
				p[i]=3;
			} else {
				if (cnt[2]>=max(cnt[0],cnt[1])){
					p[i]=1;
				} else {
					p[i]=2;
				}
				++cnt[2];
			}
		}
	}
	For(i,1,n){
		cnt[p[i]]++;
		if (p[i]>=2) ans=1ll*ans*cnt[p[i]-1]%mod,--cnt[p[i]-1];
	}
	For(i,1,n/3) ans=1ll*ans*i%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 5264
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  cout << max({A + A - 1, B + B - 1, A + B}) << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check


void solve(long long N, long long A, long long B, std::vector<long long> P){
    ll cntA=0, cntB=0, cntC=0;
    A++; B++;
    REP(i, N){
        if(P[i]<A){
            cntA++;
        }
        else if(P[i]<B){
            cntB++;
        }
        else{
            cntC++;
        }
    }
    cout << min(cntA, min(cntB, cntC)) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    solve(N, A, B, std::move(P));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e16
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

struct edge {
  ll to;
  ll cost;
  edge() {}
  edge(ll to_, ll cost_) : to(to_), cost(cost_) {}
};
std::vector<edge> graph1[123456], graph2[123456];

// O(ElogV)ダイクストラ
ll D1[123456], D2[123456];
void Dijkstra(uint32_t s, ll D[123456], bool on) {
  using P = std::pair<ll, ll>; // cost pos
  std::priority_queue<P, std::vector<P>, std::greater<P>> que;
  REP(i, 123455) { D[i] = INF; }
  D[s] = 0;
  que.emplace(0, s);
  while (!que.empty()) {
    auto p = que.top();
    que.pop();
    const auto &nowpos = p.second;
    const auto &nowcost = p.first;
    if (D[nowpos] < nowcost) {
      continue;
    }
    if (on) {
      for (const auto &e : graph1[nowpos]) {
        auto cost = nowcost + e.cost;
        if (cost < D[e.to]) {
          D[e.to] = cost;
          que.emplace(cost, e.to);
        }
      }
    } else {
      for (const auto &e : graph2[nowpos]) {
        auto cost = nowcost + e.cost;
        if (cost < D[e.to]) {
          D[e.to] = cost;
          que.emplace(cost, e.to);
        }
      }
    }
  }
}

ll imos[114514];
int main() {
  ll n, m, s, t;
  cin >> n >> m >> s >> t;
  s--, t--;
  REP(i, m) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    u--;
    v--;
    graph1[u].pb({v, a});
    graph1[v].pb({u, a});
    graph2[v].pb({u, b});
    graph2[u].pb({v, b});
  }
  Dijkstra(s, D1, true);
  Dijkstra(t, D2, false);

  REP(i, n) { imos[i] = D1[i] + D2[i]; }
  for (int i = n - 1; i >= 1; i--) {
    imos[i - 1] = min(imos[i], imos[i - 1]);
  }
  REP(i, n) { cout << 1000000000000000 - imos[i] << endl; }
}


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

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define pb push_back
#define F first
#define S second
#define lll long long
#define lld long double

#define data etokek

#define int lll

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree <T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

const int N = 2e3 + 32;
//const int M = 1e9 + 7;
const int mod = 998244353;
const int rx[4] = {-1, -1, 1, 1};
const int ry[4] = {-1, 1, -1, 1};
const lld eps = 1e-11;
const double pi = acos(-1.0);
const int kx[8] = {1, 1, -1, -1, 2, 2, -2, -2};
const int ky[8] = {2, -2, 2, -2, 1, -1, 1, -1};

pair < int, int > a[N];

int dp[N][N];

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(time(0));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("mushrooms.in", "r", stdin);
//    freopen("mushrooms.out", "w", stdout);
#endif
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].F;
        a[i].S = i;
    }
    sort(a, a + n);
    reverse(a, a + n);
    int r;
    for (int i = 0; i < n; ++i) {
        for (int l = 0; l <= i; ++l) {
            r = n - 1 - (i - l);
            dp[i + 1][l + 1] = max(dp[i + 1][l + 1], dp[i][l] + abs(a[i].S - l) * a[i].F);
            dp[i + 1][l] = max(dp[i + 1][l], dp[i][l] + abs(a[i].S - r) * a[i].F);
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        ans = max(ans, dp[n][i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 26448
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
ll pre[maxn];
ll findp(ll x){return pre[x]==x?x:pre[x]=findp(pre[x]);}
ll a[maxn];
bool f[maxn];
int main(){
	ll n,m;
	inl2(n,m);
	FOR(i,1,n)pre[i]=i;
	ll ans=m;
	while(m--){
		ll c1,c2;
		inl2(c1,c2);
		ll fx=findp(c1),fy=findp(c2);
		if(fx!=fy)pre[fy]=fx,a[fx]+=a[fy];
		a[fx]++;
	}
	ll x=findp(1),y=findp(2);
	ll xx=1,yy=1;
	FOR(i,3,n){
		if(findp(i)==x){
			xx++;
		}
		 else if(findp(i)==y){
			yy++;
		}
	}
	if(xx<yy){
		swap(xx,yy);
		swap(x,y);
	}
	outl((n-yy)*(n-yy-1)/2+yy*(yy-1)/2-ans);
}

Measured memory_bytes: 1792
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] data = new int[100];
		for(int i = 0; i < 100; i++) {
			data[i] = 0;
		}
		
		int tmp;
		while(sc.hasNext()) {
			tmp = sc.nextInt();
			data[tmp - 1]++;
		}
		
		int max = Integer.MIN_VALUE;
		for(int i = 0; i < 100; i++) {
			max = Math.max(max, data[i]);
		}
		
		for(int i = 0; i < 100; i++) {
			if(data[i] == max)	System.out.println(i + 1);
		}
	}
}

Measured memory_bytes: 26260
N,u,v = list(map(int,input().split()))
u,w = u-1,v-1
w,u = u,w
e_list = [[] for i in range(N)]
for i in range(N-1):
        a,b = list(map(int,input().split()))
        a,b = a-1,b-1
        e_list[a].append(b)
        e_list[b].append(a)

vi = u #時と場合によってここを変える
from collections import deque
Q = deque([vi])
checked_list = [False for i in range(N)]
checked_list[vi]=True
min_path_list = [10**27 for i in range(N)] #問題によりここを変える
min_path_list[vi] = 0
prev_list = [-1 for i in range(N)]
while len(Q)>0:
    v = Q.pop()
    for v1 in e_list[v]:
        if not checked_list[v1]:
            checked_list[v1]=True
            prev_list[v1] = v
            Q.appendleft(v1)
            min_path_list[v1]=min(min_path_list[v1],min_path_list[v]+1) #問題によりここを変える

dis=min_path_list[w]//2
w_min = min_path_list[w]
current = w
for i in range(dis):
        current = prev_list[current]
dist = min_path_list[current]
vi = current #時と場合によってここを変える
Q = deque([vi])
checked_list = [False for i in range(N)]
checked_list[vi]=True
checked_list[prev_list[vi]]=True
min_path_list = [10**27 for i in range(N)] #問題によりここを変える
min_path_list[vi] = 0
while len(Q)>0:
    v = Q.pop()
    for v1 in e_list[v]:
        if not checked_list[v1]:
            checked_list[v1]=True
            Q.appendleft(v1)
            min_path_list[v1]=min(min_path_list[v1],min_path_list[v]+1) #問題によりここを変える
depth = 0
for i in range(N):
        if min_path_list[i]<10**27:
                depth = max(min_path_list[i],depth)

depth = dist+depth
print(depth-1)

Measured memory_bytes: 73376
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n,x;
  cin >> n >> x;
  vi m(n);

  int sum = 0;

  rep(i,n)
  {
    cin >> m[i];
    sum += m[i];
  }

  vsort(m);

  int ans = (x - sum) / m[0] + n;

  cout << ans << endl;



  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

int main(){
int i,j,l, k[6],s[6], n[6], n2[6];
char c;

 for (i = 0; i<6; i++){
   scanf("%d", &s[i]);
   n[i] = i;
 }
 for (i = 0; i<6; i++){
   scanf("%d", &k[i]);
 }
 for (j = 0; j < 5000; j++){
   if (j%6<3&&j%5==4){
     n2[0] = n[1]; 
     n2[1] = n[5]; 
     n2[3] = n[3]; 
     n2[4] = n[0]; 
     n2[2] = n[2]; 
     n2[5] = n[4];
   }
   else {
     n2[0] = n[3]; 
     n2[1] = n[1]; 
     n2[3] = n[5]; 
     n2[4] = n[4]; 
     n2[2] = n[0]; 
     n2[5] = n[2];
   }
   for (i = 0; i < 6; i++){
     n[i] = n2[i];
   }
   for (l = 0; l < 6; l++){
     if (s[l] != k[n[l]])break;
                 
   }
   if (l == 6){ printf("Yes\n"); break; }
 }
 if (j == 5000)printf("No\n");
 return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
  int n, t, a;
  cin >> n >> t >> a;

  double d;
  int ans;
  for(int i = 0; i< n; i++)
  {
    int h;
    cin >> h;
    double tmpD = fabs((t - 0.006 * h) - a);
    if(i == 0 || tmpD < d)
    {
      d = tmpD;
      ans = i;
    }
  }
  cout << ans + 1 << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
//#pragma GCC target ("avx,avx2,tune=native")
//#pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define orz ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);    
#define inp freopen("input.txt","r",stdin);freopen("out.txt","w",stdout); 
ll mod=1e9+7;
void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
const int N=2e5+5;
int a[N],v[N];
int main() {
	//io();
	string s;
	ll n,k,q,m,sum=0;
	cin>>n>>m;
	priority_queue<int> pq;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		pq.push(x);
	}
	while(m--){
		int x=pq.top();
		x=x/2;
		pq.pop();
		pq.push(x);
	}
	while(pq.size()){
		int x=pq.top();

		pq.pop();
		sum+=x;
	}
	cout<<sum;
}
 

 

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


int main() {
  int N ;
  cin >> N;
  int a = N % 10;
    
  if( a == 3){
    cout << "bon" << endl;
  }
  else if( a==0 || a==1 || a==6 || a==8){
  cout << "pon" << endl;
  }
  else{
    cout << "hon" <<endl;
  }
}

Measured memory_bytes: 3584
# 駐車場があり、以下の二種類のプランのどちらかを選んで駐車できます。
# プラン 1 : T 時間駐車した場合、A×T 円が駐車料金となる。
# プラン 2 : 駐車した時間に関わらず B 円が駐車料金となる。
# N 時間駐車するとき、駐車料金は最小でいくらになるか求めてください。

input_line = gets.chomp.split
n = input_line[0].to_i
a = input_line[1].to_i
b = input_line[2].to_i

plan_1 = n * a
plan_2 = b

if plan_1 < plan_2
  puts plan_1
else
  puts plan_2
end


Measured memory_bytes: 1788
class PriorityQueue
	def initialize
		@node = []
		@n = 0
	end

	private

	def left_key key
		2*key+1
	end

	def right_key key
		2*key+2
	end

	def from_root_swap key, 
		right = right_key(key)
		left = left_key(key)
		if  key < 0 
			return nil
		end
		if !@node[left] && !@node[right]
			return nil
		elsif @node[left] && !@node[right]
			if @node[left].cost < @node[key].cost
				@node[key], @node[left] =  @node[left], @node[key]
				from_root_swap(left)
			end
		elsif @node[right] && !@node[left]
			if @node[right].cost < @node[key].cost
				@node[key], @node[right] =  @node[right], @node[key]
				from_root_swap(right)
			end
		elsif @node[key].cost >= @node[left].cost && @node[left].cost <= @node[right].cost
			@node[key], @node[left] =  @node[left], @node[key]
			from_root_swap(left)
		elsif @node[key].cost >= @node[right].cost && @node[right].cost <= @node[left].cost
			@node[key], @node[right] =  @node[right], @node[key]
			from_root_swap(right)
		end
	end

	def from_leaf_swap key
		if key == 0
			return nil
		end
		parent_key = (key-1)/2
		if @node[parent_key].cost > @node[key].cost
			@node[key], @node[parent_key] = @node[parent_key], @node[key]
			from_leaf_swap(parent_key)
		end
	end

	def extract!
		node = @node[0]
		if @node.size == 0
			railse "Queue is Empty"
		elsif @node.size == 1
			@n -= 1
			return @node.pop
		else
		@n -= 1
		node = @node[0]
		@node[0] = @node.pop
		from_root_swap(0)
		return node
		end
	end

	def insert! node
		@node << node
		@n += 1
		from_leaf_swap(@n - 1)
	end



	public

	def << node
		insert!(node)
	end

	def pop
		extract!
	end

	def empty?
		@node.empty?
	end

end



n = gets.to_i
m = Array.new(n){Array.new(n){Float::INFINITY}}
n.times do |i|
	s = gets.split.map(&:to_i)
	s[1].times do |j|
		m[s[0]][s[ 2 * j + 2]] = s[2 * j + 3]
	end
end

Vector = Struct.new(:sta, :end, :cost)
pq = PriorityQueue.new
BLACK = 0
WHITE = 1
color = Array.new(n){WHITE}
cost = Array.new(n){Float::INFINITY}
cost[0] = 0
color[0] = BLACK
u = 0
loop{


	n.times do |i|
		pq << Vector.new(u, i, cost[u] + m[u][i] ) if color[i] == WHITE
	end


	break if pq.empty?
	vector = pq.pop
	next if vector.cost == Float::INFINITY

	color[vector.end] = BLACK
	 cost[vector.end] = vector.cost if cost[vector.end] > vector.cost
	 u = vector.end
}

n.times do |i|
	puts "#{i} #{cost[i]}"
end

Measured memory_bytes: 9112
N = int(input())
A_list = list(map(int, input().split()))

n_operation = 0
while True:
  new_A_list = []
  for A in A_list:
    if A % 2:
      print(n_operation)
      exit()
    else:
      new_A_list.append(A // 2)
  # Update
  A_list = new_A_list
  n_operation += 1
      

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Set<Integer> set = new HashSet<>();
      
      	for(int i = 0 ; i < 3 ; i++){
      		set.add(sc.nextInt());
        }

        System.out.println(set.size() == 2 ? "Yes" : "No");
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;
const ll MOD=1000000007;

int main()
{
  int N, M;
  ll res=1;
  cin >> N >> M;

  vector<bool> broken(N+1,false);
  rep(i,M) {
    int a;
    cin >> a;
    broken[a]=true;
  }

  ll dp[110000];
  rep (i,N) dp[i] = 0;
  dp[0]=1;
  rep (i,N){
    if(!broken[i+1] && i+1<=N){
      dp[i+1] += dp[i];
      dp[i+1] %= MOD;
    }
    if(!broken[i+2] && i+2<=N){
      dp[i+2] += dp[i];
      dp[i+2] %= MOD;
    }
  }

  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = [list(map(int, input().split())) for _ in range(q)]

num_array = [0 for _ in range(10**5 + 1)]
result = 0

for num in a:
  num_array[num] += 1
  result += num
  
for array in bc:
  dif = array[1] - array[0]
  result += dif * num_array[array[0]]
  num_array[array[1]] += num_array[array[0]]
  num_array[array[0]] = 0
  print(result)

Measured memory_bytes: 33104
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int N;
    cin >> N;
    pair<string, int> List[N];
    for(int i = 0; i < N; ++i) cin >> List[i].first >> List[i].second;
    string X;
    cin >> X;
    for(int i = 0; i < N; ++i) if(List[i].first == X) {
        int res = 0;
        for(int j = i+1; j < N; ++j) res += List[j].second;
        cout << res << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;
const int maxn=2e5+100;
int a[maxn],b[maxn];
void myinit(){
	cin >> n;
	for (int i=1;i<=n;i++) cin >> a[i];
	for (int i=1;i<=n;i++) cin >> b[i];
}
int k;
int c[maxn];
void solve(){
	myinit();
	int ans=0;
	for (k=0;k<=28;k++){
//		cout << "k=" << k << ' ';
		for (int i=1;i<=n;i++) c[i]=b[i]%(1<<(k+1));
		sort(c+1,c+1+n);
//		cout << "k=" << k << endl;
//		cout << "a=";for (int i=1;i<=n;i++) cout << a[i]%(1<<(k+1)) << ' ';cout << endl;
//		cout << "c=";for (int i=1;i<=n;i++) cout << c[i] << ' ';cout << endl;
		int s=0;
		for (int i=1;i<=n;i++){
			s+=lower_bound(c+1,c+1+n,(1<<(k+1))-(a[i]%(1<<(k+1))))-
			lower_bound(c+1,c+1+n,(1<<k)-(a[i]%(1<<(k+1))));
			s+=lower_bound(c+1,c+1+n,(1<<(k+2))-a[i]%(1<<(k+1)))-
			lower_bound(c+1,c+1+n,(1<<(k+1))+(1<<k)-(a[i]%(1<<(k+1))));
//			cout << "tmps=" << s << endl;
//			cout << "s=" << s << ' ' << (1<<(k+1))-1-(a[i]%(1<<(k+1))) << ' ' 
//			<< (1<<k)-(a[i]%(1<<(k+1))) << endl;
		}
//		cout << endl;
//		cout << "s=" << s << endl;
		if (s%2) ans+=(1<<k);
//		cout << "ans=" << ans << endl;
	}
	cout << ans << endl;
}
signed main(){
	solve();
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k,h,i,ans=0;
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>h;
		if(h>=k)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
n, m = [int(i) for i in input().split()]
p = [0 for i in range(m)]
y = [0 for i in range(m)]

out = [[0, 0] for i in range(m)]
hash = [[] for i in range(10**5+10)]
for i in range(m):
    p[i], y[i] = [int(i) for i in input().split()]
    hash[p[i]].append([y[i], i])

for i in range(len(hash)):
    hash[i] = sorted(hash[i])
    for j in range(len(hash[i])):
        out[hash[i][j][1]] = i, j+1
for i in range(len(out)):
    print("{}{}".format(str(out[i][0]).zfill(6), str(out[i][1]).zfill(6)))

Measured memory_bytes: 50016
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 3010
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
#define INF 10000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	ll n;
    cin>>n;
    ll a=1;
    for(int i=2;i<sqrt(n)+1;i++){
        if(n%i==0)a=i;
    }
    ll b=(ll)n/a;
    ll ans=a+b-2;
    OUT(ans);
    return 0;
}

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

int count_round_mine(vector<vector<char>> S, int H, int W)
{
  int result = 0;
  for (int i = H - 1; i < H + 2; i++)
  {
    for (int j = W - 1; j < W + 2; j++)
    {
      if (S[i][j] == '#')
        result++;
    }
  }

  return result;
}

int main()
{
  int H, W;
  cin >> H >> W;

  vector<vector<char>> S(H + 2, vector<char>(W + 2));

  for (int i = 1; i < H + 1; i++)
  {
    for (int j = 1; j < W + 1; j++)
    {
      cin >> S[i][j];
    }
  }

  for (int i = 1; i < H + 1; i++)
  {
    for (int j = 1; j < W + 1; j++)
    {
      if (S[i][j] == '#')
        cout << '#';
      else
        cout << count_round_mine(S, i, j);
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    long H, W;
    cin >> H >> W;
    std::vector<std::vector<string>> mat(H, vector<string>(W, ""));
    for(size_t i=0;i<H; i++)
    {
        string line;
        cin >> line;
        for(size_t j=0;j<W; j++)
        {
            mat[i][j] = line[j];
        }
    }
    std::vector<std::vector<long>> mat_count(H, vector<long>(W, 0));
    for(size_t i=0;i<H; i++)
    {
        long count = 0;
        for(size_t j=0;j<W; j++)
        {
            if(mat[i][j] == "#") count = 0;
            else count++;
            mat_count[i][j] += count;
        }
    }
    for(size_t i=0;i<H; i++)
    {
        long count = 0;
        for(size_t j=W-1;j>=0; j--)
        {
            if(mat[i][j] == "#") count = 0;
            else count++;
            mat_count[i][j] += count;
            if(j==0) break;
        }
    }
    for(size_t j=0;j<W; j++)
    {
        long count = 0;
        for(size_t i=0;i<H; i++)
        {
            if(mat[i][j] == "#") count = 0;
            else count++;
            mat_count[i][j] += count;
        }
    }
    long max_path=0;
    for(size_t j=0;j<W; j++)
    {
        long count = 0;
        for(size_t i=H-1;i>=0; i--)
        {
            if(mat[i][j] == "#") count = 0;
            else count++;
            mat_count[i][j] += count;
            max_path = max(max_path, -3+mat_count[i][j]);
            if(i==0) break;
        }
    }

    cout << max_path << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 250496
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll N, K;
	cin >> N >> K;
	vector<ll> a(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> a[i];
	}

	vector<ll> sum;
	sum.push_back(0);
	for (auto i = 0; i < N; ++i)
	{
		sum.push_back(a[i] + sum[i]);
	}

	vector<ll> b;
	for (auto l = 0; l < N; ++l)
	{
		for (auto r = l; r < N; ++r)
		{
			b.push_back(sum[r + 1] - sum[l]);
		}
	}
	sort(b.begin(), b.end());

	auto ans = 0ll;
	auto start = b.begin();
	for (auto i = 41; i >= 0; --i)
	{
		auto bit = 1ll << i;
		auto iter = lower_bound(start, b.end(), bit);
		auto num = (ll)(b.end() - iter);
		if (num >= K)
		{
			ans |= bit;
			start = iter;
		}
		else if (num <= 0)
		{
			continue;
		}
		
		for (auto it = iter; it != b.end(); ++it)
		{
			*it = *it & ~bit;
		}
		sort(start, b.end());
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6524
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define HUGE_NUM 9999999999999999

int N;
ll W[4001],dp[4000][4000];
int loc[4000][4000];

int main(){

	scanf("%d",&N);
	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++)dp[i][k] = HUGE_NUM;
	}

	W[0] = 0;
	for(int i = 1; i <= N; i++){
		scanf("%lld",&W[i]);
		W[i] += W[i-1];
	}

	for(int i = 0; i < N; i++){
		dp[i][i] = 0;
		loc[i][i] = i;
	}

	int right;
	ll tmp;
	for(int length = 2; length <= N; length++){
		for(int left = 0; left+length-1 <= N-1; left++){
			right = left+length-1;
			for(int mid = loc[left][right-1]; mid <= loc[left+1][right]; mid++){
				tmp = dp[left][mid]+dp[mid+1][right]+W[right+1]-W[left];
				if(tmp < dp[left][right]){
					dp[left][right] = tmp;
					loc[left][right] = mid;
				}
			}
		}
	}

	printf("%lld\n",dp[0][N-1]);
}

Measured memory_bytes: 173260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    string s; cin >> s;
    
    if(s.back() == 's'){
        print(s + "es")
    }else{
        print(s + "s")
    }
    
    return 0;
}

Measured memory_bytes: 3604
N, M = list(map(int, input().split()))
E = [[False]*N for _ in range(N)]
for m in range(M):
    a, b = list(map(int, input().split()))
    E[a-1][b-1] = E[b-1][a-1] = True

P = []
V = [False]*N
V[0] = True
p = [0] + [None]*(N-1)
def dfs(i):
    if i==N:
        P.append(p[:])
        return
        
    for v, visited in enumerate(V):
        if not visited:
            p[i] = v
            V[v] = True
            dfs(i+1)
            V[v] = False

dfs(1)

ans = 0
for p in P:
    ok = True
    for i in range(N-1):
        if not E[p[i]][p[i+1]]:
            ok = False
            break
    if ok: ans+=1
print(ans)

Measured memory_bytes: 3700
#include <algorithm>
#include <iostream>
#include <queue>
#include <utility>

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

ll n, d, a, ans;
P xh[220000];
queue<P> q;

int main() {
  cin >> n >> d >> a;
  
  for (ll i = 0; i < n; i++) {
    cin >> xh[i].first >> xh[i].second;
    xh[i].second = (xh[i].second+a-1)/a;
  }
  
  sort(xh, xh+n);
  
  ll sum = 0;
  for (ll i = 0; i < n; i++) {
    while (q.size() and q.front().first < xh[i].first) {
      sum -= q.front().second;
      q.pop();
    }
    ll num = max(0LL, xh[i].second - sum);
    ans += num;
    sum += num;
    q.push(P(xh[i].first + 2*d, num));
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6656
main = do
 a <- getLine
 let h = g.f. (read::String->Double) $ a
 --print h
 if(h /= -1) then print h else putStr ":("

f :: Double -> [Int]
f x = [if((x==).fromIntegral.floor.(1.08*).fromIntegral.ceiling $ moto) then 
	   ceiling moto else -1 ,
       if((x==).fromIntegral.floor.(1.08*).fromIntegral.floor $   moto) then 
       floor moto else -1] 
  where 
    moto = x /1.08
    
g :: [Int] -> Int
g (-1: (-1) :xs)= -1 
g (-1:a:xs) =  a
g (a:_) =  a
g _ = -3

Measured memory_bytes: 508
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 998244353, N = 1e5 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int h1, m1, h2, m2, k;

main () {
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int l = h1*60 + m1 + 1, r = h2 * 60 + m2;
	cout << (r - l + 1) - k << endl;

}





Measured memory_bytes: 3636
r="#"
s='.'
loop{
	h,w=gets.split(" ").map(&:to_i)
	break if h==0 and w==0
	h.times{|i|
		w.times{|j|
			if (i+j)%2==0
				print("#{r}")
			else
				print("#{s}")
			end
		}
		puts""
	}
	puts ""
}

Measured memory_bytes: 6104
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
  int N;
  cin >> N;
  LL A[N],t[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    t[i]=A[i];
  }
  sort(t,t+N);
  map<LL,int> ma;
  for(int i=0;i<N;i++) ma[t[i]]=i;
  int ans=0;
  for(int i=0;i<N;i++) if(i%2!=ma[A[i]]%2) ans++;
  cout << ans/2 << endl;
  return 0;
}


Measured memory_bytes: 8064
// 2013/07/07 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	while(true){
		int N;
		cin >> N;

		if(N==0)
			break;

		if(N%1111==0){
			cout << "NA" << endl;
			continue;
		}

		int cnt = 0;

		while(true){
			if(N==6174){
				cout << cnt << endl;
				break;
			}

			int n[4];
			n[0] = N/1000;
			n[1] = N/100%10;
			n[2] = N/10%10;
			n[3] = N%10;

			sort(n, n+4);

			int L = n[3]*1000+n[2]*100+n[1]*10+n[0];
			int S = n[0]*1000+n[1]*100+n[2]*10+n[3];

			N = L-S;
			cnt++;
		}
	}

	return 0;
}

Measured memory_bytes: 1180
(let* ((n (read))
       (m (read))
       (s (read))
       (arr (make-array (1+ n) :initial-element 0 :element-type 'fixnum)))
  (loop :repeat s :do(incf (aref arr (read))))
  (loop :for k :from 1 :upto n :do(format t "~A~%" (if (< 0 (+ m (* -1 s) (aref  arr k))) "Yes" "No"))))

Measured memory_bytes: 58088
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    long[] T = sc.nextLongList(N);
    
    long lcm = T[0];
    for (long v : T) {
      long gcd = gcd(lcm, v);
      
      lcm *= v / gcd;
    }
    
    System.out.println(lcm);
  }
  
  public static long gcd(long a, long b) {
    if (a > b) {
        long tmp = a;
        a = b;
        b = tmp;
    }
    while (a != 0) {
        long c = a;
        a = b % c;
        b = c;
    }
    return b;
}

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 23252
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	tmp, _ := reader.ReadString('\n')
	tmp = strings.Trim(tmp, "\n")

	a, _ := strconv.ParseInt(tmp, 10, 64)

	fmt.Println(3 * a * a)
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define INF 100000000
typedef long long ll;

using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;
    int c = stoi(a + b);
    bool flag = false;
    REP(i, 505) {
        if (i*i == c) {
            flag = true;
            break;
        }
    }
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int i,j;
#define fi(o,n) for(i=o;i<n;i++)
#define fj(o,n) for(i=o;j<n;j++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define double long double
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define WW 100000
#define INF 1000000000000000000 //1e18
#define EPS 0.000000001 //1e-9
//for(auto &x: a) cout<<x; to traverse along array if size is KNOWN.
//max({_,......,_}) can give maximum of any number of elements. Similarly min also.
//reverse(all(v)) would reverse a vector
//count_if(lower_bound, upper_bound, function)
int32_t main()
{   IOS
    int t,a=0;cin>>t;
    fi(1,t+1)
    {
        if(i%3==0||i%5==0) continue;
        else a+=i;

    }
    cout<<a;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define N 200005
using namespace std;
typedef pair<int,int> P;

int h, w, n;

int L[N*2], R[N*2];

void init(){
  
  int x=w-1, f=1;
  
  for(int i=0;i<N*2;i++){
    
    L[i]=x;

    R[i]=w-x-1;
    
    if(!f){
      x++;
      if(x==w){
	f=1;
	x=w-1;
      }
    }else{
      x--;
      if(x==-1){
	f=0;
	x=0;
      }
    }
    
  }
  
}

P ab[N];

int ans[N];

int main(){

  cin>>h>>w>>n;
  
  init();

  int lr;
  
  if(h%2) lr=1; // r
  else lr=0; // l
  
  int step=h%(w*2);
  
  for(int i=0;i<w;i++){
    if(!lr) ans[L[w-i-1+step]]=i;
    else ans[R[i+step]]=i;
    lr=!lr;
  }
  
  for(int i=0;i<n;i++)
    scanf("%d %d", &ab[i].first, &ab[i].second);
  
  sort(ab,ab+n,greater<P>());
  
  int a, b;
  
  for(int i=0;i<n;i++){
    
    a=ab[i].first;
    b=ab[i].second;
    
    int step=a%(w*2);
    
    b--;
    
    swap(ans[R[b+step]],ans[L[w-(b+1)-1+step]]);
    
  }
  
  for(int i=0;i<w;i++) printf("%d\n",ans[i]+1);
  
  return 0;
}

Measured memory_bytes: 8592
#include <stdio.h>

int main(void)
{
  int x,y;

 while(1){
  scanf("%d %d", &x,&y);
  if ( x == 0 && y == 0)
   break;
  if(x<y){
  printf("%d %d\n",x,y);
} else {
  printf("%d %d\n",y,x);
}
}
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
string s;
int dp[305][305][305];
int solve(int l,int r,int k)
{
	if (k<0)
	return -1e9;
	if (r-l<1)
	return r-l+1;
	if (dp[l][r][k]!=-1)
	return dp[l][r][k];
	return dp[l][r][k]=max(max(solve(l+1,r,k),solve(l,r-1,k)),2+solve(l+1,r-1,k-(s[l]!=s[r])));
}
int main()
{
	int k;
	cin >> s >> k;
	memset(dp,-1,sizeof(dp));
	cout << solve(0,s.size()-1,k);
}

Measured memory_bytes: 111232
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  vi v(n), d(n);
  rep(i, n) cin >> v[i];
  int i = 0, c = 0;
  while (i != 1) {
    c++;
    if (d[i]) {
      cout << -1 << endl;
      return;
    }
    d[i] = true;
    i    = v[i] - 1;
  }
  cout << c << endl;
}


Measured memory_bytes: 1792
// Problem : D - Knapsack 1
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

#define ff first
#define fs second
#define lb lower_bound
#define ub upper_bound

#define int long long
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector< vi >
#define vpii vector< pii >
#define vb vector<bool>
#define si set<int>
#define mii map<int, int>
#define mci map<char, int>
#define md 1000000007
#define pb push_back
#define eb emplace_back
#define fio ios_base::sync_with_stdio (false); cin.tie (NULL);  cout.tie (NULL);
#define qw1(x) cerr<<#x<<": "<<x<<" "<<endl
#define qw2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define qw3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define qw4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl


#define f(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define rl(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define all(x) x.begin(),x.end()
#define endl '\n'
void printv(vector<int>  v){ for(int i=0;i<v.size();i++) cout<<v[i]<<' '; cout<<endl;   }
int bem(int m , int n, int mod) { int res=1; while(n){
	     			        if(n%2!=0) { res*=m; res%=mod; }
	    			        m*=m;   m%=mod;   n/=2;
			                          }
				return res;	}
int be(int a, int b) { int res=1; 	while(b){
				if(b%2!=0) res*=a;
				a*=a; b/=2;
				}
			return res;	}
void sieve(int n, vb &prime){
    prime[0]=false;     prime[1]=false;
    for(int i=2;i*i<=n;i++){
         if(prime[i]==true){
              for(int j=i*i;j<=n;j+=i)    prime[j]=false;
             	  }
    	 }
	}

/*void solve()
  {
int n, wt; cin>>n>>wt;
vi v(n), w(n);
f(i, 0, n-1) cin>>w[i]>>v[i];
vector< vector< int> > dp(n, vi (wt+1, 0));
printv(v); printv(w);
for( int i=0; i<n; i++){
  for(int j=1; j<=wt; j++)
  {
  	if(j-w[i]>=0)
  	  dp[i][j]=max(dp[i][j], dp[i][j-w[i]]+v[i]);
  	else dp[i][j]=0;
  }
  cout<<i<<' ';printv(dp[i]);
  }
  cout<<*max_element(dp[n-1].begin(), dp[n-1].end())<<endl;
  }*/
 vi v,w;
 vvi dp;
 int fun(int wt, int n)
 {
 	if(n<0) return 0;
 	if(dp[wt][n]!=-1) return dp[wt][n];
 	if(wt==0) return dp[wt][n]=0; 
 	if(wt<w[n]) return dp[wt][n]=fun(wt, n-1);
 	else
 	return dp[wt][n]=max(fun(wt, n-1), fun(wt-w[n], n-1)+v[n]);
 	
 }
 void solve()
 {
 	int n, wt; cin>>n>>wt;
 	v.resize(n); w.resize(n);
 	f(i, 0, n-1) cin>>w[i]>>v[i];
 	dp.resize(wt+1, vi(n, -1));
 	cout<<fun(wt, n-1)<<endl;
 } 
  

int32_t main ()
{
//fio
int t=1; 
//cin>>t; 
while(t--){
	solve();
}
 
}








Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
vector<int> adj[100000];
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
int main(){
    ll n,ans=0;
  string s;
  cin>>n>>s;
  int r[n+1],g[n+1],b[n+1];
  r[0]=0;
  g[0]=0;
  b[0]=0;
  for(int i=0;i<n;i++){
    r[i+1]=r[i];g[i+1]=g[i];b[i+1]=b[i];
    if(s[i]=='R') r[i+1]++;
    else if(s[i]=='G') g[i+1]++;
    else if(s[i]=='B') b[i+1]++;
  }
  for(int i=1;i+2<=n;i++){
    for(int j=i+2;j<=n;j++){
      if(s[i-1]==s[j-1]) continue;
      
        if(s[i-1]=='R' && s[j-1]=='G') ans+=b[j-1]-b[i-1];
        else if(s[i-1]=='G' && s[j-1]=='R') ans+=b[j-1]-b[i-1];
      
        else if(s[i-1]=='R' && s[j-1]=='B') ans+=g[j-1]-g[i-1];
        else if(s[i-1]=='B' && s[j-1]=='R') ans+=g[j-1]-g[i-1];
       
        else if(s[i-1]=='B' && s[j-1]=='G') ans+=r[j-1]-r[i-1];
        else if(s[i-1]=='G' && s[j-1]=='B') ans+=r[j-1]-r[i-1];
      if((j-i)%2==0 && (s[(j+i)/2-1]!=s[i-1] && s[(j+i)/2-1]!=s[j-1])) ans--;
    }
  }
 
  cout<<ans;
}


Measured memory_bytes: 6040
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;
vector<pair<ll,int>> fs;
int trydivi(ll n){
  
  for(ll i=2;i*i<=n;i++){
    int x=0;
    while(n%i==0){
      n/=i;
      x++;
    }
    fs.emplace_back(i,x);
  }
  if(n!=1)fs.emplace_back(n,1);
  return 0;
}

int main(void){
    ll n;
    cin>>n;
    trydivi(n);
    int ans = 0;
    for(int i=0;i<fs.size();i++){
        int x=fs[i].second;
        int b=1;
        while(1){
            if(b>x)break;
            x-=b;
            b++;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 19744