akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;

int main() {
int a,b,c,k,sum=0;
cin>>a>>b>>c>>k;
if(k<=a){
    cout<<k<<endl;
}
else if(k<=a+b){
    cout<<a<<endl;
}
else
cout<<a-(k-a-b);


return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

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

		int n = in.nextInt();
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int d = in.nextInt();

		String s = in.next();

		// 両端は要らない
		int r = c > d ? c : d;
		s = s.substring(a - 1, r);

		// 岩2連続以上→不可能
		if ( s.contains("##") ) {
			System.out.println("No");
		} else {

			// 追い越しの必要がない場合 abcd  or acbd
			if ( (b < c && c < d) || c < b ) {
				System.out.println("Yes");
			} else
			// 追い越しの必要がある場合 abdc
			if ( d < c ) {
				// 追い越し場所ない場合
				if ( !s.contains("...") ) {
					System.out.println("No");
				} else {

					if ( s.substring(b - 2, d + 1).contains("...") ) {
						System.out.println("Yes");
					} else {
						System.out.println("No");
					}

				}
			}
		}
		in.close();
	}
}


Measured memory_bytes: 27908
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;

  unordered_set<int> divisors(int n)
  {
  	unordered_set<int> ans;

  	for(int i = 1; i*i <= n; i++)
  	{
  		if(n%i == 0)ans.insert(i),ans.insert(n/i);
  	}
  	ans.erase(1);
  	return ans;
  }
int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS



    int n;
    cin >> n;

    vector<int> v(n);

    for(int i = 0; i < n; i++)
    {
    	cin >> v[i];
    }

    unordered_set<int> s;

    bool ok = true;

    for(int i = 0; i < n; i++)
    {
    	unordered_set<int> s1 = divisors(v[i]);

    	for(auto &j : s1)
    	{
    		if(s.count(j))
    		{
    			ok = false;
    			break;
    		}
    		s.insert(j);
    	}
    	if(!ok)
    	{
    		ok = false;
    		break;
    	}
    }

    if(ok)
    {
    	cout << "pairwise coprime";
    }
    else
    {
    	int gc = v[0];

    	for(int i = 1; i < n; i++)
    	{	

    		gc = __gcd(gc,v[i]);
    	}

    	

    	if(gc != 1)
    	{
    		cout << "not coprime";
    	}
    	else
    	{
    		cout << "setwise coprime";
    	}
    }


    return 0;
}


Measured memory_bytes: 11096
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 100010, P = 1000000007;

int n;
char s[N];
int cnt[26];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  scanf("%d%s", &n, s);
  for (int i = 0; i < n; ++i)
    ++cnt[s[i] - 'a'];
  int ans = 1;
  for (int i = 0; i < 26; ++i)
    ans = ans * (ll)(cnt[i] + 1) % P;
  printf("%d\n", ans - 1);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=1000000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> divisor(ll x){vector<ll> div;
	for(ll i=1;i*i<=x;i++){if(x%i==0){div.pb(i);if(i*i!=x)div.pb(x/i);}}
	sort(div.bg,div.ed);return div;}


int main(){
	ll N; cin>>N;
	ll tmp=111;
	while(tmp<N){
		tmp+=111;
	}
	cout<<tmp;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		  try(Scanner sc = new Scanner(System.in)) {
				  String str=sc.next();
				  int d=str.length();
				  int n=sc.nextInt();
				  int count=0, sum=0;
				  for(int i=0; i<n; i++) {
					  count=0;
					  String s=sc.next();
					  s+=s;
					  //System.out.println(s);
					  for(int j=0; j<s.length()-d+1; j++) {
						  String s1=s.substring(j, j+d);
						  //System.out.println(s1);
						  if(s1.equals(str)) {
							  count=1;
						  }
					  }
					  //System.out.println(count);
					  sum+=count;
				  }
				  System.out.println(sum);
		}
	}
}


Measured memory_bytes: 26220
#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<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0) :x(x%mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
};

mint dp[55][55][3000];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N, K;
	cin >> N >> K;
	dp[0][0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k <= N*N;k++) {
				dp[i + 1][j][k + 2 * j] += dp[i][j][k];
				dp[i + 1][j + 1][k + 2 * (j + 1)] += dp[i][j][k];
				dp[i + 1][j][k + 2 * j] +=(mint)(2*j)*dp[i][j][k];
				if(j)dp[i + 1][j - 1][k + 2 * (j - 1)] += (mint)(j*j)*dp[i][j][k];
			}
		}
	}
	puts(dp[N][0][K].x);

	return 0;
}

