akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=3005;
const int MOD=998244353;
int A,B,C,D;
long long dp[N][N];
long long dfs(int r,int c)
{
	if(r<A||c<B) return 0;
	if(dp[r][c]!=-1) return dp[r][c];
	int res=0;
	res=(res+dfs(r,c-1)*r%MOD)%MOD;
	res=(res+dfs(r-1,c)*c%MOD)%MOD;
	res=(res-dfs(r-1,c-1)*(r-1)%MOD*(c-1)%MOD+MOD)%MOD;
	return dp[r][c]=res;
}
int main()
{
	scanf("%d%d%d%d",&A,&B,&C,&D);
	memset(dp,-1,sizeof(dp));
	dp[A][B]=1;
	printf("%lld",dfs(C,D));
	return 0;
}

Measured memory_bytes: 74724
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int n,a,b,ans=0;
	cin>>n>>a>>b;
	rep(i,n){
		int t;
		cin>>t;

		if (t<a || b<=t){
			ans++;
		}
	}
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 256
#coding:utf-8
S = input()
def checkMonth(s):
    num = int(s[0]) * 10 + int(s[1])
    if num >= 1 and num <= 12:
        return True
    else:
        return False
early = S[:2]
late = S[2:]
#print (early,late)
earlyIsMonth = checkMonth(early)
lateIsMonth = checkMonth(late)
if earlyIsMonth and lateIsMonth:
    print ("AMBIGUOUS")
elif earlyIsMonth and not lateIsMonth:
    print ("MMYY")
elif not earlyIsMonth and lateIsMonth:
    print ("YYMM")
else:
    print ("NA")



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 2 + 10, INF = 1e9 * 1e9 + 10;

int main()
{
    fastInp;

    ll h, w;
    cin >> h >> w;

    if (h == 1 || w == 1) {
        cout << "1";
        return 0;
    }
    cout << (h * w - 1) / 2 + 1;
    
    
    return 0;
}

Measured memory_bytes: 3652
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int X = nextInt();
		int Y = nextInt();
		String ans = "";
		ans=String.valueOf(X+Y/2);




		System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 23252
#include <bits/stdc++.h> //abc177-C
using namespace std;
int main() {
    string s;
    cin >> s;

    if ((s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) || (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) || (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3624
N = input()
N = int(N)
a = input()
nums = a.split()
counter = 0
semi = 0
for i in range(N):
    n = int(nums[i])
    if n % 4 == 0:
        counter += 1
    elif n % 2 == 0:
        semi += 1
    else: continue
if counter >= N // 2 :
    print("Yes")
elif counter == 0 & semi == N:
    print("Yes")
elif semi >= (N - counter*2):
    print("Yes")
else:
    print("No")


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

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

const long long MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<double> a(n);
  rep(i,n) cin >> a.at(i);
  
  double ans = 0;
  
  rep(i,n) ans += 1/a.at(i);
  
  ans = 1 / ans;
  cout << fixed << setprecision(10);
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int A, B, C;
	int counter = 0;
	int zankin;

	scanf("%d %d %d", &A, &B, &C);

	zankin = B;

	while(counter<C && zankin>=A)
	{
		zankin = zankin -A;
		counter++;
	}

	printf("%d", counter);

	return 0;
}

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

long powm(long x, long a, long m)
{
    long s = 1;
    long p = x % m;
    for (int i = 0; i < 32; i++)
    {
        if((a >> i) & 1){
            s = (s * p) % m;
        }
        p = p*p % m;
    }
    return s;
}

long invm(long x, long m)
{
    return powm(x, m-2, m);
}

vector<long> ntbl, dtbl;
void conbm_init(long a, long m)
{
    ntbl.resize(a+1, 1);
    dtbl.resize(a+1, 1);
    long n = 1, d = 1;
    for (long i = 0; i < a; i++)
    {
        n = (n * (a - i)) % m;
        d = (d * (i + 1)) % m;
        ntbl[i] = n;
        dtbl[i] = d;
    }
}
long conbm(long a, long b, long m)
{
    if(ntbl.size() != a+1) conbm_init(a, m);
    return (ntbl[b-1] * invm(dtbl[b-1], m)) % m;
}

void Main()
{
    long mod = 998244353;
    long n, m, k;
    cin >> n >> m >> k;

    long ans = 0;
    long tmp = 1;
    for (int i = 0; i < n; i++)
    {
        long s = (i==0) ? m : m-1;
        tmp = tmp * s % mod;
        if(i+1 >= n-k) {
            ans += tmp * conbm(n-1, n-(i+1), mod) % mod;
            ans %= mod;
        }
    }
    
    cout << ans << endl;

}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 6368
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000,mod=1000000007;

int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        // #ifndef ONLINE_JUDGE
        //     freopen("input.txt","r",stdin);
        //     freopen("output.txt","w",stdout);
        // #endif
        ll sum=0;ll n;cin>>n;
        for(ll i=1;i<=n;i++){
            if(i%5&&i%3)sum+=i;
        }
        cout<<sum;

}


Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main()
{
	// スペース区切りの整数の入力
    long double D,T,S;
    cin >> D >> T >> S;
    
  	if(D/T<=S){
    	cout << "Yes" << endl;
    }
  	else{
         cout << "No" << endl; 
    }

    return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,t;
	scanf("%d%d",&a,&b);
	a=a*100;
	if(b==100)
		a*=10;
	if(b<10)
	{
		a/=10;
	}
	a+=b;
	t=sqrt(a);
	if(t*t==a)
		printf("Yes");
	else
		printf("No");
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x;
    long long ans=0;
    cin>>n>>x;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
        if(a[i]>x){ans+=a[i]-x;a[i]=x;}
        if(a[i]+a[i+1]>x){
            ans+=a[i]+a[i+1]-x;
            a[i+1]=x-a[i];
            }
    }
    cout<<ans;
}

