akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int X[100009];

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a+b == 15)
		printf("+\n");
	else if(a*b == 15)
		printf("*\n");
	else
		printf("x\n");
	
	return 0;
}



Measured memory_bytes: 128
S=list(input())
n=len(S)
ans=0
for i in range(2**(n-1)):
    stack=""
    l=[]
    for j in range(n):
        stack=stack+S[j]
        if ((i >> j) & 1)or j==n-1:
            l.append(int(stack))
            stack=""
    ans+=sum(l)
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>

char end(char* s){
    int l = strlen(s);
    return s[l-1];
}

int main(){
    char A[11], B[11], C[11];
    scanf("%s %s %s", A, B, C);
    if(end(A)==B[0]&&end(B)==C[0]) printf("YES\n");
    else printf("NO\n");
    return 0;
}

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

using namespace std;

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

  int x;
  cin >> x;

  string ans = "No";
  if (x >= 30) {
    ans = "Yes";
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3604
s = list(input())
count = [0]*len(s)

for i in range(0,len(s)):
	if s[i] == 'A' or s[i] == 'T' or s[i] == 'C' or s[i] == 'G':
		if i >= 1:
			count[i] = count[i-1] +1
		if i == 0:
			count[i] = 1
	else:
		count[i] = 0

print(max(count))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//F6編譯，右上三角形執行，ctrl+c強制停止執行  F5開啟exe
#define ll long long
#define maxn 200005
#define mod 1000000000
using namespace std;

typedef pair<int, int> P;

int n;
ll k;
int a[maxn], f[maxn], used[maxn];
int from, cycle;
int st;

void solve(int x)
{
    int now = 1;
    for (int i = 0; i < x; i++)
        now = a[now];
    printf("%d\n", now);
}

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    if (k <= n)
    {
        solve(k);
        return 0;
    }
    f[0] = 1;
    used[1] = 0;
    int now = 1;
    for (int i = 1;; i++)
    {
        now = a[now];
        if (used[now])
        {
            from = used[now];
            cycle = i - from;
            break;
        }
        used[now] = i;
        f[i] = now;
    }
    //printf("%d \n", cycle);
    k = (k - from) % cycle + from;
    solve(k);

    return 0;
}

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

int main() {
  int n, y;
  cin >> n;
  cin >> y;
  for(int i = 0; i <= n; i++) {
    for(int j = 0; j <= n - i; j++) {
      int k = n - i - j;
      if (i * 10000 + j * 5000 + k * 1000 == y) {
	cout << i << " " << j << " " << k;
	return 0;
      }
    }
  }
  cout << "-1 -1 -1";
  return 0;
}

Measured memory_bytes: 764
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	long double n , m ,k;
	cin>> n >> m >> k ;
	ll mx=max(n , m);
	ll ans=ceil(k/mx);
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
 
const int INF = 2100100100;
const int MOD = 1e9 + 7;
 
// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}
 
int N, M, K, Q, W, H, R, C;
string S;
char table[100][100];
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
 
    REP(i, 50) {
        REP(j, 100) {
            table[i][j] = '.';
            table[i + 50][j] = '#';
        }
    }
    A--, B--;
 
    for (int i = 0; i < 50; i += 2) {
        if (B == 0) break;
        for (int j = 0; j < 50; j += 2) {
            if (B == 0) break;
            table[i][j] = '#';
            B--;
        }
    }
 
    for (int i = 0; i < 49; i += 2) {
        if (A == 0) break;
        for (int j = 0; j < 50; j += 2) {
            if (A == 0) break;
            table[i + 51][j] = '.';
            A--;
        }
    }
 
    cout << "100 100\n";
    REP(i, 100) {
        REP(j, 100) { cout << table[i][j]; }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int x, a, b;
  	cin >> x >> a >> b;
  	if (b <= a){
    	cout << "delicious";
    } else if(b > a + x){
    	cout << "dangerous";
    } else {
    	cout << "safe";
    }
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i, n) EFOR(i,0,n)
#define REP_FROM(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define REP_REV(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define REP_FROMREV(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define EPS 1e-10
#ifndef LOCAL
#define cerr if (false) cerr
#endif
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <class T> T sq(T x) { return x * x; }
template <class T> T clamp(T a, T l, T r) { return min(max(a, l), r); } // [l, r]
const double PI  = acos(-1.0);

// Process
class Process {
	public:
		string name;
		int cost;
};

// Queue(Round Robin)
class MyQueue {
	private:
		queue<Process> q;
		int quantom;
		int elapsed;

	public:
		MyQueue() {
			elapsed = 0;
		}
		void setQuantom(int q);
		void addProcess(Process p);
		bool isDone();
		void simulate();
};

void MyQueue::setQuantom(int q) {
	quantom = q;
}

void MyQueue::addProcess(Process p) {
	q.push(p);
}

