akhauriyash/Code-Regression huggingface dataset:
/*     *******************Bismillahir Rahmanir Rahim************************
                          MD. ASFAKUL GHANI!
                          *ProMAGFAT*!
 SECRET_warning :)->FAT   CSE-25!
                          JAHANGIRNAGAR UNIVERSITY!
                          Dhaka,Bangladesh!
*/

#include <bits/stdc++.h>
#include <set>
using namespace std;

#define           fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define           Im int main()
#define           ll long long
#define           sc scanf
#define           pf printf
#define           rn0 return 0
#define           rn return
#define           f0(i,n) for(ll i=0;i<n;i++)
#define           f1(i,n) for(ll i=1;i<=n;i++)
#define           f2(i,n) for(ll i=n-1;i>=0;i--)
#define           pi 2*acos(0.0)
#define           modulo 1000003
#define           dd double
#define           PI 3.14159265358979
#define           pi 2*acos(0.0)
#define           p_b push_back
#define           ps push

/*
ll for_binarySearch(ll a,ll b,ll aa[],ll x){while(a<=b){ll mid=(a+b)/2;if(aa[mid]==x) return 1;else if(aa[mid] > x) b=mid-1;else a=mid+1;}return -1;}
ll for_gcd(ll a,ll b){if(a==0) return b;else return for_gcd(b%a,a);}
ll for_prime(ll x){for (ll i=2;i*i<=x;i++){if(x%i==0) return 0;}return 1;}
void for_swap(char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
ll for_big_mod(ll b,ll p,ll m){if(p==0) return 1;else if(p%2==0){ll k=for_big_mod(b,p/2,m);return (k*k)%m;}else return ((b%m)*(for_big_mod(b,p-1,m)))%m;}
ll for_josephus(ll n,ll k){if(n==1) return 1;return (for_josephus(n-1,k)+k-1)%n+1;}
ll for_gcdExtended(ll a,ll b,ll *x,ll *y){if(a==0){*x=0;*y=1;return b;}ll x1,y1;ll gcd=for_gcdExtended(b%a,a,&x1,&y1);*x=y1-(b/a)*x1;*y=x1;return gcd;}
*/
/*
void debug1()
{
    cout << "***" << endl;
}

void debug11(ll n)
{
    cout << n << endl;
}
*/

Im
{
    /*#ifdef FAT
       freopen("input.txt","w",stdin);
    #endif // FAT*/

    fasterIO;
    ll n;
    cin>>n;
    ll a1[n+5];
    ll c1 = 0;
    for (ll i = 0; i < n; i += 1){
        cin>>a1[i];
    }
    for (ll i = 0; i < n; i += 1){
        ll pos = i;
        for (ll j = i; j < n; j += 1){
            if (a1[j] < a1[pos]){
                pos = j;
            }
        }
        if (pos != i) {
            c1 += 1;
            swap(a1[i],a1[pos]);
        }
    }
    for (ll i = 0; i < n; i += 1){
        if (i==0) cout << a1[i];
        else cout << " " << a1[i];
    }
    cout << endl;
    cout << c1 << endl;

   // main();

    rn0;
}