Measured memory_bytes: 640
#include<stdio.h>
typedef struct Node{
  int parent,left,right;
}Node;  
Node T[100000];
int n,D[100000];
void print(int p){
  int i,s;
  printf("node %d: parent = %d, depth = %d, ", p, T[p].parent, D[p]);
  if(T[p].parent==-1)
    printf("root, [");
  else if(T[p].left==-1)
    printf("leaf, [");
 else
    printf("internal node, [");
  s = T[p].left;
  for(i = 0; s!=-1;i++,s = T[s].right){
    if(i)
      printf(", "); 
    printf("%d", s);
  } 
  printf("]\n");
} 
int depth(int x, int y){
  D[x]=y;
   
  if(T[x].right!=-1){
    depth(T[x].right, y);
  }
  if(T[x].left!=-1){
    depth(T[x].left, y+1);
  }
}
int main(){
  int a,b,c,left,right,i,j;
  scanf("%d", &n);
  for(i=0; i<n; i++)
    T[i].parent=T[i].left=T[i].right=-1;   
  for(i=0;i<n;i++){
    scanf("%d%d",&a,&b);    
    for(j=0;j<b;j++){
      scanf("%d",&c); 
      if(j==0)
    T[a].left=c;    
      else
    T[left].right=c;  
      left = c;
      T[c].parent=a;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].parent==-1)
      right=i;
  }
  depth(right, 0);
  for(i=0;i<n;i++)
    print(i);
  return 0;
}

Measured memory_bytes: 5296
import math
INF = 10**9+7

n = int(input())
m = int(math.sqrt(n))
b = INF
for i in range(1,m+1):
    if n%i==0:
        a = max(i,n//i)
        b = min(b,a)
    else:
        continue
print(len(str(b)))

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define getBit(x,i) (x&(1<<i))
#define setBit(x,i) (x|(1<<i))
#define mem(A,N) memset(A,N,sizeof(A))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define rep(i, x, y)  for(int i = x; i < y; ++i)
#define Rep(i, x, y)  for(int i = x; i <= y; ++i)
#define srep(i, x, y) for(int i = x; i > y; --i)
#define sRep(i, x, y) for(int i = x; i >= y; --i)
#define all(v) v.begin(),v.end()
#define Sort(x) sort(x.begin(), x.end())
#define f1(i,n) for (int i=1; i<=n; i++)
#define f0(i,n) for (int i=0; i<n; i++)
#define sz(x) ((int)(x).size())
#define len(x) ((int)(x).length())
#define fi first
#define se second

#define linf 0x7FFFFFFFFFFFFFFF
#define inf 0x7FFFFFFF
#define mod 1000000007
#define eps 1e-9
#define Pi 3.14159265358979323846

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define write(x) cerr << #x << " = " << (x) << ", "
#define writeI0 cerr << "i = " << 0 << ", "
#define dumpI0 cerr << "i = " << 0 << endl
#define printSet(x) for(auto it = s.begin(); it!=s.end(); it++) (it==s.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printVector(x) for(auto it = x.begin(); it!=x.end(); it++) (it==x.begin())? cout << *it : cout << ' ' << *it; cout << endl;
#define printArray(a,x,y) for(auto it = a+x; it != a+y; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;
#define PrintArray(a,x,y) for(auto it = a+x; it != a+y+1; it++) (it==a+x)? cout << *it : cout << ' ' << *it; cout << endl;

// ***************** End Of Template ********************

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a*n, b);
    return 0;
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i, n)
    cin >> v.at(i);
  
  ll k = 1;
  ll ans = 0;
  ll cnt = 0;
  rep(i, n){
    if(v.at(i) == k)
      k++;
    else{
      ans++;
      cnt ++;
    }
  }
  
  if(cnt == n)
    cout << -1 << endl;
  else
    cout << ans << endl;
}

Measured memory_bytes: 4848
n = int(input())
w = list(map(int,input().split()))
l = []
for i in range(n-1):
    w1 = w[0:i+1]
    w2 = w[i+1:len(w)]
    t = sum(w1)
    s = sum(w2)
    l.append(abs(t-s))