bool MyQueue::isDone() {
	return q.size() <= 0;
}

void MyQueue::simulate() {
	Process proc = q.front(); q.pop();

	elapsed += min(quantom, proc.cost);
	proc.cost -= min(quantom, proc.cost);
	if(proc.cost <= 0) {
		cout << proc.name << " " << elapsed << endl;
	} else {
		q.push(proc);
	}
}

int main(int argc, char *argv[]) {
	// Something to do
	MyQueue mq;
	int n, q;
	cin >> n >> q;
	mq.setQuantom(q);

	REP(i, n) {
		Process proc;
		string name;
		int cost;
		cin >> name >> cost;
		proc.name = name;
		proc.cost = cost;
		mq.addProcess(proc);
	}

	while(!mq.isDone()) {
		mq.simulate();
	}

	return 0;
}

Measured memory_bytes: 6232
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000000;
int main(){
  long long A, B, C;
  cin >> A >> B >> C;
  long long K;
  cin >> K;
  if (K % 2 == 0){
    cout << A - B << endl;
  } else {
    cout << B - A << endl;
  }
}

Measured memory_bytes: 256
a,b,c,x,y = map(int, input().split())

ans = 10**18
for k in range(2*10**5+1):
    if k%2 != 0:
        continue
    i = max(x-k//2, 0)
    j = max(y-k//2, 0)
    temp = a*i+b*j+c*k
    ans = min(ans, temp)
print(ans)


Measured memory_bytes: 67728
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,K;
  cin >> N >> K;
  vector<int> p(N);
  rep(i,N) cin >> p[i];
  sort(ALL(p));
  int sum = 0;
  rep(i,K)
  {
    sum += p[i];
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
const int N = 500005;

char s[N];

int n;

int main() {

	scanf("%s", s);

	n = (int)strlen(s);

	int last = 0;

	ll ans = 0;
	for(int i = 0; i < n; i++) {
		int j = i;
		while(j + 1 < n and s[j + 1] == s[i]) j++;
		int len = j - i + 1;
		if(s[i] == '>') {
			ans += 1LL * len * (len - 1) / 2;
			ans += max(0, len - last);
		}
		else {
			ans += 1LL * len * (len + 1) / 2;
		}
		last = len;
		i = j;
	}

	printf("%lld\n", ans);
}


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

#define ll long long
#define ar array

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a;
	cin >> a;
	cout << a+a*a+a*a*a;

	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
template<class S>void tf(bool b,S t,S f){cout<<(b?t:f)<<endl;}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<set<int>> in(n+1),out(n+1);
	rep(i,n+m-1){
		int a,b;
		cin>>a>>b;
		in[b].insert(a);
		out[a].insert(b);
	}
	using pii=pair<int,int>;
	auto cmp=[](pii a, pii b){return a.sc>b.sc;};
	priority_queue<pii,vector<pii>, decltype(cmp)> q(cmp);
	vi par(n+1,-1),isS(n+1,0);
	range(i,1,n+1){
		if(in[i].size()==0){
			q.emplace(i,0);
			par[i]=0;
		}
	}
	while(!q.empty()){
		int p,e;
		tie(p,e)=q.top();
		q.pop();
		if(isS[p])continue;
		isS[p]=1;
		//cout<<p<<",";
		for(auto&o:out[p]){
			//if(par[o]==p)continue;
			in[o].erase(p);
			par[o]=p;
			q.emplace(o,in[o].size());
		}
	}
	range(i,1,n+1)cout<<par[i]<<endl;
	return 0;
}

Measured memory_bytes: 21236
a,b,c=map(int,input().split())
print(min(abs(b-a)+abs(c-b),abs(c-a)+abs(b-c),abs(a-b)+abs(c-a),abs(c-b)+abs(a-c),abs(a-c)+abs(b-a),abs(b-c)+abs(a-b)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
const int N=10;

int n;
int P[N],Q[N],A[N];
 

void init()
{scanf("%d",&n);
 for (int i=1; i<=n; i++)
   scanf("%d", &P[i]);
 for (int i=1; i<=n; i++)
   scanf("%d", &Q[i]);
}

bool check(int t[])
{for (int i=1; i<=n; i++)
   if (A[i]!=t[i]) return true;
 return false;
}

void work()
{int a=0,b=0;
 for (int i=1;i<=n;i++)
   A[i]=i;
 while (check(P))
   {a++;
    next_permutation(A+1,A+1+n);
   }
 for (int i=1;i<=n;i++)
   A[i]=i;
 while (check(Q))
   {b++;
    next_permutation(A+1,A+1+n);
   } 
 printf("%d\n",abs(a-b));   
}

int main()
{
 init();
 work();
 return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <algorithm>
#include <queue>

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  std::pair<int, long long> job[100000];
  for (int i = 0; i < n; ++i)
  {
    scanf("%d%lld", &job[i].first, &job[i].second);
  }
  std::sort(job, job + n);
  std::priority_queue<long long> q;
  long long ans = 0;
  auto *p = job;
  for (int i = 1; i <= m; ++i)
  {
    while (p < (job + n) && p->first <= i)
    {
      q.emplace(p->second);
      ++p;
    }
    if (q.size() > 0)
    {
      ans += q.top();
      q.pop();
    }
  }
  printf("%lld\n", ans);
  return 0;
}

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

using namespace std;

int main() {
    int N, K, d, a;
    cin >> N >> K;
    vector<int> count(N);
    for (int i = 0; i < K; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> a;
            count[a-1] = 1;
        }
    }
    cout << N - accumulate(count.begin(), count.end(), 0) << endl;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    ll a, b; cin >> a >> b;

    int m = 0;
    if (a < 0) m -= a;
    if (b < 0) m += b + 1;

    if (a <= 0 && 0 <= b) {
        cout << "Zero" << endl;
    }
    else if (m % 2 == 1) {
        cout << "Negative" << endl;
    }
    else {
        cout << "Positive" << endl;
    }
    
    return 0;
}






Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import math
import collections
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n=I()
strs=[]
for i in range(n):
    line=sorted(input().rstrip())
    STR=""
    for j in line:
        STR=STR+j
    strs.append(STR)
#print(strs)
x=collections.Counter(strs)
#print(x)
sm=0
for j in x:
    sm+=x[j]*(x[j]-1)//2
print(sm)

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

#define int long long

#define Vanya Unstoppable

#define double long double

using namespace std;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    string a; cin >> a;
    cout << (a[2] == a[3] && a[4] == a[5] ? "Yes" : "No");
}


Measured memory_bytes: 256
import static java.lang.System.in;
import static java.lang.System.out;
import static java.lang.Math.*;

import java.util.*;


public class Main {

	public static Scanner sc=new Scanner(in);

	static class Node{
		int id;
		int fp;
		boolean isC;
		List<Edge> link=new ArrayList<Edge>();

		Node(int _id,int _fp,boolean _isC){
			id=_id;
			fp=_fp;
			isC=_isC;
		}
	}

	static class Edge{
		Node f,t;
		int cost;
		Edge(Node _f,Node _t,int _cost){
			f=_f;t=_t;cost=_cost;
		}
	}

	static class Task implements Comparable<Task>{
		Node node;
		int time;
		Task(Node _node,int _time){
			node=_node;time=_time;
		}
		public int compareTo(Task arg0){
			return time-arg0.time;
		}
	}

	public static int[][] dijkstra(Node[][] graph,int s){
		int n=graph.length,M=graph[0].length-1;
		PriorityQueue<Task> que=new PriorityQueue<Task>();
		int[][] d=new int[n][M+1];
		for(int i=0;i<n;i++)
			Arrays.fill(d[i],1<<30);
		que.offer(new Task(graph[s][M],0));
		d[s][M]=0;
		while(!que.isEmpty()){
			Task di=que.poll();
			if(d[di.node.id][di.node.fp]<di.time)continue;
			for(Edge edge:di.node.link){
				if(d[edge.t.id][edge.t.fp]>d[di.node.id][di.node.fp]+edge.cost){
					d[edge.t.id][edge.t.fp]=d[di.node.id][di.node.fp]+edge.cost;
					que.offer(new Task(edge.t,d[di.node.id][di.node.fp]));

					//prev[edge.to]=di.id;
				}
			}
		}
		return d;
	}

	public void run(){
		while(true){
			int n=sc.nextInt(),m=sc.nextInt(),l=sc.nextInt(),
					k=sc.nextInt(),s=sc.nextInt(),e=sc.nextInt();
			if(n==0)return;

			boolean[] ccity=new boolean[n];
			for(int i=0;i<l;i++){
				int v=sc.nextInt();
				ccity[v]=true;
			}
			ccity[s]=ccity[e]=true;

			long[][] d=new long[n][n];

			for(int i=0;i<n;i++){
				Arrays.fill(d[i],1<<30);
				d[i][i]=0;
			}
			for(int i=0;i<k;i++){
				int x=sc.nextInt(),y=sc.nextInt(),t=sc.nextInt();
				d[x][y]=d[y][x]=t;
			}
		    for(int _k=0;_k<n;_k++)
		    	for(int i=0;i<n;i++)for(int j=0;j<n;j++)
		    		d[i][j] = min(d[i][j], d[i][_k] + d[_k][j]);

		    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
		    	if(d[i][j]>m || !ccity[i] || !ccity[j])d[i][j]=1<<30;
		    }

		    for(int _k=0;_k<n;_k++)
		    	for(int i=0;i<n;i++)for(int j=0;j<n;j++)
		    		d[i][j] = min(d[i][j], d[i][_k] + d[_k][j]);

			if(d[s][e]==1<<30)
				ln("Help!");
			else{
				ln(d[s][e]+max(0,d[s][e]-m));
			}
		}

	}

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

	//output lib
	public static void ln(){
		out.println();
	}
	public static void pr(Object obj){
		out.print(str(obj));
	}
	public static void ln(Object obj){
		pr(obj);ln();
	}
	public static String str(Object obj){
		return obj.toString();
	}
	public static <E> String str(E[] obj){
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<obj.length;i++){
			sb.append(i==0?"":" ").append(obj[i]);
		}
		return sb.toString();
	}
	public static <E> String str(List<E> obj){
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<obj.size();i++){
			sb.append(i==0?"":" ").append(obj.get(i));
		}
		return sb.toString();
	}


}

