akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
	
    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	int N = sc.nextInt();

	int A = sc.nextInt();

	int B = sc.nextInt();

	if((N*A)<B){

	System.out.println(N*A);	

   }
	else{

	System.out.println(B);
 
   } 

  }
 }

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  if(c > b && b > a){
    cout << "Yes" << endl;
    return 0;
  }
  rep(i, k){
    if(c > b && b > a){
      cout << "Yes" << endl;
      return 0;
    }
    if(b <= a){
      b *= 2;
      continue;
    }
    if(c <= b){
      c *= 2;
      continue;
    }
  }
  if(c > b && b > a){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main(){
	while( 1 ){
		int N, Q;
		cin >> N >> Q;
		if( N == 0 ) break;
		int list[101], i, j;
		for( i = 1; i < 101; i++ ){
			list[i] = Q;
		}
		for( i = 0; i < N; i++ ){
			int M;
			cin >> M;
			vector<int> date(M);
			for( j = 0; j < M; j++ ){
				cin >> date[j];
				list[date[j]]--;
			}
		}
		int ans = 0;
		for( i = 0; i < 101; i++ ){
			if( list[i] <= 0 ){
				if( ans == 0 || list[i] < list[ans] ){
					ans = i;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
LL H,W,N;
typedef pair<int,int>P;
vector<int>G[200011];
int main(){
	cin>>H>>W>>N;
	REP(i,N){
		int X,Y;
		cin>>X>>Y;
		G[Y].push_back(X);
	}
	REP(i,200011){
		sort(G[i].begin(),G[i].end());
	}
	int ans=H;
	LL now=1;
	REP(i,200009){
		//if(i>W+5)break;
		//cout<<now<<endl;
		if(i==0)continue;
		if(G[i].size()==0){
			now++;
			REP(j,G[i+1].size()){
				if(now==G[i+1][j]){
					now++;
				}
			}
			continue;
		}
		if(i==1){
			//1より大きく始めにぶつかる場所
			ans=min(ans,G[1][0]-1);
			now++;
			REP(j,G[i+1].size()){
				if(now==G[i+1][j]){
					now++;
				}
			}
		}else{
			LL t=300000;
			REP(j,G[i].size()){
				if(now<G[i][j]){
					ans=min(ans,G[i][j]-1);
				}
			}
			now++;
			REP(j,G[i+1].size()){
				if(now==G[i+1][j]){
					now++;
				}
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8704
H, W, D = map(int, input().split())
A = []
C = [0 for _ in range(H * W + 1)]
for h in range(H):
    A.append(list(map(lambda x: int(x) - 1, input().split())))
for i in range(H):
    for j in range(W):
        C[A[i][j]] = (i, j)
h = [0 for _ in range(H * W)]
for i in range(D):
    s = 0
    for j in range(i, H * W, D):
        if j != i:
            n = (C[j][0], C[j][1])
            p = (C[j - D][0], C[j - D][1])
            s += abs(n[0] - p[0]) + abs(n[1] - p[1])
        h[j] = s
Q = int(input())
for _ in range(Q):
    l, r = map(lambda x: int(x) - 1, input().split())
    print(h[r] - h[l])


Measured memory_bytes: 18096
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cerr << "\n\n" << "Time elapsed: " << \
					  (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
					  return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'

ll p1=101,mod1=17093097961,p2=53,mod2=491845979;
pair<pll,ll> dp[10005];
pll dp1[10005];
pll prv[10005];
pll prv1[10005];
bool vis[10005],vis1[10005];
bool act[10];
ll a[10]={0,2,5,5,4,5,6,3,7,6};
string s,s1;

inline void rec(pll node)
{
	char c=node.ss+'0';
	s+=c;
	if(node.ff==0)
		return;

	rec(prv[node.ff]);
}
inline void rec1(pll node)
{
	char c=node.ss+'0';
	s+=c;
	if(node.ff==0)
		return;

	rec1(prv1[node.ff]);
}

int main()
{
	fastio;
	#ifdef APNA_IO
		start_routine();
        freopen("input.txt", "rt", stdin);
        freopen("output.txt", "wt", stdout);
    #endif
 	
 	vis[0]=1;
 	vis1[0]=1;
 	ll n,m;cin>>n>>m;
 	for(ll i=0;i<m;i++)
 	{
 		ll x;cin>>x;
 		act[x]=1;
 	}
 	
 	for(ll i=1;i<=n;i++)
 	{
 		for(ll k=1;k<=9;k++)
 		{
 			if(act[k])
 			{
 				if(i-a[k]<0)
 					continue;

 				if(!vis[i-a[k]])
 					continue;

 				vis[i]=1;
 				ll x1=((dp[i-a[k]].ff.ff*p1)%mod1+k)%mod1;
 				ll x2=((dp[i-a[k]].ff.ss*p2)%mod2+k)%mod2;
 				ll y=dp[i-a[k]].ss+1;
 				ll y1=dp1[i-a[k]].ss+1;
 				if(y>dp[i].ss)
 				{
 					dp[i].ss=y;
 					dp[i].ff={x1,x2};
 					prv[i]={i-a[k],k};
 				}
 				else if(y==dp[i].ss && x1>dp[i].ff.ff && x2>dp[i].ff.ss)
 				{
 					dp[i].ff={x1,x2};
 					prv[i]={max(i-a[k],0ll),k};
 				}
 				else if(y==dp[i].ss && x1==dp[i].ff.ff && x2==dp[i].ff.ss && k>prv[i].ss)
 				{
 						prv[i].ss=k;
 				}
 			}

 			if(act[k])
 			{
 				if(i-a[k]<0)
 					continue;

 				if(!vis1[i-a[k]])
 					continue;

 				vis1[i]=1;
 				ll x1=((dp1[i-a[k]].ff*p1)%mod1+k)%mod1;
 				ll y1=dp1[i-a[k]].ss+1;
 				if(y1>dp1[i].ss)
 				{
 					dp1[i].ss=y1;
 					dp1[i].ff=x1;
 					prv1[i]={i-a[k],k};
 				}
 				else if(y1==dp1[i].ss && x1>dp1[i].ff)
 				{
 					dp1[i].ff=x1;
 					prv1[i]={max(i-a[k],0ll),k};
 				}
 				else if(y1==dp1[i].ss && x1==dp1[i].ff && k>prv1[i].ss)
 				{
 						prv1[i].ss=k;
 				}
 			}
 		}
 	}

 	// cout<<prv[2].ff<<" "<<prv[2].ss<<endl;

 	rec(prv[n]);
 	sort(s.begin(), s.end());
 	reverse(s.begin(), s.end());
 	string s1=s;
 	// cout<<s1<<endl;

 	s="";
 	rec1(prv1[n]);
 	sort(s.begin(), s.end());
 	reverse(s.begin(), s.end());
 	// cout<<s<<endl;
 	
 	if(s1.length()>s.length())
 		s=s1;
 	else if(s1.length()==s.length() && s1>s)
 		s=s1;
 	cout<<s;

	#ifdef APNA_IO
		end_routine();
    #endif
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

 
int main() {
    ll a,b,n;
    cin >> a >> b >> n;
    ll ans;
    if(n>=b-1){
        ans=a*(b-1)/b;
    }
    else ans=a*n/b;
    cout << ans << endl;
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  ll N,K,D,A; cin >> N >> K;
  set<ll> su;
  REP(i,K) {
    cin >> D;
    REP(j,D) {
      cin >> A;
      su.insert(A);
    }
  }
  cout << N - su.size();
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>

using namespace std;

int main() {
    int K, S;
    int count = 0;
    cin >> K >> S;
    for (int i = 0; i <= K; i++)
    {
        for (int j = 0; j <= K; j++)
        {
                if (S - i - j >= 0 && S - i - j <= K)
                {
                    count++;
                }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    string s;
    cin >> s;

    int n = s.size();
    vector< vs64 > dp(n + 1, vs64(13, 0));
    dp[0][0] = 1;

    rep (i, n)
    {
        if (s[i] == '?')
        {
            rep (num, 10)
            {
                rep (j, 13)
                {
                    dp[i + 1][(j * 10 + num) % 13] = (dp[i + 1][(j * 10 + num) % 13] + dp[i][j]) % MOD;
                }
            }
        }
        else
        {
            int num = s[i] - '0';
            rep (j, 13)
            {
                dp[i + 1][(j * 10 + num) % 13] = (dp[i + 1][(j * 10 + num) % 13] + dp[i][j]) % MOD;
            }
        }
    }

    cout << dp[n][5] << "\n";
    return 0;
}



Measured memory_bytes: 13648
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int m, k, n;
vector<int> res;

signed main() {
    cin >> m >> k;
    n = 1<<(m+1);
    if (k>=(1<<m)) return cout << -1 << endl, 0;
    if (m==0) return cout << "0 0" << endl, 0;
    if (m==1) {
        if (k==0) return cout << "0 0 1 1" << endl, 0;
        return cout << -1 << endl, 0;
    }
    rep(i,1<<m) if (i!=k) res.push_back(i);
    res.push_back(k);
    repr(i,(1<<m)-1) if (i!=k) res.push_back(i);
    res.push_back(k);
    rep(i,n) cout << res[i] << bln(i,n);
}

Measured memory_bytes: 2932
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std; 
int main() {
    string t;
    cin>>t;
    int tl=t.length();
    for(int i=0;i<tl-1;i++){
        if(t[i]==t[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
    }
    for(int i=0;i<tl-2;i++){
        if(t[i]==t[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int k, n; std::cin >> k >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    int ans = 1e9;
    for (int i = 1; i < n; i++) {
        ans = std::min(ans, k - a[i] + a[i - 1]);
    }
    std::cout << std::min(ans, a[n - 1] - a[0]) << std::endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

int main() {
    int w, h, n;
    cin >> w >> h >> n;

    int x, y, a;
    int l = 0, r = w, d = 0, u = h;
    for (int i = 0; i < n; i++) {
        cin >> x >> y >> a;
        if (a == 1) l = max(l, x);
        if (a == 2) r = min(r, x);
        if (a == 3) d = max(d, y);
        if (a == 4) u = min(u, y);
    }
    cout << max(u - d, 0) * max(r - l, 0) << endl;
    return 0;
}

Measured memory_bytes: 3592
n,m = list(map(int, input().split() ))
A= [[0 for i in range(m)] for j in range(n)] 
b = [0 for i in range(m)]
for ni in range(n):
 A[ni] = list( map(int,input().split() ))
for mi in range(m):
 b[mi] = int(input());

for i in range(n):
 ai = 0;
 for mi in range(m):
  ai = ai + A[i][mi]*b[mi];
 print(ai)



Measured memory_bytes: 6020
inf = float('inf')

n,m = map(int,input().split())
c = list(map(int,input().split()))

dp = [inf]*(n+1)
dp[0] = 0
for i in range(1,n+1):
    for ci in c:
        if i - ci >= 0:
            dp[i] = min(dp[i], dp[i-ci] + 1)

ans = dp[n]
print(ans)


Measured memory_bytes: 7260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, dp[100000][4], a[100009], b[100009], c[100009];
int f(int i, int j) {
	if (i == n)return 0;
	if (dp[i][j] != -1)return dp[i][j];
	if (j == 1)return dp[i][j] = max(b[i] + f(i + 1, 2), c[i] + f(i + 1, 3));
	if (j == 2)return dp[i][j] = max(a[i] + f(i + 1, 1), c[i] + f(i + 1, 3));
	if (j == 3)return dp[i][j] = max(a[i] + f(i + 1, 1), b[i] + f(i + 1, 2));
}
int main() {
	memset(dp, -1, sizeof dp);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	cout << max(f(0, 1), max(f(0, 2), f(0, 3))) << endl;
}

Measured memory_bytes: 7680
import sys
input = sys.stdin.readline

N,M = map(int,input().split())
AB = [0]*M
C = [0]*M
for i in range(M):
    AB[i] = list(map(int,input().split()))
    C[i] = list(map(int,input().split()))

INF = 10**8
dp = [[INF]*(2**N) for _ in [0]*(M+1)]
dp[0][0] = 0

for i,ab in enumerate(AB):
    a,b = ab
    c = sum(1<<(d-1) for d in C[i])
    for t in range(2**N):
        dp[i+1][t] = min(dp[i+1][t],dp[i][t])
        dp[i+1][t|c] = min(dp[i+1][t|c],dp[i][t|c],dp[i][t]+a)
ans = dp[-1][-1]
if ans == INF : ans = -1
print(ans)

Measured memory_bytes: 77804
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<ll,ll>pll;



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

	vector<int>v(2);
	v[0] = -1;
	rep(i, 0, m) {
		int l, r;
		cin >> l >> r;
		if (v[0] == -1) {
			v[0] = l;
			v[1] = r;
		}
		else {
			v[0] = max(l,v[0]);
			v[1] = min(r,v[1]);
		}
		if (v[0] > v[1]) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << v[1] - v[0] + 1 << endl;





	return 0;
}

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

using std::vector;

typedef struct bomb {
        int x;
        int y;
} bomb;

int main() {
        const int N = 8;
        int num;
        int mass[N][N];
        vector<bomb> bv;
        char s[9];

        scanf("%d", &num);
        for (int n = 0; n < num; n++) {
                for (int i = 0; i < N; i++) {
                        scanf("%s", s);
                        for (int j = 0; j < 8; j++) {
                                mass[i][j] = s[j]-'0';
                        }
                }
                bomb first;
                scanf("%d", &first.x);
                scanf("%d", &first.y);
                first.x--; first.y--;
                bv.push_back(first);
                while (!bv.empty()) {
                        int x = bv.front().x, y = bv.front().y;
                        mass[y][x] = 0;
                        for (int dx = -3; dx <= 3; dx++) {
                                if (x+dx < 0 || x+dx >= N) {
                                        continue;
                                }
                                if (mass[y][x+dx] == 1) {
                                        bomb b;
                                        b.x = x+dx;
                                        b.y = y;
                                        bv.push_back(b);
                                }
                        }
                        for (int dy = -3; dy <= 3; dy++) {
                                if (y+dy < 0 || y+dy >= N) {
                                        continue;
                                }
                                if (mass[y+dy][x] == 1) {
                                        bomb b;
                                        b.x = x;
                                        b.y = y+dy;
                                        bv.push_back(b);
                                }
                        }
                        bv.erase(bv.begin());
                }

                printf("Data %d:\n", n+1);
                for (int i = 0; i < N; i++) {
                        for(int j = 0; j < N; j++) {
                                printf("%d", mass[i][j]);
                        }
                        printf("\n");
                }
        }

        return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int64 calc_S(int64 x1, int64 y1, int64 x2, int64 y2, int64 x3, int64 y3) {
    int64 mx_x = max({x1, x2, x3}), mn_x = min({x1, x2, x3});
    int64 mx_y = max({y1, y2, y3}), mn_y = min({y1, y2, y3});
    int64 res = (mx_x-mn_x)*(mx_y-mn_y)*2;
    res -= abs(x1-x2)*(abs(y1-y2));
    res -= abs(x1-x3)*(abs(y1-y3));
    res -= abs(x3-x2)*(abs(y3-y2));
    return res;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 S;
	cin >> S;
	int64 e = sqrt(S);
	int64 x1, x2, x3, y1, y2, y3;
	if (e*e < S) e++;
	if (e*(e-1) <= S) {
	    x1 = 0; y1 = 0; x2 = e; y2 = 1; x3 = e*e-S; y3 = e;
	} else {
        x1 = 0; y1 = 0; x2 = e; y2 = 1; x3 = e*(e-1)-S; y3 = e-1;
	}
//	if (calc_S(x1, y1, x2, y2, x3, y3) == S) {
//	    cout << "ok" << endl;
//	}
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;	

signed main(){IOS;
	string s,t; cin>>s>>t;
	int n = s.size() , m = t.size();
	vector<vector<int>>dp(n+1,vector<int>(m+1,0));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i-1]==t[j-1]){
				dp[i][j] = max(dp[i][j],max(dp[i-1][j-1]+1,max(dp[i-1][j],dp[i][j-1])));
			}else {
				dp[i][j] = max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
			}
		}
	}
	int i = n , j = m ;
	string ans = "";
	while(i>0 and j > 0){
		if(s[i-1] == t[j-1]){
			ans+=s[i-1];
			i--;
			j--;
		}else if( dp[i][j-1] > dp[i-1][j]){
			j--;
		}else {
			i--;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 70784
n, W = input().split()
n = int(n)
W = int(W)

items = []
for _ in range(n):
    v, w = input().split()
    items.append((int(v), int(w)))

dp = [[0 for _ in range(n+1)] for _ in range(W+1)]

for i in range(1, W+1):
     for j in range(1, n+1):
         value = items[j-1][0]
         weight = items[j-1][1]
         if i >= weight:
             dp[i][j] = max(dp[i][j-1], dp[i-weight][j-1]+value)
         else:
             dp[i][j] = dp[i][j-1]

print(dp[W][n])

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

int main(){
	int n, temp, max=0, min=10e9+1;
	cin >> n;
	while(n--){
		cin >> temp;
		max = (temp>max?temp:max);
		min = (temp<min?temp:min);
	}
	cout << max-min << endl;
}

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

int main(void)
{
    string str;

    cin >> str;

    int ans = 700;

    for(int i = 0; i < 3; i++)
    {
        if(str.at(i) == 'o') ans += 100;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <stdlib.h>
#include <algorithm>

int main()
{
    int a,b;
    scanf("%d", &a);
    scanf("%d", &b);

    if(b % a == 0)
        printf("%d",a+b);
    else
        printf("%d",b-a);
    return 0;
}

Measured memory_bytes: 128
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 3010;
const int SIZE3 = 330;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
#define endl "\n" //インタラクティブでは消す
ut N, M, K, L, Q, D, H,W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;

VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL DP[1001][30001];
bool finished[1001][30001];
LL A[SIZE2][SIZE2];
LL WW[SIZE], S[SIZE], V[SIZE];
Vpr v;
LL solve2(LL n,LL w) {
	if (n == -1) return 0;
	int i = v[n].second;
	if (finished[n][w]) return DP[n][w];
	finished[n][w] = true;
	DP[n][w] = solve2(n - 1, w);
	if (w <= S[i]) MX(DP[n][w], solve2(n - 1, w + WW[i]) + V[i]);
	return DP[n][w];
}
LL solve() {
	int N;
	cin >> N;
	REP(i, N) {
		cin >> WW[i] >> S[i] >> V[i];
		v.pb(WW[i]+S[i],i);
	}
	sort(ALL(v),greater<pr>());
	cout << solve2(N - 1, 0) << endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(0);
	solve();
	cin >> N;
	return 0;

}


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

char a,b,c;

inline int qr()
{
	int w=1,x=0;char a=0;
	while(a<'0'&&a>'9'){if(a=='-')w=-1;a=getchar();}
	while(a<='9'||a>='0'){x=(x<<3)+(x<<1)+(a^48);a=getchar(); }
	return x*w;
}

int main()
{
	cin>>a>>b>>c;
	if(a=='R'&&b=='R'&&c=='R')
	{
		cout<<3<<endl;
		return 0;
	}
	if(a=='S'&&b=='S'&&c=='S')
	{
		cout<<0<<endl;
		return 0;
	}
	if((a=='R'&&b=='R')||(b=='R'&&c=='R'))
	{
		cout<<2<<endl;
		return 0;
	}
	cout<<1<<endl;
		return 0;
	return 0;
}

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

int main(){
    int k, n;
    cin >> k >> n;
    int a[n+10], b[n+10];
    for (int i = 0; i < n; ++i){
        cin >> a[i];
        if (i>0){
            b[i-1] = a[i]-a[i-1];
        }
    }
    sort(b, b+n-1, greater<int>());
    int d_max = max({b[0], a[0]+(k-a[n-1])});
    cout << k-d_max << endl;
}

Measured memory_bytes: 1792
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,k,c = m()

s = list(input())[:-1]


dp0 = [-1 for i in range(k)]
dp1 = [-1 for i in range(k)]
co = 0
po = 0
for i in range(n):
    if co == 0:
        if s[i] == "o":
            dp0[po] = i
            if po == k-1:
                break
            po += 1
            co = c
    else:
        co -= 1

co = 0

po = k-1

for i in range(n-1,-1,-1):
    if co == 0:
        if s[i] == "o":
            dp1[po] = i
            if po == 0:
                break
            co = c
            po -= 1

    else:
        co -= 1

for i in range(k):
    if dp0[i] == dp1[i] and dp0[i] != -1:
        print(dp0[i]+1)


Measured memory_bytes: 64700
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333

using namespace std;
long long ans;
int i,j,m,n,p,k,col[N],flag=0,x,y,cnt,size[3];
vector<int>v[N],vn[N];
void dfs(int x)
{
		int i;
		size[col[x]]++;
		for (i=0;i<(int)v[x].size();++i)
		{
				int p=v[x][i];
				++cnt;
				if (col[p]!=-1)
				{
						if (col[p]!=(col[x]+1)%3) flag=1;
				}
				else col[p]=(col[x]+1)%3,dfs(p);
		}
		for (i=0;i<(int)vn[x].size();++i)
		{
				int p=vn[x][i];
				++cnt;
				if (col[p]!=-1)
				{
						if (col[p]!=(col[x]+2)%3) flag=1;
				}
				else col[p]=(col[x]+2)%3,dfs(p);
		}
}
int main()
{
		scanf("%d%d",&n,&m);
		for (i=1;i<=m;++i)
		{
				scanf("%d%d",&x,&y);
				v[x].pb(y);
				vn[y].pb(x);
		}
		memset(col,-1,sizeof(col));
		for (i=1;i<=n;++i)
			if (col[i]==-1)
			{
					flag=0; cnt=0; 
					memset(size,0,sizeof(size));
					col[i]=0;
					dfs(i);
					if (flag) 
					ans+=1ll*(size[0]+size[1]+size[2])*(size[0]+size[1]+size[2]);
					else if (size[0]&&size[1]&&size[2])
					{
							ans+=1ll*size[0]*size[1]+1ll*size[1]*size[2]+1ll*size[2]*size[0];
					}
					else ans+=cnt/2;
			}
		cout<<ans<<endl;
}


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

int main() {
    long long X,t; cin >> X >> t;
    if(t>X)cout << 0 << endl;
    else cout << X-t << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

vector<int> G[52];
int n,m;
int a,b,c;
int steps[3];
int d[52];
int goal;
int dp[52][52][102];

bool dfs(int v,int u,int a) {
    if(a==0) {
        return v==u;
    }
    if(dp[v][u][a]!=-1) return dp[v][u][a];
    bool f=false;
    rep(i,G[v].size()) {
        f|=dfs(G[v][i],u,a-1);
    }

    return dp[v][u][a]=f;
}

int nextCost(int u) {
    int ret=-1;
    rep(i,3) {
        int t=INF;
        rep(v,n) {
            if(dfs(v,u,steps[i])) {
                t=min(t,d[v]);
            }
        }

        ret=max(ret,t);
    }

    return ret;
}

void bfs() {
    d[goal]=0;
    bool f=true;
    while(f) {
        f=false;
        //printf("debug %d %d\n",v,d[v]);
        rep(u,n) {
            int t=nextCost(u);
            if(t==-1||t==INF) continue;
            if(d[u]>t+1) {
                f=true;
                d[u]=t+1;
            }
        }
    }
}

int main() {
    rep(i,52) d[i]=INF;
    memset(dp,-1,sizeof(dp));
    cin>>n>>m;
    cin>>a>>b>>c;
    steps[0]=a; steps[1]=b; steps[2]=c;
    goal = n-1;
    rep(i,m) {
        int s,t;
        cin>>s>>t; s--;t--;
        G[t].pb(s);
    }
    bfs();
    int ans=d[0];

    if(ans==INF) cout<<"IMPOSSIBLE"<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2324
#include <stdio.h>
#include <string.h>
 
int main(){
  char s[201];
  char p[101];
  char temp[101];
 
  scanf("%s %s", s, p);
  strcpy(temp, s);
  strcat(s,temp);
  if(strstr(s, p)){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
 
  return 0;
}


Measured memory_bytes: 2140
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>

using namespace std;

const int N = 1000001;

const int mod = 1000000007;

int power_mod(long long a, int b) {
	long long res = 1;
	while(b) {
		if(b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}

int main() {
	int n; cin >> n;
	vector<int> p(N, 0);
	vector<int> a(n);

	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		int x = a[i];
		for(int j = 2; j * j <= x; ++j) {
			int count = 0;
			while(x % j == 0) {
				++count;
				x /= j;
			}
			p[j] = max(p[j], count);
		}
		if(x > 1) p[x] = max(p[x], 1);
	}
	long long l = 1;	
	for(int i = 1; i < N; ++i) {
		if(p[i] > 0) {
			l = l * power_mod(i, p[i]);
			l %= mod;
		}
	}
	long long ans = 0;
	for(int i = 0; i < n; ++i) {
		ans = ans + l * power_mod(a[i], mod - 2);
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4224
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n = gi();
    int m = gi();
    printf(m == n ? "Yes\n" : "No\n");

    return 0;
}


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

public class Main {
	static final int NUM_RAND = 10;

	/**
	 * @param args
	 */
	public static void main(String[] args)
			throws IOException {
		BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in));
		int numInput = Integer.parseInt(br.readLine());
		for(int i = 0; i < numInput; i++){
			int[] r = rand(Integer.parseInt(br.readLine()));
			System.out.println("Case " + (i + 1) + ":");
			for(int n : r){
				System.out.println(n);
			}
		}
	}

	public static int[] rand(int seed) {
		int[] r = new int[NUM_RAND];
		String randSquare = null;
		for (int i = 0; i < r.length; i++) {
			randSquare = String.format("%08d", seed * seed);
			String center = getCenter(randSquare);
			r[i] = Integer.parseInt(center);
			seed = r[i];
		}
		return r;
	}

	private static String getCenter(String str) {
		return str.substring(2, 6);
	}
}

Measured memory_bytes: 17040
#include<iostream>
#include<cstdio>
#include<cstring>
#define MAXN 1001
using namespace std;
string t;
int c_pos,f_pos;
int main()
{
	cin>>t;
	for(int i=0;i<t.length();i++)
	{
		if(t[i]=='C')
		{
			if(c_pos==0)
			{
				c_pos=i+1;
			}
			
		}
		if(t[i]=='F')
		{
			f_pos=i+1;
		}
	}
	if(c_pos!=0&&f_pos!=0&&(c_pos<f_pos)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, K;
	cin >> n >> K;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	int idx = -1;

	vector<int> ans;
	bool ok = true;
	for (int j = 0; j <= K; j++) {
		int nex = -1;
		for (int i = 0; i < n; i++) {
			if (i == idx) continue;
			if (a[i] == 0) {
				ok = false;
				break;
			}	
			if (nex == -1 || a[i] < a[nex]) nex = i;		
		}
		if (!ok) break;

		for (int i = 0; i < n; i++) {
			if (i == idx || i == nex) continue;
			a[i]--;
			ans.push_back(i + 1);
		}
		a[nex]--;
		ans.push_back(nex + 1);
		idx = nex;
	}

	if (ok) {
		cout << ans.size() << endl;
		for (int i = 0; i < ans.size(); i++) {
			cout << ans[i] << " \n"[i + 1 == ans.size()];
		}
	} else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    int[string] m;
    string s;
    while ((s = readln.chomp).length > 0) {
        foreach (c; s) {
            if (isAlpha(c)) {
                m[c.to!string.toLower]++;
            }
        }
    }

    foreach (c; lowercase) {
        auto b = c.to!string in m;
        writefln("%s : %s", c, b == null ? 0 : *b);
    }
}

Measured memory_bytes: 2484
n = int(input())
d = {"AC" : 0, "WA" : 0, "TLE" : 0, "RE" : 0}
for i in range(n):
    d[input()] += 1
print("AC x", d["AC"])
print("WA x", d["WA"])
print("TLE x", d["TLE"])
print("RE x", d["RE"])


Measured memory_bytes: 9020
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;

void main()
{
  auto kt = readln.chomp.split.map!(to!int);
  auto a = readln.chomp.split.map!(to!int).array;
  int res;
  int prev = -1;
  foreach_reverse (n; 1..kt[0]+1) {
    int index = -1;
    int max_n;
    foreach (i, e; a) {
      if (e == n) {
        index = i.to!int;
        break;
      }
      if (i == prev) {
        continue;
      }
      if (e > max_n) {
        index = i.to!int;
        max_n = e;
      }
    }
    a[index]--;
    if (prev == index) res++;
    prev = index;
  }
  res.writeln;
}


Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

RGB_ = list(map(int, input().split()))
K = int(input())

from itertools import product
L = list(product(range(3), repeat=K))
for l in L:
    RGB=RGB_[:]
    for i in l:
        RGB[i] = RGB[i]*2
        if RGB[2]>RGB[1]>RGB[0]:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 9260
#!/usr/bin/env node
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/2/ALDS1_2_A

"use strict";
(function (stdin) {
  const [N, a] = stdin.toString().trim().split("\n");
  const A = a.split(" ").map(Number);
  let flag = 1;
  let i = 0;
  let count = 0;
  while (flag) {
    flag = 0;
    for (let j = N - 1; j > i; j--) {
      if (A[j] < A[j - 1]) {
        count++;
        const prev = A[j - 1];
        A[j - 1] = A[j];
        A[j] = prev;
        flag = 1;
      }
    }
    i++;
  }
  console.log(A.join(" "));
  console.log(count);
})(require("fs").readFileSync("/dev/stdin", "UTF-8"));



Measured memory_bytes: 15424
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	static int i;
	static int count = 0;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] param = line.split("");
		if (param.length >= 2 & param.length <= 26) {
			for (i = 0; i < param.length-1; i++) {
				for (int k = i + 1; k < param.length; k++) {
					if (param[i].equals(param[k])) {
						System.out.println("no");
						count++;
						break;
					}
				}
				if(count == 1){
					break;
				}
			}
		}else{
			System.out.println("miss");
		}
		if (count == 0) {
			System.out.println("yes");
		}

	}

}

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

signed main(void)
{
	int n, m, K;
	cin >> n >> m >> K;
	rep(k, n)
	{
		rep(l, m)
		{
			if (k * (m - l) + (n - k) * l == K)
			{
				cout << "Yes" << endl;
				return 0;
			}	
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int N, M;
  while(cin>>N>>M && N){
    vector<int> s(N), t(N);
    vector<int> rope(M);
    REP(i, N) scanf("%d %d", &s[i], &t[i]);
    REP(i, M) scanf("%d", &rope[i]);
    sort(rope.begin(), rope.end());
    vector<int> sum_mod[2] = {vector<int>(M), vector<int>(M)};
    REP(i, M - 1){
      sum_mod[0][i + 1] = sum_mod[0][i] + ((i % 2 == 0) ? (rope[i + 1] - rope[i]) : 0);
      sum_mod[1][i + 1] = sum_mod[1][i] + ((i % 2 == 1) ? (rope[i + 1] - rope[i]) : 0);
    }
    ll ans = 0;
    REP(i, N){
      bool rev = (s[i] > t[i]);
      if(rev) swap(s[i], t[i]);
      int b_idx = upper_bound(rope.begin(), rope.end(), s[i]) - rope.begin();
      int e_idx = upper_bound(rope.begin(), rope.end(), t[i]) - rope.begin();
      if(b_idx == e_idx){
        ans += (t[i] - s[i]);
        continue;
      }
      assert(b_idx < e_idx);
      e_idx--;
      if(!rev){
        int mod = (b_idx + 1) % 2;
        ans += sum_mod[mod][e_idx] - sum_mod[mod][b_idx];
        ans += (rope[b_idx] - s[i]);
        if((e_idx % 2) == mod){
          ans += (t[i] - rope[e_idx]);
        }
      }else{
        int mod = (e_idx) % 2;
        ans += sum_mod[mod][e_idx] - sum_mod[mod][b_idx];
        ans += (t[i] - rope[e_idx]);
        if(((b_idx + 1) % 2) == mod){
          ans += (rope[b_idx] - s[i]);
        }
      }
    }
    cout<<ans<<endl;
  }

  return 0;
}

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

int minCost(int a[], int n){
	int dp[n] = {0};
	if(n==1){
		return 0;
	}
	dp[1] = abs(a[1]-a[0]);

	for(int i=2;i<n;i++){
		dp[i] = min((dp[i-1]+abs(a[i]-a[i-1])), (dp[i-2]+abs(a[i]-a[i-2])));
	}
	return dp[n-1];
}

int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	cout<<minCost(a,n)<<"\n";
}

Measured memory_bytes: 1024
from itertools import product
N = int(input())
STR = ['3','5','7']
cnt = 0
for i in range(10):
  if N < 10 ** i-1:
    break
  else:
    A=list(product(STR,repeat = i+1))
    for j in A:
      if j.count('3')>=1 and j.count('5')>=1 and j.count('7')>=1 and int(''.join(j))<=N:
        cnt +=1
print(cnt)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <math.h>

typedef long long int ll;

using namespace std;

int main()
{
  ll M1,D1,M2,D2;
  cin >> M1 >>D1>>M2>>D2;

  if(M1==M2){
    cout << 0 << endl;
  }
  else{
    cout << 1 << endl;
  }




  
}

Measured memory_bytes: 256
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
M,a,b=10**9+7,0,0
for i in range(n):a+=(2*i-n+1)*x[i];a%=M
for i in range(m):b+=(2*i-m+1)*y[i];b%=M
print(a*b%M)

Measured memory_bytes: 24452
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

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

    if(s == "ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }

}

Measured memory_bytes: 3592
n = int(input())
xs = list(enumerate(map(int, input().split())))
xs.sort(key=lambda x: x[1])
xs.reverse()

dp = [[0 for _ in range(n + 1)] for _ in range(n + 1)]

for i in range(1, n + 1):
    (j, a) = xs[i - 1]

    for x in range(0, i + 1):
        y = i - x
        if x == 0:
            dp[x][y] = dp[x][y - 1] + a * (n - y - j)
        elif y == 0:
            dp[x][y] = dp[x - 1][y] + a * (j - x + 1)
        else:
            dp[x][y] = max(dp[x][y - 1] + a * (n - y - j),
                    dp[x - 1][y] + a * (j - x + 1))

print(max([dp[i][n - i] for i in range(n + 1)]))

Measured memory_bytes: 125604
#include<bits/stdc++.h>
using namespace std;
int64_t n,ans;
void DFS(int64_t x,bool a,bool b,bool c)
{
    if(x>n)return;
    if(a==1&&b==1&&c==1)ans++;
    DFS(x*10+3,1,b,c);
    DFS(x*10+5,a,1,c);
    DFS(x*10+7,a,b,1);
}

int main()
{
    cin>>n;
    DFS(0,0,0,0);
    cout<<ans<<endl;
}


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

int main(){
    int n, v;
    scanf("%d", &n);
    map<int, int> mp1, mp2;
    rep(i, n){
        scanf("%d", &v);
        if(i % 2) mp1[v]++;
        else mp2[v]++;
    }
    int oo[2][2] = {}, ee[2][2] = {};
    rep(i, 2){
        auto tmp = mp1.end();
        for(auto it = mp1.begin(); it != mp1.end(); it++){
            if(oo[i][1] < it->second){
                tie(oo[i][0], oo[i][1]) = *it;
                tmp = it;
            }
        }
        if(tmp != mp1.end()) mp1.erase(tmp);
        
        tmp = mp2.end();
        for(auto it = mp2.begin(); it != mp2.end(); it++){
            if(ee[i][1] < it->second){
                tie(ee[i][0], ee[i][1]) = *it;
                tmp = it;
            }
        }
        if(tmp != mp2.end()) mp2.erase(tmp);
    }
  	int ans;
    if(oo[0][0] != ee[0][0]){
        ans = n - oo[0][1] - ee[0][1]; 
    } else {
        ans = n - max(oo[1][1] + ee[0][1], oo[0][1] + ee[1][1]);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll ans = 0;
  if (a >= 2 * c) {
    ans += 2 * c * x;
    y -= x;
    x = 0;
    if (y > 0) {
      if (b >= 2 * c) ans += 2 * c * y;
      else ans += b * y;
    }
  }
  else if (b >= 2 * c) {
    ans += 2 * c * y;
    x -= y;
    y = 0;
    if (x > 0) ans += a * x;
  }
  else if (a + b >= 2 * c) {
    ans += 2 * c * min(x, y);
    while (x > 0 && y > 0) {
      x--;
      y--;
    }
    if (x > 0) ans += a * x;
    else ans += b * y;
  }
  else ans += a * x + b * y;
  cout << ans << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int64_t ans=0;
  bool flag=false;
  int n=1;
  for(int i=0;i<N;i++){
    cin >> a.at(i);
    if(a.at(i)==1){
      flag=true;
    }
    if(a.at(i)==n){
      n++;
    }else{
      ans++;
    }
  }
  if(!flag){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1024