akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iterator>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>
#define vi vector<int>
#define vl vector<long long>
#define vpi vector<pair<int,int> >
#define ll long long 
#define vpl vector<pair><long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pci pair<char,int>
#define un unsigned
# define M_PI           3.14159265358979323846  /* pi */
// #define mod 998244353
#define mod 1000000007
#define MAXN  1000001
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


/*
//------------------------------------------DSU--------------------------------------------------------//
int parent[1000001];
int ssize[1000001];


int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void make_set(int v) {
    parent[v] = v;
    ssize[v] = 1;
}

void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (ssize[a] < ssize[b])
            swap(a, b);
        parent[b] = a;
        ssize[a] += ssize[b];
    }
}
*/

//-----------------------------Sieve Of Eratosthenes--------------------------------------//

/*
v<int> primes;
void SieveOfEratosthenes(int n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.pb(p); 
}

*/

ll gcd(ll a,ll b)
{
    if(min(a,b) == 0)
    return max(a,b);
    else if(a == 1 || b == 1)
    return 1;
    if(b > a)
    swap(a,b);
    return gcd(a%b,b);
}


void solve()
{
    ll k;
    cin>>k;
    ll ans = 0;
    for(int i = 1 ; i <= k ; i++)
    {
        for(int j = 1 ; j <= k ; j++)
        {
            for(int p = 1 ; p <= k ; p++)
            {
                ans += gcd(i,gcd(j,p)); 
            }
        }
    }
    cout<<ans<<endl;
}



int main()
{
    fast;
    int t;
    // cin>>t;
    t = 1;
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
const int nmax=40,abmax=10,inf=1000000;
int a[nmax],b[nmax],c[nmax];
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];
main(){
  int n,ma,mb;
  cin>>n>>ma>>mb;
  for(int i=0;i<n;++i)cin>>a[i]>>b[i]>>c[i];
  for(int i=0;i<=n;++i)
    for(int ca=0;ca<=nmax*abmax;++ca)
      for(int cb=0;cb<=nmax*abmax;++cb)
        dp[i][ca][cb]=inf;
  dp[0][0][0]=0;
  for(int i=0;i<n;++i)
    for(int ca=0;ca<=nmax*abmax;++ca)
      for(int cb=0;cb<=nmax*abmax;++cb){
        if(dp[i][ca][cb]==inf)continue;
        dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
        dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
      }
  int ans=inf;
  for(int ca=1;ca<=nmax*abmax;++ca)
    for(int cb=1;cb<=nmax*abmax;++cb)
      if(ca*mb==cb*ma)ans=min(ans,dp[n][ca][cb]);
  if(ans==inf)ans=-1;
  cout<<ans<<endl;
}


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

using namespace std;

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

  vector<long long> a(n);
  for(long long i=0; i<n; i++) cin>>a[i];
  sort(a.begin(), a.end());
  
  a.erase(unique(a.begin(), a.end()), a.end());

  if(a.size()%2!=0) cout<<a.size()<<endl;
  else if(a.size()%2==0) cout<<a.size()-1<<endl;

}


Measured memory_bytes: 4028
<?php

while (TRUE) {
    fscanf(STDIN, "%d", $n);
    if (feof(STDIN)) {
        break;
    }
    $c = comb($n);
    echo (string) $c . PHP_EOL;
}

function comb($n) {
    $count = 0;
    for ($a = 0; $a < 10; $a++) {
        for ($b = 0; $b < 10; $b++) {
            for ($c = 0; $c < 10; $c++) {
                for ($d = 0; $d < 10; $d++) {
                    if ($a + $b + $c + $d === $n) {
                        $count++;
                    }
                }
            }
        }
    }
    return $count;
}

Measured memory_bytes: 6624
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define LF double
#define LL long long
#define ULL unsigned int
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define fd(i,j,k) for(int i=j;i>=k;i--)
#define fr(i,j) for(int i=begin[j];i;i=next[i])
using namespace std;
int const mn=2*1e3+3,mo=1e9+7;
int n,K,tmp,u[mn],v[mn],gra,begin[mn],to[mn*2],next[mn*2];
void insert(int u,int v){
    to[++gra]=v;
    next[gra]=begin[u];
    begin[u]=gra;
}
void dfs(int p,int q,int dep){
    tmp++;
    if(!dep)return;
    fr(i,p)if(to[i]!=q)
        dfs(to[i],p,dep-1);
}
int main(){
    scanf("%d%d",&n,&K);
    fo(i,1,n-1){
        scanf("%d%d",&u[i],&v[i]);
        insert(u[i],v[i]);
        insert(v[i],u[i]);
    }
    int ans=0;
    if(K&1){
        fo(i,1,n-1){
            tmp=0;
            dfs(u[i],v[i],K/2);
            dfs(v[i],u[i],K/2);
            ans=max(ans,tmp);
        }
    }else{
        fo(i,1,n){
            tmp=0;
            dfs(i,0,K/2);
            ans=max(ans,tmp);
        }
    }
    printf("%d",n-ans);
    return 0;
}

 

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

