akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vpii        vector< pii >
#define vi          vector<ll>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			1'010'000'000'000'000'017LL
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define sz(x)       (ll)x.size()
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )

using namespace std;

template<class T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
ll DivisorCount(ll x) {
	ll ans = 1;
	for (int i = 2; i <= sqrt(x); i++) {
		int cnt = 0;
		while (x % i == 0) {
			cnt++;
			x /= i;
		}
		ans *= (cnt + 1);
		if (x == 1) break;
	}
	if (x != 1) ans *= 2;
	return ans;
}

void Main() {
	ll N, Q, sum = 0;
	cin >> N;
	vi mem(pow(10, 5) + 10, 0);
	rep(i, 0, N) {
		ll tmp;
		cin >> tmp;
		mem[tmp]++;
		sum += tmp;
	}
	cin >> Q;
	vi B(Q, 0), C(Q, 0);
	rep(i, 0, Q) cin >> B[i] >> C[i];

	rep(i, 0, Q) {
		sum = sum + (mem[B[i]] * C[i]) - (mem[B[i]] * B[i]);
		mem[C[i]] += mem[B[i]];
		mem[B[i]] = 0;
		cout << sum << endl;
	}
}




int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	Main();
	return 0;
}


Measured memory_bytes: 5540
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const signed int inf = (signed) (~0u >> 1);

template <typename T>
void pfill(T* pst, const T* ped, T val) {
	for ( ; pst != ped; *(pst++) = val);
}

typedef class Edge {
	public:
		int ed, nx, r;

		Edge(int ed = 0, int nx = 0, int r = 0) : ed(ed), nx(nx), r(r) {	}
} Edge;

typedef class MapManager {
	public:
		int *h;
		vector<Edge> es;

		MapManager() {	}
		MapManager(int n) {
			h = new int[(n + 1)];
			pfill(h, h + n + 1, -1);
		}
		~MapManager() {
			delete[] h;
			es.clear();
		}

		void addEdge(int u, int v, int r) {
			es.push_back(Edge(v, h[u], r));
			h[u] = (signed) es.size() - 1;
		}

		void addArc(int u, int v, int cap) {
			addEdge(u, v, cap);
			addEdge(v, u, 0);
		}

		Edge& operator [] (int p) {
			return es[p];
		}
} MapManager;

typedef class Network {
	public:
		int S, T;
		int *cur, *div;
		MapManager g;

		Network() {	}
		Network(int S, int T) : S(S), T(T), g(T + 1) {
			cur = new int[(T + 1)];
			div = new int[(T + 1)];
		}
		~Network() {
			delete[] cur;
			delete[] div;
		}

		boolean bfs() {
			static queue<int> que;
			pfill(div, div + T + 1, -1);
			div[S] = 0;
			que.push(S);
			while (!que.empty()) {
				int e = que.front();
				que.pop();
				for (int i = g.h[e], eu; ~i; i = g[i].nx) {
//					cerr << i << '\n';
					if (!g[i].r)
						continue;
					eu = g[i].ed;
					if (!~div[eu]) {
						div[eu] = div[e] + 1;
						que.push(eu);
					}
				}
			}
			return ~div[T];
		} 

		int dfs(int p, int minf) {
			if (p == T || !minf)
				return minf;
			int flow = 0, f; 
			for (int& i = cur[p], e; (~i); i = cur[p], i = g[i].nx) {
				e = g[i].ed;
				if (div[e] == div[p] + 1 && (f = dfs(e, min(minf, g[i].r))) > 0) {
					flow += f;
					g[i].r -= f;
					g[i ^ 1].r += f;
					minf -= f;
					if (!minf) {
						break;	
					}
				}
			}
			return flow;
		}

		int dinic() {
			int rt = 0;
//			cerr << g.h[0] << '\n';
			while (bfs()) {
				for (int i = 0; i <= T; i++)
					cur[i] = g.h[i];
				rt += dfs(S, inf);
			}
			return rt;
		}
} Network;

const int N = 1e5 + 5;

int n, T;
int uf[N << 1];
int P[N], Q[N];

int find(int x) {
	return uf[x] == x ? x : (uf[x] = find(uf[x]));
}
void unit(int x, int y) {
	x = find(x), y = find(y);
	if (x ^ y) {
		uf[x] = y;
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= 2 * n; i++)
		uf[i] = i;
	for (int i = 1; i <= n; i++) {
		scanf("%d", P + i);
		unit(i, ++P[i]);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", Q + i);
		unit(i + n, ++Q[i] + n);
	}
	Network network (0, T = 2 * n + 1);
	MapManager &g = network.g;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i == P[i] && i == Q[i]) {
			continue;
		}
		ans++;
		if (i != P[i] && i != Q[i]) {
			g.addArc(find(i), find(i + n), 1);
		} else if (i == P[i] && i != Q[i]) {
			g.addArc(0, find(i + n), 1);
		} else if (i != P[i] && i == Q[i]) {
			g.addArc(find(i), T, 1);
		}
		if (P[i] == Q[i]) {
			g.addArc(find(i + n), find(i), 1);
		}
	}
	ans -= network.dinic();
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 10988
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
 long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
