akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
S = input()

def check(x):
    i = 0
    for a in S:
        if a == x[i]:
            i += 1
            if i == 3:
                return True
    return False

cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            x = str(i)+str(j)+str(k)
            if check(x):
                cnt += 1
print(cnt)


Measured memory_bytes: 40556
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



const int INF = 1<<29;

int N, K;
pint pr[2100];

int sum[12][2100];
int dp[12][2100];

int main() {
    while (cin >> N >> K) {
        for (int i = 0; i < N; ++i) cin >> pr[i].second >> pr[i].first;
        sort(pr, pr+N, greater<pint>());
        
        for (int i = 0; i < 12; ++i) {
            for (int j = 1; j < 2100; ++j) sum[i][j] = -INF;
            sum[i][0] = 0;
        }
        
        int num = 0, pre = -1, tot = 0;
        for (int i = 0; i < N; ++i) {
            int so = pr[i].first;
            if (pre != so) {
                pre = so;
                num = 0;
                tot = 0;
            }
            ++num;
            tot += pr[i].second;
            sum[pre][num] = tot + num * (num-1);
            
            //cout << pre << ", " << num << " : " << sum[pre][num] << endl;
        }
         
        memset(dp, -1, sizeof(dp));
        dp[0][0] = 0;
        for (int i = 1; i <= 12; ++i) {
            for (int j = 0; j <= K; ++j) {
                if (dp[i-1][j] == -1) continue;
                
                //cout << i -1 << ", " << j << " : " << dp[i-1][j] << endl;
                
                for (int add = 0; j + add <= K; ++add) {
                    if (sum[i][add] >= 0) {
                        chmax(dp[i][j+add], dp[i-1][j] + sum[i][add]);
                    }
                }
            }
        }
        
        cout << dp[11][K] << endl;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> vec(N);
  for (int i=0; i<N; i++) {
    string s;
    int p;
    cin >> s >> p;
    vec.at(i) = make_tuple(s, -p, i+1);
  }

  sort(vec.begin(), vec.end());

  int ind;
  for (int i = 0; i < N; i++) {
    tie(ignore, ignore, ind) = vec.at(i);
    cout << ind << endl;
  }
}


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

using namespace std;

int main(){
	
	int N;
	cin >> N;
	std::vector<int> L(N);
	int sum=0;

	for (int i = 0; i < N; i++)
	{
		cin >> L[i];
		sum += L[i] ;
	}
	sort(L.begin(),L.end());
	string ans = "Yes";

	if(sum-L[N-1] <= L[N-1])
		ans = "No";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>

std::array<std::size_t, 100001> arr;

int main()
{
    std::size_t N, Q;
    std::cin >> N >> Q;
    std::string str;
    std::cin >> str;
    std::size_t sum = 0;

    for( std::size_t i = 1; i < N; ++i ) {
        if( str[i-1] == 'A' && str[i] == 'C' ) {
            ++sum;
        }
        arr[i+1] = sum;
    }
    
    for( ; Q--; ) {
        std::size_t l, r;
        std::cin >> l >> r;
        std::cout << arr[r] - arr[l-1] - (l-1&&str[l-2]=='A'&&str[l-1]=='C') << std::endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define forna(i,a,n) for(int i=a;i<n;i++)
typedef long long int lli;
using namespace std;

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lli t,n,m;
cin>>n;
if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9) cout<<"hon"<<endl;
if(n%10==0||n%10==1||n%10==6||n%10==8) cout<<"pon"<<endl;
if(n%10==3) cout<<"bon"<<endl;
}


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


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



int main(){
    //1行目を取得
    int h,w;
    cin >> h >> w;
    //1行ずつごと　h個のvectorに突っ込む
    vector<string> s(h);
    rep(i,h) cin >> s[i]; 
    //加算していくカウンター
    int ans = 0;
    //スタート地点を全探索する。スタート地点ごとにBFSを実行
    rep(si,h)rep(sj,w){
        //壁のマスはスルー
        if (s[si][sj] == '#') continue;
        //ベクターの2次元配列による到達番号表。初期値はINFにしておく
        vector<vector<int>> dist(h, vector<int>(w, INF));
        //BFS用のqueueを用意
        queue<P> q;
        //番号表のS[i][j]マスをx（到達番号）にアップデートする無名関数
        //アップデート後、対象のマスを次の処理待ちとしてqueueに追加もしている
        //[&]にすることで、無名関数内でdistやqを更新できるようにする。
        auto update = [&](int i, int j, int x){
            //対象マスが更新済みなら、再更新はしない。（大きい値への上書きを防ぐ）
            if (dist[i][j] != INF) return;
            //xで更新
            dist[i][j] = x;
            //queueにS[i][j]を突っ込む。（隣接探しの処理待ちにする）
            q.push(P(i,j));
        };
        //スタート地点(si,sj)の番号表を0で更新
        update(si,sj,0);
        //BFS実行。queueがなくなるまで、「隣接する(最大4つの)マスを探し、到達番号表のupdate」を繰り返す
        while(!q.empty()){
            //queueの最初の要素（front())から、座標i,jを取得する
            //要素はpair型なので、firstで1要素目、secondで2要素目を取得
            int i = q.front().first;
            int j = q.front().second;
            //最初の要素を使い終わったので、取り出す
            q.pop();
            //移動できる4方向で到達番号表のupdateを行う
            //4方向のdirを配列として定義しておくことで、for文（rep）でシンプルに書ける
            rep(dir,4){
                //ni -> Next i
                int ni = i+di[dir], nj = j+dj[dir];
                //移動できないケース（範囲外の場合、壁の場合）スルー
                if(ni < 0 || nj <0 || ni>=h || nj>=w) continue;
                if(s[ni][nj] =='#') continue;
                //(i,j)の到達番号＋1で、(ni,nj)をアップデート（さらにupdateの中でqueueにプッシュしている）
                update(ni,nj,dist[i][j]+1);
            }
        }
        rep(i,h)rep(j,w){
            //未更新の（=壁または到達不可能）マスはスルー
            if (dist[i][j] == INF) continue;
            //これまでの最大ans（別のスタート地点のものも含む）と、今回の番号表の(i,j)のうち、大きいものに更新
            ans = max(ans, dist[i][j]);
        }
    }
    //出力
    cout << ans <<endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

inline ll mod(ll a, ll m=MOD){return (a%m+m)%m;}
inline ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
inline ll inv(ll n, ll m=MOD){
    ll a = n, b = m, x = 1, y = 0;
    while(b){
        ll t = a/b;
        a -= t*b;
        swap(a, b);
        x -= t*y;
        swap(x, y);
    }
    return mod(a, m); 
}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __{ __(){ /* cin.tie(0); ios::sync_with_stdio(0); */ cout<<fixed<<setprecision(15); } };

int main(){

    int k, x;
    scanf("%d%d", &k, &x);
    Judge(k*500 >= x);



    return 0;
}


Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	final long MODULO = 998244353L;
	long[] fac = new long[400];
	long[] invfac = new long[400];
	long[] inv = new long[400];
	long[][] C = new long[400][400];
	long[] pow2 = new long[400];
	{
		fac[0] = 1;
		invfac[0] = 1;
		inv[1] = 1;
		for (int i = 1; i < fac.length; ++i) {
			fac[i] = fac[i - 1] * i % MODULO;
		}
		for (int i = 2; i < inv.length; ++i) {
			inv[i] = (MODULO - (MODULO / i) * inv[(int) (MODULO % i)] % MODULO) % MODULO;
		}
		for (int i = 1; i < invfac.length; ++i) {
			invfac[i] = invfac[i - 1] * inv[i] % MODULO;
		}
		C[0][0] = 1;
		for (int i = 1; i < C.length; ++i) {
			for (int j = 0; j <= i; ++j) {
				C[i][j] = (j > 0 ? C[i - 1][j - 1] : 0) + C[i - 1][j];
				C[i][j] %= MODULO;
			}
		}
		pow2[0] = 1;
		for (int i = 1; i < pow2.length; ++i) {
			pow2[i] = pow2[i - 1] * 2 % MODULO;
		}

	}

	void run() {
		Scanner sc = new Scanner(System.in);
		Random rand = new Random();
		// while (true) {
		int n = sc.nextInt();
		// int n = rand.nextInt(5);
		long[] x = new long[n];
		long[] y = new long[n];
		for (int i = 0; i < n; ++i) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			// x[i] = rand.nextInt(5);
			// y[i] = rand.nextInt(5);
		}
		solver(n, x, y);
		// }
	}

	void solver(int n, long[] x, long[] y) {
		long ans = pow2[n];

		ans = (ans - n + MODULO) % MODULO;
		for (int i = 0; i < n; ++i) {
			boolean[] vis = new boolean[n];
			vis[i] = true;
			for (int j = i + 1; j < n; ++j) {
				if (vis[j])
					continue;
				vis[j] = true;
				int cnt = 1;
				for (int k = j + 1; k < n; ++k) {
					if ((x[i] - x[j]) * (y[k] - y[i]) == (y[i] - y[j]) * (x[k] - x[i])) {
						if (vis[k]) {
							throw new AssertionError();
						}
						vis[k] = true;
						++cnt;
					}
				}
				ans = (ans - (pow2[cnt] - 1) + MODULO) % MODULO;
			}
		}
		System.out.println(ans - 1);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 28244
N = int(input())
A = input().split(" ")
D = int(A[0])
X = int(A[1])


sum = X
list = []



for i in range(N):
    eat = int(input())
    day = 1

    while True:
        if(day > D):
            break
        day += eat
        sum += 1


print(sum)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int h, w, d; cin >> h >> w >> d;
  if (d & 1) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) cout << (i + j & 1 ? 'R' : 'Y');
      cout << '\n';
    }
  } else {
    string s = "RYBG";
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        int x = (i + w - j) % (2 * d) / d;
        int y = (i + w + j) % (2 * d) / d;
        cout << s[2 * x + y];
      }
      cout << '\n';
    }
  }
}

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