Measured memory_bytes: 64736
#include<iostream>
#include<vector>
#include<algorithm>

typedef long long ll;

using namespace std;

ll N,M,L,K[2001],sum[100001],dp[2001][2001];

ll func(ll l,ll r){

  if(dp[l][r]>0)return dp[l][r];

  ll n=max(l,r)+1;
  if(n==N)return (sum[K[n]]-sum[K[l]-1])/L+(sum[K[n]]-sum[K[r]-1])/L;

  ll lf=func(n,r)+(sum[K[n]]-sum[K[l]-1])/L;
  ll rt=func(l,n)+(sum[K[n]]-sum[K[r]-1])/L;

  return dp[l][r]=min(lf,rt);
}

int main(void){

  cin >> N >> M >> L;

  for(int i=1;i<=N;i++)cin >> K[i];
  
  sort(K+1,K+N+1);

  for(int i=1;i<=M;i++){
    cin >> sum[i];
    sum[i]+=sum[i-1];
  }

  cout << func(1,1) << endl;

  return 0;
}

Measured memory_bytes: 33300
#include <iostream>
#include <stdlib.h>

using namespace std;

int main() {

    int numS;
    cin >> numS;

    int *arrS = (int*) malloc(numS * sizeof(int));
    for (int i = 0; i < numS; i++) {
        cin >> arrS[i];
    }

    int numT;
    cin >> numT;
    int count = 0;
    for (int i = 0; i < numT; i++) {
        int current;
        cin >> current;
        for (int j = 0; j < numS; j++) {
            if (*(arrS + j) == current) {
                count++;
                break;
            }
        }
    }

    free(arrS);

    cout << count;
    cout << endl;

    return 0;
}



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

