akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<queue>

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second

typedef pair<lint, lint> P;
const lint MOD = 1e9+7;
const lint INF = MOD * MOD;

int main(){
    int h, w; cin >> h >> w;
    string s[21];
    rep(i, h) cin >> s[i];
    lint ans = 0;
    rep(i, h) rep(j, w){
        if(s[i][j] == '#') continue;
        lint d[h][w];
        rep(x, h) rep(y, w) d[x][y] = INF;
        d[i][j] = 0;
        queue<P> q; q.push(make_pair(i, j));
        while(!q.empty()){
            P t = q.front(); q.pop();
            vector<P> vp;            
            if(t.fi > 0) vp.push_back(make_pair(t.fi-1, t.se));
            if(t.fi < h-1) vp.push_back(make_pair(t.fi+1, t.se));
            if(t.se > 0) vp.push_back(make_pair(t.fi, t.se-1));
            if(t.se < w-1) vp.push_back(make_pair(t.fi, t.se+1));
            rep(k, vp.size()){
                if(s[vp[k].fi][vp[k].se] == '#' || d[vp[k].fi][vp[k].se] < INF) continue;
                d[vp[k].fi][vp[k].se] = d[t.fi][t.se] + 1;
                q.push(vp[k]);
            }
        }
        lint res = 0;
        rep(i, h) rep(j, w){
            if(d[i][j] != INF) res = max(res, d[i][j]);
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  string s0 = s.substr(0, 1);
  int ns = (int)s.size();
  string sl;
  if (ns != 1) sl = s.substr(ns - 1);
  string rest;
  if (ns >= 3) rest = s.substr(1, ns - 2);
  int q;
  cin >> q;
  int rev = 1;
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if (t == 1)
      rev = -rev;
    else {
      int f;
      cin >> f;
      string c;
      cin >> c;
      if ((f == 1 && rev == 1) || (f == 2 && rev == -1)) {
        s0.insert(0, c);
      } else {
        sl.append(c);
      }
    }
  }
  s = s0 + rest + sl;
  if (rev == -1) reverse(s.begin(), s.end());
  cout << s << '\n';
  return 0;
}

Measured memory_bytes: 4240
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

double distanceAB(double xa, double ya, double xb, double yb);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


int cnt[1000001];

int main()
{
	ll dp[15][1050];
	ll n, s;
	
	dp[0][0] = 1;
	
	for (int i=0; i<=100; i++)
	{
		for (int j=1000; j>=i; j--)
		{
			for (int k=9; k>0; k--)
			{
				dp[k][j] += dp[k-1][j-i];
			}
		}
	}
	
	while (cin >> n >> s, n | s)
	{
		cout << dp[n][s] << endl;
	}
	
	return 0;
}



double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define endl '\n'
vector<vector<int>> cnts;
bool check(int l, int r) {
     for (int bit = 0; bit <= 20; ++bit) {
          if (cnts[bit][r] - (l?cnts[bit][max(l-1,(int)0)]:0) > 1) {
               return false;
          }
     }
     return true;
}

signed main()
{
     int n;
     cin >> n;
     vector<int> a(n);
     for (int i = 0; i < n; ++i) {
          cin >> a[i];
     }
     cnts.resize(26, vector<int>(n));
     for (int i = 0; i < n; ++i) {
          for (int bt = 0; bt <= 20; ++bt) {
               if ((a[i] >> bt) & 1) {
                    cnts[bt][i]++;
                    //cout <<1;
               } else {
                    //cout <<0;
               }
               if (i) {
                    cnts[bt][i] += cnts[bt][i - 1];
               }
          }
          //cout << endl;
     }
     int ans = 0;
     for (int i = 0; i < n; ++i) {
          int l = i, r = n;
          while (r - l > 1) {
               int m = (r + l) / 2;
               if (check(i, m)) {
                    l = m;
               } else {
                    r = m;
               }
          }
          ans += r - i;
          
     }
     cout << ans;
     return 0;
}


Measured memory_bytes: 44032
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
  // freopen("input.txt","r",stdin);
    long long int n1,m1,t;
 //   cin>>t;
   t=1;
    while(t--)
    {
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=1,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int c=0,n,m,l=0,r=0,k,min1=10000000000000,max2=-100;
 cin>>n>>m;
 vector<long long int>v;
 for(j=n;j<=m;j++)
 {
 	p=j;
 	while(p)
 	{
 		v.push_back(p%10);
 		p=p/10;
	 }
	 for(i=0;i<v.size()/2;i++)
	 {
	 	if(v[i]!=v[v.size()-i-1])
	 	break;
	 }
	 if(i==v.size()/2)
	 l++;
	 v.clear();
 	
 }
 cout<<l;
 //cout<<min1;
 }
 
 //vector<pair<long long int,long long int>>v;
 
    
 return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=9223372036854775806;
const int inf=2147483646;
string a;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>a;
	sort(a.begin(),a.end());
	if (a[0]==a[1]&&a[2]==a[3]&&a[1]!=a[2])
		cout<<"Yes";
	else 
		cout<<"No";
	return 0;
}

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