ll bionomial(ll n , ll r){
	
	ll res = 1 ;
	for (ll i =  0 ; i<r;i++){
		res *= (n-i) ;
		res %= MOD ;
	}
	return res ;
}
void solve()
{
	int a ,b,c ; 
	cin>>a>>b>>c;
	if((a==b && c!=b && c!=a)||(c==b && a!=c && b!=a)||(c==a && b!=a && b!=c)){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
}
 
int main() {
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		
		int sum=0;
		for(int i=0;i<n;i++){
			sum+=a[i]-1;
		}
		System.out.println(sum);
		
	}
}

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

// マクロ //
#define rep(v,times) for(int v = 0; v < (int)(times); v++)
#define req(v,first,endplus1) for(int v = first; v < (int)(endplus1); v++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using plili = pair<lint, lint>;
using vplili = vector<plili>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd_(a, b);
}

template<class T, class Q> double distance(T a, Q b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };
const int dx8[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy8[8] = { 0,1,1,1,0,-1,-1,-1 };

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    int N;
    cin >> N;
    unordered_map<int, int> M;
    req(i, 1, 101) {
        req(j, 1, 101) {
            req(k, 1, 101) {
                if (M.count(i * i + j * j + k * k + i * j + j * k + k * i)) M[i * i + j * j + k * k + i * j + j * k + k * i]++;
                else M[i * i + j * j + k * k + i * j + j * k + k * i] = 1;
            }
        }
    }
    req(i, 1, N + 1) {
        cout << (M.count(i) ? M[i] : 0) << endl;
    }
}

Measured memory_bytes: 4748
n,K = map(int,input().split())
h = [0]
for i in input().split(): h.append(int(i))
def cost(i,j): return abs(h[i]-h[j])

dp = [float("inf") for _ in range(n+1)]
dp[0] = dp[1] = 0
for i in range(2,n+1):
    for k in range(1,K+1):
        if i-k > 0:
            dp[i] = min(dp[i-k]+cost(i,i-k),dp[i])

print(dp[n])


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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define present(c,x) ((c).find(x) != (c).end()) //set,map
#define cpresent(c,x) (find(all(c),x) != (c).end()) //vector

const long long int N = 1e9 + 5;
long long int n;