using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

void solve(){
    int n;
    cin >> n;
    int a[n+10];
    rep(i,n){
        cin >> a[i];
    }
    /*
    int count=0;
    rep(i,n){
        if(a[i]>=2){
            count += a[i]/2;
            a[i]=a[i]%2;
        }
    }
    for(int i=1; i<n; i++){
        if(a[i-1]==1&&a[i]==1){
            count++;
            a[i-1]=0;
            a[i]=0;
        }
    }
    cout << count << endl;
    */

    //上の解法だと、1 2 3の時にミスる
    //0がなければ、結局１枚だけ残してあとは全部回収することが可能

    ll ans=0;
    ll tmp=0;
    rep(i,n){
        if(a[i]==0){
            ans+=tmp/2;
            tmp=0;
        }
        else{
            tmp+=a[i];
        }
    }
    ans += tmp/2;
    cout << ans << endl;
}

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


Measured memory_bytes: 640
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ！！

X = int(input())
A = int(input())
B = int(input())

X = X - A
for i in range(1,1000):
    if X < B:
        break
    else:
        X = X - B
print(X)

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

int main(void)
{
	int r, c;
	int num[256][256];
	int c_sum[256] = {0}, r_sum[256] = {0}, all_sum = 0;

	cin >> r >> c;

	for(int i = 0; i < r; i++) {
		for(int j = 0; j < c; j++) {
			cin >> num[i][j];
			c_sum[i] += num[i][j];
			r_sum[j] += num[i][j];
			all_sum += num[i][j];
		}
	}

	for(int i = 0; i < r; i++) {
		for(int j = 0; j < c; j++) {
			cout << num[i][j] << ' ';
		}
		cout << c_sum[i] << endl;
	}

	for(int j = 0; j < c; j++) {
		cout << r_sum[j] << ' ';
	}
	cout << all_sum << endl;

	return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
#include <functional>
#define int long long
using namespace std;
 
const int depth = 16;
class Segtree {
	int data[1 << (depth + 1)];
public:
 
	void init() { for (int i = 0; i < (1 << (depth + 1)); i++) data[i] = 0; }
	
	//区間[l, r)にvを足す
	void add(int l, int r, int v, int a = 0, int b = (1 << depth), int id = 0) {
		if (l >= b || r <= a) return;
		if (l <= a && b <= r) { data[id] += v; return; }
		add(l, r, v, a, a + (b - a) / 2, id * 2 + 1);
		add(l, r, v, a + (b - a) / 2, b, id * 2 + 2);
	}
	
	//要素posの値
	int getNum(int pos) {
		pos = (1 << depth) - 1 + pos;
		int ret = data[pos];
		while (pos > 0) {
			pos = (pos - 1) / 2;
			ret += data[pos];
		}
		return ret;
	}
};

Segtree seg;

int getHanten(vector<double> a) {
	map<double, int> pos;
	int i;
	int n = a.size();
	
	seg.init();
	for (i = 0; i < n; i++) {
		pos[a[i]] = i;
	}
	for (i = 0; i < n; i++) seg.add(i, i + 1, i);
	
	sort(a.begin(), a.end());
	
	int ans = 0;
	for (i = 0; i < n; i++) {
		ans += seg.getNum(pos[a[i]]);
		seg.add(pos[a[i]] + 1, n, -1);
	}
	return ans;
}

int n;
int a[40000], b[40000], c[40000];

int countX(double l) {
	int i;
	typedef pair<double, double> P;
	vector<P> ys;
	
	for (i = 0; i < n; i++) {
		double y = (c[i] - a[i] * l) / (double)b[i];
		double katamuki = -a[i] / (double)b[i];
		ys.push_back(P(y, katamuki));
	}
	sort(ys.begin(), ys.end(), greater<P>());
	
	vector<double> a;
	for (i = 0; i < n; i++) {
		a.push_back(ys[i].second);
	}
	
	return getHanten(a);
}

int countY(double l) {
	int i;
	typedef pair<double, double> P;
	vector<P> xs;
	
	for (i = 0; i < n; i++) {
		double x = (c[i] - b[i] * l) / (double)a[i];
		double kt = -b[i] / (double)a[i];
		xs.push_back(P(x, kt));
	}
	sort(xs.begin(), xs.end(), greater<P>());
	
	vector<double> a;
	for (i = 0; i < n; i++) {
		a.push_back(xs[i].second);
	}
	return getHanten(a);
}

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
	
	int k = n * (n - 1) / 2;
	double st, ed, mid;
	
	st = -1e+9;
	ed = 1e+9;
	for (i = 0; i < 70; i++) {
		mid = (st + ed) / 2;
		if (countX(mid) >= (k - 1) / 2 + 1) { ed = mid; }
		else { st = mid; }
	}
	double ansX = st;
	
	st = -1e+9;
	ed = 1e+9;
	for (i = 0; i < 70; i++) {
		mid = (st + ed) / 2;
		if (countY(mid) >= (k - 1) / 2 + 1) { ed = mid; }
		else { st = mid; }
	}
	double ansY = st;
	
	printf("%.14f %.14f\n", ansX, ansY);
	return 0;
}

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


