akhauriyash/Code-Regression huggingface dataset:
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    ll x, y, z;
    cin >> x >> y >> z;
    ll storage;
    ll multiple;
        if (x > 0) {
            multiple = x/z;
            if (multiple >= y) {
                x = x - y*z;
                cout << x;
                return 0;
            }
            storage = (y - multiple) % 2;
            if (storage == 1) {
                x -= z * (multiple + 1);
            }
            else {
                x -= z * (multiple);
            }
        }
        else {
            multiple = abs(x)/z;
            if (multiple >= y) {
                x = x + y*z;
                cout << abs(x);
                return 0;
            }
            storage = (y - multiple) % 2;
            if (storage == 1) {
                x += z * (multiple + 1);
            }
            else {
                x += z * (multiple);
            }
        }
    cout << abs(x);
}



Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int mod=998244353;
#define N 3030
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int dp[N][N],A,B,C,D;
int main(){
	A=read(),B=read(),C=read(),D=read();
	dp[A][B]=1;
	for(int i=A;i<=C;++i){
		for(int j=B;j<=D;++j){
			if(i==A&&j==B)continue;
			dp[i][j]=(1LL*dp[i-1][j]*j+1LL*dp[i][j-1]*i-1LL*dp[i-1][j-1]*(i-1)%mod*(j-1)%mod+mod)%mod;
		}
	}
	printf("%d\n",dp[C][D]);
	return 0;
}



Measured memory_bytes: 39220
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	static int d[];
	static List<edge> edges;

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

		int V = sc.nextInt(); //頂点の数
		int E = sc.nextInt(); //辺の数
		int r = sc.nextInt(); //始点の番号

		d = new int[V];
		edges = new ArrayList<>();

		for(int i = 0; i < E; i++){
			int start = sc.nextInt();
			int end = sc.nextInt();
			int cost = sc.nextInt();

			edges.add(new edge(start, end, cost));
		}

		execDijkstra(r);

		for(int i=0; i<d.length; i++){
			if(d[i] == Integer.MAX_VALUE/2){
				System.out.println("INF");
			}else {
				System.out.println(d[i]);
			}
		}
	}

	static void execDijkstra(int now){
		Arrays.fill(d, Integer.MAX_VALUE/2);
		d[now] =0;

		while(true){
			boolean judge =false;
			for(edge e: edges){
				if(d[e.to]> d[e.from] + e.cost){
					d[e.to] = d[e.from] + e.cost;
					judge = true;
				}
			}
			if(!judge){
				break;
			}
		}
	}

	static class edge{
		int from;
		int to;
		int cost;

		public edge(int a, int b, int c) {
			this.from =a;
			this.to = b;
			this.cost = c;
		}
	}
}


Measured memory_bytes: 316568
using System;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int M = cin.nextInt();
        int[] X = cin.arrayInt();
        int[] D = new int[M - 1];

        Array.Sort(X);

        for (int i = 0; i < M - 1; i++)
        {
            D[i] = X[i + 1] - X[i];
        }

        Array.Sort(D);

        int ret = 0;
        for (int i = 0; i < M - N; i++)
        {
            ret += D[i];
        }

        Console.WriteLine(ret);
    }
}


class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 19552
#include <iostream>
#include <vector>
#include <cstring>



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

using namespace std;

int main(){
    string S;
    cin >> S;
    ll res = 0;

    REP(i,S.size())
    {
        res += S[i] - '0';

    }

    string ans;

    ll N;
    N = stoi(S);

    if(N % res == 0)ans = "Yes";
    else ans = "No";

    cout << ans << endl;
}




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

