akhauriyash/Code-Regression huggingface dataset:
import sys
import copy

input = sys.stdin.readline

def mymax(a, b, c=None):
    """
        最大値を返すメソッド.
        値が2, 3つの場合のみ対応している.
    """
    if c == None:
        if a > b:
            return a
        else:
            return b

    if a > b:
        if c > a:
            return c
        else:
            return a
    else:
        if c > b:
            return c
        else:
            return b

def main():
    H, W = map(int, input().split())
    grid = []
    for _ in range(H):
        grid.append(list(input()[:-1]))
    
    L = [[0] * W for _ in range(H)]
    R = copy.deepcopy(L)
    U = copy.deepcopy(L)
    D = copy.deepcopy(L)
    
    for h in range(H):
        cntL, cntR = 0, 0
        for w in range(W):
            wreverse = W - w - 1
            if grid[h][w] == '.':
                cntL += 1
            else:
                cntL = 0
            if grid[h][wreverse] == '.':
                cntR += 1
            else:
                cntR = 0
            L[h][w] = cntL
            R[h][wreverse] = cntR

    for w in range(W):
        cntU, cntD = 0, 0
        for h in range(H):
            hreverse = H - h - 1
            if grid[h][w] == '.':
                cntU += 1
            else:
                cntU = 0
            if grid[hreverse][w] == '.':
                cntD += 1
            else:
                cntD = 0
            U[h][w] = cntU
            D[hreverse][w] = cntD
    
    ans = 0
    for h in range(H):
        for w in range(W):
            ans = mymax(ans, L[h][w] + R[h][w] + U[h][w] + D[h][w] - 3)

    print(ans)
        
if __name__ == "__main__":
    main()


Measured memory_bytes: 365132
import java.util.Scanner;

/**
 * Created by torum on 2017/09/23.
 */
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = sc.nextInt();
        int count = 0;
        for(int i= 0; i <= N; i++ ){
            for(int j = 0; j<= M;j++){
                count = 0;
                count = i*M + j*N - (2*i*j);
                if(K == count){
                    System.out.println("Yes");
                    return ;
                }
            }
        }
        System.out.println("No");


    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using s64 = signed long long;
using u64 = unsigned long long;
using f128 = long double;

int main()
{
    s64 n, x, t;
    cin >> n >> x >> t;

    s64 count = ceil((float)n / (float)x);
    cout << count * t << endl;

    return 0;
}


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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = (int)2e5 + 10;
char inp[N];

int main(){
  fastIO;
  string t;
  cin >> t;
  int n = t.size();
  int zer = 0, one = 0;
  for(int i = 0 ; i < n; i ++ ){
    inp[i]=t[i];
    if(t[i]=='0')zer++;
    else one++;
  }
  vector<int> rem;
  int pf = 0;
  ll ans = 0;
  for(int i = 0 ; i < n ; i ++ ){
    if(t[i]=='0'){
      rem.push_back(0);
    }
    else{
      if(!rem.empty() && rem.back() == 1){
        rem.pop_back();
        ans += zer;
        continue;
      }
      rem.push_back(1);
    }
  }
  pf = 0;
  int xr = 1;
  for(auto x : rem){
    if(x==0) pf ++ ;
    else{
      ans += (pf+xr)/2;
      ans += zer-pf;
    }
    xr ^= 1;
  }
  for(int i = 1; i <= one; i ++ ){
    ans += (i + 1) / 2;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 4680
#include<stdio.h>
int a[109];
int abs(int x)
{
    return x>0?x:-x;
}
int main()
{
    int n,i,j,minn=2147483647,ans=0,sum=0;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1; i<=n; i++)
    {    ans=0;
        for(j=i+1; j<=n; j++)
        {
            ans+=a[j];
        }
        sum+=a[i];
        if(abs(ans-sum)<minn)
        {
            minn=abs(ans-sum);
            continue;
        }
    }printf("%d\n",minn);
    return 0;


}


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < (n); ++i){
    if(s.substr(i,3)=="ABC") ++cnt;
    else continue;
  }
  cout << cnt << endl;
  
  return 0;
}


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

using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>

