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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 11000000;
const i64 P = 998244353;
i64 fact[maxn], tcaf[maxn];

i64 deg(i64 x, i64 d) {
    if (d < 0) d += P - 1;
    i64 y = 1;
    while (d) {
        if (d & 1) (y *= x) %= P;
        d /= 2;
        (x *= x) %= P;
    }
    return y;
}

i64 cnk(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * tcaf[k] % P * tcaf[n - k] % P;
}

map<string, int> memo;

bool can(string s) {
    if (s == "") return true;
    if (memo.count(s)) return memo[s];
    forn(i, s.size() - 1) {
        if (s[i] == 'A' && s[i + 1] == 'B') continue;
        if (s[i] == 'B' && s[i + 1] == 'A') continue;
        string t;
        forn(j, s.size()) if (j != i && j != i + 1) t += s[j];
        if (can(t)) return memo[s] = 1;
    }
    return memo[s] = 0;
}

int n;
i64 cnt[2];

void rec(string &s) {
    if (s.size() == n) {
        ++cnt[can(s)];
        if (!can(s)) cerr << s << '\n';
        return;
    }
    forn(i, 3) {
        s += (char)('A' + i);
        rec(s);
        s.resize(s.size() - 1);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    cin >> n;
    fact[0] = 1;
    for1(i, n) fact[i] = fact[i - 1] * i % P;
    forn(i, n + 1) tcaf[i] = deg(fact[i], -1);

    i64 ans = 0;
    fore(i, n / 2 + 1, n) (ans += cnk(n, i) * deg(2, n - i)) %= P;
    (ans *= 2) %= P;
    cout << (deg(3, n) - ans + P) % P << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 162048
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int p[n],cp[n];
  bool can=true;
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  for(int i=1;i<n;i++){
    if(p[i-1]>p[i]){
      can=false;
      break;
    }
  }
  if(can==true){
    cout <<"YES\n";
    return 0;
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      copy(p,p+n,cp);
      int tmp=cp[i];
      cp[i]=cp[j];
      cp[j]=tmp;
      can=true;
      for(int k=1;k<n;k++){
        if(cp[k-1]>cp[k]){
          can=false;
          break;
        }
      }
      if(can==true){
        cout <<"YES\n";
        return 0;
      }
    }
  }
  cout << "NO\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <iomanip>
#include <time.h>
#include <math.h>
#include <bitset>

#pragma comment(linker, "/STACK:256000000")

using namespace std;

typedef long long int ll;
typedef long double ld;

const int INF = 1000 * 1000 * 1000 + 21;
const ll LLINF = (1ll << 60) + 5;
const int MOD = 1000 * 1000 * 1000 + 7;


int main()
{
#ifdef CH_EGOR
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
	//freopen("", "r", stdin);
	//freopen("", "w", stdout);
#endif

	int n;
	cin >> n;
	cout << 24 + 24 - n;

	return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
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; }
ll mod= 1e9 + 7;



int main() {
  ll d,t,s;
  cin >> d >>t >>s;
  if(s*t>=d){cout << "Yes" << endl;}else{cout << "No" << endl;}
}


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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

string s;

signed main() {
    cin>>s;

    int ans=0,ret=0;
    rep(i,0,s.length()) {
        if(s[i]=='g') {
            if(ret>0) {
                ret--;
                ans++;
            }else{
                ret++;
            }
        }else{
            if(ret>0) {
                ret--;
            }else{
                ans--;
                ret++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int[] a = new int[m];
		int[] c = new int[m];
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			a[i] = Integer.parseInt(sa[0]);
			sa = br.readLine().split(" ");
			for (int j = 0; j < sa.length; j++) {
				int o = Integer.parseInt(sa[j]) - 1;
				o = 1 << o;
				c[i] |= o;
			}
		}
		br.close();

		int n2 = 1 << n;
		int[] dp = new int[n2];
		Arrays.fill(dp, 100000000);
		dp[0] = 0;
		for (int i = 0; i < n2; i++) {
			for (int j = 0; j < m; j++) {
				int k = c[j] | i;
				dp[k] = Math.min(dp[k], dp[i] + a[j]);
			}
		}
		if (dp[n2 - 1] == 100000000) {
			System.out.println(-1);
		} else {
			System.out.println(dp[n2 - 1]);
		}
	}

	static class Key {
		int a, b, c;
	}
}


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

int main() {
    int N;
    cin >> N;
    vector<int> W(N);
    int total;
    for (int i=0; i<N; i++) {
        cin >> W[i];
        total += W[i];
    }

    int sum;
    int opp;
    int minval = total;
    for (int i=0; i<N; i++) {
        sum += W[i];
        opp = total - sum;
        if (abs(opp - sum) < minval) minval = abs(opp - sum);
    }

    cout << minval << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; int k; cin>>s>>k;
    rep(i,s.size()){
        if(s.at(i)!='a' and 'z'-s.at(i)+1<=k){
            k-='z'-s.at(i)+1;
            s.at(i)='a';
        }
    }
    k%=26;
    s.back()='a'+(s.back()-'a'+k)%26;
    cout<<s<<endl;
}

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

  int l,r,d; cin>>l>>r>>d;
  int ans =0;
  for (int i=l; i<=r; i++) {
    if ((i%d ) == 0) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include <stdio.h>
int a1, m1, a2, m2, a3, m3;
int gcd(int x, int y) {
	if (x == 0) return y;
	if (y == 0) return x;
	if (x > y) return gcd(y, x % y);
	return gcd(x, y % x);
}
long long lcm(long long x, long long y) {
	return 1LL * x / gcd(x, y) * y;
}
long long lcm(int a, int b, int c) {
	return lcm(lcm(a, b), lcm(a, c));
}
inline int solve(int x, int m) {
	int ret = 1, s = x;
	while (s != 1) s = s * x % m, ret++;
	return ret;
}
int main() {
	while (true) {
		scanf("%d%d%d%d%d%d", &a1, &m1, &a2, &m2, &a3, &m3);
		if (!a1 && !m1 && !a2 && !m2 && !a3 && !m3) break;
		printf("%lld\n", lcm(solve(a1, m1), solve(a2, m2), solve(a3, m3)));
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll n;
vector<P> g[101010];
ll dist[101010];

int main(){
	cin>>n;
  rep(i,n){
    g[i].push_back(P((i+1)%n,1));
    g[i].push_back(P((i*10)%n,0));
  }
  rep(i,n)dist[i]=INF;
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(1,1));
  while(que.size()){
    ll v=que.top().se;
    ll d=que.top().fi;
    que.pop();
    if(dist[v]!=INF)continue;
    dist[v]=d;
    //dbg(v);
    for(P e : g[v]){
      que.push(P(d+e.se,e.fi));
    }
  }
  cout<<dist[0]<<endl;
	return 0;
}


Measured memory_bytes: 10228
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<math.h>
#include<string>
#include<queue>
#include<set>
using namespace std;
#define int long long
#define ll long long
#define vel vector<ll>
#define vvel vector<vel>
#define sor(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define rep(i,n) for(ll i=0;i<n;i++)
#define upperbound(v,val) upper_bound(v.begin(),v.end(),val)
#define lowerbound(v,val) lower_bound(v.begin(),v.end(),val)
#define mkp make_pair
#define pin pair<ll,ll>
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
int ze = 0;
vel rui(63, 1);
void make_rui() {
	for (int i = 1; i < 63; i++) {
		rui[i] = rui[i - 1] * 2;
	}
}
signed main() {
	make_rui();
	int h, w, n; cin >> h >> w >> n;
	int now_y, now_x; cin >> now_y >> now_x; now_x--; now_y--;
	string s, t; cin >> s >> t;
	int li_l = 0, li_r = w, li_u = h, li_d = 0;
	for (int i = n - 1; i > 0; i--) {
		if (s[i] == 'D') { li_u--; }
		if (s[i] == 'U') { li_d++; }
		if (s[i] == 'L') { li_l++; }
		if (s[i] == 'R') { li_r--; }
		if (li_u == li_d) { cout << "NO" << endl; return 0; }
		if (li_l == li_r) { cout << "NO" << endl; return 0; }
		if (t[i - 1] == 'D') { li_d--; mmax(li_d, ze); }
		if (t[i - 1] == 'U') { li_u++; mmin(li_u, h); }
		if (t[i - 1] == 'L') { li_r++; mmin(li_r, w); }
		if (t[i - 1] == 'R') { li_l--; mmax(li_l, ze); }
	}
	if (s[0] == 'D') { li_u--; }
	if (s[0] == 'U') { li_d++; }
	if (s[0] == 'L') { li_l++; }
	if (s[0] == 'R') { li_r--; }
	if (li_u == li_d) { cout << "NO" << endl; return 0; }
	if (li_l == li_r) { cout << "NO" << endl; return 0; }
	if (li_l <= now_x and now_x < li_r and li_d <= now_y and now_y < li_u) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <map>
#include <set>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define mod 1000000007
using namespace std;

int main()
{
    //freopen("1.txt", "r", stdin);
    int a, b, c;
    cin >> a >> b >> c;
    int ret = 0;
    if (a == b && b == c) {
        if (a % 2) cout << 0;
        else cout << -1;
        return 0;
    }
    while (!(a % 2 || b % 2 || c % 2)) {
        int aa = a, bb = b, cc = c;
        a = (bb + cc) / 2;
        b = (aa + cc) / 2;
        c = (bb + cc) / 2;
        ++ret;
    }
    cout << ret;
    return 0;
}


Measured memory_bytes: 256
const lines=readlines()
input()=shift!(lines)
int(s)=parse(Int32,s)
intLine()=map(int,split(input()))
function nextLine(k)
    x,y,c=split(input())
    int(x)%2k+1,(int(y)+(c=="W")k)%2k+1
end
function solve(k,g)
    m=0
    for i=1:2k,j=1:2k
        a=0
        for x=-1:2,y=-1:2
            (x+y)%2!=0&&continue
            v,w=i+x*k,j+y*k
            v>0<w&&(a+=g[min(2k,v)][min(2k,w)])
            v>k&&w>0&&(a-=g[min(2k,v-k)][min(2k,w)])
            w>k&&v>0&&(a-=g[min(2k,v)][min(2k,w-k)])
            v>k<w&&(a+=g[min(2k,v-k)][min(2k,w-k)])
        end
        m=max(m,a)
    end
    m
end
function main()
    n,k=intLine()
    g=Array{Int32,1}[[0for j=1:2k]for i=1:2k]
    for i=1:n
        x,y=nextLine(k)
        g[x][y]+=1
    end
    println(solve(k,cumsum(map(cumsum,g))))
end
main()

Measured memory_bytes: 206852
import pprint
from collections import defaultdict

N = int(input())

SD = defaultdict(int)
for _ in range(N):
    SD[input()] += 1

M = int(input())
TD = defaultdict(int)
for _ in range(M):
    TD[input()] += 1

KS = set(list(SD.keys()) + list(TD.keys()))

RL = [0]
for k in KS:
    RL.append(SD[k] - TD[k])

print(max(RL))

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N; cin >> N;
    multiset<int> S;
    for(int i=0; i<N; i++){
        int a; cin >> a;
        auto it = S.lower_bound(a);
        if(it!=S.begin()) S.erase(--it);
        S.insert(a);
    }
    cout << S.size() << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

struct Task {
  int task_id, time, cid;
};
bool operator<(const Task &t, const Task &s) {
  return t.time > s.time;
}

int n,m;
int cache[100001];
map<int,int> lastused;

int main() {
  scanf("%d%d", &n, &m);
  int unused = 0;
  map<int,int> timeToId, idToTime;
  for (int i=0; i<n; ++i) {
    int id;
    scanf("%d", &id);
    if (idToTime.find(id) != idToTime.end()) {
      int t = idToTime[id];
      timeToId.erase(t); idToTime[id] = i; timeToId[i] = id;
    } else if (timeToId.size() < m) {
      idToTime[id] = i;
      timeToId[i] = id;
    } else {
      pair<int,int> p = *timeToId.begin();
      int rmId = p.second, rmTime = p.first;
      idToTime.erase(rmId), timeToId.erase(rmTime);
      timeToId[i] = id, idToTime[id] = i;
    }
  }

  vector<int> ans;
  for (map<int,int>::iterator it = timeToId.begin(); it != timeToId.end(); ++it)
    ans.push_back(it->second);
  reverse(ans.begin(), ans.end());
  for (int i=0; i<ans.size(); ++i) printf("%d\n", ans[i]);
}

Measured memory_bytes: 6568
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    if(a==0)
    {
        cout<<0<<endl;
        return 0;
    }
    ll g=n/(a+b);
    ll m=n%(a+b);
    ll ans=g*a;
    if(m>=a)ans+=a;
    else ans+=m;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,K; cin>>N>>K;
  string S; cin>>S;
  int ans=N;
  rep(i,0,N-1){
    if(S.substr(i,2)=="RL") ans-=2;
  }
  if(S[0]=='L') ans--;
  if(S[N-1]=='R') ans--;
  ans=min(ans+K*2,N-1);
  cout<<ans<<endl;
  }



Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
//#include <algorithm>
#include <vector>


int main(int argc, char* argv[])
{
    long h, w;
    scanf("%ld %ld", &h, &w);

    char str[100][100]={0};

    long i, j;
    for(i=0; i<h; i++) {
        scanf("%s", str[i]);
    }

    long skip[100]={0};
    for(i=0; i<w; i++) {
        for(j=0; j<h; j++){
            if(str[j][i]=='#')
                break;
        }
        if(j==h)
            skip[i]=1;
    }

    for(i=0; i<h; i++) {
        for(j=0; j<w; j++){
            if(str[i][j]=='#')
                break;
        }
        if(j==w) {
            continue;
        }

        for(j=0; j<w; j++){
            if(skip[j]==0) {
                char tmp[2]={0};
                tmp[0] = str[i][j];
                printf("%s", tmp);
            }
        }
        printf("\n");
    }

    //    printf("%d\n", a - b + 1);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int H,W;
    cin >> H >> W;
    char A[H][W];
    rep(i,H){
        rep(j,W){
            cin >> A[i][j];
        }
    }
    string ans="Possible";
    rep(i,H){
        rep(j,W){
            if(A[i][j]=='#' && A[i+1][j]=='#' && A[i][j+1]=='#'){
                ans="Impossible";
            }
            if(A[i][j]=='#' && A[i-1][j]=='#' && A[i][j-1]=='#'){
                ans="Impossible";
            }
        }
    }
    cout << ans << endl;







}


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

def check(now):
    if pow(2,now) * dice >= K:
        return True
    else:
        return False
#(l,r]
def bisec(l, r):
    if r - l == 1:
        return r
    mid = (l + r) // 2
    if check(mid):
        return bisec(l,mid)
    else:
        return bisec(mid,r)

ans = 0
for dice in range(1,N+1):
    ans += 1 / pow(2,bisec(-1,30))
print(ans/N)


Measured memory_bytes: 74400
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	double	ans = 0;
	string	ss,s;
	cin >> n;
	for(i=0;i<n;i++) {
		cin >> ss >> s;
		if (s[0]=='B') {
			ans += stof(ss)*380000.0;
		} else {
			ans += stoi(ss);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3744
/*raghav0307 - Raghav Gupta*/

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

#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int ll

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

signed main(){
	fast_io();
	int n;	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)	cin >> a[i];
	int b[n];
	priority_queue<pii> pq;
	for(int i = 0; i < n; i++){
		cin >> b[i];
		pq.push({b[i], i});
	}
	int count = 0;
	while(!pq.empty()){
		auto x = pq.top();	pq.pop();
		if(x.ff < a[x.ss]){
			cout << "-1";	return 0;
		}
		if(x.ff == a[x.ss]){
			continue;
		}
		int l = (x.ss -1 + n)%n;
		int r = (x.ss + 1)%n;
		// int mmax = max(a[x.ss], max(b[l], b[r]));
		int incr = (b[x.ss] - a[x.ss])/(b[l] + b[r]);
		// cout << x.ss << " " << b[x.ss] << "\n";
		if(incr == 0){
			cout << "-1";
			return 0;
		}
		b[x.ss] -= incr*(b[l] + b[r]);
		pq.push({b[x.ss], x.ss});
		count+= incr;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 8944
/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define MAX 10000
  #define md 1000000007
  #define add accumulate
  #define ll long long int
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  //
  //
  int dx[]={0,0,1,-1};
  int dy[]={1,-1,0,0};
	    int main(){
	  		ll h,w;	cin>>h>>w;
	  		char arr[h][w];
	  		int store[h][w];
	  		queue<pair<int,int>> q;
	  		rep(i,0,h)
	  			rep(j,0,w){
	  				cin>>arr[i][j];
	  				store[i][j]=-1;
	  				if(arr[i][j]=='#'){
	  					store[i][j]=0;
	  					q.push(mp(i,j));
	  				}
	  			}
	  		ll ans=0;
	  		while(!q.empty()){
	  			ll x=q.front().ff;
	  			ll y=q.front().ss;
	  			q.pop();

	  			rep(i,0,4){
	  				ll xx=x+dx[i];
	  				ll yy=y+dy[i];
	  				if(store[xx][yy]!=-1||xx<0||xx>=h||yy<0||yy>=w)
	  					continue;
	  				store[xx][yy]=store[x][y]+1;
	  				ans=store[x][y]+1;
	  				q.push(mp(xx,yy));
	  			}
	  		}	/*
	  		rep(i,0,h){
	  			rep(j,0,w)
	  				cout<<store[i][j];
	  			cout<<'\n';
	  		}*/
	  		cout<<ans;
	  		return 0;
	  }

Measured memory_bytes: 13328
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n,sum=0;
  cin>>n;
  for (int i = 1; i <= n; ++i)
  {
    sum+=i;
    if(sum>=n) {
      cout<<i;
      break;
    }
  }
}

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

int main()
{
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define EE emplace
#define RB rbegin()
#define MD 1000000007
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define PPF pop_front()
#define EB emplace_back
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C;u.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>ww,cc,u;
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
LL ar[100];
LL dxx[]= {-1,0,1,0};
LL dyy[]= {0,1,0,-1};
LL dx[]= {2,1,-1,-2,-2,-1,1,2};
LL dy[]= {1,2,2,1,-1,-2,-2,-1};
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
        cin>>a;
        k=0;
        for(i=0;a[i];i++)
        {
            k+=a[i]-'0';
        }
        if(k%9==0)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }

    }
    return 0;
    //IN
    //AL
}


Measured memory_bytes: 3740
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

vector<int> mn(1010, 0), mx(1010, 0);
void solve() {
  for (int i = 1; i < mn.size(); i++) {
    mn[i] = 100*i;
    mx[i] = 105*i;
  }
}

int main() {
  int x;
  cin >> x;
  solve();
  for (int i = 0; i < mn.size(); i++) {
    if (mn[i] <= x && x <= mx[i]) {
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using plpii = std::pair<long long, std::pair<int, int>>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;

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

	string s;
	cin >> s;
	int t = s[s.length() - 1] - '0';
	if (t == 0 || t == 1 || t == 6 || t == 8) {
		cout << "pon" << "\n";
	}
	else if (t == 3) {
		cout << "bon" << "\n";
	}
	else {
		cout << "hon" << "\n";
	}

	return 0;
}



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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> hs(n);
    for (int& h : hs) {
        cin >> h;
    }
    int max_run = 0, current_run = 0;
    for (int i = 0; i+1 < n; ++i) {
        if (hs[i] >= hs[i+1]) {
            ++current_run;
            max_run = max(max_run, current_run);
        } else {
            current_run = 0;
        }
    }
    cout << max_run << endl;
    return 0;
}


Measured memory_bytes: 640
N,K,Q = [int(x) for x in input().split(" ")]
answer_count = [0 for k in range(N)]
for _ in range(Q):
    answer_count[int(input()) - 1] += 1
must_answer = Q - K + 1
for i in answer_count:
    if must_answer <= i:
        print("Yes")
    else:
        print("No")

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

int main() {
  int N;
  cin >> N;
  
  vector<int> data(4);
  for (int i = 0; i < 4; i++) {
    data.at(i) = N % 10;
    N /= 10;
  }
  
  if (data.at(1) == data.at(2)) {
    if (data.at(0) == data.at(1) || data.at(2) == data.at(3)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
typedef long long ll;
int main() {
  ll s, x[3], y[3];
  scanf("%lld", &s);
  x[0] = y[0] = 0LL;
  x[1] = 1000000000LL;
  y[1] = 1LL;
  x[2] = (x[1] - s % x[1]) % x[1];
  y[2] = (s + x[2]) / x[1];
  for (int i = 0; i < 3; i++) {
    printf("%lld %lld ", x[i], y[i]);
  }
  printf("\n");
}

Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
using namespace std;
int d[1000];
int e[1000];
int f[1000];
int g[1000];
int main(){
    int a,b;
    while(scanf("%d%d",&a,&b),a+b){
        int c;
        scanf("%d",&c);
        for(int i=0;i<c;i++){
            scanf("%d%d%d%d",d+i,e+i,f+i,g+i);
        }
        int p;
        scanf("%d",&p);
        for(int i=0;i<p;i++){
            int q,r,s;
            scanf("%d%d%d",&q,&r,&s);
            int last=0;
            int ret=0;
            int now=0;
            for(int j=0;j<c;j++){
                if(f[j]==s){
                    if(g[j]){
                        if(now==0)last=d[j];
                        now++;
                    }else{
                        now--;
                        if(now==0){
                            if(q<=d[j]&&d[j]<=r)ret+=d[j]-max(q,last);
                            if(d[j]>r&&last<=r)ret+=r-max(q,last);
                        }
                    }
                }
            }
            printf("%d\n",ret);
        }
    }
}


Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end()
#define ll long long 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

signed main () {
	start_routine;
	#ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	#endif

	int n, m; cin >> n >> m;

	vi divisors;
	for (int i = 1; i * i <= m; i++) {
		if (i * i == m) {
			divisors.push_back(i);
			continue;
		}
		if (m % i == 0) divisors.push_back(i), divisors.push_back(m / i);
	}
	sort(all(divisors));

	auto it = lower_bound(divisors.begin(), divisors.end(), n);
	cout << m / *it << endl;
	end_routine;
}


Measured memory_bytes: 256
#include<string>
#include<string.h>
#include<iostream>
#include<stdio.h>
using namespace std;
const int MAXN=200020;
int f[MAXN];
int d[MAXN];
int r[MAXN];
int n,m;
int find(int x)
{
	return x==f[x]?x:find(f[x]);
}
void Merge(int a,int b)
{
	int x=find(a);
	int y=find(b);
	if(x!=y)
	f[x]=y;
}
int main()
{
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		int a,b;
		int j=0;
		memset(r,0,sizeof(r));
	    for(int i=0;i<m;i++)
	    {
			scanf("%d%d",&a,&b);
			if(a==1)
			{
				d[j++]=b;
			}
			if(b==n)
			{
				r[a]=1;
			}
		}
		int i;
		for(i=0;i<j;i++)
		{
			if(r[d[i]])
			{
				puts("POSSIBLE");
				break;
			}		
		}
		if(i==j)
			puts("IMPOSSIBLE");	
	}
} 

Measured memory_bytes: 1408
# @uthor : Kaleab Asfaw
from sys import stdin, stdout
# Fast IO
# from math import gcd

def input():
	a = stdin.readline()
	if a[-1] == "\n": a = a[:-1]
	return a
def print(*argv, end="\n", sep=" "):
	n = len(argv)
	for i in range(n):
		if i == n-1: stdout.write(str(argv[i]))
		else: stdout.write(str(argv[i]) + sep)
	stdout.write(end)
# Others
mod = 10**9+7
def lcm(x, y): return (x * y) / (gcd(x, y))
def fact(x, mod=mod):
	ans = 1
	for i in range(1, x+1): ans = (ans * i) % mod
	return ans
def arr2D(n, m, default=0):
	lst = []
	for i in range(n): temp = [default] * m; lst.append(temp)
	return lst
def sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}

def solve(n):
	c = [x for x in range(3, 2001)]
	dp = [float("-inf")] * (n+1)
	dp[0] = 1
	for i in range(1, n+1):
		s = 0
		for x in c:
			if i - x >= 0:
				s += dp[i-x]
		dp[i] = s % mod
	return dp[n]

n = int(input())
print(solve(n))

Measured memory_bytes: 73576
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll dp[1010][1 << 12], a[1010], b[1010], c[1010][20];
bool open[1010][12];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		for (int j = 0; j < b[i]; j++) {
			cin >> c[i][j];
			c[i][j]--;
			open[i][c[i][j]] = true;
		}
	}
	for (int i = 0; i < 1010; i++) {
		for (int j = 0; j < (1 << N); j++) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < (1 << N); j++) {
			int num = 0;
			int tmp = j;
			ll power = 1;
			for (int k = 0; k < N; k++) {
				if (tmp % 2 == 1 || open[i][k]) {
					num += power;
				}
				power *= 2;
				tmp /= 2;
			}
			//cout << i << " " << j << " " << num << endl;
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			dp[i + 1][num] = min(dp[i + 1][num], dp[i][j] + a[i]);
			//cout << dp[i + 1][num] <<  endl;
		}
	}
	/*for (int i = 1; i <= M; i++) {
		for (int j = 0; j < (1 << N); j++) {
			cout << i << " " << j << " " << dp[i][j] << endl;
		}
	}*/
	if (dp[M][(1 << N) - 1] == INF) cout << -1 << endl;
	else cout << dp[M][(1 << N) - 1] << endl;
}

Measured memory_bytes: 32768
n=int(input())
n1=n//1000
n2=(n//100)%10
n3=(n//10)%10
n4=n%10

if n1==n2 and n2==n3 and n3==n4:
    print('Yes')
elif n1==n2 and n2==n3:
    print('Yes')
elif n2==n3 and n3==n4:
    print('Yes')
else:
    print('No')

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


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

    // all the code goes here
    int n;cin>>n;
    int k;cin>>k;
    int a[n];
    for(int i = 0; i < n; i++)
        cin>>a[i];
    
    vector<int> dp(n,INT_MAX);
    // cout<<dp[n-1]<<"\n";
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);

    for(int i = 2; i < n; i++)
    {
        // cout<<dp[i]<<"\n";
        for(int j = 1; j <= min(k,i); j++)
            dp[i] = min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        // cout<<dp[i]<<"\n";
    }

    cout<<dp[n-1]<<"\n";

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
    long long int N;
    long long int a[5];
    scanf("%lld",&N);
    for(int i=0;i<5;i++){
        scanf("%lld",&a[i]);
    }
    long long int min =a[0];
    for(int i=0;i<5;i++){
        if(a[i]<min){
            min = a[i];
        }
    }
    long long int ans = 4+(N/min);
    if(N%min!=0){
        ans ++;
    }
    printf("%lld",ans);
    return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=21;

ll dp[MAX+1][(1<<MAX)];
int cnt[1<<MAX];

int main(){
    
    int N;cin>>N;
    bool S[N][N];
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin>>S[i][j];
        }
    }
    /*int cnt[1<<N];
    ll dp[N+1][(1<<N)];*/
    for(int i=0;i<N+1;i++){
        for(int j=0;j<(1<<N);j++){
            dp[i][j]=0;
            cnt[j]=__builtin_popcount(j);
        }
    }
    dp[0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<(1<<N);j++){
            if(cnt[j]==i){
                for(int k=0;k<N;k++){
                    if(S[i][k]&&!(j&(1<<k))) dp[i+1][j|(1<<k)]=(dp[i+1][j|(1<<k)]+dp[i][j])%mod;
                }
            }
        }
    }
    cout<<dp[N][(1<<N)-1]<<endl;
    
    
}


Measured memory_bytes: 368896
import java.util.*;

public class Main {
	static class RangeMinimumQuery {
		int N;
		long[] v;
		
		public RangeMinimumQuery(int n) {
			N=1;
			while(N<n)
				N<<=1;
			v = new long[N<<1];
		}
		
		public void add(int i, long x) {
			i+=N;
			while(i>0) {
				v[i] += x;
				i >>=1;
			}
		}
		
		//minimum value in range [a, b)
		public long getSum(int a, int b) {
			return getSum(a, b, 1, 0, N);
		}
		
		public long getSum(int a, int b, int k, int l, int r) {
			if(a<=l && r<=b)
				return v[k];
			else if(r<=a || b<=l)
				return 0;
			else
				return getSum(a, b, k*2, l, (l+r)/2) + getSum(a, b, k*2+1, (l+r)/2, r);
		}
		public long get(int i) {
			return v[i+N];
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char[] s = sc.next().toCharArray();
		int N = s.length;

		ArrayList<ArrayList<Integer>> index = new ArrayList<>();
		for(int i=0; i<26; i++)
			index.add(new ArrayList<>());
		
		for(int i=0; i<N; i++)
			index.get(s[i]-'a').add(i);
		
		int oddNum=0;
		for(int i=0; i<26; i++)
			if(index.get(i).size()%2==1)
				oddNum++;
		if(oddNum>1) {
			System.out.println(-1);
		} else {
			long ans = 0;
			boolean[] used = new boolean[N];
			int[] cnt = new int[26];
			RangeMinimumQuery rmq = new RangeMinimumQuery(N);
			
			for(int i=0; i<N; i++) {
				if(!used[i]) {
					int c = s[i]-'a';
					int pair = index.get(c).get(index.get(c).size() - cnt[c] - 1);
					if(i==pair)
						ans += (N - i -1 -rmq.getSum(i+1, N))/2;
					else
						ans += (N -pair -1 -rmq.getSum(pair+1, N));
					used[pair]=true;
					rmq.add(pair, 1);
					cnt[c]++;
				}
			}
			
			System.out.println(ans);
		}
		sc.close();
	}
	
}


Measured memory_bytes: 37632
from collections import deque
n,m=map(int,input().split())
ans=[0]*(n+1)
adj=[[] for _ in range(n+1)]
for i in range(m):
    u,v=map(int,input().split())
    adj[u].append(v)
    adj[v].append(u)
que=deque([1])
vis=[0 for _ in range(n+1)]
vis[1]=1
while que:
    t=que.popleft()
    #print(t)
    for i in adj[t]:
        #print(i)
        if vis[i]==1:
            continue
        vis[i]=1
        ans[i]=t
        que.append(i)

if 0 in ans[2:]:
    print("No")
else:
    print("Yes")
    for i in ans[2:]:
        print(i)

Measured memory_bytes: 96168
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,d,n,maxi=0,f=0,mini=INF,sum=0;
    ll q;
    ll y;
    cin>>n>>y;
    REP(i,0,n+1)REP(j,0,n+1-i)REP(k,0,n+1-i-j){
        if(i*10000+j*5000+k*1000==y&&i+j+k==n){
            cout<<i<<" "<<j<<" "<<k<<endl;
            return 0;
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}


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

using namespace std;

int main() {
  string str;
  int tmp;
  cin >> str;
  tmp = str.size();
  sort(str.begin(), str.end());
  str.erase(unique(str.begin(), str.end()), str.end());
  cout << (str.size() == tmp ? "yes" : "no") << endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var sp = Console.ReadLine().Split();
        double a = double.Parse(sp[0]);
        double b = double.Parse(sp[1]);
        double h = double.Parse(sp[2]);
        double m = double.Parse(sp[3]);

        // 角度を求める
        var 分針の角度 = m / 60.0;
        var 時針の角度 = h / 12.0 + 分針の角度 / 12.0;
        var 時針と分針の角度の差 = Math.PI * 2 * (時針の角度 - 分針の角度);
        // 余弦定理で a^2 = b^2 + c^2 - 2 * b * c * cos(角度)を求める
        double rsq = (a * a) + (b * b) - (2 * a *　b) * Math.Cos(時針と分針の角度の差);
        // a^2の平方根が答え
        double ans = Math.Sqrt(rsq);
        Console.WriteLine(ans);
    }
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REP2(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<ll> l(n + 1);
    l[0] = 2;
    l[1] = 1;

    for(int i = 2; i <= n; i++){
        l[i] = l[i - 1] + l[i - 2];
    }
    OP(l[n]);
}


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

int main() {
	int N;
	cin >> N;
	vector<int> V(N);
	rep(i,N) cin >> V[i];
	vector<int> C(N);
	rep(i,N) cin >> C[i];

	int ans = 0;
	rep(i,N){
		if(V[i] - C[i] >0) ans += (V[i] - C[i]);
	}
	cout << ans << endl;
}

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

typedef long long ll;

int main(){
  int n;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  int k=n/2;
  ll ans=0;
  if(n%2==0){
    for(int i=0;i<k-1;i++){
      ans-=a[i]*2;
    }
    ans-=a[k-1];
    ans+=a[k];
    for(int i=k+1;i<n;i++){
      ans+=a[i]*2;
    }
  }
  else{
    ll x=0,y=0;
    for(int i=0;i<k-1;i++){
      x-=a[i]*2;
      y-=a[i]*2;
    }
    x-=a[k-1],y-=a[k-1]*2;
    x-=a[k],y+=a[k];
    x+=a[k+1]*2,y+=a[k+1];
    for(int i=k+2;i<n;i++){
      x+=a[i]*2;
      y+=a[i]*2;
    }
    ans=max(x,y);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int n = 600002;
typedef long long ll;
const ll MOD = 998244353;

ll F[n];
ll N, A, B, K;

ll exp(ll b, ll e){
	if(e == 0)
		return 1;
	if(e % 2 == 0){
		ll r = exp(b, e/2);
		return (r*r) % MOD;
	}
	return (b*exp(b, e-1)) % MOD;
}

ll modInv(ll a){
	return exp(a, MOD-2);
}

ll BC(ll n, ll k){
	if(k == 0)
		return 1;

	ll r = 0;
	r += F[n];
	r = (r *modInv(F[k])) % MOD;
	r = (r *modInv(F[n-k])) % MOD;
	return r;
}

int main(){
	cin >> N >> A >> B >> K;
	F[0] = 1;
	for(int i = 1; i <= N; ++i){
		F[i] = (F[i-1] * i) % MOD;
	}
	ll C = 0;
	for(int i = 0; i <= N; ++i){
		ll K2 = K - i*A;
		if(K2 % B == 0){
			ll j = K2/B;
			if(j >= 0 && j <= N){
				//cout << "BC i: " << N << ", "<< i <<": "<< BC(N, i) << endl;
				//cout << "BC j: " << N << ", "<< j <<": "<< BC(N, j) << endl;
				C = (C + BC(N, i)*BC(N, j)) % MOD;
			}
		}
	}

	cout << C << endl;
	return 0;
}

Measured memory_bytes: 4352
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

Measured memory_bytes: 21844
argS = input()
argS1 = int(argS[0:2])
argS2 = int(argS[2:4])

if argS1 > 0 and argS1 < 13:
  flgMM1 = True
else:
  flgMM1 = False

if argS2 > 0 and argS2 < 13:
  flgMM2 = True
else:
  flgMM2 = False

if flgMM1 == True and flgMM2 == False:
  ans = "MMYY"
elif flgMM1 == False and flgMM2 == True:
  ans = "YYMM"
elif flgMM1 == True and flgMM2 == True:
  ans = "AMBIGUOUS"
else:
  ans = "NA"

print(ans)

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
a.sort()
c=[0]
for i in range(n):
    c.append(c[i]+a[i])
p=[0 for i in range(n)]
for i in range(n):
    if c[i]*2<a[i]:
        p[i]=1
for i in range(n):
    if p[n-i-1]:
        print(i+1)
        break
#print(a,c,p,sep='\n')

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)
// }}} 2

// numerous {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// systems }}} 2

// }}} 1

int main() {

    char a[60],b[60];

    ll ans = 1;

    int n;

    Scd(n);
    scanf("%s", a);
    scanf("%s", b);

    bool t = 1; //precious is single?

    int i = 0;
    if( a[i] == b[i] ){
        ans = 3;
        t = 1;
    }else{
        ans = 6;
        t = 0;
        i++;
    }
    while(++i < n){
        if( a[i] == b[i] ){
            if( t ){
                ans = ans * 2 % 1000000007;
            }
            t = 1;
        }else{
            if( t )
            ans = ans * 2 % 1000000007;
            else
            ans = ans * 3 % 1000000007;
            i++;
            t = 0;
        }

        //printf ("%c,%c -- %d,%d\n", a[i], b[i], t, ans);


    }

    printf ("%d\n", ans);

    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
<url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0364>
?????????============================================================
 ??¢??????????°???????????????????????????§????????§????????§?????????
 ???????????????W??H ?????????????????¶??????????????????????????¢????????¢?????§???????????????
 ????????????????????¨?????????????????????????????????????????¨??????????????????????????????????????????
 ????????????x???????????????y ????????????(x, y)??§??¨????????????
 ??????????????????(0, 0)?????????????????????(W-1, H-1)??§?????????
 
 ??¢???????????£????????????????????????????????????????????????????????????????????¢???????????????
 ?????????????????????????????????????????°???????????????0, 0???????????????
 ?????¢??????????????¨????????????????????¨?????????????????¢??¨?????????
 ?????????????????¨??????????????????????????????????????\??????????¨????????????????????????§?????¨????????¨?????§?????????
 
 ???????????????????????????????????????????????????????????¢?????????????????????????????????
 ??????????????¨?????????????????????????????¨??????????????????????????????????????¨?????????????????????????????????????????????????????????
 ??????????????????1 ?????????????????????????????????????¶?????????????
 ??????????????¨?????°?????¶?????????????????????????????¨????????????????????????????????????
 ??????????????????????????????????????±????????????????????¨?????????????????????????????????????§???????????????¨?????§?????????
 
 ?????¢?????§????????¨???????????±????????????????????¨??????????????????????????¨???????????????????????????????°????????????????????????????????????°????????????????????????
=================================================================

?§£??¬=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    int W,H,N; cin >> W >> H >> N;
    vector<int> X(W);
    for(int i = 0; i < N;i++){
        int x,y; cin >> x>>y;
        X[x] = max(X[x],y);
    }
    int res = INF;
    int tmp = 0;
    for(int i = W-1; i>=0;i--){
        res = min(res,i + tmp);
        tmp = max(tmp,X[i]);
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 3356
#include<cstdio>
int main(){
	int a,b,c;
	while(scanf("%d %d %d",&a,&b,&c)==3){
		if(c-b<=0)
			printf("delicious\n");
		if(c-b>0){
			if(a-(c-b)>=0)
				printf("safe\n");
			else
				printf("dangerous\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
n=int(input())
a=[int(i) for i in input().split()]
now=a[0]
cnt=0
res=0
for i in range(1,n):
  if a[i]<=now:
    cnt+=1
  else:
    res=max(cnt,res)
    cnt=0
  now=a[i]
res=max(cnt,res)
print(res)

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

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

    int values[n];
    int weight[n];
    for (int i = 0; i < n; i++) cin >> values[i] >> weight[i];

    int dp[n+1][W+1];
    for ( int w = 0; w <= W; w++ ) {dp[0][w] = 0;}

    for ( int i = 0; i < n; i++ ) {
        for ( int w = 0; w <= W; w++ ) {
            if ( w < weight[i] ) {
                dp[i+1][w] = dp[i][w];
            } else {
                dp[i+1][w] = max(dp[i][w-weight[i]] + values[i], dp[i][w]);
            }
        }
    }

    cout << dp[n][W] << endl;
}


Measured memory_bytes: 7036