int main(){
    int dp[9];
    vector<vector<int> > v(4,vi(2));
    for (int i = 0; i < 4; i++) {
        v[i][0] = ((pow(2,i)));
        cin>>v[i][1];
    }
    for (int i = 0; i < 9; i++) dp[i] = 1e9;
    cin>>n;
    dp[0] = 0;
    for (int i = 1; i <= 8; i++) {
        for (int j = 0; j < 4; j++) {
            if (v[j][0] <= i && dp[i-v[j][0]] + v[j][1] < dp[i]) {
                dp[i] = dp[i - v[j][0]] + v[j][1];
            }
        }
    }
    long long ans = (n/2)*dp[8] + (n%2)*dp[4];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f(X, Y) :- X =< 8, Y =< 8.

main :-
	get_number(N),
    get_number(M),
    f(N, M) -> writeln("Yay!") ; writeln(":(").


Measured memory_bytes: 8060
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

void solve(){
    int n;
    ll ans{};
    cin>>n;
    vector<int> k(n),l(n),r(n),L,R;
    fr(i,n){
        cin>>k[i]>>l[i]>>r[i];
        ans+=min(l[i],r[i]);
        if(l[i]>r[i]) L.push_back(i);
        else R.push_back(i);
    }
    {
        vector<vector<int>> x(L.size());
        for(auto i:L) x[min(k[i],(int)L.size())-1].push_back(l[i]-r[i]);
        priority_queue<int> pq;
        ifr(i,L.size()){
            for(auto&j:x[i]) pq.push(j);
            if(!pq.empty()){
                ans+=pq.top();
                pq.pop();
            }
        }
    }
    {
        vector<vector<int>> x(R.size());
        for(auto i:R) if(k[i]<n) x[min(n-k[i],(int)R.size())-1].push_back(r[i]-l[i]);
        priority_queue<int> pq;
        ifr(i,R.size()){
            for(auto&j:x[i]) pq.push(j);
            if(!pq.empty()){
                ans+=pq.top();
                pq.pop();
            }
        }
    }
    cout<<ans<<'\n';
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t{1};
    cin>>t;
    fr(i,t) solve();
}

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

using namespace std;

int main()
{
	string str;
	int ans;
	bool same = true;
	int cnt = 0;
	vector<int> v;

	cin >> str;
	if (str.at(2) == str.at(3) && str.at(4) == str.at(5)) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 504
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

void msort_inner(const int size, char (*a)[size], char (*b)[size], const int count, int (*comp)(const void*, const void*)){
	if(count<=1) return;
	const int lr=count/2, rr=count;
	int ll=0, rl=count/2;
	int k=0;
	msort_inner(size, a+ll, b+ll, lr-ll, comp);
	msort_inner(size, a+rl, b+rl, rr-rl, comp);
	while(ll<lr && rl<rr){
		if(comp(a[ll], a[rl])<=0){
			memcpy(b[k], a[ll], size);
			k++; ll++;
		}else{
			memcpy(b[k], a[rl], size);
			k++; rl++;
		}
	}
	while(ll<lr){
		memcpy(b[k], a[ll], size);
		k++; ll++;
	}
	while(rl<rr){
		memcpy(b[k], a[rl], size);
		k++; rl++;
	}
	memcpy(a, b, size*count);
}

void msort(void *base, const int count, const int size, int (*comp)(const void*, const void*)){
	char (*a)[size] = (char(*)[size])base;
	char (*b)[size] = (char(*)[size])malloc(count*size);
	msort_inner(size, a, b, count, comp);
	free(b);
}

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}

int n;
int a[100001];
int b[100001];
int c[100001];
int d[200001];

void inc(int i){
	i+=100000;
	while(i<=200000){
		d[i]++;
		i+=i&-i;
	}
}

int sum(int i){
	i+=100000;
	int s=0;
	while(i>0){
		s+=d[i];
		i-=i&-i;
	}
	return s;
}

long f(int x){
	for(int i=1; i<=n; i++){
		c[i]=c[i-1]+(a[i]<=x?1:-1);
	}
	memset(d, 0, sizeof(d));
	long ans=0;
	inc(c[0]);
	for(int i=1; i<=n; i++){
		ans+=sum(c[i]-1);
		inc(c[i]);
	}
	return ans;
}

int main(void){
	n=nextint();
	for(int i=1; i<=n; i++){
		a[i]=b[i]=nextint();
	}
	msort(b+1, n, sizeof(int), comp);
	int kl=1, kr=n;
	long m = (long)n*(n+1)/4+1;
	//printf("%d\n", m);
	while(kl<=kr){
		int km=(kl+kr)/2;
		//printf("%d %d %ld\n", km, b[km], f(b[km]));
		if(f(b[km])>=m) kr=km-1; else kl=km+1;
	}
	//printf("%d %d %ld\n", kl, b[kl], f(b[kl]));
	printf("%d\n", b[kl]);
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair 
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) <<"\n"
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9;
const ll MAX = 1e5+10;
const ll inf = 1e18+7;

int main(){
	fastio;
	ll n,a,b,cont=0;
	cin>>n;
	bool go = false;
	f(i,0,n){
		cin>>a>>b;
		if(a==b) cont++;
		else cont=0;
		if(cont==3) go = true;
	}
	if(go) cout<<"Yes\n";
	else cout<<"No\n";
    return 0; 
}

Measured memory_bytes: 3640
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long
 
#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)
 
#define sl          cout<<' '
#define ps          printf(" ")
 
#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))
 
#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())
 
#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound
 
#define MX1     100000
#define MX2     1000000
#define MX3     10000
#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli dp[1<<15];

lli Power(lli a,lli b)
{
    lli result=1;
 
    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }
 
        b=b>>1;
        a=(a*a)%mod;
    }
 
 return result;
}
 
int main()
{
    opt;
    
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli A,B,C,D;
    cin>>A>>B>>C>>D;
    
    lli i;
    map<lli,lli>M;
    map<lli,lli>:: itr it;
    
    for(i=A;i<B;i++)
    {
        M[i]++;
    }
    
    
    for(i=C;i<D;i++)
    {
        M[i]++;
    }
    
    lli cnt=0;
    for(it=M.begin();it!=M.end();it++)
    {
        if(it->S==2)
        {
            cnt++;
        }
    }
    
    cout<<cnt;
    
 
 return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int ans = 0;
    int cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] <= a) {
            cnt1++;
        }
        else if (a < p[i] && p[i] <= b) {
            cnt2++;
        }
        else {
            cnt3++;
        }
    }
    
    cout << min(cnt1, min(cnt2, cnt3));
    return 0;
}

 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   string s;
   cin >> s;
   if(s[1] == 'B') s[1] = 'R';
   else s[1] = 'B';
   cout << s;
   return 0;
} 