int main()
{
	long long  n,a,b,c;
	cin>>n;
	for(int a=1;a<=3500;a++)
		for(int b=1;b<=3500;b++){
		long long x=n*a*b;
		long long y=4*a*b-n*(b+a);
			if(y>0 && x%y==0){
				cout<<a<<" "<<b<<" "<<x/y<<endl;
				return 0;
			}
		}
	return 0;
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
ARR = [int(s) for s in input().split(" ")]

def calculate(n, arr):
    dict = {'gray': False, 'brown': False, 'green': False, 'water': False, 'blue': False, 'yellow': False,
            'orange': False, 'red': False}
    any = 0

    for ar in arr:
        if ar >= 1 and ar <= 399:
            dict.__setitem__('gray',True)
        elif ar >= 400 and ar <= 799:
            dict.__setitem__('brown', True)
        elif ar >= 800 and ar <= 1199:
            dict.__setitem__('green', True)
        elif ar >= 1200 and ar <= 1599:
            dict.__setitem__('water', True)
        elif ar >= 1600 and ar <= 1999:
            dict.__setitem__('blue', True)
        elif ar >= 2000 and ar <= 2399:
            dict.__setitem__('yellow', True)
        elif ar >= 2400 and ar <= 2799:
            dict.__setitem__('orange', True)
        elif ar >= 2800 and ar <= 3199:
            dict.__setitem__('red', True)
        else:
            any = any + 1

    l = np.array(list(dict.values()))

    goodNum = np.sum(l == True)
    badNum = np.sum(l == False)

    if goodNum == 0:
        print(1,goodNum + any)
    else:
        print(goodNum,goodNum + any)

calculate(N,ARR)

Measured memory_bytes: 12508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,x,t;
  int time=0,count=0;
  cin >> n >> x >> t;
  while(count<n){
    count+=x;
    time+=t;
  }
  cout << time << endl;
}

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

#define INF 1000000000

int counter = 0;