int main()
{
    int a, b, sa, height = 1, i;

    cin >> a >> b;

    sa = b - a;
    for(i = 1;i < sa;i++){
        height += i + 1;
    }

    cout << height - b<< "\n";

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  vector<vector<int>>A(3,vector<int>(3));
  vector<vector<int>>C(3,vector<int>(3,0));
  rep(i,3)rep(j,3)cin>>A[i][j];
  int N; cin>>N;
  vector<int>B(N);
  rep(i,N){
    cin>>B[i];
    rep(j,3)rep(k,3)if(A[j][k]==B[i])C[j][k]=1;
  }
  cout<<((C[0][0]==1&&C[0][1]==1&&C[0][2]==1)||(C[0][0]==1&&C[1][0]==1&&C[2][0]==1)||(C[0][0]==1&&C[1][1]==1&&C[2][2]==1)||(C[0][1]==1&&C[1][1]==1&&C[2][1]==1)||(C[0][2]==1&&C[1][2]==1&&C[2][2]==1)||(C[0][2]==1&&C[1][1]==1&&C[2][0]==1)||(C[1][0]==1&&C[1][1]==1&&C[1][2]==1)||(C[2][0]==1&&C[2][1]==1&&C[2][2]==1)? "Yes":"No")<<endl;
}

Measured memory_bytes: 3624
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
const ll INF = 1LL << 60;

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

  int L[M], R[M];
  int maxL = 0;
  int minR = 10000000;
  rep(i, M)
  {
    cin >> L[i] >> R[i];
    if (maxL < L[i])
      maxL = L[i];
    if (minR > R[i])
      minR = R[i];
  }
  cout << max((minR - maxL) + 1, 0) << endl;
}


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

namespace Panasonic2020A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] arr = "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".Split(',').Select(int.Parse).ToArray();
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(arr[n - 1]);
        }
    }
}


