akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;



int main() {

	double A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	int water = 100 * A;
	int sugar = 0;
	double rat = 0;

	int i = 0;
	while (100 * A * i <= F) {
		int j = 0;
		while (100 * (A * i + B * j) <= F) {
			int k = 0;
			while (100 * (A * i + B * j) + C * k <= F) {
				int l = 0;
				while (100 * (A * i + B * j) + C * k + D * l <= F && 100 * (A * i + B * j) + C * k + D * l >= 100*A) {
					double a_i_j_k_l = (100*(C * k + D * l)) / (100 * (A * i + B * j) + C * k + D * l);
					if (C * k + D * l <= E * (A * i + B * j) && a_i_j_k_l > rat) {
						water = 100 * (A * i + B * j) + C * k + D * l;
						sugar = C * k + D * l;
						rat = a_i_j_k_l;
					}
					l++;
				}
				k++;
			}
			j++;
		}
		i++;
	}

	cout << water << " " << sugar;
	
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
	int r, g, b;
	cin >> r >> g >> b;
	int res = r * 100 + g * 10 + b;

	if (res % 4 == 0)
		cout << "YES\n";
	else
		cout << "NO\n";

	return 0;
}

Measured memory_bytes: 256
A,B,K = map(int,input().split())
data=[]
for k in range(K):
  data.append(A+k)
  data.append(B-k)
  
data_set = set(data)
data=list(data_set)
data.sort()
for i in data:
  if A<=i<=B:
    print(i)

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

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

        int N = sc.nextInt();

        Map<Integer, Integer> resMap = new HashMap<Integer, Integer>();
        Map<Integer, String> scoreMap = new HashMap<Integer, String>();
        Set<String> citySet = new TreeSet<String>();
        for (int i = 0; i < N; i++) {
            String city = sc.next();
            int score = sc.nextInt();
            citySet.add(city);
            scoreMap.put(score, city);
            resMap.put(score, i + 1);
        }

        for (String city : citySet) {
            List<Integer> scoreList = new ArrayList<Integer>();
            for (int score : scoreMap.keySet()) {
                if (city.equals(scoreMap.get(score))) {
                    scoreList.add(score);
                }
            }
            Collections.sort(scoreList, Collections.reverseOrder());
            for (int score : scoreList) {
                System.out.println(resMap.get(score));
            }
        }
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
#define N 1000002
const int p=1e9+7;
struct quji{int l,r,mid,mn;}c[N<<2];
struct node{int x,va;friend bool operator <(node n1,node n2){return n1.va<n2.va;}};
struct edge{int to,nxxt;}e[N<<1];
int n,a[N],b[N],head[N],cnt=1,rd[N],s[N],tot,k;
priority_queue<node>q;
inline void ins(int u,int v){e[cnt].to=v;e[cnt].nxxt=head[u];head[u]=cnt++;}
void bt(int ind,int l,int r)
{
	c[ind].l=l;c[ind].r=r;c[ind].mid=(l+r)>>1;c[ind].mn=1e9;
	if(l==r)return;bt(ind<<1,l,c[ind].mid);bt(ind<<1|1,c[ind].mid+1,r);
}
void chng(int ind,int x,int y)
{
	if(c[ind].l==c[ind].r){c[ind].mn=min(c[ind].mn,y);return;}
	if(x<=c[ind].mid)chng(ind<<1,x,y);else chng(ind<<1|1,x,y);
	c[ind].mn=min(c[ind<<1].mn,c[ind<<1|1].mn);
}
int ask(int ind,int l,int r)
{
	if(l<=c[ind].l&&c[ind].r<=r)return c[ind].mn;
	int ret=1e9;
	if(l<=c[ind].mid)ret=min(ret,ask(ind<<1,l,r));
	if(r>c[ind].mid)ret=min(ret,ask(ind<<1|1,l,r));
	return ret;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),b[a[i]]=i;
	for(int i=1,j=n;i<j;i++,j--)swap(b[i],b[j]);
	bt(1,1,n);
	for(int i=n;i;i--)
	{
		int x=ask(1,b[i],min(n,b[i]+k-1));
		if(x<=n)ins(i,x),rd[x]++;
		x=ask(1,max(1,b[i]-k+1),b[i]);
		if(x<=n)ins(i,x),rd[x]++;
		chng(1,b[i],i);
	}
	for(int i=1;i<=n;i++)if(!rd[i])q.push((node){i,b[i]});
	while(!q.empty())
	{
		node a1=q.top();q.pop();s[++tot]=a1.va;;
		for(int i=head[a1.x];i;i=e[i].nxxt)
		{
			int t1=e[i].to;rd[t1]--;if(!rd[t1])q.push((node){t1,b[t1]});
		}
	}
	for(int i=1,j=n;i<j;i++,j--)swap(s[i],s[j]);
	for(int i=1;i<=n;i++)a[s[i]]=i;
	for(int i=1;i<=n;i++)printf("%d\n",a[i]);
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
int n;
cin>>n;
int a[n],count=0,A=0,B=0;
rep(i,n){
cin>>a[i];
count+=a[i];
}
sort(a,a+n);
for(int i=n-1;i>=0;i-=2){
A+=a[i];
}

