akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <cmath>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef multiset<int> MS;
typedef queue<int> Q;

int keta(int n){
    int ret = 0;
    while(n){
        n /= 10;
        ret++;
    }
    return ret;
}

int main(){
    ll n; cin>>n;
    int ans = 1000;
    for(int i=1; i<=sqrt(n); i++){
        if(n%i == 0){
            ans = min(ans, max(keta(i), keta(n/i)));
        }
    }
    OUT(ans);
}

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

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)

void solve(std::string S){
    ll ans = 0;
    rep(i, 4){
        if(S.at(i) == '+')
            ans ++;
        else 
            ans --;
    }
    cout << ans << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main(){
  int D;
  cin>>D;
  int C[26];
  map<int,int>mp;
  for(int i=0;i<26;i++){
    cin>>C[i];
    if(C[i]>10){
      mp[i]++;
    }   
  }
  int S[365][26];
  for(int i=0;i<365;i++){
    for(int j=0;j<26;j++){
      cin>>S[i][j];
    }
  }
  
  int flag=1;
  int temp=0;
  int now=0;
  int maxans=0;
  while(temp<365){
    maxans=0;
    now=0;
    if((temp/26)%2 == 1){
      cout<<temp%26+1<<endl;
      temp++;
      continue;
    }
    for(int i=0;i<26;i++){
      if(S[temp][i]>maxans){
        now=i;
        maxans=S[temp][i];
      }
    }
    cout<<now+1<<endl;
    temp++;
  }
  return 0;
}



Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Program
{
    #region Standard I/O
    readonly TextReader input;
    readonly TextWriter output;

    X[] ReadLine<X>(Func<string, X> func)
    {
        return input.ReadLine().Split(' ').Select(func).ToArray();
    }

    void WriteLineOne(object obj)
    {
        output.WriteLine("{0}", obj);
    }

    void WriteLineMany(params object[] objects)
    {
        output.WriteLine(string.Join(" ", objects.Select(obj => obj.ToString())));
    }
    #endregion

    long x, a, b;

    void Read()
    {
        var l = ReadLine(long.Parse);
        x = l[0];
        a = l[1];
        b = l[2];
    }

    string Solve()
    {
        if (b - a <= 0)
        {
            return "delicious";
        }
        else if (b - a <= x)
        {
            return "safe";
        }
        return "dangerous";
    }

    public void Run()
    {
        Read();
        WriteLineOne(Solve());
    }

    public Program(TextReader input, TextWriter output)
    {
        this.input = input;
        this.output = output;
    }

    public static void Main(string[] args)
    {
        new Program(Console.In, Console.Out).Run();
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
using namespace std;

int main(void) {
	int a, b;
	cin >> a >> b;
	if (a*b%2 == 0)cout << "Even" << endl;
	else cout << "Odd" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n;
    cin>>n;
    ll sum=0;
    vector<ll> a;
    bool f=true;
    rep(i,n){
      ll k;
      cin>>k;
      if(k%2)f=false;

    }

   if(f){
       cout<<"second"<<endl;
   }else{
       cout<<"first"<<endl;
   }

    return 0;
}


Measured memory_bytes: 256
function Main(arg)
{
  var N = arg.split("\n")[0]+"";

  if (N.startsWith("keyence") || N.endsWith("keyence")) {
    console.log("YES");
    return;
  }
  else {
    for (var i = 1; i <= 7; i++){
      if (N.startsWith("keyence".slice(0, i)) && N.endsWith("keyence".slice(i))) {
        console.log("YES");
    	return;
      }
    }
  }

  console.log("NO");
  return;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>

using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    vector<int> v(n + 1, 0);
    for(int i = 0; i < n; i++){
        long long int x;
        cin >> x;
        if(x <= n){
            v[x]++;
        }else{
            ans++;
        }
    }
    for(int i = 0; i < n + 1; i++){
        if(v[i] > i){
            ans += v[i] - i;
        }
        else if(v[i] < i){
            ans += v[i];
        }
    }
    cout << ans;
}

Measured memory_bytes: 640
#include<cstdio>

int main(void) {
    int n,m;
    scanf("%d%d",&n,&m);
    int a=1;
    for(int i=0; i<m; i++)
        a*=2;
    printf("%d\n", (1900*m + 100*(n-m))*a);

    return 0;
}

Measured memory_bytes: 128
P,S=print,sorted
n,k,*t=map(int,open(i:=0).read().split())
l=S([a-1,i:=i+1]for a in t)[::-1]
_,r=zip(*l)
while k:
 *_,b=r;k-=1
 for t in S(l)[::-1]:
  if t[1]-b:t[t[0]<1<exit(P(-1))]-=1;r+=t[1],
P(len(r),*r)

Measured memory_bytes: 9420
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];

    int sum = 0;
    for(int i = 0; i < n; i++) sum += A[i];

    int num = 0;
    for(int i = 0; i < n; i++){
        if(A[i] >= (sum+(4*m-1)) / (4*m)) num++;
    }

    if(num >= m){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	vector<int> hist(n + 1);
	for(int i = 0; i < n; ++i){ ++hist[a[i]]; }
	int lo = n, hi = 0;
	for(int i = 0; i <= n; ++i){
		if(hist[i] != 0){
			lo = min(lo, i);
			hi = max(hi, i);
		}
	}
	bool answer = true;
	if(lo != (hi + 1) / 2){ answer = false; }
	if(hi % 2 == 0){
		if(hist[lo] != 1){ answer = false; }
	}else{
		if(hist[lo] != 2){ answer = false; }
	}
	for(int i = lo + 1; i <= hi; ++i){
		if(hist[i] < 2){ answer = false; }
	}
	cout << (answer ? "Possible" : "Impossible") << endl;
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int i,j,first,last,groups,counter,num_people;
    cin >> groups;

    for(i = 1; i <= groups; i++) {
        cin >> first >> last;
        counter += last - first + 1;
    }

    cout << counter << endl;
       
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
using namespace std;
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 long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n,k,i,t,u;
    cin>>n>>k;
    set<int> s;
    rep(i,k){
        cin>>t;
        s.insert(t);
    }
    for(i=n;;i++){
        t=i;
        bool ch=true;
        while(t>0){
            u=t%10;
            t/=10;
            if(s.find(u)!=s.end()){
                ch=false;
                break;
            }
        }
        if(ch){
            cout<<i<<endl;
            return 0;
        }
    }


//////////////////////////////////////////////////////
return 0;}


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

pre_list = list(map(lambda s: int(s) - 1, input().split()))
in_list = list(map(lambda s: int(s) - 1, input().split()))
post_list = []


def f(n, left, right):
    num = pre_list[n]

    if right - left == 1:
        post_list.append(num)
        return
        
    idx = in_list.index(num)
    n += 1
    if idx - left >= 1:
        f(n, left, idx)
    n += idx - left
    if right - idx - 1 >= 1:
        f(n, idx+1, right)
    post_list.append(num)


f(0, 0, N)
print(' '.join(map(lambda x: str(x+1), post_list)))


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> vec (N);
  for(int i = 0;i < N;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(), vec.end());
  int a = 0;
  for(int i = 0;i < K;i++){
    a = a + vec.at(i);
  }
  cout << a << endl;
}

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

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

  #define lp(start,finish) for(int i=start; i<finish; i++)
  #define read freopen("input.txt","r",stdin);
  #define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

int main(){
	//read
	int group,sum=0,startSeat,endSeat;
	cin >> group;
	while(group--){
		cin >> startSeat >> endSeat;
		sum += (endSeat - startSeat) + 1;
	}	
	cout  << sum << endl;
	return 0;
}

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

using ll = long long;

//constant
const ll MOD = 1e+9 + 7;
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }


template<typename Int, Int mod>
class ModInt {
public:
	static const Int Mod = mod;
	Int x;
	ModInt() { x = 0; }
	ModInt(int a) { Int t = a % mod; if (t < 0) t += mod; x = t; }
	ModInt(long long a) { Int t = a % mod; if (t < 0) t += mod; x = t; }
	Int get() const { return x; }

	ModInt& operator += (ModInt that) { if ((x += that.x) >= mod) x -= mod; return *this; }
	ModInt& operator -= (ModInt that) { if ((x += mod - that.x) >= mod) x -= mod; return *this; }
	ModInt& operator *= (ModInt that) { x = (long long)(x)*that.x % mod; return *this; }
	bool operator == (ModInt that) const { return x == that.x; }
	ModInt operator + (ModInt that) const { return ModInt(*this) += that; }
	ModInt operator - (ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator * (ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator - () const { return ModInt(-this->x); }
	inline friend ostream& operator << (ostream& out, ModInt m) { return out << m.x; }

	ModInt power(long long k) const {
		ModInt r(1); ModInt b = *this;
		if (k <= 0) return r;
		while (k) { if (k & 1) r *= b; b *= b; k >>= 1; }
		return r;
	}
	ModInt inverse() const {
		long long a = x, b = mod, u = 1, v = 0;
		while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
		return ModInt(u);
	}
};

typedef ModInt<int, MOD> Mint;


int main(void) {

	int H, W;
	cin >> H >> W;

	vector<vector<bool>> A(H, vector<bool>(W, false));
	char tmp;
	for (auto& col : A) {
		REP(i, W) {
			cin >> tmp;
			col[i] = (tmp == '.');
		}
	}

    vector<vector<Mint>> dp(H, vector<Mint>(W));
    dp[0][0] = 1;

    REP(i, H) {
        REP(j, W) {
            if (i < H - 1 && A[i + 1][j]) dp[i + 1][j] += dp[i][j];
            if (j < W - 1 && A[i][j+1]) dp[i][j+1] += dp[i][j];
        }
    }

	cout << dp[H - 1][W - 1].get() << endl;

	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    if(n < 600) printf("8\n");
    else if(n < 800) printf("7\n");
    else if(n < 1000) printf("6\n");
    else if(n < 1200) printf("5\n");
    else if(n < 1400) printf("4\n");
    else if(n < 1600) printf("3\n");
    else if(n < 1800) printf("2\n");
    else if(n < 2000) printf("1\n");
    return 0;
}

Measured memory_bytes: 3684
N = int(input())
initial = ['M', 'A', 'R', 'C', 'H']
num = [0]*5

for i in range(N):
    S = input()
    for j in range(len(initial)):
        if S[0]==initial[j]:
            num[j] += 1
            break

ans = 0
ans += num[0]*num[1]*(num[2]+num[3]+num[4])
ans += num[0]*num[2]*(num[3]+num[4])
ans += num[0]*num[3]*num[4]
ans += num[1]*num[2]*(num[3]+num[4])
ans += num[1]*num[3]*num[4]
ans += num[2]*num[3]*num[4]

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define fLoop for(lli i = 0; i < N; i++)
main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli N;
    cin >> N;
    lli *A = new lli[N];
    lli *B = new lli[N];
    lli *C = new lli[N];
    for(lli i = 0; i < N; i++) {
    	cin >> A[i] >> B[i] >> C[i];
	}
	lli **DP = new lli*[N];
	for(lli i = 0; i < N; i++) {
		DP[i] = new lli[3];
	}
	DP[0][0] = A[0];
	DP[0][1] = B[0];
	DP[0][2] = C[0];
	for(lli i = 1; i < N; i++) {
		DP[i][0] = A[i] + max(DP[i - 1][1], DP[i - 1][2]);
		DP[i][1] = B[i] + max(DP[i - 1][2], DP[i - 1][0]);
		DP[i][2] = C[i] + max(DP[i - 1][1], DP[i - 1][0]);
	}
	cout << max(DP[N - 1][0], max(DP[N - 1][1], DP[N - 1][2])) << '\n';
	delete[] A;
	delete[] B;
	delete[] C;
	for(lli i = 0; i < N; i++) {
		delete[] DP[i];
	}
	delete[] DP;
}

Measured memory_bytes: 9520
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int N;
	ll T;
	cin >> N >> T;
	ll ans = 0;
	ll prev = 0;
	for (int i = 0; i < N; i++) {
		ll t;
		cin >> t;
		if (t <= prev) {
			ans += t + T - prev;
		}
		else {
			ans += T;
		}
		prev = t + T;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin
from collections import defaultdict, deque
import math

readline = stdin.readline


v, e, r = map(int, readline().split())

g = defaultdict(list)
for i in range(e):
    s, t, length = map(int, readline().split())
    g[s].append((length, t))
d = [float('inf')] * v
d[r] = 0
que = deque([(d[r], r)])
while que:
    du, u = que.popleft()
    for length, v in g[u]:
        if d[v] > du + length:
            d[v] = du + length
            que.append((d[v], v))
for di in d:
    print('INF' if math.isinf(di) else di)

Measured memory_bytes: 110172
#include <bits/stdc++.h>
#define FIN freopen("input/in.txt", "r", stdin)
#define FOUT freopen("output/out.txt", "w", stdout)
using namespace std;
typedef long long LL;
typedef unsigned u;
typedef unsigned long long ull;
typedef long double ld;

const int MAXN = 2e5+5;
const int MAXM = 5e6+5;
const double eps = 1e-8;
const LL MOD = 998244353;

int n, t, a;
double h[MAXN];

vector<string> ans;

struct node {
    int id;
    double x;
    bool operator < (const node &ano) const {
        return x < ano.x;
    }
} dat[MAXN];

int main() {


    cin >> n;
    cin >> t >> a;
    for (int i=1; i<=n; ++i) cin >> h[i];

    for (int i=1; i<=n; ++i) {
        dat[i].id = i;
        dat[i].x = t - 0.006 * h[i] - a;
    }
    dat[n+1].id = -1;
    dat[n+1].x = 1e19;
    sort(dat+1, dat+n+2);

    int l = 1, r = n+1;
    while (l < r-1) {
        int m = (l+r) >> 1;
        if (dat[m].x <= eps) l = m;
        else r = m;
    }
    double ansx = 1e18; int ans = -1;
    if (l > 1) {
        ansx = fabs(dat[l-1].x);
        ans = dat[l-1].id;
    }
    if (fabs(dat[l].x) < ansx) {
        ansx = fabs(dat[l].x);
        ans = dat[l].id;
    }
    if (l < n && fabs(dat[l+1].x) < ansx) ansx = dat[l+1].x, ans = dat[l+1].id;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1){
            res=(a*res)%10;
        }
        a=(a*a);
        b/=2;
    }
    return res;
}  
int n,m,k;
vector<string> s(1e6+7); 
bool valid(int x,int y){ 
    if(x<1||x>n||y<1||y>m) return false;
    if(s[x-1][y-1]=='@') return false; 
    return true;
}
int dfs(int x1,int y1,int x2,int y2){
    vector<vector<int>> dis(n+1,vector<int> (m+1,1e7));
    queue<pp > q;
    dis[x1][y1]=0;
    q.emplace(x1,y1);
    while(!q.empty()){
        x1=q.front().ff;
        y1=q.front().ss;
        q.pop(); 
        //cout<<x1<<" "<<y1<<endl;
        for(int i=1;i<=k&&x1+i<=n;i++){
            //cout<<x1+i<<" "<<y1<<endl;
            if(!valid(x1+i,y1)) break; 
            if(dis[x1+i][y1]<dis[x1][y1]+1) break;
            if(dis[x1+i][y1]==1e7){
                dis[x1+i][y1]=dis[x1][y1]+1;
                q.emplace(x1+i,y1);
            }
        }
        for(int i=1;i<=k&&x1-i>0;i++){
            if(!valid(x1-i,y1)) break; 
            if(dis[x1-i][y1]<dis[x1][y1]+1) break;
            if(dis[x1-i][y1]==1e7){
                dis[x1-i][y1]=dis[x1][y1]+1;
                q.emplace(x1-i,y1);
            }
        }
        for(int i=1;i<=k&&y1+i<=m;i++){
            if(!valid(x1,y1+i)) break; 
            if(dis[x1][y1+i]<dis[x1][y1]+1) break;
            if(dis[x1][y1+i]==1e7){
                dis[x1][y1+i]=dis[x1][y1]+1;
                q.emplace(x1,y1+i);
            }
        }
        for(int i=1;i<=k&&y1-i>0;i++){
            if(!valid(x1,y1-i)) break; 
            if(dis[x1][y1-i]<dis[x1][y1]+1) break;
            if(dis[x1][y1-i]==1e7){
                dis[x1][y1-i]=dis[x1][y1]+1;
                q.emplace(x1,y1-i);
            }
        }
    }
    if(dis[x2][y2]==1e7) return -1;
    return dis[x2][y2];
}
void solve(){
    cin>>n>>m>>k; 
    int x1,x2,y1,y2;
    //vector<vector<int>> vis(n+1,vector<int> (m+1,0));
    cin>>x1>>y1>>x2>>y2;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    cout<<dfs(x1,y1,x2,y2);
}
int main() {
	// your code goes here
	//isprime();
	//prime(); 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//int t;
	//cin>>t;
	//while(t--) 
	    solve();
	return 0; 
	
}



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

