akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> b(n),a(n);
    rep(i,n) cin>>b[i];
    rep(i,n){
        int num=-1;
        for(int j=b.size()-1;j>=0;j--){
            if(b[j]==j+1){
                num=j;
                break;
            }
        }
        if(num==-1){
            cout<<-1;
            return 0;
            }
        a[i]=num+1;
        b.erase(b.begin()+num);
    }
    rep(i,n) cout<<a[n-1-i]<<endl;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main(void){
   int a,b,i,s=0,d;
   scanf("%d %d",&a,&b);
   int c[b];
   for(i=0;i<b;i++){
       scanf("%d",&c[i]);
       s+=c[i];
   }
   d=a-s;
   if(d<0){
       d=-1;
   }
   printf("%d",d);
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

typedef struct edge{
    int from;
    int to;
    ll cost;
} edge;
typedef struct DP{
    ll cost;
    int from;
} DP;


int n, m;

vector<edge> G;
DP dp[1010];

bool bellman_ford(int s, int t) { // sは開始頂点, tは目的頂点
  dp[s].cost = 0; // 開始点の距離は0
    REP(i,2*n) {
        for(auto e: G) {
            if (dp[e.from].cost != LINF && dp[e.to].cost > dp[e.from].cost+e.cost) {
                dp[e.to].cost = dp[e.from].cost + e.cost;
                if(i>=n && e.to==t-1) return true;
            }
        }
    }
  return false;
}

int main(int argc, char const *argv[]) {
    cin >> n >> m;
    REP(i,1010) {
        dp[i].cost = LINF;
        dp[i].from = INF;
    }
    REP(i,m) {
        int a, b, c;
        cin >> a >> b >> c;
        edge e = {a-1, b-1, -c};
        G.push_back(e);
    }
    int start = 0;
    sort(G.begin(), G.end(), [](const edge& x, const edge& y) { return x.from < y.from;});
    bool f = bellman_ford(start, n);
    //for(auto x: G) cout << "from = " << x.from << " to = " << x.to << " cost = " << x.cost << std::endl;
    if (f) cout << "inf" << std::endl;
    else cout << -dp[n-1].cost << std::endl;
    return 0;
}

Measured memory_bytes: 384
s,t,_,*z=open(0)
v,w=[0],[0]
for c in s:v+=v[-1]+(c<'B'or 2),
for c in t:w+=w[-1]+(c<'B'or 2),
for x in z:
  a,b,c,d=map(int,x.split())
  print('YNEOS'[(v[b]-v[a-1])%3!=(w[d]-w[c-1])%3::2])

Measured memory_bytes: 20720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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


  string s,t;
  cin >> s >> t;
  rep(i,s.size()){
    if(s[i]!=t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
    cout << "Yes" << endl;
  
  return 0;
    

}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<string> S(n);
  rep(i,n) cin >> S[i];
  vector<int> cnt(26);

  for(int i=0;i<n;i++){
    vector<int> cnt_(26);
    rep(j,26) cnt_[j]=0;
    for(int j=0;j<(int)S[i].size();j++){
      if(i==0){
        cnt[(char)S[i][j]-'a']++;
      }
      else{
        cnt_[(char)S[i][j]-'a']++;
      }
    }
    if(i!=0){
      for(int j=0;j<26;j++){
        cnt[j] = min(cnt[j],cnt_[j]);
      }
    }
  }
  rep(i,26){
    rep(j,cnt[i]){
      cout << (char)('a'+i);
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
s=list(input())
d=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
c=[]
for i in s:
    h=d.index(i)
    h=h+n
    if h>=26:
        h=h-26
    c.append(d[h])
print("".join(c))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#include <boost/multiprecision/cpp_int.hpp> 
using boost::multiprecision::cpp_int; 

int32_t main()
{
	ios_base::sync_with_stdio(0);
	 cin.tie(0); 
	 cout.tie(0);
  
  	cpp_int a;
	 double b;
	cin >> a >> b;
	b = ((b)*(1000.0000000000000000));
	cpp_int n = (cpp_int)b;
	cpp_int x = a;
	cpp_int ans = (n*x);
	cpp_int t = ans/1000;
	cout << t << endl;
}

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

using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

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

int main() {
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a+b>=k)
        cout<<min(a,k);
    else{
        cout<<2*a+b-k;
    }
	return 0;
}

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

bool searchEdge(const int a[][2], int n, int edge[]);
int calcArea(const int a[][2], const int edge[]);

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

	int *s = new int[n];
	for (int i = 0; i < n; i++) cin >> s[i];

	int q;
	cin >> q;

	int *t = new int[q];
	for (int i = 0; i < q; i++) cin >> t[i];

	int c = 0;
	for (int i = 0; i < q; i++) {
		int st = 0, ed = n - 1;
		while (st <= ed) {
			int m = (ed + st) / 2;
			if (t[i] == s[m]) {
				c++;
				break;
			}
			else if (t[i] > s[m]) {
				st = m + 1;
			}
			else if (t[i] < s[m]) {
				ed = m - 1;
			}
		}
	}

	delete[] s, t;

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 3236
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#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>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< 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 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    int N;
    cin >> N;
    int a[3001];
    rep(i, 0, N) cin >> a[i];
    ll ans = 0;
    ll** dp = new ll*[3001];
    rep(i, 0, 3001){
        dp[i] = new ll[3001];
    }
    rep(st, 0, N){
        dp[st][st] = a[st];
    }
    for(int k=1; k<N; k++){
        for(int st=0; st+k<N; st++){
            int en = st + k;
            dp[st][en] = max(a[st] - dp[st+1][en], a[en] - dp[st][en-1]);
        }
    }
    cout << dp[0][N-1] << endl;
    /*
    rep(i, 0, N){
        rep(j, 0, N){
            cout << dp[i][j] << ", ";
        }
        cout << endl;
    }
    */

    rep(i, 0, 3001) delete[] dp[i];
    delete[] dp;
    return 0;
}




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

using namespace std;

class Solution {
public:
	void solve() {
		int n;
		cin >> n;
		vector<int> ans(n, 0);
		for (int i = 0; i < n - 1; i++) {
			int a;
			cin >> a;
			ans[a - 1]++;
		}
		for (int i = 0; i < n; i++) cout << ans[i] << "\n";
		cout << "\n";

		return;
	};
};

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

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int n; scanf("%d", &n);
	vvi v(3, vi(n));
	forn(i, 3) {
		forn(j, n) {
			scanf("%d", &v[i][j]);
		}
	}
	int satis = 0;
	forn(i, n - 1) {
		satis += v[1][v[0][i] - 1];
		if(v[0][i] + 1 == v[0][i + 1]) {
			satis += v[2][v[0][i] - 1];
		}
	}
	satis += v[1][v[0][n - 1] - 1];
	printf("%d", satis);
}










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

//タイマー
class Timer {
	chrono::high_resolution_clock::time_point start, end;
	double limit;

public:
	Timer() {
		start = chrono::high_resolution_clock::now();
	}
	Timer(double l) {
		start = chrono::high_resolution_clock::now();
		limit = l;
	}

	double getTime() {
		end = chrono::high_resolution_clock::now();
		return chrono::duration<double>(end - start).count();
	}

	bool Over() {
		if (getTime() > limit) {
			return true;
		}
		return false;
	}

	void setLimit(double l) {
		limit = l;
	}
	void setStart() { start = chrono::high_resolution_clock::now(); }
};
//疑似乱数
class Xor128 {
	unsigned static int x, y, z, w;
public:
	Xor128() {
		x = 31103110, y = 123456789, z = 521288629, w = 88675123;
	}

	unsigned int rand()
	{
		unsigned int t;
		t = (x ^ (x << 11)); x = y; y = z; z = w;
		return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
	}
};
unsigned int Xor128::x, Xor128::y, Xor128::z, Xor128::w;

int solve(vector<int>&T) {
	int max_s = 0;
	Timer tmr(1.8);
	Xor128 xor128;
	int N = T.size();

	while (!tmr.Over()) {
		sort(T.begin(), T.end());
		int s = 12;
		for (int i = 0; i < N; i++) {
			if (i)s = min(s, T[i] - T[i - 1]);
			else s = min(s, 24 - T[N - 1]);
		}
		max_s = max(max_s, s);

		int r = xor128.rand() % N;
		T[r] = 24 - T[r];
	}

	return max_s;
}

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

	int N; cin >> N;
	vector<int>T(N+1);
	for (int i = 0; i < N; i++)cin >> T[i+1];
	N++;
	cout << solve(T) << endl;

	return 0;
}