string s;

bool chk_block(int a, int b) {
	for (int i = a; i <= b - 1; ++i) {
		if (s[i] == '#' && s[i + 1] == '#')return false;
	}
	return true;
}

bool chk_jump(int a, int b) {
	for (int i = a; i <= b; ++i) {
		if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.')return true;
	}
	return false;
}

signed main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	--a; --b; --c; --d;
	cin >> s;
	bool ans;
	if (c < d)ans = chk_block(a, d);
	else ans = chk_block(a, c) && chk_jump(b, d);

	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>

using namespace std;


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


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll INF=1LL<<60;
const int MOD=1e9+7;

int main(){
    int N, M, K; cin >> N >> M >> K;
    vi A(N), B(M);
    vector<ll> s1(N+1, 0), s2(M+1, 0);
    for(int i=0; i<N; i++){
        cin >> A[i];
        s1[i+1]+=s1[i]+A[i];
    }
    for(int i=0; i<M; i++){
        cin >> B[i];
        s2[i+1]+=s2[i]+B[i];
    }
    int res=0, pos=0;
    for(int i=0; i<=N; i++){
        while(pos <= M && s1[i]+s2[pos] <= K){
            res=max(res, i+pos);
            pos++;
        }
        if(pos > 0) pos--;
    }
    pos=0;
    for(int i=0; i<=M; i++){
        while(pos <= N && s2[i]+s1[pos] <= K){
            res=max(res, i+pos);
            pos++;
        }
        if(pos > 0) pos--;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 7984
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define num(a) a-'0'
#define maxself(a,b) if(b>a)a=b
#define minself(a,b) if(b<a)a=b;
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define vl vector<long long int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"	
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	int n;
	cin>>n;
	v<v<p<int,int>>> a(n);
	int h;
	rep(i,0,n){
		cin>>h;
		rep(j,0,h){
			int x,pos;
			cin>>x>>pos;
			a[i].pb(mk(x,pos));
		}
	}
	ll ans=0;
	for(int bit=0;bit<(1<<n);bit++){
		int counter=0;
		int pos=1;
		for(int j=0;j<n;j++){
			if(1<<j & bit){
				for(auto e:a[j]){
					h=((1<<(e.f-1)) & bit);
					if(h==0 && e.s==1){
						pos=0;
					}
					else if(h!=0 && e.s==0){
						pos=0;
						break;
					}
				}
				counter++;
			}
		}
		if(pos){
			maxself(ans,counter);
		}
	}
	cout<<ans<<ln;
}

int main(){
	boost_io;
	solve();
	return 0;
}

Measured memory_bytes: 3600
// https://atcoder.jp/contests/dp/tasks/dp_c

#include <iostream>

using namespace std;
using ll =  long long;

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

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

    ll dp[n][3];

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for (int i = 1; i < n; ++i) {
        int beforeA = dp[i - 1][0];
        int beforeB = dp[i - 1][1];
        int beforeC = dp[i - 1][2];

        int currentA = a[i];
        int currentB = b[i];
        int currentC = c[i];

        dp[i][0] = max(beforeB + currentA, beforeC + currentA);
        dp[i][1] = max(beforeA + currentB, beforeC + currentB);
        dp[i][2] = max(beforeA + currentC, beforeB + currentC);
    }

    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>

int main(int argc, char **argv)
{
	unsigned long long target = 0;
	unsigned long long count = 0;

	std::cin >> target;
	count = ((target / 11) * 2);
	if (target % 11 > 6) {
		count += 2;
	}
	else if (target % 11 > 0) {
		count++;
	}
	else {
		// Do nothing.
	}

	std::cout << count;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(void) {
    char S[10];
    scanf("%s", S);
    
    switch(S[0]) {
        case 'S':
            printf("Cloudy\n");
            break;
        case 'C':
            printf("Rainy\n");
            break;
        case 'R':
            printf("Sunny\n");
    }
   

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
    return 0;
}

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

int main()
{
	string s;
	cin >> s;
	if(s == "Sunny")
		cout << "Cloudy" << endl;
	else if(s == "Cloudy")
		cout << "Rainy" << endl;
	else if(s == "Rainy")
		cout << "Sunny" << endl;
	return 0;
 } 

Measured memory_bytes: 256
n = int(input())
max_candy = [ [ 0 for i in range(n) ] for j in range(2) ]
given_candy = [ [ int(v) for v in input().split() ] for j in range(2) ] 



max_candy[0] = [ sum(given_candy[0][:i+1]) for i in range(n) ]
max_candy[1][0] = given_candy[0][0] + given_candy[1][0]
for i in range(n-1):
	max_candy[1][i+1] = max(max_candy[1][i],max_candy[0][i+1])  + given_candy[1][i+1]

print(max_candy[1][-1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;


int main(){
    string s;
    cin >> s;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
        cout<<"Bad"<<endl;return 0;
    }cout<<"Good"<<endl;return 0;
    return 0;
}


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

int main() {
    long n;
    vector<long> vl;
    cin >> n;
    long count = 0;
    for (long i=0; i<n; i++) {
        long unko;
        cin >> unko;
        vl.push_back(unko);
    }
    for (long i=1; i<=n; i++) {
        if (vl[i-1] == i) {
            long unko = vl[i];
            vl[i] = vl[i-1];
            vl[i-1] = unko;
            count ++;
        }
    }
    printf("%ld\n", count);
    return 0;
}


Measured memory_bytes: 1400
program AGC015A
    implicit none
    integer(8)::N,A,B
    read*,N,A,B
    if((N==1.and.A/=B).or.A>B)then
        print'(i0)',0
    else
        print'(i0)',B*(N-1)+A-(B+A*(N-1))+1
    end if
end program AGC015A

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    int N;
    string S;
    cin >> N >> S;
    //sheep = 1 wolf = 0;
    vector<bool> SW(N+1);
    int J[4][2] = {
        {1,1},
        {1,0},
        {0,1},
        {0,0},
    };
    int I = 0;
    while(I < 4){
        SW[0] = J[I][0];
        SW[1] = J[I][1];
        for(int i=1;i<N;i++){
            if(SW[i] && S[i] == 'o'){
                SW[i+1] = SW[i-1];
            }else if(SW[i] && S[i] == 'x'){
                SW[i+1] = !SW[i-1];
            }else if(!SW[i] && S[i] == 'o'){
                SW[i+1] = !SW[i-1];
            }else if(!SW[i] && S[i] == 'x'){
                SW[i+1] = SW[i-1];
            }
        }
        bool a = SW[0] && S[0] == 'o' && SW[1] == SW[N-1];
        bool b = SW[0] && S[0] == 'x' && SW[1] != SW[N-1];
        bool c = !SW[0] && S[0] == 'o' && SW[1] != SW[N-1];
        bool d = !SW[0] && S[0] == 'x' && SW[1] == SW[N-1];
        bool e = SW[0] == SW[N];
        if(e && (a || b || c || d)){
            rep(i,N) cout << (SW[i] ? "S" : "W");
            cout << endl;
            return 0;
        }
        I++;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#define INF 1e9
#define MOD 1000000007
#define MAX 210000
#define ll long long
using namespace std;
typedef unsigned long long ull;
typedef pair<int, int> p;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }
    else{
        int x,y;
        cin>>x>>y;
        cout<<x+y;
    }



    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] argv){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int h = n/3600;
		int m = (n-h*3600)/60;
		int s = (n-h*3600-m*60);
		System.out.println(h+":"+m+":"+s);
	}
}