Measured memory_bytes: 71168
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
K = INT()
x = list(MAP())

ans = 0
for i in range(N):
    ans = ans + 2 * min([x[i], K - x[i]])
print(ans)


Measured memory_bytes: 27296
use std::io;
use std::io::{BufReader, BufWriter, Read, Stdin, Write};
  use std::str;
  
  fn read<T: str::FromStr>() -> Vec<T> {
      let mut s = String::new();
      io::stdin().read_line(&mut s).unwrap();
      s.trim()
          .split_whitespace()
          .map(|x| T::from_str(x).ok().unwrap())
          .collect()
  }
  
  fn main() {
      let tanka = read::<u8>();
      if tanka.iter().filter(|&n| *n == 5).count() == 2
          && tanka.iter().filter(|&n| *n == 7).count() == 1
      {
          println!("YES");
      } else {
          println!("NO");
      }
  }


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

int main() {
	int N;
	double D;
	cin >> N >> D;

	double X, Y;
	int ans=0;
	rep(i, N){
		cin >> X >> Y;
		if(sqrt(X*X+Y*Y) <= D) ans++;
	}

	cout << ans << endl;

}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i, 26)cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d)rep(j, 26)cin >> s[i][j];
    //-----code------//
    rep(i, d)cout << 1 << endl;
}


Measured memory_bytes: 3680
import math
import sys
n = int(input())
a = list(map(int, input().split()))

ga = a[0]
for i in range(n):
  ga = math.gcd(ga, a[i])

if ga != 1:
  print("not coprime")
  sys.exit()

m = 1000000
b = [0]*(m+1)
#高速素因数分解
for i in range(2, m):
  if b[i] != 0:
    continue
  j = 1
  while True:
    t = i * j
    if t > m:
      break
    if b[t] == 0:
      b[t] = i
    j += 1
d = {}
for i in a:
  p = i
  #pが1になるまで重複素因子があるかを調べる
  while p != 1:
    if p in d:
      print("setwise coprime")
      sys.exit()
    d[p] = 1
    p = int(p/b[p])
#pairwise coprimeではない
print("pairwise coprime")