void merge(int A[], int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1 + 1];
    int R[n2 + 1];
    for(int i = 0; i < n1; i++)
        L[i] = A[left + i];
    for(int i = 0; i < n2; i++)
        R[i] = A[mid + i];
    L[n1] = INF;
    R[n2] = INF;
    int i = 0;
    int j = 0;
    for(int k = left; k < right; k++)
    {
        counter++;
        if(L[i] <= R[j])
        {
            A[k] = L[i];
            i++;
        }
        else
        {
            A[k] = R[j];
            j++;
        }
    }
}

void merge_sort(int A[], int left, int right)
{
    if(left + 1 < right)
    {
        int mid = (left + right) / 2;
        merge_sort(A, left, mid);
        merge_sort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    int A[n];
    for(int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    merge_sort(A, 0, n);

    for(int i = 0; i < n - 1; i++)
        printf("%d ", A[i]);
    printf("%d\n", A[n - 1]);
    printf("%d\n", counter);
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	string str;
	cin >> str;
	int cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < str.size(); i++) {
		if (str[i] != '0' + i % 2) {
			cnt1++;
		}
		else {
			cnt2++;
		}
	}
	cout << min(cnt1, cnt2) << "\n";
}

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


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        if(a<b) {
            int k=0;
            k=a; a=b; b=k;
        }
      
       if(a<c) {
           int k=0;
            k=c; c=a; a=k;
        }
        
        if(a*a==b*b+c*c) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}



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

using namespace std;

void Solve(){
    int n;
    cin>>n;
    long long res = 0;
    for(int i = 1; i <= n; i++){
        if(i % 3 == 0 || i % 5 == 0) continue;
        res += i;
    }
    cout<<res<<'\n';
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int test_case = 1;
    //cin>>test_case;
    while(test_case--){
        Solve();
    }
}

Measured memory_bytes: 3652
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        
        int r=sc.nextInt();
        int D=sc.nextInt();
        
        int[] x=new int[11];
        x[0]=sc.nextInt();
        
        for(int i=1;i<x.length;i++) {
        	x[i]=(r*x[i-1])-D;
        }
        
        for(int j=1;j<x.length;j++) {
        	System.out.println(x[j]);
        }
        
        sc.close();
    }
}

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

#define max(a,b) (a>b)?a:b
using namespace std;

int main(int args, char *argc[]){
  int a,b,c,d;
  int q,w,e,r;
  cin>>a>>b>>c>>d;
  cin>>q>>w>>e>>r;
  int suma=a+b+c+d;
  int sumb=q+w+e+r;
  cout<<(max(suma,sumb))<<endl;
  return 0;
}


Measured memory_bytes: 1160
import math

count = 0

N, H = list(map(int, input().split()))
a, b = [], []

for i in range(N):
    tmp = list(map(int, input().split()))
    a.append(tmp[0])
    b.append(tmp[1])

max_a = max(a)
b.sort(reverse=True)

for b_ in b:
    if max_a <= b_:
        H -= b_
        count += 1
    if H <= 0:
        break
if H > 0:
    count += math.ceil(H / max_a)

print(count)

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

const double INF = 1e4;

template <typename T>
struct Dijkstra {
  struct Edge {
    int to;
    int cost;
    int cap;
  };
  vector<vector<Edge>> g;
  Dijkstra(int n) : g(n) {}

  void addEdge(int u, int v, int d, int c) {
    g[u].push_back({v, d, c});
    g[v].push_back({u, d, c});
  }
  T build(int s, int t) {
    vector<vector<vector<T>>> dp(
        g.size(), vector<vector<T>>(g.size(), vector<T>(31, INF)));
    struct Node {
      T time;
      int speed;
      int to;
      int rev;
      bool operator>(const Node& other) const { return speed > other.speed; }
    };
    priority_queue<Node, vector<Node>, greater<Node>> pq;
    pq.push({0.0, 0, s, s});

    while (!pq.empty()) {
      auto now = pq.top();
      pq.pop();
      if (dp[now.to][now.rev][now.speed] < now.time) continue;
      for (auto&& nxt : g[now.to]) {
        if (nxt.to == now.rev) continue;
        for (int ds = -1; ds <= 1; ds++) {
          int speed = now.speed + ds;
          if (speed < 1 || nxt.cap < speed) continue;
          double time = now.time + 1.0 * nxt.cost / speed;
          if (dp[nxt.to][now.to][speed] > time) {
            dp[nxt.to][now.to][speed] = time;
            pq.push({time, speed, nxt.to, now.to});
          }
        }
      }
    }
    T res = INF;
    for (int i = 0; i < g.size(); i++) {
      res = min(res, dp[t][i][1]);
    }
    return res;
  }
};