Measured memory_bytes: 26248
#include<stdio.h>
int main()
{
	int height[10];
	int i;
	int rank[3] = {};
	for (i = 0; i < 10; i++)
	{
		scanf("%d", &height[i]);
		if (height[i] >= rank[0])
		{
			rank[2] = rank[1];
			rank[1] = rank[0];
			rank[0] = height[i];
		}
		else if (height[i] >= rank[1])
		{
			rank[2] = rank[1];
			rank[1] = height[i];
		}
		else if (height[i] >= rank[2])
			rank[2] = height[i];
	}
	printf("%d\n%d\n%d\n", rank[0], rank[1], rank[2]);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n;
   cin>>n;

   long int extra = n % 1000;
   long int ans = 1000 - extra;
   ans %= 1000;
   cout<<ans;
   return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>

int n, m;
char S[100005];
int ans[100005];

int main(){
  scanf("%d%d", &n,&m);
  scanf("%s", S);

  int k = 0;
  for(int i = 0; i < n; ){
    int j = std::min(i + m, n);
    for(; j > i && S[n-j] == '1'; j--) ;
    if(j == i){
      puts("-1");
      return 0;
    }
    ans[k++] = j - i;
    i = j;
  }

  while(k > 0) printf("%d ", ans[--k]);


  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    string s;cin>>s;
    int n=s.size();
    int cnt=0;
    rep(i,n){
        if(s[i]!=s[n-i-1]) cnt++;
    }
    cnt/=2;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cassert>

typedef long long ll;
typedef __int128 u128;

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

int fpow(int a,ll b,int c)
{
	ll w=1,o=a;
	while(b) {
		if(b&1) w=w*o%c;
		o=o*o%c;
		b>>=1;
	}
	return w;
}

int Phi(int n)
{
	int r=n;
	for(int i=2; i*i<=n; i++)
		if(n%i==0)
		{
			r=r/i*(i-1);
			while(n%i==0)n/=i;
		}
	if(n>1)r=r/n*(n-1);
	return r;
}

ll exgcd(ll a,ll b,ll&x,ll&y)
{
	if(!b)
	{
		x=1;
		y=0;
		return a;
	}
	ll c=exgcd(b,a%b,x,y);
	ll t=x;
	x=y;
	y=t-a/b*y;
	return c;
}

ll Inv(ll a,ll b)
{
	ll x,y;
	exgcd(a,b,x,y);
	return(x+b)%b;
}

ll now,M;

void excrt(ll a,ll b)
{
	ll c=((a-now)%b+b)%b;
	ll x,y;
	ll d=exgcd(M,b,x,y);
	assert(c%d==0);
	c/=d;
	b/=d;
	x=(x%b+b)%b;
	x=(u128)x*c%b;
	now+=x*M;
	M*=b;
}

int T,n,m;

ll solve(int d)
{
	if(d==1)
		return 1;
	int pd=Phi(d);
	ll y=solve(gcd(d,pd));
	now=y%pd;
	M=pd;
	excrt(fpow(n,y,d),d);
	return !now?M:now;
}

int main()
{
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d",&n,&m);
		printf("%lld\n",solve(m));
	}
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
long S[100000];
long T[50000];
bool flag[50000];
int n,q;
void binarySearch(long k){
	int lb = -1, ub = q;
	//int mid = (ub + lb) / 2;
	while (ub - lb > 1){
		int mid = (ub + lb) / 2;
		if (T[mid] > k) ub = mid;
		else lb = mid;
	}
	if (T[lb] == k) flag[lb] = true;
	else if (T[ub] == k) flag[ub] = true;
}

int main(){
	scanf("%d",&n);
	for (int i = 0; i < n; ++i) scanf("%d", &S[i]);
	scanf("%d",&q);
	for (int i = 0; i < q; ++i) scanf("%d",&T[i]);
	sort(T, T + q);
	int cnt = 0;
	for (int i = 0; i < n;++i) binarySearch(S[i]);
	for (int i = 0; i < q; ++i) if (flag[i]) ++cnt;
	cout << cnt << '\n';
}

Measured memory_bytes: 2440
open Batteries
(* 文字列をcharのlistにする *)
let explode s = List.init (String.length s) (String.get s)
let s = read_line () |> explode
let _ = (
  if List.nth s 2 = List.nth s 3 && List.nth s 4 = List.nth s 5 then "Yes" else "No") |> print_endline

Measured memory_bytes: 1024
/*
  Contest 088
  A - Infinite Coins
  Rakesh Kumar --> 18/09/2020
 */

#include <bits/stdc++.h>

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

    int n = 0;
    std::cin >> n;
    std::cout << n / 3 << std::endl;

    return 0;
}


Measured memory_bytes: 3604
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
a=[[False]*3 for i in range(3)]
for i in range(3):
    for j in range(3):
        for b in B:
            if A[i][j]==b:
                a[i][j]=True
bingo=False
for i in range(3):
    if a[i][0] and a[i][1] and a[i][2]:
        bingo=True
for j in range(3):
    if a[0][j] and a[1][j] and a[2][j]:
        bingo=True
if a[0][0] and a[1][1] and a[2][2]:
    bingo=True
if a[2][0] and a[1][1] and a[2][0]:
    bingo=True
print("Yes" if bingo else "No")

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main(){

	const int N_MAX=1000000;
	int i,j,n[32],ni,soi,max;
	int so[N_MAX],count[N_MAX];
	
	for(i=0;i<N_MAX;i++)
		so[i]=1;
	ni=0;
	max=0;
	while(cin>>n[ni])
		if(n[ni++]>max)
			max=n[ni-1];
	int sq_max = (int)sqrt(max);
	so[0]=so[1]=0;
	for(soi=0,i=2;i<=sq_max;i++){
		if(so[i]==0)continue;
		for(j=i*2;j<=max;j+=i)
			so[j]=0;
	}
	for(i=2;i<=max;i++){
		count[i] = count[i-1]+so[i];
	}
	for(i=0;i<ni;i++)
		cout << count[n[i]] << endl;

	return 0;
}

Measured memory_bytes: 8968
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
const int N=1e9+7;
#define infi 1e18
int32_t main()
{
	IOS;
    int n,k;
    cin>>n>>k;
    int h[n+1];
    int dp[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>h[i];
        dp[i]=infi;
    }
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
      for(int j=max((int)1,i-k);j<i;j++)
      {
          dp[i] = min(dp[i],abs(h[i]-h[j])+dp[j]);
      }
    }
    cout<<dp[n];
}