int x;
int main() {

  //ios::sync_with_stdio(false);
  //cin.tie(0);
  ll l,r;
  sf(l);sf(r);
  if(r-l>=2019)
  {
      pf(0);
      return 0;
  }
  ll mn=999999999999999999;
  for(ll i=l;i<r;i++)
  {
      for(ll j=i+1;j<=r;j++)
      {
          ll temp=(i*j)%2019;
          if(temp<mn)mn=temp;
      }
  }
  pf(mn);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define MOD 1000000007
#define deb(n) cout<<"[ "#n<<" = "<<n<<" ]"<<endl;
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const long long  MAX = 1 << 18;
int case_no = 1;
#define w(x) int x; cin>>x; while(x--)

int main() {
    FIO
    int n;
    cin >> n;
    if(n == 0) cout << "1" << endl;
    else cout << "0" << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <bitset>
#include <numeric>
#include <cmath>
#include <tuple>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(ll i = 0; i < N; i++){
        cin >> A[i];
    }

    for(ll i = 0; i < N; i++){
        A[i] = A[i] - (i+1);
    }

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

    ll med = 0;
    med = A[N/2];

    ll ans = 0;
    for(int i = 0; i < N; i++){
        ans += abs(A[i]- med);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
n,a,b = map(int,input().split())


"""
def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res
"""
def cmb(n, r, p):
    #print(r)
    if (r < 0) or (n < r):
        return 0
    tmp = 1
    for i in range(r):
        tmp *= (n-i) % p
        tmp %= p
        tmp *= pow(r-i,p-2,p) % p
        tmp %= p
    return tmp%p
    #r = min(r, n - r)
    #return fact[n] * factinv[r] * factinv[n-r] % p

N = n

"""
def pow(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
        print(n,x,ans)
    return ans

pow(2,9)
exit()
"""
p = 10 ** 9 + 7
#N = 10 ** 6  # N は必要分だけ用意する
"""
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
"""
ans = (pow(2,n)-1)%p
#print(ans)
#exit()
#print(cmb(n, a, p) , cmb(n, b, p))
#print(ans,cmb(n, a, p),cmb(n, b, p))
ans -= (cmb(n, a, p) + cmb(n, b, p))

print(ans%p)

Measured memory_bytes: 280860
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vvll = vector<vector<ll>>;
using vll = vector<ll>;

vector<ll> dx{0,1,0,-1};
vector<ll> dy{1,0,-1,0};

int main(){
    ll H,W;
    cin>>H>>W;
    vector<string> route(H);
    vvll dist(H,vll(W,-1));
    for(ll i=0;i<H;i++)
    {
        cin>>route[i];
    }
    ll ma=0;
    for(ll i=0;i<H;i++)
    {
        for(ll j=0;j<W;j++)
        {
            if(route[i][j]=='#')continue;
            queue<pll>  que;
            dist=vvll(H,vll(W,-1));
            que.push(make_pair(i,j));
            dist[i][j]=0;
            while(!que.empty())
            {
                pll v=que.front();
                que.pop();
                for(ll k=0;k<4;k++)
                {
                    ll x=v.first+dx[k];
                    ll y=v.second+dy[k];
                    if(x<0 || y<0 || H<=x || W<=y)continue;
                    if(route[x][y]=='#')continue;
                    if(dist[x][y]!=-1)continue;
                    que.push(make_pair(x,y));
                    dist[x][y]=dist[v.first][v.second]+1;
                    ma = max(ma,dist[x][y]);
                }
            }
        }
    }
    cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 3640
program equeue
    implicit none
    integer(8),allocatable:: v(:)
    integer(8):: n,k
    integer(8):: i,li,ri,put, ans
    integer(8),allocatable:: get(:)

    read*, n, k
    allocate(v(n))
    read*, v(:)

    ans=-1000000000
    do li=0, min(n,k)
        do ri=0, min(n,k)-li
            put = k - li - ri
            allocate(get(li+ri))
            get(:li) = v(:li)
            get(li+1:) = v(n-ri+1:)
            if (.not. li+ri == 0) call merge_sort(get,1_8,li+ri)
            do i=1, min(int(size(get)),int(put))
                get(i) = max(0_8,get(i)) 
            end do
            ans=max(ans,sum(get))
            deallocate(get)
        end do
    end do

    print*, ans

contains
recursive subroutine merge_sort(ar,fst,lst)
    integer(8), intent(inout):: ar(:)
    integer(8), intent(in):: fst,lst
    integer(8):: mdl


    if (lst-fst < 2) then
        if (lst-fst == 0) return
        if (ar(fst) > ar(lst)) call swap(ar(fst), ar(lst))
        return
    end if

    mdl = (fst+lst)/2

    call merge_sort(ar,fst,mdl)
    call merge_sort(ar,mdl+1,lst)
    call merge_(ar,fst,mdl,lst)
end subroutine

subroutine merge_(ar,fst,mdl,lst)
    integer(8),intent(inout):: ar(:)
    integer(8),intent(in):: fst,mdl,lst
    integer(8),allocatable:: tmp(:)
    integer(8):: li, ri, ti
    
    allocate(tmp(lst-fst+1))
    li = fst
    ri = mdl+1
    ti = 1

    do while (li <= mdl .and. ri <= lst)
        if (ar(li) <= ar(ri)) then
            tmp(ti) = ar(li)
            li=li+1
        else
            tmp(ti) = ar(ri)
            ri=ri+1
        end if
        ti=ti+1
    end do
    

    if (li <= mdl) then
        tmp(ti:) = ar(li:mdl)
    else
        tmp(ti:) = ar(ri:lst)
    end if

    ar(fst:lst) = tmp(:)
    deallocate(tmp)
end subroutine

subroutine swap(x,y)
    integer(8), intent(inout):: x,y
    integer(8)::tmp
    tmp=x
    x=y
    y=tmp
end subroutine
    
end program equeue

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

int main() {
    ll N, K, Q;
    cin >> N >> K >> Q;

    vector<ll> A(Q, -1);
    rep(i, Q){
        cin >> A.at(i);
    }

    vector<ll> B(N, 0);
    rep(i, Q){
        B.at(A.at(i)-1) += 1;
    }

    rep(i, N){
        if(K - (Q - B.at(i)) <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }

}

Measured memory_bytes: 2176
# -*- coding: utf-8 -*-

def main():
    # # 整数の入力
    # a = int(input())
    # # スペース区切りの整数の入力
    # b, c = map(int, input().split())
    # # 文字列の入力
    # s = input()
    # # 出力
    # print("{} {}".format(a+b+c, s))
    r = int(input())
    print(3 * r * r)

if __name__=='__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main() {
	int n, p;
	while (cin >> n >> p) {
		if (n == 0 && p == 0) {
			break;
		}
		int kouho[50] = {0};
		int owan = p;
		int counter = 0;
		while (1) {
			//cout << owan << endl;
			if (owan > 0) {
				kouho[counter]++;
				owan--;
				if (owan == 0) {
					bool hantei = true;
					for (int i = 0; i < n; i++) {
						if (i != counter && kouho[i] != 0) {
							hantei = false;
						}
					}
					if (hantei) {
						break;
					}
				}
			} else {
				owan = kouho[counter];
				kouho[counter] = 0;
			}
			counter++;
			if (counter >= n) {
				counter = 0;
			}
		}
		cout << counter << endl;
	}
	return 0;
}

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

int main() {
	int A, B, M;
	cin >> A >> B >> M;
	vector<int> a(A), b(B);
	for (int i = 0; i < A; i++) {
		cin >> a.at(i);
	}
	for (int i = 0; i < B; i++) {
		cin >> b.at(i);
	}
	int min_a = *min_element(a.begin(), a.end());
	int min_b = *min_element(b.begin(), b.end());
	int ans = (min_a + min_b);
	for (int i = 0; i < M; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		int tmp = a.at(x - 1) + b.at(y - 1) - c;
		if (tmp < ans) ans = tmp;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);


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

string s;
cin >> s;
if(s == "ABC") cout << "ARC" << endl;
else cout << "ABC" << endl;




//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 3656
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Dividing a String
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

char buf[MAX_N + 8];
int dp[MAX_N + 1][2];

/* subroutines */

inline void setmax(int &a, int b) { if (a < b) a = b; }

/* main */

int main() {
  char *s = buf + 2;
  scanf("%s", s);
  int n = strlen(s);

  if (n == 1) {
    puts("1");
    return 0;
  }

  for (int i = 0; i < n; i++)
    for (int j = 0; j < 2; j++) {
      if (j != 0 || s[i - 1] != s[i])
	setmax(dp[i + 1][0], dp[i][j] + 1);
      if (i + 1 < n && (j != 1 || s[i - 2] != s[i] || s[i - 1] != s[i + 1]))
	setmax(dp[i + 2][1], dp[i][j] + 1);
    }

  printf("%d\n", max(dp[n][0], dp[n][1]));
  return 0;
}


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

void dfs(vector<int> v[], vector<int> &dp, vector<bool> &visited, int i) {
	visited[i] = true;
	
	for(int j=0;j<v[i].size();j++) {
		if(!visited[v[i][j]]) {
			dfs(v, dp, visited, v[i][j]);
		}
		dp[i] = max(dp[i], 1 + dp[v[i][j]]);
	}
}

int main() {
	int n,m, a, b;
	cin>>n>>m;
	vector<int> v[n+1];
	for(int i=0;i<m;i++) {
		cin>>a>>b;
		v[a].push_back(b);
	}
	vector<int> dp(n+1, 0);
	vector<bool> visited(n+1, false);
	for(int i=1;i<=n;i++) {
		if(!visited[i]) {
			dfs(v, dp, visited, i);
		}
	}
	int answer = INT_MIN;
	for(int i=1;i<=n;i++) {
		answer = max(answer, dp[i]);
	}
	cout<<answer<<endl;
	
	return 0;
}


Measured memory_bytes: 9600
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

bool compare(tuple<int, string, int>& a, tuple<int, string, int>& b) {
    if (get<1>(a) != get<1>(b))
        return get<1>(a) < get<1>(b);
    else
        return get<2>(a) > get<2>(b);
}

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

    vector<tuple<int, string, int>> v(n);
    for (int i = 0; i < n; ++i) {
        string s;
        int p;
        cin >> s >> p;
        v[i] = make_tuple(i, s, p);
    }

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

    for (int i = 0; i < n; ++i)
        cout << get<0>(v[i]) + 1 << '\n';
}


Measured memory_bytes: 256
let () =
  let n, x = Scanf.scanf "%d %d\n" (fun n x -> n, x) in
  let a :: as_ = Array.to_list @@ Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  List.fold_left (fun (prev, acc) a ->
    let cost = max 0 (prev + a - x) in
    (max 0 (a - cost), cost + acc)) (a, 0) as_
  |> snd
  |> Printf.printf "%d\n"

Measured memory_bytes: 6272
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if(a <= 9 && b <= 9) cout << a*b << endl;
	else cout << -1 << endl;
	return 0;
}

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

int main() {
  ll n;cin>>n;
  vector<char> ans;
  ll d = (n-1) % 26;
  while (n>0) {
    ans.push_back('a'+d);
    n = (n-1)/26;
    d = (n-1)%26;
  }
  reverse(ans.begin(), ans.end());
  for (auto c: ans) cout<<c;
}


Measured memory_bytes: 3624
N=int(input())

def check(n):
  cnt=0
  for i in range(1,n+1):
    if n%i==0:
      cnt+=1
  if cnt==8:
    return True
  else:
    return False

ans=0
for j in range(1,N+1):
  if check(j) and j%2==1:
    ans+=1

print(ans)

Measured memory_bytes: 3060
# coding: utf-8
import math
n=int(input())
A=[]
B=[]
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
cnt=0
for i in range(n-1,-1,-1):
    a=A[i]
    b=B[i]
    cnt += math.ceil((a+cnt)/b)*b-(a+cnt)
print(cnt)

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

int n,ji,cnt;
long long ans,a[100010],b[100010],res;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	b[1]=2;
	for(int i=2;i<=n;++i)
	b[i]=-b[i-1];
	b[1]=1;
	if(b[n]==2)
	b[n]=1;
	else
	b[n]=-1;
	sort(b+1,b+n+1);
	for(int i=1;i<=n;++i)
	{
		ans+=a[i]*b[i];
//		cout<<i<<" "<<a[i]<<" "<<b[i]<<endl;
	}
	b[1]=-2;
	for(int i=2;i<=n;++i)
	b[i]=-b[i-1];
	b[1]=-1;
	if(b[n]==2)
	b[n]=1;
	else
	b[n]=-1;
	sort(b+1,b+n+1);
	for(int i=1;i<=n;++i)
	{
		res+=a[i]*b[i];
//		cout<<i<<" "<<a[i]<<" "<<b[i]<<endl;
	}	
	printf("%lld\n",max(ans,res));	
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(int argc, const char * argv[]) {
    int count=0, i;
    char w[11], t[1001];
    scanf("%s", &w);
    for( i = 0 ; i < strlen(w) ; i++ ){
        w[i] = tolower(w[i]);
    }
    while(1){
        scanf("%s", &t);
        if( strcmp("END_OF_TEXT",t) == 0 ){
            break;
        }
        for( i = 0 ; i < strlen(t) ; i++ ){
            t[i] = tolower(t[i]);
        }
        if( strcmp(t,w) == 0 ){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 552
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,m;
	cin>>n>>m;
	int s[n+1];
	for(int i=1;i<=n;i++) cin>>s[i];
	int sum=0;
	for(int i=1;i<=n;i++) {
		sum+=s[i];
	}
	double c;
	c=(double)sum/(double)((double)m*(double)4.0);
	int ans=0;
	for(int i=1;i<=n;i++) {
		if((double)s[i]>=c) {
			ans++;
		}
	}
	if(ans>=m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
s_given = list(input())
t_given = list(input())

s_len = len(s_given)
t_len = len(t_given)
s_sorted = sorted(s_given)
t_sorted = sorted(t_given, reverse=True)

for i in range(t_len):
    if s_sorted[i] < t_sorted[i]:
        print('Yes')
        break
    elif s_sorted[i] > t_sorted[i]:
        print('No')
        break

    #s_sortedとt_sortedが同一の場合にNoと出力するため、この順序でifとelifを書く
    if i == t_len - 1:
        print('No')
        break
    elif i == s_len - 1 :
        print('Yes')
        break


Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

long long a,b,x;
long long s,e;

int main() {
	scanf("%lld %lld %lld",&a,&b,&x);
	s = (a + (a % x == 0 ? 0 : x)) / x;
	e = b / x;
	printf("%lld",e - s + 1);
	return 0;
}

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

using namespace std;
//fold
#define ll long long
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define Loop(i, a, b) for(int i = a ; i < b ; ++i)
#define loop(i, n) Loop(i, 0, n)
#define ff first
#define ss second
#define mkp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vvii vector<vii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define vvll vector<vll>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define INF 1e18+5
#define inf 1e8+5
#define M 1000000007 //check
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

template <typename T> T max(T a, T b, T c){ return max(a, max(b, c));}
template <typename T> T min(T a, T b, T c){ return min(a, min(b, c));}
//endfold
int n;
double eps = 1e-10;
vector<pair<double, double>> points;
vector<pair<double, double>> d;
double val(double t)
{
	double mxx = -INF, mnx = INF, mxy = -INF, mny = INF;
	loop(i, n)
	{
		mxx = max(mxx, points[i].ff + d[i].ff *t);
		mnx = min(mnx, points[i].ff + d[i].ff *t);
		mxy = max(mxy, points[i].ss + d[i].ss *t);
		mny = min(mny, points[i].ss + d[i].ss *t);
	}
	return (mxx-mnx)*(mxy-mny);
}
double tsearch(double low, double high)
{
	double ans = INF;
	int cnt = 0;
	while(cnt < 1000)
	{
		double mid1 = low + (high-low)/double(3);
		double mid2 = high - (high-low)/double(3);
		double l = val(mid1), r = val(mid2);
		if(r < l) low = mid1+eps;
		else high = mid2-eps;
		ans = min(ans, l, r);
		cnt++;
	}
	return ans;
}
int main() {
	_69e27;

	cin >> n;
	points.resize(n);
	d.resize(n, mkp(0, 0));
	loop(i, n)
	{
		cin >> points[i].ff >> points[i].ss;
		char in;
		cin >> in;
		if(in == 'L') d[i].ff = -1;
		if(in == 'R') d[i].ff = 1;
		if(in == 'U') d[i].ss = 1;
		if(in == 'D') d[i].ss = -1;
	}
	cout << fixed << setprecision(10) << tsearch(0, inf);
	return 0;
}

Measured memory_bytes: 3328
N = int(input())
A = []
for i in input().split():
	A.append(int(i))
B = []
diff = []
Ind = 0
zero_or_positive_diff = []
negative_diff = []
for i in input().split():
	b = int(i)
	B.append(b)
	d = A[Ind] - b
	diff.append(d)
	if d >= 0:
		zero_or_positive_diff.append(d)
	else:
		negative_diff.append(d)
	Ind += 1

zero_or_positive_diff.sort()
zero_or_positive_diff.reverse()
sum_negative_diff = sum(negative_diff)

if sum(A) < sum(B):
	print(-1)
	exit()

Ind = 0
part_sum_zero_or_positive_diff = 0
while part_sum_zero_or_positive_diff + sum_negative_diff < 0:
	sum_negative_diff += zero_or_positive_diff[Ind]
	Ind += 1

print(Ind+len(negative_diff))


Measured memory_bytes: 24300
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    vector<int> v(n, -1), b(n);
    v.front() = 0;
    queue<int> Q;
    Q.emplace(0);
    while(!Q.empty()){
        int x = Q.front(); Q.pop();
        for (auto &&i : G[x]) {
            if(!~v[i]){
                v[i] = v[x]+1;
                Q.emplace(i);
                b[i] = x;
            }
        }
    }
    puts("Yes");
    for (int i = 1; i < n; ++i) {
        cout << b[i]+1 << "\n";
    }
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll num(ll a){
    if(a == 1){
        return 2;
    }
    if(a == 2){
        return 5;
    }
    if(a == 3){
        return 5;
    }
    if(a == 4){
        return 4;
    }
    if(a == 5){
        return 5;
    }
    if(a == 6){
        return 6;
    }
    if(a == 7){
        return 3;
    }
    if(a == 8){
        return 7;
    }
    if(a == 9){
        return 6;
    }
    else{
        return INF;
    }
}
int main()
{
    cout << fixed << setprecision(15);

    ll N, M;
    cin >> N >> M;

    vector<ll> A(M);

    REP(i, N){
        cin >> A[i];
    }
    
    vector<ll> dp(N+1, -INF);
    dp[0] = 0;

    for(ll i=1; i<=N; i++){
        ll t_max = -INF;
        REP(j, M){
            if(i-num(A[j]) < 0) continue;
            t_max = max(t_max, dp[i-num(A[j])] + 1); 
        }
        dp[i] = t_max;
    }

    ll digit = dp[N];


    sort(A.begin(), A.end(), greater<int>());

    REP(i, digit){
        for(auto v: A){
            if(N - num(v) < 0) continue;
            if(dp[N - num(v)] == dp[N]-1){
                // cout << "N:" <<  N << endl;
                cout << v;
                N = N - num(v);
                break;
            }
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
struct aa{
	int root;
	int from;
	int data;
	long long int time;
};
typedef int Weight;
map < pair<int, int>, vector<int>>longs;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src_, int dst_, Weight weight_) :
		src(src_), dst(dst_), weight(weight_) { }
	Edge(int src_, int dst_) :
		src(src_), dst(dst_) {
	}
};
class Compare {
public:
	//aa?????????????????¶
	bool operator()(const aa&l, const aa&r) {
		return l.time< r.time;
	}
};
vector<int>datas;
vector<vector<Edge>>edges;
pair<long long int, vector<int>> dfs(const int now, const int from) {
	long long int amax=0;
	vector<int>max_vs;
	for (auto e : edges[now]) {
		if (e.dst == from)continue;
		auto p(dfs(e.dst, e.src));
		if (amax < p.first+e.weight) {
			amax = p.first+e.weight;
			max_vs = p.second;
		}
	}
	max_vs.emplace_back(now);
	return make_pair(amax, max_vs);
}
priority_queue<aa, vector<aa>, Compare>que;
void dfs2(const int now, const int from,const vector<int>&max_vs, int& depth, priority_queue<aa, vector<aa>, Compare>&que,const int data_id) {
	
	for (auto e : edges[now]) {
		if (e.dst == from)continue;
		if (e.dst == max_vs[depth + 1]) {
			depth++;
			dfs2(e.dst, e.src, max_vs,depth,que,data_id);
			depth--;
		}
		else {
			auto p=dfs(e.dst, e.src);
			reverse(p.second.begin(), p.second.end());
			if (longs.find(make_pair(e.dst, e.src)) == longs.end()) {
				longs[make_pair(e.dst, e.src)] = p.second;
			}
			que.push(aa{ e.dst,e.src,data_id,(p.first+e.weight)*datas[data_id] });
		}
	}
	return ;
}
int main() {
	int N, M; cin >> N >> M;
	edges.resize(N);
	for (int i = 0; i < N-1; ++i) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		edges[a].push_back(Edge(a, b, c));
		edges[b].push_back(Edge(b, a, c));
	}
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		datas.emplace_back(a);
	}
	for (int i = 0; i < N; ++i) {
		auto p(dfs(i, -1));
		reverse(p.second.begin(), p.second.end());
		if (longs.find(make_pair(i, -1)) == longs.end()) {
			longs[make_pair(i, -1)] = p.second;
		}
		que.push(aa{ i,-1,i,p.first*datas[i] });
	}
	long long int ans = 0;
	while (!que.empty()) {
		if (!M)break;
		M--;
		aa atop(que.top());
		que.pop();
		ans += atop.time;
		int d = 0;
		dfs2(atop.root, atop.from, longs[make_pair(atop.root,atop.from)],d, que, atop.data);

	}
	cout << ans << endl;
	return 0;
}

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

int main(void){
  int i,N; cin >> N;
  vector<int> A(N);
  for(i=0; i<N; ++i) cin >> A[i];
  
  long long score=0;
  int sum=0, left, right=0;
  for(left=0; left<N; ++left){
    while(right<N && (sum+A[right])==(sum^A[right])) sum^=A[right++];
    score += (right-left);
    if(right==left) ++right; else sum^=A[left];
  }
  cout << score << endl;
  return 0;
}


Measured memory_bytes: 4028
object Main {
  val days = List("SUN", "MON" ,"TUE", "WED", "THU", "FRI", "SAT")
  def main(args: Array[String]): Unit = {
    val result = solve(io.Source.stdin.getLines().toList.head)
    println(result)
  }
  def solve(s: String): Int = {
    7 - days.indexOf(s)
  }
}

Measured memory_bytes: 27336
import java.awt.geom.Point2D;
import java.util.*;


public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ_GRL_2();
	}

	class AOJ_GRL_2{
		int cost[][]; //コスト
		int d[];//使用済み頂点群からの最短距離
		boolean used[];//既に使用されたかのフラグ
		int V;//頂点数
		int INF;
		int cnt;//答え
		void Prim(int s){//任意の頂点
			d = new int[V];
			used = new boolean[V];
			INF = Integer.MAX_VALUE;
			Arrays.fill(used, false);
			Arrays.fill(d,INF);
			d[s] = 0;
			cnt = 0;
			while(true){
				int v=-1;
				for(int u=0;u<V;u++){//まだ使われていない頂点のうち最小のものを探す
					if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
				}
				if(v==-1)break;
				used[v]=true;
				
				int a = d[v]/100;
				if(a>0)a--;
				cnt+=a;
				
				for(int k=0;k<V;k++)if(!used[k]&&cost[v][k]!=0){
					d[k] = Math.min(cost[v][k], d[k]);
				}
			}
		}

		public AOJ_GRL_2() {
			while(true){
				V = in.nextInt();
				cost = new int[V][V];
				if(V==0)break;
				int n = in.nextInt();
				for(int i=0;i<n;i++){
					String input[] = in.next().split(",");
					int a = Integer.parseInt(input[0]);
					int b = Integer.parseInt(input[1]);
					int c = Integer.parseInt(input[2]);
					cost[a][b] = c;
					cost[b][a] = c;
				}
				Prim(0);
				System.out.println(cnt);
			}
		}
	}

}

Measured memory_bytes: 32928
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  int ans = x;
  REP(i, n) {
    int a;
    cin >> a;
    ans += (d + a - 1) / a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner s  = new Scanner(System.in);
        String str = s.nextLine();
        String up  = str.toUpperCase();
        String low = str.toLowerCase();
        int i;
        for(i=0;i<str.length();i++){
            if(str.charAt(i)==up.charAt(i))System.out.print(low.charAt(i));
            else System.out.print(up.charAt(i));
        }
        System.out.println();
    }
}


Measured memory_bytes: 27172
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int v = scanner.nextInt();
		int p = scanner.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextInt();
		}
		scanner.close();
		Arrays.parallelSort(a);

		int min = p;
		int sup = n + 1;
		int mid;
		while (sup - min > 1) {
			mid = (min + sup) / 2;
			if (canBeChosen(mid, n, m, v, p, a)) {
				min = mid;
			} else {
				sup = mid;
			}
		}

		System.out.println(min);
	}

	static boolean canBeChosen(int k, int n, int m, int v, int p, int[] a) {
		int threshold = a[n - k] + m;
		if (threshold < a[n - p]) {
			return false;
		}
		int remain = v - (n - k + p);
		if (remain <= 0) {
			return true;
		}
		long canVote = 0;
		for (int i = p; i < k; i++) {
			canVote += threshold - a[n - i];
		}
		return canVote >= (long) remain * m;

	}
}