Measured memory_bytes: 134460
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>
using namespace std;
long long int MOD = 1000000000 + 7;
using ll = long long;
ll LARGE = 1000000;


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

	ll d = c - a - b;
	if (d < 0) {
		cout << "No" << endl;

		return 0;
	}
	if (4 * a * b < d * d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << 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 ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int mod = 1000000007;
struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a){
        if((x+=a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if(!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }

    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1){
        fact[0] = 1;
        for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for(int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;  
    }
    mint operator()(int n, int k){
        if(k < 0 || n < k) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
} comb(100005);

mint f(int n, int k){
    if(n<0) return 0;
    mint res = comb(n,k);
    res *= comb.fact[k];
    return res;
}

int k;
mint ans;
vector<int> to[100005];
void dfs(int v, int p=-1){
    for(int u : to[v]){
        if(u==p) continue;
        dfs(u,v);
    }
    int nk = (p==-1) ? k:k-2;
    //自分が根なら自分とその子、それ以外なら子の数
    int c = (p==-1) ? to[v].size()+1 : to[v].size()-1;
    ans *= f(nk,c);
}

int main(){
    int n; 
    cin >> n >> k;
    rep(i,n-1){
        int a, b; 
        cin >> a >> b;
        --a, --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans = 1;
    dfs(0);
    cout << ans.x << endl;
    return 0;

}

Measured memory_bytes: 10752
import collections
from functools import reduce
from operator import mul


def trial_division(n):
    l = []
    f = 2
    while f * f <= n:
        if n % f == 0:
            l.append(f)
            n //= f
        else:
            f += 1
    if n > 1:
        l.append(n)
    return l


def combinations_count(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    return reduce(mul, range(n, n - r, -1)) // reduce(mul, range(r, 0, -1))


N, M = map(int, input().split())

c = collections.Counter(trial_division(M))
a = 1
for i in c.values():
    a *= combinations_count(i + N - 1, i)

print(a % (10**9 + 7))

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

int main(){
	while(1){
		int n, m;
		long t[30000];
		t[0]=0;
		
		scanf(" %d %d", &n, &m);
		if(n==0 && m==0) break;
		for(int i=1; i<=n; ++i) scanf(" %ld", &t[i]);
		for(int i=n+1; i<=n+m; ++i) scanf(" %ld", &t[i]);
		sort(t, t+n+m+1);
		
		long max=0;
		for(int i=0; i<n+m; ++i){
			if(max<t[i+1]-t[i]) max=t[i+1]-t[i];	
		}
		
		printf("%ld\n", max);
	}
}

Measured memory_bytes: 1368
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = s;
        t = t.replace(t.charAt(2), t.charAt(3));
        t = t.replace(t.charAt(4), t.charAt(5));
        if(t.equals(s)){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var N = int.Parse(input[0]);
            var K = int.Parse(input[1]);

            var A = new int[N];
            var d = new int[K];
            var ans = 0;

            for (int i = 0; i < K; i++)
            {
                d[i] = int.Parse(Console.ReadLine());
                var temp = new int[1000];
                if (d[i] >= 2)
                {
                    var input2 = Console.ReadLine().Split(' ');
                    for (int j = 1; j <= d[i]; j++)
                    {
                        temp[j] = int.Parse(input2[j - 1]);
                    }
                }
                else
                {
                    temp[1] = int.Parse(Console.ReadLine());
                }

                for (int j = 1; j <= d[i]; j++)
                {
                    A[temp[j] - 1]++;
                }
            }

            for (int i = 0; i < A.Length; i++)
            {
                if (A[i] == 0)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,k;
  cin >> n >> k;
  vector<int32> a(n);
  REP(i,n)cin >> a[i];
  sort(all(a));
  int32 ans = 0;
  REP(i,k){
    ans += a[i];
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {

    int INF = Integer.MAX_VALUE;
    long MOD = 1000000007;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int c = 0;
        int ans = INF;
        for(int i = 0; i < S.length()-2;i++){
            String s = S.substring(i,i+3);
            int o = Integer.parseInt(s);
            if(Math.abs(o-753) <= ans){
                ans = Math.abs(o-753);
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const int MAX_N = 200005;
int sz, bit[MAX_N + 1];

// iが与えられた時に、a[1]+a[2]+...+a[i]を計算する
int sum(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i; // 最後の1ビット
    }
    return s;
}

// iとxが与えられた時に、a[i]にxを足す
void add(int i, int x) {
    while (i <= sz) {
        bit[i] += x;
        i += i & -i;
    }
}

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

    int n;
    ll k;
    cin >> n >> k;

    ll a[n+1];
    vector <ll> sa(n+1);
    a[0] = sa[0] = 0;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        a[i] -= k;
        a[i] += a[i-1];
        sa[i] = a[i];
    }

    sort(sa.begin(), sa.end());
    unique(sa.begin(), sa.end());

    map <ll, int> mp;
    sz = sa.size();
    for (int i = 1; i <= sz; i++) {
        if (mp[sa[i-1]] > 0) break;
        mp[sa[i-1]] = i;
    }

    for (int i = 0; i <= n; i++) {
        ans += sum(mp[a[i]]);
        add(mp[a[i]], 1);
    }

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

Measured memory_bytes: 16640
#include<cstdio>

using namespace std;

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    int ans = 1;
    for (int i = 0; i < n; i++){
        if (ans < k) ans *= 2;
        else ans += k; 
    }
    printf("%d\n", ans);
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};
const int SZ = 100000;
const int OFS = 50000;

bool ab[SZ], ac[SZ], bc[SZ];

bool match(char c1, char c2){
    return (c1 == '?' || c2 == '?' || c1 == c2);
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string a, b, c; cin >> a >> b >> c;
    int na = a.size(), nb = b.size(), nc = c.size();
    fill(ab, ab + SZ, true);
    fill(ac, ac + SZ, true);
    fill(bc, bc + SZ, true);
    for(int i=0;i<na;i++) for(int j=0;j<nb;j++) if(!match(a[i], b[j])) ab[i-j+OFS] = false;
    for(int i=0;i<na;i++) for(int j=0;j<nc;j++) if(!match(a[i], c[j])) ac[i-j+OFS] = false;
    for(int i=0;i<nb;i++) for(int j=0;j<nc;j++) if(!match(b[i], c[j])) bc[i-j+OFS] = false;

    int ans = na + nb + nc;
    for(int i=-4000;i<=4000;i++){
        for(int j=-4000;j<=4000;j++){
            if(ab[i+OFS] && ac[j+OFS] && bc[j-i+OFS]){
                int left = min(0, min(i, j));
                int right = max(na, max(nb + i, nc + j));
                ans = min(ans, right - left);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <unordered_set>
#include <vector>
#include <iostream>

using namespace std;

typedef long int ll;

bool win(ll N,unordered_set<ll>& s)
{
    vector<bool> dp(N+1);

    //false -> lose

    for (int i=1;i<=N;++i)
    {
        for (auto option: s)
        {
            if (i - option>=0 && dp[i-option] == false)
            {
                dp[i] = true;
                continue;
            }
        }
    }

    return dp[N];
}

int main()
{
    ll K,N;
    cin>>N>>K;

    unordered_set<ll> s;

    for (int i=0;i<N;++i)
    {
        ll x;
        cin>>x;
        s.insert(x);
    }

    bool w = win(K,s);

    if (w) cout<<"First"<<endl;
    else cout<<"Second"<<endl;

    return 0;
}


Measured memory_bytes: 3616
use std::io::*;
use std::str::*;
use std::cmp::*;
use std::fmt;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().unwrap_or_else(|_| panic!("Faild to parse {}", s))
}


fn main() {
    let mut q:i64 = read();
    let mut h:i64 = read();
    let mut s:i64 = read();
    let mut d:i64 = read();
    let mut n:i64 = read();

    d = min(8*q,min(4*h,min(2*s,d)));
    s = min(4*q,min(2*h,s));

    if n%2 == 1{
        println!("{}",s+(n/2)*d);
    }
    else{
        println!("{}",(n/2)*d);
    }
}



Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    int ac = a-c;
    int AC = Math.abs(ac);
    int ab = a-b;
    int AB = Math.abs(ab);
    int bc = b-c;
    int BC = Math.abs(bc);
    
    if(AC<=d){
    System.out.println("Yes");
    }else if(AB<=d && BC<=d){
    System.out.println("Yes");
    }else{
    System.out.println("No");   
        }
    }
}

Measured memory_bytes: 35796
import sys,math
from collections import deque,defaultdict
import operator as op
from functools import reduce

I=sys.stdin.readline

def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))
def mi():
	return map(int,I().strip().split())
def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom


def main():
	n,d=mi()
	cnt=0
	for _ in range(n):
		x,y=mi()
		m=math.sqrt(x**2+y**2)
		if m<=d:
			cnt+=1
	print(cnt)





		










		


		










		






if __name__ == '__main__':
	main()

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll i,j,n,m,k,cnt=0,ans=0,t=1;
    cin>>n;
    ll a[n];
    rep(i,0,n) cin>>a[i];
    ll b[n];
    rep(i,0,n) b[i]=a[i];
    sort(b,b+n);
    ll fl=0;
    rep(i,0,n){
        if(a[i]!=b[i]){
            fl=1;
            break;
        }
    }
    if(!fl) ret("YES")
    rep(i,0,n){
        rep(j,i+1,n){
            fl=0;
            swap(a[i],a[j]);
            rep(k,0,n){
                if(a[k]!=b[k]){
                    fl=1;
                    break;
                }
            }
            swap(a[i],a[j]);
            if(!fl) ret("YES")
        }
    }    
    ret("NO")
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int A,B;
  scanf("%d %d",&A,&B);
  int x,y,z;
  x=A+B;
  y=A-B;
  z=A*B;
  int m,n;

  if(x<=y){
    m=y;
  }
  else if(y<=x){
    m=x;
  }

  if(y<=z){
    n=z;
  }
  else if(z<=y){
    n=y;
  }

  if(m<=n){
    printf("%d",n);
  }
  else if(n<=m){
    printf("%d",m);
  }
  return 0;
}




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

struct Edge {int from, to, weight;};
using Graph = vector<vector<Edge>>;

int D, N;
string TEXT;
vector<string> PIECE;

set<string> OK;

string text;

int DP[45][45];

bool Levenshtein(auto p) {
  for(auto i = p; i <= text.size(); ++i) {
    auto d = D + 1;
    for(auto j = 1; j <= TEXT.size(); ++j) {
      if(text[i-1] == TEXT[j-1]) DP[i][j] = DP[i-1][j-1];
      else                       DP[i][j] = 1 + min({DP[i-1][j], DP[i][j-1], DP[i-1][j-1]});
      d = min(d, DP[i][j]);
    }
    if(D < d) return false;
  }
  return true;
}

void dfs(const auto& G, auto& used, auto cur) {
  if(TEXT.size() + D < text.size()) return;

  if(!Levenshtein(text.size() - PIECE[cur].size() + 1)) return;

  if(used.count(text)) return;
  used.emplace(text);

  if(DP[text.size()][TEXT.size()] <= D) OK.emplace(text);

  auto dup = text;
  for(auto e: G[cur]) {
    text = dup + PIECE[e.to].substr(e.weight);
    dfs(G, used, e.to);
  }
  text = dup;
}

void solve() {
  Graph G(N);
  for(auto i = 0; i < N; ++i) for(auto j = 0; j < N; ++j) {
    auto lhs = PIECE[i];
    auto rhs = PIECE[j];
    for(auto k = 0; k < lhs.size(); ++k) if(lhs.substr(lhs.size() - k) == rhs.substr(0, k)) G[i].push_back({i, j, k});
  }
 
  unordered_set<string> used;
  for(auto i = 0; i < N; ++i) {
    text = PIECE[i];
    dfs(G, used, i);
  }
}

int main() {
  for(auto i = 0; i < 45; ++i) DP[i][0] = DP[0][i] = i;

  while(cin >> D >> N, D | N) {
    cin >> TEXT;
    PIECE = vector<string>(N);
    for(auto& i: PIECE) cin >> i;
 
    sort(begin(PIECE), end(PIECE));
    PIECE.erase(unique(begin(PIECE), end(PIECE)), end(PIECE));
    N = PIECE.size();
 
    OK.clear();
    solve();
    cout << OK.size() << endl;
    if(OK.size() <= 5) for(auto i: OK) cout << i << endl;
  }
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i]
#define si(x)       cin>>x
#define sii(x,y)    cin>>x>>y
#define siii(x,y,z) cin>>x>>y>>z
#define ahell   998244353
#define hell 1000000007
#define N1 100001
#define fl 1.0000000000
//#define mod 998244353
#define cntbit(a) __builtin_popcountl(a)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int dp[501][501],cost[501][501];
void func()
{
    int k,n,i,j,l;
    cin>>n;
    int a[n];

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

    for(i=0;i<n;i++)
        dp[i][i]=a[i];

    for(int l=2;l<=n;l++)
    {
        for(i=0;i+l-1<n;i++)
        {
            j=i+l-1;
            int ans=dp[i][i]+dp[i+1][j]+cost[i][i]+cost[i+1][j],sum=0;
            for(k=i+1;k<j;k++)
            {
                ans=min(ans,dp[i][k]+dp[k+1][j]+cost[i][k]+cost[k+1][j]);
            }
            sum=dp[i][i]+dp[i+1][j];
            cost[i][j]=ans;
            dp[i][j]=sum;
        }
    }

 cout<<cost[0][n-1];

}
main()
{
  ios
int n,m,i;
int j;
int u,v,q;
int test=1;
//si(test);

while(test--)
{
string s;
int d;
func();
}

}


Measured memory_bytes: 6708
import std.stdio, std.string, std.array, std.algorithm, std.conv, std.typecons, std.numeric, std.math;

void main()
{
    for (;;) {
        auto wh = readln.split.to!(int[]);
        auto W = wh[0];
        auto H = wh[1];
        if (W == 0 && H == 0) return;

        auto MAP = new char[][](2*H-1, 2*W-1);
        foreach (i; 0..2*H-1) {
            foreach (j, c; readln.chomp) {
                MAP[i][j] = c;
            }
        }

        auto MEMO = new bool[][](2*H-1, 2*W-1);

        auto ss = [[0, 0, 0]];
        MEMO[0][0] = true;
        while (!ss.empty) {
            auto s = ss[0];
            ss = ss[1..$];
            auto x = s[0];
            auto y = s[1];
            auto c = s[2];
            foreach (d; [[1,0], [0,1], [-1,0], [0,-1]]) {
                auto xx = x+d[0];
                auto yy = y+d[1];
                if (xx < 0 || xx >= 2*W-1 || yy < 0 || yy >= 2*H-1 || MAP[yy][xx] == '1') continue;
                xx += d[0];
                yy += d[1];
                if (MEMO[yy][xx]) continue;
                MEMO[yy][xx] = true;
                if (xx == 2*W-2 && yy == 2*H-2) {
                    writeln(c+2);
                    goto ok;
                }
                ss ~= [xx, yy, c+1];
            }
        }
        writeln(0);
        ok:
    }
}


Measured memory_bytes: 3192
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef unsigned long long ull;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int INF = 1 << 27;

//////////////////////////////
// ??¢???????????? (??¢????????¨????????????????????????????????¨??°?????????2???????????????????????????????????????
void dfs(int u, int prev, int *cnt, int *visited, int *prenum, int *lowest, int *parent, vector< vector<int> > &v){
  visited[u] = true;
  prenum[u] = lowest[u] = *cnt;
  REP(i, v[u].size()){
    int next = v[u][i];
    if(!visited[next]){
      parent[next] = u;
      ++(*cnt);
      dfs(next, u, cnt, visited, prenum, lowest, parent, v);
      lowest[u] = min(lowest[u], lowest[next]);
    } else if(next != prev)
      lowest[u] = min(lowest[u], prenum[next]);
  }
}
vector<int> articulation_points(int V, int E, vector< vector<int> > &v){
  int visited[V], prenum[V], lowest[V], parent[V];
  memset(visited, 0, sizeof(visited));
  parent[0] = -1;
  int tmp = 1;
  dfs(0, -1, &tmp, visited, prenum, lowest, parent, v);
  vector<int> ret;
  int cnt = 0, used[V];
  memset(used, 0, sizeof(used));
  FOR(i, 1, V){
    if(parent[i] == 0) ++cnt;
    if(parent[i] > 0 && !used[parent[i]] && prenum[parent[i]] <= lowest[i]){
      used[parent[i]] = true;
      ret.push_back(parent[i]);
    }
  }
  if(cnt >= 2) ret.push_back(0);
  return ret;
}
int main() {
	int v, e; cin >> v >> e;
	vector<vi> vvi(v);
	REP(i, e) {
		int a,b; cin >> a >> b;
		vvi[a].pb(b);
		vvi[b].pb(a);
	}
	vi ans = articulation_points(v, e, vvi);
	sort(ans.begin(), ans.end());
	REP(i, ans.size())
		cout << ans[i] << endl;
	return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
 
signed main()
{   
    gearup;
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll res = 0;
    vl dp(n+1,0);
    rep(i,n){
        int num = a[i];
        dp[num] = dp[num-1] + 1;
    }
    rep1(i,n+1)chmax(res,dp[i]);
    out(n - res);
}


Measured memory_bytes: 6364
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        string a = "abcdefghijklnmopqrstuvwxyz";
        int i = a.IndexOf(Console.ReadLine().Trim());
        string s = a.Substring(i + 1, 1);

        Console.WriteLine(s);

        //Console.ReadKey();
    }
}


Measured memory_bytes: 13280
h,w=map(int,input().split())
f=[]
f.append("."*(w+2))
for i in range(h):
  f.append("."+input()+".")
f.append("."*(w+2))
a=[]
for i in range(1,h+1):
  dumy2=""
  for j in range(1,w+1):
    if f[i][j]==".":
      dumy=f[i-1][j-1]+f[i-1][j]+f[i-1][j+1]+f[i][j-1]+f[i][j]+f[i][j+1]+f[i+1][j-1]+f[i+1][j]+f[i+1][j+1]
      n=dumy.count("#")
      dumy2+=str(n)
    else:
      dumy2+="#"
  a.append(dumy2)
for i in range(h):
  print(a[i])
    
    

Measured memory_bytes: 39408
/*
___mennat khoday ra azz o va jall ke taatash mojebe ghorbat ast o be shokr andarash mazide nemat.
___har nafasi ke foro miravad momedde hayatast o chon bar miayad mofarrahe zat.
___pas dar har nafasi 2 nemat mojod ast o bar har nematy shokry vajeb.

___az dast o zabane ke barayad ?
___kaz ohdeye shokrash be dar ayad !


___man be to dami gharar natvanam kard
___va ehsane to ra shomar natvanam kard
####################
___gar bar tane man zaban shavad har moyee
___yek shokre to az hezar natvanam kard

*/

#include <bits/stdc++.h>

#define pb push_back
#define SALI main
#define left(x) ((x)*2)
#define right(x) (((x)*2)+1)
#define fuck(x) cout << #x << " : " << x << endl;
#define findLowVec(v,x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define findUpVec(v,x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define findLowArr(a,n,x) (lower_bound(a, a+n, x) - a)
#define findUpArr(a,n,x) (upper_bound(a, a+n, x) - a)
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;

template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p)
{return out << "(" << p.first << ", " << p.second << ")";}

template<class A> ostream& operator <<(ostream& out, const vector<A> &v)
{out << "[";for(int i = 0; i < v.size(); i++) {if(i) out << ", ";out << v[i];}return out << "]";}

template<class A,class B> ostream& operator <<(ostream& out, const set<A,B> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

template<class A> ostream& operator <<(ostream& out, const set<A> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}
const int mod = 1e9 + 7;
const int N = 3e3 + 10;
// dp[i][j] = number of permtion for i-1 first char(1 ... i) such that the last number is j
// dp[1][1] = 1

int dp[N][N];
int sum[N][N];
ll fsum(int i,int a, int b) {return ( ( (sum[i][b] - sum[i][a-1])%mod) + mod) % mod;}
int32_t SALI()
{
    int n; cin >> n;
    string s; cin >> s;
    dp[1][1] = 1;
    sum[1][1] = 1;
    for(int i = 0; i < s.size(); i++){
        for(int j = 1; j <= i+2; j++){
            if(s[i] == '<'){ // dp[i+2][j] = sum dp[i+1][k] : k = [1 , j-1]
                dp[i+2][j] = fsum(i+1,1,j-1);
            }
            if(s[i] == '>'){ // dp[i+2][j] = sum dp[i+1][k] : k = [j+1 , i+2]
                dp[i+2][j] = fsum(i+1,j,i+1);
            }

            sum[i+2][j] = sum[i+2][j-1] + dp[i+2][j];
            sum[i+2][j] %= mod;
        }
    }

    cout << fsum(n,1,n);
}



/**< WRITEN BY ALI ADELKHAH */



Measured memory_bytes: 95952
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

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

    if(a+b>=10) cout << "error" << endl;
    else cout << a + b << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
char s[20];
int main()
{
	cin>>s;
	if(s[0]=='S')
	printf("Cloudy");
	if(s[0]=='C')
	printf("Rainy");
	if(s[0]=='R')
	printf("Sunny");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;
ll dp[5050][5050];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n ;
  cin >> n;
  string s;
  cin >> s;
  
  for(int i=n-1;i>=0;--i){
    for(int j=n-1;j>=0;--j){
      if(s[i] != s[j]) dp[i][j]=0;
      else dp[i][j] = dp[i+1][j+1]+1;
    }
  }
  int ans = 0;
  rep(i,n)rep(j,n){
    if(i>=j)continue;
    int now = min(dp[i][j],j-i);
    ans = max(ans,now);
  }
  cout << ans << endl;
                         
  return 0;
}

Measured memory_bytes: 200916
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int addTrue;
		int Number;
		int Count = 0;

		int[] NumList = new int[2];
		String[] InputList;

		Scanner sc = null;

		try {

			//??\????????????
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			while (true) {
				//??\??????????????????
				String line = br.readLine();

				if (line != null) {
					//???????????????????????????
					InputList = line.split(" ", 0);

					//?????????????????´??°???Int???
					for (int i = 0; i < InputList.length; i++) {
						NumList[i] = Integer.parseInt(InputList[i]);
					}

					Number = NumList[0];
					addTrue = NumList[1];

					//????????????????¢????
					if (Number != 0 || addTrue != 0) {
						Count = 0;
						//?????????????????????????????¢???(???????????????)
						for (int i = 1; i <= Number; i++) {
							for (int j = i + 1; j <= Number; j++) {
								for (int k = j + 1; k <= Number; k++) {

									if ((i + j + k) == addTrue) {
										Count++;
									}
								}
							}
						}
						//???????????????
						System.out.println(Count);

					}else{
						break;
					}
				}else{
					break;
				}
			}
		}catch (IOException e) {
			System.out.println(e);
		}
	}

}

Measured memory_bytes: 25164
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int;  // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

void comb(int X, int M, vector<vector<int>>& A, vector<int>& C, vector<int>& h, int first, int end, int index, int& ans) {
  if (index == h.size()) {
    int sum = 0;
    // アルゴリズム理解度たりてるかチェック
    // 足りてないなら　returnする
    vector<int> s(M, 0);
    for (int i = 0; i < h.size(); ++i) {
      for (int j = 0; j < M; ++j) {
        s[j] += A[h[i]][j];
      }
    }

    for (auto v : s) {
      if (v < X) return;
    }

    // cout << endl;

    // for (auto v : s) {
    //   cout << v << "||";
    // }
    // 合計金額チェック ansと比較する
    int mon = 0;
    for (int i = 0; i < h.size(); ++i) {
      mon += C[h[i]];
    }

    if (mon < ans) {
      ans = mon;
    }

    return;
  }

  for (int i = first; i <= end; ++i) {
    h[index] = i;
    comb(X, M, A, C, h, i + 1, end + 1, index + 1, ans);
  }
}

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));

  for (int i = 0; i < N; ++i) {
    cin >> C[i];
    for (int j = 0; j < M; ++j) {
      cin >> A[i][j];
    }
  }
  // 全パターン網羅する
  // vector<int> A(2);
  // comb(A, 0, 2, 0);
  int ans = INT_MAX;

  for (int i = 1; i <= N; ++i) {
    vector<int> tmp(i);
    comb(X, M, A, C, tmp, 0, N - i, 0, ans);
  }

  if (ans == INT_MAX) {
    cout << -1 << endl;
    return 0;
  }

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


Measured memory_bytes: 3628
n = int(input())
c = [l for l in input()]
ideal = ['R']*(c.count('R')) + ['W']*(c.count('W'))

w_to_r=0
r_to_w=0
for i_, c_ in zip(ideal, c):
  if (i_=='R') and (c_=='W'):
    w_to_r+=1
  if (i_=='W') and (c_=='R'):
    r_to_w+=1

print(max(w_to_r, r_to_w))

Measured memory_bytes: 13928
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, n, m, sum = 0, ans = 1;
  scanf("%lld%lld", &n, &m);
  ll a[n];
  for(i = 0; i < n; ++i) scanf("%lld", &a[i]), sum += a[i];
  for(i = 0; i < n; ++i) if(a[i] >= (sum + 4 * m - 1) / (4 * m)) ans++;
  if(ans > m) printf("Yes");
  else printf("No");
  return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = T.size();
  for (int i = 0; i + T.size() - 1 < S.size(); i++) {
    int dif = 0;
    for (int j = 0; j < T.size(); j++) {
      if (S.at(i + j) != T.at(j)) dif++;
    }
    ans = min(ans, dif);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3612
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *AB = map(int, read().split())
A = AB[:N + 1]
B = AB[N + 1:]

ans = 0
cnt = 0
for i, j in zip(A, B):
    # print(f'A:{i} B:{j} cnt:{cnt}')
    ans += min(i, cnt)
    m = min(i-cnt, j)
    m=max(m,0)
    ans += m
    cnt = max(j - m, 0)
ans += min(A[-1], cnt)

print(ans)

Measured memory_bytes: 23432
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Trim();
            var n = s.Length;

            var count = 0;
            for(var i = 0; i < n / 2; i++){
                if(s[i] != s[n - i - 1]){
                    count += 1;
                }
            }

            Console.WriteLine(count);
        }
    }
}


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

int main(){
  int N,A,B,C,X,ans=0;
 

  while(1){
    cin>>N>>A>>B>>C>>X;
    if((N+A+B+C+X)==0)break;
    ans=0;
    vector<int> Y(N,0);
    for(int i=0;i<N;i++) cin>>Y[i];
    int i=0;
    while(1){
      bool flag=0;
      
      if(Y[i]==X) i++;
      if(i==N)flag=1;
	
      if(flag==1||ans>10000)break;
      ans++;
      X=(A*X+B)%C;
    }
    if(ans<=10000)cout<<ans<<endl;
    else cout<<"-1"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1196