akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class ABC084D
    {
        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static public void Main(string[] args)
        {
            var table = new bool[100001];
            table[0] = table[1] = true;
            for (int i = 2; i <= 50000; ++i)
            {
                if (!table[i])
                {
                    for (int j = i * 2; j <= 100000; j += i)
                    {
                        table[j] = true;
                    }
                }
            }

            var sumary = new int[100001];
            for (int i = 1; i <= 100000; ++i)
            {
                if (!table[i] && ((i + 1) % 2 == 0) && !table[(i + 1) / 2])
                {
                    sumary[i] = 1;
                }
                sumary[i] += sumary[i - 1];
            }

            var Q = Console_.NextInt();
            for (int i = 0; i < Q; ++i)
            {
                var l = Console_.NextInt();
                var r = Console_.NextInt();
                Console.WriteLine(sumary[r] - sumary[l - 1]);
            }
        }
    }
}


Measured memory_bytes: 17732
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
// priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > pq;

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}

long long nCr(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


// a^n mod を計算する
long long modpow(long long a, long long n, long long MOD) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long Mod) {
    return modpow(a, Mod - 2, Mod);
}


bool IsPrime(int x){
    for (int i = 2; i*i <= x; i++){
        if (x % i == 0){
            return false;
        }
    }
    return true;
}

vector<pair<ll, ll> > PrimeFactor(ll N){
    vector<pair<ll, ll> > prime;
    for (int i = 2; i*i <= N; i++){
        if (N % i != 0) continue;
        int cnt = 0;
        while (N % i == 0){
            cnt++;
            N /= i;
        }
        prime.push_back({i, cnt});
    }
    if (N > 1){
        prime.push_back({N, 1});
    }
    return prime;
}

vector<pair<ll, ll> > CountPrime(ll N){
    vector<pair<ll, ll> > prime;
    for (ll i = 2; i * i <= N; i++){
        if (N % i != 0) continue;
        ll cnt = 0, n = N;
        while (n % i == 0){
            cnt++;
            n /= i;
        }
        prime.push_back({i, cnt});
    }
    prime.push_back({N, 1});
    return prime;
}

int main(){
    ll N, K; cin >> N >> K;
    vector<ll> h(N), cost(N+2, MM);
    for (int i = 0; i < N; i++){
        cin >> h[i];
    }

    cost[0] = 0;
    for (int i = 0; i < N-1; i++){
        for (int s = 1; s <= K; s++){
            if (s+i >= N){
                s = K; 
                continue;
            }
            cost[i+s] = min(cost[i+s], cost[i] + abs(h[i+s]-h[i]));
        }
    }
    cout << cost[N-1] << endl;
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))


"""
「1回の握手でX以上幸福度が上がるならば採用」としたときに，何個採用することになるか？
此の値が初めてM以上になったところのXを利用すれば答えが出る．
例えばM+2開催消してしまったら，2*X引けば良い

「X以上なら採用」は左手ごとに，右手を二分探索

"""
def main():
    import bisect
    
    mod=10**9+7
    N,M=MI()
    A=LI()
    A.sort()
    
    def ch(X):
        temp=0
        
        for i in range(N):#左手
            l=A[i]
            t=X-l
            num=bisect.bisect_left(A,t)
            temp+=N-num
            
        return temp>=M
    
    
    ok=0
    ng=2*(10**5) + 1
    
    while ng - ok > 1:
        med=(ok+ng)//2
        if ch(med):
            ok=med
        else:
            ng=med
            
    # 総和の計算パート，累積和で
    S=[0]*(N+1)
    for i in range(N):
        S[i+1]=S[i]+A[i]
        
    ans=0
    temp=0
    X=ok
    for i in range(N):#左手
        l=A[i]
        t=X-l
        num=bisect.bisect_left(A,t)
        temp+=N-num
        ans+=S[-1] - S[num] + (N-num)*l
        # print(i,num,S[-1]-S[num],(N-num)*l)

        
    if temp>M:
        ans-=X*(temp-M)
        
    print(ans)
    
        
    
        
    
            
    
            
        
            

main()


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

