akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
using namespace std;
const long long MOD = 1000000007;

char S[100009];

int main()
{
	int ret;

	ret = scanf("%s", &S);

	long long count[13];
	long long countB[13];
	count[0] = 1;
	count[1] = 0;
	count[2] = 0;
	count[3] = 0;
	count[4] = 0;
	count[5] = 0;
	count[6] = 0;
	count[7] = 0;
	count[8] = 0;
	count[9] = 0;
	count[10] = 0;
	count[11] = 0;
	count[12] = 0;

	for (int i = 0; S[i] != '\0'; i++) {
		char c = S[i];

		//10倍
		for (int j = 0; j < 13; j++) { countB[j] = count[j]; }
		count[0] = countB[0];
		count[10] = countB[1];
		count[7] = countB[2];
		count[4] = countB[3];
		count[1] = countB[4];
		count[11] = countB[5];
		count[8] = countB[6];
		count[5] = countB[7];
		count[2] = countB[8];
		count[12] = countB[9];
		count[9] = countB[10];
		count[6] = countB[11];
		count[3] = countB[12];

		//--------- 桁の処理
		if (c == '?') {
			for (int j = 0; j < 13; j++) { countB[j] = count[j]; }
			for (int j = 0; j < 13; j++) { count[j] = 0; }

			for (int j = 0; j < 13; j++) {
				long long val = countB[j];
				for (int k = 0; k < 10; k++) {
					count[(j + k) % 13] += val;
					count[(j + k) % 13] = count[(j + k) % 13] % MOD;
				}
			}
		}
		else {//数字の時
			int num = c - '0';
			for (int j = 0; j < 13; j++) { countB[j] = count[j]; }
			for (int j = 0; j < 13; j++) {
				count[(j+num)%13] = countB[j];
			}
		}
	}

	printf("%lld", count[5]);

end:
	return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    for (int i = 0; i < N; i++)
        cin >> x[i];

    int res = 1000000000;
    for (int i = 0; i < N - K + 1; i++) {
        if (abs(x[i]) < abs(x[i + K - 1])) {
            res = min(res, abs(x[i]) + abs(x[i + K - 1] - x[i]));
        } else {
            res = min(res, abs(x[i + K - 1]) + abs(x[i + K - 1] - x[i]));
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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;
}

ll M = 1000000007;

void solve()
{
	int n;
	cin>>n;
	vector<int>a(n);
	map<int,int>count;
	ll sum=0;
	map<int,int>f;
	rep(i,n){
		cin>>a[i];
		sum+=a[i];
		count[a[i]]++;
		
	}
	int q;
	cin>>q;
	
	rep(i,q){
		ll b,c;
		cin>>b>>c;
		ll cnt=count[b];
		ll dis=(c-b)*cnt;
		count[c]+=count[b];
		count[b]=0;
		sum+=dis;
		cout<<sum<<endl;
	}

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 8024
#include <bits/stdc++.h>
using ll = long long;
// #define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
// const int MOD = 1000000007;

template <typename T>
void __print__(std::ostream &os, const char *, const char *tail, const T &fst) {
    os << fst << tail;
}
template <typename Fst, typename... Rst>
void __print__(std::ostream &os, const char *del, const char *tail, const Fst &fst,
               const Rst &... rst) {
    os << fst << del;
    __print__(os, del, tail, rst...);
}

#ifdef LOCAL
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __print__(os, ", ", "\n", __VA_ARGS__);           \
        std::cerr << os.str();                            \
    } while (0)
#else
#define dump(...)
#endif

template <typename Fst, typename... Rst>
void println(const Fst &fst, const Rst &... rst) {
    __print__(std::cout, "\n", "\n", fst, rst...);
}
template <typename Fst, typename... Rst>
void print(const Fst &fst, const Rst &... rst) {
    __print__(std::cout, " ", "\n", fst, rst...);
}

template <typename iter>
void println_(iter bgn, iter end) {
    while (bgn != end) println(*bgn++);
}

template <typename iter>
void print_(iter bgn, iter end) {
    while (bgn != end) {
        std::cout << *bgn++;
        std::cout << (bgn == end ? "\n" : " ");
    }
}

int _ = (std::cout.precision(10), std::cout.setf(std::ios::fixed), std::cin.tie(0),
         std::ios::sync_with_stdio(0), 0);

template <typename T>
std::vector<T> ndarray(int n, T v) {
    return std::vector<T>(n, v);
}
template <typename... Args>
auto ndarray(int n, Args... args) {
    auto val = ndarray(args...);
    return std::vector<decltype(val)>(n, move(val));
}

template <typename T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, true : false;
}

template <typename T>
bool umin(T &a, const T &b) {
    return a > b ? a = b, true : false;
}

using namespace std;

int main() {
    int n, k;
    while (cin >> n >> k && n) {
        int a[100010];
        rep(i, n) cin >> a[i];
        int g = a[0];
        bool ok = false;
        rep(i, n) {
            g = __gcd(g, a[i]);
        }
        rep(i, n) {
            if (a[i] >= k && (a[i] - k) % g == 0) {
                ok = true;
            }
        }
        print(ok ? "POSSIBLE" : "IMPOSSIBLE");
    }
}


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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define ll long long  int
#define ld long double
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define pi 3.14159265358979
#define pa pair<ll,ll>
//#define goodset tree<pa, null_type, less<pa>, rb_tree_tag, tree_order_statistics_node_update>
//#define FRE freopen("acm.in","r",stdin); freopen("acm.out","w",stdout);

const ll mod = 1e9+7 ;
const ll N = 2e5+5;

ll par[N],val[N];
ll root (ll u)
{
    if(par[u]==u)
        return u;
    return par[u]=root(par[u]);
}
int main()
{
    ll i,j,k,tc;
    //cin>>tc;
    tc=1;
    while(tc--)
    {
       ll n,m;
       cin>>n>>m;
       for(i=1; i<=n; i++)
    {
        par[i]=i;
        val[i]=1;
    }
       for(i=0; i<m; i++)
       {
           ll u,v;
           cin>>u>>v;
            ll u1=root(u);
            ll u2=root(v);
            if(u1!=u2)
            {
                par[u1]=u2;
                val[u2]+=val[u1];
                val[u1]=0;
            }
       }
       ll ans=0;
       for(i=1; i<=n; i++)
       {
           ans=max(ans,val[i]);
       }
       cout<<ans<<"\n";
    }

    return 0;
}


Measured memory_bytes: 6760
using System;

namespace ITP1_7_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, x, count ;
            while(true)
            {
                string[] str = Console.ReadLine().Split(' ');
                n = int.Parse(str[0]);
                x = int.Parse(str[1]);
                if (n == 0 && x == 0)
                    break;
                count = 0;
                for (int i = 1; i <= min(n - 2, x / 3 - 1); i++) 
                {
                    for (int j = i + 1; j <= min(n - 1, x - i - 1); j++) 
                    {
                        for (int k = j + 1; k <= min(n, x - i - j); k++) 
                        {
                            if ((i + j + k) == x)
                                count += 1;
                        }
                    }

                }
                Console.WriteLine("{0}", count);
            }
        }

        static int min(int a, int b)
        {
            if (a < b)
                return a;
            else
                return b;
        }
    }
}

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