Measured memory_bytes: 3652
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>
using ll = long long;
using namespace std;


int main() {
    vector<int> A(20, 0);
    vector<int> B(20, 0);
    vector<int> C(19, 0);
    int N;
    int sum = 0;
    
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        A[i]--;
    }
    for(int i = 0; i < N; i++){
        cin >> B[i];
    }
    for(int i = 0; i < N-1; i++){
        cin >> C[i];
    }
    
    for(int i = 0; i < N; i++){
        sum += B[A[i]];
        if(i >= 1 && A[i] == A[i-1] + 1){
            sum += C[A[i]-1];
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <string.h>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
#define int long long
signed main() {
	set<int> s;
	set<int> ss;
	int n;
	int a[200004];
	int tmp;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &tmp);
		a[tmp] = i;
	}
	long long ans = 0;
	s.insert(0); s.insert(n + 1);
	ss.insert(0); ss.insert(-n - 1);
	int start, end;
	int now;
	int x, y, z;

	for (int i = 1; i <= n; i++) {
		now = a[i];
		end = *(s.upper_bound(now));
		start = -(*(ss.upper_bound(-now)));
		x = end - start - 1;
		y = end - now - 1;
		z = now - start - 1;
		ans += i*((x*x + x) / 2 - (y*y + y) / 2 - (z*z + z) / 2);
		s.insert(now);
		ss.insert(-now);
	}
	cout << ans;
}


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

static const int N = 1000;

int lcs(string X, string Y)
{
    int c[N+1][N+1] ;
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    X = " " + X ;
    Y = " " + Y ;
    for (int i = 0; i <= m; i++) c[i][0] = 0;
    for (int j = 0; j <= n; j++) c[0][j] = 0;

    for (int i = 1 ; i <= m; i++)
    {
        for (int j = 1 ; j <= n ; j++)
        {
            if (X[i] == Y[j])
            {
                c[i][j] = c[i-1][j-1] + 1 ;
            }
            else
            {
                c[i][j] = max(c[i][j-1], c[i-1][j]) ;
            }
            maxl = max(maxl, c[i][j]) ;
        }
    }
    return maxl ;

}

int main()
{
    string s1, s2 ;
    int n; cin >> n;
    for (int i = 0; i < n ; i++)
    {
        cin >> s1 >> s2 ;
        cout << lcs(s1, s2) << endl ;
    }
    return 0 ;
}


Measured memory_bytes: 7064
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);    
#define f(i,j,k)  for(int i=j;i<k;i++)
#define fr(i,j,k) for(int i<=k-1;i>=j;i--)
#define ll long long
#define ld long double
#define pb push_back
#define all(x) x.begin(),x.end()

using namespace std;

int main()
{
	fio
	int TC;
	//cin>>TC;
	TC=1;
	while(TC--)
	{
		int k,a,b;
		cin>>k>>a>>b;
		bool found=false;
		for(int i=a;i<=b;i++)
			if(i%k==0)
			{
				found=true;
				break;
			} 
		found?cout<<"OK":cout<<"NG";
		cout<<endl;
		
	}
	return 0;
}


Measured memory_bytes: 3648
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a,b;
        a=sc.nextInt();
        b=sc.nextInt();
        if(a==b){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

    int n;
    cin >> n;

    vector <string> w(n);
    for(int i = 0; i < n; i++){
        cin >> w[i];
    }

    bool flag = true;
    
    for(int i = 0; i < n - 1; i++){
        int l = w[i].length();
        if (w[i][l-1] != w[i+1][0]) {
            flag = false;
            break;
        }
    }

    sort(w.begin(), w.end());
    for(int i = 0; i < n-1; i++){
        if (w[i] == w[i+1]) {
            flag = false;
            break;
        }
    }
    
    if (flag == true) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n = input_n
l = input_a
n = n - 1
cnt = 0
n.times do |i|
  ((i + 1)..n).each do |j|
    ((j + 1)..n).each do |k|
      next if l[i] == l[j] || l[j] == l[k] || l[i] == l[k]
      len = l[i] + l[j] + l[k]
      max = [l[i], l[j], l[k]].max
      rest = len - max
      if max < rest
        cnt += 1
      end
    end
  end
end

puts cnt


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
template<class num> inline void rd(num &x) {
	char c;
	while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar()))
		x = (x << 3) + (x << 1) + c - '0';
	if(neg) x = -x;
}
const int N = 2012345;