vector<int> sides;

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

	for(int i = 0; i < 3; i++) {
  		int x;
  		cin >> x;
  		sides.push_back(x);
  	}
  
  	sort(sides.begin(), sides.end());
  	cout << (sides[0] * sides[1])/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;
  long numR = 0;
  long numW = 0;
  long RtoW = 0;
  long WtoR = 0;
  cin >> N;
  char c[200000];
  for(long i = 0; i < N; i++){
   cin >> c[i];
    if(c[i] == 'R'){
      numR++;
    }
    if(c[i] == 'W'){
      numW++;
    }
  }
  for(long i = 0; i < numR; i++){
    if(c[i] == 'W'){
      WtoR++;
    }
  }
  for(long i = numR; i < N; i++){
    if(c[i] == 'R'){
      RtoW++;
    }
  }
  if(RtoW > WtoR){
    cout << RtoW  << endl;
  }else{
    cout << WtoR << endl;
  } 
}

Measured memory_bytes: 3740
# -*- coding: utf-8 -*-

n, a, b = map(int, input().split())
H = [int(input()) for _ in range(n)]


def ok(t):
    count = 0
    for h in H:
        if h - b*t > 0:
            count += -(-(h - b*t) // (a - b))
    return count <= t


lo = 0
hi = 10**9+1
while hi - lo > 1:
    mid = (lo + hi) // 2
    if ok(mid):
        hi = mid
    else:
        lo = mid
print(hi)


Measured memory_bytes: 7072
import java.util.*
import kotlin.collections.HashMap
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val n = readInt()
    val a = readInts().groupingBy { it }.eachCount().toMutableMap()
    val q = readInt()
    var t = a.asSequence().map { (k, v) -> k.toLong() * v.toLong() }.sum()
    (1..q).forEach { _ ->
        val (b, c) = readInts()
        a.remove(b)?.let {
            a[c] = a.getOrDefault(c, 0) + it
            t += it * (c - b)
        }
        println(t)
    }
}


Measured memory_bytes: 79984
import math

def main():
  n = int(input())

  r = 0
  for _ in range(n):
    m = int(input())

    flag = True
    for i in range(int(math.sqrt(m)) - 1):
      if m % (i+2) == 0:
        flag = False
        break
      
    if flag:
      r += 1

  print(r)

if __name__ == '__main__':
  main()


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

template <int Mod, bool IsPrime = false>
class mod_int {
    using ll = long long;

public:
    constexpr mod_int() : n(0) {}
    constexpr mod_int(int n_) : n(n_) {
        if(n >= Mod)     n %= Mod;
        else if(n < 0) n = (n % Mod + Mod) % Mod;
    }
    constexpr mod_int(ll n_) : n(n_) { n = (n + Mod) % Mod; }

    constexpr operator int() const { return n; }
    constexpr operator ll() const  { return n; }

    constexpr bool operator==(mod_int const& other) const { return n == other.n; }
    constexpr mod_int& operator+=(mod_int const& other) {
        if((n += other.n) >= Mod) n -= Mod;
        return *this;
    }
    constexpr mod_int& operator-=(mod_int const& other) {
        if((n += Mod - other.n) >= Mod) n -= Mod;
        return *this;
    }
    constexpr mod_int& operator*=(mod_int const& other) {
        n = (unsigned long long)n * other.n % Mod;
        return *this;
    }
    constexpr typename std::enable_if<IsPrime, mod_int>::type& operator/=(mod_int const& other) {
        return *this *= other.inverse();
    }
    constexpr mod_int operator+(mod_int other) const { return mod_int(*this) += other; }
    constexpr mod_int operator-(mod_int other) const { return mod_int(*this) -= other; }
    constexpr mod_int operator*(mod_int other) const { return mod_int(*this) *= other; }
    constexpr mod_int operator/(mod_int other) const { return mod_int(*this) /= other; }

    constexpr typename std::enable_if<IsPrime, mod_int>::type inverse() const {
        ll a = n, b = Mod, u = 1, v = 0;
        while(b) {
            ll t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        return mod_int(u);
    }

private:
    ll n;
};

template <int Mod, bool IsPrime>
std::ostream& operator<<(std::ostream& os, mod_int<Mod, IsPrime> const& n) {
    os << (int)n;
    return os;
}

constexpr int default_mod = 1000000007;

template <int Mod = default_mod>
mod_int<Mod, true> fact(int n) {
    static std::vector<mod_int<Mod, true>> v = {1};
    if(n >= static_cast<int>(v.size())) {
        const int from = v.size(), to = n + 1024;
        v.reserve(to);
        for(int i = from; i < to; ++i) {
            v.push_back(v.back() * mod_int<Mod, true>(i));
        }
    }
    return v[n];
}

template <int Mod = default_mod>
mod_int<Mod, true> comb(int n, int r) { // nCr
    if(r < 0 || r > n) return 0;
    return fact<Mod>(n) / fact<Mod>(r) / fact<Mod>(n - r);
}

using mint = mod_int<default_mod, true>; // default

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<mint> sum(n + 1); // 1/1 + 1/2 + 1/3 + ...
    for(int i = 1; i <= n; ++i) {
        sum[i] = sum[i - 1] + mint(1) / mint(i);
    }