Measured memory_bytes: 3220
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int c = saori.saori_hayami();
		boolean flg = true;
		if(a+b+c < 22){
			flg = false;
		}
		if(flg){
			System.out.println("bust");
		} else {
			System.out.println("win");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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


int main() {
  int n;
  cin >> n;
  int a[n];//問題文のデータを収納
  int order[n];//各順番を収納
  
  for(int i=0;i<n;i++){
      cin >> a[i];
      order[a[i]-1] = i+1;
  }

  for(int num:order){
      cout << num << " ";
  }
  cout << endl;
}


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

int cPD(string S){
	int i;
	int N1=0;
	int N2=0;
	for(i=0;i<S.size();i++){
		if(S[i]=='D'){
			N1++;
		}
	}
	for(i=0;i<S.size()-1;i++){
		if(S[i]=='P'&&S[i+1]=='D'){
			N2++;
		}
	}
	return N1+N2;

}

int main()
{
    string S, S1, S2;
	cin>>S;
	S1=S; 
	S2=S;
	int i;
	for(i=0;i<S.size();i++){
		S1[i]=S[i];
		S2[i]=S[i];
	}
	int M1,M2;
	for(i=0;i<S.size();i++){
		if(S[i]=='?'){
			S1[i]='D';
		}
	}
	M1=cPD(S1);
	for(i=0;i<S.size();i++){
		if(S[i]=='?'){
			S2[i]='P';
		}
	}
	M2=cPD(S2);
	if(M1>M2){
		cout<< S1;
	}
	else{
		cout<< S2;
	
	}
	return 0;
}

Measured memory_bytes: 4124
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    string a;
    cin >> a;
    if (a[0]=='9' || a[1]=='9'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm> 
using namespace std;
 
# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    long long int ans = (n/11)*2;
    if(n%11!=0) ans += (n%11<=6?1:2);  
    p(ans)
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    string s;
    char a[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    cin>>s;
    long long z=s.length(),q=26-n-1;
    for(int j=0;j<z;j++)
    {
        for(int i=0;i<26;i++)
        {
            if(i<=q)
            {
                if(s[j]==a[i]) cout<<a[i+n];
            }else
            {
                if(s[j]==a[i]) cout<<a[i-q-1];
            }
        }
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
/*
std::string substrBack(std::string str, size_t pos, size_t len) {
	const size_t strLen = str.length();

	return str.substr(strLen - pos, len);
}*/

using namespace std;

int main() {
	while (true) {
		string s1,s2;
		string mozi;
		string data[1000];
		string data2[1000];
		string i1;
		string i2;
		int bun = 0;
		int cnt = 0;
		int flag = 0;
		int bun2 = 0;
		cin >> s1;
		if (s1 == ".") {
			return 0;
		}
		cin >> s2;
		for (int i = 0; i < (int)s1.size(); i++) {
			mozi = s1[i];
			if (flag == 1) {
				if (mozi == "\"") {
					flag = 0;
					bun++;
					cnt++;
				}
				else {
					data[cnt]+=mozi;
				}
			}else if (mozi == "\"") {
				flag = 1;
				i1 += "\"";
			}
			else {
				i1 += mozi;
			}
		}
		flag = 0;
		cnt = 0;
		for (int i = 0; i < (int)s2.size(); i++) {
			mozi = s2[i];
			if (flag == 1) {
				if (mozi == "\"") {
					flag = 0;
					cnt++;
					bun2++;
				}
				else {
					data2[cnt] += mozi;
				}
			}
			else if (mozi == "\"") {
				flag = 1;
				i2 += "\"";
			}
			else {
				i2 += mozi;
			}
		}
		int cnt2 = 0;
		for (int i = 0; i < bun; i++) {
			if (data[i] != data2[i]) {
				cnt2++;
			}
		}
		if (bun2 != bun) {
			cout << "DIFFERENT" << endl;
		}
		else {
			if (i1 == i2) {
				if (cnt2 == 1) {
					cout << "CLOSE" << endl;
				}
				else if (cnt2 == 0) {
					cout << "IDENTICAL" << endl;
				}
				else {
					cout << "DIFFERENT" << endl;
				}
			}
			else {
				cout << "DIFFERENT" << endl;
			}
		}
	}
	/*while (true) {
	string s;
	string c;
	string d;
	int kagi;
	char mozi;
	int maru;
	cin >> s;
	if (s == ".") {
		return 0;
	}
	int flag;
	for (int i = 0; i < (int)s.size(); i++) {
		flag = 0;
		mozi = s[i];
		if (mozi == '(' || mozi == '[') {
			c.push_back(mozi);
		}
		if (mozi == ')' || mozi == ']') {
			d = substrBack(c, 1, 1);
			kagi = d[0];
			if (kagi != mozi) {
				flag = 1;
				break;
			}
			c.pop_back();
		}
	}
		if (c.size() == 0 || flag == 1) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}*/

}



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

const int N = 200010;

int a[N], pre[N];

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++ i){
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < k; ++ i){
        memset(pre, 0, sizeof(pre));
        for (int j = 0; j < n; ++ j){
            int left = j - a[j], right = j + a[j] + 1;
            left = std::max(left, 0);
            ++ pre[left];
            if (right < N){
                -- pre[right];
            }
        }
        for (int j = 1; j < n; ++ j){
            pre[j] += pre[j - 1];
        }
        for (int j = 0; j < n; ++ j){
            a[j] = pre[j];
        }
        bool flag = true;
        for (int j = 0; j < n; ++ j){
            if (a[j] != n){
                flag = false;
                break;
            }
        }
        if (flag){
            break;
        }
    }
    for (int i = 0; i < n; ++ i){
        printf("%d%c", a[i], " \n"[i == n - 1]);
    }
    return 0;
}

Measured memory_bytes: 5324
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;


string S;

ll ans=1,N,M,A[100005];
queue<int>que;
ll fib[100005];
int main() {

	cin >> N >> M;
	FOR(i, 1, M+1)cin >> A[i];
	A[0] = -1;
	fib[1] = 1; fib[2] = 1;
	FOR(i, 3, 100003) {
		fib[i] = fib[i - 1] + fib[i - 2];
		fib[i] %= MOD;
	}
	FOR(i, 1, M+1) {
		if (A[i] - A[i - 1] == 1) { ans = 0; break; }
		ans = (ans*fib[A[i] - A[i - 1]-1])%MOD;
	}
	if (M > 0) {
		ans = (ans*fib[N - A[M]])%MOD;
	}
	else if (M == 0) {
		ans = fib[N+1];
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
//input.c
#include <stdio.h>
#include<stdlib.h>


int main(void){
  
  int a[3];
  int b[3];
 int count[4] = {0,0,0,0};

  scanf("%d %d",&(a[0]),&(b[0]));
  scanf("%d %d",&(a[1]),&(b[1]));
  scanf("%d %d",&(a[2]),&(b[2]));

for( int i=0;i<3;i++ )
{
count[a[i]]++;
if( 3 <= count[a[i]] )
{
 printf("NO");
return 0;
}
count[b[i]]++;
if( 3 <= count[b[i]] )
{
 printf("NO");
return 0;
}
}

printf("YES");
  return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)

n = int(input())
cnt = []

def search(x, use):
    if x > n:
        return
    if use == 0b111:
        cnt.append(1)
        
    search(x * 10 + 3, use | 0b100)
    search(x * 10 + 5, use | 0b010)
    search(x * 10 + 7, use | 0b001)

search(0, 0)
print(sum(cnt))

Measured memory_bytes: 9144
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,t = LI()
    switch = LI()
    ans = t

    for i in range(1,n):
        span = switch[i] - switch[i-1]
        if span < t:
            ans += -(t-span) + t
        else:
            ans += t
    
    print(ans)

main()            


Measured memory_bytes: 95212
H,W=map(int,input().split())
N=int(input())
alist=list(map(int,input().split()))

cmat=[[-1]*W for _ in range(H)]

x,y=0,0
c=1
for a in alist:
  while a:
    #print(x,y)
    cmat[x][y]=c
    y+=1
    a-=1
    
    if y==W:
      x+=1
      y=0
  c+=1
      
#print(cmat)
for i in range(H):
  if i%2==1:
    cmat[i].reverse()
  print(*cmat[i])

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a[3];
  string s;
  rep(i,0,3) cin >> a[i];
  sort(a, a+3);
  co(a[2]-a[0]);
  return 0;
}


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

int main(){
    int N,a=0,b=0,r=0; cin >> N; 
    vector<int> one_case;
    int P[N],Q[N];
    
    for(int i=0;i<N;i++) cin >> P[i];
    for(int i=0;i<N;i++) cin >> Q[i];
    for (int i=1;i<=N;i++) one_case.emplace_back(i);
    
    do {
        int num_a=0,num_b=0,index=0;
        for (auto num : one_case) {
            if(num == P[index]) num_a++;
            if(num == Q[index]) num_b++;
            index++;
        }
        
        if(num_a == N) a = r;
        if(num_b == N) b = r;
        r++;
    } while (next_permutation(one_case.begin(), one_case.end()));
    
    cout << abs(a-b) << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int n, a[234321], b[234321], f;
signed main() {
	cin >> n;
	for1(i, n) {
		cin >> a[i];
		f += b[a[i]]++;
	}
	for1(i, n) cout << f - b[a[i]] + 1 << endl;
}

Measured memory_bytes: 4736
#include<stdio.h>

int F(int);
int Fib[45];
int main()
{
  int n,i;
  for(i=0;i<45;i++)Fib[i]=0;
  scanf("%d",&n);
  printf("%d\n",F(n));
  return 0;
}

int F(int n)
{
  if(n==0||n==1)return Fib[n]=1;
  if(Fib[n]!=0)return Fib[n];
  return Fib[n]=F(n-1)+F(n-2);
}
  

Measured memory_bytes: 596
input = gets(nil).chomp

input.split("\n").each do |line|
  w = line.to_f
  case
  when w <= 48
    puts "light fly"
  when w > 48 && w <= 51
    puts "fly"
  when w > 51 && w <= 54
    puts "bantam"
  when w > 54 && w <= 57
    puts "feather"
  when w > 57 && w <= 60
    puts "light"
  when w > 60 && w <= 64
    puts "light welter"
  when w > 64 && w <= 69
    puts "welter"
  when w > 69 && w <= 75
    puts "light middle"
  when w > 75 && w <= 81
    puts "middle"
  when w > 81 && w <= 91
    puts "light heavy"
  when w > 91
    puts "heavy"
  end
end

Measured memory_bytes: 6128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n;
    cin>>n;
    cout<<n*n*n<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

template <class T>
class CuSum {
private:
	vector<T> cusum;

public:
	CuSum(vector<T> const& vec) : cusum(vec.size() + 1) {
		for (int i = 0; i < (int)vec.size(); i++) cusum[i + 1] = cusum[i] + vec[i];
	}
	CuSum(const int N) : cusum(N + 1) {}
	void add(const int i, const T& x) { cusum[i + 1] += x; }
	void build() { for (int i = 0; i < (int)cusum.size() - 1; i++) cusum[i + 1] += cusum[i]; }

	// partial sum of 0-indexed [l, r)
	T operator()(int l, int r) {
		if (r < l || r < 0) {
			assert(0);
			return T(0);
		}
		else return cusum[r] - cusum[l];
	}
	// 0-indexed
	const T& operator[](int i) { return cusum[i + 1]; }
	T back() { return cusum.back(); }
};

int main() {

	int N, Q;
	scanf("%d", &N);
	scanf("%d", &Q);

	vector<lint> A(N);
	for (int i = 0; i < N; i++) scanf("%lld", &A[i]);

	vector<lint> X(Q);
	for (int i = 0; i < Q; i++) scanf("%lld", &X[i]);

	// xが小さいとき青木君は下から、高橋君は上から取っていく
	// 青木君が先にN/2目をとれるようになるところから順番の入れ替わりが発生する
	// 入れ替わり後は交互にとることになる

	// 境界をさがしていく
	// lは最小、rはN/2をさしておく
	// (Al + Ar) / 2 < x なら Arを先にとれる可能性がある
	// r - l 番目にArをとることになるので、高橋君より早く取れるか判定
	// 早く取れるならl++, r++、そうでないなら次の境界を試したいのでl++

	int l = 0, r = N / 2;
	vector<lint> border;
	while (r != N - 1) {
		lint c = (A[l] + A[r] + 2) / 2;
		if (r - l < N - r) {
			border.emplace_back(c);
			l++, r++;
		}
		else l++;
	}
	DMP(border);

	// 境界がわかれば取り方は簡単あとは累積和と、奇数偶数番目の累積和を計算しておけば和は求まる
	vector<lint> odd((N + 1) / 2), even((N + 1) / 2);
	for (int i = 0; i < N; i+=2) {
		odd[i / 2] = A[i];
		even[i / 2] = A[i + 1];
	}
	DMP(odd, even);
	CuSum sumA(A), sumO(odd), sumE(even);

	// N/2以降のものが何個とれるかは2分探索できる
	for (int i = 0; i < Q; i++) {
		int cnt = upper_bound(border.begin(), border.end(), X[i]) - border.begin();
		DMP(cnt);
		lint ans = sumA(N / 2 + cnt, N);
		if (N & 1) ans += sumO(0, cnt);
		else ans += sumE(0, cnt);
		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 7676
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n, m;
const int maxN = 15;
int edge[maxN][maxN];
int cmp[(1 << maxN) + 2];
int dp[(1 << maxN) + 2][maxN];
inline void upd(int& a, int b) {
    a = max(a, b);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> m;
    int tot = 0;
    for (int i = 1; i <= m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        edge[a][b] = edge[b][a] = c;
        tot += c;
    }
    for (int mask = 0; mask < (1 << n); mask++) {
        for (int i = 0; i < n; i++) {
            if (!(mask & (1 << i))) continue;
            for (int j = 0; j < i; j++) {
                if (!(mask & (1 << j))) continue;
                cmp[mask] += edge[i][j];
            }
        }
    }
    for (int c = 0; c < (1 << n); c++) {
        for (int j = 0; j < n; j++) dp[c][j] = -1e9;
    }
    for (int mask = 1; mask < (1 << n); mask++) {
        if ((mask & (1 << (n - 1)))) continue;
        if (!(mask & 1)) continue;
        dp[mask][0] = cmp[mask];
    }
    int all = ((1 << n) - 1);
    for (int mask = 0; mask < (1 << n); mask++) {
        for (int lst = 0; lst < n; lst++) {
            if (dp[mask][lst] < 0) continue;
            int pp = all ^ mask;
            for (int sb = pp; sb > 0; sb = pp & (sb - 1)) {
                for (int j = 0; j < n; j++) {
                    if ((sb & (1 << j)) && edge[j][lst]) {
                        upd(dp[mask | sb][j], dp[mask][lst] + cmp[sb] + edge[lst][j]);
                    }
                }
            }
        }
    }
    cout << -dp[(1 << n) - 1][n - 1] + tot;
    return 0;
}

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

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
    return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
    os<<'[';
    rep(i,a.size()) os<<(i?" ":"")<<a[i];
    return os<<']';
}

typedef pair<int, pii> State;

int H, W, N;
char m[1010][1010];

int bfs(pii s, int dest, pii &ns) {
	queue<pair<int, pii> > q;
	q.push(mp(0, s));
	map<pii, bool> visited;
	
	while(!q.empty()) {
		pair<int, pii> p = q.front();
		q.pop();
		if (visited[p.snd]) continue;
		visited[p.snd] = true;
		
		if (m[p.snd.snd][p.snd.fst] == dest + '0') {
			ns = p.snd;
			return p.fst;
		}
		
		static const int dx[] = {1, 0, -1, 0};
		static const int dy[] = {0, 1, 0, -1};
		rep(d, 4) {
			int tx = p.snd.fst + dx[d];
			int ty = p.snd.snd + dy[d];
			if (tx < 0 || tx >= W || ty < 0 || ty >= H) continue;
			if (m[ty][tx] == 'X') continue;
			q.push(mp(p.fst + 1, mp(tx, ty)));
		}
	}
}

int main() {
	cin >> H >> W >> N;
	pii s;
	rep(i, H) rep(j, W) {
		cin >> m[i][j];
		if (m[i][j] == 'S') {
			s.fst = j;
			s.snd = i;
		}
	}
	
	int ans = 0;
	rep(i, N) ans += bfs(s, i + 1, s);
	
	cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 30000
def main():
    A, B = map(int, input().split())
    S = input()
    for i in range(A+B+1):
        if i == A and S[i] != "-":
            return "No"
        if i != A and S[i] == "-":
            return "No"
    return "Yes"

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#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 SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A,B,T;
	cin >> A >> B >> T;

	cout << B * (T / A) << endl;
	return 0;
}



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

#define rep(i,n) for(int i=0; i<(n); i++)
#define repi(i,a,b) for(int i = (a); i<= (b); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9+7);//998244353;
const int N = (int)(2e6+5);

void pre() {

}

void solve() {
  int n,m,k;  cin>>n>>m>>k;
  vector<ll> a(n),b(m),pa(n+1),pb(m+1);
  rep(i,n)  cin>>a[i];
  rep(i,m)  cin>>b[i];

  pa[0] = pb[0] = 0;

  rep(i,n)  pa[i+1] = a[i]+pa[i];
  rep(i,m)  pb[i+1] = b[i]+pb[i];

  //for(int i:pa) cout<<i<<' '; cout<<'\n';


  int ans = 0;

  rep(i,n+1) {
    if(pa[i] > k)  break;
    //cout<<a[i]<<' '<<k-pa[i]<<' ';
    int j = (upper_bound(all(pb),k-pa[i]) - 1 - pb.begin());
    //cout<<i<<' '<<j<<'\n';
    ans = max(i+j,ans);
  }
  cout<<ans;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  #endif
  int t = 1;
  pre();
  //cin>>t;
  rep(i,t)  {
    //cout<<"\nCase #"<<(i+1)<<"\n";
    solve();
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 9504
// Marcin Knapik
// before you read it
// make sure it's a good idea
#include<bits/stdc++.h>
using namespace std;

typedef long long         ll;
typedef unsigned long long      ull;
typedef pair< ll, ll >        pll;
typedef pair< int, int  >       ii;
typedef vector< int  >       vi;
typedef vector< ii >        vii;
typedef vector< vi >        vvi;
typedef vector< vector < ii > >   vvii;
typedef vector< ll >        vll;
typedef vector< pll >       vpll;
typedef long double         ld;

#define boost   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define szy     first
#define gi      second
#define sz(a)   (int)(a).size()
#define pb      push_back
#define all(c)    (c).begin(), (c).end()
#define rall(c)   (c).rbegin(), (c).rend()


template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template<class T> inline T sub(T a, T b, T mod) {return ((a - b)+mod)%mod;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }

ld e = 2.7182818284590452353602874713526624;
ld PI = acos(-1);
ld eps = 1e-11;

const ll T = 1 << 19;
const ll INF = 1e9 + 7;
const ll BIG_INF = 1e18 + 5;
const long long  N = 1e6 + 7;
const ll M = 2007;
ll n, m, k;
int s,t;

vi stopnie;

ll dp[100000][107];

int main(){
	boost;

	cin >> n >> k;
	vll tab;
	for(int i = 2 ; i * i <= n ; i++){
		tab.pb(n/i+1);
	}
	for(int i = sqrt(n)+1 ; i >= 1 ; i--){
		tab.pb(i);
	}
	sort(all(tab));
	tab.erase(unique(all(tab)), tab.end());
	tab.pb(n+1);

	// cout << tab << endl;
	for(int i = 0 ; i < sz(tab)-1 ; i++){
		dp[i][1] = tab[i+1] - tab[i];
	}

	for(int i = 2; i <= k; i++){
		int id = 0;
		ll temp = 0;
		for( int j = sz(tab) - 2; j >= 0; j--){
			while(id < sz(tab)-1 && (tab[id + 1] - 1 ) * tab[j] <= n){
				temp = (temp + dp[id++][i-1])%INF;
			}
			dp[j][i] = (temp * (tab[j+1] - tab[j]))%INF;
		}
	}	
	ll wynik = 0;
	for(int i = 0 ; i <sz(tab); i++){
		wynik = (wynik + dp[i][k])%INF;
	}
	cout << wynik << '\n';
}		

Measured memory_bytes: 54136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  int ans=0;
  int cnt=0;
  rep(i,n){
    if(a[i]%2==0){
      cnt++;
    }
  }
  cout<<pow(3,n)-pow(2,cnt)<<endl;
}

Measured memory_bytes: 4132
import scala.io.StdIn.readLine

object Main {
  def sort(a:Array[Int],k:Int) = {
    val count = new Array[Int](k+1)
    val buf = new Array[Int](a.length)
    a.map( x=> count(x) += 1 )
    for(i<-1 to k) count(i) += count(i-1)
    for(i<-0 until a.length) {
      val j = a.length-1-i
      buf(count(a(j))-1) = a(j)
      count(a(j)) = count(a(j))-1
    }
    buf
  }

  def main(args:Array[String]) = {
    readLine
    val a = readLine.split(" ").map(_.toInt)
    val result = sort(a,10000)
    println(result.mkString(" "))
  }
}

Measured memory_bytes: 473588
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int count = 0;
        for(int i =0; i < n; i++) {
            int minj = i;
            for(int j = i; j < n; j++) {
                if(a[j] < a[minj]) {
                    minj = j;
                }
            }
            if (i != minj) {
                int tmp = a[i];
                a[i] = a[minj];
                a[minj] = tmp;
                count += 1;
            }
        }
        System.out.printf("%d", a[0]);
        for(int i = 1; i < n; i ++) {
            System.out.printf(" %d", a[i]);
        }
        System.out.printf("\n");
        System.out.println(count);
    }
}


Measured memory_bytes: 26776
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;

int ctoi(char c) {
    switch (c) {
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default: return 0;
    }
}


int main(int argc, const char * argv[]) {

    int k, a, b, c;
    string ans;
    
    cin >> k;
    cin >> a >> b;
    
    c = a / k;
    
    while(1)
    {
        if (c * k >= a && c * k <= b)
        {
            ans = "OK";
            break;
        } else if (c * k <= b)
        {
            c++;
        } else if (c * k > b) {
            ans = "NG";
            break;
        }
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3596
<?php
$s = trim(fgets(STDIN));
$n = strlen($s);
$i = $n - 1;
$ans = 1;
while($i > 0){
if($s[$i] == "Z"){
$ans += $i;
$i = 1;
}
--$i;
}

while($i < $n){
if($s[$i] == "A"){
$ans -= $i;
$i = $n;
}
++$i;
}
echo $ans;
?>

Measured memory_bytes: 3960
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main( void )
{
	map < string, int > T;
	int n;
	while ( cin >> n && n != 0 )
	{
		for ( int i = 0; i < n; i++ )
		{
			string item;
			int value;
			cin >> item >> value;

			T[item] = value;
		}

		int m;
		cin >> m;
		for ( int i = 0; i < m; i++ )
		{
			string item;
			int k;
			cin >> item >> k;

			int sum = 0;
			for ( int j = 0; j < k; j++ )
			{
				string additem;
				cin >> additem;
				sum += T[additem];
			}

			T[item] = min( T[item], sum );
		}

		string getitem;
		cin >> getitem;

		cout << T[getitem] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int nax = 2 *101010;
int s[nax], a[nax];

int main() {
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	// vi a(n + 1), s(n + 1);
	FOR(i, 1, n) {
		cin >> a[i];
		s[i] = a[i] + s[i-1];
	}
	int najw = -1;
	FOR(i, k, n) {
		int ta = s[i] - s[i - k];
		if (najw == -1 || ta > najw) {
			najw = ta;
		}
	}
	double res = najw;
	printf("%.1lf\n", (res + k) / 2);
	// cout << (res + k) / 2 << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
	int N;
	int K;
	int i,count=0;
	scanf("%d %d",&N, &K);
	int h[N];
	for(i=0;i<N;i++){
		scanf("%d",&h[i]);
	}
	for(i=0;i<N;i++){
		if(h[i]>=K){
			count=count+1;
		}
	}
	printf("%d",count);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N, K;
  cin >> N >> K;
  cout << N % K << endl;
  return 0;
}

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

using namespace std;
int T[100];
int fibo(int n) {
    if(T[n] != 0) return T[n];
    T[n] = fibo(n-1) + fibo(n-2);
    return T[n];
}
int main() {
    T[0] = T[1] = 1;
    int n;
    cin >> n;
    cout << fibo(n) << endl;
}



Measured memory_bytes: 3100
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll N;
	ll A[100001],sum=0;
	scan(N);
	rep(i,N){
		scan(A[i]);
		sum+=A[i];
	}
	ll kaisu;
	if(sum%(N*(N+1)/2)!=0){
		prin("NO"); return 0;
	}
	else{
		kaisu=sum/(N*(N+1)/2);
	}
	int flag=1;
	ll dansanum=0;
	rep(i,N){
		if((kaisu-(A[(i+1)%N]-A[i]))>=0&&(kaisu-(A[(i+1)%N]-A[i]))%N==0){
			dansanum+=(kaisu-(A[(i+1)%N]-A[i]))/N;
		}
		else{
			flag=0;
			break;
		}
	}
	if(flag&&dansanum==kaisu){
		prin("YES");
	}
	else prin("NO");
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
const ll MOD = 1000000007;

int main() {
    ll n,k;
    cin >> n >> k;
    vector<pair<ll,ll>> p(n);
    rep(i,n) {
        cin >> p.at(i).first >> p.at(i).second;
    }
    VSort(p)
    ll sum = 0;
    rep(i,n) {
        sum += p.at(i).second;
        if (sum >= k) {
            cout << p.at(i).first;
            return 0;
        }
    }
}

Measured memory_bytes: 1792
<?php
fscanf(STDIN, '%s', $today_wether);
$wether_list = ['Sunny', 'Cloudy', 'Rainy'];

$today_whether_key = array_search($today_wether, $wether_list);
$next_wether = $today_whether_key + 1;
if ($next_wether <= 2) {
  echo $wether_list[$next_wether];
} else {
  echo $wether_list[0];
}


Measured memory_bytes: 4856
while (line = gets)
  rs = line.chomp.split(" ").map{|s| s.to_f}

  bl = rs.shift
  m = rs.length
  rs.sort!

  r0 = r1 = rs.shift
  nums = [r0]

  while ! rs.empty?
    rlen = rs.length
    max_diff0 = max_diff1 = 0.0
    max_i0 = max_i1 = 0

    for i in (0...rlen)
      diff0 = (r0 - rs[i]).abs
      if max_diff0 < diff0
        max_diff0 = diff0
        max_i0 = i
      end

      diff1 = (r1 - rs[i]).abs
      if max_diff1 < diff1
        max_diff1 = diff1
        max_i1 = i
      end
    end

    if max_diff0 > max_diff1 ||
        max_diff0 == max_diff1 && r0 + rs[max_i0] <= r1 + rs[max_i1]
      r0 = rs.delete_at(max_i0)
      nums.unshift r0
    else
      r1 = rs.delete_at(max_i1)
      nums.push r1
    end
  end

  l = nums[0] + nums[m - 1]
  for i in (1...m)
    rp = nums[i - 1] + nums[i]
    rm = nums[i - 1] - nums[i]
    l += Math.sqrt(rp * rp - rm * rm)
  end

  puts (bl >= l) ? "OK" : "NA"
end

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

int main(){
    int n;
    cin >> n;
    vector<long> a(n);
    for(int i = 0;i < n;i++){
      cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    long ans;
    ans = a.back() - a.at(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys,itertools
input = sys.stdin.readline

def search(t, S):
    for s in S:
        if s == t:
            return 1
    return 0

N = int(input())
S = list(map(int,input().split()))
Q = int(input())
T = list(map(int,input().split()))

cnt = 0
for t in T:
    cnt += search(t, S)

print(cnt)




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

int main() {
  int tmp0 = 0, tmp1 = 0, tmp3 = 0, tmp4 = 0, tmp5 =0;
  char tmp2 = '\0';
  string str = "";
  cin >> str;
  while (str[tmp0]!='\0') {
    if (str[tmp0]=='N') {
      if (!tmp1)tmp1++;
    } else if (str[tmp0]=='S') {
      if (!tmp3)tmp3++;
    } else if (str[tmp0]=='W') {
      if (!tmp4)tmp4++;
    } else if (str[tmp0]=='E') {
      if (!tmp5)tmp5++;
    }
    tmp0++;
  }
  if ((tmp1+tmp3+tmp4+tmp5)>=4) {
    puts("Yes");
  } else if ((tmp1+tmp3)>=2&&!(tmp4-tmp5)) {
    puts("Yes");
  } else if (tmp4+tmp5>=2&&!(tmp1-tmp3)) {
    puts("Yes");
  } else puts("No");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a;
int l,p;
int main()
{
	cin>>a;
	l=a.length();
	 for(register int i=0;i<l;i++)
    {
        if(a[i]=='C')
        {
            for(register int j=i+1;j<l;j++)
            {
                if(a[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
 } 

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

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


Measured memory_bytes: 3588
#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;
	cin >> n;
 
	map<string, vector<int>>mp;
	map<pair<string,int>, int>mp1;
	rep(i, 0, n) {
		string temp;
		cin >> temp;
		int t;
		cin >> t;
		mp[temp].pb(t);
		mp1[{temp,t}] = i;
	}
 
	fore(x, mp) {
		vector<int>temp = x.second;
		sort(all(temp));
		reverse(all(temp));
		rep(i, 0, temp.size()) {
			cout << mp1[{x.first, temp[i]}] + 1 << endl;
		}
	}
 
 
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long A = in.nextLong();
            long B = in.nextLong();
            long max = gcd(A, B);
            Set<Long> list = new HashSet<>();
            for (long i = 2; i * i <= max; i++) {
                if (max % i == 0) {
                    list.add(i);
                    while (max % i == 0) {
                        max /= i;
                    }
                }
            }
            if (max > 1) {
                list.add(max);
            }
            out.println(list.size() + 1);
        }

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

    }
}



Measured memory_bytes: 22860
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int, int>;
using vpi = vector<pi>;
const int maxn = 1<<19, mod = 998244353;
int n;
pi a[maxn];
pi merge(pi a, pi b) {
	if(b.first>a.first) swap(a, b);
	if(b.first>a.second) a.second = b.first;
	return a;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 0; i < 1<<n; i++) cin >> a[i].first;
	for(int j = 0; j < n; j++)
	for(int i = 0; i < 1<<n; i++)
		if(i&(1<<j))
			a[i] = merge(a[i], a[i^(1<<j)]);
	int lst = 0;
	for(int i = 1; i < 1 << n; i++) {
		lst = max(lst, a[i].first + a[i].second);
		cout << lst << "\n";
	}
}


Measured memory_bytes: 7168
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int a[100005], cnt = 0, vis[100005],n,k;

int main(){
	scanf("%d",&n);
	for(int i = 1; i <= n; i++)
		scanf("%d",&a[i]);
	k = 1;
	while(true){
		if(vis[k] == 1 || vis[2] == 1) break;
		cnt++;
		vis[k] = 1;
		k = a[k];
	}
	if(vis[2] == 0) printf("-1\n");
	else
	printf("%d\n",cnt - 1);
	return 0;
}


Measured memory_bytes: 896
function Main(input) {
	input = input.split("\n");
	var N = input[0];
	var A = input[1].split(" ").map(a => parseInt(a));
	
	var num = 0;
	for(var i = 0; i < N; i++){
		if(A[i] & 1) num++;
	}
	var ans = (num & 1 ? "NO" : "YES");
	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 17484
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int a, p;
	cin >> a >> p;
	
	cout << ((a * 3) + p) / 2 << endl;
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256