akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    StringBuffer s = new StringBuffer(sc.next());
    int q = sc.nextInt();
    
    boolean flg = false;

    StringBuffer pre = new StringBuffer();
    StringBuffer post = new StringBuffer();
       
    for(int j=0;j<q;j++){
      if(sc.nextInt()==1){
        flg = !flg;
      }else{
        if(sc.nextInt()==1){
          if(flg){
            post.append(sc.next());
          }else{
            pre.append(sc.next());
          }
        }else{
          if(flg){
            pre.append(sc.next());
          }else{
            post.append(sc.next());
          }
        }
      }
    }

    if(flg){
      System.out.print(post.reverse());
      System.out.print(s.reverse());
      System.out.print(pre);
    }else{
      System.out.print(pre.reverse());
      System.out.print(s);
      System.out.print(post);

    }
  }
}

Measured memory_bytes: 120560
s = input()
ans = 0
cnt = 0
left = 200005
right = 0
for i in range(len(s)):
    if (s[i]=='A') : 
        left = min(left, i)
    if (s[i]  == "Z") :
        right = max(right, i)
print(right - left+1)

Measured memory_bytes: 9204
a, b, k = map(int, input().split())

if b - a + 1 > 2 * k:
    l = [int(i) for i in range(a, a + k)] + [int(j) for j in range(b - k + 1, b + 1)]
    #print([a : a + k + 1] + [b - k: b + 1]) ?
else:
    l = [int(i) for i in range(a, b + 1)]

for i in l:
    print(i)

