akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
using namespace std;
using ll = long long;

signed main() {
    IO;
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll x = 0;
    for(int i = 0; i < n; ++i) {
    	cin >> a[i];
    	x = x ^ a[i];
    }
    for(int i = 0; i < n; ++i) {
    	ll pr = x ^ a[i];
    	cout << pr << " ";
    }
    return 0;
}

Measured memory_bytes: 4780
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String b = sc.next();
        int c = sc.nextInt();
        if(b.equals("+")){
            System.out.println(a+c);
        }else{
            System.out.println(a-c);
        }    
    }
}


Measured memory_bytes: 21460
#include <stdio.h>

int main(void){
	int N = 0,tmp_dif=0,max_dif;
	int A[100];
	scanf("%d",&N);
	for(int i = 0;i < N;i++){
		scanf("%d",&A[i]);
	}
	for(int i = 0;i < N;i++){
		for(int j = i+1;j < N;j++){
			tmp_dif = A[i] - A[j];
			if(tmp_dif<0){
				tmp_dif = tmp_dif*(-1);
			}
			if(tmp_dif>max_dif){
				max_dif = tmp_dif;
			}
		}
	}
	printf("%d\n", max_dif);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "TASK"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))

main(){
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    int n=in,k=in,ret=0,val=0;
    vector<int> a(n+1);
    deque<int> x,y;
    forinc(i,1,n){
        a[i]=in;
        while(x.size() && i-x.front()>=k) x.pop_front();
        while(y.size() && i-y.front()>=k) y.pop_front();
        while(x.size() && a[i]<a[x.back()]) x.pop_back();
        while(y.size() && a[i]>a[y.back()]) y.pop_back();
        x.push_back(i);
        y.push_back(i);
        if(i>=k){
            if(x.size()!=k){
                ret+=i==k || a[i]<a[y.front()] || a[i-k]>a[x.front()];
            }
            else val=1;
        }
    }
    cout<<ret+val;
}



Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;


public class Main {
	 static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    }

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

	/**
	 * @param args
	 * @throws IOException
	 */
	 static int m =(int) (1e9+7);
	 static long mod(long x) {
		 
		 return ((x%m+m)%m);
	 }
	 static long add(long x,long y) {
		 return mod((mod(x)+mod(y)));
	 }
	 static long mul(long x,long y) {
		 return mod((mod(x)*mod(y)));
	 }
	 
	public static void main(String[] args)throws IOException  {
		FastReader s=new FastReader();		
		int n = s.nextInt();
		int d = s.nextInt();
		System.out.println((int)Math.ceil((double)n/(double)((2*d)+1)));
	}
}
	



Measured memory_bytes: 32884
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, k = map(int, input().split())

ans = 0
MOD = 10 ** 9 + 7 
for i in range(k, n + 2):
    low = (0 + i - 1) * i // 2
    # high = sum(j for j in range(n + 1 - i, n + 1))
    high = (n + 1 - i + n) * i // 2
    ans += (high - low + 1) % MOD
print(ans % MOD)



Measured memory_bytes: 9384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M =1000000007;
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//MOD??
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}
ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
/*int main (){
  long long i,n,k,cnt=0;
  cin>>n>>k;
  fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
  vector <ll> dp(M);
  for(i=k;i<=n+1;i++){
    cnt+=comb(n+1,i);
    cout<<n+1<<","<<i<<","<<cnt<<endl;
    if(cnt>=(long long)10e9+7 || cnt < 0)break;
  }
  if(cnt<0||cnt>=10e9+7){
    cout<<(long long)10e9 + 7<<endl;
  }
  else
  {
    cout<<cnt<<endl;
  }
  
  
  return 0;
}
*/
int main (){
  long long acnt,bcnt,a,b,i,n,k,cnt=0;
  cin>>n>>k;
  a=n;
  b=0;
  acnt=a;
  bcnt=b;
  if(k==1){
    cnt= n + 1;
  }
  for(i=2;i<=n+1;i++){
    a--;
    b++;
    acnt=(acnt+a);
    bcnt=(bcnt+b);
    if(i>=k){
      cnt+=(acnt-bcnt+1);
      if(cnt>1000000007)
        cnt = mod(cnt,1000000007);
    }
  }
  
  cout<<cnt<<endl;
  return 0;
}


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