Measured memory_bytes: 5168
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

//below here

vector<int> func(){
	int n;
	cin >> n;
	vector<int> hs;
	vector<int> line(n);
	foreach(i,line){
		cin >> i;
		hs.push_back(i);
		sort(all(hs),greater<int>());
		if(hs.size()>2)hs.pop_back();
	}
	vector<int> res;
	foreach(i,line){
		res.push_back(hs[i==hs[0]]);
	}
	return res;
}
int main(){
	vector<int> ans = func();
	foreach(i,ans){
		cout << i << endl;
	}
	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    int n;
    cin>>n;
    ll a,b;
    cin>>a>>b;
    ll xs=0;
    for(int i = 0;i < n-2;++i) {
        ll c;
        cin>>c;
        xs=xs^c;
    }
    if((a^b)==xs){
        cout<<0<<endl;
        return 0;
    }
    ll s=a+b;
    vector<int> bxs(50),bs(50);
    for(ll i = 0;i < 50;++i) {
        if((xs&(1LL << i))!=0)bxs[i]=1;
        else bxs[i]=0;
        if((s&(1LL << i))!=0)bs[i]=1;
        else bs[i]=0;
    }
    //cerr<<xs<<endl;
    ll ta=0;
    vector<ll> as;
    for(ll i = 49;i >= 0;--i) {
        if(bs[i]==3) {
            if(bxs[i]==1) {
                cout<<-1<<endl;
                return 0;
            }
            else {
                ta+=(1LL << i);
                if(ta>=a) {
                    cout<<-1<<endl;
                    return 0;
                }
                bs[i-1]+=2;
            }
        }
        else if(bs[i]==2) {
            if(bxs[i]==1) {
                as.emplace_back(1LL << i);
                if(i==0) {
                    cout<<-1<<endl;
                    return 0;
                }
                bs[i-1]+=2;
            }
            else {
                ta+=(1LL << i);
                if(ta>=a) {
                    cout<<-1<<endl;
                    return 0;
                }
            }
        }
        else if(bs[i]==1) {
            if(bxs[i]==1) {
                as.emplace_back(1LL << i);
            }
            else {
                if(i==0) {
                    cout<<-1<<endl;
                    return 0;
                }
                bs[i-1]+=2;
            }
        }
        else {
            if(bxs[i]==1) {
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    for(auto i:as){
        if(ta+i<a)ta+=i;
    }
    if(ta==0){
        cout<<-1<<endl;
    }
    else cout<<(a-ta)<<endl;

    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define endl "\n"

typedef long long ll;
using namespace std;

//ll const N = 32000;

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

    int N, maxx = 0;
    cin >> N;

    map<string, int> mymap;

    for(int i = 0; i < N; i++)
    {
        string str;
        cin >> str;

        mymap[str]++;
        if(mymap[str] > maxx)maxx = mymap[str];
    }

    map<string, int>::iterator it;

    for(it = mymap.begin(); it != mymap.end(); it++)
    {
        if(it -> second == maxx)cout << it -> first << endl;
    }

    return 0;
}

Measured memory_bytes: 19276
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	while(true) {
		int a =scan.nextInt();
		String op = scan.next();
	    int b =scan.nextInt();
		if (op.equals("+")) {
			System.out.println(a+b);
		}
		else if (op.equals("-")) {
			System.out.println(a-b);
		}else if (op.equals("*")) {
			System.out.println(a*b);
		}else if (op.equals("/")) {
			System.out.println(a/b);
		}else if (op.equals("?")) {
			break;
		}
	}
		
	 		
		
		
		
		

	}

}



Measured memory_bytes: 26488
#include <iostream>

using namespace std;

int main()
{
    int a, b, cnt=1;
    cin >> a >> b;
    
    if(b==1){ cout << 0; return 0; }
    
    else{
        int num = a;
        while(num<b){
            num = num + a - 1;
            cnt++;
        }
        
        cout << cnt;
        return 0;
    }
}

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

using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	cout << (a-1) * (b-1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;

    int check[26] = {0,};

    for (int i = 0; i < s.size(); i++) {
        check[s[i] - 'a'] = 1;
    }

    for (int i = 0; i < 26; i++) {
        if (check[i] == 0) {
            cout << static_cast<char>('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	string s;
	cin >> s;

	bool flag=false;

	REP(i, s.size() - 1) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			flag = true;
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
S = input()
K = int(input())

if '1' not in S:
  print(S[0])
  exit()


inf_num = list(filter(lambda x: x != '1', S[:K]))
if K <= len(S):
  if len(inf_num) == 0:
    print('1')
    exit()

print(inf_num[0])

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
	double t, v;
	int y;
	while (cin >> v){
		t = y = 0;
		t = v / 9.8;
		y = 4.9 * t * t;
		if (y < 4.9 * t * t){
			y += 5;
		}
		cout << y / 5 + 1 << endl;
	}
	return (0);
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int a, b, k; cin >> a >> b >> k;
    if (b - a + 1 <= 2 * k) {
        for (int i = a; i <= b; i++) {
            printf("%d\n", i);
        }
    } else {
        for (int i = a; i <= a + k - 1; i++) {
            printf("%d\n", i);
        }
        for (int i = b - k + 1; i <= b; i++) {
            printf("%d\n", i);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N, K;
	cin >> N >> K;
	int h[100100];
	for (int i = 0; i < N; ++i) {
		cin >> h[i];
	}
	int dp[100100];
	for (int i = 0; i < 100100; ++i)dp[i] = 1e9;
	for (int i = 1; i <= K; ++i) {
		dp[i] = abs(h[i] - h[0]);
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 1; j <= K; ++j) {
			dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
		}
	}
	cout << dp[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,n;
    cin>>n>>t;
    int arr1[n];
    int arr2[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr1[i]>>arr2[i];
    }
    int sm = 10000;
    for(int i=0;i<n;i++)
    {
        if(t>=arr2[i] && sm>arr1[i])
        {
            sm = arr1[i];
        }
    }
    if(sm==10000)
    {cout<<"TLE";}
    else 
    cout<<sm;
}

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

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;
const int MOD = 1000000007;

typedef long long ll;

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll LCM(ll x, ll y)
{
    return x * y / GCD(x, y);
}

using Graph = vector<vector<int>>;

typedef pair<int, int> P;

vector<int> to[200005]; //vector<int> の配列
vector<int> ans;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> jobs(m);

    rep(i, n)
    {
        int a, b;
        cin >> a >> b;
        a--;
        if (a <= m - 1) {
            jobs.at(a).push_back(b);
        }
    }

    int sum = 0;
    priority_queue<int> que;
    for (int remain = 0; remain <= m - 1; remain++) {
        for (int i = 0; i < jobs.at(remain).size(); i++) {
            int add = jobs.at(remain).at(i);
            que.push(add);
        }
        if (que.size() > 0) {
            sum += que.top();
            que.pop();
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 10240
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
constexpr int INF = 1 << 30;
constexpr int MOD = 1e9 + 7;

int n;

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

  long ans = 0;
  for(int i = 1; i < n; ++i) ans += i;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
H,W=map(int, raw_input().split())
s=[ list(raw_input()) for i in range(H)]
diff=[(1,0),(-1,0),(0,1),(0,-1)]

for i in range(H):
	for j in range(W):
		if s[i][j]=="#":
			for dx,dy in diff:
				if i+dx>=0 and j+dy>=0 and i+dx<H and j+dy<W:
					if s[i+dx][j+dy]=="#":
						break
			else:
				print "No"
				quit()
else:
	print "Yes"




Measured memory_bytes: 2692
#include <iostream>

int main(){
    std::string s;
    std::cin >> s;
    for(char c : s){
        switch(c){
        case 'A':
            std::cout << 'T';
            break;
        case 'T':
            std::cout << 'A';
            break;
        case 'C':
            std::cout << 'G';
            break;
        case 'G':
            std::cout << 'C';
            break;
        }
    }
    std::cout << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 103
#define INF 1000000
#define NIL -1
#define WHITE 0
#define BLACK 1

int n,G[MAX][MAX],d[MAX],mincost,color[MAX];

void initializeSingleSource(){
  int v;
  for( v = 0 ; v < n ; v++ ){
    d[v] = INF;
    color[v] = WHITE;
  }
  d[0] = 0;
}

void dijkstra(){
  int i,v,u;
  initializeSingleSource();

  while(1){
    mincost = INF;
    for( i = 0 ; i < n ;i ++ )
      {
	if( color[i] != BLACK && d[i] < mincost ){
	  mincost = d[i];
	  u = i;
	}
      }
    
    if( mincost == INF ) break;

    color[u] = BLACK;

    for( v = 0 ; v < n ; v++ ){
      if( color[v] != BLACK && G[u][v] != INF ){
	if(( d[u] + G[u][v] ) < d[v] ){
	  d[v] = d[u] + G[u][v];
	}
      }
    }


  }
}

int main(){
  int i,j,u,v,k;
  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ )
    {
      for( j = 0 ; j < n ; j++ ) G[i][j] = INF;
    }
  
  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d",&u,&k);
    for( j = 0 ; j < k ; j++ ){
      scanf("%d",&v);
      scanf("%d",&G[u][v]);
    }
  }

  dijkstra();

  for( i = 0 ; i < n ; i++ )
    {
      if( d[i] != INF )
      printf("%d %d\n",i,d[i]);
    }
  
  return 0;
}

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

int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if (x+r<=W and x-r>=0 and y+r<=H and y-r>=0) {
        puts("Yes");
    }
    else {
        puts("No");
    }
}



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

int main() {
  int h,n;
  cin>>h>>n;
  vector<int> a(n);
  bool ans=false;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int c=0;
  for(int i=0;i<n;i++){
    c+=a[i];
    if(c>=h) ans=true;
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 640
import sys
import queue
from collections import defaultdict

input = sys.stdin.readline
sys.setrecursionlimit(20000000)

ans = 0
n, u, v = map(int, input().split())
u -= 1; v -= 1
ab = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)

path_u = [0] * n
path_v = [0] * n

# u
checked = [False] * n
checked[u] = True
q = queue.Queue()
q.put((u, 0))
while not q.empty():
    cur, count = q.get()
    path_u[cur] = count
    for i in ab[cur]:
        if not checked[i]:
            q.put((i, count+1))
            checked[i] = True

# v
checked = [False] * n
checked[v] = True
q = queue.Queue()
q.put((v, 0))
while not q.empty():
    cur, count = q.get()
    path_v[cur] = count
    for i in ab[cur]:
        if not checked[i]:
            q.put((i, count+1))
            checked[i] = True

ans = 0
for u_, v_ in zip(path_u, path_v):
    if u_ < v_:
        ans = max(ans, v_ - 1)
# print(path_u, path_v)
print(ans)


Measured memory_bytes: 79388
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n,r;
cin>>n>>r;
if(n>=10)
{
    cout<<r<<endl;
}else
{
    cout<<r+100*(10-n)<<endl;
}
return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
a, b, c = map(int, input().split())
K = int(input())


def calcMaximumSum(a, b, c, K):
    maximum = max([a, b, c])
    if(maximum == a):
        return a * (2 ** K) + b + c
    elif(maximum == b):
        return a + b * (2 ** K) + c
    else:
        return a + b + c * (2 ** K)


print(calcMaximumSum(a, b, c, K))


Measured memory_bytes: 3064