print(min(l))

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

long long gcd(long long x,long long y){
  return y==0?x:gcd(y,x%y);
}

int main(){
  //freopen("aa.in","r",stdin);
  int _;scanf("%d",&_);
  for(;_--;){
    long long A,B,C,D;
    scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
    if(A<B||D<B){puts("No");continue;}
    if(C>=B-1){puts("Yes");continue;}
    long long G=gcd(B,D);
    A%=G;
    if(-G+A>=C-B+1)puts("No");
    //if(A==0&&-G>=C-B+1||A&&A>=C-B+1)puts("No");
    else puts("Yes");
  }
  return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
#define p 998244353
using namespace std;
inline ll read(){
    ll x = 0; char zf = 1; char ch = getchar();
    while (ch != '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int i,j,k,m,n,x,y,z,cnt,sum;
int main(){
	ll a=r,b=r,c=r,d=r;
	cout<<(a-c)*(b-d);
    return 0;
}








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

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
bool e[101][101] = {};
int main(){

    cin >> N;
    int M = 0;
    if(N % 2 == 0){
        for(int i = 0; i < N; i++){
            for(int j = i + 1; j < N; j++){
                if(i + j + 1 != N){
                    e[i][j] = 1;
                    M++;
                }
            }
        }
    }
    else{
        for(int i = 0; i < N; i++){
            for(int j = i + 1; j < N; j++){
                if(i + j != N - 2){
                    e[i][j] = 1;
                    M++;
                }
            }
        }
    }

    cout << M << endl;
    

    // for(int y = 0; y < N; y++){
    //     for(int x = 0; x < N; x++){
    //         if(y >= x) cout << "# " ;
    //         else cout << e[y][x] << " ";
    //     }
    //     cout << endl;
    // }

    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            if(e[i][j])
            cout << i + 1 << " " << j + 1 << endl;
        }
    }

    // N = 8;
    // for(int mask = 0; mask < (1 << (N * (N - 1) / 2)); mask++){
    //     bool e[10][10] = {};
    //     int c = 0;
    //     for(int y = 0; y < N; y++){
    //         for(int x = y + 1; x < N; x++){
    //             if((mask >> c) & 1){
    //                 e[y][x] = true;
    //                 e[x][y] = true;
    //             }
    //             c++;
    //         }
    //     }
    //     int tot = 0;
    //     for(int j = 0; j < N; j++){
    //         if(e[0][j]){
    //             tot += j + 1;
    //         }
    //     }
    //     if(tot==0)continue;
    //     bool ok = true;
    //     for(int i = 1; i < N; i++){
    //         int sum = 0;
    //         for(int j = 0; j < N; j++){
    //             if(e[i][j]){
    //                 sum += j + 1;
    //             }
    //         }
    //         if(sum != tot) ok = false;
    //     }
    //     if(ok){
    //         for(int y = 0; y < N; y++){
    //             for(int x = 0; x < N; x++){
    //                 if(y >= x) cout << "# " ;
    //                 else cout << e[y][x] << " ";
    //             }
    //             cout << endl;
    //         }
    //         cout<<endl;
    //         // return 0;
    //     }
    // }

    return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<string , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  int hi = 0;
  map<string, int> mp;
  rep(i, n) {
    string s; cin >> s;
    ++mp[s];
     hi = max(hi, mp[s]);
  }
  for(auto a : mp) {
    if(a.second == hi) cout << a.first << endl;
  }
}


Measured memory_bytes: 23808
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {
    
    string S;
    cin >> S;
    for(int i=0;i<S.length();i++) S[i] = 'x';
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n;
    int i;

    scanf("%d",&n);

    int b[n-1];
    for(i=0;i<n-1;i++){
        scanf("%d",&b[i]);
    }

    int sum_a=b[0];

    for(i=0;i<n-2;i++){
        if(b[i]>=b[i+1]) {
            sum_a+=b[i+1];
        }else{
            sum_a+=b[i];
        }
    }
    sum_a+=b[n-2];

    printf("%d\n",sum_a);
    return 0;
}


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

int main(void){
    int n,p,m;
    cin >> n;
    m=n+1;
    int ans=0;
    rep(_,n){
        cin >> p;
        if(p<m){
            ans++;
            m=p;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	
	int a,b;
	cin>>a>>b;
	if(a==2){
		cout<<"No"<<endl;
	}
	
	else if(b==2){
		cout<<"No"<<endl;
	}
	
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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)

typedef long long ll;

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

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    a += b;
    int t = stoi(a);
    rep(i, sqrt(t) + 1) {
      if (i * i == t) {
        cout << "Yes" << '\n';
        return 0;
      }
    }
    cout << "No" << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <string> v;

int calc(int node){
    vector <int> vis(n);
    vector <int> cur;
    cur.push_back(node);
    vis[node] = 1;
    int ret = 0;
    while(1){
        ret++;
        vector <int> new_cur;
        for(auto &i : cur){
            for(int j = 0 ; j < n ; j++){
                if(v[i][j] == '0') continue;
                if(vis[j]) continue;
                vis[j] = 1;
                new_cur.push_back(j);
            }
        }
        if(new_cur.size() == 0) break;
        swap(cur, new_cur);
        for(auto &i : cur){
            for(auto &j : cur){
                if(v[i][j] == '1'){
                    return -1;
                }
            }
        }
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    v.resize(n);
    for(auto &i : v) cin >> i;
    int ans = -1;
    for(int i = 0 ; i < n ; i++){
        ans = max(ans, calc(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int a[256];char s[256];
int main()
{
    cin>>s;int l=1;
    for(int i=0; s[i]; i++)a[s[i]]=1,l++;
    for(int c='z'; c>='a'; c--)
        if(!a[c])s[l++]=c;
    if(next_permutation(s,s+l)) cout<<s;
    else cout<<-1;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    a = list(map(int, input().split()))
    ans = "APPROVED"
    for i in range(N):
        if a[i] % 2 ==0:
            if a[i] % 3 != 0 and a[i] % 5 != 0:
                ans = "DENIED" 
    print(ans)

main()

Measured memory_bytes: 2940
function bomb(y,x,first,color){
   var dy=[-1,0,0,1];
   var dx=[0,-1,1,0];
   for(var i=0;i<4;i++){
      var X=x+dx[i];
      var Y=y+dy[i];
      if(X<0 || Y<0 || X>=w || Y>=h)continue;
      if(yx[Y][X]==first){
         yx[Y][X]=color;
         cnt++;
         bomb(Y,X,first,color);
      }
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var all=[];
var loop=function (ary){
   if(ary.length==4)all.push(ary);
   else{
      for(var i=1;i<=6;i++)loop(ary.concat(i));
   }
};
loop([]);
while(true){
   var hwc=arr.shift();
   if(hwc=="0 0 0")break;
   hwc=hwc.split(" ").map(Number);
   var h=hwc[0];
   var w=hwc[1];
   var c=hwc[2];
   var panel=[]
   for(var i=0;i<h;i++)panel.push(arr.shift().split(" ").map(Number));
   var max=0;
   var yx=[];
   var cnt=1;
   all.forEach(function(v,index){
      yx=[];
      for(var i=0;i<h;i++)yx.push(panel[i].slice());
      v=v.concat(c);
      v.forEach(function(value){
         var first=yx[0][0];
         yx[0][0]=value;
         if(value!=first)bomb(0,0,first,value);
      });
      cnt=1;
      yx[0][0]=0;
      bomb(0,0,c,0);
      max=Math.max(max,cnt);
   });
   console.log(max);
}

Measured memory_bytes: 20836
package main

import "fmt"

func main() {
	var a, b, c, d, e, f int
	fmt.Scan(&a, &b, &c, &d, &e, &f)

	mw := make(map[int]bool)
	ms := make(map[int]bool)

	a = a * 100
	b = b * 100

	for i := 0; i*a <= f; i++ {
		for j := 0; j*b <= f-i*a; j++ {
			mw[a*i+b*j] = true
		}
	}

	for i := 0; i*c <= f; i++ {
		for j := 0; j*d <= f-i*c; j++ {
			ms[c*i+d*j] = true
		}
	}

	var maxW, maxS int

	// water
	for i := 0; i <= f; i++ {
		// sugar
		for j := 0; j <= f-i && i*e >= j*100; j++ {
			if !(mw[i] && ms[j]) {
				continue
			}
			if j*(maxW+maxS) >= (i+j)*maxS {
				maxW, maxS = i, j
			}
		}
	}

	fmt.Println(maxW+maxS, maxS)
}

func dencity(water, sugar int) float64 {
	if water+sugar == 0 {
		return 0
	}
	return float64(100*sugar) / float64(water+sugar)
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

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

	string *taro = new string[n];
	string *hanako = new string[n];

	for (int i = 0; i < n; i++)
		cin >> taro[i] >> hanako[i];

	int pointTaro = 0, pointHanako = 0;
	for (int i = 0; i < n; i++){
		if (taro[i] == hanako[i]){
			pointTaro++;
			pointHanako++;
		} else if (taro[i] > hanako[i]){
			pointTaro += 3;
		} else {
			pointHanako += 3;
		}
	}

	cout << pointTaro << " " << pointHanako << endl;

	delete[] hanako;
	delete[] taro;

	return 0;
}



Measured memory_bytes: 3260
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
long long n,m,i,j,a[200005],pre[200005],suf[200005],ans;
int main()
{
	scanf("%lld%lld",&n,&m);
	fz1(i,n){
		scanf("%lld",&a[i]);
		pre[i]=pre[i-1]+max(a[i],0ll);
	}
	fd1(i,n){
		suf[i]=suf[i+1]+max(a[i],0ll);
	}
	fz1(i,n){
		a[i]+=a[i-1];
	}
	fz1(i,n-m+1){
		ans=max(ans,a[i+m-1]-a[i-1]+pre[i-1]+suf[i+m]);
		ans=max(ans,pre[i-1]+suf[i+m]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    cin >> N;
    vector<ll> A, B;
    rep(i,N){
        ll inp;
        cin >> inp;
        inp -= (i+1);
        A.pb(inp);
        B.pb(inp);
    }
    
    sort(all(A));
    
    ll m1 , m2;
    m1 = A[A.size()/2];
    m2 = A[A.size()/2-1];

    ll ans1 = 0;
    ll ans2 = 0;
    
    rep(i,N){
        ans1 += abs(B[i]-m1);
        ans2 += abs(B[i]-m2);
    }
    cout << min(ans1, ans2) << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define INF 1000000000000000
#define MAX (int)(1e6)+1
#define MOD 1000000007

using namespace std;

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,int> pwi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector< vector<pair<int,lli > > > wGraph;
typedef vector<vector<int> > graph;
//typedef vector<vector<int> > matrix;

vi parent(MAX);
vi siz(MAX);

void make_set(int n){
    parent[n] = n;
    siz[n] = 1;
}

int find_set(int v){
    if(parent[v]==v){
        return v;
    }
    return parent[v] = find_set(parent[v]);
}

void union_set(int a,int b){
    a = find_set(a);
    b = find_set(b);
    if(a!=b){

        if(siz[a] < siz[b])
            swap(a,b);
        parent[b] = a;
        siz[a]+=siz[b];
    }
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(2);

    int n,m;

    cin>>n>>m;

    rep(i,n) make_set(i);

    rep(i,m){
        int a,b,z;
        cin>>a>>b>>z;
        union_set(a-1,b-1);
    }

    int res = 0;
    rep(i,n){
        if(parent[i] == i){
            res++;
        }
    }

    cout<<res<<"\n";

    return 0;

}


Measured memory_bytes: 8064
#include "bits/stdc++.h"

using namespace std;

const long long MOD = 1000000007;

long long calc(const vector<long long>& X) {
    long long N = X.size();
    vector<long long> accum(N + 1, 0LL);
    accum[0] = 0LL;
    for (long long i = 0; i < N; ++i) {
        accum[i + 1] = X[i] + accum[i];
    }

    long long ret = 0LL;
    if (N % 2 == 1) {
        long long nloop = (N - 1) / 2;
        for (long long i = 1; i <= nloop; ++i) {
            ret += 2LL * (accum[N] - accum[N - i]);
            ret %= MOD;
            ret -= 2LL * (accum[i] - accum[0]);
            ret %= MOD;
        }
    }
    else {
        long long nloop = (N - 2) / 2;
        for (long long i = 1; i <= nloop; ++i) {
            ret += 2LL * (accum[N] - accum[N - i]);
            ret %= MOD;
            ret -= 2LL * (accum[i] - accum[0]);
            ret %= MOD;
        }
        ret += accum[N] - accum[N / 2];
        ret %= MOD;
        ret -= accum[N / 2] - accum[0];
        ret %= MOD;
    }

    return ret;
}

void Main() {
    long long N, M;
    cin >> N >> M;
    vector<long long> X(N, 0), Y(M, 0);
    for (long long i = 0; i < N; ++i) {
        cin >> X[i];
    }
    for (long long i = 0; i < M; ++i) {
        cin >> Y[i];
    }

    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());

    long long accumX = calc(X);
    long long accumY = calc(Y);

    long long ans = accumX * accumY;
    ans %= MOD;
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 5552
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N, A, B;
    cin >> N >> A >> B;
    long long ans;
    if(A > B || (A < B && N == 1)) ans = 0;
    else ans = (N - 2) * (B - A) + 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e6+100;
int n,v2[maxn],fa[maxn];
LL v[maxn],sz[maxn],ds[maxn];
map<LL,int> tp;
bool cmp(int a,int b){return v[a]<v[b];}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&v[i]),tp[v[i]]=i,v2[i]=i,sz[i]=1;
	sort(v2+1,v2+n+1,cmp);
	for(int i=n;i>1;i--){
		long long tp2=v[v2[i]]-n+sz[v2[i]]*2;
		if(!tp[tp2]){
			puts("-1");
			return 0;
		}
		int sb=tp[tp2];
		ds[sb]+=ds[v2[i]]+sz[v2[i]];
		sz[sb]+=sz[v2[i]];
		fa[v2[i]]=sb;
	}
	if(ds[v2[1]]!=v[v2[1]]) puts("-1");
	else for(int i=1;i<=n;i++) if(fa[i]) printf("%d %d\n",i,fa[i]);
	return 0;
}

Measured memory_bytes: 20736
s=input()
n=len(s)
for i in range(2**(n-1)):
    sum=int(s[0])
    op = []
    for j in range(n-1):
      if ((i>>j)&1):
          sum+=int(s[j+1])
          op.append('+')
      else:
          sum-=int(s[j+1])
          op.append('-')
    if sum == 7:
        ans = s[0]
        for i in range(n-1):
            ans += op[i]
            ans += s[i+1]
        ans += '=7'
        print(ans)
        break

Measured memory_bytes: 3064
n=int(input())
p=[3,13,23,43,53,73,103,113,163,173,193,223,233,263,283,293,313,353,373,383,443,463,503,563,593,613,643,653,673,683,733,743,773,823,853,863,883,953,983,1013,1033,1063,1093,1103,1123,1153,1163,1193,1213,1223,1283,1303,1373,1423,1433,1453,1483,1493]
for i in range(n):
    print(p[i],end=' ')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
int a[214514];
int b[214514];
using namespace std;
signed main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(n%2==0){
        for(int k=0;k<n;k++){
            if(k%2==0){
                b[k/2+n/2]=a[k];
            }
            else{
                b[n/2-k/2-1]=a[k];
            }
        }
    }
    else{
        for(int m=0;m<n;m++){
            if(m%2==0){
                b[n/2-m/2]=a[m];
            }
            else{
                b[n/2+m/2+1]=a[m];
            }
        }
    }
    for(int j=0;j<n;j++){
        cout<<b[j]<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
  int A;
  int B;
  cin >> A >> B;
  if(A * B % 2 == 0)
  {
    cout << "Even" << endl;
  }
  else
  {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 3584
#if 1
  #include <bits/stdc++.h>
#else
  #include "../../bits/stdc++.h"
#endif

#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))

using namespace std;

typedef pair<int, int> P;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second

#define MAX_N 102

int n, m;
int t[MAX_N], h[MAX_N];

bool input(){
  cin>>n>>m;
  REP(i, n)cin>>t[i];
  REP(i, m)cin>>h[i];
  return n|m;
}

void solve(){
  int st=0, sh=0, a;
  int pt=-1, ph=-1;
  REP(i, n)st+=t[i];
  REP(i, m)sh+=h[i];
  if((st+sh)%2) {
    cout<<-1<<endl;
    return ;
  }
  a = (st+sh)/2;
  REP(i, n) {
    REP(j, m) {
      if((st-t[i]+h[j])==a) {
        if(pt<0) {
          pt=t[i];
          ph=h[j];
        }else {
          if(pt+ph>t[i]+h[j]) {
            pt=t[i];
            ph=h[j];
          }
        }
      }
    }
  }
  if(pt<0) {
    cout<<-1<<endl;
    return ;
  }
  cout<<pt<<' '<<ph<<endl;
}

int main(){
  cin.tie(0);
  
  while (input()){
      solve();
  }
  
  return 0;
}

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


bool is_prime(ll N) {
    if (N == 1) return false;
    for (ll i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int main() {
    int Q;
    cin >> Q;
    vector<int> l(Q), r(Q);
    rep(i,Q) cin >> l[i] >> r[i];
    
    vector<int> prime_v(100000);
    for (int i = 3; i <= 100000; i += 2) {
        if(is_prime(i) && is_prime((i+1)/2)) ++prime_v[i];
    }
    for (int i = 3; i <= 100000; i += 2) prime_v[i] += prime_v[i-2];

    rep(i,Q) {
        if (l[i] == 1) cout << prime_v[r[i]] << endl;
        else cout << prime_v[r[i]] - prime_v[l[i]-2] << endl;
    }
}



Measured memory_bytes: 4244
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,k=1;
char s[100005];
bool h[100005];
vector<P>ans;
void dfs(int v,int p){
    k++;
    for(int i=p-1;i>0;i--){
        if(h[i]){
            for(int j=0;j<p-1-i;j++){
                ans.PB(P(v,k++));
            }
            ans.PB(P(v,k));
            dfs(k,i);
            break;
        }
    }
}
int main(void){
    cin>>s;
    n=strlen(s);
    if(s[0]=='0'||s[n-1]=='1'){
        cout<<"-1\n";
        return 0;
    }
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[n-i-2]){
            cout<<-1<<endl;
            return 0;
        }
        if(i<(n+1)/2&&s[i]=='1')h[i+1]=true;
    }
    for(int i=(n+1)/2;i>0;i--){
        if(h[i]){
            for(int j=0;j<n-i-1;j++){
                ans.PB(P(0,k++));
            }
            ans.PB(P(0,k));
            dfs(k,i);
            break;
        }
    }
    for(int i=0;i<ans.size();i++)cout<<ans[i].F+1<<' '<<ans[i].S+1<<endl;
}


Measured memory_bytes: 5364
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    static int tc=1;
    static String[] s;
 
    public static long[] ila(String[] s){
        long[] array=new long[s.length];
        for(int i=0;i<array.length;i++)
            array[i]=Long.parseLong(s[i]);
        return array;
    }
    public static void main (String[] args) throws java.lang.Exception
    {
        //tc=Integer.parseInt(br.readLine());
        t:
        while(tc-->0){
		  String[] days={"SUN","MON","TUE","WED","THU","FRI","SAT"};
		  ArrayList<String> al=new ArrayList<>();
		  for(int i=0;i<days.length;i++){
		  	al.add(days[i]);
		  }
		  String str=br.readLine();
		  int x=al.indexOf(str);
		  int ans=7-x;
		  if(ans==0)
			System.out.println(7);
		  else
			System.out.println(ans);
        }
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18
int main(){
    ll n;
    cin>>n;
    string ans="";
    while(n!=0){
        char hoge='0'+abs(n%2);
        n-=abs(n%2);
        ans=hoge+ans;
        n/=-2;
    }
    if(ans=="")ans="0";
    cout<<ans<<endl;
}

Measured memory_bytes: 256
function main(input) {
    const args = input.split('\n');
    const Fir = args[0].split(' ');

    const N = parseInt(Fir[0]);
    const H = parseInt(Fir[1]);
    const W = parseInt(Fir[2]);

    var ans = 0;

    for(var i = 1; i <= N; i++) {
        var materials = args[i].split(' ');
        var material_H = parseInt(materials[0]);
        var material_W = parseInt(materials[1]);

        if (H <= material_H && W <= material_W) {
            ans++;
        }
    }
    console.log(ans);

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;


#include <random>

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

    int D;
    cin>>D;
    int c[26];
    int q[D];
    rep(i,26){
        cin>>c[i];
    }
    int s[D][26];
    rep(i,D){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int ans=0;
    int l[26]{};
    int y=0;
    rep(i,D){

        int an=-INF;
        int x=0;
        rep(k,26){
            int a=ans;
            int la[26];
            rep(_,26){
                la[_]=l[_];
            }
            a+=s[i][k];
            rep(j,26){
                if(j==k){
                    la[k]=0;
                }else{
                    la[j]++;
                    a-=la[j]*c[j];
                }
            }
            if(an<a){
                x=k;
                an=a;
            }
        }
        y=x;
        ans+=s[i][y];
        rep(j,26){
            if(j==y){
                l[y]=0;
            }else{
                l[j]++;
                ans-=l[j]*c[j];
            }
        }
        y++;
        q[i]=y;
    }

    int tr=0;
    std::random_device rnd; 
    while(tr<=145000){
        int g=rnd()%26;
        int h=rnd()%26;
        tr++;
        int ansm=0;
        int r[D];
        rep(i,D){
            if(i==g){
                if(h!=q[i]){
                    r[i]=h;
                }else{
                    r[i]=rnd()%26;
                }

            }else{
                r[i]=q[i];
            }
        }
        int lx[26]{};
        rep(i,D){
            ansm+=s[i][r[i]];
            rep(j,26){
                if(j==r[i]){
                    lx[r[i]]=0;
                }else{
                    lx[j]++;
                    ansm-=lx[j]*c[j];
                }
            }
        }
        if(ansm>ans){
            rep(i,D){
                q[i]=r[i];
            }
            ans=ansm;
        }
    }
    rep(i,D){
        cout << q[i] << endl;
    }

    



}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
typedef pair<double,int> P;
int n,m;
int a[10001];
int b[10001];
int c[10001];
int d[10001];


//????°???¨?????¨
#define MAX_N 20001
int par1[MAX_N];
int rank1[MAX_N];

//?????????
void init(int n){
   for(int i=0;i<n;i++){
       par1[i]=i;
       rank1[i]=0;
   }
}
//??¨??????????±???????
int find(int x){
    if(par1[x]==x){
       return x;
    }else{
       return par1[x]=find(par1[x]);
    }
}
//x??¨y????±??????????????????????
void unite(int x,int y){
   x=find(x);
   y=find(y);
   if(x==y) return;
   if(rank1[x]<rank1[y]){
        par1[x]=y;
   }else{
        par1[y]=x;
        if(rank1[x]==rank1[y]){
             rank1[x]++;
        }
   }
}
//x??¨y???????????????????±????????????????
bool same(int x,int y){
     return find(x) == find(y);
}

//MST
double MST(vector<P> ma){
   init(n+10);
   double cost=0;
   for(auto it=ma.begin();it!=ma.end();it++){
      int aa=a[it->second];
      int bb=b[it->second];
      if(!same(aa,bb)){
          unite(aa,bb);
      }else{
          cost+=it->first;
          //cout<<it->first<<endl;
      }
   }
   return cost;
}

bool check(double x){
   //?????????????????????
   vector<P> ma;
   //
   REP(i,m){
      //cout<<"X"<<x<<endl;
      double aa=(x*c[i]-d[i]);
      ma.push_back(make_pair(aa,i));
   }
   sort(ma.begin(),ma.end());
   //cout<<MST(ma)<<endl;
   return MST(ma)>=0;
}

double binary_search(){
   double lb=0;
   double ub=1e10;
   REP(i,300){
       double mid=(lb+ub)/2;
       if(check(mid)){
          ub=mid;
       }else{
          lb=mid;
       }
   }
   return ub;
}

int main(){
    cin>>n>>m;
    REP(i,m){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    //cout<<check()<<endl;
    cout<<fixed<<setprecision(12)<<binary_search()<<endl;
    return 0;
}

Measured memory_bytes: 3644
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n,a = imap()
x = np.array(iarr()) - a

# dp[i][和 + NA]
# 本来のSの範囲は、1N-NAから50N-NA
# 負の数はdp範囲外なのでNAたすと、1Nから50N
# 和０のときは dp[n][0+NA]
dp = np.zeros((n+1, 50*n+1)).astype(int)
dp[0][n*a] = 1

for i in range(n):
    for s in range(50*n+1):
        dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if 50*n>= s-x[i] >=0 else dp[i][s]

ans = dp[n][n*a] - 1 #実際は初期条件の０個選ぶパターンを除外
print(ans)




Measured memory_bytes: 17760
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	REP(i, n){
		cin >> a[i];
	}
	REP(i, n-k){
		if(a[i] < a[i+k]){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4840
H = int(input())

cnt = 0
result = 0


def gener():
  now = 3
  while True:
    yield now
    now = now*2+1


if H == 1:
  print(1)
elif H == 2 or H == 3:
  print(3)
else:
  while True:
    if H <= 1:
      break
    cnt += 1
    H = int(H / 2)

  
  gen = gener()
  gen.__next__()

  for i in range(int(cnt)):
    if i == cnt-2:
      result = gen.__next__()
      print(result)
    else:
      gen.__next__()








Measured memory_bytes: 3064
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
sum = arr.sum
ans = []
m = gets.to_i
m.times do
  p,x = gets.chomp.split(' ').map(&:to_i)
  ans.push(sum - (arr[p-1] - x))
end
puts ans


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

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

    ll d = c - a - b;
    if ( d > 0 && d *d > 4 * a * b ) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	int h = t / 3600;
	int m = (t - 3600 * h) / 60;
	int s = (t - 3600 * h) % 60;

	cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3096
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  char op;
  cin >> a >> op >> b;
  while(op!='?'){
    int c;
    if(op=='+') c=a+b;
    if(op=='-') c=a-b;
    if(op=='*') c=a*b;
    if(op=='/') c=a/b;
    cout << c << endl;
    cin >> a >> op >> b;
  }
  return 0;
}



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

int main()
{
    using namespace std;
    int32_t N, M, X;
    cin >> N >> M >> X;

    vector<int32_t> A(N+1, 0);
    for (auto j=0; j < M; ++j) {
        int32_t idx;
        cin >> idx;
        A[idx] = 1;
    }
    
    int32_t left=0, right=0;
    for (auto j=X; j < N; ++j) {
        right += A[j];
    }
    
    for (auto j=X; 0 < j; --j) {
        left += A[j];
    }
    
    cout << min(left, right) << endl;
}

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

int gcd(int x, int y){
  while(x>0 && y>0){
    if(y>x){
      swap(x,y);
    }
    x %= y;
  }
  return y;
}

long lcm(long x, int y){
  int g = gcd(x, y);
  return (x * y) / g;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    a.at(i) /= 2;
  }
  long l = 1;
  for(int i=0;i<n;i++){
    l = lcm(l,a.at(i));
  }
  if(l > m){
    cout << 0 << endl;
  }else{
    for(int i=0;i<n;i++){
      if((l / a.at(i)) % 2 == 0){
        cout << 0 << endl;
        break;
      }
      if(i==n-1){
        cout << 1+(m-l)/(2*l) << endl;
      }
    }
  }
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		int n=Integer.valueOf(s);
		int x=n%10;
		if(x==2 || x==4 || x==5 || x==7 || x==9)
			System.out.println("hon");
		else if(x==0 || x==1 || x==6 || x==8)
			System.out.println("pon");
		else
			System.out.println("bon");
	}

}


Measured memory_bytes: 32640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
    int a, b;
    bool operator < (ii o) const {
        return tie(a, b) < tie(o.a, o.b);
    }
};
struct iii {
    int a, b, c;
    bool operator < (iii o) const {
        return tie(a, b, c) < tie(o.a, o.b, o.c);
    }
};

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 1000005;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    int x;
    cin >> x;
    cout << (x^1) << "\n";
}


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

int main(){
  int n; cin >>n;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  int cnt4 = 0, cnt2 = 0, cnt1 = 0;
  for(int x : a){
    if(x%4==0) cnt4++;
    else if(x%2==0) cnt2++;
    else cnt1++;
  }
  if(cnt2==0) {
    if(cnt4+1>=cnt1) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else {
    if(cnt4>=cnt1) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0; 
}

Measured memory_bytes: 3780