akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isPossible(x) printf("%s\n",(x) ? "Possible" : "Impossible")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)

// const long long INF = 1LL<<50;

#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
// const int mod =(int)998244353;
const int mod =(int)1e9+7;

const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(a<0)a=-a;
    if(b<0)b=-b;
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
  if(a<0)a=-a;
  if(b<0)b=-b;
    ll g;g=gcd(a,b);
    return b/g*a;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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;
}
//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;
int main() {
    ios::sync_with_stdio(false);
    string S,T;
    cin>>S>>T;
    int sn,tn;
    sn=S.length();tn=T.length();
    int ans=INF;
    REP(i,sn-tn+1){
        int ans_temp=0;
        REP(j,tn){
            if(S[i+j]!=T[j]){
                ans_temp++;
            }
        }
        ans=min(ans,ans_temp);
    }
    cout<<ans<<endl;
    return 0;
} 
 

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }

int main(void){
    int N;
    cin>>N;
    ll A[N];
    ll s=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        s+=A[i];
    }
    ll x=s;
    for(int i=0;i<N-1;i+=2){
        x-=2*A[i];
    }
    vector<ll> v;
    v.push_back(x);
    for(int i=N-2;i>=0;i--){
        x=2*A[i]-x;
        v.push_back(x);
    }
    for(int i=N-1;i>=0;i--){
        if(i==0) cout<<v[i]<<endl;
        else cout<<v[i]<<" ";
    }
}

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

int main() {
  int A, B, seki;

  cin >> A >> B;
  seki = A * B;
  
  if (seki % 2 == 0 ) {
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" << endl;
  }
}

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

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		Main app = new Main();
		String source, res;
		
		int n = Integer.valueOf(reader.readLine());
		for(int i = 0; i < n; i++){
			source = reader.readLine();
			fffff : for(int a = 0; a < 26; a++){
				for(int b = 0; b < 26; b++){
					char ch[] = source.toCharArray();
					res = "";
					for(int f = 0; f < source.length(); f++){
						if(ch[f] == ' ' || ch[f] == '.'){
							res += " ";
							continue;
						}
						res += (char)app.F(a, b, ch[f]);
					}
					if(res.contains("this") || res.contains("that")){
						System.out.println(res);
						break fffff;
					}
				}
			}
		}
		reader.readLine();
	}
	
	public int F(int a, int b, int y){
		return (a * (y - 97) + b) % 26 + 97;
	}
}

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

int main(){
    int A,B;
    cin >> A >> B;
    int x;
    
    x = A + B;
    if(A-B > x){
        x = A- B;
    }
    if(A*B > x){
        x = A*B;
    }
    
    cout <<  x << endl;
    
    return 0;
}


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

auto chmax = [](auto&& a, auto b) { return a < b ? a = b, 1 : 0; };

uint8_t dp[186][186][186][17];

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (auto&& e : s) cin >> e;
  vector cum(h + 1, vector<int>(w + 1));
  for (int i = h; i--; ) {
    for (int j = w; j--; ) {
      cum[i][j] = s[i][j] == '#';
      cum[i][j] += cum[i + 1][j];
      cum[i][j] += cum[i][j + 1];
      cum[i][j] -= cum[i + 1][j + 1];
    }
  }
  auto all = [&](int li, int ri, int lj, int rj) {
    int sum = 0;
    sum += cum[li][lj];
    sum -= cum[ri][lj];
    sum -= cum[li][rj];
    sum += cum[ri][rj];
    return sum == 0 or sum == (ri - li) * (rj - lj);
  };
  for (int li = h; li--; ) {
    for (int ri = li + 1; ri <= h; ++ri) {
      for (int lj = w; lj >= 0; --lj) {
        int ok = lj, ng = w + 1;
        while (ng - ok > 1) {
          int mid = (ok + ng) / 2;
          (all(li, ri, lj, mid) ? ok : ng) = mid;
        }
        dp[li][ri][lj][0] = ok;
        for (int x = 1; x <= 16; ++x) {
          dp[li][ri][lj][x] = dp[li][ri][dp[li][ri][lj][x - 1]][x - 1];
          ok = li, ng = ri;
          while (ng - ok > 1) {
            int mid = (ok + ng) / 2;
            (dp[li][mid][lj][x - 1] > dp[mid][ri][lj][x - 1] ? ok : ng) = mid;
          }
          chmax(dp[li][ri][lj][x], min(dp[li][ok][lj][x - 1], dp[ok][ri][lj][x - 1]));
          chmax(dp[li][ri][lj][x], min(dp[li][ng][lj][x - 1], dp[ng][ri][lj][x - 1]));
        }
      }
    }
  }
  for (int x = 0; ; ++x) {
    if (dp[0][h][0][x] == w) {
      cout << x << '\n';
      exit(0);
    }
  }
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

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

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using uint1024_t = mp::uint1024_t;
using namespace std;