int main (void) {
	int n, m;
	rd(n); rd(m);
	string s, t; cin >> s >> t;
	ll ans = ll(n) / __gcd(n, m) * m;
	map <ll, char> f;
	ll p = 0;
	for (int i = 0; i < s.size(); i++) {
		f[p] = s[i];
		p += ans / n;
	}
	p = 0;
	for (int i = 0; i < m; i++) {
		if (f.count(p) and f[p] != t[i]) {
			printf("-1\n");
			return 0;
		}
		p += ans / m;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

const int MAXX = 1299800;
bool isPrime[MAXX] = {false};
vector<int> PS;
void sieve(){
    for(int i=2;i<MAXX;i++) isPrime[i] = true;
    for(int i=2;i*i < MAXX;i++){
        if(!isPrime[i]) continue;
        for(int j=i*i;j<MAXX;j+=i){
            isPrime[j] = false;
        }
    }
    rep(i,MAXX) if(isPrime[i]) PS.push_back(i);
}

int main(){
    sieve();
    while(true){
        int n;
        cin >> n;
        if(n==0)break;
        if(isPrime[n]){
            cout << 0 << endl;
        }else{
            int ind = lower_bound(all(PS),n) - PS.begin();
            cout << PS[ind] - PS[ind-1] << endl;
        }
    }
    return 0;
}

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

int main() {
  int a,b;
  double doublea,doubleb;
  
  cin >>a >>b;
  cout << a/b <<" "<<a%b<<" ";
  doublea=a;
  doubleb=b;
  cout << fixed<<setprecision(5)<<doublea/doubleb<<endl;
	return 0;
}



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

int main(int argc, const char * argv[]) {

    double a,b,C;
    double S,L,h;
    
    scanf("%lf %lf %lf", &a, &b, &C);
    
    S = 0.5 * a * b * sin(C * M_PI/180);
    L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C * M_PI/180));
    h = b * sin(C * M_PI/180);
    
    printf("%f %f %f\n", S, L, h);
    return 0;
}