int gcd(int x, int y)
{
    if(x < y)
        swap(x, y);

    while(y > 0)
    {
        int r = x % y;
        x = y;
        y = r;
    }

    return x;
}

int main()
{
    int x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
    char str1[32];
	cin >> str1;

    str1[5] = ' ';
	str1[13] = ' ';

	cout << str1 << endl;

	return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int w, a, b;
  cin >> w >> a >> b;
  int la = a, ra = a + w;
  int lb = b, rb = b + w;
  if (lb > ra) cout << lb - ra << '\n';
  else if (rb < la) cout << la - rb << '\n';
  else cout << 0 << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	int even = 0;
	int N = in();
	vint data(N);
	rep(i,N) {
		data[i] = in();
		if (data[i] % 2 == 0) even++;
	}
	cout << pow(3, N) - pow(2, even) << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#define M 100

int D[M][M];
int n;

int main() {

  int i,j;
  int num,cout,a;
  
  scanf("%d",&n);

  for(i=0;i<n;i++) {
    for(j=0;j<n;j++) {
      D[i][j] = 0;
    }
  }

  for(i=0;i<n;i++) {
    scanf("%d",&num);
    scanf("%d",&cout);
    for(j=0;j<cout;j++) {
      scanf("%d",&a);
      D[num-1][a-1] = 1;
    }
  }

  for(i=0;i<n;i++) {
    for(j=0;j<n;j++) {
      if(j>0) printf(" ");
      printf("%d",D[i][j]);
    }
    printf("\n");
  }
  
  return 0;

}



Measured memory_bytes: 2112
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define INF 1<<30

int main(){
  long a,b;
  cin>>a>>b;

  if(a*b<=0) cout<<"Zero"<<endl;
  else if(a>0) cout<<"Positive"<<endl;
  else if((b-a)%2==1) cout<<"Positive"<<endl;
  else cout<<"Negative"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a , b, rez, c;
    cin>>a;
    for(int i=1; i<=a; ++i)
    {
        cin>>b;
        if(b%2==0 && (b%3!=0 && b%5!=0 ))
            {cout<<"DENIED";
        return 0;}
    }
    cout<<"APPROVED";
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define DOW(i,b,a) for (int i = (b); i >= (a); i--)
#define pb(a) push_back(a)
#define ALL(a) (a).begin(),(a).end()
#define fi first
#define se second

template<typename T>
void print_array(T* arr, int num) {
   FOR(i, 0, num) cout << arr[i] << ' ';
   cout << endl;
}

template<typename T> 
void print_vector(vector<T> vec) {
   FOR(i,0,vec.size()) cout << vec[i] << ' ';
   cout << endl;
}

string a,b;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
   // freopen("test.txt", "r", stdin);
    cin >> a >> b;
    if (a.length() > b.length()) cout << "GREATER";
    else if (a.length() < b.length()) cout << "LESS";
    else {
        FOR(i,0,a.length()) {
            if (a[i] > b[i]) {
                cout << "GREATER";
                return 0;
            } else if (a[i] < b[i]) {
                cout << "LESS";
                return 0;
            }
        }
        cout << "EQUAL";
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		char a[]=s.toCharArray();
		int c=0;
		int j=1;
		for(int i=0;i<n-2;i++) {
			if(a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C')
				c++;
		}
		System.out.println(c);


	}

}


Measured memory_bytes: 23508
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
int main(){
	int count=0,judge=0,J=0,len;

	string S;
	cin>>S;
	len=S.size();
	if(S[0]=='A'){
		for(int i=2;i<len-1;i++){
			if(S[i]=='C')count++;
		}
		if(count==1){
			for(int i=1;i<len;i++){
				judge=1;
				if(('a'<=S[i])&&(S[i]<='z')){
					judge=0;
				}else if(S[i]=='C'){
					judge=0;
				}
				if(judge==1){
					J=1;
					break;
				}
			}
		}else J=1;
	}else J=1;
	if(J==0)cout<<"AC"<<endl;
	else cout<<"WA"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int INF = 1000000000;

int main(){
	int n,k,q;
	int a[2000];
	int ans = INF;
	scanf("%d%d%d",&n,&k,&q);
	for(int i=0;i<n;i++) scanf("%d",a+i);
	for(int i=0;i<n;i++){
		vector<int> v[2000];
		int cnt = 0;
		for(int j=0;j<n;j++){
			if(a[j]<a[i]) cnt++;
			else v[cnt].push_back(a[j]);
		}
		if((int)v[cnt].size()!=0) cnt++;
		vector<int> u;
		for(int j=0;j<cnt;j++){
			sort(v[j].begin(),v[j].end());
			for(int l=0;l<=(int)v[j].size()-k;l++){
				u.push_back(v[j][l]);
			}
		}
		if(u.size()<q) continue;
		sort(u.begin(),u.end());
		ans = min(ans,u[q-1]-a[i]);
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a;
		int b;
		cin >> a >> b;
		cout << a + b << endl;
	}
}

Measured memory_bytes: 256
var
	N,i,j,ans:int64;
begin
	read(N);
	i:=1;
	while i<=N do begin
		j:=N div(N div i)+1;
		inc(ans,(j-i)*(i+j-1)*(N div i)*(N div i+1)div 4);
		i:=j;
	end;
	writeln(ans);
end.

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

using namespace std;

const int INF = 1e9 - 7;
int n,k;
vector<long long> h, dp;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	h = vector<long long>(n );
	dp = vector<long long>(n, INF);
	for(auto &it : h) cin >> it;
	dp[0] = 0;
	for(long long i=0 ; i<n ; i++){
		for(long long j = i + 1 ; j <=i + k ; j++){
			if( j < n){
				dp[j] = min(dp[j],dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	cout << dp[n - 1] <<"\n";
	

	return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    int d;
    int x;
    for (int i = 0; i < K; i++) {
        cin >> d;
        for (int j = 0; j < d; j++) {
            cin >> x;
            x--;
            A[x]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#define MAX 500000
#define SENTINEL 2000000000;

int L[MAX/2+2], R[MAX/2+2];
int cnt;
 
void merge(int A[], int n, int left, int mid, int right){
   int n1 = mid - left;
   int n2 = right - mid;  
   for( int i=0; i<n1; i++) L[i] = A[left + i];
   for( int i=0; i<n2; i++) R[i] = A[mid + i];
   L[n1] = R[n2] = SENTINEL;
   int i=0, j=0;
   for(int k = left; k<right; k++){
      cnt++;
      if(L[i] <= R[j]){
         A[k] = L[i++];
      } else {
         A[k] = R[j++];
      }
   }
}

void mergeSort(int A[], int n, int left, int right){
   if(left+1 < right){
      int mid = (left + right) / 2;
      mergeSort(A, n, left, mid);
      mergeSort(A, n, mid, right);
      merge(A, n, left, mid, right);
   }
}

int main(){
   int A[MAX], n, i;
   cnt = 0;

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

   mergeSort(A, n, 0, n);

   for(i=0; i<n; i++){
      if( i ) printf(" ");
      printf("%d", A[i]);
   }
   
   printf("\n");

   printf("%d\n", cnt); 

   return 0;
}


Measured memory_bytes: 5628
k = int(input())

counter = 0
num_object = [i for i in range(1,10)]

ketaflag_min = 0
ketaflag_max = len(num_object)
index = 1
if k <= 10:
    print(k)

else:
    while True:
        # print(ketaflag_min,ketaflag_max)
        for i in range(ketaflag_min,ketaflag_max):
            last_keta = num_object[i] % 10
            # print(i, num_object[i])
            if last_keta != 9 and last_keta != 0:
                max_keta = last_keta + 1
                min_keta = last_keta - 1
                newnum_max =  num_object[i] * 10 + max_keta
                newnum_mid =  num_object[i] * 10 + last_keta
                newnum_min =  num_object[i] * 10 + min_keta
                num_object.append(min(newnum_max,newnum_min))
                num_object.append(newnum_mid)
                num_object.append(max(newnum_max,newnum_min))
            elif last_keta == 9:
                newnum_min = num_object[i] * 10 + 8
                newnum_mid = num_object[i] * 10 + 9
                num_object.append(newnum_min)
                num_object.append(newnum_mid)
            else:
                newnum_min = num_object[i] * 10 + 0
                newnum_mid = num_object[i] * 10 + 1
                num_object.append(newnum_min)
                num_object.append(newnum_mid)
            if len(num_object) >= k:
                print(num_object[k-1])
                exit()
        ketaflag_min = ketaflag_max
        ketaflag_max = len(num_object)
        # print(num_object)


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

/*

 A^5-B^5
=(A-B)(A^4+A^3B+A^2B^2+A^3B+B^4)=X

A>B
A^4<X
B^4<X<200^4


*/

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

	long long X;
	scanf("%lld", &X);

	for (long long B = -200; B <= 200; B++) {
		for (long long A = B + 1; A <= 200; A++) {
			if (X == A * A * A * A * A - B * B * B * B * B) {
				cout << A << " " << B;
				return 0;
			}
		}
	}
	// cout << "NOTFOUND";
	return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int digit(long long int a)
{	
	int  ans = 0;
	while(a > 0){
		a/=10;
		ans++;
	}

	return ans;
}


int main() {
	int i;
	int count = 1;
	long long int N, A = 1, B;
	int ans = 15;

	cin >> N;

	while ((double)A <= sqrt((double)N))
	{
		if (N % A == 0)
		{
			B = N/A;
			count = max(digit(A),digit(B));
			if (ans > count)
			{
				ans = count;
			}
			
		}
		A++;
	}

	
	cout << ans <<endl;

}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int n,m;
int i,j;
int d[100000];
int main(){
		scanf("%d %d",&n,&m);
		d[0]=0;
		int x;
		for(i=0;i<n-1;i++){
			scanf("%d",&x);
			d[i+1]=d[i]+x;
		}
		int ans=0;
		int pos=0;
		for(i=0;i<m;i++){
			scanf("%d",&x);
			ans=(ans+abs(d[pos+x]-d[pos]))%100000;
			pos+=x;
		}
		printf("%d\n",ans);
}

Measured memory_bytes: 1412
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n, L;
int a[N];
int main() {
	#ifdef wws
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n >> L;
	rep(i, 1, n) {
		cin >> a[i];
	}
	int p = -1;
	rep(i, 1, n - 1) {
		if (a[i] + a[i + 1] >= L) {
			p = i;
		}
	}
	if (p == -1) cout << "Impossible", ioi;
	vector <int> ans;
	rep(i, p, n - 1) ans.pb(i);
	per(i, p - 1, 1) ans.pb(i);
	reverse(all(ans));
	cout << "Possible\n";
	for (auto it : ans) cout << it << nl;
	ioi
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)
 
const int MAXN = 1e6+5;
const int MOD = 1e9+7;
const int INF = 1e9+1;

int X;
int dp[MAXN];
vector<int> V = {100,101,102,103,104,105};

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> X;
    dp[0] = 1;
    for(int v : V) {
        fore(i,v,X) {
            if(dp[i-v]) dp[i] = 1;
        }
    }

    cout << dp[X] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int h, w;
  cin >> h >> w;
  vector<string> g(h+1);
  rep(i, h) {
    string s;
    cin >> s;
    s += '.';
    g[i] = s;
  }
  g[h] = g[h-1];

  vector<vi> dp(h+1, vi(w+1));
  dp[0][0] = 1;

  constexpr ll mod = 1e9+7;

  rep(i, h) {
    rep(j, w) {
      if (g[i][j+1] == '.') (dp[i][j+1] += dp[i][j]) %= mod;
      if (g[i+1][j] == '.') (dp[i+1][j] += dp[i][j]) %= mod;
    }
  }

  cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 6144
a = gets.split.map(&:to_i)

if a[0] == a[1] && a[1] == a[2]
  cnt = 1
else
  if a.count(a[0]) > 1
    cnt = 2
  elsif a.count(a[1]) > 1
    cnt = 2
  else
    cnt = 3
  end
end

puts cnt


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

int main() {
	int N, ans;
	cin >> N;
	std::vector<int> W(N), sa(N);

	for(int i = 0; i < N; i++){
		cin >> W[i];
		sa[0] += W[i];
	}
	sa[0] -= 2*W[0];
	for(int i = 1; i < N; i++){
		sa[i] = sa[i-1] - 2*W[i];
	}
	ans = sa[0];
	for(int i = 1; i < N; i++){
		if(abs(sa[i]) < abs(sa[i-1]))ans = abs(sa[i]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100001][4],f[100001][4]={0};
int main()
{
	int i,k,j,m,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=3;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=3;j++)
		{
			for(k=1;k<=3;k++)
			{
				if(k!=j)
					f[i][j]=max(f[i][j],f[i-1][k]+a[i][j]);
			}
		}
	}
	printf("%d",max(max(f[n][1],f[n][2]),f[n][3]));
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
map<pii,int> Mp;
int H , W;
ll ans[10];

int main(){
    scanf("%d%d",&H,&W);
    int n;scanf("%d",&n);
    rep(i,0,n){
        int x , y;
        scanf("%d%d",&x,&y);
        rep(dx,-2,1) rep(dy,-2,1){
            int nx = x + dx , ny = y + dy;
            if(nx >= 1 && nx <= H - 2 && ny >= 1 && ny <= W - 2) Mp[mp(nx,ny)]++;
        }
    }
    ll all = 1ll * (W - 2) * (H - 2);
    for(auto e : Mp) ans[e.se]++ , all--;
    ans[0] = all;
    rep(i,0,10) printf("%lld\n",ans[i]);
    return 0;
}


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

namespace diverta2019A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NK = CIN.IntArray();
            Console.WriteLine(NK[0] - NK[1] + 1);
        }
    }
    
    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 11348
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

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

    ll N, M; cin >> N >> M;
    vl A(N); REP(i, N) cin >> A[i];
    vl B(M), C(M); REP(i, M) cin >> B[i] >> C[i];

    priority_queue<ll> pq;
    map<ll, ll> mp;
    REP(i, N) {
        if (mp[A[i]] == 0) {
            pq.push(A[i]);
        }
        mp[A[i]]++;
    }

    REP(i, M){
        if (mp[C[i]] == 0) {
            pq.push(C[i]);
        }
        
        if (mp[C[i]] < N) {        
            mp[C[i]] += B[i];
        }
    }

    ll ans = 0;
    REP(i, N) {
        ll hi = pq.top();
        mp[hi]--;
        if (mp[hi] == 0) pq.pop();

        ans += hi;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16624
#include <iostream>

using namespace std;

int main()
{
    string s ;
    cin>>s ;
    int ans = 700 ;
    for(int i = 0 ; i < 3 ; ++i)
        if(s[i] == 'o')
         ans += 100 ;
    cout<<ans;
    return 0 ;
}


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

// # DEFINES # //
#define ll long long
#define M (ll)1e9+7
#define EPS 1e-9

using namespace std;


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



    ll a, b;

    cin >> a >> b;

    ll m1 = a + a-1;
    ll m2 = a + b;
    ll m3 = b + b-1;

    cout << max(m1, max(m2, m3)) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
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; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
ll lcm(ll x, ll y){
  return x / gcd(x,y) * y;
}
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main(){
  int h, a; cin >> h >> a;
  
  cout << (h+a-1)/a;
  
return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL MOD = 1000000007LL;
int cnt[100000];
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b; a--; b--;
		cnt[a]++;
		cnt[b]++;
	}
	for (int i = 0; i < N; i++) {
		if (cnt[i] % 2) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cerr << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i <= en; i++)
#define all(v) (v).begin(),(v).end()
#define X first
#define Y second
#define pb push_back
#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t main(){ fast;
	int n; cin>>n;
	int ans = 0;
	forr(i, 1, n){
		int x; cin>>x;
		if(i & 1 && x & 1 ){
			ans++;
		}
	}
	cout<<ans<<endl;
}
	


Measured memory_bytes: 3520
#include "iostream"
#include "algorithm"
#include "vector"

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;

  long long a[N];
  for (size_t i = 0; i < N; i++) {
    /* code */
    std::cin >> a[i];
  }

 long long res = 0;

 for (size_t i = 0; i < N; i++) {
   /* code */
   res += a[i] -1;
 }

 std::cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005
  
typedef struct pp{
  char name[100];
  int t;
}P;
  
P Q[LEN+1];
int head, tail, n;
  
void enqueue(P x){
  Q[tail] = x;
  if(tail + 1 == LEN + 1)
   tail = 0;
  else
   tail++;
}
  
P dequeue(){
  P a;
  a = Q[head];
  if(head + 1 == LEN + 1)
   head = 0;
  else
   head++;
  return a;
}
  
int isEmpty(){
  if(head == tail)
     return 1;
  else
     return 0;
}
  
int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  
  head = 1;
  tail = n + 1;
    
  for(;;){
    u = dequeue();
    c = u.t - q;
      
    if(c > 0){
      elaps += q;
      u.t = c;
      enqueue(u);
    }
      
    else if(c <= 0){
      elaps += u.t;
      printf("%s %d\n", u.name, elaps);
    }
  
    if(isEmpty() == 1)
      break;
    else
      continue;
  }
  return 0;
}

Measured memory_bytes: 10756
N=int(input())
S=input()
L=[chr(i) for i in range(97, 97+26)]
ans0 = 0

for i in range(N-1):
  s1=S[0:i+1]
  s2=S[i+1:N]
  ans = 0
  for j in L:
    if ((j in s1) & (j in s2)):
      ans = ans + 1
    #print(ans)
  if ans0 < ans:
    ans0 = ans
print(ans0)
    


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

int xs[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
int ys[8] = {1, 1, 1, 0, 0, -1, -1, -1};

int h, w;

bool check(int x, int y){
    if (x >= 0 && x < h && y >= 0 && y < w){
        return true;
    }
    
    return false;
}

int main(){
    
    //int h, w;
    cin >> h >> w;
    
    string s;
    vector<vector<int>>arr(h, vector<int>(w));
    for(int i = 0; i < h; i++){
        cin >> s;
        for(int j = 0; j < w; j++){
            s[j] == '.' ? arr[i][j] = 1 : arr[i][j] = 0; 
        }
    }
    string res;
    for(int i = 0; i < h; i++){
        res = "";
        for(int j = 0; j < w; j++){
            if(arr[i][j] == 1){
                int total = 0;
                for(int k = 0; k < 8; k++){
                    if(check(i+xs[k], j+ys[k]) && arr[i+xs[k]][j+ys[k]] == 0){
                        total += 1;
                    }
                }
                res += (char)(total + '0');
            }
            else { 
                res += '#'; 
            }
        }
        cout << res  << endl; 
    }
    
    
    return 0;
    
}


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

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

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

int main() {

  int X;
  cin >> X;

  int answer = 1;

  for (int i = 2; i <= X; i++) {

    bool flg = true;
    int count = 2;
    
    while (flg) {
      if (pow(i, count) <= X) {
        answer = max(answer, (int) pow(i,count));
      } else {
        flg = false;
      }
      count++;
    }
  }

  cout << answer << endl;

}

Measured memory_bytes: 256
#coding: utf-8

s = input()
lenS = len(s)
q = int(input())
for i in range(q):
    temp = list(map(str, input().split()))
    idxA = int(temp[1])
    idxB = int(temp[2])
    if temp[0] == 'print':
        print(s[idxA:idxB + 1])
    else:
        head = s[:idxA]
        tail = s[idxB + 1:]
        if temp[0] == 'replace':
            body = temp[3]
        else:
            body = s[idxA:idxB + 1]
            body = body[::-1]
        s = head + body + tail


Measured memory_bytes: 5616
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, W = map(int, input().split())
    item = []
    for _ in range(N):
        w, v = map(int, input().split())
        item.append((w, v))

    dp = [0] * (W + 1)
    for w, v in item:
        for i in range(w, W + 1)[::-1]:
            tmp = dp[i - w] + v
            if tmp > dp[i]:
                dp[i] = tmp

    print(max(dp))


if __name__ == "__main__":
    main()


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

#define PI 3.141592653589793238462643383279
typedef long long ll;
const long double EPS = 1e-9;
const ll MOD = 1e9+7;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << setprecision(20);
    #ifdef LOCAL_TEST
    freopen("input.txt","r",stdin);
    #endif
    int t, x; cin >> t >> x;
    cout << 1.0 * t / x << '\n';
    return 0;
}


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

int ok(string A){
    int notcount = 0;
    int length = A.size();
    for (int i=0; i<length/2; i++){
        if(A.at(i) != A.at(i + length/2)){
            notcount ++;
        }
    }
    if (notcount == 0){
        return 1;
    }
    else{
        return 0;
    }
}

int main(){
    string S;
    cin >> S;

    int count=0;
    int good=0;
    int Sbig = S.size();
    
    while(good == 0){
        S.erase(S.size()-2);
        count += 2;
        if (ok (S) == 1){
            good ++;
        }
    }
    cout << Sbig-count << endl;
}

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

int f[10001]; //f[i]=残りi本使用の時、最大何桁作れるか
int A[9];

int main(){
  int N,M;
  std::cin>>N>>M;

  for(int i=0;i<=N;++i)f[i]=-999999;
  f[0]=0;
  int need[10]={-1,2,5,5,4,5,6,3,7,6};

  for(int i=0;i<M;++i){
    std::cin>>A[i];
  }
  
  std::sort(A,A+M);

  for(int i=0;i<=N;++i){
    for(int j=0;j<M;++j){
      if(i+need[A[j]]>N)continue;
      f[i+need[A[j]]]=std::max(f[i+need[A[j]]],f[i]+1);
    }
  }
  
  std::string ans="";
  int res=N;
  while(res>0){
    for(int i=M-1;i>=0;--i){
      if(need[A[i]]>res)continue;
      if(f[res-need[A[i]]]+1==f[res]){
	ans=ans+(char)('0'+A[i]);
	res-=need[A[i]];
	break;
      }
    }
  }
  std::cout<<ans<<std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n;
  scanf("%d", &n);
  char s[n+1];
  scanf("%s", s);
  int i;
  int num = 0;
  for(i=0;i<n;i++){
    if(s[i]=='R'){
      num++;
    }
  }
  if(num > (n - num)){
    puts("Yes");
  }else{
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main{
  public static void main(String[] args){
  	Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String result = "Good";
    for(int i = 0;i < s.length() - 1; i++){
    	if(s.substring(i,i+1).equals(s.substring(i+1,i+2))){
        	result = "Bad";
          	break;
        }
    }
    System.out.println(result);
  }
}


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

int main(){
	int a,b,n;
	while(cin >> a >> b >> n){
		int ret = 0;
		for(int i=0;i<n;i++){
			a=(a%b)*10;
			ret+=a/b;
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(array.Max() - array.Min());
        }
    }
}


Measured memory_bytes: 13396
function Main(input) {
  var N = parseInt(input.split("\n")[0]);
  var Alist = input.split("\n")[1].split(" ");
  var Blist = input.split("\n")[2].split(" ");
  
  for(var i = 0; i < Alist.length; i++){
    Alist[i] = parseInt(Alist[i]);
    if(i < Blist.length){
       Blist[i] = parseInt(Blist[i]);
    }
  }
  
  var output = 0;
  
  for(var i = 0; i < Blist.length; i++){
    var tmpA1 = Alist[i];
    var tmpA2 = Alist[i + 1];
    var tmpB = Blist[i];
    
    output += Math.min(tmpA1,tmpB);
    tmpB = tmpB - Math.min(tmpA1,tmpB);
    if(tmpB == 0){
       continue;
    }else{
      output += Math.min(tmpA2,tmpB);
      if(tmpA2 - tmpB > 0){
     	Alist[i + 1] = tmpA2 - tmpB;
      }else{
        Alist[i + 1] = 0;
      }
    }
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 31524
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ll n, c;
  cin >> n >> c;
  vector<ll> x(n), v(n);
  rep(i, n) cin >> x[i] >> v[i];
  vector<ll> vsum(n+1);
  rep(i, n) vsum[i+1] = vsum[i]+v[i];
  vector<ll> a1(n+1), a2(n+1);
  rep(i, n) {
    a1[i+1] = max(a1[i], vsum[i+1]-x[i]);
    a2[i+1] = max(a2[i], vsum[i+1]-x[i]*2);
  }
  reverse(a1.begin(), a1.end());
  reverse(a2.begin(), a2.end());
  vector<pair<ll, ll>> b(n+1);
  for (int i = 1; i <= n; i++) {
    b[i].first = (vsum[n]-vsum[n-i])-(c-x[n-i]);
    b[i].second = c-x[n-i];
  }
  ll ans = 0;
  rep(i, n+1) {
    chmax(ans, a1[i]+b[i].first-b[i].second);
    chmax(ans, a2[i]+b[i].first);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <cassert>
using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;

int N,M;
const int MAX_N = 20010;
const int MAX_M = 160010;

struct pt{
	int x,id;
	pt(){}
	pt(int x_,int id_):x(x_),id(id_){}
	bool operator<(const pt& r)const{
		return x<r.x;
	}
}a[MAX_N];

int pos[MAX_N];
int sz;

mat path,rpath;

bool vsi[MAX_M];
int ID[MAX_M];
vec st;

void add_edge(int x,int y){
	if(x<=0||x==M||x>=M*2){
		puts("-1");
		exit(0);
	}
	if(y<=0||y==M||y>=M*2){
		puts("-1");
		exit(0);
	}
	path[x].push_back(y);
	rpath[y].push_back(x);
}

void update(int x){
	x+=sz;
	while(x>1){
		add_edge(x/2,x);
		add_edge(x/2+M,x+M);
		x>>=1;
	}
}

void update(int x,int L,int R){
	x+=sz,L+=sz,R+=sz;
	while(L<R){
		if(L%2==1)add_edge(x,(L++)+M);
		if(R%2==0)add_edge(x,(R--)+M);
		L>>=1,R>>=1;
	}
	if(L==R)add_edge(x,L+M);
}

void init(int len){
	st.clear();
	memset(vsi,0,sizeof(vsi));
	memset(ID,-1,sizeof(ID));
	path.assign(M*2,vec());
	rpath.assign(M*2,vec());

	for(int i=0;i<N;i+=2){
		add_edge(pos[i],pos[i+1]+M);
		add_edge(pos[i]+M,pos[i+1]);
		add_edge(pos[i+1],pos[i]+M);
		add_edge(pos[i+1]+M,pos[i]);
	}
	for(int i=0;i<N;i++){
		update(i);
	}

	int L=0,R=0;
	for(int i=0;i<N;i++){
		while(L<i&&a[i].x-a[L].x>=len)L++;
		while(R<N&&a[R].x-a[i].x<len)R++;
		update(i,L,i-1);
		update(i,i+1,R-1);
	}
}

void dfs(int v){
	vsi[v]=1;
	for(auto& u:path[v]){
		if(vsi[u])continue;
		dfs(u);
	}
	st.push_back(v);
}

void rdfs(int v,int c){
	ID[v]=c;
	for(auto& u:rpath[v]){
		if(ID[u]>=0)continue;
		rdfs(u,c);
	}
}

bool chk(int len){
	init(len);
	vsi[0]=vsi[M]=1;
	for(int i=0;i<M*2;i++){
		if(vsi[i])continue;
		dfs(i);
	}
	int v,c=0;
	while(!st.empty()){
		v=st.back();st.pop_back();
		if(ID[v]>=0)continue;
		rdfs(v,c++);
	}
	for(int i=sz;i<N+sz;i++){
		if(ID[i]==ID[i+M])return 0;
	}
	return 1;
}

int main(){

	scanf("%d",&N);
	N<<=1;
	for(sz=1;sz<N;sz<<=1);
	M=N+sz;

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

	sort(a,a+N);
	for(int i=0;i<N;i++){
		pos[a[i].id]=i+sz;
	}

	int lo=0,hi=1e9,mid;
	while(lo+1<hi){
		mid=(lo+hi)/2;
		if(chk(mid))lo=mid;
		else hi=mid;
	}
	printf("%d\n",lo);

	return 0;
}


Measured memory_bytes: 27896
n=gets.to_i
f=n.times.map{gets.chop.split.join.to_i(2)}
pr=n.times.map{ |i| gets.chop.split.map(&:to_i)}

p 1.upto(2**10-1).map{ |i|
  s=n.times.map{ |j| pr[j][(f[j] & i).to_s(2).chars.count("1")] }.inject(:+)
}.max


Measured memory_bytes: 1916
N,M,C = list(map(int,input().split(" ")))
B = list(map(int,input().split(" ")))
A = [list(map(int,input().split(" "))) for i in range(N)]
ans = []
for i in range(len(A)):
    total=0
    for j in range(len(A[0])):
        #print(A[i][j]*B[j])
        total+=A[i][j]*B[j]
    total+=C
    if total>0:
        ans.append(total)

print(len(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 1e3 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll cnt[Maxn][Maxn];
ll ps[Maxn][Maxn];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, k;
	cin >> n >> k;
	ll x, y;
	char c;
	for(int i = 1; i <= n; i++){
		cin >> x >> y >> c;
		ll z = (x / k) + (y / k) + (c == 'B');
		z &= 1;
		ll al = k - (x % k);
		ll bl = k - (y % k);
		ll del = 1;
		if(z == 1){
			del = -1;
			cnt[0][0] ++;
		}
		cnt[0][0] += del;
		cnt[al][0] -= del;
		cnt[0][bl] -= del;
		cnt[al][bl] += del;
		
		cnt[al][bl] += del;
		cnt[al][k] -= del;
		cnt[k][bl] -= del;
		cnt[k][k] += del;
	}
	ll ans = 0;
	for(int i = 0; i < k; i++){
		for(int j = 0; j < k; j ++){
			//cerr << cnt[i][j] << ',';
			ps[i][j] += cnt[i][j];
			if(j > 0) ps[i][j] += ps[i][j - 1];
			if(i > 0) ps[i][j] += ps[i - 1][j];	
			if((i > 0) && (j > 0)) ps[i][j] -= ps[i - 1][j - 1];
			ans = max(ans, max(ps[i][j], n - ps[i][j]));
			//cerr << ans << '\n';
			//cerr << ps[i][j] << " ";
		}
		//cerr << '\n';
	}
	cout << ans;
	return 0;
}

/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;
ll n,m,q;
vector<ll> a(50),b(50),c(50),d(50);
void call(vector<ll> A,ll & ans)
{
	if(A.size()==n)
	{
		ll k=0;
		for(ll i=0;i<q;i++)
		{
			if(A[b[i]-1]-A[a[i]-1]==c[i])
			k+=d[i];
		}
		ans=max(ans,k);
		return ;
	}
	ll r=1;
	if(A.size()!=0)
	r=A[A.size()-1];
	for(ll i=r;i<=m;i++)
	{
		A.push_back(i);
		call(A,ans);
		A.pop_back();
	}
	
	
}
main()
{
	ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m>>q;
ll ans=0;
vector<ll> A;
for(ll i=0;i<q;i++)
cin>>a[i]>>b[i]>>c[i]>>d[i];
call(A,ans);
cout<<ans;

}

Measured memory_bytes: 3656