    mint ans;
    for(int i = 0; i < n; ++i) {
        ans += mint(a[i]) * fact(n) * (sum[i + 1] + sum[n - i]);
        ans -= mint(a[i]) * fact(n); // 重複して数えてるので取り除く
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <cstdint>
#include <deque>
#include <algorithm>
#include <utility>
#include <unordered_map>

using namespace std;
int main() {
  int n;
  cin >> n;
  unordered_map<int, vector<pair<int, uint64_t>>> edges;
  for (int i = 1; i < n; i++) {
    int from, to, weight;
    cin >> from >> to >> weight;
    edges[from].emplace_back(make_pair(to, weight));
    edges[to].emplace_back(make_pair(from, weight));
  }
  int q, k;
  cin >> q >> k;

  vector<uint64_t> dist(n + 1);
  deque<pair<int, uint64_t>> queue;  // vertex, dist
  queue.push_back(make_pair(k, 0));  // starting point
  while (!queue.empty()) {
    auto start = queue.front();
    queue.pop_front();
    uint64_t current_dist = start.second;
    dist[start.first] = current_dist;

    auto edge = edges.find(start.first);
    for (auto& entry : edge->second) {
      if (dist[entry.first] == 0 && entry.first != k) {
        queue.push_back(make_pair(entry.first, current_dist + entry.second));
      }
    }
  }

  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    cout << dist[x] + dist[y] << "\n";
  }
}

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

using namespace std;

#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 RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

ll mi[16];
ll x[15], y[15];
ll a[15];
int sel[15];

void dfs(int n, int k, vll &kyori) {
  if(n == k) {
    int cnt = 0;
    ll now = 0;
    REP(i, n) {
      cnt += sel[i] != -1;
      now += kyori[i] * a[i];
    }
    chmin(mi[cnt], now);
  } else {
    vll prev = kyori;
    sel[k] = -1;
    dfs(n, k+1, kyori);
    sel[k] = 0;
    REP(i, n) {
      kyori[i] = min(prev[i], abs(x[i] - x[k]));
    }
    dfs(n, k+1, kyori);
    sel[k] = 1;
    REP(i, n) {
      kyori[i] = min(prev[i], abs(y[i] - y[k]));
    }
    dfs(n, k+1, kyori);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  REP(i, n) {
    cin >> x[i] >> y[i] >> a[i];
  }

  REP(i, n+1) {
    mi[i] = LINF;
  }

  vll kyori(n);
  REP(i, n) {
    kyori[i] = min(abs(x[i]), abs(y[i]));
  }
  dfs(n, 0, kyori);

  REP(i, n+1) {
    cout << mi[i] << endl;
  }

}








Measured memory_bytes: 3644
import java.util.*;

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

		while(true){
			int h=sc.nextInt(), w=sc.nextInt();
			if(h==0 && w==0) break;
			char[][] map = new char[h][w];

			int ax=-1, ay=-1, bx=-1, by=-1;
			for(int i=0;i<h;i++){
				map[i] = sc.next().toCharArray();
				for(int j=0;j<w;j++){
					if(map[i][j] == 'A'){
						ax = j;
						ay = i;
						map[i][j] = '.';
					}
					if(map[i][j] == 'B'){
						bx = j;
						by = i;
						map[i][j] = '.';
					}
				}
			}

			char[] op = sc.next().toCharArray();
			int x = bx, y = by;
			int ans = -1;

			for(int cost=0;cost<10000;cost++){
				if(map[y][x] == '.'){
					int costAB = getCost(ax,ay,x,y,map);
					if(costAB <= cost){
						ans = cost;
						break;
					}
				}

				switch(op[cost%op.length]){
				case '8': if(y-1>=0) y--; break;
				case '6': if(x+1<w) x++; break;
				case '4': if(x-1>=0) x--; break;
				case '2': if(y+1<h) y++; break;
				}
			}

			if(ans == -1) System.out.println("impossible");
			else System.out.printf("%d %d %d\n",ans,y,x);
		}
	}

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

	private static int getCost(int sx,int sy,int gx,int gy,char[][] map){
		Queue<State> open = new LinkedList<State>();
		HashSet<State> closed = new HashSet<State>();

		open.add(new State(sx,sy,0));

		int ans = Integer.MAX_VALUE;
		while(!open.isEmpty()){
			State st = open.poll();
			if(closed.contains(st)) continue;
			closed.add(st);
			if(st.x == gx && st.y == gy){
				ans = st.cost;
				break;
			}

			for(int i=0;i<4;i++){
				int nx = st.x + dx[i];
				int ny = st.y + dy[i];
				if(nx>=0 && nx<map[0].length && ny>=0 && ny<map.length && map[ny][nx]=='.'){
					open.add(new State(nx,ny,st.cost+1));
				}
			}
		}

		return ans;
	}

	public static class State{
		int x,y,cost;

		State(int x,int y,int cost){
			this.x = x;
			this.y = y;
			this.cost = cost;
		}