Measured memory_bytes: 13396
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner scan = new Scanner(System.in);
        
        int x = scan.nextInt();
        
        if (x >= 30){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35720
n = int(input())
a = [int(v) for v in input().split()]

x = a[0]
y = sum(a[1:])
ans = abs(x - y)

for i in range(1, n - 1):
    x += a[i]
    y -= a[i]
    diff = abs(x - y)
    ans = min(ans, diff)

print(ans)

Measured memory_bytes: 24832
import bisect
import sys
input = sys.stdin.readline
a,b,q=map(int, input().split())
s=[int(input()) for i in range(a)]
t=[int(input()) for i in range(b)]
x=[int(input()) for i in range(q)]
s=[-float('inf')]+s+[float('inf')]
t=[-float('inf')]+t+[float('inf')]

for i in range(q):
    index1=bisect.bisect_right(s, x[i]) 
    index2=bisect.bisect_right(t, x[i])  
    v1=abs(x[i]-s[index1-1])
    v2=abs(x[i]-s[index1])
    w1=abs(x[i]-t[index2-1])
    w2=abs(x[i]-t[index2])
    
    print(min(2*v1+w2,2*v2+w1,2*w1+v2,2*w2+v1,v1+abs(w1-v1),w1+abs(w1-v1),v2+abs(w2-v2),w2+abs(w2-v2)))

    
    
    
        
            

        


        
        
    
    
        



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

#define ll long long

signed main()
{
  string s,t; cin >> s >> t;
  int cnt=0;
  for(int i = 0; i<s.size(); ++i){
    if(s[i]!=t[i]) ++cnt;
  }
  cout << cnt << endl;
}

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

int main(){

    vector<int> H(3);
    for(int i = 0; i < 3; i++){
        cin >> H.at(i);
    }

    int fcount = 0;
    int scount = 0;

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

        if(H.at(i) == 5){
            fcount++;
        }
        else if(H.at(i) == 7){
            scount++;
        }

    }

    if(fcount == 2 && scount == 1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int64_t n, m;
  cin >> n >> m;
  cout << min(m / 2, (2 * n + m) / 4) << endl;
}


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

int main(){

    while(1){
        int w, d; cin >> w >> d;
        if(w == 0) break;

        vector<int> a(w);
        vector<int> b(d);
        int ans = 0;
        for(int i = 0; i < w; i++){
            cin >> a[i];
            ans += a[i];
        }
        for(int i = 0; i < d; i++){
            cin >> b[i];
            ans += b[i];
        }

        sort(a.begin(), a.end());
        sort(b.begin(), b.end());        

        for(int i = 0; i < w - 1; i++){
            for(int j = 0; j < d - 1; j++){
                if(a[i] == b[j]){
                    ans -= a[i];
                    a[i] = 0;
                    b[j] = 0;
                }
            }
        }

        cout << ans - a[w - 1] << endl;
    }
}


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

using namespace std;

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

vector<int> v;

int main()
{
	int N;
	int x;

	cin >> N >> x;

	int u = 0;

	REP(i, N)
	{
		cin >> u;
		v.push_back(u);
	}

	sort(v.begin(), v.end());

	int Ans = 0;

	REP(i, N)
	{
		int n = v[i];
		if (x < n)
		{
			x = 0;
			break;
		}
		else
		{
			x -= n;
			Ans++;
		}
	}

	if (x > 0)
	{
		Ans--;
	}

	cout << Ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define all(x) x.begin(), x.end()
#define ll long long
#define INF 2e9
using namespace std;

void Main() {
    int n;
    cin >> n;
    int A[n], B[n - 1];
    rep(i, 0, n - 1) { cin >> B[i]; }
    A[0] = B[0];
    if (n == 2) {
        cout << B[0] * 2 << endl;
        return;
    }
    rep(i, 1, n - 1) {
        A[i] = min({B[i - 1], B[i]});
        if (i == n - 2) {
            A[i + 1] = B[i];
        }
    }
    int ans = 0;
    rep(i, 0, n) { ans += A[i]; }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15) << endl;
    Main();
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    ll w,h;
    cin >> w >> h;
    vector<pair<ll,bool>>a(w+h);
    rep(i,w){
        ll x;
        cin >> x;
        a[i] = make_pair(x, true);
    }
    rep(i,h){
        ll x;
        cin >> x;
        a[i+w] = make_pair(x, false);
    }
    sort(a.begin(),a.end());
    ll ans = 0;
    ll x,y;
    x = w + 1;
    y = h + 1;
    for(auto &e:a){
        if(e.second){
            ans += e.first * y;
            x--;
        }else{
            ans += e.first * x;
            y--;
        }
        if(x == 0 and y == 0)break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const N = input.shift() - 0
  input = input[0].split(' ')
  let a = {}
  let b = {}
  let count = [0, 0]
  for (let i = 0; i < N; i++) {
    if (i%2) {
      let num = input[i] - 0
      if (!(num in a)) {
        a[num] = 0
        count[0]++
      }
      a[num]++
    } else {
      let num = input[i] - 0
      if (!(num in b)) {
        b[num] = 0
        count[1]++
      }
      b[num]++
    }
  }
  a = Object.keys(a).map(v => [v, a[v]]).sort((x, y) => y[1] - x[1])
  b = Object.keys(b).map(v => [v, b[v]]).sort((x, y) => y[1] - x[1])
  if (a[0][0]!==b[0][0]) {
    console.log(N - a[0][1] - b[0][1])
  } else if (a.length === 1) {
    console.log(N - a[0][1])
  } else {
    const ptnA = (N - a[1][1] - b[0][1])
    const ptnB = (N - a[0][1] - b[1][1])
    console.log(Math.min(ptnA, ptnB))
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 36660
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const ll INF = 1e18;
const int N = 401;
int a[N];
ll ps[N], dp[N][N];

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) ps[i] = ps[i-1] + a[i];

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			dp[i][j] = INF;
	for (int i = 1; i <= n; i++) dp[i][i] = 0;

	for (int x = 1; x < n; x++) {
		for (int i = 1; i <= n - x; i++) {
			for (int j = i; j < i + x; j++) {
				ll tmp = dp[i][j] + dp[j+1][i+x] + ps[i+x] - ps[i-1];
				dp[i][i+x] = min(dp[i][i+x], tmp);
			}
		}
	}
	printf("%lld\n", dp[1][n]);
}


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

using namespace std;

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

  int n;
  cin >> n;

  int contest = 111;
  while (contest < 1110) {
    if (n <= contest) {
      cout << contest << endl;
      break;
    }
    contest += 111;
  }
  return 0;
}

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

int main () {
	int d;
	while (scanf("%d", &d) != EOF) {
		cout << "Christmas";
		int cnt = 25 - d;
		for (int i = 0; i < cnt; ++i) {
			cout << " Eve";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){

ll N, M, Ans = 0;cin >> N >> M;
vector<vector<ll>> V(N);

rep(i, 0, M){

    ll a, b;cin >> a >> b;

    V[a - 1].push_back(b - 1);

    V[b - 1].push_back(a - 1);
}

rep(i, 0, V[0].size()){
    
    rep(j, 0, V[V[0][i]].size()){

        if(V[V[0][i]][j] == N - 1){cout << "POSSIBLE";exit(0);}
    }

}

cout << "IMPOSSIBLE";

}

Measured memory_bytes: 15952
S = list(input())
a,b = 0,0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == '1':
            a += 1
        else:
            b += 1
    else:
        if S[i] == '1':
            b += 1
        else:
            a += 1
print(min(a,b))


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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    VVI tab(2, VI(n));
    FOR(i,0,1) FOR(j,0,n-1) {
        cin >> tab[i][j];
    }
    
    VVI dp = tab;
    FOR(i,0,1) FOR(j,0,n-1) if (i || j) {
        if (!i) {
            dp[i][j] += dp[i][j-1];
        } else if (!j) {
            dp[i][j] += dp[i-1][j];
        } else {
            dp[i][j] += max(dp[i-1][j], dp[i][j-1]);
        }
    }
    
    cout << dp[1][n-1];

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int f(int x) {
  return x % 2 == 0 ? x / 2 : 3 * x + 1;
}

int main(void) {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<P> qs(q);
  rep(i, q) {
    cin >> qs[i].first >> qs[i].second;
  }

  vector<int> vec(n);
  int cnt = 0;
  vec[0] = 0;
  for (int i = 0; i < n - 1; i++) {
    string ss = s.substr(i, 2);
    if (ss == "AC") cnt++;
    vec[i + 1] = cnt;
  }

  rep(i, q) {
    int l = qs[i].first;
    int r = qs[i].second;
    --l;
    --r;
    int ans = vec[r] - vec[l];
    cout << ans << endl;
  }

  return 0;
}


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

void findNext(vector<int>& nums, int& len) {
  nums[0]++;
  for (int i = 0; i < len - 1; ++i) {
    if (nums[i] == 10 || abs(nums[i] - nums[i+1]) >= 2) {
      nums[i+1]++;
      nums[i] = nums[i+1] == 10 ? 0 : nums[i+1] - 1;
      for (int j = i - 1; j >= 0; --j)
        nums[j] = max(nums[j+1]-1, 0);
    }
  }
  
  if (nums[len-1] == 10) {
    nums[len-1] = 0;
    nums[len] = 1;
    len++;
  }
}
int main() {
  vector<int> nums(10);
  int n, len(1);
  cin >> n;
  for (int i = 0; i < n; ++i) findNext(nums, len);
  bool f(false);
  for (int i = 9; i >= 0; --i)
    if (f |= nums[i])
      cout << nums[i];
  cout << '\n';
  return 0;
}

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

const int inf=1e9+7;

int main()
{
#ifdef LOCAL
	assert(freopen("in.in","r",stdin));
#endif
	int n,k;cin>>n>>k;
	vector<int> arr(n);
	for(auto& i:arr)cin>>i;
	vector<int> dp(n);
	for(auto i=1;i<n;i++){
		int index=i;
		int mn=inf;
		index--;
		while(index>=max(0,i-k)){
			mn=min(mn,dp[index]+abs(arr[i]-arr[index])) , index--;
		}
		dp[i]=mn;
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define Maxn 100000
#define ll long long
#define Inf 0x3f3f3f3f3f3f3f3fll
int head[Maxn+5],arrive[Maxn<<1|5],nxt[Maxn<<1|5],val[Maxn<<1|5],tot;
void add_edge(int from,int to,int w){
	arrive[++tot]=to;
	nxt[tot]=head[from];
	val[tot]=w;
	head[from]=tot;
}
ll dis[Maxn+5];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
bool vis[Maxn+5];
void dij(){
	memset(dis,0x3f,sizeof dis);
	dis[1]=0;
	q.push(make_pair(0,1));
	int u;
	while(!q.empty()){
		u=q.top().second;
		q.pop();
		if(vis[u]){
			continue;
		}
		vis[u]=1;
		for(int i=head[u];i;i=nxt[i]){
			int v=arrive[i];
			if(dis[u]+val[i]<dis[v]){
				dis[v]=dis[u]+val[i];
				q.push(make_pair(dis[v],v));
			}
		}
	}
}
int main(){
	int n,m;
	int l,r,c;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&l,&r,&c);
		add_edge(l,r,c);
	}
	for(int i=1;i<n;i++){
		add_edge(i+1,i,0);
	}
	dij();
	cout<<(dis[n]==Inf?-1:dis[n])<<endl;
	return 0;
}


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

using namespace std;

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

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

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


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

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

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

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cinii(K,X);
    for(int i=X-K+1;i<=X+K-1;i++) cout << i << " ";
    cout << nn;
    return 0;
}

Measured memory_bytes: 256
// ref: https://img.atcoder.jp/arc096/editorial.pdf

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
    
    int sum=INT_MAX;
    for(int i=0; i<=max(X, Y); ++i){
        int tmp = 2*C*i + A*max(0, X-i) + B*max(0, Y-i);
        sum = min(sum, tmp);
    }
    
    cout << sum << endl;
    
    return 0;
}

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

struct Object{
  string name;
  int time;
};
 
int main(){
  int n,q;
  cin>>n>>q;
  Object ob;
  queue<Object> numq;
  for (int i=0;i<n;i++){
    cin>>ob.name>>ob.time;
    numq.push(ob);
  }
  int time =0;
  
  while(numq.size()>0){
    int a = numq.front().time;
    string b = numq.front().name;
    numq.pop();
    if(a<=q){
      time += a;
      cout<<b<<" "<<time<<endl;
    }
    else{
      time += q;
      numq.push(Object{b,a-q});
    }
  }
  return 0;
}


Measured memory_bytes: 6288
a=[[10*[0]for _ in[0]*3]for _ in[0]*4]
for _ in[0]*int(input()):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]+=v
for i in range(4):
 for j in range(3):print('',*a[i][j])
 if i<3:print('#'*20)


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