Measured memory_bytes: 2056
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int h, w;
	string s;
	cin >> h >> w;
	rep(i, h) {
		cin >> s;
		rep(i, 2) {
			cout << s << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative ((<$>))
import qualified Control.Monad as Monad (when, replicateM)

main = do
    s <- getLine
    Monad.when (s /= "-") $ do
        m <- read <$> getLine
        hs <- map read <$> Monad.replicateM m getLine
        putStrLn $ repeatShuffle hs s
        main

repeatShuffle :: [Int] -> String -> String
repeatShuffle [] s     = s
repeatShuffle (x:xs) s = repeatShuffle xs $ shuffle x s

shuffle :: Int -> String -> String
shuffle h s = s2 ++ s1
    where (s1,s2) = splitAt h s

Measured memory_bytes: 3948
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
*/

typedef pair<int, int> P;


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

	int h, w;
	cin >> h >> w;
	vector<vector<char>> a(h, vector<char>(w));

	queue<P> que;

	rep(i, h) {
		rep(j, w) {
			cin >> a[i][j];
			if (a[i][j] == '#') {
				que.push({ i, j });
			}
		}
	}

	int ans = 0;

	while (1) {
		if (que.empty()) {
			cout << ans - 1 << endl;
			return 0;
		}

		vector<pair<int, int>> bpos;

		ans++;
		while (!que.empty()) {
			P p = que.front(); que.pop();
			// 移動4方向をループ
			for (int k = 0; k < 4; k++) {
				int nx = p.first + dx[k], ny = p.second + dy[k];

				if (nx >= 0 && nx < h && ny >= 0 && ny < w) {
					if (a[nx][ny] == '.') {
						bpos.push_back({ nx, ny });
						a[nx][ny] = '#';
					}
				}
			}
		}

		rep(i, (int)bpos.size()) {
			que.push({ bpos[i].first, bpos[i].second });
		}
	}

	return 0;
}

Measured memory_bytes: 10228
#include <iostream>
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define li long ll
#define pp pair<ll, ll>
#define lb lower_bound
#define ub upper_bound
#define mk make_pair
#define pb push_back
#define llp(i, x, n) for (ll i = x; i < n; i++)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define fr first
#define ss second
#define mod 1000000007
using namespace std;
int main()
{
	fast;
    string s,t;
    cin>>s>>t;
    int m=INT_MAX;
    int n=t.size();
    for(int i=0;i<=s.size()-n;i++)
    {
    	int c=0;
    	for(int j=0;j<t.size();j++)
    	{
    		if(s[i+j]==t[j])
    		c++;
    	}
    	m=min(m,n-c);
    }
    cout<<m<<endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
#include <math.h>
using namespace std;
#define MAXSIZE 100005
#define PI 3.141592653589793
#define MOD_CONST 1000000007
typedef long long int lli;

int main(){
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for(int i = 0; i < 3; ++i){
    ans += s[i] == t[i];
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
 
public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        this.Input = Reader.ReadLine();
        string ans = "Second";
        if(GetAns(this.Input)) {
            ans = "First";
        }

        Console.WriteLine(ans);
    }

    private string Input;
    private Dictionary<string, bool> dic = new Dictionary<string, bool>();

    private bool GetAns(String text) {
        if(text.Length % 2 == 0) {
            if(text.First() ==  text.Last()) {
                return true;
            } else {
                return false;
            }
        } else {
            if(text.First() ==  text.Last()) {
                return false;
            } else {
                return true;
            }
        }
    }

 
 
    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"


acba


";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 3288
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define mod 1000000007
#define INF 10000000
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
bool solve(int );
string s1, s2, s3, s4;
string s;
int main() {
	cin >> s;
	for (int i = 0; i < 10; i++)s.push_back('p');
	s1 = "dreamer";
	s2 = "dream";
	s3 = "erase";
	s4 = "eraser";
	bool ans = solve(0);
	if (ans == true)cout << "YES" << endl;
	else cout << "NO"<<endl;
	return 0;
}
bool solve(int n) {
	//cout << "call " << n << endl;
	if (n == s.size()-10) {
	//	cout << n << " hazitrue" << endl;
		return true;
		
	}
	bool ans = false;
	bool flag = true;
	for (int i = 0; i < s1.size(); i++) {
		if (s[n + i] != s1[i])flag = false;
	}
	if (flag) {
		ans = ans || solve(n + s1.size());
	}
	flag = true;
	for (int i = 0; i < s2.size(); i++) {
		if (s[n + i] != s2[i])flag = false;
	}
	if (flag) {
		ans = ans || solve(n + s2.size());
	}
	flag = true;
	for (int i = 0; i < s3.size(); i++) {
		if (s[n + i] != s3[i])flag = false;
	}
	if (flag) {
		ans = ans || solve(n + s3.size());
	}
	flag = true;
	for (int i = 0; i < s4.size(); i++) {
		if (s[n + i] != s4[i])flag = false;
	}
	if (flag) {
		ans = ans || solve(n + s4.size());
	}
	else {
	//	cout << n << " " << ans << endl;
		return ans;
	}
}

Measured memory_bytes: 1536
#include <stdio.h>

int main(void){
  int N;
  scanf("%d",&N);

  int ans = 0;
  while(N > 0){
    ans += N%10;
    N /= 10;
  }

  if(ans == 1) printf("10\n");
  else printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	int a,b;
	int y=0;
	int x=0;
	while(true){
		cin>>a>>b;
		if(a+b==0) break;
		if(y!=0) cout<<endl;
		for(int i=a;i<=b;i++){
			if((i%4==0&&i%100!=0)||i%400==0){
				printf("%d\n",i);
				x++;
			}
			if(i==b&&x==0){
				printf("%s\n","NA");
			}
		}
		x=0;
		y++;
	}
}

Measured memory_bytes: 3212
#include <algorithm>
#include <iostream>
#include <cstring>
#include <bitset>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>

int main()
{
    std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
    int n = 0, a = 0, b = 0;
    std::cin >> n >> a >> b;
    std::cout << std::min(a * n, b) << std::endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<ll> A(200005);
  rep(i,N) cin >> A[i];
  vector<ll> S(200005);
  S[0] = A[0];
  for(int i = 0; i < N-1; i++){
    S[i+1] = S[i] + A[i+1]; 
  }
  ll sum = 0;
  ll mod = 1000000000+7;
  rep(i,N-1){
    ll a = (S[N-1]-S[i])%mod;
    sum += A[i]*a;
    sum %= mod;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 6424
#include <cstdio>

int gcd(int x1, int x2){
  if(x1 == 0) { return x2; }
  if(x2 == 0) { return x1; }
  if(x1 > x2){
    return gcd(x1 % x2, x2);
  } else {
    return gcd(x1, x2 % x1);
  }
}

int lcm(int x1, int x2){
  return x1 * x2 / gcd(x1, x2);
}

int main(){
  int n;
  int A[10];
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  int result = A[0];
  for(int i = 1; i < n; i++){
    result = lcm(result, A[i]);
  }
  printf("%d\n", result);
}

Measured memory_bytes: 1012
import java.util.Scanner;

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 d = sc.nextInt();
		int e = sc.nextInt();
		
		int ans = 0;
		if(a < 0) {
			ans += -a * c;
			ans += d;
			ans += e * b;
		}else {
			ans += e * (b - a);
		}
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 26060
/**
 *    SATAR ALLAH
 *
**/
#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

int main()
{

    int n;

    scanf("%d",&n);

    printf("%d",n/3);
    return 0;
}


Measured memory_bytes: 256
N=int(input())
C=[0]*(N-1)
S=[0]*(N-1)
F=[0]*(N-1)
for i in range(N-1):
  C[i], S[i], F[i]=map(int, input().split())
  
for i in range(N-1):
  t=S[i]+C[i]
  for j in range(i+1, N-1):
    if t<S[j]:
      t=S[j]
    else:
      if t%F[j]>0:
        t=(1+t//F[j])*F[j]
    t+=C[j]      
  print(t)
print(0)

Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int K = scan.nextInt();
		int N = scan.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = scan.nextInt();
		}

		Arrays.sort(A);

		int max = K - A[N-1] + A[0];

		for (int i = 1; i < N; i++) {
			if (A[i]-A[i-1] > max) {
				max = A[i]-A[i-1];
			}
		}

		System.out.println(K-max);

	}

}

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

const int MAX = 100000;
const int NIL = -1;

struct Node
{
	int p; //親
	int l;  //最も左の子供
	int r;  //すぐ右の兄弟
};

Node T[MAX];
int D[MAX];

void setDepth(int u, int p)
{
	D[u] = p;
	if (T[u].r != NIL)
	{
		setDepth(T[u].r, p);
	}

	if (T[u].l != NIL)
	{
		setDepth(T[u].l, p+1);
	}
}

void print(int u)
{
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].p == NIL)
	{
		cout << "root, ";
	}
	else if (T[u].l == NIL)
	{
		cout << "leaf, ";
	}
	else
	{
		cout << "internal node, ";
	}

	cout << "[";

	for (int i = 0, c = T[u].l; c != NIL; ++i, c = T[c].r)
	{
		if (i)
		{
			cout << ", ";
		}

		cout << c;
	}

	cout << "]" << endl;
}

int main()
{
	int n,u,d,c,l,r;
	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		T[i].p = T[i].l = T[i].r = NIL;
	}

	for (int i = 0; i < n; ++i)
	{
		cin >> u >> d;
		for (int j = 0; j < d; ++j)
		{
			cin >> c;
			if (j == 0)
			{
				T[u].l = c;
			}
			else
			{
				T[l].r = c;
			}
			l = c;
			T[c].p = u;
		}
	}

	for (int i = 0; i < n; ++i)
	{
		if (T[i].p == NIL)
		{
			r = i;
		}
	}

	setDepth(r,0);

	for (int i = 0; i < n; ++i)
	{
		print(i);
	}

	return 0;
}