int main() {

	string s;
	cin >> s;
	int n = s.size();
	map<char, int> m;
	for(int i = 0; i < n; i++) {
		m[s[i]] += 1;
	}
	bool ans = true;
	for(int i = 0; i < n; i++) {
		if(m[s[i]] != 1)  {
			ans = false;
		}
	}
	if(ans) {
		cout << "yes" << endl;
	}else {
		cout << "no" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
using namespace std;


int main(){
    int n,w;
    cin>>n>>w;
    int a[100000],b[100000];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    
    int dp[100000]={};
    int dpd[100000]={};
    for(int t=0;t<n;t++){
        for(int i=1;i<=w;i++){
            if(i-b[t]>=0){
              dp[i]=max(dpd[i],dpd[i-b[t]]+a[t]);
            }
        }
        for(int i=0;i<=w;i++){dpd[i]=dp[i];}
    }
    
    
    cout<<dp[w]<<endl;
    
    return 0;
}



Measured memory_bytes: 3888
n = int(input())
ans = 0
m = 1000
for i in range(n):
  tmp = int(input())
  ans += tmp
  if tmp%10 != 0:
    m = min(m,tmp)
if ans%10 != 0:
  print(ans)
else:
  if m == 1000:
    print(0)
  else:
    print(ans-m)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, z, n) for(int64_t i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
//const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;
typedef pair<int64_t, int64_t> P;

int main(){
    int K, X;
    cin >> K >> X;
    if (K * 500 >= X) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
    int a,b,c=0;
    cin >> a;
    b=a;
    while(b!=0){
        c+=b%10;
        b/=10;
    }
    if(a%c==0)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


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

using namespace std;

typedef long long int64;

int main()
{
  int N, W;
  int w1;
  cin >> N >> W;

  vector< int > st[4];
  for(int i = 0; i < N; i++) {
    int w, v;
    cin >> w >> v;
    if(i == 0) w1 = w;
    st[w - w1].push_back(v);
  }
  for(int i = 0; i < 4; i++) {
    sort(begin(st[i]), end(st[i]));
    st[i].push_back(0);
    reverse(begin(st[i]), end(st[i]));
    for(int j = 1; j < st[i].size(); j++) {
      st[i][j] += st[i][j - 1];
    }
  }

  int ret = 0;
  for(int64 i = 0; i < st[0].size(); i++) {
    for(int64 j = 0; j < st[1].size(); j++) {
      for(int64 k = 0; k < st[2].size(); k++) {
        for(int64 l = 0; l < st[3].size(); l++) {
          int64 fact = w1 * i + (w1 + 1) * j + (w1 + 2) * k + (w1 + 3) * l;
          if(fact <= W) {
            ret = max(ret, st[0][i] + st[1][j] + st[2][k] + st[3][l]);
          }
        }
      }
    }
  }

  cout << ret << endl;
}

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


using ll = long long;


int main()
{
    int h, w;
    cin >> h >> w;
    ll ans;
    if (h == 1 || w == 1) ans = 1;
    else ans = ((ll)h * (ll)w + 1) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int M = sc.nextInt();

    int[] K = new int[N];
    int[][] A = new int[N][];

    for (int i = 0; i < N; i++) {
      K[i] = sc.nextInt();
      A[i] = new int[K[i]];
      for (int j = 0; j < K[i]; j++) {
        A[i][j] = sc.nextInt();
      }
    }

    sc.close();

    int[] m = new int[M+1];

    for (int i = 0; i < N; i++) {
 
      for (int j = 0; j < K[i]; j++) {

        m[A[i][j]]++;

      }

    }

    int count = 0;

    for (int i = 0; i < M+1; i++) {
      if (m[i] == N) {
        count++;
      }
    }

    System.out.println(count);

  }

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
    #include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
    #include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define pi std::pair<int, int>
#define stdabs std::abs
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
constexpr ll mod = 1000000000 + 7;
int grid[5][110];
int n;
vector<int> record;
int main()
{
    stat();
    cin >> n;
    //    memset(&grid[0][0],0,sizeof(grid));
    for (int i = 1; i != 3; ++i) {
        for (int j = 1; j != n + 1; ++j) {
            cin >> grid[i][j];
        }
    }

    for (int i = 1; i != 3; ++i) {
        for (int j = 1; j != n + 1; ++j) {
            grid[i][j]=max(grid[i-1][j],grid[i][j-1])+grid[i][j];
        }
    }


    cout << grid[2][n] << endl;

    return 0;
}
ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

template <typename T> T fact(T num)
{
    if (num == 1) { return 1; }
    return num * fact(num - 1);
}


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

int main(){
  int S, h, m, s;
  cin >> S;
  h = S / 3600;
  S %= 3600;
  m = S / 60;
  S %= 60;
  s = S;
  cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 1168
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		long n = sc.nextInt();
		long a = sc.nextInt();
		long b = sc.nextInt();
		
		if(a > b) {
			System.out.println(0);
			return;
		}
		
		if(n == 1) {
			if(a != b) {
				System.out.println(0);
				return;
			} else {
				System.out.println(1);
				return;
			}
		}
		
		long ans = (b-a)*(n-2)+1;
		System.out.println(ans);
	}

	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	    public int nextInt(){
	    	return Integer.parseInt(next());
	    }
	}
}


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

int Fibonacci(int n) {
    int F[45];
    F[0] = 1;
    F[1] = 1;
    for(int i = 2; i <= n; i++) {
        F[i] = F[i-1] + F[i-2];
    }
    return F[n];
}

int main() {
    int n;
    cin >> n;
    cout << Fibonacci(n) << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 100000007;

int main() {
    ll N,M;cin >> N >> M;
    vector<ll> X(N,0);
    vector<ll> H(N);
    for (ll i = 0;i < N;i++){
        cin >> H[i];
    }
    for (int i = 0;i < M;i++){
        int a,b;cin >> a >> b;
        a--;b--;
        X[a] = max(X[a],H[b]);
        X[b] = max(X[b],H[a]);
    }
    int ans = 0;
    for (int i = 0;i < N;i++){
        if (H[i] > X[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
 
const int MX = 100005;
 
int main(){
  ll n, d;
  int ans = 0;
  cin >> n >> d;
  ll x,y;
  rep(i,n){
    cin >> x >> y;
    if(x*x+y*y <= d*d)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3568
#include <stdio.h>
   int main(void){
      int r, g, b;
      int num;
      scanf("%d%d%d", &r, &g, &b);
      num = r*100 + g*10 + b;
      if(num % 4 != 0)
         printf("NO\n");
      else printf("YES\n");
}

Measured memory_bytes: 128
import itertools

if __name__ == "__main__":
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    k = int(input())
    l_an = [a, b, c, d, e]
    ret = "Yay!"
    for i in list(itertools.combinations(l_an, 2)):
        if i[1] - i[0] > k:
            ret = ":("
            break
    print(ret)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  string s;cin>>s;

  string hi="hi";
  string hh;
  int flag=0;
  hh="";
  REP(i,5){
    hh+=hi;
    if (s==hh){flag=1;break;}
  }

  if (flag==0){
    cout<<"No"<<endl;
    return 0;
  }else{
    cout<<"Yes"<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;

int a[30],n,m;

int main() {
    //freopen("test.in","r",stdin);
    cin >> n;
    memset(a,0,sizeof(a));
    for (int i=1;i<=n;i++) {
        cin >> m;
        if (1<=m && m<=399) a[1] = 1;
         else if (400<=m && m<=799) a[2] = 1;
          else if (800<=m && m<=1199) a[3] = 1;
           else if (1200<=m && m<=1599) a[4] = 1;
            else if (1600<=m && m<=1999) a[5] = 1;
             else if (2000<=m && m<=2399) a[6] = 1;
              else if (2400<=m && m<=2799) a[7] = 1;
               else if (2800<=m && m<=3199) a[8] = 1;
                else a[9]++;
    }
    long long sum = 0;
    for (int i=1;i<=8;i++) {
        if (a[i]) sum++;
    }
    if (sum != 0)
    cout << sum << ' ' << sum+a[9] << endl;
     else cout << 1 << ' ' << a[9] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
const int N=505;
int n,m;
char pp[N][N],rd[N][N],bl[N][N];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
int main()
{
	//freopen("AND Grid.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n,m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",pp[i]+1);
		for(int j=1;j<=m;j++) if(pp[i][j]=='#') rd[i][j]=bl[i][j]='#';
	}
	for(int i=1;i<=n;i++)
	{
		rd[i][1]=bl[i][m]='#';
	}
	for(int i=2;i<n;i++)
	{
		for(int j=2;j<m;j++)
		{
			if(i&1) rd[i][j]='#';
			else bl[i][j]='#';
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			printf("%c",rd[i][j]=='#' ? '#' : '.');
		}
		printf("\n");
	}
	printf("\n");
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			printf("%c",bl[i][j]=='#' ? '#' : '.');
		}
		printf("\n");
	}
	//fclose(stdin); fclose(stdout);
	return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#define MAX_N 100
typedef struct { int r, c; } md_t;

static void matrix_chain_multiplication(md_t *md, int n, int m[MAX_N][MAX_N]) {
  int i, j, k, l, cost;

  for (l = 2; l < n + 1; ++l) {
    for (i = 0; i < n - l + 1; ++i) {
      j = i + l - 1;
      m[i][j] = -1;
      for (k = i; k < j; ++k) {
        cost = m[i][k] + m[k + 1][j] + md[i].r * md[k].c * md[j].c;
        if (m[i][j] == -1 || cost < m[i][j]) m[i][j] = cost;
      }
    }
  }
}

int main(int argc, char **argv) {
  int n, i, j, m[MAX_N][MAX_N];
  md_t md[MAX_N];

  scanf("%d", &n);
  for (i = 0; i < n; ++i) scanf("%d %d", &md[i].r, &md[i].c);
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n; ++j) m[i][j] = 0;
  }
  matrix_chain_multiplication(md, n, m);
  printf("%d\n", m[0][n - 1]);
  exit(0);
}


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

void solve(std::string S) {
    int head = std::stoi(S.substr(0, 2));
    int tail = std::stoi(S.substr(2, 2));
    if ( (head <= 12 && head >= 1) && (tail <= 12 && tail >= 1) ) {
        cout << "AMBIGUOUS" << endl;
    } else if ((head <= 12 && head >= 1) && !(tail <= 12 && tail >= 1)) {
        cout << "MMYY" << endl;
    } else if (!(head <= 12 && head >= 1) && (tail <= 12 && tail >= 1)) {
        cout << "YYMM" << endl;
    } else {
        cout << "NA" << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 3588
@AAA=@BBB=@CCC=@DDD=1;
for$i(1..<>-1){
	for$j(@_=glob'{A,B,C,D}'x3){
		"$j$_"=~/ABC|A.*C.*B|CAB/ or$j=~/./,(${$'.$_}[$i]+=$$j[$i-1])%=$%=1e9+7for A..D
	}
}
($\+=$$_[-1])%=$%for@_;print


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

const int N=200005;
const int inf=1<<30;
int n,a[N];
long long s[N],ans=inf;

long long solve(int i,int j,int k)
{
	long long s1=s[i],s2=s[j]-s[i],s3=s[k]-s[j],s4=s[n]-s[k];
	return max(max(s1,s2),max(s3,s4))-min(min(s1,s2),min(s3,s4));
	return 0;
}

int main()
{
	int i,j,k,lb1,rb1,lb2,rb2,mid;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	    scanf("%d",&a[i]),s[i]=s[i-1]+a[i];
	for(i=2;i+1<n;i++)
	{
		lb1=1,rb1=i;
		while(lb1+1<rb1)
		{
			mid=(lb1+rb1)/2;
			if(s[mid]*2<=s[i])
			    lb1=mid;
			else
			    rb1=mid;
		}
		lb2=i+1,rb2=n;
		while(lb2+1<rb2)
		{
			mid=(lb2+rb2)/2;
			if((s[mid]-s[i])*2<=s[n]-s[i])
			    lb2=mid;
			else
			    rb2=mid;
		}
		j=lb1,k=lb2;
		ans=min(ans,min(solve(j,i,k),solve(j+1,i,k)));
		ans=min(ans,min(solve(j,i,k+1),solve(j+1,i,k+1)));
	}
	cout<<ans;
	return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i< n ; i++)
		cin >> a[i];
	// sort(a.begin(), a.end());
	vector<bool> dp(k+1, false);
	dp[0] = false;
	for(int i = 1; i<=k; i++){
		for(int j = 0; j<n; j++){
			if(i-a[j]>=0){
				if(dp[i-a[j]] == false){
					dp[i] = true;
					j = n+1;
				}
			}
			else{
				break;
			}
		}
	}
	if(dp[k]){
		cout<<"First"<<endl;
	}
	else
		cout<<"Second"<<endl;
		
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define FOR(i, i0, n) for(int i = (i0); i < (n); i ++)
#define COUT(val) cout << (val) << "\n";
using namespace std;
using ll = long long int;

int main(void){
    int n, wMax;
    cin >> n >> wMax;
    vector<int> w(n), v(n);
    FOR(i, 0, n) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(wMax+1, vector<ll>(n));

    FOR(i, 1, wMax+1){
        dp[i][0] = (i < w[0]) ? 0 : v[0];
        FOR(j, 1, n){
            dp[i][j] = max(dp[i][j-1], (i < w[j]) ? 0 : v[j] + dp[i-w[j]][j-1]);
        }
    }
    
    COUT(dp[wMax][n-1]);
}

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

void BubbleSort(int NumCard, string InCard[]);
void SelectSort(int NumCard, string InCard[]);
bool IsStable(int NumCard, const string OldCard[], string NewCard[]);

int main(){
    int N;
    cin >> N;
    string Card[N];
    string BubbleCard[N];
    string SelectCard[N];

    rep(i,N){
        cin >> Card[i]; //Card[i][0]が記号，Card[i][1]が数字
    }

    rep(i,N){
        BubbleCard[i] = Card[i];
        SelectCard[i] = Card[i];
    }

    BubbleSort(N, BubbleCard);

    rep(i,N-1) cout << BubbleCard[i] << " ";
    cout << BubbleCard[N-1] << endl;

    if (IsStable(N, Card, BubbleCard)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    SelectSort(N, SelectCard);

    rep(i,N-1) cout << SelectCard[i] << " ";
    cout << SelectCard[N-1] << endl;

    if (IsStable(N, Card, SelectCard)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    
    return 0;
}

void BubbleSort(int NumCard, string InCard[]){
    bool Unsorted = true;
    int SortedNum = 0; //Aの最初からSortedNum個目まではソート済
    int SwapNum = 0; //交換数

    while(Unsorted){
        Unsorted = false;
        for(int CurPos = NumCard-1; CurPos >= SortedNum + 1; --CurPos){
            if(InCard[CurPos][1] < InCard[CurPos-1][1]){
                swap(InCard[CurPos], InCard[CurPos-1]);
                ++SwapNum;
                Unsorted = true;
            }
        }
        ++SortedNum;
    }

    return;
}

void SelectSort(int NumCard, string InCard[]){
    int SwapNum = 0; //交換数

    for(int SortedNum = 0; SortedNum < NumCard; ++SortedNum){    //Aの最初からSortedNum個目まではソート済
        bool Swapped = false; //このループで交換が行われたか
        int MinPos = SortedNum;    //未ソート部分での最小要素の位置
        for(int CurPos = SortedNum; CurPos < NumCard; ++CurPos){
            if (InCard[CurPos][1] < InCard[MinPos][1]){
                Swapped = true;
                MinPos = CurPos;
            }
        }
        swap(InCard[SortedNum], InCard[MinPos]);
        if(Swapped) ++SwapNum;
    }
}

bool IsStable(int NumCard, const string OldCard[], string NewCard[]){
    for(int i = 0; i < NumCard; i++){
        for(int j = i+1; j < NumCard; j++){
            for(int a = 0; a < NumCard; a++){
                for(int b = a+1; b < NumCard; b++){

                    if (OldCard[i][1] == OldCard[j][1]){
                        if (OldCard[j][1] == NewCard[a][1]){
                            if(NewCard[a][1] == NewCard[b][1]){//注目している数字が全て同じ
                                if(OldCard[i][0] == NewCard[b][0]){
                                    if(OldCard[j][0] == NewCard[a][0]){//その中で文字の前後関係が逆
                                        return false;
                                    }
                                }
                            }
                        }
                    }

               }
            }
        }
    }
    return true;
}


Measured memory_bytes: 3204
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = 0;
		int[] a = new int[200000];
		int[] z = new int[200000];
		int k = 0;
		int j = 0;
		for(int i = 0;i < s.length();i++) {
			char c = s.charAt(i);
			if(c == 'A') {
				a[k] = i;
				k++;
			}else if(c == 'Z') {
				z[j] = i;
				j++;
			}
		}
		len = z[j-1] - a[0] + 1;
		System.out.println(len);
	}
}


Measured memory_bytes: 30416
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long a[2000],b[2000],c[2000];
const int maxn=1e6;
const int N=1e7;
long long ans[N];
long long d[maxn];
bool cmp(long long a,long long b){
    return a>b;
}
int main(){
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    for(int i=0;i<x;i++)
        cin>>a[i];
    for(int i=0;i<y;i++)
        cin>>b[i];
    for(int i=0;i<z;i++)
        cin>>c[i];
    sort(c,c+z,cmp);
    int cur=0;
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            d[cur++]=a[i]+b[j];
        }
    }
    cur=0;
    sort(d,d+x*y,cmp);
    int f=min(3000,x*y);
    for(int i=0;i<f;i++){
        for(int j=0;j<z;j++){
            ans[cur++]=d[i]+c[j];
            //cout<<i*f+j<<endl;
        }
    }
    cur=f*z;
    sort(ans,ans+cur,cmp);
    for(int i=0;i<k;i++){
        cout<<ans[i]<<endl;
    }
}


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

int main() {
  ll d,n;
  cin >> d >> n;
  ll ans=0;
  ans=n;
  if(ans==100) {
    ans++;
  }
  while(d) {
    ans*=100;
    d--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = get!(usize);
    let mut aa = get!(u64; n);

    let mut index = HashMap::new();

    for (i, &a) in aa.iter().enumerate() {
        index.insert(a, i);
    }


    aa.sort();
    let ans = aa.iter()
        .enumerate()
        .filter(|&(i, &a)| {
            (i as i64 - index.get(&a).cloned().unwrap() as i64).abs() % 2 == 1
        })
        .count() / 2;

    println!("{}", ans);
}


Measured memory_bytes: 12540
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace();
    let a: i64 = iter.next().unwrap().parse().unwrap();
    let b: i64 = iter.next().unwrap().parse().unwrap();
    let _c: i64 = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();
    if (a - b).abs() > 1000000000000000000 {
        println!("Unfair");
    } else {
        println!("{}", if k % 2 == 0 { a - b } else { b - a });
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
int main() {
  int n,ans;
  string s;
  char a,b;
  cin>>n>>s;
  ans=n;
  a=s[0];
  rep(i,n-1){
    b=s[i+1];
    if(a==b) ans--;
    else a=b;
  }
  cout<<ans;
}

Measured memory_bytes: 3732
s=int(input())
P=[s]
i=1

def MY_function(n):
    if n%2==0:
        result=n//2
    else:
        result=3*n+1

    return(result)

while True:
        i+=1
        s= MY_function(s)
        P +=[s]

        if P.count(s) != 1:
            break
    
print(i)

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

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;
typedef long long ll;

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

  vector<ll> A(n);
  rep (i, n) cin >> A[i];

  ll max = -1000001;
  ll min =  1000001;
  ll sum = 0;

  for (ll e : A) {
    min = (e < min) ? e : min;
    max = (e > max) ? e : max;
    sum += e;
  }

  cout << min << ' ' << max << ' ' << sum << endl;
}

Measured memory_bytes: 3168
#include <cstdio>
bool f[100001];
int c[100002];
int N, L, R;
int main ()
{
    for(int i =2; i <=100000; i++) if (!f[i])for(int j = i + i ;j <=100000; j += i )
        f[j]= true ;
    for ( int i =3; i <=100000; i +=2) if (!f[i]&&!f[(i+1)/2]) c[i]++;
    for ( int i =3; i <=100000; i++) c[i] += c[i-1];
    scanf ("%d" ,&N);
    while (N--)
    {
        scanf ("%d %d " ,&L ,& R );
        printf ("%d \n " , c[R] - c[L-1]);
    }
}


Measured memory_bytes: 1280
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long A = sc.nextLong();
    long B = sc.nextLong();
    long[] h = new long[N + 1];
    for(int i = 0; i < N; i++) {
      h[i] = sc.nextLong();
    }
    long left = 1;
    long right = (int)Math.pow(10, 9);
    long ans = (int)Math.pow(10, 9);
    while(left < right) {
      long med = (left + right) / 2;
      long count = 0;
      for(int i = 0; i < N; i++) {
        long r = h[i] - med * B;
        if(r > 0) {
          count += (long)((r + A - B - 1) / (A - B));
        }
      }
      if(count > med) {
        left = med + 1;
      } else {
        ans = med;
        right = med;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 50284
S = input()
X = list(S)
Y = [int(X[i]) for i in range(4)]
a = 10 * Y[0] + Y[1]
b = 10 * Y[2] + Y[3]
if a >= 13 or a == 0:
    if b >= 13 or b == 0:
        print('NA')
    else:
        print('YYMM')
else:
    if b >= 13 or b == 0:
        print('MMYY')
    else:
        print('AMBIGUOUS')

Measured memory_bytes: 3060
import java.util.*;
import java.math.*;

class Main {
  public static void main (String[] args) {
    Scanner scan_ = new Scanner(System.in);
   int h_ = 0;
   int w_ = 0;
   while(scan_.hasNext()) {
      h_ = scan_.nextInt();
      w_ = scan_.nextInt();
      if(h_ != 0 | w_!=0) {
       for( int i = 0; i < h_ ; i++) {
         for(int n = 0; n < w_ ; n++) {
           System.out.print("#");
         }
         System.out.println();
       }
       
       System.out.println();
    }
    
  }
}
}


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

int main(void){
    int x,y,z,cnt=0;
    cin>>x>>y>>z;
    x-=(z*2)+y;
    cnt++;
    while(x-y>0 && x-(y+z)>=0){
        x-=y+z;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


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

parr.sort(reverse=True)
qarr.sort(reverse=True)
rarr.sort(reverse=True)
parr = parr[:x]
qarr = qarr[:y]
arr = parr + qarr + rarr
arr.sort(reverse=True)
print(sum(arr[:x+y]))

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

int main() {
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    rep(i,n) cin >> t[i];
    sort(all(t));
    int ans = 0;
    for(int i = 0; i < n;) {
        ans++;
        int s = i;
        while(i<n && t[i]-t[s] <= k && i - s +1 <= c) ++i;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3796
import numpy as np

N, M = map(int, input().split())
lst = [list(map(int, input().split())) for s in range(M)]
P = list(map(int, input().split()))

all_lst = []
for x in lst:

    b = [0] * N
    for i in x[1:]:
        b[i - 1] = 1

    all_lst.append(b)

cnt = 0
for v in range(2 ** N):
    v = bin(v)[2:]

    b = [0] * N
    for i, n in enumerate(v[::-1]):
        if n == '1':
            b[i] = 1

    b = np.array(b)

    found = True
    for i, tar in enumerate(all_lst):
        p = np.sum(b * np.array(tar)) % 2

        if P[i] != p:
            found = False
            break

    if found:
        cnt += 1

print(cnt)


Measured memory_bytes: 12512
H, W = map(int, input().split())
S = [input() for _ in range(H)]

ans = True

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            t = False
            if i != 0:
                t = max(t, S[i - 1][j] == "#")
            if i != H - 1:
                t = max(t, S[i + 1][j] == "#")
            if j != 0:
                t = max(t, S[i][j - 1] == "#")
            if j != W - 1:
                t = max(t, S[i][j + 1] == "#")

            if not t:
                ans = False
                break

if ans:
    print("Yes")

else:
    print("No")


Measured memory_bytes: 9092
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

// int main(){
//     vector<ll> vec(10001);
//     vec[0] = 1;
//     for(int i=1;i<=10000;i++){
//         vec[i] = vec[i-1] + i;
//     }
//     int n;
//     while(cin >> n){
//         cout << vec[n] << endl;
//     }
//     return 0;
// }
int main(){
     int n;
     while(cin >> n){
         cout << n*(n+1)/2 +1 << endl;
     }
     return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

const int dx[] = { -1 , 0 , 0 , 1 } ;
const int dy[] = { 0 , -1 , 1 , 0 } ;

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    ll n ; cin >> n ;

    ll ans = LLONG_MAX ;
    for ( ll i=1 ; i*i <= n ; i++ )
    {
        if ( n % i ) C ;

        ll a = i ;
        ll  b = n/i ;

        ans = min ( ans , abs ( i-1 ) + abs ( b-1 ) ) ;
    }
    cout << ans ; line
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
#define Mod 1000000007
int n,m,dp[3005][3005][2],ans;
int main(void){
	register int i,j,l;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)dp[0][i][0]=1;
	dp[0][0][1]=1;
	for(i=0;i<m;++i)
		for(j=0;j<=n;++j)
			for(l=0;l<2;++l)
			if(dp[i][j][l]){
				if(!j){
					(dp[i+1][j][1]+=dp[i][j][l])%=Mod,
					(dp[i+1][j+1][1]+=dp[i][j][l])%=Mod;
				}else
				if(j==n){
					(dp[i+1][j][l|(j==1)]+=dp[i][j][l])%=Mod,
					(dp[i+1][j-1][l|(j==1)]+=dp[i][j][l])%=Mod;
				}else{
					(dp[i+1][j][l]+=dp[i][j][l])%=Mod,
					(dp[i+1][j+1][l]+=dp[i][j][l])%=Mod,
					(dp[i+1][j][l|(j==1)]+=dp[i][j][l])%=Mod,
					(dp[i+1][j-1][l|(j==1)]+=dp[i][j][l])%=Mod;
				}
			}
	for(i=0;i<=n;++i)
		(ans+=dp[m][i][1])%=Mod;  
    return printf("%d\n",ans),0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef long double LD; 
typedef long long ll; 
#define int ll 
#define ff(i,a,b) for (int i = a; i < b; i++) 
#define bf(i,a,b) for (int i = a; i >= b; i--) 
#define all(v) v.begin(),v.end() 
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define F first 
#define S second
#define pb push_back
#define mp make_pair
#define lb lower_bound   
#define ub upper_bound
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define one cout<<"-1"<<endl
#define pi 3.141592653589793238
#define intmx INT_MAX 
#define intmi INT_MIN
const int MOD=1e9+7;
int mod(int x){
    return ((x%MOD + MOD)%MOD);
}
int add(int a,int b){
    return mod(mod(a)+mod(b));
}
int mul(int a,int b){
    return mod(mod(a)*mod(b));
}
void solve(){
   bool x;
   cin>>x;
   if(x==0)
   cout<<"1";
   else
   cout<<"0";
}
signed main() {
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N;
    cin >> N;

    for (ll h = 1; h <= 3500; h++) {
        for (ll n = 1; n <= 3500; n++) {
            ll a = N * h * n;
            ll b = 4 * h * n - N * n - N * h;
            if (b <= 0 || a % b != 0) continue;
            cout << h << " " << n << " " << a / b << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int main(int argc, const char * argv[]) {
  ll N, W;
  cin >> N >> W;
  vector<ll> v1, v2, v3, v4;
  
  ll w1 = 0;
  for (int i = 0; i < N; i++) {
    ll wi, vi;
    cin >> wi >> vi;
    if (i == 0) {
      w1 = wi;
    }
    if (wi == w1 + 0) {
      v1.push_back(vi);
    }
    if (wi == w1 + 1) {
      v2.push_back(vi);
    }
    if (wi == w1 + 2) {
      v3.push_back(vi);
    }
    if (wi == w1 + 3) {
      v4.push_back(vi);
    }
  }
  sort(v1.begin(), v1.end(), greater<ll>());
  sort(v2.begin(), v2.end(), greater<ll>());
  sort(v3.begin(), v3.end(), greater<ll>());
  sort(v4.begin(), v4.end(), greater<ll>());
  
  int l1, l2, l3, l4;
  l1 = v1.size();
  l2 = v2.size();
  l3 = v3.size();
  l4 = v4.size();
  
  ll a1[l1 + 1] = {};
  ll a2[l2 + 1] = {};
  ll a3[l3 + 1] = {};
  ll a4[l4 + 1] = {};
  a1[1] = (l1 > 0) ? v1[0] : 0;
  a2[1] = (l2 > 0) ? v2[0] : 0;
  a3[1] = (l3 > 0) ? v3[0] : 0;
  a4[1] = (l4 > 0) ? v4[0] : 0;
  for (int i = 2; i < l1 + 1; i++) {
    a1[i] += (v1[i - 1] + a1[i - 1]);
  }
  for (int i = 2; i < l2 + 1; i++) {
    a2[i] += (v2[i - 1] + a2[i - 1]);
  }
  for (int i = 2; i < l3 + 1; i++) {
    a3[i] += (v3[i - 1] + a3[i - 1]);
  }
  for (int i = 2; i < l4 + 1; i++) {
    a4[i] += (v4[i - 1] + a4[i - 1]);
  }

  ll maxv= 0;
  for (int i1 = 0; i1 < l1 + 1; i1++) {
    for (int i2 = 0; i2 < l2 + 1; i2++) {
      for (int i3 = 0; i3 < l3 + 1; i3++) {
        for (int i4 = 0; i4 < l4 + 1; i4++) {
          ll w = w1 * i1 + (w1 + 1) * i2 + (w1 + 2) * i3 + (w1 + 3) * i4;
          if (w > W) {
            continue;
          }
          ll v = a1[i1] + a2[i2] + a3[i3] + a4[i4];
          maxv = max(maxv, v);
        }
      }
    }
  }

  cout << maxv << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

int H, W;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

char maze[MAX][MAX];
int path[MAX][MAX];

bool inrange(int x, int y) {
    return 0 <= x && x < W && 0 <= y && y < H;
}

int bfs(intP s) {
    queue<intP> q;
    q.push(s);
    path[s.second][s.first] = 1;
    while (!q.empty()) {
        intP n = q.front();
        q.pop();
        int x = n.first, y = n.second;
        rep(4, d) {
            int nx = x + dx[d], ny = y + dy[d];
            if (inrange(nx, ny) && maze[ny][nx] == '.' && path[ny][nx] == 0) {
                path[ny][nx] = path[y][x] + 1;
                q.push(intP(nx, ny));
            }
        }
    }
    return path[H-1][W-1];
}

void solve(void){
    cin >> H >> W;
    int cnt = 0;
    rep(H, i) scanf("%s\n", maze[i]);
    rep(H, i) rep(W, j) if (maze[i][j] == '.') cnt++;
    int score = bfs(intP(0, 0));
    
    if (!score) {
        cout << -1 << endl;
        return;
    }
    cout << cnt - score << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;
 
int N;
vector<int> v;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N;
  string S;
  cin >> S;
  N = S.length();
  int west = 0, east = 0;
  int cnt_west[N], cnt_east[N];
  for(int i=N-1; i>=0; --i){
    cnt_west[i] = west;
    west += (S[i] == 'W');
  }
  for(int i=0; i<N; ++i){
    cnt_east[i] = east;
    east += (S[i] == 'E');
  }
  int res = N;
  for(int i=0; i<N; ++i){
    res = min(res, N - 1 - cnt_east[i] - cnt_west[i]);
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 2964
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int k, a, b;
    cin >> k >> a >> b;
    if(a/k*k+k <= b || a%k == 0 || b%k == 0){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var k, s int
	fmt.Scan(&k, &s)

	ans := 0
	for x := 0; x <= k; x++ {
		for y := 0; y <= k; y++ {
			z := s - x - y
			if z >= 0 && z <= k {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B >= C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import bisect
n = int(input())
length_list = sorted(list(map(int, input().split())))
result = 0
 
for i in range(n-2):
  for j in range(i+1, n-1):
    upper = length_list[i] + length_list[j] - 1
    search_target = length_list[j+1:]
    less_than_upper = bisect.bisect_right(search_target, upper)
    result += less_than_upper
    
print(result)

Measured memory_bytes: 59192