using namespace std;
typedef long long ll;

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

#define MOD 1000000007
#define INF 1000000000

int H, W, d;
int main()
{
    cin >> H >> W >> d;

    if(d % 2 != 0) {
        REP(i, H) {
            char tile1, tile2;
            if(i % 2 == 0) {
                tile1 = 'R';
                tile2 = 'G';
            } else {
                tile1 = 'G';
                tile2 = 'R';
            }
            REP(j, W) {
                if(j % 2 == 0) { printf("%c", tile1); }
                else { printf("%c", tile2); }
            }
            printf("\n");
        }
    } else {
        REP(i, H) {
            char up, down, left, right;
            for(int j = 0; j < W; j += d) {
                if(((i + j) / d) % 2 == 0) {
                    up = 'R';
                    down = 'G';
                    left = 'Y';
                    right = 'B';
                } else {
                    up = 'G';
                    down = 'R';
                    left = 'B';
                    right = 'Y';
                }
                int up_n = d - (i % d) * 2;
                if(i % d >= d / 2) { up_n = 0; }
                int down_n = ((i % d) - d / 2) * 2;
                if(i % d <= d / 2) { down_n = 0; }
                int width_n;
                if(i % d <= d / 2) {
                    width_n = i % d;
                } else {
                    width_n = d - (i % d);
                }
                int ind = j;
                for(int k = 0; k < width_n && ind < W; k++, ind++) { printf("%c", left); }
                for(int k = 0; k < up_n && ind < W; k++, ind++) { printf("%c", up); }
                for(int k = 0; k < down_n && ind < W; k++, ind++) { printf("%c",down); }
                for(int k = 0; k < width_n && ind < W; k++, ind++) { printf("%c", right); }
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int MAXN = 1e6 + 10;


struct Dsu {
  struct node_struct {
    int par, size;
    node_struct(int p, int s) : par(p), size(s) {}
    void merge(node_struct &b) {
      b.par = par;
      size += b.size;
    }
  };
  vector<node_struct> nodes;
  stack<tuple<int, int, node_struct, node_struct>> stk;
  int compo;
  Dsu(int n) {
    nodes.reserve(n);
    compo = n;
    for (int i = 0; i < n; ++i) nodes.emplace_back(i, 1);
  }
  int anc(int x) {
    while (x != nodes[x].par) x = nodes[x].par;
    return x;
  }
  bool unite(int x, int y) {
    int a = anc(x);
    int b = anc(y);
    stk.emplace(a, b, nodes[a], nodes[b]);
    if (a == b) return false;
    if (nodes[a].size < nodes[b].size) swap(a, b);
    --compo;
    nodes[a].merge(nodes[b]);
    return true;
  }
  void revert(int version = -1) {  // 0 index
    if (version == -1) version = stk.size() - 1;
    for (; stk.size() != version; stk.pop()) {
      nodes[get<0>(stk.top())] = get<2>(stk.top());
      nodes[get<1>(stk.top())] = get<3>(stk.top());
    }
  }
};




int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N, M;
  cin >> N >> M;
  Dsu djs(N);
  for (int i = 0; i < M; ++i) {
    int u, v, w; cin >> u >> v >> w;
    --u, --v;
    djs.unite(u, v);
  }
  cout << djs.compo << '\n';
}


Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a, b;

	scanf("%d %d", &a,&b);
	if (a < b) printf("a < b\n");
	else if (a > b) printf("a > b\n");
	else printf("a == b\n");
	return 0;
}



Measured memory_bytes: 2120
#include <stdio.h>
#include <string.h>

int main(void){
    char a[100], b[100], c[100];
    scanf("%s %s %s", a, b, c);

    int na, nb, nc;
    na = strlen(a);
    nb = strlen(b);
    nc = strlen(c);

    if (a[na-1] == b[0] && b[nb-1] == c[0]) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  string s;
  cin>>s;
  int K;
  cin>>K;
  int n=s.size();
  vector<int>sp(n);
  for(int i=0;i<n;i++){
    sp[i]=26-(s[i]-'a');
  }
  for(int i=0;i<n;i++){
    if(sp[i]<=K){
      if(s[i]>(char)((s[i]-'a'+sp[i])%26+'a')){
      s[i]='a';K-=sp[i];}
      }
  }
  if(K>0){
    s[n-1]=(char)((s[n-1]-'a'+K)%26+'a');
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 3840
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#include <cassert>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

/*  PrimeFact
    init(N): 初期化。O(N log log N)
    get(n): クエリ。素因数分解を求める。O(log n)
 */
template <typename T>
struct PrimeFact {
    vector<T> spf;
   // PrimeFact(T N) { init(N); }
    void init(T N) { // 前処理。spf を求める
        spf.assign(N + 1, 0);
        for (T i = 0; i <= N; i++) spf[i] = i;
        for (T i = 2; i * i <= N; i++) {
            if (spf[i] == i) {
                for (T j = i * i; j <= N; j += i) {
                    if (spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }
    map<T, T> get(T n) { // nの素因数分解を求める
        map<T, T> m;
        while (n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        return m;
    }
};

int main(){
    ll N; cin >> N;
    PrimeFact<ll> pf;
    pf.init(N + 1);
    ll cnt = 0;
    for(ll c = 1; c < N; c++){
        ll rem = N-c;
        map<ll,ll> des = pf.get(rem);
        ll tmp = 1;
        for(auto iter = des.begin(); iter != des.end(); iter++){
            tmp *= iter->second+1;
        }
        cnt += tmp;
    }
    cout << cnt << endl;
    sysp;
}

Measured memory_bytes: 11176
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(S: str):
    N = len(S)
    l = [0] * (N+1)

    for i in range(N):
        if S[i] == '<':
            l[i+1] = l[i]+1

    for i in range(N)[::-1]:
        if S[i] == '>':
            l[i] = max(l[i], l[i+1]+1)

    print(sum(l))

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    string S;
    cin >> S;

    int N = (int)S.size();

    string news = "NEWS";
    Vi used(4);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 4; j++) {
            if (S[i] == news[j]) {
                used[j] = 1;
            }
        }
    }

    bool ng = (used[0] ^ used[3]) || (used[1] ^ used[2]);

    cout << (ng ? "No\n" : "Yes\n");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
const int inf = pow(10,9);
const int nil = -1;
int i, n, m, t;
priority_queue<int> q;

int main() {
    scanf(" %d %d", &n, &m);
    rep(0,n) {
        scanf(" %d", &t);
        q.push(t);
    }
    rep(0, m) {
        t = q.top(); q.pop();
        q.push(t/2);
    }
    long long ans = 0;
    rep(0, n) {
        ans += q.top();q.pop();
    }

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

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long LL;
const int N=1e5;

int n;
bool vis[N];
vector<int> pp;

void init() {
	for(int i=2;i<N;i++) {
		if(vis[i]) continue;
		if(i%5==1) pp.push_back(i);
		//pp.push_back(i);
		for(int j=i*2;j<N;j+=i) {
			vis[j]=1;
		}
	}
}

int main() {
	scanf("%d",&n);
	init();
	for(int i=0;i<n;i++) {
		printf("%d ",pp[i]);
	}
}

Measured memory_bytes: 384
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *                    # ll = deepcopy(l)
from heapq import *                    # heappush(hp,x)
from string import *                # alpha = ascii_lowercase
from random import *                # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *                # bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin                # bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize                # minn = -maxsize
from operator import *                # d = sorted(d.items(), key=itemgetter(1))
from itertools import *                # pre = [0] + list(accumulate(l))
from collections import Counter        # d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	p = 1
	if(0 in l):
		return 0
	for i in l:
		p *= i
		if(p > 10**18):
			return -1
	return p
	

N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l)
print(ans)



Measured memory_bytes: 23816
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j,dp[500005],l;
string st;
int main()
{
	cin>>st>>st;
	st=" "+st;
	for (i=3;i<st.length();i++)
	{
		dp[i]=dp[i-1];
		if (st.substr(i-3+1,3)=="101")
		{
			l=i;
			for (j=i-2;st[j]=='1'&&j>0;j--)
			{
				dp[i]=max(dp[i],dp[j-1]+i-j-1);
			}
		}
		if (st[i]=='0') l=0;
		if (st[i]=='1'&&l)
		{
			 dp[i]=max(dp[i],dp[l-3]+i-l+1);
		}
	}
	cout<<dp[st.length()-1];
	return 0;
}

Measured memory_bytes: 2840
#!/usr/bin/env python
#_*_coding:utf-8_*_
s = raw_input()
t = raw_input()
lens = len(s)
if lens != len(t):
    print 'No'
    exit(0)
elif s == t:
    print 'Yes'
    exit(0)
else:
    for i in range(1, lens):
        if s[i:] + s[:i] == t:
            print 'Yes'
            exit(0)
print 'No'

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

int main(){
	int field[1000][1000];
	int n,dp[1000][1000];
	while(cin >> n,n){
		getchar();
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				char c = getchar();
				if(c == '.') field[i][j] = 1;
				else field[i][j] = 0;
				dp[i][j] = 0;
			}
			getchar();
		}
		for(int i = 0;i < n;i++){
			dp[i][0] = field[i][0];
			dp[0][i] = field[0][i];
		}
		int ma = 0;
		for(int i = 1;i < n;i++){
			for(int j = 1;j < n;j++){
				if(!field[i][j]) dp[i][j] = 0;
				else dp[i][j] = min(min(dp[i - 1][j],dp[i][j - 1]),dp[i - 1][j - 1]) + 1;
				ma = max(ma,dp[i][j]);
			}
		}
		cout << ma << endl;
	}
	return 0;
}

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

using namespace std;

int main() {

	string s;
	cin >> s;

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

Measured memory_bytes: 256
/*
 * Atcoder Beginner Contest 154
 * 
 * Time: 8ms
 * Memory: 888KB
 * 
 * Author:DragonLee
 */

#include <iostream>
#include <map>
using namespace std;

int main() {
    string s, t, u;
    int a, b;
    map<string, int> m;
    cin >> s >> t >> a >> b;
    m[s] = a;
    m[t] = b;
    cin >> u;
    m[u] -= 1;
    cout << m[s] << " " << m[t] << endl;
    return 0;
}

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

int main() {
	int seconds, minutes, hours;

	cin >> seconds;
	hours = seconds / 3600;
	minutes = (seconds - 3600 * hours) / 60;
	seconds %= 60;
	cout << hours << ":" << minutes << ":" << seconds << endl;
	return 0;
}

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

int main() {
	
	int x, y;
	scanf("%d%d", &x,&y);
	
	vector<int> dp(x);
	for(int i=0; i<x; i++) {
		if(y >= 2) {
			dp[i] = 2;
			y -= 2;
		}
	}
	for(int i=0; i<x; i++) {
		if(y >= 2) {
			dp[i] += 2;
			y -= 2;
		}
	}
	bool ok = false;;
	for(int a : dp) {
		if(a == 0) {
			ok = true;
			break;
		}
	}
	if(y || ok) printf("No");
	else printf("Yes");
	
	
	return 0;
}

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

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

    int x[5];
    rep(i,5){
        cin>>x[i];
        if(x[i]==0) cout<<i+1<<endl;
    }

    return 0;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1];

        for(int i = 1;i <= n;i++){
            a[i]  = sc.nextInt();
        }

        int[] ans = new int[n+1];
        int count = 0;
        List<Integer> index = new ArrayList<>();
        for(int i = n;i > 0;i--){
            if(i * 2 > n){
                ans[i] = a[i];
                if(ans[i] == 1){
                    count++;
                    index.add(i);
                }
            } else {
                int sum = 0;
                for(int j = 2;i*j <= n;j++){
                    sum += ans[i*j];
                }
                if(sum % 2 == a[i]){
                    ans[i] = 0;
                } else {
                    ans[i] = 1;
                    count++;
                    index.add(i);
                }
            }
        }
        System.out.println(count);
        if(count != 0) {
            StringBuilder sb = new StringBuilder();
            for (Integer i : index) {
                sb.append(i);
                sb.append(" ");
            }
            sb.deleteCharAt(sb.length()-1);
            System.out.println(sb.toString());

        }
    }
}



Measured memory_bytes: 90984
#include<bits/stdc++.h>
using namespace std;
 
typedef long long   ll;
typedef long double ld;
const int N  = 5e5+10;
const ll mod = 1e9+7;
const ll inf = 1e18;
 
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb              push_back
#define mp              make_pair
#define ub              upper_bound                 // first element >  val(itr)
#define lb              lower_bound                 // first element >= val(itr) 
#define all(x)          (x).begin(),(x).end()
#define reset(a,x)      memset(a,x,sizeof(a))       // x can be 0 or -1
#define leadzero(a)     __builtin_clz(a)            // count leading zeroes
#define trailzero(a)    __builtin_ctz(a)            // count trailing zeroes
#define bitcount(a)     __builtin_popcount(a)       // count set bits
#define iceil(n,x)      ((n)+(x)-1)/(x)
#define test            int t; cin>>t; while(t--)
#define forn(i,a,e)     for(ll i = a; i < e; i++)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define sp              <<" "<<
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;    }
ll powm(ll base,ll exp){ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
ll add(ll a,ll b)  { return (a%mod+b%mod)%mod;        }
ll sub(ll a, ll b) { return (a%mod+mod-b%mod)%mod;    }
ll mult(ll a,ll b) { return ((a%mod)*(b%mod))%mod;    }
ll choose2(ll n)   { ll ans=(n*(n-1))/2; return ans;  }
ll dist2(ll x1,ll y1,ll x2,ll y2){ ll ans=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1); return ans;}

int main()
{
    fast
    ll x,a;
    cin>>x>>a;

    if(x<a)
      cout<<0;
    else
      cout<<10;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const int maxn=1e6+10;
int main(){
	fast;
	ll t,n,x; cin>>n>>x>>t;
	ll step=ceil((double)n/x);
	cout<<step*t<<'\n';

	return 0;
}
//prime func
//subset production
//factorization
 
//Trees
//Graphs(dfs,bfs,shortes path etc.)
//DP-Recursion

Measured memory_bytes: 3740