		public boolean equals(Object o){
			State st = (State)o;
			return this.x == st.x && this.y == st.y;
		}

		public int hashCode(){
			return this.x * 100 + this.y;
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define For(i,x,y) for(int i = x; i <= y; ++i)
#define FOR For
#define rev_For(i,x,y) for(int i = x; i >= y; --i)
#define REV_FOR rev_For
#define ll long long
#define Size(v) ((int)v.size())
#define _section "\n--------------------\n"
#define fi first
#define se second
#define pb push_back
using namespace std;
// using namespace __gnu_pbds;


int x, y, z;

void input() {
	cin >> x >> y >> z;
}

void solve() {
	swap(x, y);
	swap(x, z);

	cout << x << ' ' << y << ' ' << z;	
}

signed main() {
#ifdef _DEBUG
	freopen("INPUT.inp", "r", stdin);
	//freopen("OUTPUT.out", "w", stdout);
	clock_t start, end;
	start = clock();
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//------------------------------------------------------------------------------------
//----------------------------------MAIN PROGRAM--------------------------------------
	int t = 1;
	while (t--) {
		input();
		solve();
	}
//--------------------------------------END-------------------------------------------
//------------------------------------------------------------------------------------
#ifdef _DEBUG
	end = clock();
	cerr << "\n----------\nTime Elapsed: " << fixed << double(end - start) / double(CLOCKS_PER_SEC) << setprecision(6) << '\n';
#endif
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(a,n) for (int a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<int,int> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

// auto mod int
// depends on Template

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main(){
    ll n;
    cin >> n;
    vector<ll>c(n);
    rep(i,n)cin>>c[i];
    vector<mint>dp(n+1,0);
    dp[n-1]=1;
    vector<ll>last(2e5+5,n);
    last[c[n-1]]=n-1;
    for(int i=n-2;i>=0;i--){
        dp[i]+=dp[i+1];
        if(i<last[c[i]]-1)dp[i]+=dp[last[c[i]]];
        last[c[i]]=i;
    }
    cout << dp[0] << endl;
    return 0;
}



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

class ORDER {
public:
	int N, A;
	void MONEY() {
		cin >> N >> A;
		while (1) {
			if (N % 500 == 0) {
				cout << "Yes" << endl;
				break;
			}
			N--;
			A--;
			if (A < 0) {
				break;
			}
		}
		if (A < 0) {
			cout << "No" << endl;
		}
	}
};

int main() {
	ORDER x;
	x.MONEY();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int A, B, K;
    cin >> A >> B >> K;

    repi(i, A, B + 1) {
        if(i < A + K) {
            cout << i << endl;
        } else if(i > B - K) {
            cout << i << endl;
        }
    }
}

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

const double EPS = 1e-6;
const double INF = 1e12;
const double PI = acos(-1);

using Point = complex<double>;
using Polygon = vector<Point>;

inline int sgn(const double &a) { return (a < -EPS ? -1 : (a > EPS ? 1 : 0)); }

inline bool eq(const Point &a, const Point &b) { return abs(a - b) < EPS; }

namespace std {
inline bool operator<(const Point &a, const Point &b) {
    if (sgn(a.real() - b.real()))
        return sgn(a.real() - b.real()) < 0;
    return sgn(a.imag() - b.imag()) < 0;
}

inline bool operator==(const Point &a, const Point &b) {
    return eq(a.real(), b.real()) && eq(a.imag(), b.imag());
}
} // namespace std

double dot(const Point &a, const Point &b) { return real(conj(a) * b); }

double det(const Point &a, const Point &b) { return imag(conj(a) * b); }

struct Line {
    Point p1, p2;

    Line(Point p1 = Point(), Point p2 = Point()) : p1(p1), p2(p2) {}

    bool operator<(const Line &rhs) const {
        if (eq(p2, rhs.p2))
            return p1 < rhs.p1;
        return p2 < rhs.p2;
    }
    bool operator==(const Line &rhs) const {
        return (eq(p1, rhs.p1) && eq(p2, rhs.p2)) ||
               (eq(p1, rhs.p2) && eq(p2, rhs.p1));
    }
};

inline Point curr(const Polygon &p, const int &i) { return p[i % p.size()]; }

inline Point next(const Polygon &p, const int &i) {
    return p[(i + 1) % p.size()];
}

inline Point prev(const Polygon &p, const int &i) {
    return p[(i + p.size() - 1) % p.size()];
}

struct Circle {
    Point p;
    double r;
    Circle(Point p = Point(), double r = 0) : p(p), r(r) {}
};

vector<Point> intersection(Circle c1, Circle c2) {
    double d = abs(c1.p - c2.p);
    vector<Point> res;
    if(sgn(c1.r+c2.r - d) < 0)return res;
    double rc = (d*d + c1.r*c1.r - c2.r*c2.r) / (2*d);
    double rs = sqrt(c1.r*c1.r - rc*rc);
    Point e = (c2.p - c1.p) / d;
    res.push_back(c1.p+e*Point(rc, rs));
    Point p = c1.p+e*Point(rc, -rs);
    if(res[0] == p)return res;
    res.push_back(p);
    if(res[1] < res[0])swap(res[1], res[0]);
    return res;
}

int main(){
    double c1x, c1y, c1r, c2x, c2y, c2r;
    cin >> c1x >> c1y >> c1r >> c2x >> c2y >> c2r;
    auto v = intersection(Circle(Point(c1x, c1y), c1r), Circle(Point(c2x, c2y), c2r));
    int idx = (v.size() == 1 ? 0 : 1);
    printf("%.10f %.10f %.10f %.10f\n", v[0].real(), v[0].imag(), v[idx].real(), v[idx].imag());
    return 0;
}



Measured memory_bytes: 3344
#include <stdio.h>
int main ()
{
    int K,A,B,X=1;
    scanf("%d",&K);
    scanf("%d %d",&A,&B);
    
    for(int i=A;i<=B;i++)
    {
        if (i%K==0)
        {
            X=0;
        }
    }
    if (X==0)
    {
        printf("OK");
    }
    else
    {
        printf("NG");
    }    
    
    return 0;
}

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

using namespace std;

using ll = long long;

int Solve() {
    int n, m;
    cin >> n >> m;

    vector<vector<bool>> g(n, vector<bool>(n, false));
    for (int i = 0, a, b; i < m; ++i) {
        cin >> a >> b;
        g[a - 1][b - 1] = g[b - 1][a - 1] = true;
    }

    vector<int> ord(n - 1);
    for (int i = 0; i < n - 1; ++i) ord[i] = i + 1;
    int res = 0;
    do {
        bool find = true;
        for (int i = 0, cur = 0; i < n - 1; ++i) {
            if (g[cur][ord[i]]) cur = ord[i];
            else { find = false; break; }
        }
        if (find) ++res;
    } while (next_permutation(ord.begin(), ord.end()));

    return res;
}

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

    cout << Solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 500010
int n;
int a[N];
void swap(int *a, int *b){
    int t;
    t = *a;
    *a= *b;
    *b = t;
}
void maxHeapify(int i){
    int l = 2*i;
    int r = 2*i+1;
    int maxi = i;
    if(l <= n && a[l] > a[maxi]){
        maxi = l;
    }
    if(r <= n && a[r] > a[maxi]){
        maxi = r;
    }
    if(maxi != i){
        swap(&a[i], &a[maxi]);
        maxHeapify(maxi);
    }
}
int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for(int i = n/2; i >= 1; i--){
        maxHeapify(i);
    }
    for(int i = 1; i<= n; i++){
        printf(" %d", a[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 4664
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;} 
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    if(n * 2 == m) cout << n << '\n';
    else if(n < m/2) cout << (n + m/2) / 2 << '\n';
    else if(n > m/2) cout << m / 2 << '\n';
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import logging
import time


class Solver:
    def __init__(self):
        self.n = 0
        self.k = 0

    # 入力
    def input_value(self):
        # self.n = int(input())
        # self.A, self.B = map(int, input().split())
        # self.A = list(map(int, input().split()))
        # self.a, self.b, self.c = map(int, [input() for i in range(4)])
        # self.t = [None] * self.n
        self.n, self.k, = map(int, input().split())

    # @staticmethod
    # def can_go(t, x, y):
        # logging.debug(input_str)

        # logging.debug(input_str)

    def run(self):
        if self.n % self.k == 0:
            return 0
        return 1

    @staticmethod
    def test(self):
        start_time = time.time()

        # assert self.run(3, 1, 2), 'Error.'

        elapsed_time = time.time() - start_time
        logging.debug('elapsed_time: {0}'.format(elapsed_time) + '[sec]')


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)

    solver = Solver()

    # solver.test()

    solver.input_value()
    ans = solver.run()
    # print(str(ans))
    print(str(ans))


Measured memory_bytes: 4232
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int n, i;
	cin >> n >> i;

	cout << n - i + 1 << endl;
}

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

	solve();
}

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

using namespace std;

struct CumulativeSum2D
{
  vector< vector< int > > data;

  CumulativeSum2D(int W, int H) : data(W + 1, vector< int >(H + 1, 0))
  {
  };

  inline void add(int x, int y, int z)
  {
    ++x, ++y;
    if(x >= data.size() || y >= data[0].size()) return;
    data[x][y] += z;
  }

  void build()
  {
    for(int i = 1; i < data.size(); i++) {
      for(int j = 1; j < data[i].size(); j++) {
        data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
      }
    }
  }

  inline int query(int sx, int sy, int gx, int gy)
  {
    return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
  }
};

int main()
{
  int N, M, X[5000], Y[5000];

  scanf("%d %d", &N, &M);
  vector< int > xs, ys;
  for(int i = 0; i < N; i++) {
    scanf("%d %d", &X[i], &Y[i]);
    xs.push_back(X[i]);
    ys.push_back(Y[i]);
  }
  sort(begin(xs), end(xs));
  xs.erase(unique(begin(xs), end(xs)), end(xs));
  sort(begin(ys), end(ys));
  ys.erase(unique(begin(ys), end(ys)), end(ys));
  CumulativeSum2D sum(xs.size(), ys.size());
  for(int i = 0; i < N; i++) {
    sum.add(lower_bound(begin(xs), end(xs), X[i]) - begin(xs),
            lower_bound(begin(ys), end(ys), Y[i]) - begin(ys), 1);
  }
  sum.build();
  for(int i = 0; i < M; i++) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    x1 = lower_bound(begin(xs), end(xs), x1) - begin(xs);
    y1 = lower_bound(begin(ys), end(ys), y1) - begin(ys);
    x2 = upper_bound(begin(xs), end(xs), x2) - begin(xs);
    y2 = upper_bound(begin(ys), end(ys), y2) - begin(ys);
    printf("%d\n", sum.query(x1, y1, x2, y2));
  }
}

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

#define int long long

using namespace std;

int pw (int x) {
    int ans = 1;
    for (int i = 1; i <= x; i++) ans *= 10;
    return ans;
}

void solve(){
    int pos = 0;
    for (int i = 1; i <= 10; i++) {
        cout << "? " << pw(i) << endl;
        string s;
        cin >> s;

        if (s == "N") {
            pos = i;
            break;
        }
    }

    if (!pos) {
        for (int i = 0; i <= 9; i++) {
            cout << "? " << pw(i) + 1 << endl;
            string s;
            cin >> s;

            if (s == "Y") {
                cout << "! " << pw(i) << endl;
                return;
            }
        }
    }

    int l = pw(pos - 1);
    int r = pw(pos) - 1;

    while (l <= r) {
        int mid = (l + r) >> 1;
        cout << "? " << mid * 10 << endl;
        string s;
        cin >> s;

        if (s == "Y") r = mid - 1;
        else l = mid + 1;
    }

    cout << "!" << " " << l << endl;
    return;
}

signed main(){
    solve();
    return 0;
}


Measured memory_bytes: 596
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int con = 0;
      int ans = c;
      for (int count = 0; count < A; count++){
	      int ac = sc.nextInt();
              int scores[] = new int[A];
	      scores[count] = ac;
              for(int s = 1 ;s<=b;s= s+scores[count])
{con++;}
	    }
      ans = ans + con;
      System.out.println(ans);
   }
 }


Measured memory_bytes: 21844
/*
** author:mahmoud magdy
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
const int N=1e5+1;
int n,w;
int a[105],b[105];
ll dp[105][N];
ll solve(int i, int rem)
{
    if(rem==0)
        return 0;
    if(rem<0||i==n)
       return 2e18;
    if(dp[i][rem]!=-1)
       return dp[i][rem];
    ll ch1=solve(i+1,rem);
    ll ch2=a[i]+solve(i+1,rem-b[i]);
    return dp[i][rem]=min(ch1,ch2);
}
int main()
{
    fast();
    n=D(),w=D();
    for(int i=0; i<n; ++i)
    {
        a[i]=D(),b[i]=D();
    }
    memset(dp,-1,sizeof dp);
    int ans=0;
    for(int i=0; i<N; ++i)
    {
        if(solve(0,i)<=w){
            ans=i;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 85624
import java.io.*;

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] str;
		int m,f,r;

		while(true){
			str = buf.readLine().split(" ");
			m = Integer.parseInt(str[0]);
			f = Integer.parseInt(str[1]);
			r = Integer.parseInt(str[2]);
			if(m==-1 && f==-1 && r==-1)
				break;
			if(m == -1 || f == -1 || (m+f)<30)
				sb.append("F"+"\n");
			else{
				if(m+f >= 80)
					sb.append("A" + "\n");
				if(m+f>=65 && m+f <80)
					sb.append("B" + "\n");
				if(m+f>=50 && m+f<65)
					sb.append("C" + "\n");
				if(m+f>=30 && m+f<50){
					if(r >= 50)
						sb.append("C" + "\n");
					else 
						sb.append("D"+"\n");
				}
			}

		}
		System.out.print(sb);		
	}
}

Measured memory_bytes: 24204
n = int(input())
lis = []
for _ in range(n):
  s = list(str(input()))
  s.sort()
  lis.append(s)
lis.sort()
ans = 0
num = 0
for i in range(n-1):
  if lis[i+1] == lis[i]:
    num += 1
  else:
    ans += (num * (num+1))//2
    num = 0
ans += (num * (num+1))//2
print(ans)

Measured memory_bytes: 24652
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(int, n);
  n *= 3;
  deque<int> dq(n);
  rep(i, n) cin >> dq[i];
  sort(rng(dq));
  ll ans = 0;
  rep(i, n / 3) {
    dq.pop_back();
    ans += dq.back();
    dq.pop_back();
    dq.pop_front();
  }
  cout << ans << endl;
}

Measured memory_bytes: 1664
N, A, B = map(int, input().split())
check = [0 for _ in range(N)]

for i in range(A):
    check[i] += 1

for i in range(B):
    check[-(i + 1)] += 1

cnt = 0
for c in check:
    if c == 2:
        cnt += 1

print(min(A, B), cnt)


Measured memory_bytes: 3060
N = int(input())

messages = []
for i in range(N):
    a = int(input())
    message = []
    for j in range(a):
        pair = list(map(int, input().split()))
        message.append(pair)
    messages.append([a, message])


result = 0
for pattern in range(2 ** N):

    confidence = True
    for i in range(N):

        if not ((pattern >> i) & 1):
            continue

        a = messages[i][0]
        message = messages[i][1]
        for j in range(a):
            x, y = message[j][0], message[j][1]

            condition = (pattern >> (x - 1)) & 1
            if condition and y == 0:
                confidence = False

            condition = not ((pattern >> (x - 1)) & 1)
            if condition and y == 1:
                confidence = False

    if confidence:
        count = 0
        for n in range(N):
            if (pattern >> n) & 1:
                count += 1

        result = max(result, count)

print(result)


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

int main() {
  int n;
  cin >> n;
  if(n < 600) cout << 8;
  else if( n < 800) cout << 7;
  else if (n < 1000) cout << 6;
  else if (n < 1200) cout << 5;
  else if (n < 1400) cout << 4;
  else if (n < 1600) cout << 3;
  else if (n < 1800) cout << 2;
  else cout << 1;
  cout << endl;
  return 0; 
}

Measured memory_bytes: 3632
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a),greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) printf("%d\n",(x));
#define ENDL printf("\n");
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template<class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

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

signed main(){
    int n;
    while( cin >> n && n){
        vector<pair<int,int>> crd(n);
        rep(i ,n) cin >> crd[i].first >> crd[i].second;
        u64 score_A = 0 , score_B = 0;
        rep(i , n){
            if(crd[i].first > crd[i].second) score_A += crd[i].first + crd[i].second;
            else if ( crd[i].first == crd[i].second) { score_A += crd[i].first; score_B += crd[i].second; }
            else if ( crd[i].first < crd[i].second) score_B += crd[i].first +crd[i].second;
        }
        cout << score_A << " " << score_B << endl;
    }
}


Measured memory_bytes: 3156
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;


int main() {
	int N;
	scanf("%d", &N);
	int *H = new int[N];
	for (int i = 0; i < N; i++)scanf("%d", H + i);
	bool can = true;
	for (int i = 0; i < N - 1; i++) {
		if (H[i] < H[i + 1]) {
			H[i + 1]--;
		}
		else if (H[i] == H[i + 1]) {

		}
		else {
			can = false;
			break;
		}
	}
	printf(can ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 640
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


  string s;
  cin >> s;
  int n = s.size();
  for(int i=0;i<n;i++){
    cout << "x";
  }
  cout << endl;


return 0;
}
///....


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
using namespace std;

struct rrobin
{
	string	name;
	int			time;
};

int main()
{
	queue<rrobin> q;
	int n, qt;
	cin >> n >> qt;

	for( int i = 0; i < n; i++ ) {
		rrobin t;
		cin >> t.name >> t.time;
		q.push( t );
	}

	int stime = 0;
	while( !q.empty() ) {
		rrobin t;
		t = q.front();
		if( t.time > qt ) {
			stime += qt;
			t.time = t.time - qt;
			q.pop();
			q.push( t );
		}
		else {
			stime += t.time;
			q.pop();
			cout << t.name << " " << stime << endl;
		}
	}

	return 0;
}




Measured memory_bytes: 6188
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>

#define PI 3.14159265359


using namespace std;
int main()
{
    double r;
    cin >> r;

    double area = r*r*PI;
    double enshu = 2*r*PI;

    printf("%.6f %.6f\n",area,enshu);

    return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
const ll INF = 1LL << 60;
const ll MOD = (ll) 1e9 + 7;

int main(){
    int n;
    cin >> n;
    deque<int> d;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (i % 2 == 1) {
            d.push_back(a);
        }
        else {
            d.push_front(a);
        }
    }
    if (n % 2 == 0) {
        reverse(d.begin(), d.end());
    }
    for (auto&& x : d) {
        cout << x << " ";
    }
    cout << "\n";
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

vector<vector<ll>> dp(100000, vector<ll>(3, 0));
//dp.at(i).at(j)はi+1日目にjをしたときの最大幸福

int main(){
  ll N;
  cin >> N;
  vector<ll> a(N), b(N), c(N);
  rep(i, N){
    cin >> a.at(i) >> b.at(i) >> c.at(i);
  }
  dp.at(0).at(0) = a.at(0);
  dp.at(0).at(1) = b.at(0);
  dp.at(0).at(2) = c.at(0);
  rep(i, N-1){
    dp.at(i+1).at(0) = max(dp.at(i).at(1)+a.at(i+1), dp.at(i).at(2)+a.at(i+1));
    dp.at(i+1).at(1) = max(dp.at(i).at(0)+b.at(i+1), dp.at(i).at(2)+b.at(i+1));
    dp.at(i+1).at(2) = max(dp.at(i).at(0)+c.at(i+1), dp.at(i).at(1)+c.at(i+1));
  }
  cout << max(dp.at(N-1).at(0), max(dp.at(N-1).at(1), dp.at(N-1).at(2))) << endl;
}

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

int main() {
    string s; cin >> s;
    int q; cin >> q;
    int r = 1;
    vector<char> fr;
    vector<char> bk;
    rep(i,q){
        int t; cin >> t;
        if(t == 1) r *= -1;
        else {
            int f; cin >> f;
            char c; cin >> c;
            if(r == 1){
                if(f == 1) fr.push_back(c);
                else bk.push_back(c);
            }
            else {
                if(f == 1) bk.push_back(c);
                else fr.push_back(c);
            }
        }
    }

    if(r == 1){
        reverse(fr.begin(),fr.end());
        for(char c : fr){
            cout << c;
        }
        cout << s;
        for(char c : bk){
            cout << c;
        }
        cout << endl;
    }
    else{
        reverse(bk.begin(),bk.end());
        reverse(s.begin(),s.end());
        for(char c : bk){
            cout << c;
        }
        cout << s;
        for(char c : fr){
            cout << c;
        }
        cout << endl;
    }
}


Measured memory_bytes: 1024
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

/***************/

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}
#define ll long long
ll gcd (ll a, ll b) {
    while (b > 0) {
        ll t = a % b;
        a = b, b = t;
    }
    return a;
}

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

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    for (int i = n; i >= 0; i--) {
        int ok = 1;
        for (int j = 0; j < i; j++) {
            if (b[j] != a[n - i + j]) {
                ok = 0; break;
            }
        }
        if (ok == 1) {
            cout << n + n - i << endl; return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        if (n > 99) {
            System.out.println("ABC" + n);
        } else {
            System.out.println("ABC0" + n);
        }
    }
}

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

