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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n,m;cin >>n>>m;
    vector<bool>ch(n,false);
    ch[0]=true;
    vector<ll>cnt(n,1);
    for (int i = 0; i < m; ++i) {
        ll x,y;cin >>x>>y;
        x--;y--;
        cnt[x]--;
        cnt[y]++;
        if(ch[x]){
            ch[y]=true;
            if(cnt[x]==0)ch[x]=false;
        }
    }
    ll ans=0;
    for (int i = 0; i < n; ++i) {
        if(ch[i])ans++;
    }
    cout <<ans <<endl;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
 
int main(){
  char s[258] = {}, tmp[258] = {};
  int m, h, i, l;
  while(scanf("%s", s) && s[0] != '-'){
    scanf("%d", &m);
    while(m--){
      scanf("%d", &h);
      strcpy(tmp, s + h);
      s[h] = '\0';
      strcat(tmp, s);
      strcpy(s, tmp);
    }
    puts(s);
  }
  return 0;
}


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

using ld = double;
using ll = long long;
using ull = unsigned long long;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;

const int SZ = 1 << 13;
char buff[SZ], *pos = buff + SZ - 1;
#define getchar() (++ pos == buff + SZ ? fread(pos = buff, 1, SZ, stdin), *pos : *pos)

inline ll read() {
	ll x = 0; int f = 1, c = getchar();
	for (;!isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x<<3) + (x<<1) + (c^48);
	return x * f;
}

const int N = 1 << 17;
int n;
int mod;
vector <int> g[N];
int dp[N];
int ans[N];

void predfs(int u, int p) {
	dp[u] = 1;
	for (int i = 0; i < (int) g[u].size(); ++ i) {
		if (g[u][i] != p) {
			int v = g[u][i];
			predfs(v, u);
			dp[u] = 1LL * dp[u] * (dp[v] + 1) % mod;
		}
	}
//	printf("dp[%d] = %d\n", u, dp[u]);
}

void dfs(int u, int p, int res) {
	ans[u] = 1LL * res * dp[u] % mod;
	vector <int> son;
	for (int i = 0; i < (int) g[u].size(); ++ i)
		if (g[u][i] != p) son.push_back(g[u][i]);
	vector <int> pre, suf;
	pre.resize(son.size() + 1);
	suf.resize(son.size() + 1);
	pre[0] = suf.back() = 1;
	for (int i = 0; i < (int) son.size(); ++ i) pre[i + 1] = 1LL * pre[i] * (dp[son[i]] + 1) % mod;
	for (int i = (int) son.size() - 1; ~i; -- i) suf[i] = 1LL * suf[i + 1] * (dp[son[i]] + 1) % mod;
//	printf("%d\n", u);
//	printf("pre "); for (int i = 0; i < (int) pre.size(); ++ i) printf("%d%c", pre[i], " \n"[i + 1 == (int) pre.size()]);
//	printf("suf "); for (int i = 0; i < (int) suf.size(); ++ i) printf("%d%c", suf[i], " \n"[i + 1 == (int) suf.size()]);
	for (int i = 0; i < (int) son.size(); ++ i) {
		int v = son[i];
		dfs(v, u, (1 + 1LL * res * pre[i] % mod * suf[i + 1] % mod) % mod);
	}
}