int main(){
    ll n ;
    cin >> n ;
    vector<ll> A(n) ;
    rep(i,n) cin >> A.at(i) ;
    ll q ;
    cin >> q ;
    vector<ll> ans(q+1) ;
    rep(i,n) ans.at(0) += A.at(i) ; 
    map<ll,ll> mp ;
    rep(i,n) mp[A[i]]++ ;
    vector<ll> B(q) , C(q) ;
    rep(i,q) cin >> B.at(i) >> C.at(i) ;
    rep(i,q){
        //cout <<"ans" << ans << " mp[B.at(i)]" << mp[B.at(i)] << " B.at(i)" << B.at(i) << "  C.at(i)" << C.at(i) << " " << endl ;
        ans.at(i+1) = ans.at(i) - mp[B.at(i)]*B.at(i) + mp[B.at(i)]*C.at(i) ;
        cout << ans.at(i+1) << endl ;
        mp[C.at(i)] += mp[B.at(i)] ;
        mp[B.at(i)] = 0 ;
    }
}

 

Measured memory_bytes: 12228
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	char S[3000], T[3000];
	scanf("%s", S);
	int N = strlen(S);
	scanf("%s", T);
	int M = strlen(T);

	short dp[3001][3001];
	dp[0][0] = 0;
	rep1(i, N) dp[i][0] = 0;
	rep1(j, M) dp[0][j] = 0;
	rep(i, N) {
		rep(j, M) {
			dp[i + 1][j + 1] = (S[i] == T[j] ? dp[i][j] + 1 : max(dp[i][j + 1], dp[i + 1][j]));
		}
	}
	char kotae[3000];
	int k = dp[N][M];
	int i = N, j = M;
	while (k > 0) {
		while (i > 0 && dp[i - 1][j] == dp[i][j]) i--;
		while (j > 0 && dp[i][j - 1] == dp[i][j]) j--;
		i--;
		j--;
		kotae[--k] = S[i];
	}
	fwrite(kotae, 1, dp[N][M], stdout);

	Would you please return 0;
}