Measured memory_bytes: 384
n=int(input())
a=[int(x) for x in input().split()]
a.sort()
lar=sec=i=0
while(i<n-1):
    if a[i]==a[i+1]:
        i+=1
        if a[i]>lar:
            sec=lar
            lar=a[i]
        elif a[i]>sec:
             sec=a[i]
    i+=1
print(lar*sec)
    


Measured memory_bytes: 14252
import numpy as np

n, k, q = map(int, input().split())
point = np.array([k]*n)
minus = np.array([-q]*n)
for i in range(q):
    A = int(input())
    minus[A-1] +=1
point = point + minus

for i in range(n):
    if point[i] > 0:
        print('Yes')
    else:
        print("No")


Measured memory_bytes: 14804
//Vivek Shah
#include <bits/stdc++.h>
 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long 
#define mod 1000000007
#define llt int test;cin>>test;while(test--)
#define pb push_back
#define setto(n) cout << fixed<< setprecision(n)
#define fi first
#define se second
#define sz(i) int(i.size())
#define all(v) v.begin(),v.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define len(s) s.length()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define INF LONG_MAX
#define LOW LONG_MIN

using namespace std; 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}
template<class T> void smax(T& a, T val) {if (a < val) a = val;}
template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
#define MAX 150

int a, b, c;
string s1[MAX], s2[MAX];
std::map<string, int> M1;
int main(){
	boost;
	cin>>a;
	for (int i = 0; i < a; ++i)
	{
		cin>>s1[i];
		M1[s1[i]]++;
	}
	cin>>b;
	for (int i = 0; i < b; ++i)
	{
		cin>>s2[i];
		M1[s2[i]]--;
	}
	int ans = 0;
	for(auto i: M1){
		smax(ans, i.se);
	}
	cout<<ans;
	return 0;
}

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

