akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int x[5];

  for(int i=0;i<5;i++) cin >> x[i];

  sort(x, x+5, [](int a, int b){
                 int p = a%10 ? a % 10 : 10;
                 int q = b%10 ? b % 10 : 10;

                 return p > q;
               });

  int ans = 0;

  for(int i=0;i<5;i++){
    ans = (ans+9) / 10 * 10;
    ans += x[i];

    debug(x[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

using namespace std;

int main() {
  int a[3][3];
  for(int i=0;i<3;i++){
  for(int j=0;j<3;j++){
   cin >> a[i][j];
  }
  }
  int n;
  cin >> n ;
  
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b.at(i);
  }
  for(int k=0;k<n;k++){
  for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(b.at(k)==a[i][j]){
          a[i][j]=0;
          break;
      }
  }
  }
  }

  if((a[0][0]==0 && a[0][1]==0 && a[0][2]==0)|
     (a[1][0]==0 && a[1][1]==0 && a[1][2]==0)|
         (a[2][0]==0 && a[2][1]==0 && a[2][2]==0)|
         (a[0][0]==0 && a[1][0]==0 && a[2][0]==0)|
         (a[1][1]==0 && a[2][1]==0 && a[3][1]==0)|
         (a[0][2]==0 && a[1][2]==0 && a[2][2]==0)|
         (a[0][0]==0 && a[1][1]==0 && a[2][2]==0)|
         (a[0][2]==0 && a[1][1]==0 && a[2][0]==0)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;    
  }  
  return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const LL MOD = 998244353;
const int N = 3000;
LL memo[N+1][N+1];
LL mod_pow(LL base, LL exp)
{
	if(exp==0) return 1;
	if(exp&1) return (base*mod_pow(base,exp-1))%MOD;
	else return mod_pow((base*base)%MOD, exp>>1);
}
int n;
int a[N];
LL count(int i, int W)
{
	if(W < 0)
		return 0;
	if(W==0)
		return mod_pow(2,n-i);
	if(n==i) // and W > 0
		return 0;
	if(memo[i][W]!=-1)
		return memo[i][W];
	else
		return memo[i][W] = (count(i+1,W-a[i])+2*count(i+1,W))%MOD;
}
int main()
{
	int s; cin >> n >> s;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	memset(memo,-1,sizeof memo);
	cout<<count(0,s)<<endl;

	return 0;
}

Measured memory_bytes: 74100
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void){
  int n,k,tmp,i,j;
  double p,ans=0;
  scanf("%d %d",&n,&k);
  for(i=1;i<=n;i++){
    tmp=i;
    p=(double)1/n;
    for(j=0;j<100000;j++){
      if(tmp>=k) break;
      tmp*=2;
    }
    //printf("%d\n",j);
    //printf("%f ",p);
    p*=pow(0.5,j);
    //printf("%f\n",p);
    ans+=p;
  }
  printf("%.12f\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
	
	int n,m,i,j;
	int a,b;
	int A[100][100] = {0};
	int B[100] = {0};
	int C[100] = {0};
	
	scanf("%d %d ",&n,&m);
	
	for(j=0;j<n;j++){
		for(i=0;i<m;i++){
			scanf("%d",&a);
			A[j][i] = a;
		}
	}
	
	for(j = 0;j<m;j++){
		scanf("%d",&b);
		B[j] = b;
	}
	
	for(j=0;j<n;j++){
		for(i=0;i<m;i++){
			C[j] = C[j] + A[j][i]*B[i];
		}
	}
	
	for( i=0;i<n;i++){
		printf("%d\n",C[i]);
	}
	
	return 0;
}


Measured memory_bytes: 2088
n = int(input())
# a, b = map(int, input().split())
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"
a = a.split(", ")
print(int(a[n-1]))



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
const int N = 3e4 + 5;
const int M = 1e6 + 5;
const int Mod = 1e9 + 7;

ll fp(ll x, ll y, ll m = Mod) {
	ll res = 1;
	for (int i = 0; (1LL << i) <= y; i++, x = x * x % m)
		if (y & 1LL << i)
			res = res * x % m;
	return res;
}

int main()
{
	GO;
	int n, k;
	cin >> n >> k;
	vec ans(k + 1);
	ll sum = 0;
	for (int i = k; i >= 1; i--)
	{
		ans[i] = fp(k / i, n);
		for (int j = 2 * i; j <= k; j += i)
			ans[i] = (ans[i] - ans[j] + Mod) % Mod;
		sum = (sum + i * ans[i] % Mod) % Mod;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3920
from collections import Counter
N = int(input())
S = []
for _ in range(N):
    S.append(input())
S.sort()
C = Counter(S)
C = sorted(C.items(), key=lambda x:x[1], reverse=True)
vm = 0
for k, v in C:
    if v >= vm:
        vm = v
        print(k)
    else:
        break

Measured memory_bytes: 49504
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline int rdi(){
	int x=0,f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	return f?-x:x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
ll md=1000000007,dp[100010][2];
vector<int> v[100010];
inline void dfs(int x,int par){
	ll l=1,r=1;
	for(int y:v[x]){
		if(y!=par){
			dfs(y,x);
			l=(l*dp[y][0])%md;
			r=(r*(dp[y][1]+dp[y][0]))%md;
		}
	}
	dp[x][0]=r;
	dp[x][1]=l;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int i,n;
	cin>>n;
	for(i=0;i<n-1;++i){
		int a,b;
		cin>>a>>b;
		--a,--b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(0,-1);
	cout<<(dp[0][0]+dp[0][1])%md<<endl;
	return 0;
}

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

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

  vector<int> C(26);
  for (int i = 0; i < 26; i++) cin >> C.at(i);

  vector<vector<int>> S(D, vector<int>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) cin >> S.at(i).at(j);
  }

  // i 日目に開くコンテストのタイプを決める
  vector<int> T(D);
  for (int d = 0; d < D; d++) {
    int type = 0;
    int s_max = 0;
    for (int i = 0; i < 26; i++) {
      if (S.at(d).at(i) > s_max) {
        type = i+1;
        s_max = S.at(d).at(i);
      }
    }
    T.at(d) = type;
  }

  // i 日目に開くコンテストのタイプを出力
  for (int i = 0; i < D; i++) cout << T.at(i) << endl;
}


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 500005
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long

#define mod  1000000007



int main()
{
	FAST;
	ll a, b;
	cin >> a >> b;
	ll ans = a*b / (__gcd(a, b));
	cout << ans;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define INT long long int
#define oo 987654321
#define MOD 1000000007
using namespace std;
string s;
INT n, a;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>s;
    for(int i = 0 ; i < n ; i++ )
    {
        if( s[i] == 'R' ) a++;
        else a--;
    }
    if( a > 0 ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

#define ll long long
int gcd(ll a, ll b) {
  return a % b ? gcd(b, a%b) : b;
}
int main() {
  int N;
  cin >> N;
  ll A[N];
  for (int i = 0; i < N; i++) cin >> A[i]; 
  
  ll ans = A[0];
  
  for (int i = 0; i < N-1; i++) {
    ans = gcd(ans, A[i+1]);
  }
  
  cout << ans << endl;
        
}

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<algorithm>
#define LL long long
#define FIO ios_base::sync_with_stdio(false), cin.tie(0)
using namespace std;

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

int main()
{
	int x, i; cin>>x;
	if(x==2) { cout<<2<<endl; return 0; }
	
	for(i=x; ; i++)
	{
		if(isPrime(i)) break;
	}
	cout<<i<<endl;
}

Measured memory_bytes: 3536
n,k=map(int, input().split())
s=str(input())
S=list(s)
if S[k-1]=='A':
  S[k-1]='a'
elif S[k-1]=='B':
  S[k-1]='b'
else:
  S[k-1]='c'
print(''.join(S))

Measured memory_bytes: 3060
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

//#define MOD 1000000007LL
#define MOD 998244353LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;





signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b; cin >> a >> b;
	if (a > b)swap(a, b);
	rep(i, b) cout << a;
	cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 100005

//const int INF = 1e9 + 7;


int main() {

	int a, b;
	cin >> a >> b;
	char mp[105][105];

	for (int i = 0; i < 100; i++)
	{
		for (int j = 0; j < 100; j++)
		{
			if (i < 50) {
				mp[i][j] = '#';//黒
			}
			else {
				mp[i][j] = '.';//白
			}
		}
	}

	int black = 1, white = 1;
	
	for (int i = 0; i < 50; i+= 2)
	{
		for (int j = 0; j < 100; j+=2)
		{
			if (white < a) {
				mp[i][j] = '.';
				white++;
			}
		}
	}
	
	for (int i = 51; i < 100; i += 2)
	{
		for (int j = 0; j < 100; j += 2)
		{
			if (black < b) {
				mp[i][j] = '#';
				black++;
			}
		}
	}

	cout << "100 100" << endl;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			cout << mp[i][j];
		}
		cout << endl;
	}


	return 0;
}


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

int		main(void)
{
	string s;

	cin >> s;
	if (s[0] != 'A' || s[1] < 'a' || s[1] > 'z' || s.back() < 'a' || s.back() > 'z')
	{
		puts("WA");
		return (0);
	}
	int c_cnt = 0;

	for (int i = 2; i < s.size() - 1; i++)
	{
		if (s[i] == 'C' && c_cnt == 0)
		{
			c_cnt++;
			continue ;
		}
		if (s[i] < 'a' || s[i] > 'z')
		{
			puts("WA");
			return (0);
		}
	}
	if (c_cnt == 0)
		puts("WA");
	else
		puts("AC");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  vector<int> p(n);
  REP(i,n) cin>>p[i];
  set<int> s;
  vector<bool> v(n, true);
  REP(i,n) {
    if(s.count(p[i]+1)) {
      v[p[i]-1] = false;
    }
    s.insert(p[i]);
  }
  int mx = 1;
  int now = 0;
  REP(i,n-1) {
    if (v[i]) ++now;
    if (!v[i]) now = 0;
    mx = max(mx, now+1);
  }
  cout << n - mx << endl;
  return 0;
}


Measured memory_bytes: 10368
#!/usr/bin/env python
n, x = map(int, input().split())
L = [int(i) for i in input().split()]

cnt = 1
D = [0]
for i in range(2, n+2):
    d = D[-1] + L[i-2]
    if d <= x:
        cnt += 1
    D.append(d)
print(cnt)


Measured memory_bytes: 2940
def main():
    dic1 = {}
    dic2 = {}
    S = list(input().rstrip())
    T = list(input().rstrip())
    for s, t in zip(S, T):
        if s not in dic1:
            dic1[s] = t
        elif dic1[s] != t:
            print('No')
            exit()
        if t not in dic2:
            dic2[t] = s
        elif dic2[t] != s:
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 90452
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];

void solve(){
	double L;
	 cin>>L;
	 L/=3;
	 printf("%.9f",L*L*L);
}
int main() {
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
import sys
n,m,x,y = map(int,input().split())
x_arr = sorted(list(map(int,input().split())))
y_arr = sorted(list(map(int,input().split())))
for z in range(x+1,y+1,1):
  if x_arr[-1] < z and y_arr[0] >= z:
    print('No War')
    sys.exit()
print('War')

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int N; cin >> N;
   vector<int> A(3 * N);
   for (int i = 0; i < 3 * N; ++i) cin >> A[i], --A[i];
   vector<vector<int>> dp(N, vector<int>(N, -1e9));
   dp[A[0]][A[1]] = dp[A[1]][A[0]] = 0;
   vector<int> best_row(N, -1e9);
   best_row[A[0]] = 0;
   best_row[A[1]] = 0;
   int best = 0;
   int offset = 0;
   for (int cur = 2; cur + 2 < 3 * N; cur += 3) {
      if (A[cur] == A[cur + 1] && A[cur] == A[cur + 2]) {
         offset++;
         continue;
      }
      vector<tuple<int, int, int>> changes;
      if (A[cur] == A[cur + 1] || A[cur] == A[cur + 2] || A[cur + 1] == A[cur + 2]) {
         int diff = A[cur] ^ A[cur + 1] ^ A[cur + 2];
         int same = (A[cur] + A[cur + 1] + A[cur + 2] - diff) >> 1;
         for (int z = 0; z < N; ++z) {
            changes.emplace_back(diff, z, dp[same][z] + 1);
            changes.emplace_back(z, diff, dp[z][same] + 1);
         }
      }
      for (int i = 0; i < 3; ++i) {
         int x = A[cur + i];
         int y = A[cur + (i + 1) % 3];
         int z = A[cur + (i + 2) % 3];
         changes.emplace_back(y, z, dp[x][x] + 1);
         changes.emplace_back(z, y, dp[x][x] + 1);
         for (int t = 0; t < N; ++t) {
            changes.emplace_back(x, t, best_row[t]);
            changes.emplace_back(t, x, best_row[t]);
         }
      }
      for (int i = 0; i < 3; ++i) {
         for (int j = 0; j < 3; ++j) if (i ^ j) {
            changes.emplace_back(A[cur + i], A[cur + j], best);
         }
      }
      for (auto c : changes) {
         int x, y, z;
         tie(x, y, z) = c;
         dp[x][y] = max(dp[x][y], z);
         best = max(best, z);
         best_row[x] = max(best_row[x], z);
      }
   }
   best = max(best, dp[A.back()][A.back()] + 1);
   cout << best + offset << '\n';
   return 0;
}


Measured memory_bytes: 19504
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;


struct UnionFind{
    std::vector<int> par;
    ll huben;
    UnionFind(ll N){
        par.resize(N,-1);
        huben = N*(N-1)/2;
    }
    int root(int x){
        if(par[x]<0) return x;
        else return par[x] = root(par[x]);
    }
    int size(int x){
        return -par[root(x)];
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(same(x,y)) return false;
        if(size(x)<size(y)) swap(x,y);
        huben-=par[x]*par[y];
        par[x]+=par[y];
        par[y]=x;
        return true;
    }
};
int main(){
    ll N,M;cin>>N>>M;
    vector<int> a(M),b(M);
    REP(i,M) cin>>a[i]>>b[i];
    vector<ll> ans(M);
    UnionFind uni(N);
    for(int i=M-1;i>=0;--i){
        ans[i] = uni.huben;
        uni.unite(a[i]-1,b[i]-1);
    }
    REP(i,M) cout<<ans[i]<<endl;
}


Measured memory_bytes: 3328
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)



main :: IO ()
main = do
    x <- readLn
    print $ head $ dropWhile (not . isPrime) [x..]

isPrime :: Int -> Bool
isPrime 2 = True
isPrime n = let rt = ceiling (sqrt $ fromIntegral n)
                ls = [2..rt]
    in [] == filter (\m -> n `mod` m == 0) ls










Measured memory_bytes: 508
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <fstream>
#include <climits>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <memory>
#include <set>
#include <map>
#include <list>
#include <cmath>

using namespace std;

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

const int maxn=1e5+10;
ll h[maxn];
ll n,a,b;

int ok(ll t)
{
    ll need=0;
    for(int i=0;i<n;i++)
        if(h[i]-b*t>0)
            need+=(h[i]-b*t+a-b-1)/(a-b);
    return need<=t;
}

int main()
{
    //freopen("/Users/qianjay/Documents/apac/in","r",stdin);
    scanf("%lld%lld%lld",&n,&a,&b);
    for(int i=0;i<n;i++)
        scanf("%lld",&h[i]);
    ll l=0,r=1e9;
    
    while(l+1<r)
    {
        ll mid=(l+r)>>1;
        
        if(ok(mid)) r=mid;
        else l=mid;
    }
    cout<<r<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  char a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a==b&&b==c)cout<<"Yes";
  else if(b==c&&c==d)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
S = input()

A = []

ok = 1
ans = 0
cnt = 0
for i in range(len(S)):
    if ok == 1 and i < len(S)-1 and S[i] == 'B' and S[i+1] == 'C':
        A.append('B')
        ans += cnt
    elif S[i] == 'A':
        A.append('A')
        cnt += 1
        ok = 1
    elif ok == 1 and i > 0 and S[i-1] == 'B' and S[i] == 'C':
        continue
    else:
        A = []
        cnt = 0
        ok = 0

print(ans)

Measured memory_bytes: 10676
N = gets.to_i
A = []
N.times do
  A << gets.split.map(&:to_i)
end 

lens = A.map{|x, y| x.abs + y.abs}
d = lens.map{|c| c % 2}.uniq
mx = lens.max

if d.size != 1
  puts -1
  exit
end  

ans = []
tot = 0
(0..39).each do |i|
  break if tot >= mx
  ans << 2 ** i   
  tot += ans.last
end
ans.unshift 1 if d[0] % 2 == 0
ans.reverse!

puts ans.size
puts ans.join(' ')
A.each do |x, y|
  mv = []
  ans.each do |d|
    if x.abs >= y.abs
      if x >= 0
        mv << 'R'
        x -= d
      else  
        mv << 'L'
        x += d 
      end
    else 
      if y >= 0
        mv << 'U'
        y -= d 
      else 
        mv << 'D'
        y += d 
      end
    end
  end
  puts mv.join 
end



Measured memory_bytes: 2428
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn s(n: u64) -> u64{
    let mut n = n;
    let mut ans = 0;

    while n > 0{
        ans += n%10;
        n /= 10;
    }

    ans
}

fn g(n: u64) -> f64{
    let x: f64 = n as f64;
    x / s(n) as f64
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let mut cands: Vec<u64> = vec![];

    let mut base: u64 = 1;
    for _ in 0..15{
        for j in 1..150{
            cands.push((j+1)*base-1);
        }
        base *= 10;
    }

    cands.sort();
    //println!("{:?}", cands.len());
    for i in (1..cands.len()).rev(){
        for j in (0..i).rev(){
            if g(cands[j]) > g(cands[i]) || cands[i] == cands[j]{
                cands.remove(j);
                break;
            }
        }
    }

    //println!("{:?}", cands.len());

     for i in 0..n{
         println!("{}", cands[i]);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,i,n=0,x;//??????????????
	cin>>a>>b>>c;//???????
	for(i=1;i<=a;i++)
	{
		cin>>x;
		if(x<b||x>=c) n++;//????????????
	}
	cout<<n<<endl;//???????
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

int main(){

    int N, i;
    cin >> N;

    vector<int> A(N);
    vector<int> sA(N);
    for(i=0; i<N; i++) cin >> A.at(i);

    copy(A.begin(), A.end(), sA.begin());
    sort(sA.begin(), sA.end());

    unsigned long mx = sA.at(sA.size() - 1);
    unsigned long mx2 = sA.at(sA.size() - 2);

    for(i=0; i<N; i++){
        
        if(A.at(i) == mx) cout << mx2 << endl;
        else cout << mx << endl;
    }

    return 0;
}



Measured memory_bytes: 3200
function Main(input) {
    input = input.trim();
    const s = input;

    if(s === 'ABC'){
        console.log('ARC');
    }else{
        console.log('ABC');
    }
    
}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define ll          long long
#define pb          push_back
using namespace std;

int main(){
    ll n;
    cin>>n;
    ll t = sqrt(n);
    t++;
    //cout<<t;
    while(t>0){
        if(n%t==0){
            cout<<(t-1)+(n/t-1)<<endl;
            break;
        }
        t--;
    }
}

Measured memory_bytes: 256
INF = 999999999999999999L
EPS = 1e-12

def read():
    return raw_input().strip()

def read_ints():
    return map(int,read().split())

n = int(read())
s = read()
cnts = [0]*26 
for c in s:
    cnts[ord(c)-ord("a")] += 1
# print cnts 

ans = 1
for i in range(26):
    ans = ans * (cnts[i]+1) 
ans -= 1 
print ans % (10**9+7)


Measured memory_bytes: 2692
/**
     **author : _KMS_
     **created : 05-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =6e5,MOD=1e9+7;
typedef long long ll;
int way;
int main() {
      
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n,k;
   cin>>n>>k;
   for(int i=0;i<=n;i++)
   {
         for(int j=0;j<=n;j++)
         {
               if(i+j<=k&&(k-(i+j))<=n)way++;
         }
   }
   cout<<way<<endl;
  
   
   return 0;
}

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

#define ROUND_UP(a, b) ((a) + (b)-1)/(b)

int main(void)
{
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1')
			count++;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main()
{
    int n,i,j,v,k;
    cin >> n;
    int array[n];
    for (i=0;i<n;i++){
        cin>>array[i];
    }
    for (k=0;k<n;k++){
        cout << array[k] << ((k==n-1)?'\n':' ');
    }
    for (i=1;i<n;i++){
        j=i-1;
        v=array[i];
        while(j>=0 and v<array[j]){
            array[j+1]=array[j];
            j--;
        }

        array[j+1]=v;
        for (k=0;k<n;k++){
            cout << array[k] << ((k==n-1)?'\n':' ');
        }
    }

}



Measured memory_bytes: 3064
d, n = map(int, input().split())

if d == 0:
  if n != 100:
    print(n)
  else:
    print(101)
elif d == 1:
  if n != 100:
    print(n*100)
  else:
    print(10100)
elif d == 2:
  if n != 100:
    print(n*10000)
  else:
    print(1010000)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

using Graph=vector<vector<int>>;
Graph G;

int main(){
  long long n,a,b;
  cin >> n >> a >> b;
  
  if((b-a)%2==0) cout<<(b-a)/2<<endl;
  else{
    if(a==1 && b==n) cout<<1+(b-a)/2<<endl;
    else{      
        ll c=n-b+1;
        ll d=a-1+1;
        ll e=c+(n-(a+c))/2;
        ll f=d+(b-d-1)/2;
        cout<<min(e,f)<<endl;      
    }
  }
  
}
    


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


void smain() {

    int x;
    cin>>x;
    cout<<360LL/__gcd(x,360LL);


}

Measured memory_bytes: 3600
//Say hi to nerdy_geek2799
//work untill your role model does not become your opponent

#include<bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
#define all(v) (v.begin(),v.end())
#define Ryo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;
int main()
{
    Ryo;
    

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ch=0;
    while(a>=0 and c>=0)
    {
        if(ch==0)
        {
            c-=b;
            ch=1;
        }
        else
        {
            a-=d;
            ch=0;
        }
        if(a==0 or c==0)
            break;
        // cout<<a<<" "<<c<<endl;
    }
    if(a>0)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;






int main()
{

	cin >> N;

	int a = N;
	int f = 0;
	while(a!=0){
		f+=a%10;
		a/=10;
	}

	if(N%f==0){
		cout << "Yes";
	} else {
		cout << "No";
	}




}




Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll l, r;
    int ans;
    cin >> l >> r;
    if (r - l + 1 >= 2019) {
      ans = 0;
    } else {
      ans = 2020;
      FOR(i, l, r) {
        FOR(j, i + 1, r + 1) {
          int tmp = (i % 2019) * (j % 2019);
          ans = min(ans, tmp % 2019);
        }
      }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
sys.setrecursionlimit(10**9)

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N - 1)]
C = list(map(int, input().split()))

score = sum(C) - max(C)
C.sort(reverse=True)
C = deque(C)
con = [[] for _ in range(N + 1)]
ans = [0 for i in range(N + 1)]

for ab in AB:
    a, b = ab
    con[a].append(b)
    con[b].append(a)


def dfs(x):
    if len(C) == 0:
        return
    if ans[x] == 0:
        ans[x] = C[0]
        C.popleft()
        for c in con[x]:
            dfs(c)


dfs(1)
ans = list(map(str, ans))
print(score)
print(' '.join(ans[1:]))


Measured memory_bytes: 15204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var sc = new Scanner();
            long n = sc.NextLong();
            long[] a = new long[5];
            for (int i = 0; i < a.Length; i++) a[i] = sc.NextLong();

            Console.WriteLine((long)Math.Ceiling((double)n / a.Min()) + 4);
        }
    }

    class Scanner
    {
        int index = -1;
        string[] buf;

        public Scanner()
        {
        }

        public int NextInt()
        {
            CheckNext();
            return int.Parse(buf[index++]);
        }

        public long NextLong()
        {
            CheckNext();
            return long.Parse(buf[index++]);
        }

        public string NextString()
        {
            CheckNext();
            return buf[index++];
        }

        private void CheckNext()
        {
            if (index >= 0 && index < buf.Length) return;

            buf = Console.ReadLine().Split(' ');
            index = 0;
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int k, a, b;
  cin >> k >> a >> b;
  repic(i, a, b) {
    if (i % k == 0) {
      cout << "OK" << endl;
      return;
    }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3640
import itertools

N, M, Q = map(int, input().split())

ABCD = [list(map(int, input().split())) for _ in range(Q)]

rr = range(1, M + 1)
it = itertools.combinations_with_replacement(rr, N)

M_ans = 0

for A in it:
    ans = 0
    for a, b, c, d in ABCD:
        if A[b - 1] - A[a - 1] == c:
            ans += d

    if ans > M_ans:
        M_ans = ans

print(M_ans)


Measured memory_bytes: 9196
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
#define rep(i,l,r) for(ll i=l;i<=r;i++)

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll h,w;cin>>h>>w;
    ll n;cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll x,y;
    x=0;
    y=0;
    ll s[110][110];
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<a[i-1];j++){
            if(y%2==0){
                s[y][x]=i;
                if(x==w-1){
                    y++;
                }else{
                    x++;
                }
            }else{
                s[y][x]=i;
                if(x==0){
                    y++;
                }else{
                    x--;
                }
            }
        }
    }
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            if(j==0){
                cout<<s[i][j];
            }else{
                cout<<' '<<s[i][j];
            }
        }
        cout<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n,k; cin>>n>>k;
    pii arr[k];
    for(int i=0;i<k;i++) cin>>arr[i].ff>>arr[i].ss;
    int dp[n+1]={0},ways[n+1],ans=0; 
	dp[1]=1; dp[2]=-1;
	for(int i=1;i<=n;i++){
		ans=(ans+dp[i]+mod)%mod;
		ways[i]=ans;
		for(pii it : arr){
			if(i+it.ff<=n) dp[i+it.ff]=(dp[i+it.ff]+ans)%mod;
			if(i+it.ss+1<=n) dp[i+it.ss+1]=(dp[i+it.ss+1]-ans+mod)%mod;
		}
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 6772
n,m,x,y= map(int, input().split())
lix = sorted(list(map(int, input().split())))
liy = sorted(list(map(int, input().split())))
if lix[-1] < liy[0] and x < liy[0] and lix[-1] < y:
  print('No War')
  exit()
print('War')



Measured memory_bytes: 2940
import sys
input = sys.stdin.buffer.readline

r, c, k = map(int, input().split())
v = [[0]*(c+1) for i in range(r+1)]
for i in range(k):
    cr, cc, cv = map(int, input().split())
    v[cr][cc] = cv

dp = [[0]*4 for _ in range(c+1)]
last = [[0]*4 for _ in range(c+1)]
for cr in range(1, r+1):
    for cc in range(1, c+1):
        upper = max(last[cc][0], last[cc][1], last[cc][2], last[cc][3])
        dp[cc][0] = max(upper, dp[cc-1][0], dp[cc][0])
        dp[cc][1] = max(dp[cc-1][1], dp[cc-1][0]+v[cr][cc], upper+v[cr][cc])
        dp[cc][2] = max(dp[cc-1][2], dp[cc-1][1]+v[cr][cc])
        dp[cc][3] = max(dp[cc-1][3], dp[cc-1][2]+v[cr][cc])
        last = dp
print(max(dp[c]))

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

using namespace std;

bool isPalindrome(string s);

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

  if (isPalindrome(S) && isPalindrome(S.substr(0, S.size()/2))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

bool isPalindrome(string s) {
  string r = s;
  reverse(r.begin(), r.end());
  return r == s;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
     Scanner scan = new Scanner(System.in);
     int socketsInEachStrip = scan.nextInt();
     int emptySockets = scan.nextInt();
    
     int board = 0;
     if(emptySockets==1) {
    	 board=0;
     }else{
      	while(emptySockets!=0) {
       	 board++;
     	 emptySockets = emptySockets-socketsInEachStrip;
    	 if(emptySockets<=0) {
           break;
         }else{
           emptySockets++;
         }
     }
   	}
    System.out.println(board);
    }
}

Measured memory_bytes: 21844
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL-1
double EPS=1e-9;
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef complex<double> P;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
int n;
int main(){
	cin>>n;
	vi a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];a[i]--;
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(a[a[i]]==i)ans++;
	}
	cout<<ans/2<<endl;
}
/*3 5 0 3
0 1 1
1 2 1
2 3 2
0 2 3
1 3 2*/


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int  n=700,k=0;
    char a[5];
    cin>>a;
    for(int i=0;i<3;i++)
    {
        if(a[i]=='o')
            k++;
    }
    n+=(k*100);
    cout<<n<<endl;
    return 0;
}



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

int main(void){
  while(true){
    int n, m, p;
    cin >> n >> m >> p;
    if(n == 0 && m == 0 && p == 0){ break; }
    
    int sum = 0;
    vector<int> x(n);
    for(int i = 0; i < n; i++){
      cin >> x[i];
      sum += x[i];
    }

    if(x[m - 1] == 0){ cout << 0 << endl; }
    else{
      int ans = (sum * (100 - p)) / x[m - 1];
      cout << ans << endl;
    }
  }
  return 0;
}

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

int main() {
  
  int N ; 
  cin >> N ; 
  N = (N % 10 ) ;
  
  if (N == 3){
    cout << "bon" <<endl ; 
  }
  
  
    else if(N == 0 || N ==1 || N==6 || N==8){
          cout << "pon" <<endl ; 
    }
   else {
              cout << "hon" <<endl ;  
   }
     
  
 
  
}

Measured memory_bytes: 3640
#include <stdio.h>

int main (){
	int a, b, c, x;
	scanf("%d %d %d", &a, &b, &c);
	if(a > b){
		x = a;
		a = b;
		b = x;
	}
	if(b > c){
		x = b;
		b = c;
		c = x;
	}
	if(a > b){
		x = a;
		a = b;
		b = x;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int MAX_N = 1 << 17;
class RMQ{
  public:
  int n, dat[2*MAX_N - 1];

  void init(int n_){
    n = 1;
    while(n < n_){
      n *= 2;
    }

    for(int i =0; i < 2*n-1;++i){
      dat[i] = INT_MAX;
    }
  }

  void update(int k, int a){
    k += n-1;
    dat[k] = a;
    while(k>0){
      k = (k-1)/2;
      dat[k] = min(dat[k*2+1],dat[k*2+2]);
    }
  }
  //min = query(a,b,0,0,n)
  int rec(int a,int b,int k,int l, int r){
    int vl,vr;
    if(r <= a || b <= l){
      return INT_MAX;
    }
    if(a <= l && r <= b){
      return dat[k];
    }
    else{
      vl = rec(a,b,k*2+1,l,(l+r)/2);
      vr = rec(a,b,k*2+2,(l+r)/2,r);
    }
    return min(vl,vr);
  }
  int query(int a,int b){
    return rec(a,b+1,0,0,n);
  }
};

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,q,c,x,y;
  RMQ rmq;
  cin >> n >> q;
  rmq.init(n);
  rep(i,q){
    cin >> c >> x >> y;
    if(c == 0){
      rmq.update(x,y);
    }
    else{
      cout << rmq.query(x,y) << endl;
    }
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  string s; cin >> s;
  int ans = 0, x = 0;
  for (int i = 0; i < N; ++i) {
    if (s[i] == 'I') { ans = max(ans, ++x); }
    else { --x; }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

int n,s;
int saiki(int n1,int u,int m){
    if(n1 > s) return 0;
    else if(m==1){
	int d = s-n1;
	if(d <= 9 && (u & (1<<d))==0) return 1;
	else return 0;
    }else if(m==2){
	if(s-n1>26) return 0;
    }else if(m==3){
	if(s-n1>50) return 0;
    }else if(m==4){
	if(s-n1>80) return 0;
    }else if(m==5){
	if(s-n1>115) return 0;
    }else if(m==6){
	if(s-n1>154) return 0;
    }else if(m==7){
	if(s-n1>196) return 0;
    }

    int ans;
    for(int i=9;i>=0;i--){
	if((u & (1<<i))==0){
	    ans += saiki(n1+m*i,u|(1<<i),m-1);
	}
    }
    return ans;
}

void main(){
    while(true){
	auto ss = readln();
	if(stdin.eof()) break;
	int[] s1 = ss.split().to!(int[]);
	n = s1[0];
	s = s1[1];
	if(n <= 330)
	    writeln(saiki(0,0,n));
	else writeln(0);
    }
}

Measured memory_bytes: 2448
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>


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

    int N;
    std::cin >> N;
    int prev = -1;
    int continue_count = 0;
    int result = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        std::cin >> a;
        if (a == prev) {
            ++continue_count;
        } else {
            if (continue_count >= 2) {
                result += continue_count / 2;
            }
            continue_count = 1;
        }
        prev = a;
    }
    if (continue_count >= 2) {
        result += continue_count / 2;
    }
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 256