cout<<-count+A*2<<endl;



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	string s;
	int a, b, c, ss, ans, n;
	ans = 100000;
	cin >> s;
	n = s.length();
	for (a = 0; a + 2 < n; a++) {
		b = a + 1;
		c = b + 1;
		 {
				ss = (s[a] - '0') * 100 + (s[b] - '0') * 10 + (s[c] - '0');
				ans = min(ans, abs(ss - 753));
			}
	}
	cout << ans << "\n";
	
	return 0;
}


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

typedef long long int ll;
string s, t;

int main() {
    cin >> s >> t;
    ll ans = 0;
    for(ll i = 0; i < s.length(); ++i) {
        if(s[i] != t[i]) ans++;
    }

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

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

int main() {
  int n;
  cin >> n;
  vector<int> list(n);
  for(int i=0;i<n;i++) {
    int temp;
    cin >> temp;
    list.at(temp-1)=i;
  }
  for(int i=0;i<n;i++) {
    cout << list.at(i)+1 << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main(){




int l,a,b,c,d;

cin >>l >>a >>b >>c >>d;
     
    if(a/c < b/d){ //算数にかかる日数が多いかの判定
                     if(b%d==0){cout<< l-(b/d) << endl;
                         }else{
                         cout<< l-(b/d + 1)<< endl;
                        }
    //if(b/d<a/c)
                }else{
                    
                        if(a%c==0){ cout<< l-(a/c)<< endl;
                         }else{
                        cout<< l-(a/c+1) << endl;}
                }
return 0;
}


Measured memory_bytes: 3068
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

int main()
{

  ll n;
  cin >> n;
  ll ans = 1;

  while (ans * 2 <= n)
  {
    ans *= 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
vector<int> ans;
signed main(){
	int a,b,q;cin >> a >> b >> q;
	set<int> temple,shrine;
	rep(i,a){
		int s;cin >> s;
		shrine.insert(s);
	}
	rep(i,b){
		int t;cin >> t;
		temple.insert(t);
	}
	// trace(shrine,temple);
	while(q--){
		int x;cin >> x;
		vector<int> t(2,-1);
		vector<int> s(2,-1);
		{
			
			auto tmp = shrine.lower_bound(x);
			if(tmp != shrine.end())s[1] = *tmp;
			if(tmp != shrine.begin())s[0] = *--tmp;
		}
		{

			auto tmp = temple.lower_bound(x);
			if(tmp != temple.end())t[1] = *tmp;
			if(tmp != temple.begin())t[0] = *--tmp;
		}
		int ret = 1001001001001001ll;
		rep(i,2)rep(j,2){
			//s-t
			// trace(x,s[i],t[j]);
			if(s[i] == -1||t[j] == -1)continue;
			ret = min(ret,abs(x-s[i]) + abs(s[i] - t[j]));

		}
		rep(i,2)rep(j,2){
			if(s[j] == -1|| t[i] == -1)continue;
			ret = min(ret,abs(x - t[i]) + abs(t[i] - s[j]));
		}
		ans.push_back(ret);
		

	}
	rep(i,ans.size())cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 13672
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[1100];
int b[110];
int c[110];
int main(){
	int a;
	while(scanf("%d",&a),a){
		scanf("%s",str);
		for(int i=0;i<a;i++){
			scanf("%d%d",b+i,c+i);
			b[i]--;c[i]--;
		}
		for(int i=a-1;i>=0;i--){
			int t=c[i]-b[i];
			str[b[i]]='a'+(str[b[i]]-'a'+t)%26;
			str[c[i]]='a'+(str[c[i]]-'a'+t)%26;
			swap(str[b[i]],str[c[i]]);
			}
		printf("%s\n",str);
	}
}

Measured memory_bytes: 1016
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j < wv[i][0]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]] + wv[i][1])
print(dp[N][W])

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

#define N 101

int main() {
    int i, j, k, len_s, len_p, count, flag = 0;
    char s[N], p[N];

    scanf("%s%*c%s", s, p);

    len_s = strlen(s);
    len_p = strlen(p);

    for (i = 0; i < len_s; i++) {
        count = 0;
        if (s[i] == p[0]) {
            k = i;
            for (j = 0; j < len_p; j++) {
                if (k == len_s) {
                    k = 0;
                }
                if (s[k] == p[j]) {
                    count++;
                }
                k++;
            }
            if (count == len_p) {
                flag = 1;
                break;
            }
        }
    }

    if (flag == 1) {
        printf("Yes\n");
    }
    else if (flag == 0) {
        printf("No\n");
    }

    return 0;
}



Measured memory_bytes: 2148
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

int MOD = 998244353;
// int MOD = 1000000007;

//----------------------------------------------------------------
signed main(){

	int k;
	string s1;
	cin >> s1 >> k;
	string s2 = s1;

	int n = s1.size();
	int cnt1 = 0;
	int cnt2 = 0;
	string x = s1;
	if(n*k < 20000000){
		rep(i,k-1)x += s1;
		int cnt = 0;
		rep(i,n*k-1){
			if(x[i] == x[i+1]){
				cnt++;
				// x[i+1] = '#';
				i++;
			}
		}
		cerr << cnt << endl;
	}

	if(n == 1){
		cout << k/2 << endl;
		return 0;
	}

	s2[0] = '$';
	cnt2++;
	rep(i,n-1){
		if(s1[i] == s1[i+1]){
			s1[i+1] = '#';
			cnt1++;
		}
		if(s2[i] == s2[i+1]){
			s2[i+1] = '$';
			cnt2++;
		}
	}
	

	if(s1[0] != s1[n-1]){
		cout << cnt1*k << endl;
	}else if(s1[0] == s1[n-1]){
		if(s2[0] == s2[n-1]){
			cout << cnt2*(k/2) + cnt1*(k-k/2) << endl;
			cerr << cnt1 << " " << cnt2 << endl;
		}else{
			cout << cnt1 + (k-1)*cnt2 << endl;
		}
	}



	return 0;
}

//----------------------------------------------------------------

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2017-final.contest.atcoder.jp/tasks/ddcc2017_final_b
// rm -r -f test;oj dl https://agc039.contest.atcoder.jp/tasks/agc039_a

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 1010
const int MOD = 1000000007;

int r, c;
char mat[1010][1010];
int dist[1010][1010];
bool visited[1010][1010];
int dx[] = {0, 1, -1, 0};
int dy[] = {1, 0, 0, -1};
using pii = pair<int, int>;

bool valid(pii a) {
    return !(a.first < 0 or a.second < 0 or a.first >= r or a.second >= c);
}

void bfs(pii src) {
    memset(dist, -1, sizeof dist);
    queue<pii> q;
    q.push(src);
    dist[src.first][src.second] = 0;
    visited[src.first][src.second] = true;
    while (!q.empty()) {
        pii a = q.front();
        q.pop();

        for (int i = 0; i < 4; i++) {
            pii tp = {a.first + dx[i], a.second + dy[i]};
            if (!visited[tp.first][tp.second] and valid({tp.first, tp.second}) and mat[tp.first][tp.second] == '.') {
                visited[tp.first][tp.second] = true;
                dist[tp.first][tp.second] = 1 + dist[a.first][a.second];
                q.push(tp);
            }
        }
    }
}


void solve() {
    cin >> r >> c;

    int wht = 0;
    for (int i = 0; i < r; i++)
        for (int j = 0; j < c; j++) {
            cin >> mat[i][j];
            if (mat[i][j] == '.')
                wht++;
        }

    bfs({0, 0});
    if (dist[r - 1][c - 1] == -1)
        cout << -1;
    else {
        cout << wht - (dist[r - 1][c - 1] + 1) << endl;
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

int main() {
  int n, k,sum = 0;
  cin >> n >> k;
  
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x < k - x) {
      sum += x * 2;
    }
    else {
      sum += (k - x) * 2;
    }
  }  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   998244353  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
ll power( int x , int n ){
    if(n==0) return 1 ;
    ll y = power(x,n/2);
    if(n%2==0) return multiply(y,y);
    return multiply(y,multiply(x,y));
}
// m*(m-1)^n-1
// m*m-1)
const int nmax = 2e5 + 10  ;
vector < int > fact(nmax);
ll ncr(int n , int r){
    return multiply(fact[n],multiply(power(fact[n-r],mod-2),power(fact[r],mod-2)));
}
///////////////////////////////////////////////////////////////
void solve(){
    ll n , m  , k ;
    cin >> n >> m >> k ;
    int terms = 1 ;
    fact[0] =1 ;
    for( int i = 1 ; i < nmax ; i++) fact[i] = multiply(fact[i-1],i);
    //cout << fact[5] << " " ;
    ll ans = 0 ;
    for( int i = 0 ; i <=k ; i++){
            if(n>=(i+1))
                ans = add(ans,multiply(ncr(n-1,i),multiply(m,power(m-1,n-1-i))));
    }
    cout << ans ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}


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

int N;
vector<int> A;

// dp[l][r] := [l,r]に操作を行う際のmax,min
// (N - r + l) % 2 == 1 なら太郎なのでmax
// (N - r + l) % 2 == 0 なら次郎なのでmin
ll dp[3030][3030];
bool defined[3030][3030];

bool isTaro(int l, int r) {
  return (N - r + l) % 2 == 1;
}

ll rec(int l, int r) {
  if (defined[l][r]) return dp[l][r];
  if (l == r) return (N % 2 ? 1 : -1) * A[l];
  defined[l][r] = true;
  if (isTaro(l, r)) {
    // 左から
    ll t_l = A[l] + rec(l + 1, r);
    // 右から
    ll t_r = A[r] + rec(l, r - 1);
    return dp[l][r] = max<ll>(t_l, t_r);
  } else {
    // 左から
    ll t_l = -A[l] + rec(l + 1, r);
    // 右から
    ll t_r = -A[r] + rec(l, r - 1);
    return dp[l][r] = min<ll>(t_l, t_r);
  }
}

signed main() {

  cin >> N;
  A.resize(N);
  REP(i, N) cin >> A[i];

  cout << rec(0, N - 1) << endl;

}


Measured memory_bytes: 80256
# -*- coding: utf-8 -*-
import sys


S = list(map(int,'1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(',')))
K = int(input())

print(S[K-1])

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;
signed main(){
    int n,m;
    cin>>n>>m;
    int ans;
    if(n==1&m==1){
        ans=1;
    }else{
        ans=abs((n-2)*(m-2));
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int n; cin >> n;
  vector<int> a(n),b(n);
  for(int i=0; i<n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.begin(),b.end());
  int max_value = b[b.size()-1];
  int sec_value = b[b.size()-2];
  for(int i=0; i<n; i++) {
    if(max_value==sec_value){
      cout << max_value << endl;    
    } else if(a[i]==max_value) {
      cout << sec_value << endl;    
    } else {
      cout << max_value << endl;     
    }
  }
  return 0;
}

Measured memory_bytes: 3200
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] strs = str.split("");
        for(int i = 0; i < strs.length; i++) {
            System.out.print(strs[strs.length - 1 - i]);
        }
        System.out.println("");
    
    }
 } 


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

int main(){
  ll p, q;
  vector<pair<ll, ll> > v;
  while(cin>>p>>q){
    bool flag=false;
    int i;
    v.clear();
    while(p!=0){
      pair<ll, ll> tmp;
      tmp.first=p*10/q;
      tmp.second=p*10%q;
      p=tmp.second;
      i=0;
      for(int j=0; j<v.size(); j++, i++){
        if(tmp.first==v[j].first && tmp.second==v[j].second){
          flag=true;
          break;
        }
      }
      if(flag)break;
      v.push_back(tmp);
    }
    if(flag){
      string ans1="";
      string ans2="";
      for(int j=0; j<v.size(); j++){
        ans1+=v[j].first+'0';
        if(j<i)ans2+=' ';
        else ans2+='^';
      }
      cout<<ans1<<endl;
      cout<<ans2<<endl;
    }
    else{
      string ans="";
      for(int j=0; j<v.size(); j++)
        ans+=v[j].first+'0';
      cout<<ans<<endl;
    }
  }
  return 0;
}

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

using namespace std;

int const MOD = 1000000007;

int const N = 1234567;

long long s[N];
int na[N], nb[N];
int f[N], g[N];


void add(int &a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

int main() {
  int n;
  long long A, B;
  scanf("%d%lld%lld", &n, &A, &B);
  s[0] = -(1LL << 60);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", s + i);
  }
  na[n] = n + 1;
  nb[n] = n + 1;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i + 1] - s[i] >= A) {
      na[i] = na[i + 1];
    } else na[i] = i + 1;
    if (s[i + 1] - s[i] >= B) {
      nb[i] = nb[i + 1];
    } else nb[i] = i + 1;
  }
  f[1] = g[1] = 1;
  f[2] = g[2] = MOD - 1;
  for (int i = 1; i <= n; i++) {
    add(f[i], f[i - 1]);
    add(g[i], g[i - 1]);
    // printf("%d %d %d\n", i, f[i], g[i]);
    int qa = (int) (std::lower_bound(s, s + n + 1, s[i - 1] + A) - s);
    int qb = (int) (std::lower_bound(s, s + n + 1, s[i - 1] + B) - s);
    qa = std::max(qa, i + 1);
    qb = std::max(qb, i + 1);
    if (qa <= nb[i]) {
      // printf("add g from %d to %d value of %d\n", qa, nb[i], f[i]);
      add(g[qa], f[i]);
      add(g[nb[i] + 1], MOD - f[i]);
    }
    if (qb <= na[i]) {
      // printf("add f from %d to %d value of %d\n", qb, na[i], g[i]);
      add(f[qb], g[i]);
      add(f[na[i] + 1], MOD - g[i]);
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (na[i] > n) {
      add(ans, g[i]);
    }
    if (nb[i] > n) {
      add(ans, f[i]);
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int dp[maxn];
int main(){
	int n;
	int h[maxn];
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)
		scanf("%d",&h[i]);
	memset(dp,0x3f3f,sizeof(dp));
	dp[1] = 0;
	dp[2] = abs(h[1] - h[2]);
	for(int i = 3;i <= n;i++)
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1024
#include "iostream"
#include "algorithm"
#include "string"

using namespace std;

const long long  int MOD = 1000000007;

int main(){
	int y,m,d;
	char s1,s2;
	cin>>y>>s1>>m>>s2>>d;
	if(y<2019){
		cout<<"TBD"<<endl;
	}
	else{
		if(m>4){
			cout<<"TBD"<<endl;
		}
		else{
			cout<<"Heisei"<<endl;
		}
	}
return 0;}

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

using namespace std;
 
#define int1(a) scanf("%d",&a)
#define int2(a,b) scanf("%d %d",&a,&b)
#define int3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define int4(a,b,c,d) scanf("%d %d %d %d",&a,&b,&c,&d)
 
#define lint1(a) scanf("%lld",&a)
#define lint2(a,b) scanf("%lld %lld",&a,&b)
#define lint3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define lint4(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define lli long long int
 
#define pint(x) printf("%d",x)
#define plint(x) printf("%lld",x)
#define endl '\n'
#define nl printf("\n");
#define ps printf(" "); 
 
#define all(x) x.begin(),x.end()
#define pb push_back
#define Set(a, s) memset(a, s, sizeof (a))
#define mod1 (lli)(1e9 + 7)
#define mod2 (lli)(1e9 + 9)
#define EPS 1e-9

#define fore(i,n) for(int i=n; i>=0; i--)
#define fors(i,a,n) for(int i=a; i<n; i++)
#define fora(i,ele) for(auto i: ele)
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<lli> vli;
 
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
 
double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
float roundoff(float val, float p){ return floor(val*pow(10.0,p)+0.5)/pow(10.0,p);}
lli power(lli a, lli b, lli mod){lli x=1,y=a; while(b > 0){if(b&1){x=(x*y)%mod;}y = (y*y)%mod; b /= 2;}return x;}
 
const int INF = 0x3f3f3f3f;
const float pi = 3.14159265;
 
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};
//int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1};
 lli n,k;
 vli arr;
 
 lli go(int idx, vli &dp){
	 //trace1(idx);
	 if(idx == n-1) return 0;
	 if (dp[idx] != -1) return dp[idx];
	 
	 //else if(idx==n-2) return dp[n-2] = abs(arr[n-1]-arr[n-2]);
	 
	 else{
		 lli minm = 9LL*(1e14);
		 fors(i,idx+1,min(idx+k+1,n)){
			 //trace2('f',i);
			minm = min(abs(arr[idx]-arr[i])+go(i,dp),minm);
			//trace2(i,minm);
		}
		 dp[idx] = minm;
		//trace2(idx,dp[idx]);
		return dp[idx];
	 }
	 
 }
 
int main(void) {
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    cout.tie(NULL);
	//srand (time(NULL));
	/*
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	*/
    // cout<<"Execution time : "<<tick()<<"\n";
    
    lint2(n,k);
    vli dp(n,-1);
    
   // vi arr;
    fors(i,0,n){
		lli temp;
		lint1(temp);
		arr.pb(temp);
	}
	cout<<go(0,dp);
	
    return 0;
}


Measured memory_bytes: 9716
# coding: utf-8
# Your code here!

while True:
    n=int(input())
    if n==0:
        break
    count=[0]*10
    for i in range(n):
        a=int(input())
        count[a]+=1
    for a in count:
        if a>0:
            print('*'*a)
        else:
            print('-')


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#include <stdlib.h>
#include <cmath>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

double d[2][9];

int main(){
    int N; cin>>N;
    for(int i=0;i<N;i++) cin>>d[0][i]>>d[1][i];
    double ans=0;
    for(int i=0;i<N-1; i++){
        for(int j=i+1;j<N;j++) ans+=sqrt((d[0][i]-d[0][j])*(d[0][i]-d[0][j])+(d[1][i]-d[1][j])*(d[1][i]-d[1][j]));
    }
    ans*=2;
    ans/=N;
    cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n * a, b) << '\n';
}


Measured memory_bytes: 256
program r20718f
 
implicit none
integer :: a, b
 
read *, a, b
 
if(b == 15 - a) then
 print *, '+'
else if(a == 3 .and. b == 5) then
 print *, '*'
else if(a == 5 .and. b == 3) then
 print *, '*'
else if(a == 1 .and. b == 15) then
 print *, '*'
else if(a == 15 .and. b == 1) then
 print *, '*'
else
 print *, 'x'
end if
 
end program r20718f

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

using ll = long long;
using namespace std;

const ll MOD = 1000000007;

ll dp[10010][100][2];

int main(){
    string s; cin >> s;
    int n = s.length();
    int d; cin >> d;
    
    dp[0][0][0] = 1;
    rep(i,n){
        int num = s[i] - '0';
        rep(j,d){
            rep(k,10) ( dp[i+1][(j+k)%d][1] += dp[i][j][1] ) %= MOD;
            rep(k,num) ( dp[i+1][(j+k)%d][1] += dp[i][j][0] ) %= MOD;
            ( dp[i+1][(j+num)%d][0] += dp[i][j][0] ) %= MOD;
        }
    }
    ll ans = ( dp[n][0][0] + dp[n][0][1] + MOD-1) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19200
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string a, b;
    cin >> a;
    cin >> b;

    if (a.length() > b.length()) {
        cout << "GREATER" << endl;
    } else if (a.length() < b.length()) {
        cout << "LESS" << endl;
    } else {
        int len = a.length();
        bool flag = true;
        for (int i = 0; i < len; ++i)
        {
            int a_i = int(a[i]);
            int b_i = int(b[i]);
            if (a_i > b_i) {
                cout << "GREATER" << endl;
                flag = false;
                break;
            } else if (a_i < b_i) {
                cout << "LESS" << endl;
                flag = false;
                break;
            }
        }

        if (flag) {
            cout << "EQUAL" << endl;
        }
    }


    return 0;
}


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

int main(void) {
	int w, a, b;
	scanf("%d %d %d", &w, &a, &b);

	if (a < b) {
		if (b - (a + w) > 0) {
			printf("%d", (b - (a + w)));
		}
		else {
			printf("0");
		}
	}
	else {
		if (a-(b+w) > 0) {
			printf("%d", a - (b + w));
		}
		else {
			printf("0");
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();
const long double EPS =1e-9;



int main(){
    ll n; cin>>n;
    ll a[n];
    map<int,int> mp;
    REP(i,n){
       cin>>a[i];
       if(mp.find(a[i])!=mp.end())
       mp[a[i]]++;
       else mp[a[i]]=1;
    }   
ll sum=0;
for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
  //cout<<itr->first<<" "<<itr->second<<endl;
  ll k=itr->second;
         if(k<2)continue;
         else sum+=k*(k-1)/2;

    }

    REP(i,n){
        ll diff=0,k=mp[a[i]];
       if(mp[a[i]]==2) diff=k*(k-1)/2;
       else if(mp[a[i]]>2) diff=k*(k-1)/2-(k-1)*(k-2)/2;
       cout<<sum-diff<<endl;
        
    }
}

  

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;


int main() {
  ll a,b; cin>>a>>b;
  cout<<6-(a+b)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int N, M;
vector<int> V[100001];
queue<int> q;
int RES[100001];
int main(void){
    cin >> N >> M;
    int A, B;
    REP(i,M){
        cin >> A >> B;
        V[A].push_back(B);
        V[B].push_back(A);
    }
    RES[1] = 1;
    q.push(1);
    while(!q.empty()){
        int f = q.front();
        q.pop();
        REP(i, V[f].size()){
            int c = V[f][i];
            if(RES[c] == 0){
                RES[c] = f;
                q.push(c);
            }
        }
    }
    cout << "Yes" << endl;
    for(int i=2;i<=N;i++) cout << RES[i] << endl;

    return 0;
}



Measured memory_bytes: 10440
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 AOJ0515().doIt();
	}
	
	class AOJ0515{
		void doIt(){
			while(true){
				int w = in.nextInt();
				int h = in.nextInt();
				if(w+h==0)break;
				int n = in.nextInt();
				boolean[][] kouji = new boolean[h][w];
				for(int i=0;i<h;i++)Arrays.fill(kouji[i],true);
 				for(int i=0;i<n;i++){
 					int x = in.nextInt()-1;
 					int y = in.nextInt()-1;
 					kouji[y][x] = false;
 				}
				int[][] dp = new int[h][w];
				dp[0][0]=1;				
				for(int i=0;i<h;i++)for(int s=0;s<w;s++)if(kouji[i][s]){
						for(int t=0;t<2;t++)for(int r=0;r<2;r++)if(t!=r){
							int nx = s+t;
							int ny = i+r;
							if(nx<0||nx>=w||ny<0||ny>=h)continue;
							dp[ny][nx]+=dp[i][s];
						}
				}
				System.out.println(dp[h-1][w-1]);
			}
		}
	}
}

Measured memory_bytes: 20212
A, B = map(int, input().split())
ans = 0
tap = 0
for i in range(10000):
    if B == 1:
        break
    if i == 0:
        tap += A
        ans += 1
    if i >= 1:
        tap -= 1
        tap += A
        ans += 1
    if tap >= B:
        break
print(ans)

Measured memory_bytes: 3060
import fractions

def lcm(x,y):
    return x*y//fractions.gcd(x,y)

N, M = map(int, input().split())
S = input()
T = input()

L = lcm(N,M)
ST_idx = set([i*(L//N) for i in range(N)]) & set([i*(L//M) for i in range(M)])

for x in ST_idx:
    if S[(N*x)//L] != T[(M*x)//L]:
        print(-1)
        break
else:
    print(L)

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vii = vector<pii>;
using vs = vector<string>;
#define all(x) x.begin(), x.end()
// int di[] = {0, 1, 0, -1};
// int dj[] = {1, 0, -1, 0};
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
#define x first
#define y second


int main(int argc, char **argv) {
	ios::sync_with_stdio(false), cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	int d, t, s; cin >> d >> t >> s;
	if (d / double(s) <= t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}


Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

int main()
{
    int n,k, a;

    cin >> n >> k;
    a = n % k;

    if (k > n) a = 1;
    if (a > 0) a = 1;
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    long ans = long.max;
    foreach (a; A)
    {
        long cnt;
        long t = a;
        while (t % 2 == 0)
            cnt++, t /= 2;
        ans = ans.min(cnt);
    }
    writeln(ans);
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  string d,a;
  for(int i=0;i<k;++i){
	cin>>d;
	a+=d;
  }
  while(string::npos!=to_string(n).find_first_of(a)) ++n;
  cout<<n;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	char input[5];
	int num[4];

	cin >> input;
	for(int i = 0; i < 4; i++){
		num[i] = (int)(input[i] - '0');
	}

	int op = 0;
	for(int i = 0; i < (1 << 3); i++){
		int sum = num[0];
		for(int j = 0; j < 3; j++){
			if(i & (1 << j)){
				sum += num[j + 1];
			}else{
				sum -= num[j + 1];
			}
		}
		if(sum == 7){
			op = i;
			break;
		}
	}

	for(int i = 0; i < 3; i++){
		cout << num[i];
		if(op & (1 << i)){
			cout << '+';
		}else{
			cout << '-';
		}
	}
	cout << num[3] << "=7" << endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Data.List
import Data.Char

getInt :: IO Int
getInt = (\a -> read a :: Int) <$> getLine

getIntArray :: IO [Int]
getIntArray = ((map (\a -> read a :: Int)) . words) <$> getLine

getStrArray :: Int -> IO [String]
getStrArray 0 = return [] :: IO [String]
getStrArray n = (:) <$> getLine <*> (getStrArray (n - 1))

countSq :: [Int] -> Int
countSq [n, m] = (n - 1) * (m - 1)

main = do
    print =<< (countSq <$> getIntArray)


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define N 100000
#define maxn (N + 10)
#define maxm (maxn * 2)
#define pb push_back
#define lc (id * 2)
#define rc (id * 2 + 1)
typedef long long ll;
const ll INF = (1e8);
const ll mod = (998244353);
ll numa[maxn];
int main(){
    int n;scanf("%d",&n);
    ll ans = 0;
    for(int i = 1;i <= n;i++){
        int a;scanf("%d",&a);numa[a]++;
        ans += a;
    }
    int q;scanf("%d",&q);
    while(q--){
        ll bi,ci;scanf("%lld%lld",&bi,&ci);
        ans += (numa[bi] * (ci - bi));
        numa[ci] += numa[bi];numa[bi] = 0;
        printf("%lld\n",ans);
    }

    return 0;
}

Measured memory_bytes: 4496
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<math.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;
int R,C,K;
int v[3002][3002]={};
long long int mae[3002]={};//前の行の最大スコア
long long int nw[3002][4]={};//今の行のスコア
int main()
{
 scanf("%d %d %d",&R,&C,&K);
 for(int i=0;i<K;i++)
 {
	int a,b,vl;
	scanf("%d %d %d",&a,&b,&vl);
	v[a][b]=vl;
 }
 for(int i=1;i<=R;i++)
 {
	for(int j=1;j<=C;j++)
	{
		for(int l=1;l<=3;l++)
		{
		 nw[j][l]=max(nw[j-1][l],max(nw[j-1][l-1]+v[i][j],mae[j]+v[i][j]));
		}
	 }
	for(int j=1;j<=C;j++)
	{
		mae[j]=nw[j][3];
	}
 }
 long long int ans=0;
 printf("%lld",nw[C][3]);
}

Measured memory_bytes: 39092
# input
N = int(input())

# check
if N == 0:
    print(0)
    exit(0)

r_bits = ""
p = 0
d = 0
while N + p:
    if (N & 1) ^ p:
        r_bits += '1'
        if d ^ p:
            p ^= 1
    else:
        r_bits += '0'
    N >>= 1
    d ^= 1

print(r_bits[::-1])

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

int main()
{
  int r; cin>>r;
  if (r < 1200)
  {
    cout << "ABC" << endl;
  }
  else if (r < 2800)
  {
    cout << "ARC" << endl;
  }
  else
  {
    cout << "AGC" << endl;
  }
  
  
  
}

Measured memory_bytes: 3624
/*input
2
10 -10
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll a[maxn];

int main(){
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>a[i];
	ll sum=0;
	REP(i,n) sum+=a[i];

	ll pre=0;
	ll ans=INF64;
	REP(i,n-1){
		pre+=a[i];
		ans=min(ans,abs(sum-pre-pre));
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  vi l(n+1,0), r(n+1,0);
  for (int i = 0; i < n; ++i) l[i+1] = gcd(l[i], a[i]);
  for (int i = n-1; i >= 0; --i) r[i] = gcd(r[i+1], a[i]);
  
  ll ans = 0;
  rep(i,n) chmax(ans, gcd(l[i],r[i+1]));
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {

	string s;
	cin >> s;

	long i = 0;

	if (s == "SUN") { i = 7; }
	if (s == "MON") { i = 6; }
	if (s == "TUE") { i = 5; }
	if (s == "WED") { i = 4; }
	if (s == "THU") { i = 3; }
	if (s == "FRI") { i = 2; }
	if (s == "SAT") { i = 1; }



	cout << i << endl;
}

Measured memory_bytes: 256
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,l;
	int a[203];
	int sum = 0;
	scanf("%d%d",&n,&l);
	for (int i = 1; i <= n; ++i){
		a[i] = l + i - 1;
		sum += a[i];
	}
	for (int i = 1; i <= n; ++i)
	{
		if(a[i] == 0){
			printf("%d\n", sum);
			return 0;
		}
	}
	if(sum < 0){
		printf("%d\n", sum - a[n]);
	}
	else{
		printf("%d\n", sum - a[1]);
	}
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int middle, final, retest;
    int sum;
    char grade;

    while (1){
        scanf("%d %d %d", &middle, &final, &retest);
        sum = middle + final;

        if (middle == -1 && final == -1 && retest == -1){
            break;
        }else if (middle == -1 || final == -1){
            grade = 'F';
        }else if (sum >= 80){
            grade = 'A';
        }else if (sum < 80 && sum >= 65){
            grade = 'B';
        }else if (sum < 65 && sum >= 50){
            grade = 'C';
        }else if (sum < 50 && sum >= 30){
            if (retest < 50){
                grade = 'D';
            }else{
                grade = 'C';
            }
        }else{
            grade = 'F';
        }

        printf("%c\n", grade);
    }

    return 0;
}

Measured memory_bytes: 600
from collections import Counter


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


pf = prime_factorize(int(input()))
c = Counter(pf)
#print(c)
ans = 0
for a, b in c.items():
    tmp = 1
    while True:
        b -= tmp
        if b < 0:
            break
        tmp += 1
        ans += 1
print(ans)


Measured memory_bytes: 9484
def solve(n: int):
    count = 0
    for k in range(1, n + 1, 2):
        num_aliquot = len([1 for j in range(1, k + 1) if k % j == 0])
        if num_aliquot == 8:
            count += 1

    return count


N = int(input())  # 1 <= N <= 200

print(solve(N))

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
S = input()

ans = []
for s in S:
    t = ord(s) + N
    if t > 90:
        t -= 26
    ans.append(chr(t))
print(''.join(ans))


Measured memory_bytes: 3188
from itertools import *
from collections import *
from bisect import *
N,K=map(int,input().split())
A=list(map(int,input().split()))

ruiA=[0 for i in range(N+1)]
for i in range(0,N):
    ruiA[i+1]=ruiA[i]+A[i]


nlst=[]

for i in range(len(ruiA)-1):
    for m in range(i+1,len(ruiA)):
        nlst.append(ruiA[m]-ruiA[i])
nlst.sort(reverse=True)

lenbin=60
for i in range(len(nlst)):
    lst=[]
    for m in range(lenbin):
        lst.append((nlst[i]>>m)&1)
    nlst[i]=list(reversed(lst))
lenbinst=0

use=set([i for i in range(len(nlst))])
while lenbinst<lenbin:
    idx=-1
    count=0
    dellst=set()
    for m in use:
        if nlst[m][lenbinst]==1:
            count+=1
    if count>=K:
        if len(nlst)!=count:
            for m in use:
                if nlst[m][lenbinst]!=1:
                    dellst.add(m)
    use=use-dellst
    lenbinst+=1
valuelst=[0 for i in range(lenbin)]
nlst=[nlst[i] for i in use]

for n in nlst:
    for i,a in enumerate(list(reversed(n))):
        if a:
            valuelst[i]+=1

for i in range(lenbin):
    if valuelst[i]>=K:
        newlst=[i for i in nlst if i[idx]==1]
        if len(newlst)>=K:
            nlst=newlst

valuelst=[0 for i in range(lenbin)]
for n in nlst:
    for i,a in enumerate(list(reversed(n))):
        if a:
            valuelst[i]+=1
value=0
for i in range(lenbin):
    if valuelst[i]>=K:
        value+=2**i
print(value)


Measured memory_bytes: 526324
from sys import stdin


def main():

    N, _ = [int(x) for x in stdin.readline().rstrip().split()]

    a_lists = [int(x) for x in stdin.readline().rstrip().split()]

    sum_ = sum(a_lists)

    if N >= sum_:
        print(N-sum_)
    else:
        print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 68200