akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int W,H;
int p[100100],q[100100];
int main(){
	scanf("%d %d",&W,&H);
	for(int i=0;i<W;i++)scanf("%d",&p[i]);
	for(int i=0;i<H;i++)scanf("%d",&q[i]);
	sort(p,p+W);
	sort(q,q+H);
	int w = 0, h = 0;
	ll ans = 0ll;
	for(int i=0;i<H+W;i++){
		char type;
		if(w==W){
			type = 'h';
		}else if(h==H){
			type = 'w';
		}else{
			if(p[w]<q[h])type = 'w';
			else type = 'h';
		}
		if(type=='w'){
			ans += (ll)p[w]*(ll)(H+1-h);
			w++;
		}else{
			ans += (ll)q[h]*(ll)(W+1-w);
			h++;
		}
	}
	cout << ans << endl;
	return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];
	
	cin>>n>>m;
	
	(n+m>=10)?cout<<"error"<<endl:cout<<m+n<<endl;
	
	
	
}


Measured memory_bytes: 256
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#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())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int p[SIZE],q[SIZE],r[SIZE];
int main(){
    int X,Y,A,B,C;
    R(X,Y,A,B,C);
    REP(i,A)R(p[i]);
    REP(i,B)R(q[i]);
    REP(i,C)R(r[i]);
    sort(p,p+A,greater<int>());
    sort(q,q+B,greater<int>());
    sort(r,r+C,greater<int>());
    LL an=0;
    REP(i,X)an+=p[i];
    REP(i,Y)an+=q[i];
    REP(i,C){
        int v=0;
        if(X&&r[i]-p[X-1]>v){
            v=r[i]-p[X-1];
        }
        if(Y&&r[i]-q[Y-1]>v){
            v=r[i]-q[Y-1];
        }
        if(v<=0)break;
        if(r[i]-p[X-1]==v){
            an+=r[i]-p[--X];
        }
        else{
            an+=r[i]-q[--Y];
        }
    }
    W(an);
    return 0;
}


Measured memory_bytes: 8832
#include<iostream>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

// mint
#include<cstdint>
int64_t const MOD = 1e9+7;

template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};
typedef mod_int<MOD> mint;