int main()
{
    while(1){
        int N,ans=0;
        cin>>N;
        if(N==0)
            break;
        for(int i=2;i*i/2<N;i++){
            if(i%2==0){
                if(N%i==i/2)
                    ans++;
            }
            if(i%2==1){
                if(N%i==0)
                    ans++;
            }
        } cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
X = int(input())
m = [0,0]
flg = 0
m[0] = int(X/100)
m[1] = int(X/105)
while m[0] >= m[1]:
    if X >= int(m[1] * 100) and X <=int(m[1] *105):
        flg = 1
        break
    else:
        m[1] += 1

if flg == 1:
    print("1")
else:
    print("0")

Measured memory_bytes: 38384
n = int(input())
As = list(map(int, input().split()))
ais = [0]
ais.extend(As)
m = 0
ais.append(m)
S = 0
for i in range(n-1):
  S += abs(As[i]-As[i+1])
S += abs(As[0]) + abs(As[n-1])
for i in range(1,n+1):
  sb1 = abs(ais[i-1]-ais[i])
  sb2 = abs(ais[i]-ais[i+1])
  ad = abs(ais[i-1]-ais[i+1])
    
  ans = S - sb1 - sb2 + ad
  print(ans)
  

Measured memory_bytes: 20624
c = ['a','b','c','d','e','f','g','h','i','j',
     'k','l','m','n','o','p','q','r','s','t',
     'u','v','w','x','y','z']
n = int(input())
a = []
s = ""
#print(n)
while n > 26:
  r = n % 26
  if (r == 0):
    r = 26
    
  a.append(r)
  n -= r
  n = int(n/26)
  
a.append(n)
a.reverse()
#print(a)

for i in range(len(a)):
  s = s + c[a[i]-1]
  
print(s)

Measured memory_bytes: 9212
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

string rotate(string S,int size) {
	string N;
	N = S;
	for (int i = 0;i < size;i++) {
		if (i == 0) {
			S[i] = N[size - 1];
		}
		else {
			S[i] = N[i - 1];
		}
	}
	return S;
}

int main() {
	string ans;
	string S, T;
	cin >> S;
	cin >> T;
	
	for (int i = 0;i < S.size();i++) {
		S = rotate(S, S.size());
		//cout << S << endl;
		//cout << equal(S.begin(), S.end(), T.begin(), T.end()) << endl;
		if (equal(S.begin(), S.end(), T.begin(), T.end()) == true) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

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

int MOD = 1e9 + 7;

struct Matrix {

        int n, m;
        vector < vector < int > > mat;

        Matrix(vector < vector < int > > M) : mat(M), n(M.size()), m(M[0].size()) {}

        static Matrix id(int n) {
                vector < vector < int > > I(n, vector <int> (n, 0));
                for(int i = 0; i < n; i++) {
                        I[i][i] = 1;
                }
                return Matrix(I);
        }

        Matrix operator * (Matrix A) {
                int N = n;
                int M = A.m;
                int O = m;
                vector < vector < int > > Temp(N, vector <int> (M, 0));

                for(int i = 0; i < N; i++) {
                        for(int j = 0; j < M; j++) {
                                for(int k = 0; k < O; k++) {
                                        Temp[i][j] = (Temp[i][j] + mat[i][k] * A.mat[k][j]) % MOD;
                                }
                        }
                }
                return Matrix(Temp);
        }

        friend ostream& operator << (ostream &out, Matrix A) ;


};

ostream& operator << (ostream &out, Matrix A) {
        for(int i = 0; i < A.n; i++) {
                if(i) cout << '\n';
                for(int j = 0; j < A.m; j++) {
                        cout << A.mat[i][j] << " ";
                }
        }
}

Matrix BigMod(int n, Matrix M) {
        Matrix ret = M.id(M.n);
        while(n) {
                if(n & 1) {
                        ret = ret * M;
                }
                n /= 2;
                M = M * M;

        }
        return ret;
}

int32_t main() {
        int n, k; cin >> n >> k;
        vector <vector <int> > r(n, vector <int> (n, 0));
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                cin >> r[i][j];
        Matrix M(r);

        M = BigMod(k, M);

        int ans = 0;
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                ans = (ans + M.mat[i][j]) % MOD;
        cout << ans << endl;
}


Measured memory_bytes: 384
using System;

namespace AtCoder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string input = Console.ReadLine();

            char s3 = input[2];
            char s4 = input[3];
            char s5 = input[4];
            char s6 = input[5];

            if (s3 == s4 && s5 == s6)
            {
                Console.WriteLine("Yes");

            }
            else
            {
                Console.WriteLine("No");
            }





        }
    }


}

Measured memory_bytes: 11092
#include<stdio.h>

int main() {
   int N;
   scanf("%d", &N);

   int L[N];

   for(int i = 0; i < N; i++) {
      scanf("%d", &L[i]);
   }

   int max = L[0];
   int n = 0;

   for(int i = 0; i < N; i++) {
      if(max < L[i]) {
         max = L[i];
         n = i;
      }
   }

   int sum = 0;

   for(int i = 0; i < N; i++) {
      if(i != n)  {
         sum += L[i];
      }
   }

   if(max < sum) {
      printf("Yes\n");
   } else {
      printf("No\n");
   }
      
   return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    if(A+B>C+D)cout<<"Left"<<endl;
    else if(A+B<C+D)cout<<"Right"<<endl;
    else cout<<"Balanced"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,h,w; cin >> n >> h >> w;
  int ans = 0;
  for(int i = 0; i < n; i++){
    int a,b; cin >> a >> b;
    if(a >= h and b >= w) ans++;
  }
  
  cout << ans;
}


Measured memory_bytes: 3584
using System;

namespace AtCoder{
    public static class AtCoder{
        public static void Main(){
            var input = Console.ReadLine().Split(' ');
            int s = int.Parse(input[0]);
            int w = int.Parse(input[1]);

            if (s <= w) {Console.WriteLine("unsafe");}
            else{Console.WriteLine("safe");}
        }
    }
}

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

using namespace std;

int main()
{
      string s;
      cin>>s;
      
      int n=s.size();
      int i,j;
      
      int ar[26]={0};
      
      for(i=0;i<n;i++)
      ar[s[i]-'a']=1;
      
      if(n<26)
      {
            cout<<s;
            for(i=0;i<26;i++)
            {
                  if(ar[i]==0)
                  {
                        cout<<char('a'+i)<<endl;
                        return 0;
                  }
            }
      }
      int f=0;
      for(i=n-2;i>=0;i--)
      {
            
            ar[s[i+1]-'a']=0;
            for(j=0;j<26;j++)
            {
                  char ch=char ('a'+j);
                 if(ar[j]==0 && ch>s[i])
                 {
                       s[i]=ch;
                       f=1;
                       break;
                 }
            }
            if(f==1)
            {
                  for(j=0;j<=i;j++)
                  cout<<s[j];
                  return 0;
            }
      }
      cout<<-1;
      
      return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

int main(void)
{
    char a[10] = {0};
    while(scanf("%s",a) != EOF)
    {
        int as = strlen(a),cnt = 0;
        for(int i = 0;i < as/2;i++)
        {
            if(a[i] == a[as-1-i] && a[i] != '(' && a[i] != ')'){}
            else if(a[i]=='(' && a[as-i-1]==')'){}
            else if(a[i]==')' && a[as-i-1]=='('){}
            else{cnt++;}
        }
        if(as%2 != 0){ if(a[as/2] == '(' || a[as/2] == ')'){ cnt++;}}
        printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 972
#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>;

int main(){
    int n;
    cin >> n;
    int ans;
    ans=n/200;

    cout << 10-ans << endl;
    

    return 0;
}

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

long int gcd(long int a, long int b){
	long int c;
	if (a > b) swap(a, b);
	while (b % a > 0){
		c = b % a;
		b = a;
		a = c;
	}
	return a;
}

int main(){	
	long int A, B;
	cin >> A >> B;
	vector<int> p;
    long int g = gcd(A, B);
    long int n = 1;
    auto rg = sqrt(g);
	for (int i = 2; i <= rg; i++) {
		while (g % i == 0) {
            g /= i;
            if (n < i) {
            	n = i;
            	p.push_back(i);
            }
        }
	}
    if (g > n) p.push_back(g);
    cout << (int) p.size()+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

ll mod = 1e9+7;


int main(){
    int N;
    cin >> N;
    Vd p(N+1,0);
    vector<Vd> dp(N+1, Vd(N+1,0.0));
    REP(i,N) {
        cin >> p[i+1];
        }

    dp[0][0] = 1;
    FOR(i,1,N+1) {
        dp[i][0] = dp[i-1][0]*(1-p[i]);
        //cout << dp[i][0] << endl;
        FOR(j,1,N+1) {
            dp[i][j] = dp[i-1][j]*(1-p[i]) + dp[i-1][j-1]*p[i];
            //cout << dp[i][j] << endl;
        }
    }
    double ans = 0;
    FOR(i,N/2+1,N+1) ans += dp[N][i];
    cout << fixed << setprecision(10) << ans << defaultfloat << endl;
}

Measured memory_bytes: 70784
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

char buf[100000+10];

int main(void) {
  int N, K;
  cin >> N >> K >> buf;
  int d = 0;
  REP(i, N-1) {
    if(buf[i] != buf[i+1]) {
      ++d;
    }
  }
  int res = N-d-1;
  while(d > 0 && K > 0) {
    if(d >= 2) {
      d -= 2;
      res += 2;
    } else {
      d -= 1;
      res += 1;
    }
    --K;
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int d, n, q, i, ptr, a[1 << 18], x; long long ret;
int main() {
	while (cin >> d >> n >> q) {
		for (i = 1; i < n; i++) cin >> a[i];
		sort(a, a + n);
		for (ret = i = 0; i < n; i++) a[i + n] = a[i] + d;
		while (q--) {
			scanf("%d", &x);
			ptr = lower_bound(a, a + n, x) - a;
			ret += min(a[ptr] - x, x - a[ptr + n - 1] + d);
		}
		printf("%lld\n", ret);
	}
}

Measured memory_bytes: 4072
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class BResistorsInParallel {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      double sum = 0;
      rep(i, n) {
        double a; cin >> a;
        sum += 1/a;
      }
      cout << setprecision(15) << fixed << 1/sum << endl;
    }
};

signed main() {
  BResistorsInParallel solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

int main() {
	string a;
	cin >> a;
	vector<char> s;
	for (int i = 0; i < a.length(); i++) {
		s.push_back(a[i]);
	}
	sort(s.begin(), s.end());
	s.erase(unique(s.begin(), s.end()), s.end());
	if (s.size() == 26) {
		cout << "None" << endl;
		return 0;
	}
	char alpha[26];
	for (int i = 0; i < 26; i++) {
		alpha[i] = (unsigned char)i + 'a';
	}
	for (int i = 0; i < s.size(); i++) {
		if (alpha[i] < s[i]) {
			cout << alpha[i] << endl;
			return 0;
		}
	}
	cout << alpha[s.size()] << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

typedef long long lint;

using namespace std;




int main()
{

	int a,b,c;
	cin >> a >> b >> c;
	int m = b / a;
	cout << min(m,c) << endl;
	return 0;
}

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

int w, h;
int hw[51][51];

void solve2(int y, int x) {
    using P = pair<int, int>;
    int dx[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
    int dy[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
    queue<P> que;
    que.push(P(y, x));
    while (que.size()) {
        P p = que.front(); que.pop();
        rep(d, 8) {
            int py = p.first + dy[d];
            int px = p.second + dx[d];
            if (0 <= py && py < h && 0 <= px && px < w && hw[py][px] == 1) {
                hw[py][px] = 0;
                que.push(P(py, px));
            }
        }
    }
}

int solve() {

    int ans = 0;

    rep(y, h) {
        rep(x, w) {
            if (hw[y][x] == 1) {
                hw[y][x] = 0;
                solve2(y, x);
                ans++;
            }
        }
    }

    return ans;

}

int main() {

    while (cin >> w >> h and (w or h)) {
        rep(i, h) rep(j, w) cin >> hw[i][j];
        cout << solve() << endl;
    }
}

Measured memory_bytes: 3072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.regex.Pattern;

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int[] line = Pattern.compile(" ").splitAsStream(stdin.readLine()).mapToInt(Integer::parseInt).toArray();
        int a = line[0];
        int b = line[1];
        stdout.println(Math.max(0, a - b - b));
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}


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

using namespace std;

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

int main()
{
	int h, w;
	int a, b;
	cin >> h >> w >> a >> b;
	rep(i, h)
	{
		rep(j, w)
		{
			if(i<b && j<a) cout << '0';
			else if(i>=b && j>=a) cout << '0';
			else cout << '1';
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
import sys

a, b, c, d = input()

for i in range(2**3):
    op = ['','','']
    for j in range(3):
        if (i >> j) & 1:
            op[j] = '+'
        else:
            op[j] = '-'
    if eval(a + op[0] + b + op[1] + c + op[2] + d) == 7:
        print(a + op[0] + b + op[1] + c + op[2] + d + "=7")
        sys.exit()

Measured memory_bytes: 3064
import java.util.*;
import static java.lang.Math.abs;
import static java.lang.Math.max;

public class Main {

    public static void main(String[] args) {

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

        int[] h = new int[N];
        for(int i = 0; i < N; i++){

            h[i] = scan.nextInt();
        }

        int[] l = new int[N];
        for(int i = 0; i < N; i++){

            l[i] = scan.nextInt();
        }


        int tmp = 0;
        int ans = 0;
        for(int i = 0; i < N; i++ ){

            tmp = 0;

            for(int j = 0; j <= i; j++){

                tmp += h[j];
            }

            for(int j = i; j < N; j++){

                tmp += l[j];
            }

            ans = max(ans, tmp);
        }

        System.out.print(ans);
        
    }
}

Measured memory_bytes: 23380
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <map>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int first, second;
  first = stoi(s.substr(0,2));
  second = stoi(s.substr(2,2));
  string ans;
  if(1 <= first && first <= 12){
    if(1 <= second && second <= 12){
      ans = "AMBIGUOUS";
    }
    else if(0 <= second && second <= 99){
      ans = "MMYY";
    }else{
      ans = "NA";
    }
  } else if(0 <= first && first <= 99){
    if(1 <= second && second <= 12){
      ans = "YYMM";
    }else{
      ans = "NA";
    }
  }else{
      ans = "NA";
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
//ΔARC099C
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
int n,k;
int dv(int x,int y){
	if(x%y)
		return x/y+1;
	return x/y;
}
int main()
{
	int i,x,o;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i=i+1){
		scanf("%d",&x);
		if(x==1)
			o=i;
	}
	cout<<dv(n-1,k-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int x;
	cin>>x;
	if(x%100<=5*(x/100))cout<<"1"<<endl;
	else cout<<"0"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[11234];

int main(){
	int n; scanf("%d%s", &n, s);
	int m = strlen(s);
	REP(i, m) s[i] = (s[i] - 'A' + n) % 26 + 'A';
	printf("%s\n", s);
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	double x[n], y[n];
	for(int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for(int i = 0; i < n; i++) {
		cin >> y[i];
	}
// p = 1
	double distance1 = 0;
	for(int i = 0; i < n; i++) { 
		distance1 += fabs(x[i] - y[i]);
	}
	printf("%.6lf\n",distance1);
// p = 2
	double sum = 0;
	double distance2;
	for(int i = 0; i < n; i++) {
		sum += (x[i] - y[i]) * (x[i] - y[i]);
	}
	distance2 = sqrt(sum);
	printf("%.6lf\n",distance2);
// p = 3
	sum = 0;
	double distance3;
	for(int i = 0; i < n; i++) {
		sum += fabs((x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]));
	}
	distance3 = cbrt(sum);
	printf("%.6lf\n",distance3);
// p = ∞
	double distanceinf = 0;
	for(int i = 0; i < n; i++) {
		if(fabs(x[i] - y[i]) > distanceinf) {
			distanceinf = fabs(x[i] - y[i]);
		}
	}
	printf("%.6lf\n",distanceinf);
}


Measured memory_bytes: 3384
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=8e18;
const int32_t LOG=21;
const int MOD=MOD1;

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
          int n;
          cin>>n;
          set<string> s;
          rep(i,0,n)
          {
             string str;
             cin>>str;
             s.insert(str);
          }
          int siz=s.size();
          cout<<siz<<endl;
      }     
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 19272
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int x, y;
	cin >> x >> y;
	cout << 6 - (x + y);
}


Measured memory_bytes: 256
class Tree
	attr_accessor :parent, :root, :dep, :key, :left,:right, :sib

	def initialize(key)
		@parent = -1
		@left = -1
		@right = -1
		@dep = -1
		@key = key
		@sib = -1
	end

	def depth(answer,tree)
		if @left!=-1
			@left.depth(answer + 1,tree)
		end

		if @right != -1
			@right.depth(answer + 1,tree)
		end
		@dep = answer
	end

	def height(h)
		n1 = h
		n2 = h

		if @left!=-1
			n1 = left.height(h + 1)
		end

		if @right!=-1
			n2 = right.height(h + 1)
		end

		return n1 > n2 ? n1:n2
	end

	def showparent
		if @parent==-1
			return -1
		else
			return @parent.key
		end
	end

	def showsib
		if @sib == -1
			return -1
		else
			return @sib.key
		end
	end

	def degree
		answer = 0
		if @left != -1
			answer+=1
		end
		if @right != -1
			answer+=1
		end
		return answer
	end

	def preorder(list)
		list << @key
		if @left != -1
			list = @left.preorder(list)
		end
		if @right != -1
			list = @right.preorder(list)
		end

		return list
	end

	def inorder(list)
		if @left != -1
			list = @left.inorder(list)
		end
		list << @key
		if @right != -1
			list = @right.inorder(list)
		end

		return list
	end

	def postorder(list)
		if @left != -1
			list = @left.postorder(list)
		end

		if @right != -1
			list = @right.postorder(list)
		end

		list.push(@key)
		return list
	end
end

n = gets.to_i

tree = Hash.new
check = Array.new(n){true}
n.times do |i|
	tree[i] = Tree.new(i)
end

n.times do
	data = gets.split.map(&:to_i)
	num = data[0]
	tree[num].left = tree[data[1]] || -1
	tree[num].right = tree[data[2]] || -1

  if tree[data[1]]
		tree[data[1]].parent = tree[num]
		tree[data[1]].sib = tree[data[2]] || -1
		check[data[1]] = false
	end

	if tree[data[2]]
		tree[data[2]].parent = tree[num]
		tree[data[2]].sib = tree[data[1]] || -1
		check[data[2]] = false
	end

end


r = check.index(true)
obj = tree[r]
list = []
puts "Preorder"
puts " #{obj.preorder(list).join(" ")}"
list = []

puts "Inorder"
puts " #{obj.inorder(list).join(" ")}"
list = []

puts "Postorder"
puts " #{obj.postorder(list).join(" ")}"

Measured memory_bytes: 8684
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    long long H, W, N;
    cin >> H >> W >> N;

    vector<long long> colorNum;
    long long currentC = 0;

    long long a;
    for (int i = 0; i < N; i++)
    {
        cin >> a;
        colorNum.push_back(a);
    }

    string str = "";
    for (int i = 0; i < H; i++)
    {
        str = "";
        for (int j = 0; j < W; j++)
        {
            if (i % 2 == 0)
            {
                if (j != 0)
                    str += " " + to_string(currentC + 1);
                else
                    str += to_string(currentC + 1);
            }
            else
            {
                if (j != 0)
                    str.insert(0, to_string(currentC + 1) + " ");
                else
                    str.insert(0, to_string(currentC + 1));
            }

            colorNum[currentC]--;
            if (colorNum[currentC] == 0)
            {
                currentC++;
            }
        }
        cout << str << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
 
unordered_map<ll, int> occ;

int main() {
    int n;
    cin >> n;
    string s;
    ll rez = 0, t;
    for (int ctr1 = 0; ctr1 < n; ++ctr1) {
        cin >> s;
        sort(s.begin(), s.end());
        t = 0;
        for (int ctr2 = 0; ctr2 < s.length(); ++ctr2)
            t += (s[ctr2] - 'a') * (1LL << (ctr2 * 5));
        rez += occ[t];
        ++occ[t];
    }
    cout << rez << "\n";
    return 0;
}

Measured memory_bytes: 4388
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = 1e18;
const int N = 20;



void solve(int t)
{
	ll a , b, c;
	cin >> a >> b >> c;
	ll k;
	cin >> k;

	while (b <= a and k > 0)
	{
		b *= 2;
		k--;
	}
	while (c <= b and k > 0)
	{
		c *= 2;
		k--;
	}

	if (a < b and b < c)
	{
		cout << "Yes" << endl;
		return;
	}
	cout << "No" << endl;


}




int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);



	int t = 1;
	//cin >> t;

	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
using namespace std;

int main()
{
	int X, N;
	cin >> X >> N;
	
	int p[N];
	set<int> P;
	for(int i = 0; i < N; i++){
		cin >> p[i];
		P.insert(p[i]);
	}
	
	int number_down = X;
	int number_up = X;
	int set_size = P.size();
	bool loop_d = true;
	bool loop_u = true;
	while(loop_d && loop_u){
		P.insert(number_down);
		if(set_size == P.size()){
			number_down--;
			P.insert(number_up);
			if(set_size == P.size()){
				number_up++;
			}
			else loop_u = false;
		}	
		else loop_d = false;
	}
	
	if(!loop_d) cout << number_down << endl;
	else cout << number_up << endl;	
	
	return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
        #define int long long
        #define endl '\n'
        #define modulo 10000007
        #define BIG 100004
        ///I am the backupguy!
        using namespace std;
        int input(){
        string s;
        cin>>s;
        if(s=="0"||s=="-0")
        return 0;
        int n=0;
        bool neg=0;
        for(int i=0;i<s.size();i++){
        if(!i&&s[i]=='-')
        neg=1;
        else{
        n+=(s[i]-'0');
        if(i+1!=s.size())
        n*=10;
        }
        }
        return (neg?-n:n);
        }
        void output(int n){
        vector<unsigned int8_t>buffer;
        bool neg=0;
        if(!n){
        cout<<0;
        return;
        }
        if(n<(int)0){
        neg=1;
        n=-n;
        }
        while(n){
        buffer.push_back(n%10);
        n/=10;
        }
        if(neg)
        cout<<'-';
        for(int i=buffer.size()-1;i>=0;i--)
        cout<<buffer[i];
        }
        int power(int x,int y,int m)
        {
        int temp;
        if(y == 0)
        return 1;
        temp = (power(x, y/2,m))%m;
        if (y%2 == 0)
        return ((temp%m)*temp);
        else
        return ((x%m*temp%m)*temp%m)%m;
        }
        int32_t main()
        {
        iostream::sync_with_stdio(0);
        cin.tie(0);
        int n;
        cin>>n;
        int arr[n];
        map<int,int>lol;
        for(int i=0;i<n;i++){
        cin>>arr[i];
        if(lol.find(arr[i])==lol.end())
        lol.insert({arr[i],0});
        lol.at(arr[i])++;
        }
        int total=0;
        for(auto itr=lol.begin();itr!=lol.end();itr++){
        total+=((itr->second)*((itr->second)-1)/2);
        }
        for(int i=0;i<n;i++){
        int buff=total-lol.at(arr[i])+1;
        cout<<buff<<endl;
        }
        return 0;
    }


Measured memory_bytes: 11136
def solve(L):
    cost = 0
    s = [0] * m
    for k in range(n):
        if L[k] == 1:
            cost += A[k][0]
            for l in range(1, m+1):
                s[l-1] += A[k][l]
    if all(s[i] >= x for i in range(m)):
        return cost
    else:
        return float('inf')

n, m, x = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
ans = float('inf')
for i in range(2 ** n):
    L = [0] * n
    for j in range(n):
        if ((i >> j) & 1) != 0:
            L[j] = 1
    ans = min(ans, solve(L))
if ans == float('inf'):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9156
#!/usr/bin/env python3
#ABC144 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b = LI()
if a >= 10 or b >= 10:
    print(-1)
else:
    print(a*b)

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll N, X;
ll A[MAX_N] = {};

int main()
{
    cin >> N >> X;
    REP(i, N) { cin >> A[i]; }

    ll ans = 0;
    for(int i = 1; i < N; ++i) {
        if(A[i-1] + A[i] > X) {
            // 奥のヤツ優先で食べる
            ll eat = (A[i-1] + A[i]) - X;
            ans += eat;
            if(eat > A[i]) {
                A[i] = 0;
                A[i-1] -= (eat - A[i]);
            } else {
                A[i] -= eat;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

		try{

			//最初の数値。
			String strN = insBR.readLine();
			int intN = Integer.parseInt(strN);

			//x と y の数値。
			double[][] dbXY = new double[2][intN];
			for(int i  = 0; i < dbXY.length; i++){
				String[] strXY = insBR.readLine().split(" ");
				for(int j = 0; j < strXY.length; j++){
					dbXY[i][j] = Double.parseDouble(strXY[j]);
				}
			}

			//マンハッタン距離。
			double dbManhattan = 0.0;
			List<Double> dbList = new ArrayList<Double>();
			for(int i = 0; i < intN; i++){
				double dbDistance = dbXY[0][i] - dbXY[1][i];
				dbDistance = Math.abs(dbDistance);
				dbList.add(dbDistance);
				dbManhattan += dbDistance;
			}
			String strManhattan = String.format("%1$.5f", dbManhattan);

			// p=2 のときのユークリッド距離。
			double dbEuclid = 0.0;
			for(int i = 0; i < dbList.size(); i++){
				double dbDistance = dbList.get(i);
				dbDistance = Math.pow(dbDistance, 2);
				dbEuclid += dbDistance;
			}
			dbEuclid = Math.sqrt(dbEuclid);
			String strEuclid = String.format("%1$.5f", dbEuclid);

			// p=3 のときのユークリッド距離。
			double dbNextEuclid = 0.0;
			for(int i = 0; i < dbList.size(); i++){
				double dbDistance = dbList.get(i);
				dbDistance = Math.pow(dbDistance, 3);
				dbNextEuclid += dbDistance;
			}
			dbNextEuclid = Math.cbrt(dbNextEuclid);
			String strNextEuclid = String.format("%1$.5f", dbNextEuclid);

			//チェビシェフ距離。
			double dbChebyshev = 0.0;
			for(int i = 0; i < dbList.size(); i++){
				double dbDistance = dbList.get(i);
				if(dbChebyshev < dbDistance){
					dbChebyshev = dbDistance;
				}
			}
			String strChebyshev = String.format("%1$.5f", dbChebyshev);

			//出力。
			System.out.println(strManhattan);
			System.out.println(strEuclid);
			System.out.println(strNextEuclid);
			System.out.println(strChebyshev);

		}catch(IOException e){
		 	e.printStackTrace();
		}catch(NumberFormatException e){
			e.printStackTrace();
		}

	}

}



Measured memory_bytes: 24928
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  double a,b,x;
  cin >> a >> b >> x;
  double p;
  double rad;
  double q = a*a*b-x;
  if(a*a*b/2<=x){
    
    p = q/a/a*2;
    rad = atan(p/a);
  }
  else{
    q = x;
    rad = atan(a*b*b/2/q);
  }
    
    
    
  double ans = rad*180/M_PI;
  cout << fixed << setprecision(7) << ans << endl;
    
  
         
         
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;

  int ans = inf;
  rep(i, n - 1) {
    int x = 0;
    rep(j, i + 1) x += a[j];
    int y = 0;
    rep3(j, i + 1, n) y += a[j];
    chmin(ans, abs(x - y));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,i,count=0,max;
    char s[n];
    scanf("%d %s",&n,s);
    max=count;
    for(i=0;i<n;i++){
        if(s[i]=='I'){
            count++;
        }
        if(max<count)
        {
            max=count;
        }
        if(s[i]=='D'){
            count--;
        }
    }
    printf("%d\n",max);
    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  vector<string> v;

  for (int i = 0; i < n; ++i) {
    bool ok = true;
    int j = i, k = 0;
    for (; ok and j < n and k < m; ++j, ++k) {
      if (s[j] != '?' and s[j] != t[k]) { ok= false; }
    }
    if (not ok) { continue; }
    if (k < m) { continue; }
    string u = s;
    u.replace(i, m, t);
    for (int j = 0; j < n; ++j) {
      if (u[j] == '?') { u[j] = 'a'; }
    }
    v.push_back(u);
  }
  sort(v.begin(), v.end());
  string ans = v.empty() ? "UNRESTORABLE" : v[0];
  printf("%s\n", ans.c_str());
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=1e9+7;
const int MAXN=1e5+9;
const double eps=1e-8;
const long double pi=3.1415926535897932384626433832795;
const long double e=2.71828182845904523536028747135266;
struct AAA{
    int x,y;
    bool operator <(const AAA& a) const{
        return y<a.y;
    }
}a[MAXN];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;
    while(t--){
        int n,ans=0,k;
        ll x,f1,f2;
        map<ll,int> mp;
        cin >> n;
        for (int i=1;i<=n;i++){
            cin >> x;f1=1,f2=1;
            for (ll i=2;i*i*i<=x;i++){
                k=0;
                while(x%i==0) {
                    x/=i;k++;
                }
                if(k%3==1) {
                    f1*=i;
                    f2*=i*i;
                }
                if(k%3==2){
                    f1*=i*i;
                    f2*=i;
                }
            }
            f1*=x;
            if((ll)sqrt(x)*(ll)sqrt(x)==x) f2*=(ll)sqrt(x);
            else f2*=x*x;
            if(f1==1) {
                mp[1]++;
                ans+=(mp[1]==1);
            }
            else {
                mp[f1]++;
                ans+=(mp[f1]>mp[f2]);
            }
        }
        cout << ans << endl;
    } 
    return 0;
}




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

int main(){
 int k,x;
 cin >> k >> x;
  
 if(k==1){
   cout << x << endl;
   return 0;
 }
 rep(i,2*k-1){
   cout << x+i-k+1 << " ";
 }
 return 0;
  
}

Measured memory_bytes: 3616
n, m = gets.split.map(&:to_i)

lights = m.times.map { gets.split.map(&:to_i).drop(1) }
parities = gets.split.map(&:to_i)

count = 0
0.upto(2**n-1) do |b|
  if lights.each.with_index.all? { |switches, i|
       c = switches.count { |s| ((1 << (s-1)) & b) != 0 }
       c % 2 == parities[i]
     }
    count += 1
  end
end
puts count


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

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

int main(){
  int n; cin >> n;
  int d[n]; rep(i,n) cin >> d[i];
  sort(d,d+n);
  cout << d[n/2]-d[n/2-1] << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 100;
enum Color { WHITE = 0, GRAY, BLACK };
int n;
vv(int, M, MAX, MAX, INT_MAX);
inline void dijkstra() {
	vi d(MAX, INT_MAX), color(MAX, WHITE);
	d[0] = 0;
	color[0] = GRAY;
	int minv, u;
	while(true) {
		minv = INT_MAX;
		u = -1;
		rep(i, 0, n) {
			if(minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if(u == -1) break;
		color[u] = BLACK;
		rep(v, 0, n) {
			if(color[v] != BLACK && M[u][v] != INT_MAX && d[v] > d[u] + M[u][v]) {
				d[v] = d[u] + M[u][v];
				color[v] = GRAY;
			}
		}
	}
	rep(i, 0, n) {
		cout << i << " " << (d[i] == INT_MAX ? -1 : d[i]) << endl;
	}
}
int main() {
	cin >> n;
	int u, k, v, c;
	rep(i, 0, n) {
		cin >> u >> k;
		rep(j, 0, k) {
			cin >> v >> c;
			M[u][v] = c;
		}
	}
	dijkstra();
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  // regex R ("(dream(er)?|eraser?)+");
  regex R ("(dream|dreamer|erase|eraser)+");
  cout << ((regex_match(S, R)) ? "YES" : "NO") << "\n";
}

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

int main() {
  int a,b;
  cin>>a>>b;
  if(a<b){
  for(int i=1;i<b+1;i++){
    cout<<a;
  }
  }else{
  for(int i=1;i<a+1;i++){
    cout<<b;
  }
  }
}

Measured memory_bytes: 256
n,d = map(int,input().split())
l = []
for i in range(n):
    x,y = map(int,input().split())
    g = ((x**2)+(y**2))**0.5
    l.append(g)

l.sort()
cnt = 0
for i in l:
    if i > d:
        break

    cnt = cnt+1

print(cnt)


Measured memory_bytes: 17976