Measured memory_bytes: 17792
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long m = sc.nextLong();
        long n = sc.nextLong();
        System.out.println(lcm(m, n));
    }
    
    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
    
    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MX = 120000;
int was[MX];
int cl[MX];
int vv[MX];
int vk[MX];
vector<pair<int, int> > ed;
vector<int> eds[MX];

int dfs1(int v) {
	was[v] = 1;
	for (int u: eds[v]) {
		if (was[u])
			continue;
		cl[v] = max(cl[v], dfs1(u) - 1);
	}
	return cl[v];
}

void dfs2(int v) {
	was[v] = 1;
	for (int u: eds[v]) {
		if (was[u])
			continue;
		cl[u] = max(cl[u], cl[v] - 1);
		dfs2(u);
	}
}
int n;
int k;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		cl[i] = -MX;
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		--a, --b;
		ed.push_back(make_pair(a, b));
		eds[a].push_back(b);
		eds[b].push_back(a);
	}
	scanf("%d", &k);
	for (int i = 0; i < k; ++i) {
		int v, k1;
		scanf("%d%d", &v, &k1);
		--v;
		vv[i] = v;
		vk[i] = k1;
		cl[v] = k1;
	}
	dfs1(0);
	memset(was, 0, sizeof(was));
	dfs2(0);
	for (int i = 0; i < k; ++i) {
		if (cl[vv[i]] != vk[i]) {
			cout << "No\n";
			return 0;
		}
	}
	for (int i = 0; i < ed.size(); ++i) {
		int a, b;
		tie(a, b) = ed[i];
		if (abs(cl[a] - cl[b]) != 1) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	for (int i = 0; i < n; ++i)
		cout << cl[i] << "\n";
	return 0;
}