// fact
template<typename INT, int64_t MAXN_>
struct factorial {
  INT fact[MAXN_+1], ifact[MAXN_+1];
  void init(int64_t N) {
    fact[0] = fact[1] = mint(1);
    for(int i = 2; i <= N; ++i) fact[i] = fact[i-1]*i;
    ifact[N] = fact[N].inv();
    for(int i = N-1; i >= 0; --i) ifact[i] = ifact[i+1]*(i+1);
  }
  mint comb(int64_t n, int64_t k) {
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int const MAXA = 7e5;
struct factorial<mint, MAXA> F;

int main() {
  int X, Y; std::cin >> X >> Y;
  int S = X+Y;
  if(S%3 != 0) fin(0);
  S /= 3;
  int a = Y-S, b= X-S;
  if(a < 0 || b < 0) fin(0);
  F.init(a+b);
  mint ans = F.comb(a+b, a);
  fin(ans.v_);
  return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long;

ll gcd_table[201][201];

ll gcd(ll a, ll b){
    if(gcd_table[a][b]>0){
        return gcd_table[a][b];
    }
    int max_num = max(a,b);
    ll gcd = 1;
    for(int i=1; i<=max_num; i++){
        if(a%i==0 && b%i==0){
            gcd = i;
        }
    }
    gcd_table[a][b] = gcd;
    return gcd; 
}

int main(){
    int N;
    cin >> N;
    ll sum = 0;
    for(int i=1; i<=N; i++){
        for(int j=1; j<=N; j++){
            for(int k=1; k<=N; k++){
                ll gcd_ = gcd(i,j);
                ll gcd__ = gcd(gcd_, k);
                // cout << i << " " << j << " " << k << " " << gcd__ << endl;
                sum += gcd__;
            }
        }
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template<typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a){
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os, vector<T> v){
    for(auto x:v)os << x << ' ';
    return os;
}
void debug(){cerr << '\n';}
template<typename H, typename... T>
void debug(H a, T... b){
    cerr << a;
    if(sizeof...(b))cerr << ", ";
    debug(b...);
}
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int ans = (a-c)*(b-d);
    show(ans);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int s=scan.nextInt();
		Set<Integer> set=new  HashSet<Integer>();
		for (int i = 0; i < s; i++) {
			set.add(scan.nextInt());
		}
		int q=scan.nextInt();
		int v=0;
		for (int i = 0; i < q; i++) {
			int a=scan.nextInt();
			if(!set.add(a))
			{
				v++;
			}
		}
		PrintWriter pw=new PrintWriter(System.out);
		pw.println(v);
		pw.close();

	}

}

Measured memory_bytes: 28676
#!/usr/bin/env perl

use strict;
use warnings;

my ($n, $m) = split / /, <>;
chomp $m;

my (@na, @ma);
for (my $i = 0; $i < $n; $i++) {
  my @lines = split //, <>;
  chomp $lines[$#lines];
  push @na, \@lines;
}
for (my $i = 0; $i < $m; $i++) {
  my @lines = split //, <>;
  chomp $lines[$#lines];
  push @ma, \@lines;
}

for (my $i = 0; $i < $n - $m + 1; $i++) {
  NEXT: for (my $j = 0; $j < $n - $m + 1; $j++) {
    for (my $k = 0; $k < $m; $k++) {
      for (my $l = 0; $l < $m; $l++) {
        if ($na[$i + $k][$j + $l] ne $ma[$k][$l]) {
          next NEXT;
        }
      }
    }
    print "Yes\n";
    exit;
  }
}
print "No\n";


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;
    int ans = 0;
    rep(i, n-1) {
        if (s[i] == s[i+1]) ans++;
    }
    cout << min(ans+2*k, n-1) << endl;

}


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

struct point
{
	int x,y;
}a[1005],b[1005];
int c[1005]; 

int cmp(point x,point y)
{
	if(x.x==y.x) return x.y<y.y;
	return x.x<y.x;
}

int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].x>>a[i].y;
	}
	for(int i=1;i<=n;i++){
		cin>>b[i].x>>b[i].y;
	}
	sort(b,b+n,cmp);
	int ans=0;
	for(int i=1;i<=n;i++){
		int maxn=-1;
		int z=-1;
		for(int j=1;j<=n;j++){
			if(!c[j]&&a[j].x<b[i].x&&a[j].y<b[i].y&&a[j].y>maxn){
				maxn=a[j].y;
				z=j;
			}
		}
		if(maxn!=-1){
			c[z]=1;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld DINF = 1e12;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

  ll n, m;
  cin >> n >> m;
  ll a[100010];
  rep(i, n) cin >> a[i];
  ll csum[100010];
  csum[0] = 0;
  rep(i, n) csum[i + 1] = (csum[i] + a[i]) % m;
  map<ll, ll> cnt;
  rep(i, n + 1)
  {
    cnt[csum[i]]++;
  }
  ll ans = 0;
  for (auto p : cnt)
  {
    ll t = p.second;
    ans += t * (t - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5760
typedef char Bool;
#define true 39
#define false 0 
typedef long long int64;
typedef unsigned long long uint64;
typedef int int32;
typedef unsigned int uint32;
typedef unsigned char byte;

#define surplus 1000000006
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>

int compare(const void* a, const void* b)
{
	int64* A = (long long*)a;
	int64* B = (int64*)b;
	if (*A > * B) return 1;
	if (*A < *B) return -1;
	return 0;
}

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

	char s[100000][4];



	for (int i = 0; i != n; i++)
	{
		scanf("%s", &s[i]);
	}

	int a = 0, w = 0,t = 0, r = 0;

	for (int i = 0; i != n; i++)
	{
		if (!strncmp(s[i], "AC", 3))
		{
			a++;
		}
		else if (!strncmp(s[i], "WA", 3))
		{
			w++;
		}
		else if (!strncmp(s[i], "TLE", 3))
		{
			t++;
		}
		else if (!strncmp(s[i], "RE",3))
		{
			r++;
		}
	}

	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", a, w, t, r);

	return 0;
}

Measured memory_bytes: 2124
module ABC139

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_C

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_C

    ! variables for this <subroutine>
    integer(INT32) :: num_square
    integer(INT32) :: num_movement_max
    integer(INT32) :: num_movement_trial

    ! arrays for this <subroutine>
    integer(INT32), dimension(:), allocatable :: val_height

    ! support variables for this <subroutine>
    integer(INT32) :: itr

    ! STEP.01
    ! read out the given data (the number of squares)
    read(unit=INPUT_UNIT, fmt=*) num_square

    ! STEP.02
    ! allocate the array to store the given data
    allocate( val_height(1:num_square) )

    ! STEP.03
    ! read out the given data (the values of height)
    read(unit=INPUT_UNIT, fmt=*) val_height(:)

    ! STEP.04
    ! initialize the variables for this <subroutine>
    itr                = 1_INT32
    num_movement_max   = 0_INT32
    num_movement_trial = 0_INT32

    do while (itr .lt. num_square)

      if ( val_height(itr) .ge. val_height(itr + 1) ) then
        num_movement_trial = num_movement_trial + 1_INT32
      else
        num_movement_trial = 0_INT32
      end if

      num_movement_max = max(num_movement_max, num_movement_trial)

      itr = itr + 1_INT32

    end do

    ! STEP.05
    ! allocate the array to store the given data
    deallocate( val_height )

    ! STEP.06
    ! output the answer of this task
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') num_movement_max

    ! STEP.END
    return

  end subroutine task_C

end module ABC139

program main

  ! <module>s to import
  use, non_intrinsic :: ABC139

  ! require all variables to be explicitly declared
  implicit none

  call task_C

end program main

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

bool include(vector<int> a,int value){
    for(int i = 0; i<a.size(); i++){
        if(a.at(i) == value) return true;
    }
    return false;
}

int main() {
    int H,W;
    cin >> H >> W;
    vector<string> a(H);
    for(int i = 0; i<H; i++) cin >> a.at(i);
    vector<int> h_del,w_del;
    for(int i = 0; i<H; i++){
        for(int j = 0; j<W; j++){
            if(a.at(i).at(j) == '#') break;
            if(j == W-1) h_del.push_back(i);
        }
    }
    for(int i = 0; i<W; i++){
        for(int j = 0; j<H; j++){
            if(a.at(j).at(i) == '#') break;
            if(j == H-1) w_del.push_back(i);
        }
    }
    for(int i = 0; i<H; i++){
        if(include(h_del, i)) continue;
        for(int j = 0; j<W; j++){
            if(include(w_del,j)) continue;
            cout << a.at(i).at(j);
        }
        cout << endl;
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    cout << a.at(n - 1) - a.at(0) << endl;
}

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



int main(){
  

  vector<int> Alice(101);
  int A,B;
  cin>>A>>B;
  for(int i=A;i<=B;i++){
    Alice.at(i)=1;
  }
  vector<int> Bob(101);
  int C,D;
  cin>>C>>D;
  for(int i=C;i<=D;i++){
    Bob.at(i)=1;
  }
  
  int sum=0;
  for(int i=0;i<=100;i++){
    if(Alice.at(i)==1&&Bob.at(i)==1) sum+=1;
  }
  
  cout<<max(sum-1,0)<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())

es = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)

xs = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    xs[p-1] += x

ans = [0]*N
ans[0] = xs[0]
visited = [0]*N
stack = [0]
while stack:
    v = stack.pop()
    visited[v] = 1
    for to in es[v]:
        if visited[to]:
            continue
        stack.append(to)
        ans[to] = ans[v] + xs[to]

print(*ans)

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

int main() {
  int N,a = 0;
  cin >> N;
  vector<int> B(N-1);
  for (int i=0; i<N-1; i++){
    cin >> B.at(i);
  }
  a += B.at(0) + B.at(N-2);
  if (N > 2) {
    vector<int> A(N-2);
    for (int i=2; i<N; i++){
      A.at(i-2) = min(B.at(i-1),B.at(i-2));
    }
    for (int i=2; i<N; i++){
      a += A.at(i-2);
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  long long int n;
  cin >> n;
  long long int tmp=n, sm=0;
  while(tmp!=0){
    sm+= tmp%10;
    tmp/=10;
  }
  if(n%sm==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    ans = [0]*N
    for i, a in enumerate(A, 1):
        ans[a-1] = i
    print(' '.join(map(str, ans)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25284
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <set>
#include <map>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define for_p(i, a, b) for(int i = a; i < b; i++)
#define for_m(i, a, b) for(int i = a - 1; i >= b; i--)

//a = s1.size();
//vector<string> s1;
//string s2 = accumulate( s1.begin(), s1.end(), string() );
using namespace std;

int main()
{
  int a = 0 , b = 0, c = 0, d = 0, e = 0, f = 0;
  int i = 0, j = 0;
  double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
  int a1[256], a2[512], a3[1024];
  char s1[200000], s2[200000], s3[200000];
  
  cin >> s1 >> s2;
  
  if(s1[0] == s2[0]){
    c++;
  }
    if(s1[1] == s2[1]){
    c++;
  }  if(s1[2] == s2[2]){
    c++;
  }
  cout << c << endl;
}
  



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

int main(void) {

    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n)cin>>d[i];
    sort(d.begin(),d.end());
    int ans = 1;
    int tmp = d[0];
    rep(i,n){
        if(tmp != d[i]){
            ans++;
        }
        tmp = d[i];
    }


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

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

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

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

  // ソート
  sort(a.begin(), a.end());

  // vectorをコピーする
  vector<int> u(n);
  copy(a.begin(), a.end(), back_inserter(u));

  // 重複を削除
  auto itr = unique(u.begin(), u.end());
  u.erase(itr, u.end());

  int ans = 0;
  for(int i = 0; i < u.size(); i++) {

    // 二分探索
    auto low = lower_bound(a.begin(), a.end(), u[i]);
    auto up = upper_bound(a.begin(), a.end(), u[i]);

    // 探索する数字の個数
    int cnt = up - low;

    if(cnt % 2 != 0) ans++;
  }

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


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int R=sc.nextInt();
			if(R<1200) System.out.println("ABC");
			else if(R<2800) System.out.println("ARC");
			else System.out.println("AGC");

		}
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  int i;
  int m,b;
  while(str!="-"){
    cin >> m;
    for(i=0;i<m;i++){
      cin >> b;
      str=str.substr(b,str.size()-b)+str.substr(0,b);
    }
    cout << str << endl;
    cin >> str;
  }
  
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    int q;
    cin>>q;
    vector<ll> b(q),c(q);
    map<int,int> m;
    for(int i=0; i<q; i++) cin>>b[i]>>c[i];
    ll sum=0;
    for(int i=0; i<n; i++){
        m[a[i]]++;
        sum+=a[i];   
    }
    for(int i=0; i<q; i++){
        sum-=b[i]*m[b[i]];
        sum+=c[i]*m[b[i]];
        cout<<sum<<endl;
        m[c[i]]+=m[b[i]];
        m[b[i]]=0;
    }

}

Measured memory_bytes: 10060
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

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

    int n;
    cin>>n;
    int p[n],q[n];
    ifr(i,0,n) cin>>p[i];
    ifr(i,0,n) cin>>q[i];
    int a[n],t1=-1,t2=-1,ans=0,x=0;
    ifr(i,0,n) a[i]=i+1;
    do {
    	bool f=0;
    	ifr(i,0,n) if(a[i]!=p[i]) f=1;
    	if(!f) t1 = x;f=0;
    	ifr(i,0,n) if(a[i]!=q[i]) f=1;
    	if(!f) t2 = x;
    	if(t1!=-1 && t2!=-1) {
    		ans = abs(t2-t1);
    		break;
    	}
    	x++;
    }while(next_permutation(a,a+n));
    cout<<ans<<endl;
    return 0;
}

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

#define rep(i,n)  for(int i=0;i<n;++i)
#define per(i,n)  for(int i=n-1;i>=0;--i)
#define sc1(a)  scanf("%d",&a)
#define sc2(a,b)  scanf("%d %d",&a,&b)
#define sc3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define sl1(a)  scanf("%lld",&a)
#define sl2(a,b)  scanf("%lld %lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld %lld %lld",&a,&b,&c)
#define PI 3.1415926535897932

int main(){
    char a;
    for (;;) {
        scanf("%c",&a);
        if (a=='\n' || a=='\0') break;
        if (isupper(a)) printf("%c",a+32);
        else if (islower(a)) printf("%c",a-32);
        else printf("%c",a);
    }
    puts("");
    return 0;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v) cerr << #v << ":"; rep(i, v.size()) cerr << " " << v[i]; cerr << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    for (int i = 1; i <= 5; i++) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i << endl;
            return;
        }
    }
}

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


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		System.out.println(s.substring(0, 1) + (s.length() - 2) + s.substring(s.length() - 1, s.length()));
		scan.close();

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N, T;
  cin >> N;
  T=0;
  vector<int> L(N);
  for (int i=0; i<N; i++) {
    cin >> L.at(i);
  }
  sort(L.begin(),L.end());
  for (int j=0; j<N-1; j++) {
    T=T+L.at(j);
  }
  if (T>L.at(N-1)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main()
{
 	int n;
  	cin>>n;
  	if((int)(n/1.08)*1.08==n)cout<<(int)n/1.08<<endl;
  	else
    {
      if ( ( ( (int)(n/1.08)+1 )*1.08 )< n+1 )cout<<(int)(n/1.08)+1<<endl;
      else cout<<":("<<endl;
    }
  return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		sc.close();

		if (A == B && A != C || A == C && A != B || A != B && B == C) {
			out.println("Yes");
		} else {
			out.println("No");
		}

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 21844
#include<stdio.h>

int main(void)
{
  int n;
  int h[100];
  int c=1;
  int i;
  scanf("%d",&n);
  for( i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  int max=h[0];
  
  for(i=1;i<n;i++){
    if(max<=h[i]){
      c++;
      max=h[i];
    }
  }
  printf("%d",c);
  return 0;
  
}


Measured memory_bytes: 128
SA = list(input())
SB = list(input())
SC = list(input())
A = 0
B = 0
C = 0
ans = ""
turn = "a"
while ans == "":
    if turn == "a":
        if A == len(SA):
            ans = "A"
        else:
            turn = SA[A]
        A +=1
    if turn == "b":
        if B == len(SB):
            ans = "B"
        else:
            turn = SB[B]
        B += 1
    if turn == "c":
        if C == len(SC):
            ans = "C"
        else:
            turn = SC[C]
        C += 1
print(ans)

Measured memory_bytes: 9156
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC177
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ');
            if (A.Contains("0"))
            {
                System.Console.WriteLine(0);
                return;
            }

            ulong limit = (ulong)Math.Pow(10, 18);

            ulong answer = 1;

            for (int i = 0; i < N; i++)
            {
                if (answer <= limit / ulong.Parse(A[i]))
                {
                    answer *= ulong.Parse(A[i]);
                }
                else
                {
                    System.Console.WriteLine(-1);
                    return;
                }
            }

            System.Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 40844
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("abaababaab");
            //6
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("xxxx");
            //2
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("abcabcabcabc");
            //6
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("akasakaakasakasakaakas");
            //14
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static string mS;

    static void Main()
    {
        List<string> InputList = GetInputList();
        mS = InputList[0];

        for (int I = 1; I <= mS.Length; I++) {
            if (IsGuubunStr(I)) {
                Console.WriteLine(mS.Length - I);
                break;
            }
        }
    }

    //末尾N文字を削った文字が偶文字列かを判定
    static bool IsGuubunStr(int pN)
    {
        string wkStr = mS.Substring(0, mS.Length - pN);
        int WkLength=wkStr.Length;
        if (WkLength % 2 == 1) return false;

        string FirstStr=wkStr.Substring(0,WkLength/2);
        string LastStr=wkStr.Substring(WkLength/2,WkLength/2);

        return FirstStr == LastStr;
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<time.h>
#include<cmath>
#include<vector>
using namespace std;

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

	if (s == "ABC")
		cout << "ARC";
	else if (s == "ARC")
		cout << "ABC";
	cout << endl;
}


Measured memory_bytes: 3596
n = int(input())
info = [[str(x) for x in input().split()] for _ in range(n)]
taro, hanako = 0, 0
for x, y in info:
    if x > y:
        taro += 3
    elif x < y:
        hanako += 3
    else:
        taro += 1
        hanako += 1
print(taro, hanako)


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

typedef pair<double, string> P;

void solve(int n){
	vector<P> v;
	for(int i=0; i<n; ++i){
		string s;
		cin >> s;
		int a[9];
		for(int j=0; j<9; ++j)
			cin >> a[j];
		int b = a[8] * a[7] * a[6] - a[0];
		int c = a[1] + a[2] + a[3] + a[8] * (a[4] + a[5]);
		double d = 0.0;
		if(b == 0) d = 1e9;
		else d = -(double)b/c;
		v.push_back(P(d, s));
	}
	sort(v.begin(), v.end());
	for(int i=0; i<n; ++i){
		cout << v[i].second << "\n";
//		cout << v[i].first << "\n";
	}
	cout << "#\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int n;
		cin >> n;
		if(n == 0) return 0;
		solve(n);
	}
}


Measured memory_bytes: 3176
/*
 * Problem Description: Areas on the Cross-Section Diagram
 * Category:
 * Author: Khan
 * Date: 13th October, 2017
 */

//#include <stdio.h>
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum = 0;
    for (int i = 0; cin >> ch; ++i)
    {
        if(ch == '\\')
            S1.push(i);
        else if(ch == '/' && S1.size() > 0)
        {
            int j = S1.top();
            S1.pop();
            sum += i - j;
            int a = i - j;
            while(S2.size() > 0 && S2.top().first > j)
            {
                a += S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }
    vector<int> ans;
    while(S2.size() > 0)
    {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for (int i = 0; i < ans.size(); ++i)
    {
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3200
s=input()
n=len(s)
alp=[chr(i+ord('a')) for i in range(26)]
a=[[0]*n for _ in range(26)]
for i in alp:
  ans=-2
  for j in range(n):
    if s[j]==i:
      if ans<-1:
        ans=0
        l=j
      else:ans+=1
    else:ans-=1
    if ans>0 or (j>1 and s[j-2]==s[j]==i):
      print(l+1,j+1)
      exit()
print(-1,-1)

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

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            int intN = int.Parse(Console.ReadLine());
            string strS = Console.ReadLine();
            
            string ret = string.Empty;

            char[] charList = strS.ToCharArray();
            if (intN % 26 != 0)
            {
                byte addN = (byte)(intN % 26);
                for (int i = 0; i < charList.Length; i++)
                {
                    charList[i] = (char)(charList[i] + addN);
                    if (charList[i] > 'Z')
                    {
                        charList[i] = (char)(charList[i] - 26);
                    }
                }
            }

            Console.WriteLine(charList);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11176
from collections import defaultdict


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        d = {}
        for i in range(self.n):
            p = self.find(i)
            if p in d:
                d[p].append(i)
            else:
                d[p] = [i]
        return d

    def __str__(self):
        return '\n'.join('{}: {}'.format(k, v) for k, v in self.all_group_members().items())


def resolve():
    n, m, k = map(int, input().split())
    u = UnionFind(n)
    d = defaultdict(int)
    e = defaultdict(int)
    for _ in range(m):
        a, b = [int(x) - 1 for x in input().split()]
        u.union(a, b)
        d[a] += 1
        d[b] += 1
    for _ in range(k):
        a, b = [int(x) - 1 for x in input().split()]
        if u.same(a, b):
            e[a] += 1
            e[b] += 1
    ans = [0] * n
    for i, v in u.all_group_members().items():
        x = len(v) - 1
        for j in v:
            ans[j] = x-d[j] - e[j]
    print(*ans)


if __name__ == '__main__':
    resolve()


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

int main(){
    int rep;
    cin >> rep;
    for(int r=0; r<rep; r++){
        int n;
        cin >> n;
        vector<int> h(n);
        for(int i=0; i<n; i++) cin >> h[i];
        int up=0, down=0;
        for(int i=0; i<n-1; i++){
            if(h[i] < h[i+1]){
                up = max(up, h[i+1]-h[i]);
            }else{
                down = max(down, h[i]-h[i+1]);
            }
        }
        cout << up << " " << down << endl;
    }
    return 0;
}



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

int main(){
	char memA[1024],memB[1024],result[1024];
	char *PA=memA,*PB=memB,*PC;
	int A,B,C,D;
	for(scanf("%d",&D);D>=1;D--){
		scanf("%s",PA);
		scanf("%s",PB);
		if((A=strlen(PA)-strlen(PB))<0){
			PC=PA;
			PA=PB;
			PB=PC;
			A*=-1;
		}
		for(;A>0;A--){
			for(B=strlen(PB);B>=0;B--)
				PB[B+1]=PB[B];
			PB[0]='0';
		}
		for(B=strlen(PB);B>=0;B--){
				PB[B+1]=PB[B];
				PA[B+1]=PA[B];
		}
		PB[0]='0';PA[0]='0';
		PC=result;
		PC[strlen(PA)]=0;
		B=0;C=0;
		for(A=strlen(PA)-1;A>=0;A--){
			B=(int)(PA[A]-'0')+(int)(PB[A]-'0')+C;
			C=(int)(B/10);
			B=B%10;
			PC[A]=(char)(B)+'0';
		}
		PC=(*PC=='0')?PC+1:PC;
		if(strlen(PC)<=80)
			printf("%s\n",PC);
		else
			printf("overflow\n");
	}
 	return 0;
}

Measured memory_bytes: 592
n=list(map(int,input().split()))
a=[]
for m in range(n[0]):
    a.append(list(map(int,input().split())))
    
count=0
output=[]
for i in range(n[0]-1):
    for j in range(n[1]):
        if a[i][j]%2==1:
            count += 1
            output.append("{0} {1} {2} {3}".format(i+1,j+1,i+2,j+1))
            a[i][j] -= 1
            a[i+1][j] += 1

for j in range(n[1]-1):
    if a[n[0]-1][j]%2==1:
        count += 1
        output.append("{0} {1} {2} {3}".format(n[0],j+1,n[0],j+2))
        a[n[0]-1][j] -= 1
        a[n[0]-1][j+1] += 1 

print(count)
for t in range(len(output)):
    print(output[t])

Measured memory_bytes: 16380
s = input().rstrip()
n = len(s)

x1 = 0
x2 = 0
for i in range(n):
    if i % 2 == 0:
        if s[i] == '1':
            x1 += 1
        else:
            x2 += 1
    elif i % 2 == 1:
        if s[i] == '0':
            x1 += 1
        else:
            x2 += 1

print(min(x1, x2))

Measured memory_bytes: 3188
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N, K = LI()
    RSP_score = LI()
    rsp_num = {'r': 0, 's': 1, 'p': 2}
    T = [rsp_num[i] for i in S()]

    # dp[i][j]: i回目にjを出したときの合計点数
    # Kのmod毎に独立
    dp = [[0] * 3 for _ in range(N)]
    for i in range(N):
        for j in range(3):
            # グーを出す場合、K回前までにグー以外出したときの最大得点に加えて、今回相手がチョキだったら勝点Rを足す
            if i - K >= 0:
                dp[i][j] += max([dp[i-K][k] for k in range(3) if k != j])
            if (j + 1) % 3 == T[i]:
                dp[i][j] += RSP_score[j]

    # for i in dp:
    #     print(i)
    ans = sum([max(i) for i in dp[N-K:]])
    print(ans)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 29520
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int a, b;
	cin >> a >> b;
	if ((a*b) % 2 == 0)
	{
		cout << "Even" << endl;
	}
	else
	{
		cout << "Odd" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
T = [int(input()) for _ in range(5)]
U = [T[i] for i in range(5)]

for i in range(5):
    if T[i] % 10 == 0:
        T[i] = 10
    else:
        T[i] %= 10
    U[i] += (10-T[i])

ans = sum(U)

T.sort()
ans -= (10-T[0])

print(ans)


Measured memory_bytes: 9176
def sol():
    import sys
    input=sys.stdin.readline
    h,w,n=map(int,input().split())
    d={}
    t=[(0,0),(0,1),(0,2),(1,0),(1,1),(1,2),(2,0),(2,1),(2,2)]
    for i in range(n):
        y,x=map(int,input().split())
        for a,b in t:
            a+=y
            b+=x
            if 0<a<=h and 0<b<=w and (a,b) in d: d[(a,b)]+=1
            elif 0<a<=h and 0<b<=w: d[(a,b)]=1

    ans=[0]*10
    for i in d:
        if i[0]>2 and i[1]>2:
            ans[d[i]]+=1

    ans[0]=h*w-sum(ans)-w*2-h*2+4
    for i in ans:
        print(i)

if __name__=="__main__":
    sol()

Measured memory_bytes: 139512
// SPDX-License-Identifier: X11
// 2020-08-15

#include <stdio.h>

int main() {
  int M = 0,
      c = 0;

  for (char i = 0; i < 3; ++i) {
    if (getchar() == 'R')
      ++c;
    else
      c = 0;

    if (c > M)
      M = c;
  }

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


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

#define check(val) std::cout << "\033[31m" << #val << ": " << val << "\033[m" << std::endl
#define check_v(vec) \
  std::cout << "\033[31m" << #vec << ": [ ";\
  for(auto it=vec.begin(); it!=vec.end(); it++){cout << *it << " ";}\
  cout << "]"<< "\033[m" << endl;

int main() {
  double l;
  cin >> l;
  double x = l / 3.0;
  printf("%.16f\n", x * x * x);
    
  return 0;
}


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

static const size_t H_MAX = 500000;
static int A[H_MAX+1];

int main() {
  size_t H;
  scanf("%zu", &H);
  for (size_t i = 1; i <= H; i++)
    scanf("%d\n", A + i);
  for (size_t i = H / 2; i >= 1; i--)
    for (auto j = i;;) {
      size_t l = 2 * j, r = 2 * j + 1, k;
      if (l <= H && A[l] > A[j])
        k = l;
      else
        k = j;
      if (r <= H && A[r] > A[k])
        k = r;
      if (j == k)
        break;
      std::swap(A[j], A[k]);
      j = k;
    }
  for (size_t i = 1; i <= H; i++)
    printf(" %d", A[i]);
  puts("");
  return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

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

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

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

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

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int m, n;
bool check(vector<int> v,int mid){
  int h = 1;
  int w = 0;
  rep(i,n){
    if(v[i] > mid){
      return false;
    }
    if(w + v[i] <= mid){
      w += v[i];
    }
    else{
      w = v[i];
      ++h;
    }
  }
  if(h > m){
    return false;
  }
  return true;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(cin >> m >> n&&m&&n){
    vary(int,v,n,0);
    rep(i,n){
      cin >> v[i];
    }
    int lb = 0,ub = 1500000;
    while(1){
      int mid = (lb+ub)/2;
      if(mid == lb) break;
      if(check(v,mid)){
        ub = mid;
      }
      else{
        lb = mid;
      }
    }
    cout << ub << endl;
  }
  return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;

    if(a < b){
        for(int i = 0; i < b; i++){
            cout << a;
        }
    }else{
        for(int i = 0; i < a; i++){
            cout << b;
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
int main(void)
{
  while(1){
    int n;
    int d[111][111];
    scanf("%d",&n);
    if(!n) break;
    memset(d,0,sizeof(d));
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
	scanf("%d",&d[i][j]);
	d[n][j] += d[i][j];
	d[i][n] += d[i][j];
	d[n][n] += d[i][j];
      }
    }
    for(int i = 0; i <= n; i++){
      for(int j = 0; j <= n; j++){
	printf("%5d",d[i][j]);
      }
      puts("");
    }
  }
}

Measured memory_bytes: 1100