using namespace std;
int a, b;
char c;

int main()
{
    cin >>a >> c >> b;
    if(c == '+')
    {
        printf("%d", a + b);
    }
    else
    {
        printf("%d", a - b);
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
d = n
ans = []
if n % 2 == 1: d -= 1

for i in range(1, n+1):
    for j in range(1, n+1):
        if j <= i or j == d: continue
        ans.append([i, j])
    d -= 1

print(len(ans))
for f, s in ans:
    print(f, s)


Measured memory_bytes: 9696
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d",&a);
    b=a%10;
    if(b==3)
        printf("bon\n");
    else if(b==0||b==1||b==6||b==8)
        printf("pon\n");
    else
        printf("hon\n");
    return 0;
}


Measured memory_bytes: 1644
function Main(inp) {
    var input = inp.split('\n');
    var K = Number(input[0]);
    var a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
    console.log(a[K - 1]);
}

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

Measured memory_bytes: 21064
//★#1014918 Solution for 0557: A First Grader by daiota
#include<iostream>
using namespace std;
 
int a[101];
long long dp[110][21];
int main(){
	int i,j;
	int N;
	cin >> N;
	for(i=0; i<=100; i++){for(j=0; j<=20; j++){dp[i][j] = 0;}}
	for(i=1; i<=N; i++) {cin >> a[i];}
	dp[1][a[1]] = 1;
	for(i=2; i<N; i++){
		for(j=0; j<=20; j++){
			if(j-a[i] >=  0) dp[i][j] += dp[i-1][j-a[i]];
			if(j+a[i] <= 20) dp[i][j] += dp[i-1][j+a[i]];
		}
	}
	cout << dp[N-1][a[N]] << endl;
	return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

int main(void)
{
	ll h, w;
	cin >> h >> w;
	if (h % 3 == 0 || w % 3 == 0) cout << 0 << endl;
	else {
		ll t = min(h, w);
		rep(k, w) {
			ll temp1 = h / 2 * k;
			ll temp2 = (h + 1) / 2 * k;
			ll temp3 = (w - k) * h;
			ll m = min(temp1, temp3);
			ll M = max(temp2, temp3);
			if (t > M - m) t = M - m;
		}
		rep(k, h) {
			ll temp1 = w / 2 * k;
			ll temp2 = (w + 1) / 2 * k;
			ll temp3 = (h - k) * w;
			ll m = min(temp1, temp3);
			ll M = max(temp2, temp3);
			if (t > M - m) t = M - m;
		}

		cout << t << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))

x.append(0)

cnt=0

while sum(x)>0:
	for i in range(n):
		if x[i]>0:
			for j in range(i+1,n+1):
				if x[j]==0:
					for k in range(i,j):
						x[k]=x[k]-1
					cnt+=1
					break
			break

print(cnt)

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

#define ll long long int

ll a[200005],x,aa;
ll b[200005],y,bb;
ll c[200005],cc;
ll sa[200005],sb[200005];
bool cmp(int a,int b){
	return a > b;
}
int main(){
	//  1  (x)
	ll x,y,aa,bb,cc; cin >> x >> y >> aa >> bb >> cc;
	for(int i=0;i<aa;i++) cin >> a[i];
	for(int i=0;i<bb;i++) cin >> b[i];
	for(int i=0;i<cc;i++) cin >> c[i];
	ll mx = 0;
	sort(a,a+aa,cmp); sort(b,b+bb,cmp);
	for(int i=0;i<y;i++) c[cc+i] = b[i];
	sort(c,c+cc+y,cmp);
	sa[0] = 0;
	for(int i=1;i<=x;i++) sa[i] = sa[i-1] + a[i-1];
	sb[0] = 0;
	for(int i=1;i<=cc+y;i++)
		sb[i] = sb[i-1] + c[i-1];
	for(int i=0;i<=x;i++){
		if(cc+y < y+x-i) continue;
		mx = max(mx,sa[i]+sb[y+x-i]);
	}
	cout << mx << endl;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

struct Period
{
    // start, end
    int s,e;

    Period(){}

    Period(string x)
    {
        string a=x.substr(0,5), b=x.substr(6);
        s = convertToMinite(a);
        e = convertToMinite(b);
    }

    int convertToMinite(string x)
    {
        return 60*atoi(x.substr(0,2).c_str()) + atoi(x.substr(3).c_str());
    }

    bool cover(const Period& p)
    {
        return s<=p.s && p.e<=e;
    }
};

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

    int CLASS;
    cin >>CLASS;

    vector<Period> cl(CLASS);
    rep(i,CLASS)
    {
        string s;
        cin >>s;
        cl[i] = Period(s);
    }

    vector<int> teacher_available(CLASS,0), student_available(CLASS,0);

    int Q;

    // teacher
    cin >>Q;
    while(Q--)
    {
        int k;
        cin >>k;

        vector<int> a(CLASS,0);
        rep(i,k)
        {
            string s;
            cin >>s;
            Period p(s);

            rep(j,CLASS)
            {
                if(p.cover(cl[j])) a[j]=1;
            }
        }

        rep(i,CLASS) teacher_available[i] += a[i];
    }

    // student
    cin >>Q;
    while(Q--)
    {
        int k;
        cin >>k;

        vector<int> a(CLASS,0);
        rep(i,k)
        {
            string s;
            cin >>s;
            Period p(s);

            rep(j,CLASS)
            {
                if(p.cover(cl[j])) a[j]=1;
            }
        }

        rep(i,CLASS) student_available[i] += a[i];
    }

    int ans=0;
    rep(i,CLASS) ans+=min(teacher_available[i], student_available[i]);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>

using namespace std;

int h, w;
char s[2010][2010];
int cnth[2010][2010] = {{ 0 }};
int cntw[2010][2010] = {{ 0 }};

int solve(int y, int x, int axis, int cnt)
{
	if(s[y][x] == '#')
	{
		return cnt;
	}

	if(axis == 0) return cnth[y][x] = solve(y + 1, x, axis, cnt + 1);
	else return cntw[y][x] = solve(y, x + 1, axis, cnt + 1);
}

int main()
{
	cin >> h >> w;

	for(int i = 1; i <= h; ++i)
	{
		for(int j = 1; j <= w; ++j)
		{
			cin >> s[i][j];
		}
	}

	for(int i = 0; i < h + 2; ++i) s[i][0] = s[i][w + 1] = '#';
	for(int i = 0; i < w + 2; ++i) s[0][i] = s[h + 1][i] = '#';

	for(int i = 1; i <= h; ++i)
	{
		for(int j = 1; j <= w; ++j)
		{
			if(s[i][j] == '.') 
			{
				if(cnth[i][j] == 0) solve(i, j, 0, 0);
				if(cntw[i][j] == 0) solve(i, j, 1, 0);
			}
		}
	}


	int ans = 1;
	for(int i = 1; i <= h; ++i)
	{
		for(int j = 1; j <= w; ++j)
		{
			if(s[i][j] == '.')
			{
				ans = max(ans, cnth[i][j] + cntw[i][j] - 1);
			}
		}
	}

	cout << ans << endl;
}

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

using ll = long long;

int main() {
    int N;
    cin >> N;
    rep(i, N) {
        for (int j = i + 1; j < N; j++) {
            int x = j - i;
            int y = 0;
            while (x > 0) {
                y++;
                if (x % 2 == 1) break;
                x /= 2;
            }
            cout << y << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 512
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    X            real()
#define    Y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define     point        complex<double>
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    PI  acos(-1)
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(n==i*j){
                cout<<"Yes\n";
                return 0;
            }
        }
    }
    cout<<"No\n";
}





Measured memory_bytes: 256
n=int(input())
s=input()
m=len(s)
mod=10**9+7
dp=[[0]*(n+1) for i in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
    for j in range(n+1):
        if j==0:
            dp[i][j]+=dp[i-1][j]+dp[i-1][j+1]
        elif j==n:
            dp[i][j]+=dp[i-1][j-1]*2
        else:
            dp[i][j]+=dp[i-1][j-1]*2+dp[i-1][j+1]
        dp[i][j]%=mod
def div(a,b):
    return (a*pow(b,mod-2,mod))%mod
print(div(dp[n][m],pow(2,m)))

Measured memory_bytes: 229896
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

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

	if (a >= 1 && a <= 10) {
		int ans;
		ans = a + (a * a) + (a * a * a);
		cout << ans << endl;
	}
  return 0;
}

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

int main()
{
    string S;
    cin >> S;
 
    if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
        cout << "Yes" << endl;
        return 0;
    }

     cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dl double long
#define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i)
#define rrep(i, m, n) for(ll i = (ll)(m); i > (ll)(n); --i)
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;

int main(void){
    int n;
    cin >> n;
    string s;
    set<string> S;
    rep(i, 0, n){
        cin >> s;
        if(S.find(s) != S.end()) continue;
        S.insert(s);
    }
    cout << S.size() << endl;

    return 0;
}

Measured memory_bytes: 19220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int M = sc.nextInt();
		int D = sc.nextInt();
		int count =0;
		for (int i=4;i<=M;i++) {
			for (int j=2;j<=D/10;j++) {
				for (int k=2;k<10;k++) {
					int d = j*10+k;
					if (d>D) {
						break;
					}
					if (j*k==i) {
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 35736
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

X = int(input())
done = False
while not done:
    a = make_divisors(X)
    if len(a) == 2:
        done = True
        c = X
    else:
        X += 1
       

print(c)


Measured memory_bytes: 38640
#include <iostream>

int main(int argc, char *argv[]) {
  int n, m;
  std::cin >> n >> m;
  int a[n];

  float sum = 0;
  for (int i = 0; i < n; ++i) {
    int ai;
    std::cin >> ai;
    sum += ai;
    a[i] = ai;
  }

  int count = 0;
  float k = sum / (4 * m);
  for (int i = 0; i < n; ++i) {
    if (a[i] >= k)
      ++count;
  }
  std::cout << (count >= m ? "Yes" : "No") << std::endl;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }
    int j = 1;
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        j = a.at(j - 1);
        count++;
        if (j == 2)
            break;
    }
    if (count == N)
    {
        cout << -1 << "\n";
    }
    else
    {
        cout << count << "\n";
    }
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO.Pipes;
using System.Linq;

class Program
{ 
	public static int Main()
	{
		Scanner cin = new Scanner();
	  string str = cin.next();
	  char[] s = str.ToCharArray();
	  for (int i = 0; i < s.Length; i++)
	  {
	    s[i] -= 'A';
	    int a = s[i];
	    a += 23;
	    a %= 26;
	    s[i] = Convert.ToChar(a);
	    s[i] += 'A';
	  }
    Console.WriteLine(s);
		return 0;
	}

}

class Scanner {
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

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

	public string next() {
		if (i < s.Length) return s[i++];
		do {
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
		} while ((s.Length == 1 && s[0] == "") || s.Length == 0);
		i = 0;
		return s[i++];
	}

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

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

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

}

Measured memory_bytes: 5336
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;

    string[] res;
    auto n = (N&126);
    foreach (i; 1..n+1) {
        foreach (j; i+1..n+1) {
            if (i + j == (N%2 == 0 ? N+1 : N)) continue;
            res ~= format("%d %d", i, j);
        }
        if (N%2 == 1) {
            res ~= format("%d %d", i, N);
        }
    }

    writeln(res.length);
    foreach (r; res) writeln(r);
}

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

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

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

#define pb push_back 
bool visited[200005];
ll const mod=1e9+7;
int cnt=0;
vector<vector<int>>adj(200005);
void dfs(int v)
{
	
	visited[v]=true;
	
	for(auto x:adj[v])
	{
		if(!visited[x])
		{
			cnt++;
			dfs(x);
		}
	}
	
}


int main()
{

int n,m;

cin>>n>>m;


for(int i=0,x,y;i<m;i++)
{
	cin>>x>>y;
	x--,y--;
	adj[x].pb(y);
	adj[y].pb(x);
}


int ans=0;
for(int i=0;i<n;i++)
{
	cnt=0;
	
	if(visited[i])continue;
	
	dfs(i);
	ans=max(ans,cnt+1);
	
}
cout<<ans;


}

Measured memory_bytes: 20636
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

ll n;

ll dfs(string s,int a){
    
    if(stol(s) > n)ret 0;
    int r = 0;
    if(a == 7)r ++;

    r += dfs(s+"3",a | 0x01);
    r += dfs(s+"5",a | 0x02);
    r += dfs(s+"7",a | 0x04);
    
    ret r;
}
int main(){

    cin >> n;
    
    P(dfs("0",0));
    return  0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) cin >> vec.at(i);
  int d = 100000000000;
  for(int i = 1; i < n; i++) {
    int s1 = 0;
    int s2 = 0;
    for(int j = 0; j < i; j++) s1 += vec.at(j);
    for(int j = i; j < n; j++) s2 += vec.at(j);
    d = min(d, abs(s1 - s2));
  }
  cout << d << endl;
}

Measured memory_bytes: 256
<?php

$n = intval(trim(fgets(STDIN)));
$input=explode(' ',trim(fgets(STDIN)));

$res = 1;

foreach($input as $num){
    
    $res = $res * intval($num);
    
}

if(in_array("0", $input)){
    echo "0";
}
elseif($res > 10**18) {
    echo "-1";
} else {
    echo $res;    
}

Measured memory_bytes: 25648
#include <bits/stdc++.h>
typedef long long ll;
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define dbg2(x,y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define dbg3(x,y,z) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<endl
#define dbg4(x,y,z,q) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<", "<<#q<<" = "<<q<<endl
#define dbg_array(x,sz) for (int i = 0; i < sz; ++i) cout << x[i] << " \n"[i==sz-1]
using namespace std;

const ll N = 1000 + 9, M = 400 - 9, Max_ans = 1LL * (1e16);
int a[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef ECLIPSE
	freopen("input.in", "rt", stdin);
	//freopen("output.out", "wt", stdout);
#endif
	int n, k, ans = 0;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < k; ++i)
		ans += a[i];
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 3756
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var N, K, R, S, P int
	fmt.Fscan(r, &N)
	fmt.Fscan(r, &K)
	fmt.Fscan(r, &R)
	fmt.Fscan(r, &S)
	fmt.Fscan(r, &P)
	var t string
	fmt.Fscan(r, &t)

	actual := make([]byte, N)
	ans := 0
	for i := 0; i < N; i++ {
		win := getWin(t[i])
		if i-K < 0 || actual[i-K] == 0 || win != actual[i-K] {
			// 勝てる場合
			ans += getPoint(win, R, S, P)
			actual[i] = win
		}
	}

	fmt.Println(ans)
}

func getWin(h byte) byte {
	if h == 'r' {
		return 'p'
	} else if h == 's' {
		return 'r'
	} else {
		return 's'
	}
}

func getPoint(h byte, r, s, p int) int {
	if h == 'r' {
		return r
	} else if h == 's' {
		return s
	} else {
		return p
	}
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}


Measured memory_bytes: 1408
N, A = map(int, input().split())
X=list(map(int, input().split()))
for i in range(N):
    X[i]=X[i]-A
dp = [[0 for j in range(100 * N + 1)] for i in range(N+1)]
dp[0][50 * N] = 1
for i in range(N):
	for j in range(50, 100*N + 1-50):
		dp[i+1][j] = dp[i][j] + dp[i][j - X[i]]
print(dp[N][50 * N] -1)


Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f,c;
char matriz[1005][1005];
ll memo[1005][1005];

ll mod(ll x){
    return x%1000000007;
}

bool validPos(ll i, ll j){
	return i > 0 and j > 0 and i <= f and j <= c;
}
ll dp(ll a,ll b){
    if(memo[a][b]!=-1) return memo[a][b];
    if(a==1 and b==1) return 1;
    else{
        if(matriz[a][b]!='#' and validPos(a,b)){
            memo[a][b]= mod(mod(dp(a,b-1)) + mod(dp(a-1,b)));
        }else{
            memo[a][b]=0;
        }
    }
    return memo[a][b];
}

int main(){
    
    cin>>f>>c;
    memset(memo,-1,sizeof(memo));
    for(int i=0;i<=f;i++) memo[0][i]=0;
    for(int j=0;j<=c;j++) memo[j][0]=0;
    for(int i=1;i<=f;i++){
        for(int j=1;j<=c;j++){
            cin>>matriz[i][j];
        }
    }
    cout<<dp(f,c)<<"\n";
    
}


Measured memory_bytes: 12608
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int,int> pii;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=1000005*3;
int k,n,m;
int _a[N],_b[N],*a=_a,*b=_b;
void IN(){
	static char s[N],t[N];
	n=read(),m=read(),k=read();
	cin>>(s+1)>>(t+1);
	For(i,1,n)
		a[i]=s[n-i+1]-'0';
	For(i,1,m)
		b[i]=t[m-i+1]-'0';
}
int p[N];
typedef pair <int,pair <int,int> > Node;
struct cmp{
	bool operator () (Node a,Node b){
		if (a.fi!=b.fi)
			return a.fi>b.fi;
		return a.fi>b.fi;
	}
};
priority_queue <Node,vector <Node>,cmp> Q;
int main(){
	IN();
	n=m=max(n,m)*2;
	For(i,1,n)
		if (a[i]&&b[i])
			p[i]=1,a[i]=b[i]=0;
	int las=0;
	For(i,1,n)
		if (a[i]||b[i]||p[i]){
			if (p[las]&&!p[i]){
				Q.push(mp(i-las,mp(las,i)));
				las=0;
			}
			if (p[i])
				las=i;
		}
	int rev=0;
	while (!Q.empty()){
		Node tmp=Q.top();
		Q.pop();
		if (tmp.fi>k)
			break;
		int now=tmp.fi,x=tmp.se.fi,y=tmp.se.se;
		if (!p[x]||(!a[y]&&!b[y]))
			continue;
		if (!a[y])
			rev^=1,swap(a,b);
		int yp=y;
		while (a[yp])
			a[yp++]=0;
		a[yp]=1;
		b[y]=1;
		p[x]=0;
		int yq=y-1;
		while (yq-now>0&&!p[max(yq-now,0)]&&!a[yq]&&!b[yq])
			yq--;
		if (p[yq-now])
			Q.push(mp(y-yq+now,mp(yq-now,y)));
		if (a[yp]&&b[yp]){
			p[yp-now]=1;
			a[yp]=b[yp]=0;
			int zp=yp+1;
			while (zp<=n+now&&!p[zp-now]&&!a[zp]&&!b[zp])
				zp++;
			if (a[zp]^b[zp])
				Q.push(mp(zp-yp+now,mp(yp-now,zp)));
		}
	}
	if (rev)
		swap(a,b);
	For(i,1,n)
		if (p[i])
			a[i+k]=b[i+k]=1;
	n=m=2e6+3;
	while (!a[n])
		n--;
	while (!b[m])
		m--;
	Fod(i,n,1)
		putchar('0'+a[i]);
	puts("");
	Fod(i,m,1)
		putchar('0'+b[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 33648
N = int(input())
L = list(int(input()) for i in range(N))
m = 10**9
sum = sum(L)

for l in L:
  if (l%10) != 0:
    m = min(l,m)

if (sum%10) != 0:
  print(sum)
elif (m%10) == 0:
  print(0)
else:
  print(sum-m)

Measured memory_bytes: 8996
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw_2(62,1);


int main(){
    ll N,K; cin>>N>>K;
    rep(i,N){ll x; cin>>x;}
    cout<<1+(N-2)/(K-1)<<endl;
}



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

//int main() {
//    int N, K;
//    int R, S, P;
//    cin >> N >> K >> R >> S >> P;
//    string T;
//    cin >> T;
//
//    for (char c : T) {
//        if (c == 'r') c = 'p';
//        else if (c == 's') c = 'r';
//        else if (c == 'p') c = 's';
//    }
//
//    int res = 0;
//    int cnt_r = 0, cnt_s = 0, cnt_p = 0;
//    for (char c : T) {
//        cnt_r--; cnt_s--; cnt_p--;
//        if (c == 'r') {
//            if (cnt_r < 0) res += R;
//            cnt_r = K;
//        }
//        else if (c == 's') {
//            if (cnt_s < 0) res += S;
//            cnt_s = K;
//        }
//        else if (c == 'p') {
//            if (cnt_p < 0) res += S;
//            cnt_p = K;
//        }
//    }
//
//    cout << res << endl;
//    return 0;
//}

int main() {
    long long A, B, K;
    cin >> A >> B >> K;

    long long t = K - A;

    if (t >= 0) {
        cout << max(0LL, A - K) << " "  << max(0LL, B - t) << endl;
    } else {
        cout << max(0LL, A - K) << " " << B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

template<class T> T lower_search(T lb, T ub, bool (*C)(T)) {
  REP(i,100) {
    T mid = (lb+ub)/2;
    if (C(mid)) ub = mid;
    else lb = mid;
  }
  return ub;
}

int N;
double L;
const int NUM = 100000;
int s[NUM], t[NUM], u[NUM];

bool C(double x) {
  int now = 0;
  double vol = L;
  REP(i,N) {
    vol = min(x*(s[i]-now)+vol, L);
    vol = min((x-u[i])*(t[i]-s[i])+vol, L);
    if (vol<0) return 0;
    now = t[i];
  }
  vol = min(x*(86400-t[N-1])+vol, L);
  double hoge = vol;
  now = 0;
  REP(i,N) {
    vol = min(x*(s[i]-now)+vol, L);
    vol = min((x-u[i])*(t[i]-s[i])+vol, L);
    if (vol<0) return 0;
    now = t[i];
  }
  vol = min(x*(86400-t[N-1])+vol, L);
  if(vol+EPS<hoge) return 0;
  return 1;
}

int main() {
  while(cin>>N>>L,N||L) {
    REP(i,N) cin>>s[i]>>t[i]>>u[i];
    double ans = lower_search<double>(0,INF,C);
    printf("%.10f\n", ans);
  }
}

Measured memory_bytes: 2000
S=str(input())
n=len(S)
N=2**(n-1)
L=[]#要素は全てn-1桁
for i in range(N):
    Bin=bin(i)[2:]
    Bin=(Bin[::-1]+'0'*max(0,(n-1)-len(Bin)))[::-1]
    L.append(Bin)

if n==1:
    ans=int(S)
else:
    ans=0
    for j in L:#0(1024)
        s=S
        f=0
        for k in range(1,n):#O(10)
            if k!=n-1:
                s=str(s)
                if j[k-1]=='1':
                    ans+=int(s[f:k])
                    f=k
            else:
                if j[k-1]=='1':
                    ans+=int(s[f:k])+int(s[k:])
                else:
                    ans+=int(s[f:])
            #print(j,k,ans)

print(ans)






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

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

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

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

bool tsurukame(int head, int reg) {
    int turu = head;
    int kame = 0;
    bool a = false;

    while(turu >= 0) {
        if(2 * turu + 4 * kame - reg == 0) {
            a = true;
            break;
        }
        turu--;
        kame++;
    }
    return a;
}

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

    if(tsurukame(x, y)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,c0=0,c1=0,c2=0,c3=0;
  cin>>n;
 while(n--)
 {
    string s;
   cin>>s;
   if(s[0]=='A')
     c0++;
   else if(s[0]=='W')
     c1++;
   else if(s[0]=='T')
     c2++;
   else
      c3++;
 }
  cout<<"AC x "<<c0<<"\n";
   cout<<"WA x "<<c1<<"\n";
   cout<<"TLE x "<<c2<<"\n";
   cout<<"RE x "<<c3;
   return 0;
}

Measured memory_bytes: 3604
MOD = 10 ** 9 + 7
L = input()
N = len(L)

dp = [[0] * 2 for _ in range(N + 1)]
dp[0][0] = 1

for i in range(N):
    d = int(L[i])
    for j in range(2):
        D = 1 if (d == 1 or j == 1) else 0
        for a, b in [(1, 0), (0, 1), (0, 0)]:
            if a + b <= D:
                here = dp[i + 1][j | (a + b < D)]
                here = (here + dp[i][j]) % MOD
                dp[i + 1][j | (a + b < D)] = here

print((dp[N][0] + dp[N][1]) % MOD)


Measured memory_bytes: 54236
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

ll ans = 0;
vi a(10);
int n,m,q;
vvi p (50,vi(4,0));

void g() {
  ll point=0;
  rep(i,q) {
    vi t = p.at(i);
    if(a.at(t.at(1)-1)-a.at(t.at(0)-1)==t.at(2)) point+=t.at(3);
  }
  ans = max(ans,point);
 }

void f(int x,int si) {
  a.at(si) = x;
  si++;
  if(si == n) {
    g();
    return;
  }
  srep(i,x,m+1) f(i,si);
}

int main() {
  cin >> n >> m >> q;
  rep(i,q) rep(j,4) cin >> p.at(i).at(j);

  orep(i,m) f(i,0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 int power (int a, int b = mod - 2)
{
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	read(n);
	readarr(a, n);
	map <int, int> mp;
	
	int ans = 0;
	FOR (i, 1, n)
	{
	    ans += mp[i - a[i]];
	    mp[i + a[i]]++;
	}
	
	print(ans);
}



















Measured memory_bytes: 27824