int main() {
  int n, m;
  while (cin >> n >> m, n) {
    int s, g;
    cin >> s >> g;
    s--, g--;
    Dijkstra<double> graph(n);
    for (int i = 0; i < m; i++) {
      int x, y, d, c;
      cin >> x >> y >> d >> c;
      x--, y--;
      graph.addEdge(x, y, d, c);
    }
    auto ans = graph.build(s, g);
    if (ans < INF) {
      cout << ans << endl;
    } else {
      cout << "unreachable" << endl;
    }
  }
}



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

using namespace std;
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    vector<ll> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    std::sort(l.begin(), l.end());
    int cnt = 0;
    for (int i = 0; i < l.size(); i++) {
        for (int j = i + 1; j < l.size(); j++) {
            for (int k = j + 1; k < l.size(); k++) {
                if (abs(l[i] - l[j]) < l[k] && l[k] < l[i] + l[j] &&
                    l[i] != l[j] && l[j] != l[k]) {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rrep(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr ll INF = (ll)1e9;
constexpr ll mod = (ll)1e9 + 7;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

struct UnionFind {
	vector<int>d;

	UnionFind(int N) :d(N, -1) {}

	int find(int x) {
		if (d[x] < 0)return x;
		return d[x] = find(d[x]);
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return false;
		if (d[x] > d[y])swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return -d[find(x)];
	}
};

int main() {
	init();

	int N, M; cin >> N >> M;
	UnionFind uf(N);
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		--a; --b;
		uf.unite(a, b);
	}
	int ans = 0;
	rep(i, 0, N) {
		if(uf.d[i]<0)chmax(ans, abs(uf.d[i]));
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3960
n, q = map(int, input().split())
s = input()

t = [0] * (n)
for i in range(n-1):
    if s[i:i+2] == 'AC':
        t[i+1] = t[i]+1
    else:
        t[i+1] = t[i]

for _ in range(q):
    l, r = map(int, input().split())
    print(t[r-1]-t[l-1])


Measured memory_bytes: 6060
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

template<typename X>
class LiChaoTree {
    // a*x+b
    struct Line {
        X a, b;
        Line(X a, X b) : a(a), b(b) {}
        X get(X x) const { return a * x + b; }
    };
    
    vector<X> xs;
    vector<Line> seg;
    int sz;

    void update(Line &x, int k, int l, int r) {
        int m = (l + r) / 2;
        bool lef = x.get(xs[l]) < seg[k].get(xs[l]);
        bool mid = x.get(xs[m]) < seg[k].get(xs[m]);
        if(mid) swap(seg[k], x);
        if(l + 1 >= r) return;
        else if(lef != mid) update(x, 2 * k + 1, l, m);
        else update(x, 2 * k + 2, m, r);
    }

public:
    // クエリで見たい座標リスト（昇順にソートされている必要がある）
    // INF: X 型で十分大きい値
    LiChaoTree(const vector<X> &x, X INF) : xs(x){
        sz = 1;
        while(sz < xs.size()) sz *= 2;
        while(xs.size() < sz) xs.push_back(xs.back() + 1);
        seg.assign(2 * sz - 1, Line(0, INF));
    }
    
    // a*x+b を追加する
    void update(X a, X b){
        Line l(a, b);
        update(l, 0, 0, sz);
    }
    
    // 今までに追加された直線たち a_i*x+b_i に対して
    // min(a_i*x[k]+b_i) を返す
    X query(int k){
        const X x = xs[k];
        k += sz - 1;
        X ret = seg[k].get(x);
        while(k > 0) {
          k = (k - 1) >> 1;
          ret = min(ret, seg[k].get(x));
        }
        return ret;
    }
};

int main(){
    long long N, C;
    cin >> N >> C;
    vector<long long> h(N);
    REP(i, N) cin >> h[i];

    vector<long long> dp(N);
    LiChaoTree<long long> lct(h, 1LL<<60);

    REP(i, 1, N){
        lct.update(-2*h[i-1], h[i-1]*h[i-1]+dp[i-1]);
        long long mn = lct.query(i);
        dp[i] = mn + h[i]*h[i]+C;
    }
    cout << dp[N-1] << endl;
    return 0;
}

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

int main()
{

    ll n,m,c,i,j,cnt=0,x;
    cin>>n>>m>>c;
    vector<ll>a;
    vector<ll>b;
    for(i=0; i<m; i++)
    {
        cin>>x;
        b.push_back(x);
    }
    ll s=0;
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            cin>>x;
            a.push_back(x);
            s+=a[j]*b[j];
        }
        s+=c;
        if(s>0)
        {
            cnt++;
        }
        a.clear();
        s=0;
    }
    cout<<cnt<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

void eratosthenes(vector<bool> &isPrime) {
  int n = isPrime.size();
  REP(i, n) { isPrime[i] = true; }
  isPrime[0] = false;
  isPrime[1] = false;
  for (int i = 2; i < n; i++) {
    if (!isPrime[i])
      continue;
    for (int k = 2; i * k < n; k++) {
      isPrime[i * k] = false;
    }
  }
}

int main() {
  vector<bool> isPrime(55556);
  eratosthenes(isPrime);
  REP(i, isPrime.size()) {
    if (isPrime[i] && i % 5 != 1) {
      isPrime[i] = false;
    }
  }
  int n;
  cin >> n;
  vi ans;

  REP(i, isPrime.size()) {
    if (isPrime[i]) {
      ans.push_back(i);
    }
    if (ans.size() == n) {
      break;
    }
  }
  REP(i, n) {
    cout << ans[i];
    if (i != n - 1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[]) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        String[] ss = new String[n];
        for (int i = 0; i < n; i++) ss[i] = sc.next();
        int m = sc.nextInt();
        String[] ts = new String[m];
        for (int i = 0; i < m; i++) ts[i] = sc.next();
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            if (map.containsKey(ss[i])) map.put(ss[i], map.get(ss[i]) + 1);
            else map.put(ss[i], 1);
        }
        for (int i = 0; i < m; i++) {
            if (map.containsKey(ts[i])) map.put(ts[i], map.get(ts[i]) - 1);
        }
        int max = 0;
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            int count = entry.getValue();
            if (count > max) max = count;
        }
        System.out.println(max);
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21460
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int max = Math.max(a, Math.max(b, c));

		System.out.println(a + b + c - max);
	}

}


Measured memory_bytes: 21588
s = str(input())
k = int(input())
count = 0
for i in s:
    if i == "1":
        count += 1
        if count == len(s):
            print(1)
            break
        else:
            pass
    else:
        if k <= count:
            print(1)
            break
        else:
            print(i)
            break


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String str = reader.readLine();

    if (str.contains("7")) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 32536
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;
 
//const long long INF = 1LL << 55;
 
#define itn ll
#define endl '\n'
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main(void){
   ioboost;
   
   int n;cin >> n;
   set<int> ans;
   if(n == 3){
      vi a = {2, 5, 63};
      for(auto i : a)cout <<i << endl;
   }else if(n == 4){
      vi a = {2, 5, 20, 63};
      for(auto i : a)cout <<i << endl;
   }else if(n == 5){
      vi a = {2, 5, 20, 30, 63};
      for(auto i : a)cout <<i << endl;
   }else{
      vl a;
      ll sum = 0;
      int ad[4] = {2,3,4,6};
      rep(i,n){
         ans.insert(6 * (i/4) + ad[i%4]);
         sum += 6 * (i/4) + ad[i%4];
      }
      switch(sum % 6){
         case 2:
            ans.erase(8);
            ans.insert(6*(n/4 + 1));
            break;
         case 3:
            ans.erase(9);
            ans.insert(6*(n/4 + 1));
            break;
         case 5:
            ans.erase(9);
            ans.insert(6*((n-1)/4 + 1) + 4);
            break;
         default:break;
      }
      
      for(auto i : ans){
         if(i > 30000){
            cout << i - 6 << endl;
         }else{
            cout << i << endl;
         }
      
      }
   }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#pragma GCC optimize(3,"Ofast")
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define f(i, l, r) for (int i = l; i <= r; i++)
#define rf(i, r, l) for (int i = r; i >= l; i--)
#define all(x) (x).begin(), (x).end()
#define sf(a) scanf("%d", &a)
#define llsf(a) scanf("%lld", &a)
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
//#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))
#define mod1(x) ((x>=mod)&&(x-=mod))
#define mod2(x) ((x<0)&&(x+=mod))

const int inf = 2e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);

int main() {
#ifdef local
	int start = clock();
	freopen("in.txt", "r", stdin);
#endif
	
	int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;
	int sum = (h2 - h1 - 1) * 60 + m2 + 60 - m1;
	cout << sum - k;

#ifdef local
		int end = clock();
		cout << '\n' << end - start << "ms";
#endif* /
	}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef int64_t LL;
const int MOD=1e9+7;
int P(LL a,LL n)
{
  if(n==0)return 1;
  else if(n==1)return a%MOD;
  else if(n%2==0)return P((LL)a*a%MOD,n/2)%MOD;
  else return (a*P(a,n-1))%MOD;
}
int C(LL n,LL k)
{
  LL x=1,y=1;
  k=min(k,n-k);
  if(n<0||k<0||n<k)return 0;
  if(n==0||k==0)return 1;
  for(int i=0;i<k;i++)
  {
    x*=n-i,x%=MOD;
    y*=i+1,y%=MOD;
  }
  return (x*P(y,MOD-2))%MOD;
}
int main()
{
  int N,A,B,z;
  cin>>N>>A>>B;
  z=P(2,N)-1;
  z-=C(N,A);if(z<0)z+=MOD;
  z-=C(N,B);if(z<0)z+=MOD;
  return cout<<z<<endl,0;
}

Measured memory_bytes: 256