akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, k, ta, mu;

signed main() {
	cin >> n >> k;
	ta += (n / k)*(n / k)*(n / k);
	if (k % 2 == 0) {
		if (n%k >= k / 2) {
			mu = n / k + 1;
		}
		else mu = n / k;
		ta += mu * mu*mu;
	}
	cout << ta << endl;
	ggr
}

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

using namespace std;

int main(){
	
	int N, T, S;
	
	cin >> N >> T >> S;
	
	int ans[4000];
	
	for(int i = 0; i < 4000; i++){
		ans[i] = 0;
	}
	
	for(int i = 0; i < N; i++){
		int a, b;
		cin >> b >> a;
		for(int j = T - a; j >= 0; j--){
			if(j >= S || a + j <= S){
				ans[a + j] = max(ans[a + j], ans[j] + b);
			}
		}
	}
	
	int ans_max = 0;
	
	for(int j = 0; j <= T; j++){
		if(ans_max < ans[j]){
			ans_max = ans[j];
		}
	}
	
	cout << ans_max << endl;
	
	return 0;
}

Measured memory_bytes: 3144
from collections import deque
N,W=map(int,input().split())
w1,v1=map(int,input().split())
V=[[v1],[],[],[]]
for i in range(N-1):
    w,v=map(int,input().split())
    V[w-w1].append(v)
for i in range(4):
    V[i].sort(reverse=True)