const long long int mod=1e9+7;
int main(){
	int n;
	cin>>n;
	if(n==1){
		cout<<1<<endl;
		return 0;
	}
	vector<int> isprime(1e4,1);
	vector<int> prime_seq;
	isprime[0]=isprime[1]=0;
	for(int i=2;i<isprime.size();i++){
		if(isprime[i]){
			prime_seq.push_back(i);
			for(int j=2*i;j<isprime.size();j+=i){
				isprime[j]=0;
			}
		}
	}
	vector<long long int> yaku(prime_seq.size(),0);
	for(int i=2;i<=n;i++){
		int num=i;
		for(int j=0;num>1;j++){
			while(num%prime_seq[j]==0){
				num/=prime_seq[j];
				yaku[j]++;
			}
		}
	}
	long long int res=1;
	for(int i=0;i<yaku.size();i++){
		res*=(yaku[i]+1);
		res%=mod;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>

using namespace std;

int main(){

  int A,B,C,D; cin >> A >> B >> C >> D;
  if(B < C || A > D) printf("%d\n",0);
  else cout << min(B,D) - max(A,C) << endl;


  return 0;
}


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

int main(){
  int n;
  cin >> n;
  int m = n;
  int a = 0;
  for (int i=0;i<9;i++){
    a += n%10;
    n /= 10;
  }
  if (m % a == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Collections.max

fun main(args: Array<String>) {
    readLine()
    val inp = readLine()!!.split(" ").map { it.toLong() }
    val s = inp.sum()
    val ans = inp.map { it*s }.sum() - inp.map { it*it }.sum()
    println(ans/2)
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
// #define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

int main(){
	int N;cin>>N;
	vi B(N-1),A(N);
	rp(i,N-1)cin>>B[i];

	A[0] = B[0];
	A[N-1] = B[N-2];
	for(int i=0; i<N-2; ++i){
		int mini = min(B[i], B[i+1]);
		A[i+1] = mini;
	}


	ll ans = 0;
	rp(i,N)ans += A[i];
	ote(ans);
}


Measured memory_bytes: 256
def main():
    a_info = input().split(" ")
    b_info = input().split(" ")
    second = int(input())

    sabun = (int(a_info[1]) * second) - (int(b_info[1]) * second)

    # Aの方が大きい
    if int(a_info[0]) > int(b_info[0]):
        start = int(a_info[0]) - int(b_info[0])
    else:
        start = int(b_info[0]) - int(a_info[0])

    if start <= sabun:
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    main()


Measured memory_bytes: 9196
defmodule Main do
  def main do
    n = IO.gets("")
      |> String.trim()
      |> String.to_integer()
      |> process(1)
      |> IO.puts()
  end
  
  defp process(0, acc), do: rem(acc,1000000007)
  defp process(n, acc), do: process(n - 1, rem(acc,1000000007) * n)
end

Measured memory_bytes: 30788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;

int main() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	int n; cin >> n;
	cout << (n%2?n/2+1:n/2);
	return 0;
}
	

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

int main(){
  ll n;
  cin >> n;
  vector<ll> ans(n);
  for(int i=2;i<=n;i++){
    ll num;
    cin >> num;
    ans.at(num-1)++;
  }
  rep(i,n){
    cout << ans.at(i) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 4776
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b;
    cin >> a >> b;
    if (a > b) {
        swap(a, b);
    }
    int d = b - a;
    if (d % 2 == 0) {
        cout << (a + b) / 2 << "\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }

    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
N, Q = map(int, input().split())
S = input()
counts = [[0] * N for _ in range(2)]
for i, c in enumerate(zip(S[:-1], S[1:])):
    counts[i & 1][i] = int(c == ("A", "C"))
for i in range(2):
    counts[i] = list(accumulate(reversed(counts[i])))[::-1]
for _ in range(Q):
    l, r = map(lambda n: int(n) - 1, input().split())
    print(counts[0][l] - counts[0][r] + counts[1][l] - counts[1][r])

Measured memory_bytes: 14208
import numpy as np

n, m = map(int, input().split())
g = [[] for i in range(n + 1)]
visited = np.zeros(n, dtype=np.bool)
ans = 0


def dfs(now):
    global ans
    if (visited == True).all():
        ans += 1
    for i in range(len(g[now])):
        next_n = g[now][i]
        if visited[next_n - 1] == False:
            visited[next_n - 1] = True
            dfs(next_n)
            visited[next_n - 1] = False


for i in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)
# print(g)
visited[0] = True
dfs(1)
print(ans)


Measured memory_bytes: 12480
def wari(a,i):
    if(a%i == 0):
        return 1
    else:
        return 0

def yakusum(n):
    sum = 1
    for i in range(1,n//2):
        sum += wari(n,i)
    return sum


n = int(input())
sum = 0
for i in range(105,n+1,2):
    if yakusum(i) == 8:
        sum += 1

print(sum)


Measured memory_bytes: 3060
N,L=map(int, input().split())
min_aji = abs(L)
min_aji_index = 0
for i in range(1,N):
  abs_aji = abs(L + (i+1) - 1)
  if abs_aji < min_aji:
    min_aji = abs_aji
    min_aji_index = i
    
aji = 0
for i in range(N):
  if i != min_aji_index:
    aji += L + (i+1) - 1
    
print(aji)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

#include <iostream>
 
int main(void)
{
  int N;
  std::cin >> N;
  
  std::cout << 180 * (N-2) << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main()
{
   vector<long int>p;
   vector<long int>q;
   vector<long int>r;
   vector<long int>v;
   long int x,y,a,b,c,sum,i,j;
   cin>>x>>y>>a>>b>>c;
    long int a1,b1,c1;
   for( i=0;i<a;i++)
   {

       cin>>a1;
       p.push_back(a1);
   }
   sort(p.begin(),p.end(),greater<long long int>());
   for( i=0;i<b;i++)
   {

       cin>>b1;
       q.push_back(b1);
   }
   sort(q.begin(),q.end(),greater<long long int>());
   for(i=0;i<c;i++)
   {

       cin>>c1;
       r.push_back(c1);
   }
   for(i=0;i<x;i++)
   {
       v.push_back(p[i]);
   }
   for( i=0;i<y;i++)
   {
       v.push_back(q[i]);
   }
    for(i=0;i<c;i++)
   {
       v.push_back(r[i]);
   }
   sort(v.begin(),v.end(),greater<long long int>());
   sum=0;
   for(j=0;j<(x+y);j++)
   {
      sum=sum+v[j];
   }
   cout<<sum<<endl;
   return 0;
}


Measured memory_bytes: 8816
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll X, A;
  std::cin >> X >> A;

  if (X < A) print(0);
  else print(10);

  return 0;
}


Measured memory_bytes: 256
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int mod=1000000007;
const int big=2e9+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
class cone{
public:
	int go,Rank;//??????cone????????????????????????
	set<pair<int,int>> data;
	//pair(a,-1) a??¨?????????????????????
	//pair(a,b) b??¨???????????¨?????§a???????????????
};
vector<cone> towns;
vector<int>ans;
void marge_tech(int that,int other,int dis){
	//that??¨other?????????????????? ?????????dis
	while(towns[that].go!=that){that=towns[that].go;}
	while(towns[other].go!=other){other=towns[other].go;}
	if(that==other){return;}
	if(towns[that].Rank<towns[other].Rank){swap(that,other);}
	if(towns[that].Rank==towns[other].Rank){towns[that].Rank++;}
	towns[other].go=that;
	for(auto it=towns[other].data.begin();it!=towns[other].data.end();it++){
		auto& thD=towns[that].data;
		auto itr=thD.insert((*it)).fir;
		if(itr->sec!=-1){if(itr==thD.begin()){continue;}itr--;}
		while(itr->sec==-1&&next(itr)!=thD.end()&&next(itr)->fir==itr->fir){
			ans[next(itr)->sec]=dis;
			thD.erase(next(itr));
		}
	}
}

int main(void){
	int n,m,k,q,i,j;cin>>n>>m>>k>>q;
	vector<pair<int,int>>kyo(n);//?\?????????§????????¢,??????
	vector<pair<int,int>>motok;
	vector<vector<pair<int,int>>>road(n);
	towns.res(n);
	ans.res(q);
	for(i=0;i<n;i++){kyo[i]=mp(big,i);}
	for(i=0;i<m;i++){
		int a,b,l;cin>>a>>b>>l;a--;b--;
		road[a].pub(mp(l,b));
		road[b].pub(mp(l,a));
	}
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> que;
	for(i=0;i<k;i++){int f;cin>>f;f--;que.push(mp(0,f));kyo[f].fir=0;}
	while(!que.empty()){
		int now=que.top().fir;
		int town=que.top().sec;
		que.pop();
		if(kyo[town].fir<now){continue;}
		for(auto it=road[town].begin();it<road[town].end();it++){
			int dis=now+it->fir;
			int to=it->sec;
			if(kyo[to].fir<=dis){continue;}
			kyo[to].fir=dis;
			que.push(mp(dis,to));
		}
	}
	//?\?????????§????????¢?????????
	motok=kyo;
	sort(kyo.rbegin(),kyo.rend());//??????????????????????????????
	for(i=0;i<n;i++){
		towns[i].go=i;
		towns[i].Rank=0;
		towns[i].data.ins(mp(i,-1));
	}
	for(i=0;i<q;i++){
		int s,t;cin>>s>>t;s--;t--;
		towns[s].data.ins(mp(t,i));
	}
	for(i=0;i<n;i++){
		int that=kyo[i].sec;
		for(auto it=road[that].begin();it<road[that].end();it++){
			if(kyo[i].fir>motok[it->sec].fir){continue;}
			marge_tech(that,it->sec,kyo[i].fir);
		}
	}
	for(i=0;i<q;i++){cout<<ans[i]<<endl;}
	return 0;
}

Measured memory_bytes: 58820
import java.util.*;

public class Main {
	public static void main(String[] args) {
	      Scanner sc = new Scanner(System.in);
	      int h = sc.nextInt();
	      int w = sc.nextInt();
	      
	      char[][] grid = new char[h][w];
	      for(int i = 0; i < h; i++)
	        grid[i] = sc.next().toCharArray();
	      
	      int[][] cnt = new int[h][w];
	      if(grid[0][0] == '#')
	        cnt[0][0] = 1;

	      for(int i = 1; i < w; i++) {
	          if(grid[0][i] == '.')
	            cnt[0][i] = cnt[0][i-1];
	          else {
	            if(grid[0][i-1] == '#')
	              cnt[0][i] = cnt[0][i-1];
	            else
	              cnt[0][i] = cnt[0][i-1] + 1;
	          }
	        }
	      for(int i = 1; i < h; i++) {
	          cnt[i][0] = cnt[i-1][0];
	          if (grid[i-1][0] == '.' && grid[i][0] == '#')
	          	cnt[i][0]++;
	        }
	      
	      for(int i = 1; i < h; i++) {
	          for(int j = 1; j < w; j++) {
	            if(grid[i][j] == '.') {
	              cnt[i][j] = Math.min(cnt[i-1][j], cnt[i][j-1]);
	            } else {
	              int up = cnt[i-1][j];
	              if(grid[i-1][j] == '.')
	                up++;
	              int left = cnt[i][j-1];
	              if(grid[i][j-1] == '.')
	                left++;
	              cnt[i][j] = Math.min(up, left);
	            }
	          }
	        }
	      System.out.println(cnt[h-1][w-1]);
	}
}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
int two(int n){
  int counter = 0;
  for(int i = 0; i < 6;i++){
   if(n%2 == 0){
     counter++;
     n = n/2;
   }else{
     break;
   }
  }
  return counter;
}

int main(){
  int n;
  cin >> n;
  int answer = 0;
  int x,y;
  y = 0;
  for(int i = 1; i <= n;i++){
    x = two(i);
    if(x >= y){
      y = x;
      answer = i;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
using namespace std;


int main(){
    long long n, k, c = 0;
    cin >> n >> k;
    while(n){
      n /= k;
      c++;
    }
    cout << c;
}

Measured memory_bytes: 256
/*
 ____________________________________________________________
|                                                            |
|                   Author: ay2306                           |
|____________________________________________________________|

*/
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ord_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
const ll maxn = 1e5;

int main(){
    ll m,k;
    cin >> m >> k;
    if(m == 0){
        if(k == 0){
            cout << "0 0";
            return 0;
        }else{
            cout << "-1";
            return 0;
        }
    }
    if(m == 1){
        if(k == 0){
            cout << "0 0 1 1";
            return 0;
        }else{
            cout << "-1";
            return 0;
        }
    }
    if(k >= (1 << m)){
        cout << "-1";
        return 0;
    }
    loop(i,0,(1<<m)){
        if(i == k)continue;
        cout << i << " ";
    }
    cout << k << " ";
    loopr(i,(1<<m)-1,0){
        if(i == k)continue;
        cout << i << " ";
    }
    cout << k;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    int N, X, T;
    cin >> N >> X >> T;

    int r = N % X;
    int q = N / X;

    if (r>0){
        cout << (q+1)*T << endl;
    }else{
        cout << q*T << endl;
    }
    return 0;
    
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  ll n,k;
  cin>>n>>k;

  for(int ans=1;;++ans){
    if(n<pow(k,ans)){
      cout<<ans<<endl;
      return 0;
    }
  }

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using ll = long long;
const ll INF = 1ll << 50;

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

  const int NMAX = 1000;
  const int MMAX = 2000;
  int a[MMAX], b[MMAX];
  ll c[MMAX];

  for (int i = 0; i < M; ++ i){
      std::cin >> a[i] >> b[i] >> c[i];
      c[i] = -c[i];
  }

  ll dist[NMAX];
  for (int i = 0; i < N; ++ i) {
      dist[i] = INF;
  }
  dist[0] = 0;

  for (int loop = 0; loop < N - 1; ++ loop) {
      for (int i = 0; i < M; ++ i) {
          if (dist[a[i] - 1] == INF) continue;
          if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
              dist[b[i] - 1] = dist[a[i] - 1] + c[i];
          }
      }
  }

  ll ans = dist[N - 1];

  bool negative[NMAX];
  for (int i = 0; i < N; ++ i) {
      negative[i] = false;
  }

  for (int loop = 0; loop < N; ++ loop) {
      for (int i = 0; i < M; ++ i) {
        if (dist[a[i] - 1] == INF) continue;
        if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
            dist[b[i] - 1] = dist[a[i] - 1] + c[i];
            negative[b[i] - 1] = true;
        }

        if (negative[a[i] - 1] == true) {
          negative[b[i] - 1] = true;
        }
      }
  }

  if (negative[N - 1])
      std::cout << "inf" << std::endl;
  else
      std::cout << -ans << std::endl;

  return 0;

}

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

int main()
{
    int n;
    cin >> n;
    long long * input_num = new long long[n];
    for(int i = 0; i < n; i++) cin >> input_num[i];

    long long min = input_num[0];
    long long max = input_num[0];
    long long sum = 0;

    for(int i = 0; i < n; i++) {
        if(input_num[i] < min) min = input_num[i];
        if(input_num[i] > max) max = input_num[i];
        sum += input_num[i];
    }

    cout << min << " " << max << " " << sum << endl;
    
    delete[] input_num;
    return 0;
}

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

int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a>k){
    cout<<":("<<endl;
  }else{
    cout<<"Yay!"<<endl;
  }
  
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[5000],dp[5000][5000],pref[5000];

ll sum(ll l, ll r){
	return pref[r] - pref[l - 1];
}

ll deq(ll l, ll r){
	if(l == r) return arr[l];
	if(dp[l][r] != -1) return dp[l][r];
	
	dp[l][r] = max((arr[l] + sum(l + 1, r) - deq(l + 1,r)), (arr[r] + sum(l, r - 1) - deq(l,r - 1)));
	
	return dp[l][r];
}

int main (){
	memset(dp,-1,sizeof dp);
	ll n;
	cin >> n;
	for(ll i = 1; i <= n; i++){
		cin >> arr[i];
	}
	
	pref[1] = arr[1];
	for(int i = 2; i <= n; i++){
		pref[i] = pref[i - 1] + arr[i];
	}
	
	ll ans = deq(1,n);
	ll totj = pref[n] - ans;
	cout << ans  - totj << endl; 
}

Measured memory_bytes: 195712
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>

using namespace std;

int main(int argc, char* argv[]) {

	long long S;
	int cnt = 0;
	int flg1 = 2;
	int flg2 = 2;
	int flg4 = 2;

	cin >> S;

	do{

		if (S == 4) {
			flg4--;
		}

		if (S == 2) {
			flg2--;
		}

		if (S == 1) {
			flg1--;
		}

		if (S % 2 == 0) {
			S /= 2;
		}
		else {
			S = 3 * S + 1;
		}

		cnt++;

	}while(flg1 > 0 && flg2 > 0 && flg4 > 0);

	cout << cnt << endl;

	return 0;

}

Measured memory_bytes: 256
a=[input().split() for _ in range(3)]
n=int(input())
b=[input() for _ in range(n)]
for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j]==b[k]:
                a[i][j]='0'
ans="No"
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]:
        ans="Yes"
    if a[0][i]==a[1][i]==a[2][i]:
        ans="Yes"
if a[0][0]==a[1][1]==a[2][2]:
    ans="Yes"
if a[0][2]==a[1][1]==a[2][0]:
    ans="Yes"
print(ans)

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*
説明がとても難しい、けど練習と思って書いてみる。
理屈はおいといて、すべての排他的累積和=0になる場合、後攻が必勝。
感覚的には、
1で自分にまわってきてほしくない
=2で自分にまわってほしい
=3で自分にまわってほしい
=...みたいなじり貧になるケースは、排他的累積和が0のとき後攻が勝利しそうです。（なんの証明にもなっていないけど:nauseated_face: ）

求めるべきbitは、すべてのA[i]の排他的論理和x^=A[i] (i=0～N-1)が0になること。
x=A[2]～A[N-1]までの排他的論理和//A[0]A[1]は除く。なぜかというと、排他的論理和の逆元は自身だからなんだけど、難しい:sweat_smile: 
y=(A[0]-i)^(A[1]+i)とする。//チート操作したあとの排他的論理和
x==yのとき、排他的論理和x^yが0になって解答を満たすのがわかる。
もし
x = 1010(bit表記) //=10
とする

yがとりうる組み合わせを考える。
bitが0の箇所には、1^1 または0^0が考えられる。
bitが1の箇所は0^1または1^0が考えられる。
たとえば
(1010,0000) 
(1011,0001)//1bit目にどちらも1をとるとか
(1111,0101)//1,3bit目に1をとるとか
(1000,0010)//2bit目の1を他方に渡すとか
(11010,10000)//5bit目のどちらも1をとる
なんかのバリエーションがある。

これらの組み合わせのうち、和がA[0]+A[1]と等しいものが、今回の解答の候補になる。
上位bitからの探索で選択肢を絞れる。
もしA[0]＋A[1]＝32とすると、少なくとも
(10000,10000) //16+16
両方の5bit目に1を選ばないと、満たせなくなるから。

なので、上位から見て行って
1.bitが0で、そのbitに両方1を入れたとき、A[0]+A[1]を超えるなら、0確定。
2.bitが0で、そのbitに両方1を入れたとき、A[0]+A[1]以下なら、1確定。
3.bitが1だった場合、どちらに渡すかは下位bitの選択肢によって変わるので、候補として残す。

もしA[0]=14、A[1]=8、x=100(bit表記)について上記操作を行うと、
5bit目までは16×2=32が、和の8+14=22を満たさないので、ケース1に該当し0確定
4bit目 ケース2に該当し、1xxx確定// 22 - 8×2 = 6が残りの振り分けられる値
3bit目 ケース3に該当し、 1xxxとして、3bit目100をストック// 6 - 4 =2
2bit目 ケース1に該当し、1x0x確定
1bit目 ケース2に該当し、1x01確定//2-1*2=0。値を0にできたことで、少なくとも後攻勝利パターンの存在が確定する。
この場合、考えられる組み合わせは、xに互いに0,1を分けた場合の(1001,1101)=(9,13)と(1101,1001)=(13,9)だけ。
A[0]=14により近い(13,9)が選ぶべきパターンで、解答は14-13=1になる。
*/
int main(){
  ll N,oo=1e12; cin>>N;
  vector<ll> A(N,0),B(0,0),C(0,0);
  ll x=0;
  for(ll i=0; i<N; i++) cin>>A[i];
  for(ll i=0; i<N; i++) x^=A[i];
  if(x==0){
    cout<<0<<endl;
    return 0;
  }
  x^=A[0];
  x^=A[1];
  ll tmp=A[0]+A[1];
  ll res=0;
  for(ll i=40; i>=0; i--){
    ll n=(1LL<<i);    
    if((x&n)==0){
      if(tmp>=n*2){
        res+=n;
        tmp-=n*2;
      }
    }
    else{//01の際1をどちらに入れるか選択
      B.push_back(n);
      tmp-=n;
    }
  }
  if(tmp!=0){
    cout<<-1<<endl;
    return 0;
  }
  for(auto v:B){
    if(res+v > A[0]) C.emplace_back(res+v);//A[0]を上回ったら候補。
    else res+=v;//下回ってるなら和をとっちゃう
  }
  C.emplace_back(res);
  sort(C.begin(),C.end());
  ll ans=1e12;
  for(auto v: C){
    if(v>A[0] || v==0) continue;
    ans=min(ans,A[0]-v);
  }
  if (ans==oo) cout<<-1<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 3596
# AtCoder Beginner Contest 175
# A - Rainy Season

S=input()
if S=="RRR":
    print(3)
    exit()
if S=="SRR" or S=="RRS":
    print(2)
    exit()
if S=="SSS":
    print(0)
    exit()
else:
    print(1)

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

const int fe = 0;
const int ma = 1;
int sex[100005];

int main()
{
    for (int i = 0; i < 100005; i++) {
        sex[i] = -1;
    }
    
    int n;

    scanf("%d", &n);

    int invalid = n - 1;
    int valid = 0;
    char str[16];

    printf("0\n");
    fflush(stdout);

    scanf("%s", str);

    if (str[0] == 'V') {
        return 0;
    }
    else if (str[0] == 'F') {
        sex[0] = fe;
    }
    else {
        sex[0] = ma;
    }

    while (invalid - valid > 1) {
        int mid = (invalid + valid) / 2;

        printf("%d\n", mid);
        fflush(stdout);

        scanf("%s", str);

        if (str[0] == 'V') {
            return 0;
        }
        else if (str[0] == 'F') {
            sex[mid] = fe;
        }
        else {
            sex[mid] = ma;
        }

        if ((mid - valid + 1) % 2) {
            if (sex[mid] == sex[valid]) {
                valid = mid;
            }
            else {
                invalid = mid;
            }
        }
        else {
            if (sex[mid] == sex[valid]) {
                invalid = mid;
            }
            else {
                valid = mid;
            }
        }
    }

    printf("%d\n", invalid);
    fflush(stdout);
}


Measured memory_bytes: 1236
// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
//#define PB push_back
#define CLEAR(c,d) memset((c),(d),sizeof(c))
#define TO_STRING(VariableName) # VariableName
//#define DB(c) cout<<TO_STRING(c)<<"="<<(c)<<endl

#define EXIST(e,s) ((s).find(e)!=(s).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;
// }}}

int perm_parity(vector<int> v){
	vector<int> w = v;
	sort(ALL(w));
	unordered_map<int,int> rev_v;
	REP(i,v.size())rev_v[v[i]] = i;
	int parity = 1;
	REP(i,v.size()){
		if(v[i]==w[i])continue;
		else{
			int j = rev_v[w[i]];
			swap(v[i],v[j]);
			rev_v[v[i]] = i;
			rev_v[v[j]] = j;
			parity *= -1;
		}
	}
	return parity;
}

int a[3][100010];

vector<int> v,sign,even,odd;
int odd_prod = 1, even_prod = 1;

int main(){
	int N;
	scanf("%d",&N);
	REP(i,3)REP(j,N)scanf("%d",&a[i][j]),a[i][j]--;
	bool valid = true;
	REP(i,N){
		int m = a[1][i];
		if(not ((a[0][i]==m-1 and a[2][i]==m+1) or (a[0][i]==m+1 and a[2][i]==m-1))){
			valid = false;
		}
		v.push_back(m/3);
		sign.push_back(a[0][i]==m-1?1:-1);
	}
	if(not valid){
		printf("No\n");
		return 0;
	}
	REP(i,N){
		if(i%2==0)even.push_back(v[i]),even_prod*=sign[i];
		else odd.push_back(v[i]),odd_prod*=sign[i];
	}
	int even_parity = perm_parity(even), odd_parity = perm_parity(odd);
	sort(ALL(even));sort(ALL(odd));

	REP(i,N){
		if(i%2==0){
			if(even[i/2]!=i)valid = false;
		}else{
			if(odd[i/2]!=i)valid = false;
		}
	}
	if(even_parity != odd_prod or odd_parity != even_prod) valid = false;
	if(valid)printf("Yes\n");
	else printf("No\n");
	return 0;
}


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

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

		if(N == 1) {
			System.out.println("Hello World");
		}else {
			int A = sc.nextInt();
			int B = sc.nextInt();

			System.out.println(A+B);
		}

	}

}


Measured memory_bytes: 22612
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int ans=0;
  int n;
  cin >> n;
  int a[n];
  rep(i,n){
    cin >> a[i];
    a[i]--;
  }
  rep(i,n){
    if(a[a[i]]==i)ans++;
  }
  cout << ans/2 << endl;  
return 0;}

Measured memory_bytes: 640
import copy

N,K = map(int, input().split())
S = list(input())

lenLorR, LR, temp, happness = 0, S[0], 1, 0
for i in range(1, N):
    if LR == S[i]:  temp += 1
    else:
        lenLorR += 1
        happness += temp - 1
        LR, temp = S[i], 1
lenLorR += 1
happness += temp - 1

if lenLorR // 2 <= K:   print(N-1)
else:   print(happness + K * 2)

Measured memory_bytes: 4516
e=Hash.new [];n=gets.to_i;(n-1).times{|i|gets.split.map{|v|e[v]+=[i]}};a=[0]*(n-1);(1..n).map{|w|u={};e[v=w.to_s].map{|j|u[a[j]]=1};t=1;e[v].map{|j|1>a[j]&&(t+=1until$\==u[t];a[j]=t;t+=1)}};p a.max;$><<a*$/

Measured memory_bytes: 194836
#include<bits/extc++.h>
#ifdef _debug 
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#include<bits/stdc++.h>
#define dout(i) 0&&0
#endif
#pragma GCC optimize("unroll-loops,no-stack-protector,O3")
#define eout(i) {cout << (i) << '\n';exit(0);}
#define rout(i) {return cout << (i) << '\n', 0;}
#define priority_queue __gnu_pbds::priority_queue
#define unordered_map __gnu_pbds::gp_hash_table
#define rep(a, b) {for(int _i = a;_i > 0;--_i){b;}}
#define multe int _T;for(cin >> _T;_T--;)
using namespace std;
using ll = long long;using ull = unsigned long long;using ul = unsigned;using db = double;
using __gnu_pbds::null_type;
template<typename T> void read(int n, T s){while(n--)cin >> *s, ++s;}
template<typename T> void write(int n, T s){while(n--)cout << *s << " \n"[n==0], ++s;}
template<typename T> using rbtree = __gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T> inline ostream& operator << (ostream &ou, const vector<T> &a){for(auto it = a.begin();it != a.end();++it)ou << (it != a.begin() ? " " : "") << *it;return ou;}
template<typename T1, typename T2>inline istream& operator >> (istream &in, pair<T1, T2> &a){return in >> a.first >> a.second;}
template<typename T1, typename T2>inline ostream& operator << (ostream &ou, const pair<T1, T2> &b){return ou << b.first << ' ' << b.second;}
template<typename T> inline long long pow(long long v, long long t, const T &p){long long res = 1;for(;t;t >>= 1, v = v * v % p)if(t & 1)res = res * v % p;return res;}
int n;
const int maxn = 200;
int dp[2][maxn];
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	read(n, dp[0]+1);
	read(n, dp[1]+1);
	for(int i = 1;i <= n;++i)dp[0][i] += dp[0][i-1];
	for(int i = 1;i <= n;++i)dp[1][i] += max(dp[1][i-1], dp[0][i]);
	cout << dp[1][n] << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int x,y,X,Y;

int main(){
	cin>>x>>y>>X>>Y;
	for(int i=x;i<X;i++) cout<<'R';
	for(int i=y;i<Y;i++) cout<<'U';
	for(int i=x;i<X;i++) cout<<'L';
	for(int i=y;i<Y;i++) cout<<'D';
	cout<<'D';
	for(int i=x;i<=X;i++) cout<<'R';
	for(int i=y;i<=Y;i++) cout<<'U';
	cout<<'L';
	cout<<'U';
	for(int i=x;i<=X;i++) cout<<'L';
	for(int i=y;i<=Y;i++) cout<<'D';
	cout<<'R'<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 305;
const int P = 998244353;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, sum, dp[MAXN][MAXN * MAXN][2];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int power(int x, int y) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
int main() {
	read(n), sum = 0;
	dp[0][0][0] = dp[0][0][1] = 1;
	for (int i = 1; i <= n; i++) {
		int x; read(x); sum += x;
		for (int j = 0; j <= sum; j++) {
			dp[i][j][0] = dp[i - 1][j][0];
			dp[i][j][1] = dp[i - 1][j][1] * 2 % P;
			if (j >= x) {
				update(dp[i][j][0], dp[i - 1][j - x][0]);
				update(dp[i][j][1], dp[i - 1][j - x][1]);
			}
		}
	}
	int ans = power(3, n);
	for (int i = (sum + 1) / 2; i <= sum; i++)
		update(ans, P - 3ll * dp[n][i][1] % P);
	if (sum % 2 == 0) {
		//cerr << dp[n][sum / 2][0] << endl;
		update(ans, 3ll * dp[n][sum / 2][0] % P);
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 217472
from itertools import permutations

N, M, R = map(int, input().split())
r = [int(i)-1 for i in input().split()]
v = [[] for _ in range(N)]
for _ in range(M) :
    A, B, C = map(int, input().split())
    v[A-1].append((B-1, C))
    v[B-1].append((A-1, C))

def dijkstra(s) :
    queue = [(s, 0)]
    dist = [float('inf')] * N
    dist[s] = 0
    while queue :
        cur, ccost = queue.pop()
        for nex, ncost in v[cur] :
            if ccost + ncost < dist[nex] :
                dist[nex] = ccost + ncost
                queue.append((nex, ccost + ncost))
    return dist
    
dist = dict()
for rr in r :
    dist[rr] = dijkstra(rr)

lr = len(r)
m = float('inf')
for perm in permutations(r) :
    tot = 0
    for i in range(lr-1) :
        tot += dist[perm[i]][perm[i+1]]
    m = min(m, tot)
    
print(m)

Measured memory_bytes: 48728
r, c = map(int, input().split())
element = [list(map(int, input().split())) for i in range(r)]
for i in range(r):
    element[i].append(sum(element[i]))
for i in range(r):
    for j in range(c):
        print(element[i][j],end="")
        print(' ',end="")
    print(element[i][c])
for i in range(c):
    num = 0
    for j in range(r):
        num += element[j][i]
    print(num, end="")
    print(' ',end="")
b = 0
for i in range(r):
    b += element[i][c]
print(b)



Measured memory_bytes: 6752
from operator import itemgetter
 
N = int(input())
 
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))
 
    except:
        break;
  
listB = sorted(listA)
listC = sorted(listB, key=itemgetter(1))

flag = 0
time = 0
for i in range(N):
	time += listC[i][0]
	if time > listC[i][1]:
		flag = 1
		break
 
if flag==0:
	print('Yes')
elif flag==1:
	print('No')

Measured memory_bytes: 56772
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define N 1000005

int main() {

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

    int a[105];

    int ans = 0;

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

        if((i%2) && (a[i]%2)) {
            ans++;
        }
    }

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


Measured memory_bytes: 3824
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#define int long long
using namespace std;

const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	int minus = 0;
	for(int i = 0;i < N;i++) {
		if(vec.at(i) < 0) {
			minus++;
		}
	}
	int cnt = 0;
	for(int i = 0;i < N;i++) {
		if(vec.at(i) < 0) {
			cnt += vec.at(i) * -1;
          	vec.at(i) = vec.at(i) * -1;
		}
		else {
			cnt += vec.at(i);
		}
	}
	if(minus % 2 == 0) {
		cout << cnt << endl;
	}
	else {
      	sort(vec.begin(),vec.end());
		cout << cnt - 2 * vec.at(0) << endl;
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int a[9], n, b[11];

void solve()
{
    for (int i=0; i<9; i++) cin >> a[i];
    cin >> n;
    for (int i=0; i<n; i++) cin >> b[i];
    for (int i=0; i<n; i++) {
        for (int j=0; j<9; j++) {
            if (b[i]==a[j]) a[j] = -1;
        }
    }
    if (a[0]+a[4]+a[8]==-3) nout("Yes");
    else if (a[2]+a[4]+a[6]==-3) nout("Yes");
    else if (a[0]+a[3]+a[6]==-3) nout("Yes");
    else if (a[1]+a[4]+a[7]==-3) nout("Yes");
    else if (a[2]+a[5]+a[8]==-3) nout("Yes");
    else if (a[0]+a[1]+a[2]==-3) nout("Yes");
    else if (a[3]+a[4]+a[5]==-3) nout("Yes");
    else if (a[6]+a[7]+a[8]==-3) nout("Yes");
    else nout("No");
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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


int main() {
    ll N;
    cin >> N;
    vector<ll> H(N);

    rep(i,N){
        cin >> H[i];
        if(i == 0){
            H[i]--;
        }else{
            if(H[i] > H[i-1]){
                H[i]--;
            }
        }
    }

    rep(i,N-1){
        if(H[i] > H[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 4032