int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	vector<int>mod(k);
	FOR(i, 1, n + 1) {
		if (i * 2 % k == 0) {
			mod[i%k]++;
		}
	}
	ll count = 0;
	count += (ll)pow(mod[0], 3);

	if (k % 2 == 0) {
		count += (ll)pow(mod[k / 2], 3);
	}
	printf("%lld\n", count);

}


Measured memory_bytes: 1024
n = int(input())


def make_remark_list(i, r):
    # -1: 不明, 0: 嘘つき, 1: 真実
    people = [-1] * n
    people[i] = 1
    for x, y in r:
        people[x - 1] = y
    return people


def check(x, y):
    new_list = []
    for a, b in zip(x, y):
        a, b = min(a, b), max(a, b)
        if (a, b) == (0, 1):
            return False
        elif (a, b) == (-1, 0):
            new_list.append(0)
        else:
            new_list.append(max(a, b))
    return new_list


remarks = []
for i in range(n):
    a = int(input())
    r = [tuple(map(int, input().split())) for _ in range(a)]
    remarks.append(make_remark_list(i, r))

def max_count(r, cnt, i = 0):
    tmp = r
    for j, r_j in enumerate(remarks):
        if j < i: continue
        if tmp[j] == 0:
            continue
        elif tmp[j] == 1:
            if check(tmp, r_j):
                tmp = check(tmp, r_j)
                cnt += 1
            else:
                cnt = 0
                break
        else:
            tmp[j] = 1
            if check(tmp, r_j):
                cnt_1, tmp_1 = max_count(tmp, cnt, j)
                tmp[j] = 0
                cnt_0, tmp_0 = max_count(tmp, cnt, j)
                if cnt_0 > cnt_1:
                    return cnt_0, tmp_0
                else:
                    return cnt_1, tmp_1
            else:
                tmp[j] = 0
    return cnt, tmp

r = [-1] * n
cnt, r = max_count(r, 0)
print(cnt)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        for (int i = 0; i < s.length - 1; i++) {
            if (s[i].equals(s[i + 1])) {
                System.out.println("Bad");
                return;
            }
        }
        System.out.println("Good");
    }

}


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