Measured memory_bytes: 52916
import java.util.Scanner;
public class Main {
    public static void main(String[] args){

        Scanner scanner = new Scanner(System.in);
        int a1 = scanner.nextInt();
        int a2 = scanner.nextInt();
        int a3 = scanner.nextInt();
        if(a1 +a2 +a3 >=22)

        {
            System.out.print("bust");
        } else

        {
            System.out.print("win");
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<array>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
  int n,i;
  cin >> n;
  vector<int> a(n);
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for(i=0;a[i]*2<a[n-1];i++);
  if(a[n-1]-a[i-1]*2<=a[i]*2-a[n-1]) i--;
  printf("%d %d\n",a[n-1],a[i]);
}

Measured memory_bytes: 640
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 998244353
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	string s, t;
	cin >> s >> t;
	int kotae = 0;
	rip(i, 3)if (s[i] == t[i])kotae++;
	cout << kotae << endl;
}
int main() {
	solve();
}

Measured memory_bytes: 256
import sys
from fractions import gcd
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
class SegTree:
  def segfunc(self, x, y):
    return gcd(x, y) #ここ判定関数（ただし結合則があるもの）
  def __init__(self, n, ide_ele, init_val):
    #####単位元######
    self.ide_ele = ide_ele
    #num:n以上の最小の2のべき乗
    self.num = 2 ** (n - 1).bit_length()
    self.seg = [self.ide_ele] * 2 * self.num
    #set_val
    for i in range(n):
      self.seg[i + self.num - 1] = init_val[i]    
    #built
    for i in range(self.num - 2, -1, -1) :
      self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) 
  def update(self, k, x):
    k += self.num - 1
    self.seg[k] = x
    while k + 1:
      k = (k - 1) // 2
      self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) 
  def query(self, p, q):
    if q <= p:
      return self.ide_ele
    p += self.num - 1
    q += self.num - 2
    res = self.ide_ele
    while q - p > 1:
      if p & 1 == 0:
        res = self.segfunc(res, self.seg[p])
      if q & 1 == 1:
        res = self.segfunc(res, self.seg[q])
        q -= 1
      p = p // 2
      q = (q - 1) // 2
    if p == q:
      res = self.segfunc(res, self.seg[p])
    else:
      res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
    return res