Measured memory_bytes: 11764
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int nowp,ans[10000];
char ch;
bool check(int x)
{
	printf("? ");
	for(int i=1;i<nowp;++i)
		printf("%d",ans[i]);
	printf("%d",x);
	for(int i=1;i<=12-nowp;++i)
		printf("0");
	printf("\n");
	fflush(stdout);
	while(ch=getchar(),ch!='Y'&&ch!='N');
	if(ch=='Y') return 1;
	else return 0;
}
bool check2()
{
	printf("? ");
	for(int i=1;i<=nowp;++i)
		printf("%d",ans[i]);
	printf("\n");
	fflush(stdout);
	while(ch=getchar(),ch!='Y'&&ch!='N');
	if(ch=='Y') 
	{
		if(ans[nowp]!=9)
			return 1;
		else
		{
			printf("? ");
			for(int i=1;i<=nowp;++i)
				printf("%d",ans[i]);
			for(int i=1;i<=12-nowp;++i)
				printf("0");
			printf("\n");
			fflush(stdout);
			while(ch=getchar(),ch!='Y'&&ch!='N');
			if(ch=='Y') return 1;
			else 
			{
				ans[nowp]++;
				return 0;
			}
		}
	}
	else return 0;
	
}
bool check3(int x,int p)
{
	printf("? ");
	for(int i=1;i<nowp;++i)
		printf("%d",ans[i]);
	printf("%d",x);
	for(int i=1;i<=p;++i)
		printf("0");
	printf("\n");
	fflush(stdout);
	while(ch=getchar(),ch!='Y'&&ch!='N');
	if(ch=='Y') return 1;
	else return 0;
	
}
int main()
{
	nowp=1;
	while(1)
	{
		int l=-1,r=9;
		if(nowp==1) l=0;
		while(l<r-1)
		{
			int mid=(l+r)/2;
			if(check(mid)) r=mid;
			else l=mid;
		}
		ans[nowp]=r;
			if(check2())
			{
				if(ans[nowp]<9)
				{
					int t=ans[nowp]+1;
					int now=0;
					while(1)
					{
						if(check3(t,now))
						{
							nowp+=now;
							break;
						}
						now++;
					}
				}
				else
				{
					int t=1;
					int now=1;	
					while(1)
					{
					if(!check3(t,now))
						{
							nowp+=(now-1);
							break;
						}
						now++;
					}
				}
				break;
			}
			else
			{
				ans[nowp]--;
			}
		nowp++;
	}
	printf("! ");
	for(int i=1;i<=nowp;++i)printf("%d",ans[i]);
	return 0;
}

Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

 class Main{

	public static void main(String[] args) throws IOException {
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));		

		int n = Integer.parseInt(br.readLine());
		int[] in = new int[n];
		int max = Integer.MIN_VALUE;
		int mini = 0;
		int maxj=0;
		boolean con=false;
		
		for (int i = 0; i < n; i++)
			in[i] = Integer.parseInt(br.readLine());
		
		for (int i = 0; i < n - 1; i++) {
			if (in[i] > in[mini])continue;
                           mini=i;
			for (int j = i + 1; j < n; j++){
				
				if(max+in[i]<in[j]){
					max=in[j]-in[i];
					mini=i;
					maxj=j;
					con=false;
				}
			}con=true;
		}
		System.out.println(max);
	}}