int main() {
  int H, W, M;
  cin >> H >> W >> M;
  map<int, int> h, w;
  set<pair<int, int>> s;

  for (int i = 0; i < M; i++) {
    int y, x;
    cin >> y >> x;
    y--;
    x--;
    h[y]++;
    w[x]++;
    s.insert(make_pair(y, x));
  }
  vector<pair<int, int>> hnum, wnum;
  for (auto i = h.begin(); i != h.end(); ++i) {
    hnum.push_back(make_pair(i->second, i->first));
  }
  for (auto i = w.begin(); i != w.end(); ++i) {
    wnum.push_back(make_pair(i->second, i->first));
  }
  sort(hnum.begin(), hnum.end(), greater());
  sort(wnum.begin(), wnum.end(), greater());

  int ans = hnum[0].first + wnum[0].first - 1;
  for (auto i : hnum) {
    if (i.first < hnum[0].first) break;
    for (auto j : wnum) {
      if (j.first < wnum[0].first) break;
      if ((int)s.count(make_pair(i.second, j.second)) == 0) {
        cout << i.first + j.first << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 53832
#include<cstdio>
#include<algorithm>
using namespace std;
long long K;
long long po[20], C[20], res;
void Do(int b, int e, long long S, long long c) {
	if (!c)return;
	if (b >= e) {
		if (S == K) {
			if (b == e)res += 10*c;
			else res+=c;
		}
		return;
	}
	if (abs(S - K) > po[e + 1])return;
	int i;
	for (i = -9; i <= 9; i++) {
		int t = 10 - abs(i);
		if (i >= 0 && b==0)t--;
		Do(b+1, e-1, S+i*C[b], t*c);
	}
}
void Calc(int L) {
	int i;
	for (i = 0; i < L; i++) {
		C[i] = po[L - i - 1] - po[i];
	}
	Do(0, L - 1, 0, 1);
}
int main() {
	int i;
	po[0] = 1;
	for (i = 1; i <= 18; i++)po[i] = po[i - 1] * 10;
	scanf("%lld", &K);
	for (i = 2; i <= 18; i++) {
		Calc(i);
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double s = scan.nextDouble();
    	double w = scan.nextDouble();
 
    	if(s <= w){
    		System.out.println("unsafe");
    	} else {
    		System.out.println("safe");
    	}
    	
        scan.close();
    }
}

Measured memory_bytes: 37516
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ld a,b;
    cin>>a>>b;
    for(ld i=0;i<100000;i++){
        ld k=i*0.08;
        ld f=i*0.10;
        if(!((k-a)<1&&(k-a)>=0)){
            continue;
        }
        if(!((f-b)<1&&(f-b)>=0)){
            continue;
        }
        cout<<i<<endl;
        return 0;
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
string str[1010];
int a[1010];
int main(void)
{
    int T,k,k1,t=0,n,x,s=-1;
    scanf("%d",&n);
    string str1;
    for(int i=0;i<n;i++)
    {
        cin>>str[i];
        scanf("%d",&a[i]);
    }
    cin>>str1;
    for(int i=0;i<n;i++)
    {
        if(s!=-1)
            s+=a[i];
        if(str[i]==str1)
            s=0;

    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	long long N,x,a[100000];
	scanf("%lld%lld",&N,&x);
	for(int i=0;i<N;i++){
		scanf("%lld",&a[i]);
	}
	long long res=0;
	long long b=0;
	for(int i=0;i<N;i++){
		if(b+a[i]<=x){
			b=a[i];
		}
		else{
			res+=b+a[i]-x;
			b=a[i]-(b+a[i]-x);
		}
	}
	printf("%lld",res);
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
const int maxn = 555;

int M(){
    int n, m, k;
    if(!(cin >> n >> m >> k)) return 0;
    for(int e = 0; e <= n; e++){
        for(int f = 0; f <= m; f++){
            int inter = e * f;
            if(m * e + f * n - 2 * inter == k){
                printf("Yes\n");
                return 1;
            }
        }
    }
    printf("No\n");
    return 1;
}
int main(){
    while(M());
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define very_slow       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define inf             1e18
#define MAX             1e9
#define MIN            -1e9
#define no_of_test(x)        int x; cin>>x; while(x--)
//Actual Code Is At The Top
const int mod = 1e9 + 7;
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}
int32_t main()
{   
	very_slow
//	no_of_test(x)
	{  
       string s;
       cin>>s;
       if(s[2]==s[3]&&s[4]==s[5])
       {
           cout<<"Yes"<<'\n';
       }
       else
       {
           cout<<"No"<<'\n';
       }
       
	}
	return 0;
}

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

int A[200005], B[200005];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int n;
    cin >> n;

    for (int i=1; i<=n; i++)
        cin >> A[i] >> B[i];
    
    sort(A+1, A+1+n);
    sort(B+1, B+1+n);

    int ans = 0;

    if (n % 2)
        ans = B[n/2 + 1] - A[n/2 + 1] + 1;
    else
        ans = B[n/2 + 1] + B[n/2] - A[n/2 + 1] - A[n/2] + 1;

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 5208
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;


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

	int v[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int N;
	cin >> N;
	cout << v[N - 1] << endl;
}

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


int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  while(true) {
    C -= B;
      if (C <= 0) break;
    A -= D;
      if (A <= 0) break;
  }

  if (A > 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3584
import sys
f=lambda:map(int,sys.stdin.readline().split())
n,m=f()
la=sorted(f())
ll=sorted([list(f()) for _ in range(m)],key=lambda k:-k[1])
ls=[]
t=a=0
for b,c in ll:
  if t+b>n: ls+=[c]*(n-t); t=n; break
  ls+=[c]*b; t+=b
for i in range(n):
  if i<t: a+=max(la[i],ls[i])
  else: a+=la[i]
print(a)

Measured memory_bytes: 36856
n=int(input())
fullcards={
    "S":set(range(1,14)),
    "H":set(range(1,14)),
    "C":set(range(1,14)),
    "D":set(range(1,14))
    }
cards={
    "S":set({}),
    "H":set({}),
    "C":set({}),
    "D":set({})
    }
for i in range(n):
    line=input()
    suit,rank=line.split()
    rank=int(rank)
    cards[suit].add(rank)
for s in ['S','H','C','D']:
    for r in fullcards[s]-cards[s]:
        print('%s %d' % (s,r))

Measured memory_bytes: 7744
#include <stdio.h>
int N;
int s[100001];
int d[100001];
int p[100001];


int Depth(int);
int Height(int);

int main() {
  int j,i;
  int id, l, r;
  scanf("%d", &N);

  for(i = 0; i < N; ++i) {
    p[i] = -1;
    s[i] = -1;
    d[i] = 0;
  }

  for(i = 0; i < N; i++) {
   

    scanf("%d %d %d", &id, &l, &r);

    if(l != -1) {
      p[l] = id;
      s[l] = r;
      d[id]++;
    }

    if(r != -1) {
      p[r] = id;
      s[r] = l;
      d[id]++;
    }
  }
  
  for(i = 0; i < N; ++i) {
    int depth = Depth(i);

    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",   i, p[i], s[i], d[i], depth, Height(i));
    if(depth == 0) {
      printf("root\n");
    } else if(d[i] == 0) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }
  return 0;
}

int Depth(int i) {
  if(p[i] == -1){
    return 0;
  }
    return Depth(p[i]) + 1;
}

int Height(int i) {
  int j, h=0, temp;
  
  for(j = 0; j < N; ++j) {

    if(p[j] == i) {
      temp = Height(j) + 1;

      if(temp > h) h = temp;
    }
  }
  return h;
}





Measured memory_bytes: 2112
#include<iostream>
#include<vector>
#include<stack>

int main(){
	int n, l;
	int stPos;
	bool isFoundSt=false;

	std::vector<int> aList;
	std::stack<int> knot;

	std::cin>>n>>l;
	aList.resize(n);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	for(int i=1; i<n; i++){
		if(aList[i-1]+aList[i]>=l){
			isFoundSt= true;
			stPos= i-1;
			break;
		}
	}

	if(!isFoundSt){
		std::cout<<"Impossible"<<std::endl;
		return 0;
	}

	for(int i=stPos; i>=0; i--)
		knot.push(i);

	for(int i=stPos+1; i<n-1; i++)
		knot.push(i);

	std::cout<<"Possible"<<std::endl;
	while(!knot.empty()){
		std::cout<<knot.top()+1<<std::endl;
		knot.pop();
	}


	return 0;
}

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

#define int long long
#define pb push_back
#define ff first
#define ss second

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    setprecision(20);
    
    int n;
    cin>>n;
    
    unordered_map<int,int> m;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            int cnt=0;
            while(n%i==0)
            {
                cnt++;
                n=n/i;
            }
            m[i]=cnt;
        }
    }
    if(n!=1)
        m[n]=1;
    int ans=0;
    for(auto it=m.begin();it!=m.end();it++)
    {
        int temp=it->ss;
        
        int low=0;
        int high=1e8;
        int te1=0;
        while(low<=high)
        {
            int mid=low+(high-low)/2;
            
            int val=mid*(mid+1);
            val=val/2;
            
            if(val>temp)
                high=mid-1;
            else
            {
                te1=max(te1,mid);
                low=mid+1;
            }
        }
        ans=ans+te1;
    }
    cout<<ans;
}

Measured memory_bytes: 3676
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
using namespace std;
bitset<25601>dp[80][80];
int n,m,a[80][80],b[80][80],ans=0x3f3f3f3f;
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;++i)
		for(int j=0;j<m;++j)
			scanf("%d",&a[i][j]);
	for(int i=0;i<n;++i)
		for(int j=0;j<m;++j)
			scanf("%d",&b[i][j]);
	for(int i=n-1;~i;--i)
		for(int j=m-1;~j;--j)
		{
			if(i==n-1&&j==m-1)
			{
				dp[i][j][12800+a[i][j]-b[i][j]]=dp[i][j][12800-a[i][j]+b[i][j]]=1;
				continue;
			}
			if(i<n-1)dp[i][j]|=dp[i+1][j];
			if(j<m-1)dp[i][j]|=dp[i][j+1];
			int w=a[i][j]-b[i][j];
			if(w<0)w=-w;
			dp[i][j]=(dp[i][j]<<w)|(dp[i][j]>>w);
		}
	for(int i=0;i<=25600;++i)if(dp[0][0][i])ans=min(ans,abs(12800-i));
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 20352
n = int(input())
dishes = list(map(int, input().split()))
points = list(map(int, input().split()))
adds = list(map(int, input().split()))

pre = 100
total = 0
for dish in dishes:
  if dish == pre + 1:
    total += points[dish-1] + adds[pre-1]
    pre = dish
  else:
    total += points[dish-1]
    pre = dish

print(total)

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

using namespace std;

int main(){
    int N,ans=0,sum=0,a;
    cin >> N;
    vector<int> vec(100001,0);
    for(int i=0;i<N;i++){
        cin >> a;
        vec[a]++;
    }

    for(int i=1;i<vec.size()-1;i++){
        ans = max(ans,vec[i-1]+vec[i]+vec[i+1]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	
	public static final long MOD = 1000000007L;

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();
		
		if (w == 1) {
			System.out.println(1);
			return;
		}
		
		ArrayList<boolean[]> list = new ArrayList<boolean[]>();
		list.add(new boolean[w-1]);
		boolean[] b = new boolean[w-1];
		for (int i = 0; i < w - 1; i++) {
			ArrayList<boolean[]> tlist = new ArrayList<boolean[]>();
			for (boolean[] arr : list) {
				if (i == 0 || !arr[i - 1]) {
					boolean[] tmp = arr.clone();
					tmp[i] = true;
					tlist.add(tmp);
				}
			}
			list.addAll(tlist);
		}
		
		long[][] count = new long[w][h+1];
		count[0][0] = 1;
		for (int i = 1; i < h + 1; i++) {
			for (int j = 0; j < w; j++) {
				int stay = 0;
				int left = 0;
				int right = 0;
				for (boolean[] arr : list) {
					if (j != 0 && arr[j - 1]) {
						left++;
					}
					if (j != w - 1 && arr[j]) {
						right++;
					}
					if (j != 0 && j != w - 1) {
						if (!arr[j - 1] && !arr[j]) {
							stay++;
						}
					} else if (j == 0) {
						if (!arr[j]) {
							stay++;
						}
					} else if (j == w - 1) {
						if (!arr[j - 1]) {
							stay++;
						}
					}
					
				}
				count[j][i] += count[j][i - 1] * stay;
				if (j != 0) {
					count[j][i] += count[j - 1][i - 1] * left;
				}
				if (j != w - 1) {
					count[j][i] += count[j + 1][i - 1] * right;
				}
				count[j][i] %= MOD;
			}
		}
		
		System.out.println(count[k - 1][h] % MOD);
	}
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll F[605][9];
int num[605];
ll K;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	F[0][0]=1;
	for(i=1;i<=600;i++) {
		FOR(x,8) {
			FOR(y,x+1) F[i][x]+=F[i-1][y];
			F[i][x]=min((1LL<<60)-1,F[i][x]);
		}
	}
	cin>>K;
	for(i=600;i>=1;i--) {
		num[i]=K/F[i][7];
		K%=F[i][7];
	}
	for(i=1;i<=600;i++) {
		cout<<"FESTIVA";
		FOR(x,num[i]) cout<<"L";
	}
	cout<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

template<typename T>
class BIT {
private:
	vector<T>arr;
	int siz;
public:
	BIT(int n) :siz(1) {
		while (siz < n)siz *= 2;
		arr.resize(siz + 1);
	}
	//[0,x)?????§?????????????????????
	T query(int x) const {
		T s = 0;
		while (x > 0) {
			s += arr[x];
			x -= (x & -x);
		}
		return s;
	}
	//x??????k???????????????
	void add(int x, const T& k) {
		++x;
		while (x <= siz) {
			arr[x] += k;
			x += (x & -x);
		}
	}
};

//????????????????????????????????????????????????????´????????§????????????§???????????°??¨
//BIT???2????§???????????????°?????????????§????(?????¨?????¨?????§???????????????)
template<typename T>
class RSAQ {
private:
	BIT<T>S1, S2;
public:
	//??§??????n????????°??¨?????????
	RSAQ(int n) :S1(n + 1), S2(n + 1) {}
	//[0,x)?????§?????????????????????
	T query(int x) const {
		return S1.query(x) + S2.query(x) * (x - 1);
	}
	//??????[l,r)??????????????????????´????????§????k???????????????
	void addrange(int l, int r, int k) {
		S1.add(l, -k * (l - 1));
		S1.add(r, +k * (r - 1));
		S2.add(l, +k);
		S2.add(r, -k);
	}
};

int main(void)
{
	int N, Q;
	cin >> N >> Q;
	RSAQ<LL>tree(N);
	for (int i = 0; i < Q; ++i) {
		int com;
		cin >> com;
		if (com) {
			int s, t;
			cin >> s >> t;
			LL T = tree.query(t);
			LL S = tree.query(s - 1);
			cout << T - S << endl;
		}
		else {
			int s, t, x;
			cin >> s >> t >> x;
			tree.addrange(s - 1, t, x);
		}
	}
	return 0;
}

Measured memory_bytes: 4948
# Wrote in Mar 11, 2020 12:59 by reetok
require 'time'
require 'prime'
require 'bigdecimal'
def inp(type=:to_i,spst=" ")
  return eval("gets.chomp.split(#{spst}).map(&:#{type})")
end
def inpf() return self.inp(:to_f," ") end
def inps() return self.inp(:to_s," ") end
def r_up(a, b) (a/b).ceil end
def r_down(a, b) (a/b).floor end
def sum(a) a.inject(:+) end
def big(a,b) return (a>b)? a:b end
def small(a,b) return (a<b)? a:b end
def minp(n,datatype=".to_i")
  t = []
  n.times do
    t.push(eval("gets.chomp#{datatype}"))
  end
  return t
end
def yes() puts "Yes" end
def no() puts "No" end
def ynju(bool,yes="Yes",no="No") puts (bool ? yes : no) end
class Integer
  def divisor_list
    devisors = [1]
    2.upto(self/2) do |i|
      devisors << i if self%i == 0
    end
    devisors << self
    return devisors.uniq.sort
  end
end
class Array
  def upper(a) #aより上
    self.sort.select{|n|n>=a}
  end
  def downer(a) #aより下
    self.sort.select{|n|n<=a}
  end
end
#---------------

students = []

loop do
  a = inp
  if a == [-1,-1,-1]
    break
  else
    students.push(a)
  end
end

students.each do |n|
  if n[0]==-1||n[1]==-1
    puts "F"
  elsif n[0]+n[1]  >= 80
    puts "A"
  elsif n[0]+n[1] >= 65
    puts "B"
  elsif n[0]+n[1] >= 50
    puts "C"
  elsif n[0]+n[1] >= 30
    if n[2] >= 50
      puts "C"
    else
      puts "D"
    end
  else
    puts "F"
  end
end



Measured memory_bytes: 7224
#!/usr/bin/env python3
import sys
def LI():
	return [int(s) for s in input().split()]
    
N = int(input())
H = LI()

H[0]-=1
for i in range(1, N):
    if H[i] < H[i - 1]:
        print('No')
        sys.exit()

    if H[i - 1] <= H[i] - 1:
        H[i] -= 1

print('Yes')

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
int main(){
	int num,leg;
	cin>>num>>leg;
	for(int i=0;i<=num;i++){
		int j=num-i,allf=i*2+j*4;
    	if(allf==leg){
    		cout<<"Yes"<<endl;
    		return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3568
main = readLn >>= print.(lunlun!!).pred where
 lunlun = [1..9]++concatMap f lunlun
 f x
  | r == 0 = [x*10, x*10+1]
  | r == 9 = [x*10+8, x*10+9]
  | otherwise = [x*10+r-1..x*10+r+1]
  where r = mod x 10



Measured memory_bytes: 5244
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <chrono>
#include <utility>

using namespace std;

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

constexpr int cm = 1<<17;
char buff[cm], *ci = buff + cm, ct;

inline char readchar() {
  if (ci - buff == cm) {
    fread(buff, 1, cm, stdin);
    ci = buff;
  }
  return *ci++;
}

inline int readint() {
  int num = 0;
  if (ci - buff + 16 > cm) {
    while ((ct = readchar()) >= '0') {
      num = (num << 3) + (num << 1) + ct - '0';
    }
  } else {
    while ((ct = *ci++) >= '0') {
      num = (num << 3) + (num << 1) + ct - '0';
    }
  }
  return num;
}

int main(){
  auto start = chrono::system_clock::now();

  int n = readint();

  vector<queue<int>> v(1002, queue<int> ());
  rep(i, n) {
    rep(j, n - 1) {
      int a = readint();
      v[i + 1].emplace(a);
    }
  }

  for (int day = 1; day <= n * (n - 1) / 2; ++day) {
    bool done[1002] = {};
    for (int i = 1; i <= n; ++i) {
      if (done[i]) continue;
      if (v[i].empty()) continue;
      int next = v[i].front();
      if (done[next]) continue;
      if (v[next].front() == i) {
        v[i].pop(); v[next].pop();
        done[i] = done[next] = true;
      }
    }
    if (all_of(done, done + n, [](const bool& x){return x == false;})){
      printf("-1");
      return 0;
    }
    if (all_of(v.begin(), v.end(), [](const queue<int>& x){return x.empty();})) {
      printf("%d", day);
      return 0;
    }
    auto now = chrono::system_clock::now();
    auto dur = now - start;
    auto msec = chrono::duration_cast<chrono::microseconds>(dur).count();
    if (msec >= 28000) {
      printf("%d", n * (n - 1) / 2);
      return 0;
    }
  }

  return 0;
}


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

using namespace std;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	
	string s;
	cin >> s;

	if (s[3] == '7')s[3] = '8';

	cout << s << "\n";

	return 0;
}

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

int main(){
  int n;
  cin>>n;
  int a[2][n];
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      cin>>a[i][j];
    }
  }
  int ans=-1;
  for(int i=0;i<n;i++){
    int tmp=0;
    for(int j=0;j<=i;j++){
      tmp+=a[0][j];
    }
    for(int j=i;j<n;j++){
      tmp+=a[1][j];
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
const int INF=1e9;

int main(){
    int h,w;cin>>h>>w;
    vector<string> a(h);
    for(int i=0;i<h;i++) cin>>a[i];
    int c=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#') c++;
        }
    }
    if(c==h+w-1){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
typedef long long q;
using namespace std;
q gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
int findGCD(int arr[], int n) 
{ 
    int result = arr[0]; 
    for (int i = 1; i < n; i++) 
        result = gcd(arr[i], result); 
  
    return result; 
}
int main() 
{ 
    int n;
    cin>>n;
    q s=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                int arr[] = { i, j, k};
                s=s+findGCD(arr, 3); 
            }
        }
    }
    cout<<s<<endl;
    return 0; 
} 

Measured memory_bytes: 3636
while True:
    p=0
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    for i in range(1,n+1):
        for j in range(2,n+1):
            if i==j:
                break
            for k in range(3,n+1):
                if i==k or j==k:
                    break
                g=i+j+k
                if x==g:
                    p+=1
    print(p)


Measured memory_bytes: 5596
#include <stdio.h>

int main (int argc, const char * argv[])
{
    int a[4];
    int b[4];
    int flag = 1;
    int i, j;
    int hit, blow;
    
    while(scanf("%d%d%d%d", &b[0], &b[1], &b[2], &b[3]) != EOF)
    {
        if (flag == 1)
        {
            a[0] = b[0];
            a[1] = b[1];
            a[2] = b[2];
            a[3] = b[3];
            
            flag *= -1;
        }
        else if (flag == -1)
        {
            hit = 0;
            blow = 0;
            
            for (i=0; i<4; i++)
            {
                for (j=0; j<4; j++)
                {
                    if (a[i] == b[j] && i == j)
                    {
                        hit++;
                    }
                    else if (a[i] == b[j] && i != j)
                    {
                        blow++;
                    }
                }
            }
            printf("%d %d\n", hit, blow);
            flag *= -1;
        }
    }
    return 0;
}

Measured memory_bytes: 0
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
H,W,K = map(int,input().split())
col = [[0]*W for _ in range(H)]
for i in range(H):
    s = list(input())[:-1]
    for j in range(W):
        if s[j] == "#":
            col[i][j] = 1
yoko = [0]*H
tate = [0]*W
for i in range(H):
    for j in range(W):
        yoko[i] += col[i][j]
for i in range(W):
    for j in range(H):
        tate[i] += col[j][i]
ALL = 0
for i in range(H):
    for j in range(W):
        ALL += col[i][j]
ans = 0
for i in range(2**H):
    bitlisth = deque()
    for j in range(H):
        if ((i >> j) & 1): #2進数表示のj桁目(0桁目から数える)が1かどうか
            bitlisth.appendleft(1)
        else:
          	bitlisth.appendleft(0)
    bitlisth = list(bitlisth)
    for k in range(2**W):
        bitlistw = deque()
        for l in range(W):
            if ((k >> l) & 1): #2進数表示のj桁目(0桁目から数える)が1かどうか
                bitlistw.appendleft(1)
            else:
                bitlistw.appendleft(0)
        bitlistw = list(bitlistw)
        a = ALL
        h = []
        w = []
        for p in range(H):
            if bitlisth[p] == 1:
                a -= yoko[p]
                h.append(p)
        for q in range(W):
            if bitlistw[q] == 1:
                a -= tate[q]
                w.append(q)
        for pp in h:
            for qq in w:
                a += col[pp][qq]
        if a == K:
            ans += 1
print(ans)


           
    

        




Measured memory_bytes: 10592
#include<bits/stdc++.h>
#define int long long 

using namespace std ;

int n; 
int a[100001],b[100001],c[100001];
int dp[100001][3];

int32_t main(){
        ios_base::sync_with_stdio(0); cin.tie(0);

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

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

        for(int i=1;i<n;i++){
                dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
                dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
                dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + c[i];
        }
        n--;
        cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl; 

        return 0;
}

Measured memory_bytes: 4992
n,wmax=map(int,input().split())
v=[0]*n
w=[0]*n
for i in range(n):
    w[i],v[i]=list(map(int,input().split()))
sv=sum(v)+1
dp=[[float('inf')]*sv for _ in range(n)]
dp[0][v[0]-1]=w[0]
for i in range(n):
    dp[i][0]=0
for i in range(n):
    for j in range(sv):
        dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i])
ans=float('inf')
for p in range(sv-1,-1,-1):
    if dp[n-1][p]<=wmax:
        ans=p
        break
print(ans)

Measured memory_bytes: 379984
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]

dp = [0 for _ in range(W + 1)]
for w, v in WV:
	for tw in range(W, w - 1, -1):
		dp[tw] = max(dp[tw], dp[tw - w] + v)
	#print(dp)
print(max(dp))


Measured memory_bytes: 44912
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, A);
    IN(ll, B);
    IN(ll, C);
    IN(ll, D);
    while (true)
    {
        C -= B;
        if (C <= 0)
        {
            OUT("Yes");
            return 0;
        }
        A -= D;
        if (A <= 0)
        {
            OUT("No");
            return 0;
        }
    }
}

Measured memory_bytes: 3624
# include <iostream>
using namespace std;
long long s,t,u,v;
int n,m,p,q;
void work (void)
{
	int i;
	i=1;
	u=1;
	v=1;
	while (i<=q)
	{
		u=u*(q-i+1)/i;
		if (i%2==1)
		t+=u;
   else s+=u;
		i++;
	}
	i=1;
	while (i<=p)
	{
		v*=2;
		i++;
	}
	if (m==1)
	s=t*v;
else s=(s+1)*v;
	cout<<s;
}
int main (void)
{
	int i,j;
	cin>>n>>m;
	for (i=1;i<=n;i++)
	{
		cin>>j;
		if (j%2==0)
		p++;
   else q++;
	}
	work ();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define _GLIBCXX_DEBUG
#define pb push_back;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<char, char> c_c;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
const int INF = 1e9;
const ll LLINF = 1e16;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    ll pp, qq, cnt = 0;
    vector<int> p(n);
    for(int i=0; i<n; i++) cin >> p[i];
    vector<int> q(n);
    for(int i=0; i<n; i++) cin >> q[i];
    vector<int> v(n);
    for(int i=0; i<n; i++) v[i] = i+1;
    do{
        int flgp = 1, flgq = 1;
        cnt++;
        for(int i=0; i<n; i++){
            if(p[i] != v[i]){
                flgp = 0;
            }
        }
        if(flgp) pp = cnt;
        for(int i=0; i<n; i++){
            if(q[i] != v[i]){
                flgq = 0;
            }
        }
        if(flgq) qq = cnt;
    } while(next_permutation(all(v)));

    cout << abs(pp-qq) << endl; 
    return 0;
}   

Measured memory_bytes: 256
n,m=gets.chomp.split.map(&:to_i)
DOM=1000000007
dp=[]
dp[0]=1
dp[1]=1
m.times do |i|
  dp[gets.to_i]=0
end

2.upto(n) do |i|
  if dp[i]== 0
    next
  end
  dp[i]=dp[i-2]+dp[i-1]
end  
puts dp[n]%DOM

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

const int inf = 1e9;
const ll linf = 1e18;

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

    char a, b, c, d; cin >> a >> b >> c >> d;
    for (int bits = 0; bits < (1 << 3); bits++) {
        int res = a - '0';
        res += ((bits & (1 << 0)) ? 1 : -1) * (b - '0');
        res += ((bits & (1 << 1)) ? 1 : -1) * (c - '0');
        res += ((bits & (1 << 2)) ? 1 : -1) * (d - '0');
        if (res == 7) {
            cout << a << ((bits & (1 << 0)) ? '+' : '-')
                 << b << ((bits & (1 << 1)) ? '+' : '-')
                 << c << ((bits & (1 << 2)) ? '+' : '-')
                 << d << "=7" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
class UnionFindTree():
    def __init__(self, N):
        self.parent = [-1]*(N+1)
        self.rank = [1]*(N+1)
        self.size = [1]*(N+1)
        self.hubensa = N*(N-1)//2
  
    def find(self, i):
        if self.parent[i] == -1:
            group = i
        else:
            group = self.find(self.parent[i]) 
            self.parent[i] = group
        return group
      
    def unite(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px != py:
            if self.rank[px] == self.rank[py]: # rank is same
                self.rank[px] += 1
            elif self.rank[px] < self.rank[py]:
                px, py = py, px
                
            self.parent[py] = px
            self.hubensa -= self.size[px] * self.size[py]
            self.size[px] += self.size[py]

N, M = list(map(int, input().split()))
A = [0 for _ in range(M)]
B = [0 for _ in range(M)]

for i in range(M):
    A[i], B[i] = list(map(int, input().split()))

ans = []
UFT = UnionFindTree(N)

# 後ろから処理
for i in range(M-1, -1, -1):
    ans.append(UFT.hubensa)
    UFT.unite(A[i], B[i])

print(*ans[::-1], sep="\n")


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

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

	final long MOD = 1_000_000_007L;

	void solver() {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int[] l = new int[d];
		for (int i = 0; i < d; i++) {
			l[i] = sc.nextInt();
		}
		Arrays.sort(l);
		int s = sc.nextInt();
		long[] dp = new long[90010];
		dp[s] = 1;

		for (int i = 0; i < d; i++) {
			for (int j = 0; j <= s; j++) {
				if (j - l[i] > 0)
					dp[j - l[i]] += MOD - dp[j];
				dp[j] %= MOD;
			}
		}
		long cut = 0;
		for (int i = 1; i <= s; i++) {
			long tmp = dp[i];
			for (int j = 0; j < d; j++) {
				tmp = (tmp * i) % MOD;
			}
			cut = (cut + tmp) % MOD;
		}
		System.out.println(cut);
	}
}

Measured memory_bytes: 28036
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a.begin(), a.end());
	int ai = a[n-1];
	double mx = 1e9;
	int aj = -1;
	for(int i = 0; i < n; i++) {
		if(abs(ai/2.0 - a[i]) < mx) {
			mx = abs(ai/2.0 - a[i]);
			aj = a[i];
		}
	}
	printf("%d %d\n", ai, aj);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    for(int i = 1; i <= 9; ++i) {
        if(n <= i * 111) {
            cout << i * 111; return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b, k;
  cin >> k >> a >> b;
  if(a/k != b/k || a%k == 0 || b%k == 0){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        var h = int.Parse(Console.ReadLine());
        var w = int.Parse(Console.ReadLine());
        var n = int.Parse(Console.ReadLine());

        var ans = 0;
        var sum = 0;
        if (h > w)
        {
            for (int i = 0; i < w; i++)
            {
                sum += h;
                ans++;
                if (sum >= n)
                {
                    break;
                }
            }
        }
        else
        {
            for (int i = 0; i < h; i++)
            {
                sum += w;
                ans++;
                if (sum >= n)
                {
                    break;
                }
            }
        }

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092