seg = SegTree(N, 0, a)
res = 0
for i in range(N):
  res = max(res, gcd(seg.query(0, i), seg.query(i + 1, N)))
  #print(seg.query(0, i), seg.query(i + 1, N))
print(res)

Measured memory_bytes: 87776
def resolve():
    MOD = 10 ** 9 + 7
    N, K = map(int, input().split())
    ans = 0
    for k in range(K, N + 2):
        min_num = k * (k - 1) // 2
        max_num = k * (N * 2 - k + 1) // 2
        add = max_num - min_num + 1
        ans = (ans + add) % MOD
    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9136
n = int(input())
s = [[0 for i in range(n + 1)] for j in range(n + 1)]

for r in range(n):
    inp = list(map(int, input().split()))
    for c in range(n):
        s[r + 1][c + 1] = inp[c] + s[r][c + 1]

ans = -10001

for r_end in range(1, n + 1):
    for r_start in range(r_end):
        dp = [-10001]
        for c in range(1, n + 1):
            s_tmp = s[r_end][c] - s[r_start][c]
            dp.append(max(dp[c - 1] + s_tmp, s_tmp))
        ans = max(ans, max(dp))
print(ans)



Measured memory_bytes: 6020
// https://atcoder.jp/contests/dp/tasks/dp_n