Measured memory_bytes: 7744
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  string n;
  cin >> n;
  rep(i, n.size()) {
    if (n[i] == '1') cout << '9';
    else cout << '1';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var HN = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            var H = HN[0];
            var A = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            Console.WriteLine(H<=A.Sum(n=>n)?"Yes":"No");
        }
    }
}


Measured memory_bytes: 17760
#include<bits/stdc++.h>
using namespace std;
#define int long long int
vector<int> v;
int dp[15][10][2][2][2];
int solve(int ind, int prev, int flag, int constraint, int start)
{
    if(ind >= v.size())
    {
        return flag;
    }

    if(dp[ind][prev][flag][constraint][start] != -1)
        return dp[ind][prev][flag][constraint][start];

    int ans = 0;
    if(constraint)
    {
        if(start == 0)
        {
            ans += solve(ind+1, 0, 0, 0, 0);
            for(int i=1; i<=v[ind]; i++)
            {
                ans += solve(ind+1, i, 1, (v[ind] == i)?1:0, 1);
            }
        }
        else
        {
            for(int i=0; i<=v[ind]; i++)
            {
                ans += solve(ind+1, i, (abs(prev - i)<=1)?flag & 1:0, (v[ind] == i)?1:0, 1);
            }
        }
    }
    else
    {
        if(start == 0)
        {
            ans += solve(ind+1, 0, 0, 0, 0);
            for(int i=1; i<10; i++)
            {
                ans += solve(ind+1, i, 1, 0, 1);
            }
        }
        else
        {
            for(int i=0; i<=9; i++)
            {
                ans += solve(ind+1, i, (abs(prev - i)<=1)?flag & 1:0, 0, 1);
            }
        }
    }

    return dp[ind][prev][flag][constraint][start] = ans;
}