int main() {
	n = read(), mod = read();
	for (int i = 1; i < n; ++ i) {
		int u = read() - 1, v = read() - 1;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	predfs(0, 0);
	dfs(0, 0, 1);
	for (int i = 0; i < n; ++ i) printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 27392
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

struct P {
    int x,y,d;
};

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

int main(){
    int h,w,k; cin >> h >> w >> k;
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    --x1,--y1, --x2,--y2;
    vector<string> da(h);
    rip(i,h,0) cin >> da[i];
    vector<vector<int>> gr(h, vector<int>(w,-1));
    queue<P> q;
    rip(i,4,0) {
        gr[x1][y1] = 0;
        q.push({x1, y1, 0});
    }
    auto in_table = [&](int x, int y) {return 0 <= x && x < h && 0 <= y && y < w && da[x][y] == '.';};
    while(!q.empty()) {
        auto now = q.front(); q.pop();
        rip(i,4,0) {
            int nx = now.x, ny = now.y, nd = now.d, l = gr[nx][ny];
            rip(j,k,0) {
                nx += dx[i], ny += dy[i];
                if(in_table(nx, ny) && gr[nx][ny] == -1) {
                    gr[nx][ny] = l+1;
                    q.push({nx, ny, i});
                }
                else if(in_table(nx, ny) && gr[nx][ny]== l+1) continue;
                else break;
            }
        }
    }
    cout << gr[x2][y2] << endl;
}


Measured memory_bytes: 12096
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

const int MAX_N = 1<<17;

int n, dat[MAX_N*2-1], lazy[MAX_N*2-1];
bool flag[MAX_N*2-1];

void init(int n_) {
  n = 1;
  while(n < n_) n *= 2;
  REP(i, n*2-1) {
    dat[i] = INT_MAX;
    lazy[i] = 0;
    flag[i] = false;
  }
}

void eval(int k, int l, int r) {
  if(flag[k]) {
    dat[k] = lazy[k];
    if(r-l>1) {
      lazy[2*k+1] = lazy[k]; flag[2*k+1] = true;
      lazy[2*k+2] = lazy[k]; flag[2*k+2] = true;
    }
    flag[k] = false;
  }
}

void update(int a, int b, ll x, int k=0, int l=0, int r=-1) {
  if(r < 0) r = n;
  // cout << a << " " << b << " " << x << " " << k << " " << l << " " << r << endl;

  eval(k, l, r);

  if(b <= l || r <= a) {
    // cout << "a" << endl;
    return;
  }

  if(a <= l && r <= b) {
    // cout << "b" << endl;
    lazy[k] = x;
    flag[k] = true;
    eval(k, l, r);
  } else {
    // cout << "c" << endl;
    update(a, b, x, 2*k+1, l, (l+r)/2);
    update(a, b, x, 2*k+2, (l+r)/2, r);
    dat[k] = min(dat[2*k+1], dat[2*k+2]);
  }
}

ll getMin(int a, int b, int k=0, int l=0, int r=-1) {
  if(r < 0) r = n;
  // cout << a << " " << b << " " << k << " " << l << " " << r << endl;

  eval(k, l, r);

  if(b <= l || r <= a) {
    // cout << "a" << endl;
    return INT_MAX;
  }
  if(a <= l && r <= b) {
    // cout << "b" << endl;
    return dat[k];
  }
  // cout << "c" << endl;
  ll vl = getMin(a, b, 2*k+1, l, (l+r)/2);
  ll vr = getMin(a, b, 2*k+2, (l+r)/2, r);
  return min(vl, vr);
}

signed main(void)
{
  int nn, q;
  cin >> nn >> q;
  init(nn);

  REP(i, q) {
    int a;
    cin >> a;
    if(a == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      t++;
      update(s, t, x);
    } else {
      int s, t;
      cin >> s >> t;
      t++;
      cout << getMin(s, t) << endl;
    }
    // cout << "dat: ";
    // REP(i, 2*n-1) cout << dat[i] << " "; cout << endl;
    // cout << "laz: ";
    // REP(i, 2*n-1) cout << lazy[i] << " "; cout << endl;
    // cout << "flg: ";
    // REP(i, 2*n-1) cout << flag[i] << " "; cout << endl;
  }


  return 0;
}

Measured memory_bytes: 5432
#include<iostream>
 
using namespace std;
 
int main(){
  int n, n1, n2, n3;
  
  cin >> n;
  
  n1 = n % 10;
  n = n / 10;
  n2 = n % 10;
  n3 = n / 10;
  
  cout << n1 + n2 + n3 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int h, w, sx, sy;
int map[505][505];
int forbid[505][505];
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};

bool check(int x, int y)
{
	int nx, ny;
	for(int i = 0; i < 4; i++){
		nx = x + dx[i], ny = y + dy[i];
		if(nx < 0 || nx > w+1 || ny < 0 || ny > h+1) continue;
		if(forbid[nx][ny] == 3) continue;
		if(map[x][y] & (1<<i)) forbid[nx][ny] |= 2;
		else forbid[nx][ny] |= 1;
		if(forbid[nx][ny] == 3) check(nx, ny);
	}
}

int main(void)
{
	while(1){
		cin >> h >> w >> sy >> sx;
		if(h == 0 && w == 0 && sx == 0 && sy == 0) break;
		
		for(int x = 0; x <= w+1; x++){
			for(int y = 0; y <= h+1; y++){
				map[x][y] = 0;
			}
		}
		int a;
		for(int i = 1; i <= 2*h+1; i++){
			if(i % 2){
				for(int j = 1; j <= w; j++){
					cin >> a;
					if(a) map[j][i/2+1] |= 1<<1, map[j][i/2] |= 1<<3;
				}
			}
			else{
				for(int j = 1; j <= w+1; j++){
					cin >> a;
					if(a) map[j][i/2] |= 1<<2, map[j-1][i/2] |= 1<<0;
				}
			}
		}
		
		for(int x = 0; x <= w+1; x++){
			for(int y = 0; y <= h+1; y++){
				if(x == 0 || x == w+1 || y == 0 || y == h+1) forbid[x][y] = 3;
				else forbid[x][y] = 0;
			}
		}
		for(int x = 0; x <= w+1; x++){
			for(int y = 0; y <= h+1; y++){
				if(forbid[x][y] == 3) check(x, y);
			}
		}
		
		if(forbid[sx][sy] & 1) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 5196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N;
int p[200];

vector<int> ans;
void proceed(int k){
	ans.pb(k);
	for(int i=k;i<N;i++) swap(p[i],p[i-k]);
}

void Swap(int i,int j){
	rep(k,i+1) proceed(1);
	proceed(N-1);
	rep(k,N-(i+1)) proceed(1);
}
int main(){
	cin>>N;
	rep(i,N) cin>>p[i];
	rep(t,20){
		int k = rand()%(N-1)+1;
		proceed(k);
	}
	rep(i,N-1) rep(j,N-1) if(p[j+1]<p[j]){
		Swap(j,j+1);
	}
	vector<int> nans;
	int cnt1 = 0;
	for(int v:ans){
		if(v==1){
			cnt1++;
			if(cnt1==N) cnt1 = 0;
		}else{
			rep(t,cnt1) nans.pb(1);
			nans.pb(v);
			cnt1 = 0;
		}
	}
	rep(t,cnt1) nans.pb(1);
	ans = nans;
	cout<<ans.size()<<endl;
	for(int v:ans) cout<<v<<endl;

//	rep(i,N) show(p[i]);
}


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

int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> AB(M + 1);
  vector<int> V(N + 1);
  for (int i = 0, a, b; i < M && cin >> a >> b; i++) {
    if (a == 1) V.at(b) = 1;
    AB.at(i) = {a, b};
  }
  for (int i = 0; i < M; i++) if (V.at(AB.at(i).first) && AB.at(i).second == N) {
    cout << "POSSIBLE" << "\n";
    return 0;
  }
  cout << "IMPOSSIBLE" << "\n";
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) cin>>A.at(i);

    vector<int> B(N);
    int x;
    for (int i=0; i<N; i++) {
        x=A.at(i)-1;
        B.at(x)=i+1;
    }

    for (int i=0; i<N; i++) cout<<B.at(i)<<" ";
        
    cout << endl;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;


int main() {
    char c;
    cin >> c;
    c = c + 1;
    cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    const int max_n = 1000002;
    vector<int> nums;
    for(int i=1;i<200;i++){
        int n = i * (i + 1) * (i + 2) / 6;
        if(max_n < n) break;
        nums.push_back(n);
    }

    vector<int> all(max_n, max_n);
    vector<int> odd(max_n, max_n);

    all[0] = 0;
    odd[0] = 0;
    for(int i=0;i<max_n;i++){
        for(int n : nums){
            if(max_n <= i + n) break;
            all[i+n] = min(all[i+n], all[i] + 1);
        }
        for(int n : nums){
            if(max_n <= i + n) break;
            if(n % 2 == 1) odd[i+n] = min(odd[i+n], odd[i] + 1);
        }
    }

    while(true){
        int N;
        cin >> N;
        if(N == 0) break;
        cout << all[N] << " " << odd[N] << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  string s, t; cin >> s >> t;
  int n = s.size(), m = t.size();
  string ans = "UNRESTORABLE";
  for (int i = n - m; i >= 0; --i) {
    if (not (s[i] == '?' or s[i] == t[0])) { continue; }
    int j = 0;
    string u = s;
    while (i + j < n and j < m and (s[i + j] == t[j] or s[i + j] == '?')) {
      if (s[i + j] == '?') { u[i + j] = t[j]; }
      ++j;
    }
    if (j == m) {
      ans = u;
      break;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (ans[i] == '?') { ans[i] = 'a'; }
  }

  printf("%s\n", ans.c_str());
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

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

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

int a, b, c, d;

int main(){
	ri2(a,b);
	ri2(c,d);
	cout << max(a*b,c*d) << endl;
	return 0;
}


Measured memory_bytes: 256
N=list(str(input()))
F=[N[0]+'+-'[i%2]+N[1]+'+-'[(i//2)%2]+N[2]+'+-'[(i//4)%2]+N[3] for i in range(8)]
for f in F:
    if eval(f)==7:
        print(f+'=7')
        break
    else:
        continue

Measured memory_bytes: 3060
/**
 * Title: D - Triangles
 * Url: https://atcoder.jp/contests/abc143/tasks/abc143_d
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
    int n; cin >> n;
    vector<int> l(n);
    for(int i=0; i<n; i++) cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    for(int i=0; i<n-2; i++) {
        for(int j=i+1; j<n-1; j++) {
            auto x = lower_bound(l.begin()+j, l.end(), l[i]+l[j]);
            auto pos = distance(l.begin(), x);
            ans += pos-j-1;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX 10010
int main(){
  int n,T;
  cin>>n>>T;
  int ans=MAX;
  for(int i=0;i<n;i++){
      int c,t;
      cin>>c>>t;
      if(t<=T){
        ans=min(ans,c);
      }
 }
    if(ans!=MAX)cout<<ans<<endl;
    else cout<<"TLE"<<endl;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  val rn = StdIn.readLine().trim.toInt
  val ra = StdIn.readLine().trim.split(' ').map(_.toInt)

  def bubbleSort(a: Array[Int], n: Int): (Array[Int], Int) = {
    var flag = true
    var i = 0
    var changeCount = 0
    while(flag){
      flag = false
      //(rn - 1 to 1 by -1).foreach{ j =>
      (rn - 1 to i + 1 by -1).foreach{ j =>
        if(a(j) < a(j - 1)){
          val t = a(j)
          a(j) = a(j - 1)
          a(j - 1) = t
          flag = true
          changeCount += 1
        }
      }
      i += 1
    }
    (a, changeCount)
  }

  val (r, c) = bubbleSort(ra, rn)
  println(r.toList.mkString(" "))
  println(c)
  
}



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

const int maxn=3e3+10;
double p[maxn];
double dp[maxn][maxn];
int n;

int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	 cin>>p[i];
    dp[1][1]=p[1];
    dp[1][0]=1.0000000-p[1];
    for(int i=2;i<=n;++i)
    {
        for(int j=0;j<=i;++j)
        {
            if(j==0)
            {
                dp[i][j]=dp[i-1][j]*(1.00000-p[i]);
                continue;
            }
            dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1.0000-p[i]);
        }
    }
    double ans=0.00000000000;
    for(int i=(n+1)/2;i<=n;++i)
     ans+=dp[n][i];
    printf("%.10lf\n",ans);
    return 0;
}

Measured memory_bytes: 49940
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  string s;
  cin >> s;
  int n = s.size() + 1;
  vl indeg(n, 0);
  rep(i, s.size()) {
    if (s[i] == '>') {
      indeg[i]++;
    } else {
      indeg[i + 1]++;
    }
  }
  vl d(n, -1);
  queue<pll> que;
  rep(i, n) {
    if (indeg[i] == 0) {
      que.push({i, 0});
    }
  }
  while (!que.empty()) {
    auto p = que.front();
    que.pop();
    ll i = p.first;
    ll val = p.second;
    // cerr << "!" << i << "," << val << endl;
    if (d[i] < val) {
      d[i] = val;
      if (i + 1 < n && s[i] == '<') {
        que.push({i + 1, val + 1});
      }
      if (i - 1 >= 0 && s[i - 1] == '>') {
        que.push({i - 1, val + 1});
      }
    }
  }
  ll ans = 0;
  rep(i, n) { ans += d[i]; }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12536
#include<cstdio>
#include<vector>
std::vector<int>g[100005];
int in[100005], size[100005];
int delet[100005];
int keep[100005], rkeep[100005];
int a[100005], b[100005];
int gtotal = -1;

void dfs(int u){
    delet[u] = 1;
    keep[++gtotal] = u;
    for(int v: g[u]){
        if(!delet[v]) dfs(v);
    }
}

void getAns(int seq[],int ans[],int n){
    int count = 0, base = 1;
    ans[++count] = 1; 
    for(int i = 1; i <= n; i++){
        int u = seq[i];
        int curCnt = size[u]-2;
        for(int j = 0; j < curCnt; j++){
            ans[++count] = base+j+2;
        }
        ans[++count] = ++base;
        base += curCnt;
    }
    ans[++count] = ++base;
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n-1; i++){
        int u,v;
        scanf("%d%d",&u,&v);
        in[u]++, in[v]++;
        size[u]++, size[v]++;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(int i = 1; i <= n; i++){
        if(in[i]==1) delet[i] = 1;
    }
    for(int i = 1; i <= n; i++){
        if(delet[i]){
            for(int u: g[i]) in[u]--;
        }
    }
    int ok = 1, find = -1;
    for(int i = 1; i <= n; i++){
        if(in[i]>2) ok = 0;
        if(in[i]==1 && !delet[i]) find = i;
    }
    if(!ok) printf("-1\n");
    else{
        gtotal = 0;
        dfs(find);
        if(gtotal==1){
            if(n==2) printf("1 2\n");
            else{
                printf("1 ");
                for(int i = 3; i <= n-1; i++) printf("%d ",i);
                printf("2 %d\n",n);
            }
        }
        else{
            for(int i = 1; i <= gtotal; i++){ 
                //printf("keep[%d] = %d\n",i,keep[i]);
                rkeep[i] = keep[gtotal-i+1];
            }
            getAns(keep,a,gtotal);
            getAns(rkeep,b,gtotal);
            /*for(int i = 1; i <= n; i++) printf("%d ",a[i]);
            printf("\n");
            for(int i = 1; i <= n; i++) printf("%d ",b[i]);
            printf("\n");*/
            int fix = -1;
            for(int i = 1; i <= n; i++){
                if(fix==-1){
                    if(a[i]!=b[i]){
                        if(a[i]<b[i]) fix = 0, printf("%d ",a[i]);
                        else fix = 1, printf("%d ",b[i]);
                    }
                    else printf("%d ",a[i]);
                }
                else{
                    if(fix==0) printf("%d ",a[i]);
                    else printf("%d ",b[i]);
                }
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 14472
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cctype>
using namespace std;
typedef string::const_iterator State;

int expression(State &begin);
int expression2(State &begin);
int term(State &begin);
int number(State &begin);

int number(State &begin){
	int ret=0;
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin-'0';
		begin++;
	}
	return ret;
}

int term(State &begin){
	int ret=number(begin);
	while(1){
		if(*begin=='*'){
			begin++;
			ret*=number(begin);
		}else{
			break;
		}
	}
	return ret;
}

int expression(State &begin){
	int ret=term(begin);
	while(1){
		if(*begin=='+'){
			begin++;
			ret+=term(begin);
		}else{
			break;
		}
	}
	return ret;
}

int expression2(State &begin){
	int ret=number(begin);
	while(1){
		if(*begin=='+'){
			begin++;
			ret+=number(begin);
		}else if(*begin=='*'){
			begin++;
			ret*=number(begin);
		}else{
			break;
		}
	}
	return ret;
}



int main(void){
	string str;
	cin >> str;
	State begin=str.begin();
	int ans=expression(begin);
	begin=str.begin();
	int ans2=expression2(begin);
	int n;
	scanf("%d",&n);
	if(n==ans && n==ans2)printf("U\n");
	if(n==ans && n!=ans2)printf("M\n");
	if(n!=ans && n==ans2)printf("L\n");
	if(n!=ans && n!=ans2)printf("I\n");	
	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

const int N = 8;
char m[N][N];

inline bool check(int x, int y){ return 0<=x&&x<N && 0<=y&&y<N; }

int main()
{
  while(true){
    rep(i, N) rep(j, N) if(!(cin >> m[i][j])) return 0;

    rep(i, N) rep(j, N) if(m[i][j] == '1'){
      if(check(i+1, j+1) && m[i+1][j]=='1' && m[i][j+1]  =='1' && m[i+1][j+1]=='1') cout << "A" << endl;
      if(check(i+3, j  ) && m[i+1][j]=='1' && m[i+2][j]  =='1' && m[i+3][j]  =='1') cout << "B" << endl;
      if(check(i  , j+3) && m[i][j+1]=='1' && m[i][j+2]  =='1' && m[i][j+3]  =='1') cout << "C" << endl;
      if(check(i+2, j-1) && m[i+1][j]=='1' && m[i+1][j-1]=='1' && m[i+2][j-1]=='1') cout << "D" << endl;
      if(check(i+1, j+2) && m[i][j+1]=='1' && m[i+1][j+1]=='1' && m[i+1][j+2]=='1') cout << "E" << endl;
      if(check(i+2, j+1) && m[i+1][j]=='1' && m[i+1][j+1]=='1' && m[i+2][j+1]=='1') cout << "F" << endl;
      if(check(i+1, j+1) &&
         check(i+1, j-1) && m[i][j+1]=='1' && m[i+1][j-1]=='1' && m[i+1][j]  =='1') cout << "G" << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 1136
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, K): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let mut E = (1..N).map(|i| (i, N)).collect::<Vec<_>>();
    let mut k = (N - 2) * (N - 1) / 2;
    for i in 1..N {
        for j in (i + 1)..N {
            if k > K {
                E.push((i, j));
                k -= 1;
            }
        }
    }
    let ans = if k != K {
        "-1".to_string()
    } else {
        format!(
            "{}\n{}",
            E.len(),
            E.iter()
                .map(|&(i, j)| format!("{} {}", i, j))
                .collect::<Vec<_>>()
                .join("\n")
        )
    };

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;
    vi b = a;
    sort(_all(b));
    int r = b[n / 2];
    int l = b[n / 2 - 1];

    for(auto& e : a){
        if(e < r){
            cout << r << endl;
        }
        else {
            cout << l << endl;
        }
    }

    return 0;
}


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

using namespace std;

int main(){
  int N;
  vector<int> fig(110);
  
  cin >> N;
  
  for(int i=0; i<N; i++){
    cin >> fig.at(i);
  }
  
  double reverse_sum = 0;
  for(int i=0; i<N; i++){
    reverse_sum += 1/double(fig.at(i));
  }
  reverse_sum = 1/reverse_sum;
  cout << reverse_sum << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
  int i,n,m;
  for(i=1;;i++){
    scanf("%d %d",&n,&m);
    if(n==0 && m==0)break;
    if(n>m)printf("%d %d\n",m,n);
    else printf("%d %d\n",n,m);
  }
  return 0;
}



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

int main(void){
	int N, M;
	cin >> N >> M;
	vector<int> n(N);
	vector<int> e[N];
	for(int i = 0; i < M; ++i){
		int x, y;
		cin >> x >> y;
		x--; y--;
		e[x].push_back(y);
		n[y]++;
	}
	queue<int> q;
	for(int i = 0; i < N; ++i){
		if(n[i] == 0) q.push(i);
	}
	vector<int> dp(N, 0);
	while(!q.empty()){
		int v = q.front(); q.pop();
		for(auto x : e[v]){
			n[x]--;
			if(n[x] == 0){
				q.push(x);
				dp[x] = max(dp[x], dp[v]+1);
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < N; ++i){
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    long long a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    if(a + b > 2 * c){
        if(x > y){
            cout << min(y * 2 * c + (x-y) * a, x * 2 * c);
        }
        else{
            cout << min(x * 2 * c + (y-x) * b, y * 2 * c);
        }
    }
    else{
        cout << x * a + y * b;
    }

    return 0;
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    int count = 0;
    REP(i, 0, n){
        int a; cin >> a;
        if(a != i+1){
            count++;
        }
    }
    if(count <= 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int child,weight;
vector<vector<pii>> G;
vi visited;
vi color;
void dfs(int now){
  visited[now] = 1;
  for(auto e: G[now]){
    child = e.first;
    weight = e.second;
    if(weight%2==1)color[child]=(color[now]+1)%2;
    else color[child]=color[now];
    if(!visited[child]) dfs(child);
  }
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin>>N;
  G.assign(N,vector<pii>());
  color.assign(N,0);
  visited.assign(N,0);
  int u,v,w;

  REP(i,N-1){
    cin>>u>>v>>w;
    u--;v--;
    G[u].push_back(make_pair(v,w%2));
    G[v].push_back(make_pair(u,w%2));
  }

  dfs(0);
  REP(i,N)cout<<color[i]<<"\n";
  return 0;
}


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

int main(){
	int input = -1;
	int i = 0;

	while (true){
		cin >> input;
		i++;
		if(input == 0){
			break;
		}else if(1 <= input && input <= 10000){
			cout << "Case" << " " << i << ":" << " " << input << endl;
		}else{
			cout << "error" << endl;
			break;
		}
	}
	return 0;

}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  int N,T,A;
  scanf("%d",&N);
  scanf("%d%d",&T,&A);
  int h;
  int t = 99999999;
  int num = 0;
  for(int i = 0; i < N; ++i){
    scanf("%d",&h);
      if( t > abs( A*1000 - (T * 1000 - h * 6) ) ){
        t = abs( A*1000 - (T * 1000 - h * 6) );
        num = i+1;
    }
  }


  printf("%d",num);

  return 0;
}


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

int main(){
    string s;
    string t;
    cin >> s;
    cin >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if(s<t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
before_a = -2
ans = 0
for a in A:
    ans += B[a - 1]
    if before_a + 1 == a:
        ans += C[a - 2]
    before_a = a
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  string S;
  cin >> S;
  int ans = INT_MAX;
  int cnt = 0, cnt1 = 0;
  for(int i = 0; i < S.size(); i++){
    if(S[i] - '0' != cnt1) cnt++;
    cnt1 = (cnt1 + 1) % 2;
  }
  ans = min(ans, cnt);
  cnt = 0, cnt1 = 1;
  for(int i = 0; i < S.size(); i++){
    if(S[i] - '0' != cnt1) cnt++;
    cnt1 = (cnt1 + 1) % 2;
  }
  ans = min(ans, cnt);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

UNVISITED, VISITED_IN_STACK, POPPED_OUT = 0, 1, 2


def generate_adj_matrix(v_info):
    for v_detail in v_info:
        v_adj_list = v_detail[2:]
        assert len(v_adj_list) == int(v_detail[1])
        for each in v_adj_list:
            init_adj_matrix[int(v_detail[0]) - 1][int(each) - 1] = 1
    return init_adj_matrix


def graph_dfs(v_init):
    global time

    # init the first node of overall graph iterations(times >= 1)
    vertex_visit_stack.append(v_init)
    vertex_status_list[v_init] = VISITED_IN_STACK
    vertex_d_time[v_init] += time
    # init end

    while len(vertex_visit_stack) > 1:
        current_vertex = vertex_visit_stack[-1]
        next_vertex = get_adj_vertices(vertex=current_vertex)

        if next_vertex:
            if vertex_status_list[next_vertex] is UNVISITED:
                vertex_status_list[next_vertex] = VISITED_IN_STACK
                time += 1
                vertex_d_time[next_vertex] += time
                vertex_visit_stack.append(next_vertex)
        else:
            vertex_visit_stack.pop()
            vertex_status_list[current_vertex] = POPPED_OUT
            time += 1
            vertex_f_time[current_vertex] += time

    return None


def get_adj_vertices(vertex):
    index = int(vertex) - 1
    for j in range(vertex_num):
        if adj_matrix[index][j]:
            adj_matrix[index][j] = 0
            return j + 1
    return None


def dfs_start():
    global time
    for i in range(vertex_num):
        if vertex_status_list[i + 1] == UNVISITED:
            # print('round', i + 1)
            graph_dfs(v_init=i + 1)
            time += 1


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertex_num = int(_input[0])
    vertex_info = list(map(lambda x: x.split(), _input[1:]))
    init_adj_matrix = [[0] * vertex_num for _ in range(vertex_num)]
    # assert len(vertex_info) == vertex_num

    # config length = (vertex_num + 1)
    vertex_visit_stack = [-1]
    vertex_status_list = [UNVISITED] * vertex_num
    vertex_status_list.insert(0, -1)
    vertex_d_time, vertex_f_time = ([0] * (vertex_num + 1) for _ in range(2))

    adj_matrix = generate_adj_matrix(vertex_info)
    # timing start from 1
    time = 1
    dfs_start()
    for k in range(vertex_num):
        print(k + 1, vertex_d_time[k + 1], vertex_f_time[k + 1])

Measured memory_bytes: 7936
// デバッグ実行：Ctrl+F5

using System;

class Program
{
    static void Main(string[] args)
    {
        String line;
        line = Console.ReadLine();
        String[] words = line.Split(' ');
        int X = int.Parse(words[0]);
        int Y = int.Parse(words[1]);
        
        Console.WriteLine(X + (Y / 2));
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define m 1000000007
using namespace std;
vector<vector<int>> adj;
vector<vector<int>> dp;
int dfs(int r,int par=-1,int color=1){
    if(dp[r][color]!=-1)return dp[r][color];
    long long ans = 1LL;
    for(auto c:adj[r]){
        if(c==par)continue;
        int temp = dfs(c,r,1);
        if(color==1)temp+=dfs(c,r,0);
        ans*=temp;
        ans%=m;
    }
    dp[r][color] = ans;
    return dp[r][color];
}
int main(){
    int n,u,v;
    cin>>n;
    adj.assign(n,vector<int>());
    dp.assign(n,vector<int>(2,-1));
    for(int i=0;i<n-1;i++){
        cin>>u>>v;
        u--;v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    cout<<(dfs(0)+dfs(0,-1,0))%m<<"\n";
    return 0;
}

Measured memory_bytes: 19584
#include <stdio.h>

int main () {
	int k, a, b;
	int flag = 0;
	scanf("%d", &k);
	scanf("%d %d", &a, &b);
	for (int i = a ; i <= b ; i++) {
		if (i % k == 0) {
			flag = 1;
		}
	}
	if ( flag == 1) {
		printf("OK\n");
	}	else {
		printf("NG\n");
	}
	return 0;
}

Measured memory_bytes: 1640
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, K; cin >> N >> K;

    int mod[K] = {};
    REP(i, 1, N + 1) mod[i % K]++;

    ll ans = 0;
    REP(a, 0, K) {
        int b = (K - a) % K;
        int c = (K - a) % K;
        if ((b + c) % K != 0) continue;
        ans += (ll)mod[a] * mod[b] * mod[c];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
    long long int k,a,b;

    cin >>k >>a >>b;

    long long int efficient = b - a;

    long long int ans;
    // answer is k
    if(efficient <= 2 || k < a + 1){
        ans = k + 1;
    }else{
        // increase
        k -= (a - 1);
        ans = a + efficient * (k / 2) + ( k % 2);
    }
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main() {
	int a,b,k;
	scanf("%d%d%d",&a,&b,&k);
	bool f = true;
	while(k--) {
		if(f) {
			int t=a/2;
			if(a%2 == 1)
				a--;
			a = a-t;
			b = b+t;
			f = false;
		}
		else {
			int t=b/2;
			if(b%2 == 1)
				b--;
			b = b-t;
			a = a+t;
			f = true;
		}
	}
	printf("%d %d\n",a,b);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
  int h,w;
  int i,j;
  scanf("%d",&h);
  scanf("%d",&w);
  while(!((h==0) && (w==0))){
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d",&h);
    scanf("%d",&w);
  }


  return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define vt vector
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end();
#define sz(x) (int)(x).size()
#define FOR_(i, a, b, s) \
  for (int i = (a); (s) > 0 ? i < (b) : i > (b); i += (s))
#define FOR1(n) FOR_(i, 0, n, 1)
#define FOR2(i, n) FOR_(i, 0, n, 1)
#define FOR3(i, a, b) FOR_(i, a, b, 1)
#define GET5(_1, _2, _3, _4, _5, ...) _5
#define FOR(...) GET5(__VA_ARGS__, FOR_, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define each(x, a) for (auto&& x : a)

constexpr int MX = 200005;
constexpr int INF = 1000000202;
constexpr ll LINF = 1000000000000000202LL;
constexpr ll MOD = 1000000007;  // 998244353;
constexpr ld PI = M_PI;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) { return '"' + s + '"'; }

string to_string(const char* s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) void()
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, W;
  cin >> n >> W;
  vt<int> w(n), v(n);
  FOR(n) { cin >> w[i] >> v[i]; }
  vt<vt<ll>> dp(110, vt<ll>(MX));
  FOR(i, n) {
    FOR(j, W + 1) {
      dp[i + 1][j] =
          max(dp[i][j], (j - w[i] >= 0 ? dp[i][j - w[i]] + v[i] : dp[i][j]));
      debug(i + 1, j, dp[i + 1][j]);
    }
  }
  cout << dp[n][W] << '\n';
  return 0;
}


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

//WA
typedef unsigned long long int ll;

int main()
{
    ll a, b, c, sum = 0;
    const ll con = 1000000007;

    cin >> a >> b >> c;

    if( a > c )
    {
        cout << c % con << endl;
        return 0;
    }

    sum += c % con;
    if( ( c - a + 1 ) % ( a - b ) == 0 )
        sum += ( ( c - a + 1 ) / ( a - b ) % con ) * ( b % con );
    else
        sum += ( ( ( c - a + 1 ) / ( a - b ) + 1 ) % con ) * ( b % con );

    cout << sum % con << endl;

    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define ll long long
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define binary(x) std::string binary = std::bitset<25>(x).to_string(); //to binary
#define inf 1000000007
#define mod 1000000007
#define pi pair<int,int>
#define lpi pair<int,int>
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define lvi vector<long long int>
#define pie 3.14159265358979323846
ll int MMM=inf;
int pw(ll int a, ll int b) {
    if (b == 0) return 1;
    ll int t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
using namespace std;
vi pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.pb(p);
}
bool sortbysecdesc(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    return a.first>b.first;
}
bool cmp(int x,int y){return x>y;}
int gcd(int a,int b)
{
    if(a<b)
        swap(a,b);
    return (b==0)?a:gcd(b,a%b);
}
int ab=0;
vi v[100003];
int dp[100002];
int dfs(int ind)
{
	if(dp[ind])return dp[ind];
	int ans=0;
	for(int i=0;i<v[ind].size();i++)
	{
		ans=max(ans,dfs(v[ind][i]));
	}	
	dp[ind]=ans+1; 
	return ans+1;
}
int main()
{
	faltu;
	int n,m;
	cin>>n>>m;
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
	}
	for(int i=1;i<=n;i++)
	{
		ab=max(ab,dfs(i));
	}
cout<<ab-1<<endl;
}










Measured memory_bytes: 8192
///Nahid Hasan Raju
#include <bits/stdc++.h>
#define ll long long
#define MS(ARRAY,VALUE) memset(ARRAY,VALUE,sizeof(ARRAY))
#define Fin freopen("input.txt","r",stdin)
using namespace std;

#define P(XX) cout<<XX<<endl
#define P1(XX) cerr<<"db1: "<<XX<<endl
#define P2(XX,YY) cerr<<"db2: "<<XX<<" "<<YY<<endl
#define P3(XX,YY,ZZ) cerr<<"db3: "<<XX<<" "<<YY<<" "<<ZZ<<endl
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Fout freopen("output.txt","w",stdout)
#define rep(i,a,b) for(i=a;i<=b;i++)
#define EPS 0.00000001
#define INF INT_MAX
#define PI 2*acos(0.0)
#define set(XX,POS) XX|=(1<<POS)
#define reset(XX,POS) XX&=(~(1<<POS))
#define check(XX,POS) (bool)(XX&(1<<POS))
#define toggle(XX,POS) (XX^(1<<POS))
#define SORT(v) sort(v.begin(),v.end())
#define REVERSE(V) reverse(v.begin(),v.end())
#define VALID(X,Y,R,C) X>=0 && X<R && Y>=0 && Y<C
#define SIZE(ARRAY) sizeof(ARRAY)/sizeof(ARRAY[0])
#define RT printf("Run Time : %0.3lf seconds\n", clock()/(CLOCKS_PER_SEC*1.0))
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree< pair<int,int> , null_type, less< pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> odrst;

#define MOD 1000000007ll
#define MX 2000006  ///200005

ll m, n;
ll a[MX], b[MX];
string s,s1;
map<ll,int>mp;

void func(ll p)
{

}
int main()
{
    int test=1, tc=0, i, j;
    #ifndef ONLINE_JUDGE
    //Fin;
    test=3;
    #endif
    double k, ans, t, kk;
    //scanf("%d", &test);
    while(test--)
    {
        j=0;
        cin>>k>>ans>>t;
        kk=(ans*t);
        if(kk>=k)puts("Yes");
        else puts("No");
        return 0;
        for(i=0;i<n;i++)
        {
            scanf("%lld", &a[i]);
        }



        if(t)puts("YES");
        else puts("NO");

        printf("%lld\n", ans);
        for(i=0;i<ans;i++)
        {
            printf("%lld", b[i]);
        }
    }
    return 0;
}



Measured memory_bytes: 3720