struct ________{
    ________() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    };
} ____________;

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

const int N = 9;
int n, x, y;
ii pos[N];
int fac[N];

inline double dist(ii a, ii b) {
    int c = (a.first - b.first);
    int d = (a.second - b.second);
    return sqrt(c * c + d * d);
}

void init() {
    fac[0] = 1;
    for (int i = 1; i < N; ++i) {
        fac[i] = fac[i - 1] * i;
    }
}

int main() {
    init();
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x >> y;
        pos[i] = { x, y };
    }
    double res = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            double d = dist(pos[i], pos[j]);
            res += fac[n - 1] * 2 * d;
        }
    }
    cout << res / fac[n] << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	string str;

	cin >> str;

	int head,tail;

	for(int i=0;i<str.size();i++)
	{
		if(str[i] == 'A')
		{
			head = i;
			break;
		}
	}

	for(int i=str.size()-1;i>=0;i--)
	{
		if(str[i] == 'Z')
		{
			tail = i;
			break;
		}
	}

	cout << tail - head + 1 << endl;

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<queue>
#define LL long long
using namespace std;
inline int read( )
{
  int sum=0;char c=getchar( );bool f=0;
  while(c<'0'||c>'9') {if(c=='-') f=1;c=getchar( );}
  while(c>='0'&&c<='9') {sum=sum*10+c-'0';c=getchar( );}
  if(f) return -sum;
  return sum;
}
const int N=305;
const int mod=1000000007;
struct ex{int l,c;};
int n,m,f[N][N][N];
vector<ex>S[N];
inline void up(int &x,int y) {x+=y;if(x>=mod) x-=mod;}
int main( )
{
  int i,j,k,l,r,x,y,L[4],R[4];
  n=read( );m=read( );
  for(i=1;i<=m;i++)
    {
      l=read( );r=read( );x=read( );
      S[r].push_back((ex){l,x});
    }
  vector<ex>::iterator it,ed;
  int L1,R1,L2,R2,ans=0;
  f[1][0][0]=3;
  for(i=1;i<=n;i++)
    {
      for(j=1;j<=3;j++) L[j]=mod,R[j]=-mod;
      for(it=S[i].begin( ),ed=S[i].end( );it!=ed;it++)
	x=it->l,y=it->c,L[y]=min(L[y],x),R[y]=max(R[y],x);
      if(L[1]<=R[2]||L[1]<=R[3]||L[2]<=R[3]) {puts("0");return 0;}
      L1=(R[2]!=-mod)?R[2]:0;
      R1=(L[1]!=mod)?L[1]-1:i;
      L2=(R[3]!=-mod)?R[3]:0;
      R2=(L[2]!=mod)?L[2]-1:i;
      if(i!=n)
	for(j=L1;j<=R1;j++)
	  for(k=L2;k<=R2;k++)
	    {
	      if(j<k) continue;
	      up(f[i+1][j][k],f[i][j][k]); //col[i+1]=col[i]
	      up(f[i+1][i][j],f[i][j][k]); //col[i+1]=col[k]
	      up(f[i+1][i][k],f[i][j][k]); //col[i+1]=col[j]
	    }
      else
	for(j=L1;j<=R1;j++)
	  for(k=L2;k<=R2;k++)
	    {
	      if(j<k) continue;
	      up(ans,f[i][j][k]);
	    }
    }
  printf("%d",ans);
  return 0;
}
	  

Measured memory_bytes: 108800