Measured memory_bytes: 37656
#include<iostream>
#include<vector>
#include<queue>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const int INF = 1e9;


int main(){
    int h,w;
    cin >> h >> w;
    int si,sj;
    cin >> si >> sj;
    int ti,tj;
    cin >> ti >> tj;
    si--;sj--;ti--;tj--;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<vector<int>> dist(h,vector<int>(w,INF));
    deque<P> q;
    dist[si][sj] = 0;
    q.emplace_back(si,sj);

    while(!q.empty()){
        int i = q.front().first;
        int j = q.front().second;
        int d = dist[i][j];
        q.pop_front();
        if(dist[i][j] != d)continue;
        rep(v,4){
            int ni = i + di[v];
            int nj = j + dj[v];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w)continue;
            if(s[ni][nj] == '#')continue;
            if(dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            q.emplace_front(ni,nj);
        }

        for(int ei = -2;ei <= 2;ei++){
            for(int ej = -2;ej <= 2;ej++){
                int ni = i + ei;
                int nj = j + ej;
                if(ni < 0 || ni >= h || nj < 0 || nj >= w)continue;
                if(s[ni][nj] == '#')continue;
                if(dist[ni][nj] <= d + 1)continue;
                dist[ni][nj] = d + 1;
                q.emplace_back(ni,nj);

            }
        }

    }
    int ans = dist[ti][tj];
    if(ans == INF)ans = -1;
    cout << ans << endl;

}

Measured memory_bytes: 9568
N, T = gets.chomp.split.map(&:to_i)

eggs = []
N.times { eggs << gets.chomp.split.map(&:to_i) }
eggs.sort! { |a, b| a[0] <=> b[0] }

dp = [0] * 6001

eggs.each do |egg|
  (T - 1).downto(0) do |i|
    dp[i + egg[0]] = dp[i] + egg[1] if dp[i + egg[0]] < dp[i] + egg[1]
  end
end

puts dp.max


