akhauriyash/Code-Regression huggingface dataset:
import math
import itertools

INF = 10**9+7

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

def solve(x):
	global s
	cost = 0
	debt = 0
	y = [1,-1]
	for i in range(len(s)):
		c = s[i]*x + debt
		if(y[i%2]!=sgn(c)):
			cost += abs(y[i%2]-c)
			debt += y[i%2]-c
	return cost

def sgn(n):
	if(n>0): return 1
	if(n<0): return -1
	return 0

print(min(solve(-1),solve(1)))

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string s;
	cin >> s;

	bool bad = false;
	for (int ii = 0; ii < 3; ++ii){
		if (s[ii] == s[ii+1] ){
			bad = true;
			break;
		}
	}

	if (bad){
		cout << "Bad" << endl;
	} else {
		cout << "Good" << endl;

	}

	return 0;
}


Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,k=map(int,readline().split())
    a=list(map(int,readline().split()))

    d=dict()
    for i in range(n):
        if a[i] not in d:
            d[a[i]]=1
        else:
            d[a[i]]+=1

    d=list(d.items())
    d.sort(key=lambda x:x[1])
    res=0
    for i in range(len(d)-k):
        res+=d[i][1]

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

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

typedef pair<int,int> P;

int R,C;
string S[129];
int dp[2][(1<<16)];

int getcost(int x,int y,int bt,int txc,int tyc){
  int ret = 0;
  if( bt&1 ) {
    if( (int)S[y].size() <= txc ) return -100000000;
    if(y>0){
      if( (bt & (1<<C)) ){
        int ind = (int)S[y-1].size() - tyc;
        if( S[y][txc] == S[y-1][ind] ) {
          ret += 2;
        }
      }
    }
    if(txc>0 && (bt&2) ){
      if( S[y][txc] == S[y][txc-1] ) {
        ret += 2;
      }
    }
  }

  //  cout << x << " "<< y << " "<< txc<< " " <<tyc <<" "<< endl;
  //cout << bitset<17>(bt) << endl;
  //cout << ret << endl;
  return ret; 
}