Measured memory_bytes: 3060
from math import sqrt
N,D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]
ans = 0
for a in range(1,N):
    for b in range(a):
        jijou = sum([(y-z)**2 for y,z in zip(X[a],X[b])])
        if int(sqrt(jijou))**2 == jijou:
            ans+=1
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        long x = sc.nextLong();
        long ans = (long) Math.ceil((double) x / 11);
        long part = x % 11;
        ans *= 2;
        if (part > 0 && part <= 6) {
            ans--;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22608
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <iostream>
#include<math.h>
using namespace std;
string a[4] = { "dream","dreamer","erase","eraser" };

int main() {
	int N;
	cin >> N;
	long long A[100000];
	for (int i = 0; i < N; i++)cin >> A[i];
	int ans = 1,i=0;
	while(1) {
		if(A[i] > A[i + 1]) {
			while (1) {
				i++;
				if (i >= N)break;
				if (A[i] < A[i + 1]&& i < N) {
					i++;
					if (i >= N)break;
					ans++;
					break;
				}
			}
		}
		else if (A[i] < A[i + 1]) {
			while (1) {
				i++;
				if (i >= N)break;
				if (A[i] > A[i + 1] && i < N) {
					i++;
					if (i >= N)break;
					ans++;
					break;
				}
			}
		}
		else ++i;
		if (i >= N)break;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
A = list(map(int, input().split()))
# Nの中からK個中最大でK-1個だけ変えることができるので
# N >= T*(K-1) + 1となり、この式をTを求めるように式変形する（Tは試行回数）
##a/bの切り上げは(a-1)/b+1で求まる
T = (N-2) // (K-1)+1
print(T)


Measured memory_bytes: 14008
#include <stdio.h> 
#include <stdlib.h>
 int main() { int h; int w,mark; scanf("%d %d", &h,&w); while (h!=0&&w!=0){ for(int i=0;i<h;i++){ mark=i%2; for(int j=0;j<w;j++){ if(!mark){ printf("#"); }else{ printf("."); } mark=!mark; } puts(""); } puts(""); scanf("%d %d", &h,&w); } return 0; } 



Measured memory_bytes: 2048
#include <iostream>
#include <map>
#include <cmath>

using namespace std;

std::map<long long, int> prime_fact(long long n) {
    std::map<long long, int> res;
    for (long long i=2; i*i<=n; i++) {
        while (n%i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) {
        res[n] = 1;
    }
    return res;
}

int main() {
  long long n = 0, p = 0;
  cin >> n >> p;
  map<long long, int> prime = prime_fact(p);
  long long ans = 1;
  for (auto iter=prime.begin(); iter!=prime.end(); iter++) {
    ans *= pow(iter->first, iter->second / n);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<int> ans(N, 0);
    for (int i = 1; i <= N; i++) {
        for (int j = i+1; j <= N; j++) {
            int dist = N;
            dist = min(dist, j-i);
            dist = min(dist, abs(i-X)+1+abs(Y-j));
            dist = min(dist, abs(i-Y)+1+abs(X-j));
            ans[dist]++;
        }
    }
    for (int i = 1; i <= N-1; i++) cout << ans[i] << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  for (;;) {
    c -= b;
    if (c <= 0) {
      cout << "Yes\n";
      return;
    }
    a -= d;
    if (a <= 0) {
      cout << "No\n";
      return;
    }
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




Measured memory_bytes: 3652
import java.util.Scanner;
public class Main{
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	double X=sc.nextDouble();
	double a= Math.ceil(X/105);
	int money=0;
	for(int i=(int) a;i<=X/100;i++) {
		money=(int) X;
		money-=a*100;
		if(money>=0&&money<=5*a) {
			System.out.println(1);
			System.exit(0);
		}
	}
	System.out.println(0);
}
}

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

int main()
{
  ll L,R;
  cin >> L >> R;
  R = min(R,L + 2018);
  int ans = 2019;
  for(ll i=L;i < R;i++){
    for(ll j=i+1;j <= R;j++){
      int r = i * j % 2019;
      ans = min(ans,r);
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#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() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    string s;cin >> s;
    int K;cin >> K;
    int N = s.size();
    vector<int> num(N);
    rep(i,N){
        int start = 'a' + 0;
        for(int j = start;j < s[i] + 0;j++){
            num[i]++;
        } 
    }

    int ct = 0;
    rep(i,N){
        if(num[i] == 0 && i != N-1)continue;
        int tm = K - ct;

        if(i == N-1){
            int tmp = (num[N-1] + tm) % 26;
            num[N-1] = tmp;
            break;
        }
        else if(26 - num[i] > tm){
            continue;
        }
        else{
            int tmp = 26 - num[i];
            num[i] = 0;
            ct += tmp;
        }
    }

    string ans;
    rep(i,N){
        char c = 'a' + num[i];
        ans.push_back(c);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vi v(2 * n);
	vector<pi> p;
	
	rep(i, 2 * n){
		cin >> v[i];
		p.emplace_back(v[i], i);
	}
	sort(all(p));
	vi use(n), use2(2);
	bool ok = 0;
	rep(i, n){
		if(++use[p[i].second / 2] == 2) ok = 1;
		if(++use2[p[i].second % 2] == n) ok = 1;
	}
	dbg(use2);
	
	if(ok){
		cerr<<"1"<<endl;
		
		ll sum = 0;
		rep(i, n) sum += p[i].first;
		cout << sum << endl;
	}
	else if((p[n - 1].second ^ 1) != p[n].second){
		cerr<<"2"<<endl;
		
		ll sum = p[n].first;
		rep(i, n - 1) sum += p[i].first;
		cout << sum << endl;
	}
	else{
		cerr<<"3"<<endl;
		
		ll sum = 0;
		rep(i, n - 2) sum += p[i].first;
		sum += min(p[n - 2].first + p[n + 1].first, p[n - 1].first + p[n].first);
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3188
s=input()
a=int(s[:2])
b=int(s[2:])
if (a > 12 or a == 0) and (b > 12 or b == 0):
	print("NA")
elif a > 12 or a == 0:
	print("YYMM")
elif b > 12 or b == 0:
	print("MMYY")
else: print("AMBIGUOUS")

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string A,B,C;
	cin>>A>>B>>C;

	vector<bool> AB(5000,false),BC(5000,false),AC(5000,false);
	rep(i,-2500,2500)
	{
		bool res=true;
		rep(j,0,SZ(B))
		{
			int ai=i+j,bi=j;
			if(0<=ai&&ai<SZ(A)&&A[ai]!='?'&&B[bi]!='?'&&A[ai]!=B[bi])res=false;
		}
		AB[i+2500]=res;
	}
	rep(i,-2500,2500)
	{
		bool res=true;
		rep(j,0,SZ(C))
		{
			int ai=i+j,bi=j;
			if(0<=ai&&ai<SZ(B)&&B[ai]!='?'&&C[bi]!='?'&&B[ai]!=C[bi])res=false;
		}
		BC[i+2500]=res;
	}
	rep(i,-2500,2500)
	{
		bool res=true;
		rep(j,0,SZ(C))
		{
			int ai=i+j,bi=j;
			if(0<=ai&&ai<SZ(A)&&A[ai]!='?'&&C[bi]!='?'&&A[ai]!=C[bi])res=false;
		}
		AC[i+2500]=res;
	}

	int ans=INF;
	rep(i,-4005,4006)
	{
		rep(j,-4005,4006)
		{
			int abi=i+2500,bci=j-i+2500,aci=j+2500;
			bool ok=true;
			if(0<=abi&&abi<5000&&!AB[abi])ok=false;
			if(0<=bci&&bci<5000&&!BC[bci])ok=false;
			if(0<=aci&&aci<5000&&!AC[aci])ok=false;
			if(!ok)continue;
			int l=min(0LL,min(i,j));
			int r=max(SZ(A),max(i+SZ(B),j+SZ(C)));
			chmin(ans,r-l);
		}
	}

	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

int main() {

	int n,m;
	cin >> n >> m;
	vector<int> a(m+2);

	a[0] = -1;
	a[m + 1] = n + 1;
	for (int i = 1; i <= m; i++) {
		cin >> a[i];
		if (i != 1 && a[i] - a[i - 1 ]== 1) {
			cout << 0 << endl;
			return 0;
		}
	}

	if (a[1] == 0) {
		cout << 0 << endl;
		return 0;
	}

	int st, ed,haba;
	vector<long long> fibo(n + 1);
	fibo[0] = 1; fibo[1] = 1;
	for (int i = 2; i < n + 1;i++) {
		fibo[i] = (fibo[i - 1] + fibo[i - 2])%1000000007; 
	}

	long long summ = 1;
	for (int i = 1; i <= m+1; i++) {
		st = a[i - 1] + 1;
		ed = a[i] - 1;
		summ = (summ*fibo[ed - st]) % 1000000007;
	}

	cout << summ << endl;


}

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

#define mod(cans) cans%10**9+7;
#define cin_pl(x,y) for(int i=0;i<x;i++){cin>>y[i];}
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin,(a).end
#define rall(a) (a).rbegin,(a).rend
#define st(s) size_t size = s.length();
#define prians(Answer) cout<<Answer<<"\n";
#define make_pair m_p;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> matrix;
typedef pair<int,int> pr;

int main()
{
    int a,b,t,ans;
    cin>>a>>b>>t;
    ans=t/a*b;
    prians(ans);
    return 0;
}

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

typedef complex<double> P;

int main() {
    int N;
    cin >> N;
    vector<P> points;
    for (int i = 0; i < N; i++) {
        double x, y;
        cin >> x >> y;
        points.push_back(P(x,y));
    }

    P center = P(0,0);
    vector<double> sub;
    for (int i = 0; i < N; i++) {
        center += points[i];
        sub.push_back(abs(points[(N + i - 1) % N] - points[i]));
    }

    for (int i = 0; i < N; i++) {
        if (sub[i] != sub[(i+N/2)%N]) {
            cout << "NA" << endl;
            return 0;
        }
    }

    printf("%.12f %.12f\n", center.real() / N, center.imag() / N);

    return 0;
}


Measured memory_bytes: 3412
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');

            double ans = 0;
            for (int i = 0; i < N; i++)
            {
                double v = double.Parse(s[i]);
                ans += 1 / v;
            }

            Console.WriteLine(1 / ans);
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>

using namespace std;

typedef long long int ll;

ll GCD(ll a , ll b)
{
    if(b==0)
        return a;
    else
        return GCD(b,a%b);
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    ll ans = 0;

    for(int i=1 ; i<=n ; i++)
    {
        for(int j=1 ; j<=n ; j++)
        {
            for(int k=1 ; k<=n ; k++)
            {
                ans += GCD(i,GCD(j,k));
            }
        }

    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int r,g,b;
    
    cin>>r>>g>>b;
    
    if((r*100+g*10+b)%4==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#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>
#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>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;



int main() {
	double N, K;
	cin >> N >> K;
	double ans = 0;
	for (double i = 1; i <= N; i++) {
		if (1 <= i && i <= K - 1) {
			ans += 1 / N * 1 / pow(2, ceil(log2(K / i)));
		}
		else {
			ans += 1 / N;
		}
	}
	cout << fixed << setprecision(10) << ans << endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

typedef long long ll;

void solve(long long A, long long B)
{
    if (A > 9 || B > 9)
    {
        cout << "-1" << endl;
        return;
    }
    cout << A * B << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>

void main()
{
    int n, k, a[200001], b[200001], flag;

    scanf("%d %d", &n, &k);

    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);

    while (k--)
    {
        flag = 0;
        for (int i = 0; i < n; i++)
            b[i] = 0;

        for (int i = 0; i < n; i++)
        {
            if (i - a[i] < 0)
                b[0]++;
            else
                b[i - a[i]]++;

            if (i + a[i] + 1 < n)
                b[i + a[i] + 1]--;
        }

        for (int i = 0, s = 0; i < n; i++)
        {
            s += b[i];
            b[i] = s;
            if (a[i] != b[i])
                flag = 1;

            a[i] = b[i];
        }

        if (!flag)
            break;
    }

    // for (int l = 0; l < k; l++)
    // {
    //     for (int i = 0; i < n; i++)
    //     {
    //         for (int j = i - a[i]; j <= i + a[i]; j++)
    //         {
    //             if (j < 0 || j > n - 1)
    //                 continue;

    //             b[j]++;
    //         }

    //         a[i] = b[i];
    //         b[i] = 0;
    //     }
    // }

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


Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define for1(n) for(i=1; i<=(n); i++)
#define M 1000000007


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>a>>b>>c>>d;
    x=a*c;
    y=max(x,a*d);
    y=max(y,b*d);
    y=max(y,c*b);
    cout<<y<<endl;
}



Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main () {
    int x, y;
    while (true) {
        cin >> x >> y;

        if (x == 0 && y == 0) break;
        
        if (x > y) cout << y << ' ' << x << endl;
        else cout << x << ' ' << y << endl;
    }
}


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

using namespace std;

#define Vi vector<int>
#define FOR(i,s,e) for (int i=s; i<e; i++)
#define ITER(v) v.begin(), v.end()

constexpr int N_MAX = 100;

int adj_matrix[N_MAX+1][N_MAX+1];

int d[N_MAX+1];
int f[N_MAX+1];

int t;
int n;

void dfs_visit(int id) {
    d[id] = ++t;
    FOR(i,1,n+1) {
        if (adj_matrix[id][i] && !d[i]) {
            dfs_visit(i);
        }
    }
    f[id] = ++t;
}

void dfs() {
    FOR(i,1,n+1) {
        if (!d[i]) {
            dfs_visit(i);
        }
    }
}

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

    cin >> n;

    int id, k, v;
    FOR(i,0,n) {
        cin >> id;
        cin >> k;
        FOR(j,0,k) {
            cin >> v;
            adj_matrix[id][v] = 1;
        }
    }

    dfs();

    FOR(i,1,n+1) {
        cout << i << " " << d[i] << " " << f[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

using P = pair<ll, ll>;

ll color[100005];
vector<ll> edge[100005];
map<P, ll> length;


void dfs(ll u, ll p = -1, ll len = 0){
  color[u] = len%2;
  for(auto v : edge[u]){
    if(p == v) continue;
    ll l = length[P(u, v)];
    dfs(v, u, len + l);
  }
}


int main(void){
  ll n;
  cin >> n;
  REP(i, n) color[i] = -1;
  REP(i, n-1){
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    edge[a].emplace_back(b);
    edge[b].emplace_back(a);
    length[P(a, b)] = c;
    length[P(b, a)] = c;
  }
  dfs(0);
  REP(i, n) cout << color[i] << endl;
  return 0;
}

Measured memory_bytes: 26516
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
#define inf 1000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back

int a, b;

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

cin >> a >> b;

if(a==b)cout << "Draw";

else if(a==1)cout << "Alice";

else if(b==1)cout << "Bob";

else if(a>b){
    cout << "Alice";
}
else cout << "Bob";



return 0;}


Measured memory_bytes: 256
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

int isUnder(int T,int A){ // AがT以下で1,それ以外0
    if(A<=T) return 1;
    else return 0;
}

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(A,B);
    cout <<A -B +1 << nn;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

int main(){
  int n, m, c;
  cin >> n >> m >> c;
  int ans = 0;
  vector<int> b(m), a(m);
  rep(i, m) cin >> b[i];
  rep(i, n){
       int temp = 0;
       rep(j, m){
            cin >> a[j];
            temp += b[j]*a[j];
       }
       temp += c;
       if(temp > 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int x[110];
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);

	int s = 0;
	for(int i=1;i<=a;i++) s += x[i];
	int count = 0;
	for(int i=1;i<=a;i++)
	{
		if(x[i]<=((s-1)/(4*b)));
		else count++;
	}
	printf("%s",count>=b?"Yes":"No");
}

Measured memory_bytes: 128
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

def main():
	a,b = map(int,input().split())
	if((a+b)%2==0):
		print((a+b)//2)
	else:
		print('IMPOSSIBLE')

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 6152
#include <stdio.h>

#define MAX_N 100010

int main(void) {
	int n,L,a[MAX_N];
	int i,sum[MAX_N],min,minnum;
	
	scanf("%d %d", &n,&L);
	
	for (i=1;i<=n;i++) 
		scanf("%d", &a[i]);
	
	min=0;
	for (i=1;i<n;i++) {
		sum[i]=a[i]+a[i+1];
		if (min<sum[i]) {
			min=sum[i];
			minnum=i;
		}
	}
	
	if (min<L) 
		printf("Impossible\n");
	else {
		printf("Possible\n");
		for (i=1;i<minnum;i++) 
			printf("%d\n", i);
		for (i=n-1;i>minnum;i--)
			printf("%d\n", i);
		printf("%d\n", minnum);
	}
	
	return 0;
	
}


Measured memory_bytes: 1152
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <algorithm>

int main()
{
  int N, K;
  std::cin >> N >> K;
  std::map<int, int> A;
  for (int i = 0; i < N; i++)
  {
    int tmp;
    std::cin >> tmp;
    if (A.count(tmp)) A[tmp]++;
    else A[tmp] = 1;
  }
  std::vector<std::pair<int, int> > count;
  for (auto x: A) count.push_back(std::make_pair(x.second, x.first));
  sort(count.begin(), count.end());
  reverse(count.begin(), count.end());
  int ans = 0;
  while(count.size() > K)
  {
    ans += count.at(count.size()-1).first;
    count.pop_back();
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 11768
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<i64,i64>;

int main(){
    int N,C;
    cin >> N >> C;
    int sum = 0;
    rep(i,C){
        int a;
        cin >> a;
        sum += a;
    }

    cout << sum / (N+1) + !!(sum % (N+1)) << endl;
}



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

using namespace std;

const int N = 100;
bool G[N][N];
int n;
vector<int> d(N, -1);

void bfs(int r) {
    queue<int> q;
    q.push(r);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int v = 0; v < n; ++v) {
            if (G[u][v] && d[v] == -1) {
                d[v] = d[u] + 1;
                q.push(v);
            }
        }
    }
}

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

    for (int i = 0; i < n; ++i) {
        int u, k;
        scanf("%d %d", &u, &k);
        --u;
        for (int j = 0; j < k; ++j) {
            int v;
            scanf("%d", &v);
            --v;
            G[u][v] = true;
        }
    }
    d[0] = 0;
    bfs(0);
    for (int u = 0; u < n; ++u) {
        cout << u + 1 << " " << d[u] << endl;
    }
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  fio();
  int n;
  cin >> n;
  vi a(n);
  map<int, int> mp;
  rep (i, n) {
    cin >> a[i];
    mp[a[i]];
  }
  if (mp.size() == n) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 14336
#pragma GCC optimize ("Ofast")
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "homework"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

using namespace std;
	
int gcd(int a, int b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 303;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-9;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;

int dp[101][100005];

int32_t main() {
	FAST;
	
	int n, k;
	cin >> n >> k;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= k; j++) {
			dp[i][j] = 0;
		}
	}

	vector<int> p(2*k + 5, 0);
	
	dp[0][0] = 1;
		
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		for (int j = 0; j <= k; j++) {
			p[j] += dp[i][j];
			p[j + a + 1] -= dp[i][j];
		}
		int cv = 0;
		for (int j = 0; j <= k; j++) {
			cv = (cv + 2*MOD + p[j]) % MOD;
			p[j] = 0;
			dp[i + 1][j] = cv;
		}
	}

	cout << dp[n][k];
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

ll a[2000000];
int main() {
  ll n, p, ans = 1, op;
  cin >> n >> p;
  op = p;
  unordered_map<ll, ll> mp;

  ll t = 2;
  while (p > 1 && t * t <= op) {
    if (p % t == 0) {
      mp[t]++;
      p /= t;
    } else {
      t++;
    }
  }
  if (p > 1) mp[p]++;

  for (auto m : mp) ans *= pow(m.first, m.second / n);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll ch=inf;
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		ch=min(ch,now);
		if(now<=ch){
			ans++;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int x = N * 800;
        int y = N / 15 * 200;
        int ans = x - y;

        System.out.print(ans);
    }
}


Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int N;

	cin >> N;

	vector<int> A(N);

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

	int minA = INF, maxA = 0;

	for (int i = 0; i < N; i++) {
		if (A[i] > maxA) {
			maxA = A[i];
		}
		if (A[i] < minA) {
			minA = A[i];
		}
	}

	cout << abs(maxA - minA) << endl;



	return 0;
}

Measured memory_bytes: 256
from math import atan2, degrees

a, b, x = map(int, input().split())

if a * a * b == x:
    print(0)
    exit()
elif a * a * b / 2 <= x:
    z = a * b - (x / a)

    y = (z / a) * 2

    #print(z, y)

    print(degrees(atan2(y, a)))
else:
    print(degrees(atan2(b, (x/a) * 2 / b)))

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] num = new int[3];
		for(int i = 0;i < 3;++i)
			num[i] = sc.nextInt();
		sc.close();
		
		Arrays.sort(num);
		int ans = num[0] + num[1] + num[2]*10;
		System.out.println(ans);
	}
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int mod;

template <typename T>
using Matrix = vector<vector<T>>;

template <typename T>
void init_mat(Matrix<T> &A, int h, int w){
    A.resize(h,vector<T>(w,0));
}

template <typename T>
Matrix<T> calc_mat(Matrix<T> A, Matrix<T> B){
    Matrix<T> C(A.size(),vector<T>(B[0].size()));
    for(int i=0; i<A.size(); i++){
        for(int k=0; k<B.size(); k++){
            for(int j=0; j<B[0].size(); j++){
                C[i][j]=(C[i][j]+A[i][k]*B[k][j])%mod;
            }
        }
    }
    return C;
}

template <typename T>
Matrix<T> pow_mat(Matrix<T> A, int pow){
    Matrix<T> B(A.size(),vector<T>(A.size()));
    for(int i=0; i<A.size(); i++)B[i][i]=1;
    while(pow>0){
        if(pow%2==1)B=calc_mat(B, A);
        A=calc_mat(A, A);
        pow/=2;
    }
    return B;
}

signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int L,A,B,M; cin>>L>>A>>B>>M;
    mod=M; int cur10=1,ans=0;
    rep(i,18){
        int fir=max<int>(A,A+(cur10-A+B-1)/B*B);
        cur10*=10;
        int las=min<int>(A+(L-1)*B,A+(cur10-A+B-1)/B*B-B);
        int num=(las-fir)/B+1;
        if(num<=0)continue;

        Matrix<int> mat1,mat2;
        init_mat(mat1,1,3); init_mat(mat2,3,3);
        mat1[0][0]=ans; mat1[0][1]=fir%mod; mat1[0][2]=1;
        mat2[0][0]=cur10%mod; mat2[0][1]=mat2[0][2]=mat2[1][2]=mat2[2][0]=0;
        mat2[1][0]=mat2[1][1]=mat2[2][2]=1; mat2[2][1]=B%mod;
        
        mat2=pow_mat(mat2,num);
        mat1=calc_mat(mat1,mat2);
        ans=mat1[0][0];
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  char str[100];
    scanf("%s", str);
  int i=0,sum,count=0;
while(str[i]!=0){
  if(str[i]=='A')sum++;
  else if(str[i]=='C')sum++;
  else if(str[i]=='G')sum++;
  else if(str[i]=='T')sum++;
  else sum=0;
  
  if(count<=sum){count=sum;}
  	i++;
}
printf("%d",count);
 return 0;
}


Measured memory_bytes: 128
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

map<int, bool> ok;

int main(){
	FIO
	
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)cin >> a[i];
	for(int i = 0; i < (1 << n); i++){
		int sum = 0;
		for(int j = 0; j < n; j++){
			if(i & (1 << j))sum += a[j];
		}
		ok[sum] = true;
	}
	int q;
	cin >> q;
	while(q--){
		int x;
		cin >> x;
		if(ok[x])puts("yes");
		else puts("no");
	}
	return 0;
}



Measured memory_bytes: 3124
n = int(input())
a = list(map(int, input().split()))
ave = sum(a)//n
ave1 = ave + 1
ans = 0
ans1 = 0
for i in range(n):
    ans += (a[i] - ave)**2
    ans1 += (a[i] - ave1)**2
print(min(ans, ans1))

Measured memory_bytes: 38384
n = int(input())
l = list(map(int, input().split()))

sum = 0
counter = 1
left = 0

for i in range(left, n):
    if l[i] == counter:
        sum += i-left
        counter += 1
        left = i+1
        continue
sum += n-left

if counter == 1:
    print(-1)
else:
    print(sum)


Measured memory_bytes: 77516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int x,n,p;
	cin >> x >> n;
	set< int > s;
	for (int i=0; i<n; i++) cin >> p, s.insert(p);
	int ans = 1e3, ansN = x-1;
	for (int i=x-100; i<=x+100; i++) {
		if (s.count(i) > 0) continue;
		int v = abs(x-i);
		if (v < ans) ans = v, ansN = i;
	}
	cout << ansN;
	return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
double jordan(double f[][3]);
int main(void){
    int i,j,a;
    double f[2][3];
    while(scanf("%d",&a)!=EOF){
        for(i=0;i<2;i++){
            for(j=0;j<3;j++) {
                if(i==0&&j==0) f[0][0]=(double)a;
                else scanf("%lf",&f[i][j]);
            }
        }
        jordan(f);
        printf("%.3lf %.3lf\n",f[0][2],f[1][2]);
    }
    return 0;
}

double jordan(double f[][3]){
    int i,j,k;
    double pivot,del;
    for(i=0;i<2;i++){
        pivot=f[i][i];
        for(j=i;j<3;j++){
            f[i][j]/=pivot;
        }
        for(k=0;k<2;k++){
            del=f[k][i];
            for(j=i;j<3;j++){
                if(k!=i) f[k][j]-=del*f[i][j];
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define INF 1e18
#define MAXN 200000

/*
Define dp[i] as maximum possible score out of the first i characters of the string, given the
i-th character is a 1.

dp[i] = max(dp[j] + (sum of value of all segments whose l is j < l <= i and whose r is r >= i))

Naive iteration will yield O(N^2) complexity, hence we need to use a segment tree and line sweep.
The i-th element in the segment tree will contain the value dp[i] + (sum of value of desired segments).
In order for our segment tree always maintain correct value, we have to consider two cases:
* Whenever we encounter a beginning of a segment, we will update our segment tree at index 0..l[i] - 1 by +a
* Whenever we encounter an ending of a segment, we will update our segment tree at index 0..l[i] - 1 by -a.
*/

LL tree[4 * MAXN + 3], lazy[4 * MAXN + 3];

LL evaluate(int node) {
    return tree[node] + lazy[node];
}

void pushDown(int node) {
    lazy[2 * node] += lazy[node];
    lazy[2 * node + 1] += lazy[node];
    lazy[node] = 0;
}

void pullUp(int node) {
    tree[node] = max(evaluate(2 * node), evaluate(2 * node + 1));
}

void update(int node, int l, int r, int le, int ri, LL val) {
    if (r < le || l > ri)
        return;

    if (l >= le && r <= ri) {
        lazy[node] += val;
        return;
    }

    pushDown(node);

    int m = (l + r)/2;
    update(2 * node, l, m, le, ri, val);
    update(2 * node + 1, m + 1, r, le, ri, val);

    pullUp(node);
}

LL query(int node, int l, int r, int le, int ri) {
    if (r < le || l > ri)
        return -INF;

    if (l >= le && r <= ri)
        return evaluate(node);

    pushDown(node);

    int m = (l + r)/2;
    LL leftResult = query(2 * node, l, m, le, ri);
    LL rightResult = query(2 * node + 1, m + 1, r, le, ri);

    pullUp(node);

    return max(leftResult, rightResult);
}

int N, M, l[MAXN + 3], r[MAXN + 3], a[MAXN + 3];
vector<pair<int, int> > events[MAXN + 3]; //{type, idx}
LL dp[MAXN + 3], answer;

int main() {
    scanf("%d%d", &N, &M);
    for (int i = 1; i <= M; i++) {
        scanf("%d%d%d", &l[i], &r[i], &a[i]);

        events[l[i]].push_back({1, i});
        events[r[i] + 1].push_back({-1, i});
    }

    //Init segment tree
    for (int i = 0; i <= 4 * N; i++) {
        tree[i] = 0;
        lazy[i] = 0;
    }

    dp[0] = 0;
    update(1, 0, N, 0, 0, dp[0]);

    answer = 0;
    for (int i = 1; i <= N; i++) {
        //process all events at index i
        for (auto e: events[i]) {
            int type = e.first, idx = e.second;
            if (type == -1)
                update(1, 0, N, 0, l[idx] - 1, -a[idx]);
            else
                update(1, 0, N, 0, l[idx] - 1, +a[idx]);
        }

        dp[i] = query(1, 0, N, 0, i - 1);
        update(1, 0, N, i, i, dp[i]);

        answer = max(answer, dp[i]);
    }

    printf("%lld\n", answer);
}


Measured memory_bytes: 31876
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include <cstring>
#include<bits/stdc++.h>
using namespace std;   
int main()
{
	string s;
	cin>>s;
	int cnt=0;
	for (int i=0;i<3;i++)
	{
		if (s[i]=='o') cnt++;
	}
	cout<<700+cnt*100;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k;	cin>>n>>k;
	int h[n],i,j;
	for(i=0;i<n;i++){
		cin>>h[i];
	}

	int ans[n];
	ans[n-1]=0;
	for(i=n-2;i>=0;i--){
		int temp=1000000000;
		for(j=i+1;j<=min(n-1,i+k);j++){
			temp=min(temp, ans[j]+abs(h[j]-h[i]));
		}
		ans[i]=temp;
	}
	cout<<ans[0]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, M;
  int ans = 0;
  string s;

  cin >> N;

  int gu = N/2;
  int ki = N-gu;

  cout << gu*ki<< endl;
}


Measured memory_bytes: 256
n = int(input())
primes = [0 for i in range(n)]
for i in range(2, n+1):
    tmp = i
    for j in range(2, i+1):
        while(tmp % j == 0):
            primes[j-1] += 1
            tmp = tmp // j

def num(m):
    return len(list(filter(lambda x: x >= m -1, primes)))

print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) // 2)

Measured memory_bytes: 3064
def GCD(a,b):
    c=b//a
    d=b%a
    if d==0:
        return a
    else:
        return GCD(d,a)

A,B=map(int,input().split())
if A>B:
  a=A
  b=B
else:
  a=B
  b=A
print(int(a*b/GCD(a,b)))

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

int main() {
	int a,b,c,w;
	while(cin>>a>>b,a!=0&&b!=0){
		if(b>a){w=a;a=b;b=w;}
		c=0;
		while(a!=0){
			c++;
			w=a;a=b%a;b=w;
		}
		if(c!=1)c--;
		cout<<b<<" "<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160