akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  int N;  cin>>N;
  vector<int> v(N);
  rep(i,0,N)cin>>v[i];
  int cnt=0;
  rep(i,0,N){
    if((i+1)%2==1 && v[i]%2==1) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


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

int main() {
	int n, ans; bool check;
	while (cin >> n) {
		ans = 0;
		for (int i = 1; i <= n; i++) {
			if (i <= 3) { if (i != 1) ans++; continue; }
			if (i % 2 == 0 || i % 3 == 0) continue;
			if (i % 6 != 1 && i % 6 != 5) continue;
			check = true;
			for (int j = 5; pow(j, 2) <= i; j += 6) {
				if (i % j == 0 || i % (j + 2) == 0) check = false;
				if (check == false) break;
			}
			if (check == true) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3004
import numpy as np
# 整数複数個
K, N = map(int, input().split())

# 整数 N 個 (改行区切り)
A = list(map(int, input().split()))


lengths = np.concatenate([[A[0] + (K - A[-1])], np.diff(A)],0)
print(K - lengths[np.argmax(lengths)])


Measured memory_bytes: 42916
#include<bits/stdc++.h>
#define il inline
#define rg register
using namespace std;
typedef long long ll;
const int O=510;
const ll mod=1e9+7;
il int gi(){
	int o=0,fl=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')fl=-1,ch=getchar();
	while(isdigit(ch))o=o*10+ch-'0',ch=getchar();
	return fl*o;
}
int n,c,a[O],b[O];
ll f[O][O],bin[O][O];
int main(){
	for(int i=1;i<O;++i)bin[i][0]=1;
	for(int i=1;i<O;++i)
		for(int j=1;j<O;++j)
			bin[i][j]=bin[i][j-1]*i%mod;
	for(int i=1;i<O;++i)
		for(int j=0;j<O;++j)
			bin[i][j]=(bin[i-1][j]+bin[i][j])%mod;
	n=gi();c=gi();
	for(int i=1;i<=n;++i)a[i]=gi();
	for(int i=1;i<=n;++i)b[i]=gi();
	f[0][0]=1;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=c;++j)
			for(int k=0;k<=j;++k)
				(f[i][j]+=f[i-1][j-k]*((bin[b[i]][k]-bin[a[i]-1][k])%mod+mod)%mod)%=mod;
	printf("%lld\n",f[n][c]);
	return 0;
}


Measured memory_bytes: 3840
#include <stdio.h>
#include <string.h>

int
main(void)
{
	char line[80];

	int w;

	int f[10];
	int u[10];

	int k = 512;
	for (int& d : f) {
		d = k;
		k >>= 1;
	}

	while (true) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			break;
		}
		if (sscanf(line, "%d", &w) != 1) {
			break;
		}

		int p;
		for (p = 0; p < 10; p++) {
			if (w >= f[p]) {
				break;
			}
		}

		memset(u, 0, sizeof u);

		int t = f[p];
		u[p] = 1;
		p++;

		while (true) {
			if (t == w) {
				break;
			} else if (t > w) {
				t -= f[p-1];
				u[p-1] = 0;
			}

			t += f[p];
			u[p] = 1;
			p++;
		}

		const char* sp = "";
		for (int i = 9; i >= 0; i--) {
			if (u[i]) {
				printf("%s%d", sp, f[i]);
				if (*sp == 0) {
					sp = " ";
				}
			}
		}
		printf("\n");

	}

	return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>

#define MAX_MATATABI 100
#define MAX_XY 15 + 1

typedef struct tagSpan{
	int stx;
	int sty;
	int edx;
	int edy;
} Span;

int main(void)
{
	int tc,max;
	scanf("%d", &max);
	for(tc=0;tc<max;++tc){
		int i;
		int p;
		Span spans[MAX_MATATABI];
		int ways[MAX_XY][MAX_XY] = {{0,},};
		int gx;
		int gy;
		
		scanf("%d%d", &gx, &gy);
		scanf("%d", &p);

		for(i = 0; i < p; i++){
			int x1, y1, x2, y2;
			scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
			
			if(x1 == x2){
				spans[i].stx = x1;
				spans[i].edx = x1;
				spans[i].sty = y1 < y2 ? y1 : y2;
				spans[i].edy = y1 > y2 ? y1 : y2;
			}else if(y1 == y2){
				spans[i].stx = x1 < x2 ? x1 : x2;
				spans[i].edx = x1 > x2 ? x1 : x2;
				spans[i].sty = y1;
				spans[i].edy = y1;
			}
		}

		for(i = 0; i <= gx; i++){
			int j;
			for(j = 0; j <= gy; j++){
				int m;
				int waysL, waysD;

				if(i == 0 && j == 0){
					ways[i][j] = 1;
					continue;
				}
				
				waysL = i - 1 < 0 ? 0 : ways[i - 1][j];
				waysD = j - 1 < 0 ? 0 : ways[i][j - 1];

				for(m = 0; m < p; m++){
					if(i - 1 == spans[m].stx && j == spans[m].sty && i == spans[m].edx){
						waysL = 0;
					}
					if(i == spans[m].stx && j - 1 == spans[m].sty && j == spans[m].edy){
						waysD = 0;
					}
				}

				ways[i][j] = waysL + waysD;
			}
		}

		if( ways[gx][gy] == 0){
			printf("Miserable Hokusai!\n");
		}else{
			printf("%d\n", ways[gx][gy]);
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        String str1 = sc.next();
        sc.nextLine();
        String str2 = sc.next();
        sc.nextLine();
        
        str1 += str1;
        int res = str1.indexOf(str2);
        if (res!=-1){
            System.out.println("Yes");  
        }else{
            System.out.println("No");   
        }
    }
}


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


int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  int max = -100;
  int sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    if(max < A[i]) { max = A[i]; }
  }

  for(int i = 0; i < N; i++) {
    if(max == A[i]) sum++;
  }
  int max2 = -100;
  for(int i = 0; i < N; i++) {
    if(A[i] < max && max2 < A[i]) max2 = A[i];
  }

  for(int i = 0; i < N; i++) {
    if(max == A[i] && sum == 1) {cout << max2 << endl; }
    else if(max == A[i] && sum > 1) { cout << max << endl; }
    else cout << max << endl;
  }



  return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int e,f;
	e = min(a,b);
	f = min(c,d);
	cout << e+f << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static int waruketa = 1;
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		int N = scn.nextInt();
		for (int i = 0; i < N; i++) {
			list.add(scn.nextInt());
		}

		for (int i = 0; i < list.size(); i++) {
			int x = list.get(i);
			for (int j = 0; j < i-1;) {
				if (x == list.get(j)) {
					list.remove(j);
					continue;
				}
				j++;
			}
			for (int j = i+1; j < list.size();) {
				if (x == list.get(j)) {
					list.remove(j);
					continue;
				}
				 j++;
			}
		}
		System.out.println(list.size());
	}
}