int main(){
  cin >> R >> C;
  for(int i=0;i<R;i++) cin >> S[i];

  memset(dp,-1,sizeof(dp));
  dp[0][0] = 0;
  for(int y=0;y<R;y++){
    int size = (int)S[y].size();
    for(int x=0;x<C;x++){
      int now = (C*y+x)&1;
      int nex = 1-now;
      memset(dp[nex],-1,sizeof(dp[nex]));
      for(int i=0;i<(1<<C);i++){
        int nc = dp[now][i];
        if(nc < 0 ) continue;
        int prx = (i & ((1<<x)-1) );
        int pry = (i & (~((1<<x)-1)) );
        int txc = __builtin_popcount(prx);
        int tyc = __builtin_popcount(pry);
        if( txc > size ) continue;
        if( y>0 &&  x==0 && (int)S[y-1].size() != tyc ) continue;
        if( y>0 && (int)S[y-1].size() - tyc < 0 ) continue;
        int nbt = (i<<1);
        nbt &= ((1<<C)-1);
        if( x - txc < C-size )
          dp[nex][nbt] = max( dp[nex][nbt], nc );
        int nxc = getcost(x,y,(i<<1)|1,txc,tyc);
        dp[nex][nbt|1] = max( dp[nex][nbt|1], nc + nxc );
      }
    }
  }

  int res = 0;
  for(int i=0;i<(1<<C);i++){
    int now = (C*R)&1;
    int tyc = __builtin_popcount(i);
    if((int)S[R-1].size() != tyc ) continue;
    res = max( res, dp[now][i] );
 }
  cout << res << endl;

}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int main()
{
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
    	if(s[i]=='C')
    	{
    		n=1;
    	}
    	if(s[i]=='F'&&n==1)
    	{
    		puts("Yes");
    		return 0;
    	}
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
count = 0
ans = False
for __ in range(int(input())):
    a, b = map(int, input().split())
    if a == b:
        count += 1
    else:
        count = 0
    if count == 3:
        ans = True
        break

if ans:
    print("Yes")
else:
    print("No")

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

int main(){
    int a;
    char k [101];
    scanf("%d", &a);
    scanf("%s", k);
    int len = strlen(k);
    if (len <= a) {
        printf("%s\n", k);
    }
    else{
        for(int i=0; i < a; i++){
            printf("%c",k[i]);

        }
        puts("...\n");
    }
    
    return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T;
	cin >> T;
	string s;
	cin >> s;
	int arr[200] = {0};
	for (auto i : s)
	{
		arr[i]++;
	}
	int cnt[200] = {0};
	for(int i = 0; i<arr['R'];i++)
	{
		cnt[s[i]]++;
	}
	cout <<arr['R'] - cnt['R']<<endl;
}


Measured memory_bytes: 3760
#include<stdio.h>
int main (void) {
  int n=1;
  int m=1;
  for (n=1;n<10;n++)
    {
    for (m=1;m<10;m++)
      {
        printf ("%dx%d=%d\n",n,m,n*m);
      }
    }
  return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; ++i) {
        cin >> a[i];

    }
    sort(a, a + n, greater<>());
    int s = 0;
    for(int i = 0; i < k; ++i) {
        s += a[i];

    }
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c;
  cin>>a>>b>>c;
  int an=a.size();
  int bn=b.size();
  int cn=c.size();
  if(a[an-1]==b[0]&&b[bn-1]==c[0])cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

class SegTree{
public:
  int N;
  vector<ll> dat;
  ll MIN = 0LL;

  //コンストラクタ
  SegTree(int n){
    N = 1;
    while(N < n) N *= 2;
    for(int i = 0; i < 2 * N - 1; i++){
      dat.push_back(MIN);
    }
  }

  //k番目の値(0_indexed)をaに変更
  void update(int k, ll a){
    //葉の節点
    k += N - 1;
    dat[k] = a;
    //登りながら更新
    while(k > 0){
      k = (k - 1) / 2;
      dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  //[a,b)の最小値
  ll query(int a, int b){
    return Query(a, b, 0, 0, N);
  }

  ll Query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return MIN;
    if(a <= l && r <= b) return dat[k];
    else{
      ll v1 = Query(a, b, k * 2 + 1, l, (l + r) / 2);
      ll v2 = Query(a, b, k * 2 + 2, (l + r) / 2, r);
      return max(v1, v2);
    }
  }
};

int main(){
  int N;
  cin >> N;
  int h[N];
  ll a[N];
  for(int i = 0; i < N; i++) cin >> h[i];
  for(int i = 0; i < N; i++) cin >> a[i];
  int max_h = *max_element(h, h + N);

  SegTree sg = SegTree(max_h + 1);

  for(int i = 0; i < N; i++){
    ll mx = sg.query(0, h[i]);
    sg.update(h[i], mx + a[i]);
  }

  cout << sg.query(0, max_h + 1) << endl;
  return 0;
}


Measured memory_bytes: 8816
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque


def main():
    nun, waribiki_num = map(int, input().split())
    data = list(map(int, input().split()))

    aaa = []

    for i in range(nun):
        heapq.heappush(aaa, -data[i])

    for i in range(waribiki_num):
        b = heapq.heappop(aaa)
        c = (-1 * b) // 2
        # print(c)
        heapq.heappush(aaa, -c)
    # print(aaa)

    ans = -sum(aaa)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65044
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(void){
	string s;
	cin >> s;
	int count = 0;
	string cf = "CODEFESTIVAL2016";
	for(int i=0;i<s.length();i++){
		if(s.at(i) != cf.at(i)){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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 (b < a) { a = b; return 1; } return 0; }




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


int main(){

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

    vll SA(N + 1), SB(M + 1);
    REP(i, N){
        cin >> SA[i + 1]; SA[i + 1] += SA[i];
    }
    REP(i, M){
        cin >> SB[i + 1]; SB[i + 1] += SB[i];
    }

    ll mx = 0;
    REP(i, N + 1){
        ll rem = K - SA[i];
        if (rem < 0) break;

        ll n = upper_bound(ALL(SB), rem) - SB.begin();
        chmax(mx, i + n - 1);
    }

    cout << mx << endl;
    

    return 0;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()
{

    ll luc[90];
    mset(luc,0);
    luc[0]=2, luc[1]=1;
    for(ll i = 2; i < 90; i++) luc[i] = luc[i-1]+luc[i-2];
    ll n;
    cin >> n;
    cout << luc[n];
}


Measured memory_bytes: 256
get_string(String) :-
  current_input(Input),
  read_string(Input, ' \n', '', _, String).

get_number(Number) :-
  get_string(String),
  number_string(Number, String).

solve(K, A) :-
  nth1(K, [1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692], A).

main :-
  get_number(K),
  solve(K, A),
  write(A).

Measured memory_bytes: 8104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    while(N > 0){
        if(N%10 == 7){
            cout << "Yes" << endl;
            return 0;
        }
        N /= 10;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>

using namespace std;

vector<int> G[200000];
int cnta[200000], cntb[200000];
bool deleted[200000];
string S;

void del(int v){
    deleted[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        if(S[v] == 'A'){
            cnta[G[v][i]]--;
            if(cnta[G[v][i]] == 0 && !deleted[G[v][i]]) del(G[v][i]);
        }else{
            cntb[G[v][i]]--;
            if(cntb[G[v][i]] == 0 && !deleted[G[v][i]]) del(G[v][i]);
        }
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    cin >> S;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(a != b){
            G[a].push_back(b);
            G[b].push_back(a);
            if(S[a] == 'A'){
                cnta[b]++;
            }else{
                cntb[b]++;
            }
            if(S[b] == 'A'){
                cnta[a]++;
            }else{
                cntb[a]++;
            }
        }else{
            G[a].push_back(a);
            if(S[a] == 'A'){
                cnta[a]++;
            }else{
                cntb[a]++;
            }
        }
    }
    for(int i = 0; i < N; i++){
        if((cnta[i] == 0 || cntb[i] == 0) && !deleted[i]) del(i);
    }
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(!deleted[i]) cnt++;
    }
    //cout << cnt << endl;
    if(cnt != 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 15492
import sys
input = sys.stdin.readline
INF = 10**18
sys.setrecursionlimit(10**6)


def li():
    return [int(x) for x in input().split()]


N, X, MOD = li()


n = X
nums = [X]
loop_start_i = -INF
for i in range(1, N):
    n = pow(n, 2, MOD)
    if n in nums:
        loop_start_i = nums.index(n)
        break
    nums.append(n)
# total %= MOD
loop_length = len(nums) - loop_start_i
loop_cnt = (N - loop_start_i) // loop_length
r = (N - loop_start_i) % loop_length
sum_per_loop = sum(nums[loop_start_i:])
ans = sum(nums[:loop_start_i]) + sum_per_loop * loop_cnt + sum(nums[loop_start_i:loop_start_i+r])
print(ans)

Measured memory_bytes: 68348
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<usize>();
    let _n = input[0];
    let m = input[1];
    let a = read_vec::<usize>();

    let sum: usize = a.iter().sum();



    let mut count = 0;
    for ai in a {
        if (ai as f64) / (sum as f64) >= 1f64 / 4f64 / (m as f64) {
            count += 1;
        }
    }

    if count < m {
        println!("No");
    } else {
        println!("Yes");
    }

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
#define mod 1000000007
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    ll N,K;
    cin>>N>>K;
    vint A(N),ans(N),ans2(N);
 //   vvint B(K,vint(N));
    rep(i,N)
    {
        cin>>A[i];
    }
    rep(i,N)
    {
        int a = A[i];
        rep(j,N)
        {
            if(a > A[j])
            {
                ans[i]++;
                if(j>i)
                {
                    ans2[i]++;
                }
            }
        }
    }
    ll sum1 = 0;
    ll sum2 = 0;
    rep(i,N)
    {
        sum1 = (sum1 + (ll)ans[i])%mod;
        sum2 = (sum2 + (ll)ans2[i])%mod;
    }
    ll res;
    if(K%2 == 0)
    {
        res = ((K%mod)*sum2 + ((K/2)%mod)*(K-1)%mod * sum1) % mod;
    }
    else res = ((K%mod)*sum2 + (((K-1)/2)%mod)*(K)%mod * sum1) % mod;
    cout<<res;
    return 0;
}

Measured memory_bytes: 256
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

n=int(input())
ans=[0]*n
k=0
i=2
while k<n-1:
    if i%2==0 or i%3==0:
        ans[k]=i
        k+=1
    i+=1
x=sum(ans)
ans[-1]=30000+x//6*6-x
while gcd(ans[-1],x)==1:
    ans[-1]-=6
print(*ans)

Measured memory_bytes: 4556
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int n;
    cin >> n;
    vector<int64> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    int64 money = 1000;
    int begin = 0;
    for (int i=0; i<n-1; i++) {
        if (a[i] <= a[i+1])
            continue;

        int64 stock = money/a[begin];
        money -= a[begin] * stock;
        money += a[i] * stock;
        begin = i+1;
    }
    if (a[begin]<a[n-1]) {
        int64 stock = money/a[begin];
        money -= a[begin] * stock;
        money += a[n-1] * stock;
    }
    cout << money << endl;
}


Measured memory_bytes: 3188
#include<iostream>
#include<string>

using namespace std;

int32_t get_num_32(void){
    int32_t x;
    scanf("%d",&x);
    return x;
}


int main(void){
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    int H,W;
    H = get_num_32();
    W = get_num_32();
    string a;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin >> a;
            //cout << a << endl;
            if(a == "snuke"){
                cout << (char)(j+'@') << i << "\n";
                return 0;
            }
        }
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define int long long 

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
  ソートしておいしさが大きい方からK個選ぶ
  選んだK個のうち種類数が減らなくておいしさが最も小さいものと
  選ばれたないもののうち種類数が増えおいしさが最大のものを交換してみる
  繰り返し
*/

signed main()
{
  int n, k;
  cin >> n >> k;
  
  vector<pii> a;
  rep(i, n){
    int t, d;
    cin >> t >> d;
    a.pb(mp(d, t));
  }

  sort(all(a));
  reverse(all(a));
  
  int dsum = 0, num = 0;
  map<int, int> cnt;
  stack<int> st;
  rep(i, k){
    dsum += a[i].first;
    if(cnt[a[i].second] == 0) num++;
    else st.push(i);
    cnt[a[i].second]++;
  }

  int ans = dsum + num*num;
  repi(i, k, n){
    if(st.size() == 0) break;
    if(cnt[a[i].second] == 0){
      dsum = dsum-a[st.top()].first+a[i].first;
      st.pop();
      num++;
      cnt[a[i].second]++;
      ans = max(ans, dsum + num*num);
    }
  }

  cout << ans << endl;

  
  return 0;
}


Measured memory_bytes: 6000
#include <stdio.h>

#define N 100000

int main() {
	static char s[3], ac[N + 1];
	static int kk[N + 1];
	int n, m, p, a, b;

	scanf("%d%d", &n, &m);
	a = b = 0;
	while (m--) {
		scanf("%d%s", &p, s);
		if (!ac[p] && s[0] == 'A')
			a++, b += kk[p], ac[p] = 1;
		else if (s[0] == 'W')
			kk[p]++;
	}
	printf("%d %d\n", a, b);
	return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
	int [] ans_ar; 
	public static void main(String[] args) {
		new Thread(null, new Main(), "", 32 * 1024 * 1024).start(); //
	}
	public void run() {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());
		String str = sc.next();
		char[] c = str.toCharArray();
		int[] ar = new int[n];
		int tmp = 0;
		ar[0] = 0;
		for (int i = 1; i < n; i++) {
			if(c[i-1] == 'A' && c[i]=='C')
			{
				tmp++;
			}
			ar[i] = tmp;
		}
		for (int i = 0; i < q; i++) {
			
			int l = Integer.parseInt(sc.next())-1;
			int r = Integer.parseInt(sc.next())-1;
			out.println(ar[r]-ar[l]);
		}

		//out.println(ans);
		out.flush();
	}


    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
    }
}

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


int main(void) {

	int n;
	int a, b;
	int sum;

	scanf("%d", &n);

	if (n == 1) {
		printf("Hello World\n");
		return 0;
	}
	else {
		scanf("%d%d", &a, &b);
		sum = a + b;
		printf("%d", sum);		
	}


	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	int n,ans=0,sum=0;
	scanf("%d",&n);
	string str;
	cin >> str;
	for(int i=0;i<str.size();i++) {
		if(str[i] == 'I') {
			ans ++;
		}
		sum = max(sum,ans);
		if(str[i] == 'D') {
			ans --;
		}
	}
	printf("%d",sum);
	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<long long> A(N);
  vector<int> A1(N-1,0);
  for (int i = 0; i<N; i++) cin >> A[i];
  for (int i = 0; i<N-1; i++) {
    if(A[i+1]>A[i]) A1[i] = 1;
    else if(A[i+1]<A[i]) A1[i] = -1;
  }
  int cnt = 1, sign = 0;
  for (int i = 0; i<N-1; i++) {
    if(A1[i]==0);
    else if(A1[i]==1) {
      if(sign==0) sign=1;
      else if(sign==-1){
        cnt++;
        sign = 0;
      }
    }
    else if(A1[i]==-1) {
      if(sign==0) sign=-1;
      else if(sign==1){
        cnt++;
        sign = 0;
      }
    }
  }
  cout << cnt << "\n";
}

Measured memory_bytes: 1408
#include<iostream>
#include <vector>

using namespace std;

int main()
{
    
    vector<int> vec;
    int N; cin >> N;
    
    for(int i = 0; i < N; ++i)
    {
      int Command;
      cin >> Command;
      
      if(Command == 0)
      {
          int val;
          cin >> val;
          vec.push_back(val);
      }
      else if(Command == 1)
      {
          int val;
          cin >> val;
          cout << vec[val] << endl;
      }
      else 
      {
          vec.pop_back();
      }
      
        
    }
    
    return 0;
}


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

const int MOD = 1e9 + 7;
int N, K;
unordered_map<int, long long> cache;

long long exp_mod(int a, int b, int m) {  // return a^b mod m
    long long ans = 1;
    long long tmp = a;
    while (b) {
        if (b & 1) {
            ans = (ans * tmp) % m;
        }
        b >>= 1;
        tmp = (tmp * tmp) % m;
    }
    return ans;
}

long long inv(int a, int m) {  // return a-1
    return exp_mod(a, m - 2, m);
}

long long ncr_mod(int n, int r, int m) {  // return nCr mod m
    if (n == N) {
        return cache[r];
    } else if (n == N - 1) {
        return (cache[r] * (N - r) % MOD) * inv(N, MOD) % MOD;
    }
    long long ret = 1;
    for (int i = 0; i < r; ++i) {
        ret = (ret * (n - i)) % m;
        ret = (ret * inv(1 + i, m)) % m;
    }
    return ret;
}

long long nhr_mod(int n, int r, int m) {  // return nHr mod m
    return ncr_mod(n + r - 1, r, m);
}

void preprocess() {  // preprocess NC1, NC2, ... NCN
    for (int i = 1; i <= N; ++i) {
        if (i == 1) {
            cache[i] = N;
        } else {
            cache[i] = (cache[i - 1] * (N - i + 1) % MOD) * inv(i, MOD) % MOD;
        }
    }
}

int main() {
    cin >> N >> K;
    preprocess();
    long long ans = nhr_mod(N, N, MOD);
    for (int i = K + 1; i < N; ++i) {
        ans = (ans - ncr_mod(N, i, MOD) * nhr_mod(N - i, i, MOD) % MOD + MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int a,b,k;
    cin >> a >> b >> k;
    int x[100];
    int cnt = 0;
    for(int i = 1; i <= 100; i++){
        if(a % i == 0 && b % i == 0){
            x[cnt] = i;
            cnt++;
        }
    }
    cout << x[cnt - k];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, k;
    cin >> n >> k;
    vint x(n);
    rep(i, n) cin >> x[i];

    int ans = 0;
    rep(i, n) {
        ans += min(x[i], abs(k-x[i]));
    }

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long d[101][100001],i,q,k,n,w[101],v[101];
int main()
{
  cin>>n>>k;
   for(i=1;i<=n;i++)
   {
       cin>>w[i]>>v[i];
   }
   d[1][w[1]]=v[1];
   for(i=2;i<=n;i++)
   {
       for(q=k;q>=0;q--)
       {
           d[i][q]=d[i-1][q];
           if(q-w[i]>=0)d[i][q]=max(d[i][q],d[i-1][q-w[i]]+v[i]);
       }
   }
   long long ans;
   for(q=0;q<=k;q++)
   {
       ans=max(ans,d[n][q]);
   }
   cout<<ans;
    return 0;
}


Measured memory_bytes: 77568
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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(){
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i,n) cin >> a[i];
	
	vector<ll> s(n+1);
	s[0] = 0;
	REP(i,n) s[i+1] = s[i]+a[i];
	map<ll,ll> m;
	REP(i,n+1){
		m[s[i]]++;
	}
	ll ans=0;
	for(auto x:m){
		ll k = x.second;
		ans += k*(k-1)/2;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 17844
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	int iFee1, iFee2, iTime, nDays;
	cin >> nDays >> iTime >> iFee1 >> iFee2;
	if (nDays <= iTime)
		cout << iFee1*nDays << endl;
	else
		cout << iFee1*iTime + iFee2*(nDays - iTime) << endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<long> data(N);
  long count = 0, ans = 0;
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
    if(data.at(i) < 0){
      count++;
      data.at(i) *= -1;
    }
    ans += data.at(i);
  }
  sort(data.begin(), data.end());
  if(count % 2 == 1)ans -= data.at(0) * 2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long a,b,s;
int main()
{
	scanf("%lld %lld",&a,&b);
	if(b%a==0)
	{
		s=a+b;
		printf("%lld",s);
	}
	else
	{
		s=b-a;
		printf("%lld",s);
	}
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    val N = readLine()!!.toLong()
    val input : MutableList<Long> = mutableListOf()
    repeat(5){
        input.add(readLine()!!.toLong())
    }

    var count: Long = 0L
    input.sort()
    if(N % input[0] == 0L){
        count +=  N / input[0]
        println(4L + count)
    }
    else{
        count += N / input[0]
        println(5L + count)
    }
}


Measured memory_bytes: 33648
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll=long long;

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,x,y,z,max1=0,ans,o0=0,o1=0;
    string s,t,u;
    cin>>s;
    for (ll i=0; i<s.size(); i++) {
        if (s[i]=='0') {
            o0++;
        }
        else o1++;
    }
    cout<<min(o1,o0)*2<<endl;
}



Measured memory_bytes: 512
(let ((s (concatenate 'list (read-line)))
      (lst '()))

  (loop for i in s
        if (char= i #\0) do (push "0" lst)
        else if (char= i #\1) do (push "1" lst)
        else do (pop lst))

  (format t "~a~%" (reverse (apply #'concatenate 'string lst))))


Measured memory_bytes: 10848
#include <bits/stdc++.h>
#define ll long long int
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main()
{
  IO;  
  int n; 
  cin >> n; 
  cout << 360/(__gcd(n,360)) <<endl;
  
return 0;
}



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

int n, k;
ll ans;

int main() {
    cin >> n >> k;
    for (int b = k + 1; b <= n; b++) {
        ans += (b - k) * (n / b) + max((n % b) - k + 1, 0);
        if (k == 0) ans--; // (0, b)
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s = [0] * h
inp = [[0] * (w+2) for _ in range(h+2)]
ans = [['#'] * w for _ in range(h)]
for i in range(h):
    s[i] = input()
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            inp[i+1][j+1] = 1

#print()
'''
for i in range(h+2):
    for j in range(w+2):
        print(inp[i][j], end="")
    print()
'''
#print()

for i in range(h):
    for j in range(w):
        if inp[i+1][j+1] == 0:
            ans[i][j] = str(inp[i][j] + inp[i][j+1] + inp[i][j+2] + inp[i+1][j] + inp[i+1][j+2] + inp[i+2][j] + inp[i+2][j+1] + inp[i+2][j+2])

for i in range(h):
    for j in range(w):
        print(ans[i][j], end='')
    print()


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

int main(){
    long long n,a,x,y=0,sum=0;
	cin >> n >> a >> x;
	
	if(n==1){
		cout << a << endl;
		return 0;
	}
	
	for(int i=1;i<n;i++){
		cin >> x;
		if(x-y>a) sum+=a;
		else sum+=x-y;
		y=x;
	}
	cout << sum+a << endl;
	return 0;
}

Measured memory_bytes: 256
def dfs(nums):
    if len(nums) == 1:
        return int(nums[0])
    if len(nums) == 0:
        return 0
    curr_sum = 0
    curr_sum += int(''.join(nums))
    for i in range(len(nums)-1):
        a = nums[:i+1]
        b = nums[i+1:]
        a_sum = int(''.join(a))
        curr_sum += dfs(b) + a_sum * pow(2, len(b)-1)
    return curr_sum


S = input()
s = list(S)
print(dfs(s))


Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
#define N 100

int i=0;
int e[N];
void hairetu(int);

int main(){

  char k[100];

  while( scanf("%s",k)!=EOF){

    if(k[0]=='+'){
      i--;
      e[i]=e[i]+e[i+1];
    }
    else if(k[0]=='*'){
      i--;
      e[i]=e[i]*e[i+1];
    }
    else if(k[0]=='-'){
      i--;
      e[i]=e[i]-e[i+1];
    }
    else{
      hairetu(atoi(&k));
    }
  }
  printf("%d\n" ,e[i]);
  return 0;
}

void hairetu(int k){
  i++;
  e[i]=k;
}
  
  



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  string S;
  cin >> S;
  rep(i,S.size()) cout << "x";
  cout << endl;
  
  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, k;
int a[100005];
LL sum[100005];

int main() {
    scanf("%d%d", &n, &k);
    forn(i, n) scanf("%d", a + i);
    sum[0] = 0;
    forn(i, n) sum[i + 1] = sum[i] + a[i];
    LL pos = 0;
    forn(i, n) if (i >= k) {
        pos += max(a[i], 0);
    }
    LL x = 0;
    forn(i, k) {
        x += a[i];
    }
    LL ans = pos + max(x, 0ll);
    for (int i = k; i < n; ++i) {
        pos -= max(a[i], 0);
        pos += max(a[i - k], 0);
        x += a[i];
        x -= a[i - k];
        ans = max(ans, pos + max(x, 0ll));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
i = int(input())
As = list((map(int,input().split())))
Bs = list((map(int,input().split())))
Cs = list((map(int,input().split())))

ans = sum(Bs)

for i in range(len(As) - 1):
    if As[i] + 1 == As[i+1]:
        ans += Cs[As[i] - 1]
        
print(ans)

Measured memory_bytes: 3064
from collections import deque
import sys

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

n, m, *uv, s, t = map(int, read().split())
m = iter(uv)
UV = zip(m, m)
graph = [[] for _ in range(3 * n)]
for u, v in UV:
    u -= 1
    v -= 1
    graph[u].append(v + n)
    graph[u + n].append(v + 2 * n)
    graph[u + 2 * n].append(v)
s -= 1
t -= 1
infi = 10 ** 20
dist = [-1] * (3 * n)


def bfs(s):
    que = deque()
    dist[s] = 0
    que.append(s)
    while que:
        v = que.popleft()
        if v == t:
            return dist[t]
        d = dist[v]
        for u in graph[v]:
            if dist[u] > 0:
                continue
            dist[u] = d + 1
            que.append(u)
    return -1


ans = bfs(s)
if ans > 0:
    ans //= 3
print(ans)


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

int main() {
    int a[3];
    for (int i = 0; i < 3; i++)
    {
        cin >> a[i];
    }
    sort(a, a + 3);

    int ans = 0;
    if(a[0] % 2 == a[1] % 2 && a[1] % 2 == a[2] % 2){
        ans = (2 * a[2] - a[1] - a[0]) / 2;
    }
    else if(a[0] % 2 == a[1] % 2){
        ans = (2 * a[2] - a[1] - a[0] - 2) / 2;
        ans++;
    }
    else{
        ans = (a[2] - a[1] + 1) / 2 + (a[2] - a[0] + 1) / 2;
        ans++;
    }
    cout << ans << endl;
}

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

int main(){
  string s; cin>>s;
  map<char,int> mp;
  rep(i,s.length()){
    mp[s[i]]++;
  }
  vector<string> v;
  char tmp='a';
  rep(i,26){
    if(mp[tmp]==0){
      v.push_back(s+tmp);
      break;
    }
    tmp++;
  }
  for(int i=s.length()-1;i>=0;i--){
    int tmp=s[i]-'a';
    for(int j=i-1;j>=0;j--){
      int tmp2=s[j]-'a';
      if(tmp2<tmp){
        v.push_back(s.substr(0,j)+s[i]);
      }
    }
  }
  if(v.size()!=0){
    sort(v.begin(),v.end());
    cout<<v[0]<<endl;
  }else{
    cout<<-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
A = Counter([int(i) for i in input().split()])

A = sorted(A.items(), key=lambda x: -x[0])

x = []
while len(x) < 2:
    for a, cnt in A:
        while cnt > 1 and len(x) < 2:
            x.append(a)
            cnt -= 2
    else:
        break

if len(x) < 2:
    print(0)
else:
    print(x[0] * x[1])


Measured memory_bytes: 107980
N = int(input())
dpa = [0] * N
dpb = [0] * N
dpc = [0] * N

a, b, c = map(int, input().split())
dpa[0] = a
dpb[0] = b
dpc[0] = c
for i in range(1, N):
    a, b, c = map(int, input().split())
    dpa[i] = max(dpb[i-1] + a, dpc[i-1] + a)
    dpb[i] = max(dpa[i-1] + b, dpc[i-1] + b)
    dpc[i] = max(dpa[i-1] + c, dpb[i-1] + c)

print(max(dpa[N-1], dpb[N-1], dpc[N-1]))

Measured memory_bytes: 51416
#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<ll, ll> 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 n;
    cin >> n;
    map<ll, ll> mp;
    ll sum = 0;
    rep(i,n){
        ll a;
        cin >> a;
        mp[a]++;
        sum += a;
    }
    int q;
    cin >> q;
    rep(i,q){
        ll b, c;
        cin >> b >> c;
        sum -= b * mp[b];
        sum += c * mp[b];
        mp[c] += mp[b];
        mp[b] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 9560
def main():
    from itertools import accumulate
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    accA = list(accumulate(A))
    accB = list(accumulate([0] + B))
    ans = 0
    for i in range(N):
        cur = accA[i] + (accB[N] - accB[i])
        ans = max(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main(void)
{
	string days[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
	string input;

	cin >> input;

	for(int i = 0; i < 7; ++i){
		if(days[i] == input){
			cout << (7-i) << endl;
		}
	}

	return 0;
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	string s; cin >> s;
	string res;
	int x = 0;
	rep(i, 0, s.size()) {
		if (s[i] == '0')res.push_back('0');
		else if (s[i] == '1')res.push_back('1');
		else if (!res.empty()&&s[i] == 'B')res.pop_back();
	}
	cout << res << endl;
	return 0;
}

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

struct dish {
    int A, B;

    bool operator<(const dish &other) const {
        return A + B < other.A + other.B;
    }
};

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

    int N;
    cin >> N;
    vector<dish> dishes(N);

    for (dish &d : dishes)
        cin >> d.A >> d.B;

    sort(dishes.rbegin(), dishes.rend());
    long long a_sum = 0, b_sum = 0;

    for (int i = 0; i < N; i++)
        if (i % 2 == 0)
            a_sum += dishes[i].A;
        else
            b_sum += dishes[i].B;

    cout << a_sum - b_sum << '\n';
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
	public static void main(String[] args) throws IOException {
		int count = 0;		//?§£????????°
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        while( !(line.equals("0 0")) ) {
			String nums[] = line.split(" ");
			int max = Integer.parseInt(nums[0]);
			int sum = Integer.parseInt(nums[1]);
			for( int i = 1 ; i <= max ; i++ ) {		//??????????????°???
				for( int j = i+1 ; j <= max ; j++ ) {	//??????????????°???
					int k = sum - i - j ;
					if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					}
					if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					}
					count++;
//					System.out.println( i + " " + j + " " + k ) ;
				}
			}
			System.out.println(count);
			line = br.readLine();
			count = 0;
		}
	}
}

Measured memory_bytes: 24136
L, R = gets.split.map(&:to_i)

if L == 0
  puts 0
  exit
end

if R - L > 2019
  puts 0
else
  result = []
  L.upto(R) do |i|
    (i+1).upto(R) do |j|
      result << i * j % 2019
    end
  end
  puts result.min
end

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

int main() {
	string s;
	int n, k;
	cin >> n >> k >> s;
	s += '0';
	int ans = 0,co=0,gg=0;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (s[0] == '0')
		co++;
	for (int i = 0;i < n;i++) {
		if (s[i] == '1' && s[i+1] == '0') {
			if (co == k) {
				ans = max(ans, i -gg+1);
				gg++;
				while (s[gg-1] != '0' || s[gg] != '1')
					gg++;
			}
			else
				co++;
		}
	}
	ans = max(ans, n - gg);
	cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define mn 100005
#define FLN "code"
#define endl "\n"
#define int long long
#define fi first
#define se second
#define inf 4444444444444444444
#define mod 1000000009
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define FOR0(i, a) for (int i=0; i<(a); i++)
#define FOR1(i, a) for (int i=1; i<=(a); i++)
#define codenhanh(); ios_base::sync_with_stdio(0) ,cin.tie(0),cout.tie(0);

int n,m,a[mn];
int dem=0;
vector<int> sum;
signed main()
{
	#ifdef komandocode
	freopen("code.inp", "r", stdin);
	freopen("code.out", "w", stdout);
	#endif
	codenhanh();
	cin>>n;
	cin>>m;
	int dp[60][3000];
	memset(dp, 0, sizeof(dp));
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		cin>>a[i];
			for(int j=i-1;j>=0;j--)
			{
				for(int p=0;p<=55*j;p++){
					dp[j+1][a[i]+p]+=dp[j][p];
				}	
			}
			}
            

	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=dp[i][i*m];
	}
	cout<<ans;
return 0;
}



Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define int long long 




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

    int n;cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    int bre=0;
    for(int i=0;i<n;i++)
    {
        if(i-bre+1 != arr[i])
            bre++;
    }
    
    if(bre==n) 
        cout<<-1;
    else
        cout<<bre;
    return 0;
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	ll n, t, i, j;
	cin >> n >> t;
	vl a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	int cnt = 0;
	ll m = inf, M = -1;
	ll sa = M - m;
	for (i = 0; i < n; i++) {
		if (m > a[i]) {
			m = a[i];
			M = -1;
		}
		if (M < a[i]) {
			M = a[i];
			if (sa < M - m) {
				sa = M - m;
				cnt = 1;
			}
			else if (sa == M - m) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, a, b;
	cin >> n >> a >> b;
	vi h(n);
	rep(i, n)cin >> h[i];

	int l = 0, r = 1e9;

	while (r - l > 1) {

		int c = (l + r) / 2;
		ll sum = 0;
		rep(i, n)sum += (max(h[i] - (ll)b * c, 0LL) + a - b - 1) / (a - b);
		if (sum <= c)r = c;
		else l = c;

	}

	cout << r << endl;

}

Measured memory_bytes: 640