#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mp make_pair
#define mod 1000000007
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
void init() {
  int n;
  cin >> n;
  vector<int> slimes(n);
  for (int &i : slimes)
    cin >> i;
  vector<vector<int>> dp(n, vector<int>(n));
  vector<int> pref(n);
  pref[0] = slimes[0];
  for (int i = 1; i < n; i++)
    pref[i] = pref[i - 1] + slimes[i];
  // dp[l][r] - min cost occured while merging [l,r]
  auto sum = [&](int L, int R) {
    if (L == 0)
      return pref[R];
    else
      return pref[R] - pref[L - 1];
  };
  for (int l = n - 1; l >= 0; l--) {
    for (int r = l; r < n; r++) {
      if (l == r)
        dp[l][r] = 0;
      else {
        int s = sum(l, r);
        dp[l][r] = 1e18;
        for (int k = l; k < r; k++) {
          dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + s);
        }
      }
    }
  }
  cout << dp[0][n - 1] << endl;
}
int32_t main() {
  IOS;
  init();
  return 0;
}


Measured memory_bytes: 4496
import copy
n = int(input())
X = list(map(int, input().split()))
x = X.copy()
X.sort()
m_s = X[n//2 - 1]
m_l = X[n//2]
for i in x:
    if i <= m_s:
        print(m_l)
    else:
        print(m_s)

Measured memory_bytes: 104304
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  double r;
  cin >> r;
  cout << 2 * r * 3.14159265 << '\n';
  return 0;
}

Measured memory_bytes: 3788
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        List<int>[] neighbors;
        int[] values;

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var s = cin.ReadStrArray(N);
            for (int i = 0; i < N; i++)
            {
                var chars = s[i].ToCharArray();
                Array.Sort(chars);
                s[i] = new string(chars);
            }
            var count = new Dictionary<string, long>();
            for (int i = 0; i < N; i++)
            {
                if (count.ContainsKey(s[i]))
                {
                    count[s[i]]++;
                }
                else
                {
                    count[s[i]] = 1;
                }
            }
            long ans = 0;
            foreach (var val in count.Values)
            {
                ans += val * (val - 1) / 2;
            }
            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 35140
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MAXX 1000000000000000000

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll i,j,x,y,n, fre[2019]={0}, ans=0;
	string s;
	cin >> s;
	x = 1;
	y = 0;
	n = s.length();
	for(i=n-1;i>=0;i--)
	{
		y += x*(s[i]-'0');
		y %= 2019;
		x *= 10;
		x %= 2019;
		fre[y]++;
	}
// 	cout<<y<<endl;
	ans = (fre[0]*(fre[0]+1))/2;
	for(i=1;i<2019;i++)
	{
		ans += (fre[i]*(fre[i]-1))/2;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,w,k;cin >> h >> w >> k;
    int sy,sx,gy,gx;cin >> sy >> sx >> gy >> gx;sy--;gy--;sx--;gx--;
    vector<string> g(h);
    rep(i,h){
        cin >> g[i];
    }
    queue<pair<int,int>> que;
    que.push({sy,sx});
    vector<vector<int>> dist(h,vector<int>(w,inf));
    dist[sy][sx]=0;
    while(!que.empty()){
        pair<int,int> vv=que.front();que.pop();
        rep(i,4){
            pair<int,int> v=vv;
            int cnt=0;
            while(cnt<k){
                v.fi+=dy[i];v.se+=dx[i];
                if(v.fi<0||v.se<0||v.fi>=h||v.se>=w)break;
                if(g[v.fi][v.se]=='@')break;
                if(dist[v.fi][v.se]>=dist[vv.fi][vv.se]+1){
                    if(chmin(dist[v.fi][v.se],dist[vv.fi][vv.se]+1)){
                        que.push({v.fi,v.se});
                    }
                }
                else break;
                cnt++;
            }
        }
    }
    if(dist[gy][gx]!=inf)cout << dist[gy][gx] <<endl;
    else cout << -1 <<endl;
} 

Measured memory_bytes: 12056