Measured memory_bytes: 21076
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
	int n;
	int aa = 1;
	int dx[] = {-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, /*0,*/ 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1};
	int dy[] = {-1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, /*0,*/ 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1};
	int dz[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, /*0,*/ 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1};
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		if (aa != 1) {
			cout << endl;
		}
		int d[5][5][5];
		string s;
		for (int i = 0; i < 5; i++) {
			for (int j = 0; j < 5; j++) {
				cin >> s;
				for (int k = 0; k < 5; k++) {
					d[k][j][i] = s[k]-'0';
				}
			}
		}
		/*for (int i = 0; i < 5; i++) {
			if (i != 0) {
				cout << endl;
			} else {
				printf("Case %d:\n", aa);
			}
			for (int j = 0; j < 5; j++) {
				for (int k = 0; k < 5; k++) {
					cout << d[k][j][i];
				}
				cout << endl;
			}
		}
		/*cout << 'a' << endl;*/
		int m1, m2;
		cin >> m1;
		vector<int> a(m1);
		for (int i = 0; i < m1; i++) {
			cin >> a[i];
		}
		//cout << m1 << endl;
		cin >> m2;
		vector<int> b(m2);
		for (int i = 0; i < m2; i++) {
			cin >> b[i];
		}
		//cout << m2 << endl;
		for (int i = 0; i < n; i++) {
			int d2[5][5][5];
			for (int x = 0; x < 5; x++) {
				for (int y = 0; y < 5; y++) {
					for (int z = 0; z < 5; z++) {
						int ccc = 0;
						for (int j = 0; j < 26; j++) {
							if (0 <= x+dx[j] && x+dx[j] < 5 && 0 <= y+dy[j] && y+dy[j] < 5 && 0 <= z+dz[j] && z+dz[j] < 5) {
								ccc +=d[x+dx[j]][y+dy[j]][z+dz[j]];
							}
						}
						d2[x][y][z] = 0;
						if (d[x][y][z] == 0) {
							for (int j = 0; j < m1; j++) {
								if (ccc == a[j]) {
									d2[x][y][z] = 1;
									break;
								}
							}
						} else {
							for (int j = 0; j < m2; j++) {
								if (ccc == b[j]) {
									d2[x][y][z] = 1;
									break;
								}
							}
						}
					}
				}
			}
			for (int x = 0; x < 5; x++) {
				for (int y = 0; y < 5; y++) {
					for (int z = 0; z < 5; z++) {
						d[x][y][z] = d2[x][y][z];
					}
				}
			}
		}
		for (int i = 0; i < 5; i++) {
			if (i != 0) {
				cout << endl;
			} else {
				printf("Case %d:\n", aa);
			}
			for (int j = 0; j < 5; j++) {
				for (int k = 0; k < 5; k++) {
					cout << d[k][j][i];
				}
				cout << endl;
			}
		}
		aa++;
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    string S, T;
    cin >> S >> T;
    rep(i, S.size()) {
        bool ok = true;
        rep(j, S.size()) {
            if (S[(i + j) % S.size()] != T[j]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]

ans = 10**15
for i in range(2):
    c = 0
    S = 0
    for j in range(n):
        S += A[j]
        if i % 2 == j % 2 and S <= 0:
            c += abs(S)+1
            S = 1
        elif i % 2 != j % 2 and S >= 0:
            c += S+1
            S = -1
    ans = min(ans, c)
print(ans)


Measured memory_bytes: 14332
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  int N;
  vector<int> input;
  Tmp(int N)
  : N(N)
  , input(N)
  {}
};

void solve(void)
{
  string s; cin >> s;
  auto ans = s[2] == s[3] && s[4] == s[5];
  cout << (ans ? "Yes" : "No") << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
        string s;
        cin>>s;
        int flag = 1;
        for(int i=0;i<s.length()-1;i++)
        {
            if(s[i]==s[i+1])
            {
                cout<<i+1<<" "<<i+2<<endl;
                flag = 0;
                break;
            }
            else if((i<s.length()-2)&&(s[i]==s[i+2]))
            {
                cout<<i+1<<" "<<i+3<<endl;
                flag = 0;
                break;
            }
        }
        if(flag==1)
        {
            cout<<-1<<" "<<-1<<endl;
        }

}


Measured memory_bytes: 512
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
typedef long long int lli;
static const int MOD = 10000007;
static const int MAX = 100005;

string s;
int N;



int main(){
  cin >> N;
  int A[N],B[N],C[N-1];
  int p = 0;
  stack<int> s;
  rep(i, N) {
    cin >> A[i];
    if ( A[i] == p+1 ) {
      s.push(p);
    }
    p = A[i];
  }
  int sum = 0, ans = 0;
  rep(i, N) {
    cin >> B[i];
    sum += B[i];
  }
  ans += sum;
  rep(i, N-1) {
    cin >> C[i];
  }
  while (!s.empty()) {
    int l = s.top(); s.pop();
    ans += C[l-1];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<algorithm>
#include<map>

using namespace std;

long long exp10(int x) {
	long long result = 1;
	for (int i = 0; i < x; i++) {
		result *= 10;
	}
	return result;
}

int solve(long long s) {
	if (s <= exp10(9)) {
		printf("0 0 0 %lld %lld 0\n", s, 1LL);
		return 0;
	}
	int e = 10;
	while (s > exp10(e)) {
		e += 1;
	}
	if (s == exp10(e)) {
		printf("0 0 0 %lld %lld 0\n", exp10(9), exp10(e - 9));
		return 0;
	}
	// exp10(e - 1) < s < exp10(e)
	long long z = exp10(e) - s; // s = exp10(e) - z
	// Search x < 10^(e-9), (x * 10^9 - z) > 0
	long long left = 0;
	long long right = exp10(e - 9) - 1;
	while (right - left > 1) {
		long long mid = (left + right) / 2;
		if (mid * exp10(9) - z > 0) {
			right = mid;
		}
		else {
			left = mid;
		}
	}
	long long x = right;
	long long a = exp10(e - 9) - x;
	long long d = exp10(9);
	long long b = x * exp10(9) - z;
	long long c = 1;
	if (a < 0
		|| a > exp10(9)
		|| b < 0
		|| b > exp10(9)
		|| a + c < 0
		|| a + c > exp10(9)
		|| d < 0
		|| d > exp10(9)
		|| a * d + b * c != s) {
		printf("a, %lld b %lld c %lld d %lld s %lld", a, b, c, d, a * d + b * c);
		return 1;
	}
	printf("%lld 0 0 %lld %lld %lld\n", a, b, a + c, d);
	return 0;
}

void test() {
	for (int i = 1; i <= 18; i++) {
		long long max = exp10(i);
		for (int j = 0; j < 100; j++) {
			long long s = max - j;
			if (solve(s) != 0) {
				printf("fail: %lld\n", s);
			}
		}
	}
}

int main() {
	long long s;
	scanf("%lld", &s);
	return solve(s);
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int[][] A;
        A = new int[H][W];
        for(int i=0; i<H; i++){
            char[] JOI = sc.next().toCharArray();
            int time = -1;
            for(int j=0; j<W; j++){
                if(JOI[j] == 'c') time = 0;
                A[i][j] = time;
                if(time>-1) time++;
            }
        }
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                System.out.print(A[i][j]);
                if(j<W-1) System.out.print(" ");
                else System.out.println();
            }
        }
    }
 
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll a[maxn];
int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k)){
        ll sum=0;
        for(int i=1;i<=n;i++){
            scanf("%lld",&a[i]);
        }
        sort(a+1,a+n+1);
        n-=k;
        for(int i=1;i<=n;i++)
            sum+=a[i];
        printf("%lld\n",sum);
    }
    return 0;
}


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