int fun(int a)
{
    v.clear();
    while(a)
    {
        v.push_back(a%10);
        a = a / 10;
    }
    reverse(v.begin(), v.end());
    memset(dp, -1, sizeof dp);
    return solve(0, 0, 0, 1, 0);
}

int32_t main()
{
    int k;
    cin >> k;

    // cout << "asdasd " << fun(3234566667) << endl;
    // for(int i=1; i<=50; i++)
    // {
    //     cout << i << " "<< fun(i) << endl;
    // }
    // if(k <= 9)
    // {
    //     cout << k << endl;
    //     return 0;
    // }

    // k -= 9;
    // cout << k << endl;
    int l = 1, r = 3234566667 + 1, mid;
    while(r - l > 1)
    {
        mid = (l+r) / 2;
        // cout << mid << " " << fun(mid) << endl;
        if(fun(mid) >= k)
        {
            r = mid;
        }
        else
        {
            l = mid+1;
        }
    }

    if(fun(l) == k)
    {
        cout << l << endl;
    }
    else
    {
        cout << r << endl;
    }
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    lli K,N;
    lli A0, Aprev, Anow;
    lli max = 0;
    cin >> K >> N;
    cin >> A0;
    for(lli i = 1; i < N; ++i){
        cin >> Anow;
        max = (max > Anow-Aprev) ? max : Anow-Aprev;
        Aprev = Anow;
    }
    max = (max > K+A0-Anow) ? max :  K+A0-Anow;

    cout << K-max << "\n";

    return 0;    
}

Measured memory_bytes: 256
L = input()

MOD = 10**9+7

ans = 0

n = len(L)
dp = [[0] * 2 for _ in range(n)]
dp[0][0] = 2
dp[0][1] = 1

for i in range(n-1):
    if L[i+1] == '1':
        dp[i+1][0] = dp[i][0] * 2
        dp[i+1][1] = dp[i][0] + dp[i][1] * 3
    else:
        dp[i+1][0] = dp[i][0]
        dp[i+1][1] = dp[i][1] * 3
    dp[i+1][0] %= MOD
    dp[i+1][1] %= MOD

print((dp[n-1][0]+dp[n-1][1])%MOD)


Measured memory_bytes: 54364
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int main(void){
    
    int n;
    cin >> n;
    
    vector<pair<int,int>> vpii;
    
    for(int i = 0; i < n; i++){
        int l,r;
        cin >> l >> r;
        
        vpii.push_back({l,r});
        
    }
    
    vpii.push_back({1000000,1000000});
    
    sort(vpii.begin(),vpii.end());
    
    int answer = 0;
    
    for(int i = 0; i < vpii.size()-1; i++){
        if(vpii[i].second >= vpii[i+1].first){
            answer += vpii[i+1].first - vpii[i].first + 1;
        }else{
            answer += vpii[i].second - vpii[i].first + 1;
        }
    }
    
    cout << answer << endl;
    
}


Measured memory_bytes: 256
def main():
    X,Y = map(int,input().split())
    flag = False
    for i in range(X+1):
        j = X-i
        if i*2+j*4 == Y:
            flag = True
            break
    if flag:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    main()

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

int main(){
  string str;
  cin >> str;
  int a=0;
  while(str[a]){
     a++;}
  
  int b=0;
  int res;
  
	for (int i = 0; i < a; i++) {
      int p,q;
      p = str[i]-48;
      q = i%2;
      if(p == q){
      	b++;
      }
    }

    
    
     res=min(b,a-b);
  cout <<res<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>

#define _USE_MATH_DEFINES
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999;
#define atcoder 1000000007;

using namespace std;

int main() {
	long long int x, ans = 0;

	cin >> x;
	if (x % 11 == 0) {
		ans = 2 * (x / 11);
	}
	else {
		ans = 2 * (x / 11);
		if (x % 11 <= 6)
			ans += 1;
		else
			ans += 2;
		}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    long long  i,n;
    long long rslt=1;

    scanf("%lld",&n);
    for(i=1;i<=n;i++){
            rslt*=i;

    }
    printf("%lld\n",rslt);
    return 0;
}

Measured memory_bytes: 596
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        long sum = 0;
        for (int i = 0; i < n; i++)
            a[i] = Integer.parseInt(sc.next());
        Arrays.sort(a);
        for (int i: a)
            sum += i;
        System.out.print(a[0] + " ");
        System.out.print(a[n-1] + " ");
        System.out.println(sum);
    }
}


Measured memory_bytes: 40460