Measured memory_bytes: 2172
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S,T;cin>>S>>T;
  int N=S.length();
  bool isok = false;
  repeat(i,N){
    S = S.back()+S;S.pop_back();
    isok |= S==T;
  }
  cout << (isok? "Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#include<cmath>
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,first[3010],cnte,x[3010];
struct edge{
	int to,next;
}a[6010];
inline void add(int u,int v){
	a[++cnte]=(edge){v,first[u]};first[u]=cnte;
	a[++cnte]=(edge){u,first[v]};first[v]=cnte;
}
int dfs(int u,int f){
	int i,v,re=0;
	for(i=first[u];~i;i=a[i].next){
		v=a[i].to;if(v==f) continue;
		if(!dfs(v,u)&&x[u]>x[v]) re=1;
	}
	return re;
}
int main(){
	memset(first,-1,sizeof(first));
	n=read();int i,t1,t2;
	for(i=1;i<=n;i++) x[i]=read();
	for(i=1;i<n;i++){
		t1=read();t2=read();
		add(t1,t2);
	}
	for(i=1;i<=n;i++) if(dfs(i,0)) printf("%d ",i);
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision;
// #define int cpp_int
using namespace std;

#define fastio 			ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int 			long long
#define ll 				long long
#define ld 				long double
#define vi 				vector<int>
#define pii 			pair<int,int>
#define vpii 			vector< pair<int,int> >
#define uset			unordered_set
#define umap 			unordered_map
#define maxpq 			priority_queue<int>
#define minpq			priority_queue<int,vi,greater<int>()>

#define all(v) 			v.begin(),v.end()
#define part(v,s,e)		v.begin()+s,v.begin()+e
#define rev(v)			reverse(v.begin(),v.end())
#define sz(x)			(int)x.size()
#define def(v)			memset(v,-1,sizeof(v));
#define def0(v)			memset(v,0,sizeof(v));
#define minv(a)			*min_element(all(a))
#define maxv(a)			*max_element(all(a))
#define sumv(a)			accumulate(all(a),0)

#define	lb				lower_bound
#define	ub				upper_bound
#define	desc			greater<int>()
#define	pb				emplace_back
#define	mp				make_pair
#define	F				first
#define	S				second

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a/(__gcd(a,b)))*b

#define setbits(x) 		__builtin_popcountll(x)
#define zerobits(x)		__builtin_ctzll(x)

#define ip(v)	 		for(auto& i:v)	cin>>i;
#define op(v) 			for(auto i:v)	cout<<i<<" ";cout<<endl;
#define deb(x) 			cout <<"Value of " #x << " : " << x << endl;


void solve()
{	

	int n;
	cin>>n;

	string s;
	cin>>s;

	if(n<3200)	cout<<"red\n"; 	
	else		cout<<s<<endl;

}	

int32_t main()
{

	fastio
	cout<<setprecision(15)<<fixed;

	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// 	freopen("error.txt","w",stderr);
	// #endif

	int t=1;
	// cin>>t;
	
	for(int i=1;i<=t;i++)
	{
		// cout<<"Case "<<i<<" : "<<endl;
		solve();
	}
	
	#ifndef ONLINE_JUDGE	
		cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	#endif

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int MM = 200002;
int N, h[MM], a[MM]; ll bit[MM], ans;
ll qry(int x){
    ll ret = 0;
    for(int i=x; i; i-=i&-i) ret = max(ret, bit[i]);
    return ret;
}
void upd(int x, ll val){
    for(int i=x; i<MM; i+=i&-i) bit[i] = max(bit[i], val);
}
int main(){
    scanf("%d", &N);
    for(int i=1; i<=N; i++) scanf("%d", &h[i]);
    for(int i=1; i<=N; i++){
        scanf("%d", &a[i]); ll mx = qry(h[i]); upd(h[i], mx + a[i]); ans = max(ans, mx + a[i]);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3328
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $a = explode(" ", trim(fgets(STDIN)));

  $b = [];
  $h = intdiv($n, 2);
  if($n % 2 == 1){
    $h+=1;
  }

  // 後半の半分は自分自身で決まる
  for($i=$n-1; $i>=$h; $i--){    
    if($a[$i] == "1"){
      $b[$i] = true;
    }
  }

  // 前半の半分は倍数を見て決める
  for($i=$h-1; $i>=0; $i--){
    $bai = 0;
    $hako = $i+1;
    while($hako <= $n){
      $hako += ($i+1);
//      echo $i." ".$hako.PHP_EOL;
      if(isset($b[$hako-1])){
        $bai++;
      }
    }
    if($bai % 2 != $a[$i]){
      $b[$i] = true;
    }
  }

  echo count($b).PHP_EOL;
  foreach($b as $key => $value){
    echo ($key+1)." ";
  }

  

Measured memory_bytes: 25328
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int getAbs(int x);

int main(){
    string s;
    cin >> s;
    int appearNum[26] = {};
    for(int i = 0; s[i] != '\0'; i++){
        for(int j = 0; j < 26; j++){
            if(s[i] == 'a' + j){
                appearNum[j]++;
                break;
            }
        }
    }

    bool noneFlag = false;
    for(int i = 0; i < 26; i++){
        if(appearNum[i] == 0){
            cout << (char)('a' + i) << endl;
            break;
        }

        if(i == 25) noneFlag = true;
    }

    if(noneFlag) cout << "None\n";
    return 0;
}

int getAbs(int x){
    return (x > 0)? x : -x;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  while(cin >> s){
    int i,j,k;
    int d[10][10]={};
    for(i=0;i<10;i++) d[0][i]=s[i]-'0';
    for(i=1;i<10;i++){
      for(j=0;j<10-i;j++){
	d[i][j]=(d[i-1][j]+d[i-1][j+1])%10;
      }
    }
    cout << d[9][0] << endl;
  }
}

Measured memory_bytes: 1180
#include<iostream>
#include<bits/stdc++.h>
#define print(x) cout<<#x<<"="<<x<<'\n'
#define print2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define print3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define fr(i,a,n) for(int i=a;i<=(n);++i)
#define rf(i,a,n) for(int i=a;i>=(n);--i)
#define mp make_pair
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pii>
using namespace std;

vi graph[101];
int level[101];
bool vis[101];

int main(){
	int t=1;
	// cin>>t;
	while(t--){
		int h, w;
		cin>>h>>w;
		vector<vector<char>> a(h,vector<char>(w));
		vvi dp(h+1,vi(w+1));
		rep(i,h) rep(j,w) cin>>a[i][j];
		dp[1][1]=1;
		for(int i=1;i<=h;i++){
			fr(j,1,w){
				if(i==1&&j==1){
					dp[i][j]=1;
					continue;
				}
				if(a[i-1][j-1]=='#'){
					dp[i][j]=0;
					continue;
				}
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
			}
		}
		cout<<dp[h][w]%mod<<endl;
	}
	return 0;
}


Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNextInt()) {
            int h = s.nextInt();
            int w = s.nextInt();
            if(h == 0 && w == 0) break;
            for(int i = 0; i < h; ++i) {
                for(int j = 0; j < w; ++j) {
                    System.out.print('#');
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 28868
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const int INF=1e9;
int main(){
	int N;cin>>N;
	int A[N],B[N],C[N-1];
	int sum=0;
	rep(i,0,N) cin>>A[i];
	rep(i,0,N){ cin>>B[i];sum+=B[i]; }
	rep(i,0,N-1) cin>>C[i];
	rep(i,1,N){
		if(A[i]==A[i-1]+1) sum+=C[A[i-1]-1];
	}cout<<sum<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int a=ir.nextInt();
		int b=ir.nextInt();
		out.println(((a*b)&1)==1?"Odd":"Even");
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

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

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

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

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

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}

Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
# define MOD 1000000000+7
# define INF 1e9
# define LINF 1e18
typedef long long ll;

using namespace std;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
 
int n, x,cnt,sum;
pair<int, int> p[200000];

int main() {

	int n = 0,cnt = 0;
	cin >> n;

	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		p[i] = make_pair(b, a);
	}

	sort(p, p + n);

	for (int i = 0; i < n; i++) {
		cnt += p[i].second;

		if (p[i].first < cnt) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>   pii;
typedef vector< pii>      vii;
typedef vector<int>     vi;
typedef vector< vi >    vvi;
typedef long long int   LL;
#define pb push_back
#define mp make_pair
#define scan(n) scanf("%d",&n)
#define print(n) printf("%d\n",n)
#define longscan(n) scanf("%lld",&n)
#define longprint(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
/*void sieve(int n)
  {
          for(int i=2;i*i<=100000;i++) for(int j=2*i;j<=100000;j+=i) if(!sie[j]) sie[j]=1;
          }*/
int main()
{
     int n, W;
     cin >> n >> W;
     long long int dp[n+1][W+1];
     memset(dp,0, sizeof(dp));
     long long int v[n+1], w[n+1];
     for(int j=0;j<n;j++){
         cin >> w[j] >> v[j];
     }
     dp[0][0] = 0;
     for(int i=1;i<=n;i++)
     {
         for(int j=1;j<= W;j++)
         {
             dp[i][j] = dp[i-1][j];
         }
         for(int j=w[i-1];j<= W;j++)
         {
             dp[i][j] = max(dp[i][j], dp[i-1][j-w[i-1]] + v[i-1]);
         }
     }
     cout << dp[n][W]  << "\n";
     return 0;
}


Measured memory_bytes: 79104
#include<stdio.h>
int main(void)
{
	int n;
	scanf("%d",&n);
	if(n==111){
		printf("999\n");
	}
	else if(n==911){
		printf("199\n");
	}
	else if(n==191){
		printf("919\n");
	}
	else if(n==119){
		printf("991\n");
	}
	else if(n==991){
		printf("119\n");
	}
	else if(n==199){
		printf("911\n");
	}
	else if(n==919){
		printf("191\n");
	}
	else if(n==999){
		printf("111\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    long long n;
    cin >> n;
    string s = to_string(n);
    long long m = 0;
    for(int i = 0; i < s.size(); i++){
        m += s[i] - '0';
    }
    if(n % m == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long LL;

const int N=10;

LL ans;
int len;
char s[N+5];

void Dfs(int now,LL S)
{
	LL num;
	sscanf(s+now,"%lld",&num);
	for(int i=1;i<=len-now;i++)
	{
		LL k=num/(LL)pow(10,len-now-i+1);
		LL r=num%(LL)pow(10,len-now-i+1);
		ans+=S+k+r;
		Dfs(now+i,S+k);
	}
}

int main()
{
	scanf("%s",s+1);
	len=strlen(s+1);
	Dfs(1,0);
	LL num;
	sscanf(s+1,"%lld",&num);
	printf("%lld\n",ans+num);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int N;
	cin>>N;
	int a=N%10;
	N/=10;
	int b=N%10;
	N/=10;
	int c=N%10;
	if( a==7 || b==7 || c==7 ) 
		cout << "Yes" << endl;
	else
		cout << "No" << endl; 
	return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int d[n];
  FOR(i,0,n) cin >> d[i];
  int p = d[0];
  bool yes = true;
  FOR(i,1,n){
    p -= 10;
    if(p < 0) yes = false;
    p = max(p, d[i]);
  }
  p = d[n-1];
  for(int i = n - 2; i >= 0; i--){
    p -= 10;
    if(p < 0) yes = false;
    p = max(p, d[i]);
  }
  cout << (yes ? "yes" : "no") << endl;
}


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

int main()
{
    ll n;
    cin >> n;
    ll a[n];
    REP(i, n)
        cin >> a[i];

    map<int, int> mp;
    int cnt = 0;

        for (int i = 0; i < n; i++)
    {
        int tmp = a[i] / 400;

        if (tmp >= 8)
            cnt++;
        else if (mp.count(tmp) == 0)
            mp[tmp] = 1;
    }

int mi,ma;

if (mp.size()==0){
     mi = 1;
     ma = cnt;
}else{
    mi = mp.size();
     ma = mp.size()+cnt;
}
    cout <<mi <<" " <<ma << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

signed main(){
	int A, B;
	cin >> A >> B;
	cout << 6-A-B << endl;
}

Measured memory_bytes: 256