bool isPrime(int n){
    
    if (n == 2) {
        return true;
    }
    
    if (n < 2 or n % 2 == 0) {
        return false;
    }
    
    for (int i = 3; i <= sqrt((double)n); i+=2) {
        if(n % i == 0) return false;
    }
    
    return true;
}

int main(void){
    int x;
    cin >> x;
    
    while(isPrime(x)==false){
        x++;
    }
    std::cout << x << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,w=n1()
WV=n3(n)

W=[0]
W.extend([x[0] for x in WV])
V=[0]
V.extend([x[1] for x in WV])

dp=[[0]*(w+1) for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(1,w+1):
        if j-W[i]>=0:
            dp[i][j]=max(dp[i-1][j-W[i]]+V[i],dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
print(dp[-1][-1])

Measured memory_bytes: 120044
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long int
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
}
void printMp(mp m)
{
  mp ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printUmp(ump m)
{
  ump ::iterator it;
  for(it=m.begin();it!=m.end();it++)cout<<it->first<<' '<<it->second<<endl;
}
void printSt(st s)
{
  st ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printMst(mst s)
{
  mst ::iterator it;
  for(it=s.begin();it!=s.end();it++)cout<<*it<<' ';
}
void printVec(vector<int>v)
{
for(int i=0;i<v.size();i++)cout<<v[i]<<' ';
}
void printVec2(vector<int>v[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
}
 set<pair<int,int>> primeset;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primeset.insert(mkp(p,1));
}
int32_t main()
{
fastio;
int a;in a;int b;in b;
cout<<max(a+b,max(a-b,a*b));

    return 0;
}


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

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

int main() {
	string S;
	cin >> S;
	if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  string s;cin>>s;
  int nr=1,nl=1;
  vi ans (s.size());
  rep(i,ans.size())ans[i]=0;
  rep(i,s.size()-1){
   if(s[i]=='R'&&s[i+1]=='R'){
     nr++;
   }
   else if(s[i]=='R'&&s[i+1]=='L'){
     ans[i] += (nr-1)/2;
     ans[i+1] += nr/2;
     ans[i]++;
     ans[i+1]++;
     nr=1;
   }
  }
  for(int i=s.size()-1;i>0;i--){
   if(s[i]=='L'&&s[i-1]=='L'){
     nl++;
   }
   else if(s[i]=='L'&&s[i-1]=='R'){
     ans[i] += (nl-1)/2;
     ans[i-1] += nl/2;
     
     nl=1;
   }
  }
  rep(i,ans.size())cout<<ans[i]<<" ";
  cout<<endl;
  
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	rep(i, n) {
		cin >> c[i];
		rep(j, m) {
			cin >> a[i][j];
		}
	}
	int ans = inf;
	rep(i, (1 << n)) {
		int cnt = 0;
		vector<int> check(m);
		rep(j, n) {
			if ((i >> j) & 1) {
				cnt += c[j];
				rep(k, m) {
					check[k] += a[j][k];
				}
			}
		}
		bool flag = true;
		rep(k, m) {
			if (check[k] < x) flag = false;
		}
		if (flag) chmin(ans, cnt);
	}
	if (ans == inf) cout << -1 << '\n';
	else cout << ans << '\n';
}

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


class AtCoder:
    def main(self):
        N = int(input())
        S,T = input().split()

        ans = ''
        for i in range(N):
            ans += S[i]+T[i]

        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()

Measured memory_bytes: 38256
#include <iostream>
#include <string.h>
using namespace std;

int main() {
	char S[10000];
	int n, s;
	char z[] = "Z";
	char a[] = "A";
	cin >> n >> S;
	for (int i = 0; i < strlen(S); i++) {
		s = S[i];
		if (s + n > int(z[0])) s = int(a[0]) + (s + n - int(z[0])) - 1;
		else s += n;
		S[i] = s;
	}
	cout << S << endl;
	return 0;

}

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

using namespace std;

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

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;





int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);


	int a, b;
	cin >> a >> b;

	string A = "", B = "";

	for (int i = 0; i < a; ++i) {
		A += char('0' + b);
	}

	for (int i = 0; i < b; ++i) {
		B += char('0' + a);
	}


	cout << min(A, B) << '\n';

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
#define mod2 998244353  

int solve(){
    int n;
    cin>>n;
    int a[n],b[n];
    rep(i,0,n){
        cin>>a[i];
        if(i==0) b[i]=0;
        if(i==1) b[i]=abs(a[i]-a[i-1]);
        if(i>1) b[i]=min(abs(a[i]-a[i-1])+b[i-1],abs(a[i]-a[i-2])+b[i-2]);
    }
    cout<<b[n-1];
    
    return 0;
}   
     
signed main(){
    IOS;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
      // cout<<" * "<<t<<"\n";
    }
//    return 0;
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define MII map<int,int>
#define PB push_back
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
{
    FIO
    int n; cin>>n;
    string str; cin>>str;
    if (n&1)
    {
        cout<<"No";
        return 0;
    }
    else
    {

        int c = 1;
        for (int i = 0, j = n/2; i <= n/2 - 1; ++i, ++j)
        {
            if (str[i] != str[j])
            {
                c = 0;
                cout<<"No";
                break;
            }
        }

        if (c)
        {
            cout<<"Yes";
        }
    }
    
    
    return 0;
}

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

int main(void)
{
	int n,W;
	scanf("%d%d",&n,&W);
	vector<long long int> dp(W+1,0);
	for(int item = 0;item < n;item++)
	{
		int weight,value;
		scanf("%d%d",&weight,&value);
		
		for(int wa = W - weight ; wa >= 0 ; wa--)
		{
			dp[wa+weight] = max(dp[wa+weight],dp[wa] + value);
		}
			//cout<<dp[i]<<" ";
			//cout<<endl;
	}
	long long int ans = 0;
	for(int i=0;i<=W;i++)
	{
		ans = max(ans,dp[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int n,k ;
	cin >> n >> k ;
	cout << n-k+1 << endl ;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
  
using namespace std;
  
double EPS = 1e-7;
  
double add(double a,double b){
  if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0;
  return a+b;
}
  
struct point{
  double x,y;
  point() {}
  point(double x,double y):x(x),y(y){
  }
  point operator + (point p){
    return point(add(x,p.x),add(y,p.y));
  }
  point operator - (point p){
    return point(add(x,-p.x),add(y,-p.y));
  }
  point operator * (double d){
    return point(x*d,y*d);
  }
  point operator / (double d){
    return point(x/d,y/d);
  }
};
  
double dist(point a,point b){
    return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}

int main(void){
    int n,x,y,v;
    vector<point>P;
    vector<double>V;
     
    while(cin >> n,n){
        P.clear();
        V.clear();
         
        for(int i=0;i<n;i++){
            cin >> x >> y >> v;
            P.push_back(point(x,y));
            V.push_back(v);
        }
        
        double r=0.98;
        point now(0,0);
         
        for(double d=10;d>EPS;d*=r){
            int mx=0;
            double mxd=0;
             
            for(int j=0;j<P.size();j++)
                if(dist(now,P[j])/V[j]>mxd)
		  mx=j,mxd=dist(now,P[j])/V[j];
             
            now=now+((P[mx]-now)/dist(P[mx],now)*d);
        }
         
        double ans=0;
        for(int i=0;i<P.size();i++){
	  ans=max(ans,dist(now,P[i])/V[i]);
        }
        printf("%.8f\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1248
import copy
n = int(input())
a = [int(input()) for _ in range(n)]

m = max(a)
idx = a.index(max(a))

for i in range(n):
    if i == idx:
        b = copy.copy(a)
        b.pop(idx)
        print(max(b))
    else:
        print(m)

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    ll N;
    Scll(N);

    int ans = 0;
    int k = 0;
    Repe(i,1e7,2){
        k = 0;
        while( N%i == 0 ) N/=i, k++;
        int t = 1;
        while( k >= t ) k -= t++, ans++;
    }
    if( N > 1 ) ans++;

    printf ("%d\n", ans );

    return 0;
}



Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int dx[] = {0,0,-1,1};
    int dy[] = {-1,1,0,0};

    int h,w;
    cin >> h >> w;
    vector<vector<int>> d(h, vector<int>(w, -1));
    vector<pii> e;
    REP(i, h){
        REP(j, w){
            char c; cin >> c;
            if(c=='#'){
                d[i][j] = 0;
                e.pb({i,j});
            }
        }
    }
    int ans = 0;
    REP(i, e.size()){
        int x = e[i].first;
        int y = e[i].second;
        ans = max(ans, d[x][y]);
        REP(j, 4){
            int gx = x + dx[j];
            int gy = y + dy[j];
            if(gx >= 0 && gy >= 0 && gx < h && gy < w && d[gx][gy] == -1){
                d[gx][gy] = d[x][y]+1;
                e.pb({gx,gy});
            }
        }
    }
    pr(ans);
}

Measured memory_bytes: 14444
#include <iostream>
#include<map>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <vector>
#include<math.h>

using namespace std;

#define int long long


void solver() {
    
    int n;
    cin >> n;
//    int *arr=new int[2*n];
//    for(int i=0;i<2*n;i++)
//    {
//        cin>>arr[i];
//    }
    int c;
    int d;
    cin >> c >> d;
    int loc;
    while (n - 1 > 0) {
        
        
        int a, b;
        cin >> a >> b;
        int my1 = c / a;
        if (c % a != 0) {
            my1++;
        }
        int my2 = d / b;
        if (d % b != 0) {
            my2++;
        }
        loc = max(my1, my2);
        c = a * loc;
        d = b * loc;
        n--;
        
    }
    cout << c + d;
    
    
}


int32_t main() {
    int n = 1;
    // cin >> n;
    while (n--) {
        solver();
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n;

int main() {
    cin >> n;
    int cnt = 0;
    bool flg = true;
    for(int i = 0; i < n; ++i) {
        string s; cin >> s;
        if(s == "A") cnt++;
        else {
            if(cnt == 0) {
                flg = false;
            }else cnt--;
        }
    }
    if(flg) {
        if(cnt == 0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }else cout << "NO" << endl;
}


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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define for1(i, a, b) for (int i = (int)a; i < (int)(b); ++i)
#define rfor1(i, a, b) for (int i=(int)b-1;i>=(int)a;i--)
#define for2(i, a, b) for (int i = (int)a; i <= (int)(b); ++i)
#define for3(i, a, b) for (int i = (int)a; i < (int)(b); i=i+2)
#define for4(i, a, b) for (int i = (int)a; i <= (int)(b); i=i+2)
#define tc(t) int t; cin>>t; while(t--)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b <= a + c && a + b <= b + c) {
        cout << a + b << endl;
    } else if (a + b >= a + c && c + b >= a + c) {
        cout << a + c << endl;
    } else {
        cout << b + c << endl;
    }
}









Measured memory_bytes: 3600
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;

int main() {
    int N;cin>>N;
    for(int i  = 1; i <= 9; i++){
        for(int j = 1; j <=9; j++){
            if(i*j == N){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int x; cin >> x;
	if (x <= 599)cout << 8 << endl;
	else if (x <= 799)cout << 7 << endl;
	else if (x <= 999)cout << 6 << endl;
	else if (x <= 1199)cout << 5 << endl;
	else if (x <= 1399)cout << 4 << endl;
	else if (x <= 1599)cout << 3 << endl;
	else if (x <= 1799)cout << 2 << endl;
	else cout << 1 << endl;
}

Measured memory_bytes: 3616
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();
		
		System.out.println(Math.max(0, A-B*2));
		
		sc.close();
	}
}

Measured memory_bytes: 23636
import Data.List

splitBy :: Char -> String -> [String]
splitBy _ [] = []
splitBy a x =
  let s = takeWhile (/= a) x
      x'= dropWhile (/= a) x
  in
    if x' == []
    then [s]
    else s:(splitBy a $ drop 1 x')

four_card (c1:c2:c3:c4:c5:_) =
  ( c1==c2 && c2==c3 && c3==c4 ) ||
  ( c2==c3 && c3==c4 && c4==c5 )

full_house (c1:c2:c3:c4:c5:_) =
  ( ( c1==c2 ) && ( c3==c4 && c4==c5 ) ) ||
  ( ( c1==c2 && c2==c3 ) && ( c4==c5 ) )

straight c@(c1:c2:c3:c4:c5:_) =
  let r1 = take 5 [c1..]
      r2 = [1,10,11,12,13]
  in
    r1 == c || r2 == c

three_card c@(c1:c2:c3:c4:c5:_) =
  ( c1==c2 && c2==c3 ) ||
  ( c2==c3 && c3==c4 ) ||
  ( c3==c4 && c4==c5 )

two_pair c@(c1:c2:c3:c4:c5:_) =
  ( ( c1==c2 ) && ( ( c3 == c4 ) || (c4 == c5) ) ) ||
  ( ( c2==c3 ) && ( c4 == c5 ) )

one_pair c@(c1:c2:c3:c4:c5:_) =
  ( c1==c2 ) ||
  ( c2==c3 ) ||
  ( c3==c4 ) ||
  ( c4==c5 )

ans' x
  | four_card  x = "four card"
  | full_house x = "full house"
  | straight   x = "straight"
  | three_card x = "three card"
  | two_pair   x = "two pair"
  | one_pair   x = "one pair"
  | otherwise    = "null"

ans x = ans' $ sort x

main = do
  c <- getContents
  let i = map (map read) $ map (splitBy ',') $ lines c :: [[Int]]
      o = map ans i
  mapM_ putStrLn o
      

Measured memory_bytes: 4008
s = list(input())

cnt = 0
while True:
    tmp = s.pop()
    cnt += 1
    if cnt%2==0:
        for i in range(len(s)//2):
            if s[i] == s[i+len(s)//2]:
                pass
            else:
                break
        else:
            print(len(s))
            break


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int N, ans=0;

int Sosu(int x){
  switch(x){
    case 1: return 2;
    case 2: return 3;
    case 3: return 5;
    case 4: return 7;
    case 5: return 11;
    case 6: return 13;
    case 7: return 17;
    case 8: return 19;
  }
}

int Loop(int Point, int Bridge[], int Posi){
  Point/=Sosu(Posi);
  if(Point==1){
    ans++;
    return 0;
  }
  for(int i=1 ; i<N+1 ; i++)
    if((Point%Sosu(i))+(Bridge[Posi]%Sosu(i))==0){
      //cout << Posi << "->" << i << endl;
      Loop(Point, Bridge, i);
    }
  return 0;
}

int main(){
  int M;
  cin >> N >> M;
  int Point=1, Bridge[N+1];
  for(int i=1 ; i<N+1 ; i++){
    Point*=Sosu(i);
    Bridge[i]=1;
  }
  
  for(int i=0 ; i<M ; i++){
    int A, B;
    cin >> A >> B;
    Bridge[A]*=Sosu(B);
    Bridge[B]*=Sosu(A);
  }
  
  int Posi=1;
  Loop(Point, Bridge, Posi);
  cout << ans << endl;
}

Measured memory_bytes: 256
/*---- enazuma11-------  */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define F first
#define S second
#define M 1000000007
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	int l=s.size();
	ll c=0;
	int i=0;
	int cb=0;
	while(i<l){
	if(s[i]=='B')
	cb++;
	else if(s[i]=='W')
	c+=cb;
	i++;
	}
	cout<<c;
	
	return 0;
}

Measured memory_bytes: 720