W0=W
V0=0
ans=0
for a in range(-1,len(V[0])):
    if a!=-1:
        W0-=w1
        if W0<0:
            break
        V0+=V[0][a]
    W1=W0
    V1=V0
    ans=max(ans,V0)
    for b in range(-1,len(V[1])):
        if b!=-1:
            W1-=w1+1
            if W1<0:
                break
            V1+=V[1][b]
        W2=W1
        V2=V1
        ans=max(ans,V1)
        for c in range(-1,len(V[2])):
            if c!=-1:
                W2-=w1+2
                if W2<0:
                    break
                V2+=V[2][c]
            ans=max(ans,V2)
            if W2//(w1+3)>0:
                ans=max(ans,V2+sum(V[3][0:(W2//(w1+3))]))
print(ans)

Measured memory_bytes: 3316
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);

// defines...
#define MP make_pair
#define PB push_back
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

int gcd(int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return ((ll)a*b/(ll)gcd(a, b));
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


void task()
{
    //code here...
    
    int t, ac=0, wa=0, tle=0, re=0;
	string s;
    
    cin >> t;
    while(t--){
		cin >> s;
		
		if(s=="AC") ac++;
		else if(s=="WA") wa++;
		else if(s=="TLE") tle++;
		else if(s=="RE") re++;
	}
	
	cout << "AC x " << ac << "\n";
	cout << "WA x " << wa << "\n";
	cout << "TLE x " << tle << "\n";
	cout << "RE x " << re << "\n";
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    task();

    return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, x, a, b, c, ans, m, ct, aa, bb, cc;
	cin >> n >> k;
	vector<vector<long long>> v(3); 
	for (i = 0; i < n; i++) {
		cin >> x;
		if (x >= 0) v[0].push_back(x);
		else v[1].push_back(x);
	}
	if (!v[0].empty()) sort(v[0].begin(), v[0].end());
	if (!v[1].empty()) sort(v[1].rbegin(), v[1].rend());
	v[2] = v[1];
	for (i = 0; i < v[1].size(); i++) v[1][i] = -v[1][i];
	sort(v[1].begin(), v[1].end());

	a = -(1LL << 60); b = 1LL << 60;
	
	while (a < b) {
		if (b - a == 1) c = a;
		else c = (a + b) / 2;

		ct = 0;
		for (i = 0; i < 2; i++) {
			if (v[i].empty()) continue;
			// same sign
			for (j = 0; j < v[i].size() - 1; j++) {
				if (v[i][j] * v[i][j + 1] > c) continue;
				aa = j + 1; bb = v[i].size() - 1;
				while (aa < bb) {
					cc = (aa + bb + 1) / 2;
					if (v[i][j] * v[i][cc] > c) bb = cc - 1;
					else aa = cc;
				}
				ct += aa - j;
			}
					   
			// different sign
			if (i == 1) continue;		// avoid duplication

			m = v[2].size();
			if (m == 0) continue;

			for (j = 0; j < v[i].size(); j++) {
				if (v[i][j] * v[2][m - 1] > c) continue;
				aa = 0; bb = m - 1;
				while (aa < bb) {
					cc = (aa + bb) / 2;
					if (v[i][j] * v[2][cc] > c) aa = cc + 1;
					else bb = cc;
				}
				ct += m - aa;
			}
		}

		if (ct < k) a = c + 1;
		else b = c;
	}

	cout << a << "\n";

	return 0;
}


Measured memory_bytes: 3440
#include <iostream>
#include <cmath>

using namespace std;

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

    int a, b;
    cin >> a >> b;

    double c = 1.0 * stoi(to_string(a) + to_string(b));
    c = sqrt(c);

    if (c - (int) c == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = ((int64_t)2e18);
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

vector<int> arr;
vector<int> adj[MAXN];
vector<vector<int>> lis;
vector<int> ans;

void dfs(int u, int p) {

  int l = 0, r = (int)lis.size() - 1;
  int ansj = -1;
  while (l <= r) {
    int mid = (l + r) / 2;
    // OBS: PARA >= TROCAR SINAL EMBAIXO POR <=
    
    if (arr[u] <= lis[mid].back()) {
      r = mid - 1;
      ansj = mid;
    } else
      l = mid + 1;
  }
  if (ansj == -1) {
    ansj = lis.size();
    lis.push_back(vector<int>(1, arr[u]));
  } else {
    lis[ansj].push_back(arr[u]);
  }


  ans[u] = lis.size();

  for (int v : adj[u]) {
    if (v == p)
      continue;
    dfs(v, u);
  }

  lis[ansj].pop_back();
  if (lis[ansj].empty()) {
    lis.pop_back();
  }
}

signed main() {

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

  int n;
  cin >> n;

  arr.resize(n);
  ans.resize(n);

  for (int &x : arr)
    cin >> x;

  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;

    --u, --v;

    adj[u].eb(v);
    adj[v].eb(u);
  }

  dfs(0, -1);

  for (int x : ans)
    cout << x << endl;
}


Measured memory_bytes: 39544
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm> 
#include<map>
#include<queue>
using namespace std;
int main()
{
	char a[5];
	scanf("%s",&a);
	int n;
	n=strlen(a);
   if(n==2)
   	   {
   	   	   printf("%s\n",a);
	   }
	   if(n==3)
	   {
	   	   for(int i=2;i>=0;i--)
		   { 
	       printf("%c",a[i]);
		   }
	   }
	   return 0;
}

Measured memory_bytes: 760
#include<iostream>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  stack<int> S;
  int a, b;
  string s;

  while(cin >> s){
    if(s[0] == '+'){
      a=S.top(), S.pop();
      b=S.top(), S.pop();
      S.push(a+b);
    }else if(s[0] == '-'){
      b=S.top(), S.pop();
      a=S.top(), S.pop();
      S.push(a-b);
    }else if(s[0] == '*'){
      a=S.top(), S.pop();
      b=S.top(), S.pop();
      S.push(a*b);
    }else{
      S.push(atoi(s.c_str()));
    }
  }

  cout << S.top() << endl;
  return 0;
}


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

struct card{ // represents each cards
  unsigned num;
  char suit;
  bool operator>(card &v){
    return (num > v.num);
  }
};

std::ostream& operator<<(std::ostream &os, card &v){
  os << v.suit << v.num;
  return os;
}
std::istream& operator>>(std::istream &is, card &v){
  is >> v.suit >> v.num;
  return is;
}

typedef std::vector<card> bunch; // represents bunch of cards

std::istream& operator>>(std::istream &is, bunch &v){
  card buf;
  is >> buf;
  v.push_back(buf);
  return is;
}

std::ostream& operator<<(std::ostream &os, bunch &v){
  for(unsigned i=0;i<(v.size()-1);i++){
    os << v[i] << ' ';
  }
  os << v[v.size()-1];
  return os;
}

void bubble_sort(bunch &b){
  const unsigned n = b.size();
  for(unsigned i = 0; i < n; i++){
    for(unsigned j = n-1; j > i; j--){
      if(b[j-1] > b[j]){
        std::swap(b[j-1],b[j]);
      }
    }
  }
}

void selection_sort(bunch &b){
  const unsigned n = b.size();
  for(unsigned i = 0; i < n; i++){
    unsigned min = i;
    for(unsigned j = i; j < n; j++){
      if(b[min] > b[j]){
        min = j;
      }
    }
    std::swap(b[min],b[i]);
  }
}

class pair_table{
  struct same_nums{
    unsigned num;
    std::string suits;
    bool operator==(same_nums &v){
      return (num==v.num)&&(suits==v.suits);
    }
  };
  std::vector<same_nums> pairs;
  void make_pair(bunch &b){
    bool has_same_number = false;
    struct same_nums buf;
    const unsigned target = b[0].num;
    auto is_same_num = [target](card &c){
      return target == c.num;
    };
    buf.num = target;
    buf.suits = b[0].suit;
    b.erase(b.begin());

    auto it = b.begin();
    while(
      ( it = std::find_if(b.begin(),b.end(),is_same_num) ) != b.end()
    ){
      buf.suits += it->suit;
      b.erase(it);
      has_same_number = true;
    }
    if(has_same_number){pairs.push_back(buf);}
    if(!b.empty()){
      make_pair(b);
    }
    else{
      std::sort(pairs.begin(),pairs.end(),
                [](const same_nums &c1,const same_nums &c2){return c1.num < c2.num;}
      );
    }
  }
public:
  pair_table(bunch b){
    make_pair(b);
  }
  bool operator==(pair_table &&v){
    return std::equal(pairs.begin(),pairs.end(),v.pairs.begin());
  }
};

int main(){
  bunch org;
  unsigned n;
  std::cin >> n;
  for(;n;n--){
    std::cin >> org;
  }

  pair_table a(org);
  pair_table b(org);

  bunch bub = org;
  bunch sel = org;

  bubble_sort(bub);
  std::cout << bub << '\n';
  std::cout << (pair_table(org)==pair_table(bub)?"Stable":"Not stable") << std::endl;

  selection_sort(sel);
  std::cout << sel << '\n';
  std::cout << (pair_table(org)==pair_table(sel)?"Stable":"Not stable") << std::endl;

}

Measured memory_bytes: 1244
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//solve

//FUNCTION
//solve

void solve(void)
{
  int X,A,B;
  cin>>X>>A>>B;
  X -= A;
  X %= B;
  cout<<X<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define fr(i,a,b) for(int (i)=(int) a;(i)<=(int)(b);++(i))
#define li list<int>
#define ll long long
#define mp make_pair
#define mod 1000000007
#define pb push_back
#define pi pair<int ,int >
#define pr printf
#define vi vector<ll>
#define vpi vector< pi > 
int a[222][222],b[20];
int dp[20][(1<<10)+10];
int main()
{
	int n,m,r,i,j,k;
	cin>>n>>m>>r;
	int x,y,z;
	for(i=0;i<=10;i++)
	{
		for(j=0;j<=(1<<10);j++)
			dp[i][j]=mod;
	}
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n;j++)
			a[i][j]=mod;
	}
	for(i=0;i<r;i++)
	{
		cin>>x;
		b[i]=x;
		dp[i][(1<<i)]=0;
	}
	for(i=1;i<=m;i++)
	{
		cin>>x>>y>>z;
		a[x][y]=z;
		a[y][x]=z;
	}
	for(k=1;k<=n;k++)
	{
		for(i=1;i<=n;i++)
		{
			if(i==k) continue;
			for(j=1;j<=n;j++)
			{
				if(j==k||i==j) continue;
				a[i][j]=min(a[i][j],a[i][k]+a[k][j]);

			}
		}
	}
	for(int mask=3;mask<(1<<r);mask++)
	{
		for(i=0;i<r;i++)
		{
			if(!(mask&(1<<i)))
				continue;
			for(j=0;j<r;j++)
			{
				if((!(mask&(1<<j)))||i==j)
					continue;
			dp[i][mask]=min(dp[i][mask],a[b[j]][b[i]]+dp[j][mask^(1<<i)]);
			}
		}
	}
	int res=mod;
	for(i=0;i<r;i++)
	{
		res=min(res,dp[i][(1<<r)-1]);
		//cout<<dp[i][(1<<r)-1]<<" ";
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 512
import java.io.IOException;
import java.util.Scanner;

public class Main{

    public static void main(String[] args) throws IOException, StackOverflowError{
        Scanner scanner = new Scanner(System.in);
        while(true){
        	//first line
            int r = scanner.nextInt(); // 0 <= r <= 10
            int c = scanner.nextInt(); //0 <= c <= 10000
            //separater
            if(r == 0 && c == 0){
                break;
            }
            int[] a = new int[c];
            for(int i = 0; i < r; ++i){
                for(int j = 0; j < c; ++j){
                    //In this case I considered 01 as binary digit
                    a[j] = a[j] * 2 + scanner.nextInt();
                }
            }
            //Total number of upside down is 2 to r
            int bitRow = 1 << r; // max 2^10 -> 1024
            int answer = 0;
            //Upside down row is equal to 1 in binary digit
            for(int i = 0; i < bitRow; ++i){
                int thisAnswer = 0;
                //for each column
                //Total number of columns is at most 10000
                for(int j = 0; j < c; ++j){
                    //i and column XOR computes the number of heads Senbei
                    int currentBit = Integer.bitCount(a[j] ^ i);
                    //r - currentBit means the number of tail Senbei We need larger one
                    thisAnswer += Math.max(currentBit, r - currentBit);
                }
                answer = Math.max(answer, thisAnswer);
            }
            System.out.println(answer);
        }
    }
}

Measured memory_bytes: 75532
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(int, a, N);
  int next = 1;
  int i = 0;
  while (i < N) {
    i++;
    next = a[next - 1];
    if (next == 2) {
      print(i);
      return;
    }
  }
  print(-1);
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> a( H * W );
    REP( i, H )
    {
        cin >> a[ i ];
    }
    vector<int> ri( H ), cj( W );
    REP( i, H )
    {
        REP( j, W )
        {
            if( a[ i ][ j ] == '#' )
            {
                ri[ i ]++;
                cj[ j ]++;
            }
        }
    }
    REP( i, H )
    {
        REP( j, W )
        {
            if( ri[ i ] > 0 && cj[ j ] > 0 )
            {
                cout << a[ i ][ j ];
            }
        }
        if( ri[ i ] != 0 ) cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.InputMismatchException;
import java.io.IOException;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int s = in.nextInt();
            Set<Integer> set = new HashSet<>();
            set.add(s);
            int m = 1;
            while (true) {
                m++;
                s = (s & 1) == 1 ? (s * 3) + 1 : (s >> 1);
                if (set.contains(s)) {
                    out.println(m);
                    return;
                }
                set.add(s);
            }
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



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

using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define mp make_pair
#define show(a) for(auto el:a)cout<<el<<" "
#define ff first
#define ss second
#define pairv vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define fam(v,i) for(auto i=v.begin();i!=v.end();i++)
#define fai(v,i) for(auto i : v)
#define mo 1000000007

#define nn cout<<"\n";
ll pow1(ll n,ll p)
{
if(p==0) return 1;
ll x=pow1(n, p/2);
x=(x*x)%mo;
if(p%2==0)
return x;
else
return (x*n)%mo;
}
bool sortbysec(const pair<ll,ll> &a, 
const pair<ll,ll> &b) 
{ 
return (a.second < b.second); 
} 
bool compare(const pair<ll, ll>&p1, const pair<ll,ll>&p2)
{
if(p1.ff < p2.ff) return true;
if(p1.ff == p2.ff) return p1.ff < p2.ss;
return false;
}
 
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
ll findlcm(ll arr[], ll n) 
{ 
    ll ans = arr[0]; 
   ll ma=1e+18;
    for (ll i = 1; i < n; i++) 
      {  ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
                if(ans>ma)
                {
                    ans=-1;
                    break;
                }
      }
  
    return ans; 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  
     ll n;
     cin>>n;
     ll a=n/3;
     cout<<a;
   
    
     return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>

int main(){
	int i=0,lt[4]={0},rt[4]={0};
	double left[41],right[41];
	while(scanf("%lf",&left[i])!=EOF){
		scanf("%lf",&right[i]);
		if(left[i]>=1.1) lt[0]++;
		else if(left[i]>=0.6) lt[1]++;
		else if(left[i]>=0.2) lt[2]++;
		else lt[3]++;
		if(right[i]>=1.1) rt[0]++;
		else if(right[i]>=0.6) rt[1]++;
		else if(right[i]>=0.2) rt[2]++;
		else rt[3]++;
		i++;
	}
	for(i=0;i<4;i++){
		printf("%d %d\n",lt[i],rt[i]);
	}
	return 0;
}

Measured memory_bytes: 0
n,t = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
a.sort()
DP = [[0 for i in range(t+3001)] for j in range(n+1)]
for i in range(1,n+1):
  for j in range(1,t+3001):
    if j-a[i-1][0] >= 0:
      DP[i][j] = max(DP[i-1][j],DP[i-1][j-a[i-1][0]]+a[i-1][1])
    else:
      DP[i][j] = DP[i-1][j]
ans = 0
for i in range(n):
  ans = max(ans,DP[i][t-1]+a[i][1])
print(ans)

Measured memory_bytes: 180356
#include <stdio.h>

int main(void)
{
  int y, m, d;
  char a,b;
  scanf("%d%c%d%c%d", &y, &a, &m, &b, &d);
  if (m <= 4){
    printf("Heisei\n");
  }
  else{
    printf("TBD\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ld long double
#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define reunique(x) (x).resize(std::unique(all(x)) - (x).begin())
#define roflan ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;
const int mod = (int)1e9 + 7;

void ad(int &a, int b){
  a += b;
  if (a >= mod) a -= mod;
}
void su(int &a, int b){
  a -= b;
  if (a < 0) a += mod;
}
signed main(){
  roflan;
  int n, k;
  cin >> n >> k;
  vector <int> dp(k + 1);
  vector <int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  dp[0] = 1;
  for (int i = 0; i < n; i++){
    vector <int> pref(k + 1);
    for (int used = k; used >= 0; used--){
      int L = used + 1;
      int R = used + min(k - used, a[i]);
      if (L <= R){
        ad(pref[L], dp[used]);
        if (R + 1 <= k)
          su(pref[R + 1], dp[used]);        
      }
    }
    int sum = 0;
    for (int i = 0; i <= k; i++){
      ad(sum, pref[i]);
      ad(dp[i], sum);
    }
  }
  cout << dp[k];
  return 14 / 88;
}

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

bool check(int c,vector<int> v){
	string s = to_string(c);
	for(int unsigned i=0;i<s.size();i++){
		if(find(v.begin(),v.end(),s[i] - '0') != v.end()){
			return false;
		}
	}
	return true;
}

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> v(k);
	for(int i=0;i<k;i++){
		cin >> v[i];
	}
	while(!check(n,v)){
		n++;
	}
	cout << n << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

const long long MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int D, G;
  cin >> D >> G;
  vector<int> p(D), c(D);
  for (int i = 0; i < D; ++i) cin >> p[i] >> c[i];
  int solved = INF;
  for (int i = 0; i < (1 << D); ++i) {
    int x = 0;
    int s = 0;
    vector<bool> complete(D, false);
    for (int j = D - 1; j >= 0; --j) {
      if ((i >> j) & 1 == 1) {
        x += p[j] * 100 * (j + 1) + c[j];
        s += p[j];
        complete[j] = true;
      }
    }
    for (int j = D - 1; j >= 0; --j) {
      if (complete[j]) continue;
      else {
        if (x + (p[j] - 1) * 100 * (j + 1) >= G) {
          s += (max(G - x + 100 * (j + 1) - 1, 0)) / (100 * (j + 1));
        }
        else {
          s = INF;
        }
        break;
      }
    }
    solved = min(solved, s);
  }
  cout << solved << endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()
te,tw = [],[]
te.append(1 if S[0]=='E' else 0)
tw.append(1 if S[0]=='W' else 0)
for i in range(1,N):
    if S[i]=='E':
        te.append(te[i-1]+1)
    else:
        te.append(te[i-1])
    if S[i]=='W':
        tw.append(tw[i-1]+1)
    else:
        tw.append(tw[i-1])
ans = min(te[-1],tw[-1])
for i in range(1,N-1):
    ans = min(ans,tw[i-1]+te[N-1]-te[i])
print(ans)


Measured memory_bytes: 85340
import java.io.*;
import java.util.*;
 
public class Main{
	
	
	public void solve(){
		String str = next();
		Map<String, String> map = new HashMap<>();
		map.put("A", "T");
		map.put("C", "G");
		map.put("G", "C");
		map.put("T", "A");
		
		out.println(map.get(str));
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 20820
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int a[100005],b[100005],c[100005];
int main()
{
    ll sum=0;
    int n,q;

    cin>>n;
    map<int ,int>ans;
    for(int i=0;i<n;i++)
        {cin>>a[i];ans[a[i]]++;sum+=a[i];}
    cin>>q;
    for(int i=0;i<q;i++)
    {
        cin>>b[i]>>c[i];
        if(ans[b[i]]>0)
            {
                ans[c[i]]+=ans[b[i]];
                sum+=ans[b[i]]*(c[i]-b[i]);
                ans[b[i]]=0;
            }
            printf("%lld\n",sum);
    }



    return 0;
}


Measured memory_bytes: 9164
N = int(input())
A = sorted(map(int,input().split(" ")))
B = sorted(map(int,input().split(" ")))
C = sorted(map(int,input().split(" ")))

o = []
p = []

i = 0
k = 0
for j in range(N):
    while i < N and A[i] < B[j]:
        i = i + 1
    o.append(i)

    while k < N and B[j] >= C[k]:
        k = k + 1
    p.append(N-k)

sum = 0
for x in range(N):
    sum = sum + o[x] * p[x]

print(sum)

Measured memory_bytes: 24372
#include <iostream>

using namespace std;

int f(int n)
{
  if (n % 2 == 0)
    return n / 2;
  else
    return 3 * n + 1;
}

int main()
{
  int s;

  cin >> s;

  int a[1000001];
  a[0] = s;
  a[1] = f(a[0]);
  int m = 2;
  while (true) {
    for (int i = 0; i < m - 1; i++) {
      if (a[m - 1] == a[i]) {
        cout << m << endl;
        return 0;
      }
    }
    m += 1;
    a[m - 1] = f(a[m - 2]);
  }

  return 0;
}

Measured memory_bytes: 256
import numpy as np


def main():
    bingo_card = np.array([list(map(int, input().split())) for _ in range(3)])
    counter = int(input())

    for _ in range(counter):
        bingo_card = np.where(bingo_card == int(input()), 0, bingo_card)

    vertical_bingo = min(np.sum(bingo_card, axis=0)) == 0
    horizontal_bingo = min(np.sum(bingo_card, axis=1)) == 0

    diag_normal_bingo = bingo_card[0][0] == 0 and bingo_card[1][1] == 0 and bingo_card[2][2] == 0
    diag_reverse_bingo = bingo_card[0][2] == 0 and bingo_card[1][1] == 0 and bingo_card[2][0] == 0

    if vertical_bingo or horizontal_bingo or diag_normal_bingo or diag_reverse_bingo:
        print('Yes')
        exit()
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 12444
#include <stdio.h>

int main(void) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if(a == b) printf("%d\n", c);
    else if(b == c) printf("%d\n", a);
    else if(a == c) printf("%d\n", b);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;
int main(){
	char a;
	int alpha[26];
	for(int i=0; i<26; i++){
		alpha[i]=0;
	}
	while(cin >> a){
		a=tolower(a);
		if(isalpha(a)){
			alpha[a-'a']++;
		}
	}
	for(int i=0; i<26; i++){
		printf("%c : %d\n",i+'a',alpha[i]);
	}
	return 0;
}


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

#define  optimize   ios::sync_with_stdio(0); cin.tie(0);
#define PI  acos(-1.0)
#define RESET(a, b) memset(a, b, sizeof(a))
#define pb push_back
ll solve(int a[],int x,int n){
   ll tmp=0,ans=0;
   for(int i=0;i<n;i++){
      tmp=abs(a[i]-x);
      ans+=(tmp*tmp);
   }
   return ans;
}
int main()
{
     optimize
     int n;
     cin>>n;
     int a[n+2];
     for(int i=0;i<n;i++){
        cin>>a[i];
     }
     ll d=0,mx=1e18+1;
     for(int i=-100;i<=100;i++){
        d=solve(a,i,n);
        mx=min(mx,d);
     }
     cout<<mx<<endl;

}


Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        ArrayList<Point> mList = new ArrayList<>();

        for (int i = 0; i < m; i++) {
            mList.add(new Point(sc.nextInt(), sc.nextInt()));
        }

        sc.close();

        mList.sort(Comparator.comparingInt(a -> a.b));

        int ans = 1;

        int point = mList.get(0).b;
        mList.remove(0);

        for (Point p : mList) {
            if (p.a < point && p.b >= point) {
                continue;
            } else {
                point = p.b;
                ans++;
            }
        }

        System.out.println(ans);
    }

    private static class Point {
        int a;
        int b;

        public Point(int a, int b) {
            this.a = a;
            this.b = b;
        }
    }
}

Measured memory_bytes: 94256
//
// tested with : g++ (GCC) 8.3.0
//

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

int main() {
    string s;
    cin >> s;

    int slength = s.length();
    for (int i = 0; i < slength; i++) {
        if (i % 2 == 0) { //0 2 4が奇数文字目。
            cout << s[i];
        }
    }

    return 0;
}

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

int main(){
  int N; cin >> N;
  vector<long long> A(N);
  for(int i=0; i<N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  for(int j=0; j<N; j++){
    if(binary_search(A.begin()+j+1, A.end(), A[j])){
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<map>
#include<utility>
using namespace std;

vector<long long> banned_k(vector<int> a) {
  map<long long, long long> mp;
  
  for(auto iter = a.begin(); iter != a.end(); iter++) {
    int aa = *iter;
    int current = mp[aa];
    mp[aa] = current+1;
  }

  long long all = 0;
  for(auto iter = mp.begin(); iter != mp.end(); iter++) {
    //cout << iter->first << " -> " << iter->second << endl;
    all += ((iter->second)*((iter->second) -1))/2;
  }

  vector<long long> ans;
  for(auto iter = a.begin(); iter != a.end(); iter++) {
    ans.push_back(all - (mp[(*iter)] - 1));
  }

  return ans;
}

int main() {
  int n;
  cin >> n;
  vector<int> a;
  for(int i=0;i<n;i++) {
    int aa;
    cin >> aa;
    a.push_back(aa);
  }
  vector<long long> ans = banned_k(a);
  for(int i=0; i<n;i++) {
    cout << ans[i];
    if(i != n-1) {
      cout << endl;
    }
  }
}


Measured memory_bytes: 12020
fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(' ').map(String::toLong)
    val lList = mutableListOf<Long>()
    val rList = mutableListOf<Long>()
    for(i in 1..m){
    val (l,r) = readLine()!!.split(' ').map(String::toLong)
        lList.add(l)
        rList.add(r)
    }
    println(Math.max(0,rList.min()!! - lList.max()!!+1))
}

Measured memory_bytes: 62324
n,m,x=map(int,input().split())
book=[]
ans=float("inf")
for _ in range(n):
    b=list(map(int,input().split()))
    book.append(b)

for bit in range(1,2**n+1):
    al=[0 for _ in range(m+1)]
    for i in range(n):
        ch=bit%2
        bit//=2
        if ch==1:
            for k in range(m+1):
                al[k]+=book[i][k]
    if min(al[1:])>=x:
        ans=min(ans,al[0])

if ans==float("inf"):
    print(-1)
else:
    print(ans)

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

using namespace std;

int n, x, res;

map <int, int> dem;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> x;
        dem[x]++; dem[x + 1]++; dem[x - 1]++;
    }
    for (int i = 0; i <= 100001; i++)
        res = max(res, dem[i]);
    cout << res;
}


Measured memory_bytes: 4992
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<algorithm>

const int MAXN=220;

int n,a[MAXN];

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n+n;i++) {
		scanf("%d",&a[i]); 
	}
	
	std:: sort(a+1,a+n+n+1);
	
	
	int ans=0;
	for(int i=1;i<=n+n;i+=2) {
		ans+=a[i];
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
    int a, b;
    bool operator < (ii o) const {
        return tie(a, b) < tie(o.a, o.b);
    }
};
struct iii {
    int a, b, c;
    bool operator < (iii o) const {
        return tie(a, b, c) < tie(o.a, o.b, o.c);
    }
};

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 1000005;

int N, Q;
int arr[MAXN], active[MAXN], ans[MAXN], bit[MAXN];
vector<ii> endAt[MAXN];

void add(int idx, int n) {
    for (int i = idx; i < MAXN; i += i&-i) bit[i] += n;
}

int query(int idx) {
    int ans = 0;
    for (int i = idx; i > 0; i -= i&-i) ans += bit[i];
    return ans;
}

int query(int l, int r) {
    return query(r) - query(l-1);
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> N >> Q;
    
    for (int i = 1; i <= N; i++) {
        cin >> arr[i];
    }
    
    for (int i = 1; i <= Q; i++) {
        int l, r;
        cin >> l >> r;
        endAt[r].push_back({l, i});
    }
    
    for (int i = 1; i <= N; i++) {
        if (active[arr[i]] != 0) add(active[arr[i]], -1);
        active[arr[i]] = i;
        add(i, 1);
        for (auto l: endAt[i]) {
            ans[l.b] = query(l.a, i);
        }
    }
    
    for (int i = 1; i <= Q; i++) cout << ans[i] << "\n";
    
}


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

int main() {
  int N, T;
  cin >> N >> T;
  
  int cost, time;
  int anscost = 10000;
  for( int i = 0; i < N; i++ ){
    cin >> cost >> time;
    if( time <= T ){
      if( anscost > cost ){
        anscost = cost;
      }
    }
  }
  if( anscost < 10000 ) cout << anscost << endl;
  else cout << "TLE" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_N 1000
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

char G[MAX_N][MAX_N + 1];
int dp[MAX_N][MAX_N];
int n;

int
square()
{
	int i, j;

	int max_n = 0;
	for (i = 0; i < n; ++i)
	{
		for (j = 0; j < n; ++j)
		{
			dp[i][j] = (G[i][j] == '.') ? 1 : 0;
			max_n |= dp[i][j];
		}
	}

	for (i = 1; i < n; ++i)
	{
		for (j = 1; j < n; ++j)
		{
			if (G[i][j] == '*')
				dp[i][j] = 0;
			else
			{
				dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
				max_n = max(max_n, dp[i][j]);
			}
		}
	}

	return max_n;
}

int
main(int argc, char **argv)
{
	int i;

	while (true)
	{
		scanf("%d\n", &n);
		if (n == 0)
			break;

		for (i = 0; i < n; ++i)
			fgets(&G[i][0], n + 2, stdin);

		printf("%d\n", square());
	}

	return 0;
}

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

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

    long long d_count = 0;
    //string s = "abcdefghijklmnopqrstuvwxyz";
    string ans_rev;
    string ans;

    while (N > 0){
        d_count++;
        N--;
        long long j = N % 26;
        ans_rev += ((char)'a'+(j));
        N = N / 26;
    }
    
    for (long long i = d_count - 1; i >= 0; i--){
        cout << ans_rev[i];
    }
    cout << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b;
	cin >> n >> a >> b;
	if(a>b){
		cout << 0 << endl;
		return 0;
	}else if(n==1LL&&a!=b){
		cout << 0 << endl;
		return 0;
	}
	ll ans = (b-a)*(n-2)+1LL;
	cout << ans << endl;
	return 0;
}


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

ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

ll nlcm(vector<ll> numbers) {
    ll res;
    res = numbers[0];
    for (ll i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> t(n,0);
    rep(i,n)cin >> t.at(i);
    cout << nlcm(t);
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
// Don't Lose Hope, Nor Be Sad -- Quran

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

int main(){
    int age, cost;
    cin >> age >> cost;
    if(age >= 13) cout << cost << endl;
    else if(age>=6 && age<=12) cout << cost/2 << endl;
    else{
        cout << "0\n";
    }
    return 0;   
}

Measured memory_bytes: 256
_ = input()
B = list(map(int, input().split()))
A = [B[0]] + B
for i in range(len(A)-1):
  if max(A[i],A[i+1]) > B[i]:
    if A[i] <= A[i+1]: A[i+1] = A[i]
    else : A[i] = A[i+1]
print(sum(A))

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

int main(void) {
    int a,b,c,d;

    cin >> a >> b >> c >> d;
    if(a+b<c+d) cout << "Right" << endl;
    else if(a+b>c+d)cout << "Left" << endl;
    else cout << "Balanced" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] a){

    	Scanner s = new Scanner(System.in);

    	int[] input = new int[10];
    	int w;

    	for(int i=0;i<10;i++){
    		input[i] = s.nextInt();
    	}

    	for(int i=0;i<9;i++){

    		for(int j=0;j<9;j++){

    			if(input[j] < input[j+1]){
    				w = input[j];
    				input[j] = input[j+1];
    				input[j+1] = w;
    			}

    		}

    	}

    	for(int i=0;i<3;i++){
    		System.out.println(input[i]);
    	}

    }
}

Measured memory_bytes: 26076
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
ll N,K,H,W;
ll ans = 1;
P A[200001];
ll M = 1000000007;
ll ac;
P minminus= P(M,0);
P maxminus = P(M,0);
P minplus = P(M,0);
P maxplus = P(M,0);
bool found = true;
 
int main() {
    cin >> N >> K;
    for(int i=0;i<N;i++){
        ll k;
        cin >> k;
        if(k!=0){
            A[i] = P(abs(k),k/abs(k));
        }else{
            A[i] = P(0,0);
        }
    }
    sort(A,A+N);
    for(int i=0;i<K;i++){
        if(A[N-i-1].second == -1){
            ac++;
        }
    }
    if(ac%2!=0){
        for(int i=0;i<K;i++){
            if(A[N-K].second == A[N-K+i].second){
                maxminus = P(A[N-K+i].first,N-K+i);
                break;
            }
        }
        for(int i=0;i<K;i++){
            if(A[N-K].second == (-1)*A[N-K+i].second){
                maxplus = P(A[N-K+i].first,N-K+i);
                break;
            }
        }
        for(int i=0;i<N-K;i++){
            if(A[N-K].second == A[N-K-i-1].second){
                minminus = P(A[N-K-i-1].first,N-K-i-1);
                break;
            }
        }
        for(int i=0;i<N-K;i++){
            if(A[N-K].second == (-1)*A[N-K-i-1].second){
                minplus = P(A[N-K-i-1].first,N-K-i-1);
                break;
            }
        }
        if(maxminus.first != M && minplus.first != M){
            if(minminus.first != M&&maxplus.first != M){
                if(maxminus.first*minminus.first <= minplus.first*maxplus.first){
                    A[maxminus.second] = A[minplus.second];
                }else{
                    A[maxplus.second] = A[minminus.second];
                }
            }else{
                A[maxminus.second] = A[minplus.second];
            }
        }else{
            if(minminus.first != M&&maxplus.first != M){
                A[maxplus.second] = A[minminus.second];
            }else{
//                if(A[0].first==0){
//                    cout << 0 << endl;
//                    return 0;
//                }
                found = false;
            }
        }
    }
    
    if(found){
        for(int i=0;i<K;i++){
            ans = (ans*A[N-K+i].first)%M;
        }
        cout << ans << endl;
    }else{
        for(int i=0;i<K;i++){
            ans = (ans*A[i].first)%M;
        }
        if(ans == 0){
            cout << 0 << endl;
        }else{
            cout << (-ans+M)%M << endl;
        }
    }
    
 
}


Measured memory_bytes: 6764
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, M, L;
  cin >> N >> M >> L;
  vector<vector<int64_t>> F(N, vector<int64_t>(N, INT64_MAX));
  rep(i, M) {
    int A, B, C;
    cin >> A >> B >> C;
    --A;
    --B;
    F[A][B] = C;
    F[B][A] = C;
  }
  rep(k, N) {
    rep(i, N) {
      rep(j, N) {
        if (F[i][k] == INT64_MAX || F[k][j] == INT64_MAX) continue;
        F[i][j] = min(F[i][j], F[i][k] + F[k][j]);
      }
    }
  }

  vector<vector<int>> T(N, vector<int>(N, 1000));
  rep(i, N) {
    rep(j, N) {
      if (i == j)
        T[i][j] = 0;
      else if (F[i][j] <= L)
        T[i][j] = 1;
    }
  }
  rep(k, N) {
    rep(i, N) {
      rep(j, N) {
        if (T[i][k] == INT64_MAX || T[k][j] == INT64_MAX) continue;
        T[i][j] = min(T[i][j], T[i][k] + T[k][j]);
      }
    }
  }

  int Q;
  cin >> Q;
  rep(i, Q) {
    int s, t;
    cin >> s >> t;
    --s;
    --t;
    if (T[s][t] == 1000)
      cout << -1 << endl;
    else
      cout << T[s][t] - 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 4288
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main() {
	int N;
	scanf("%d", &N);
	vector<int> p(N), q(N), t(N);
	int ap, aq, c = 0;
	rep(i, 0, N)scanf("%d", &p[i]);
	rep(i, 0, N)scanf("%d", &q[i]);
	rep(i, 0, N)t[i] = i + 1;
	while (next_permutation(t.begin(), t.end())) {
		bool flag;
		c++;
		flag = true;
		rep(i, 0, N)if (t[i] != p[i]) { flag = false; break; }
		if (flag)ap = c;
		flag = true;
		rep(i, 0, N)if (t[i] != q[i]) { flag = false; break; }
		if (flag)aq = c;
	}
	printf("%d\n", abs(ap - aq));
	return 0;
}

Measured memory_bytes: 256
N, K = list(map(int,input().split()))
S = list(input())

if S[K-1] == "A":
    S[K-1] = "a"
if S[K-1] == "B":
    S[K-1] = "b"
if S[K-1] == "C":
    S[K-1] = "c"
    
print(*S, sep='')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[100005],ans=1e9+7;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n-k+1;i++)
	    ans=min(ans,a[i+k-1]-a[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
using ll = long long;
const int N = 2e6 + 15;
int main(){
	int n;
	ll k;
	cin >> n >> k;
	int a[n+1];
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	int cur = 1;
	vector<int> vis(n+1, 0);
	int tim = 1;
	int len = -1;
	while (1) {
		if (k == 0) break;
		if (vis[cur]) {
			len = tim - vis[cur];
			break;
		}
		k--;
		vis[cur] = tim++;
		cur = a[cur];
	}
	k %= len;
	while (k--) cur = a[cur];
	cout << cur << "\n";
}


Measured memory_bytes: 4844