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


int main (){
    string S;
    long long K;
    cin>>S>>K;
    int size=S.size();
    long long same=0;
    long long samemini=0;
    long long samezero=0;
    bool samezerob = true;
    for(int i=0; i<size-1; i++){
        if(S.at(i)==S.at(i+1)){
            samemini ++;
            if(samezerob){
                samezero ++;
            }
        }
        else{
            same += (samemini+1)/2;
            samemini = 0;
            samezerob = false;
        }
    }
    if(!(S.at(0)==S.at(size-1))){
        same += (samemini+1)/2;
        cout<<K*same<<endl;
    }
    else if(samezero+1==size){
      	cout<<(size*K)/2<<endl;
      	
    }
  	else{
        same-=(samezero+1)/2;
      	same+=(samezero+samemini+2)/2;
      //cout<<(samezero+samemini+2)/2<<endl;
      //cout<<samezero<<samemini<<endl;
      cout<<same*K-(samezero+samemini+2)/2+(samezero+1)/2+(samemini+1)/2<<endl;
    }
  	

}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const int MOD = 1000000007;
long long ruijo(int x, int n) {
    long long res = 1;
    rep(i, 0, n) { res *= x; }
    return res;
}
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for(long long i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}
int main() {
    long long N, M;
    cin >> N >> M;
    vector<long long> yaku = divisor(M);
    long long max = 0;
    rep(i, 0, yaku.size()) {
        if(M / yaku[i] >= N) {
            chmax(max, yaku[i]);
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

void rotateDice( int *dice, char ins )
{
	int tdice[7];
	int i;

	for( i=0; i<6; i++ ) {
    	tdice[i]=dice[i];
    }
	if( 'E' == ins ) {
		tdice[3-1]=dice[1-1];
		tdice[4-1]=dice[6-1];
		tdice[6-1]=dice[3-1];
		tdice[1-1]=dice[4-1];
	} else if( 'W' == ins) {
		tdice[4-1]=dice[1-1];
		tdice[3-1]=dice[6-1];
		tdice[1-1]=dice[3-1];
		tdice[6-1]=dice[4-1];
	} else if( 'N' == ins ) {
		tdice[5-1]=dice[1-1];
		tdice[2-1]=dice[6-1];
		tdice[1-1]=dice[2-1];
		tdice[6-1]=dice[5-1];
	} else if( 'S' == ins ) {
		tdice[2-1]=dice[1-1];
		tdice[5-1]=dice[6-1];
		tdice[6-1]=dice[2-1];
		tdice[1-1]=dice[5-1];
	}
   	for( i=0;  i<6; i++ ) {
		dice[i]=tdice[i];
	}
	
	return;
}

int isDiffDice( int *dice, int *dice2 )
{    
 	int i;
 	int top = dice[0];
 	int diff=0;
 		
	if( top!=dice2[0] ) {
		for( i=0; i<3; i++ ) {
			rotateDice( dice2, 'N' );
			if( top==dice2[0] ) {
				break;
			}
		}
	}

	if( top!=dice2[0] ) {		
		for( i=0; i<3; i++ ) {
			rotateDice( dice2,  'E' );
			if( top==dice2[0] ) {
				break;
			}
		}
	}


    if( top!=dice2[0] ) {
		diff=1;
	} else {	
		rotateDice( dice, 'W' );
		rotateDice( dice2, 'W' );
		top=dice[0];
		for( i=0; i<3; i++ ) {
			rotateDice( dice2,  'N' );
			if( top==dice2[0] ) {
				break;
			}
		}		
	}
    
    for( i=0; i<6; i++ ) {
    	if( dice[i] != dice2[i] ) {
			diff=1;
			break; 
    	}
    }
    
    return diff;
}

int main( void ) 
{
	int dice[101][7];
	int i,j;
	int n;
	
	scanf( "%d", &n );
	for( i=0;  i<n; i++ ) {
	 	for( j=0;  j<6; j++ ) {
			scanf( "%d", &dice[i][j] );
		}
    }
    int count=0;
    for( i=0; i<n-1; i++ ) {
    	for( j=i+1; j<n; j++ ) {
    		count+=( !isDiffDice( dice[i], dice[j] ) );
	    }
    }
    
    if( 1<= count ) {
    	printf( "No\n" );
    } else {
    	printf( "Yes\n" );
    }
    
	return 0;
}

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

using namespace std;

int main(){
  long long n; cin >> n;
  long long mini = 11111111111110;
  for(long long i=1;i<=sqrt(n);i++){
      if(n%i==0){
       long long j = n/i;
       mini = min(mini, i-1+j-1);
      }
  }
  cout << mini << endl;
}


Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


int n, a, b, c, soa[105], sob[105], syoc[105], exi[105], ans;
int main() {
	cin >> n >> a;
	for (int i = 0; i < a; ++i) {
		int m;
		cin >> m;
		soa[m - 1] = 1;
	}
	cin >> b;
	for (int i = 0; i < b; ++i) {
		int m;
		cin >> m;
		sob[m - 1] = 1;
	}
	cin >> c;
	for (int i = 0; i < c; ++i) {
		int m;
		cin >> m;
		syoc[m - 1] = 1;
	}

	for (int i = 0; i < n; ++i) {
		if (!exi[i] && syoc[i] && (!soa[i] || sob[i])) { ++ans; exi[i] = 1; }
	}
	cout << ans << endl;
}


Measured memory_bytes: 3128
# ABC065 B - Trained?
N = int(input())
A = [[int(input()),False] for i in range(N)]
idx = 0
A[0][1] == True
cnt = 1

while cnt != N+1:
    if A[idx][1]:
        print(-1)
        exit()
    if A[idx][0] == 2:
        print(cnt)
        exit()
    A[idx][1] = True
    idx = A[idx][0]-1
    cnt += 1


Measured memory_bytes: 16500
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main() {
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3596
import java.util.*;
class Main {
 
	public static void main(String[] args) {
	     Scanner sc = new Scanner(System.in);
	      int H = sc.nextInt();
	      int W = sc.nextInt(); sc.nextLine(); //nextIntの後残る改行文字を消す
	      String[] line = new String[H];
	      boolean flag = true;
	      for(int i=0;i<H;i++){
	      	line[i]=sc.nextLine();
	      } 
	      char[][] a = new char[H][W];
	      char[][] b = new char[H+2][W+2];
	         for(int j=0;j<W;j++){
	          for(int k=0;k<H;k++){
	           a[k][j]=line[k].charAt(j);
	           b[k+1][j+1]=a[k][j];
	          }
	         }
	         sc.close();
	         for(int j=0;j<W+2;j++){
	          for(int k=0;k<H+2;k++){
	           b[0][j]='.';
	           b[H+1][j]='.';
	           b[k][0]='.';
	           b[k][W+1]='.';
	          }
	         }
	          
	         for(int j=1;j<W+1;j++){
	          for(int k=1;k<H+1;k++){
	          if(b[k][j]=='#'&&b[k+1][j]=='.'&&b[k-1][j]=='.'&&b[k][j+1]=='.'&&b[k][j-1]=='.'&&flag==true){
	                                       flag=false;
	                      }
	           }
	          }
	           if(!flag){
	                 System.out.println("No");
	           }else{
	                 System.out.println("Yes");      
	           }
    }
 
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define MAX 100010
#define inf 1<<28
using namespace std;

typedef pair<int,int> pii;

class edge{
public:
  int to,cost;
  bool b;
  edge(int to,int cost,bool b):to(to),cost(cost),b(b){}
};

class State{
public:
  int n,cost,sum;
  State(int n,int cost,int sum):n(n),cost(cost),sum(sum){}
  bool operator<(State s)const{
    if(cost!=s.cost)return s.cost<cost;
    return s.sum<sum;
  } 
};

vector<pair<int,int> > v[MAX];
int n,t,c[MAX];
map<string,vector<int> > m;
string a,b,s[MAX];
set<int> st;
vector<int> start,end;
pii dis[MAX];
priority_queue<State> pq;
map<int,vector<int> > M;
map<string,int> Ma;
int canp[MAX];

pii dijkstra(){
  for(int i=0;i<MAX;i++){
    dis[i].f=inf;
    dis[i].s=inf;
  }
 
  for(int i=0;i<end.size();i++)st.insert(end[i]);
  for(int i=0;i<start.size();i++){
    pq.push(State(start[i],0,0));
    dis[start[i]]=mp(0,0);
  }    

  while(!pq.empty()){
    State u=pq.top();
    pq.pop();

    if(st.find(u.n)!=st.end())return mp(u.cost,u.sum);

    if(dis[u.n]<mp(u.cost,u.sum))continue;

    for(int i=0;i<v[u.n].size();i++){
      int next=v[u.n][i].f,cost=dis[u.n].f+v[u.n][i].s,sum=dis[u.n].s;
      if(mp(cost,sum)<dis[next]){
	dis[next]=mp(cost,sum);
	pq.push(State(next,cost,sum));
      }
    }
    vector<int> vi=M[canp[u.n]];
    for(int i=0;i<vi.size();i++){
      if(vi[i]==u.n)continue;
      int next=vi[i],cost=dis[u.n].f+t,sum=dis[u.n].s+1;
      if(mp(cost,sum)<dis[next]){
	dis[next]=mp(cost,sum);
	pq.push(State(next,cost,sum));
      }
      }
  }
  return mp(-1,-1);
}

int main()
{
  int k,count1=0,count2=0;

  cin>>n>>t;
  cin>>a>>b;

  for(int i=0;i<n;i++){
    cin>>k;
    for(int j=0;j<k;j++)cin>>s[j];
    for(int j=0;j<k-1;j++)cin>>c[j];
    for(int j=0;j<k-1;j++){
      //add(count1,s[j]);
      int con;      
      if(Ma.find(s[j])==Ma.end()){
	count2++;
	con=count2;
	Ma[s[j]]=count2;
      }
      else con=Ma[s[j]];
      M[con].push_back(count1);
      canp[count1]=con;
	       
      v[count1].push_back(mp(count1+1,c[j]));
      v[count1+1].push_back(mp(count1,c[j]));
      if(s[j]==a)start.push_back(count1);
      if(s[j]==b)st.insert(count1);
      count1++;
    }
    //add(count1,s[k-1]);
    
    int con;
    if(Ma.find(s[k-1])==Ma.end()){
      count2++;
      con=count2;
      Ma[s[k-1]]=count2;
    }
    else con=Ma[s[k-1]];
    M[con].push_back(count1);
    canp[count1]=con;
    if(s[k-1]==a)start.push_back(count1);
    if(s[k-1]==b)st.insert(count1);
    count1++;
  }

  pii p=dijkstra();
  if(p==mp(-1,-1))cout<<-1<<endl;
  else cout<<p.f<<" "<<p.s<<endl;

  return 0;
}

Measured memory_bytes: 24756
import java.util.*;
import java.io.*;

public class Main {
    private static IO io = new IO();
    
    public static void main(String[] args) {
        int n = io.nextInt();
        int ans = 0;
        for (int i = 1; i*i <= n; i++) {
            if (i*i>n) break;
            ans = i*i;
        }
        System.out.println(ans);
    }

    static class IO extends PrintWriter {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        IO() {
            this(System.in);
        }

        IO(InputStream source) {
            super(System.out);
            this.in = source;
        }

        boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }
        int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }
        boolean isPrintableChar(int c) {return 33<=c &&c <=126;}
        void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;}
        boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }

        int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public void close() {
            super.close();
            try {
                in.close();
            } catch (IOException ignored) {
            }
        }
    }
}


Measured memory_bytes: 23124
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll n=in(),k=in(),q=in();
    vector<ll>seikai(n,0);
    for(ll i=0;i<q;++i)++seikai[in()-1];
    for(ll i=0;i<n;++i)cout<<(q-seikai[i]<k?"Yes":"No")<<endl;
}


Measured memory_bytes: 1408
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iostream>

using namespace std;

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

	int l = s.length();
	int ans = 800;
	for (int i = 0; i < l - 2; i++) {
		int a = s[i] - '0';
		int b = s[i + 1] - '0';
		int c = s[i + 2] - '0';
		int x = a * 100 + b * 10 + c;
		ans = min(ans, abs(x - 753));
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
date = list( map( int, input().split('/') ) )

if date[0] < 2019:
    print('Heisei')
elif date[0] == 2019 and date[1] < 4:
    print('Heisei')
elif date[0] == 2019 and date[1] == 4 and date[2] <= 30:
    print('Heisei')
else:
    print('TBD')

Measured memory_bytes: 38256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll n,l;
  cin >> n >> l;
  str s[n];
  REP(i,n){
    cin >> s[i];
  }
  sort(s,s+n);
  str ans;
  REP(i,n){
    ans+=s[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

ll mymul(ll a, ll b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  ll ans = mymul(a,b/2);
  ans *= ans;
  ans %= MOD;
  if (b & 1) ans *= a;
  return ans % MOD;
}

void solve() {
  string s;
  cin >> s;
  ll len = sz(s);
  ll ans = 0;
  ll base = 1;
  REP(i,sz(s)-1) {
    if (s[i] == '1') {
      //0の場合
      ans += base * mymul(3, len - i - 1) % MOD;
      ans %= MOD;
      //1の場合
      base *= 2;
      base %= MOD;
    }
  }
  if (s[len-1] == '1') {
    ans += 3 * base;
    ans %= MOD;
  } else {
    ans += base;
    ans %= MOD;
  }
  cout << ans << endl;
}

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

  /*Regular*/
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }

  // /*ICPC*/
  // while (cin >> t >> d >> l, t) {
  //   solve();
  // }

  //solve();
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007


    
int main()
{
    
 ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j,k;
    cin>>n;
    ll h[n][3];
    ll dp[n][3];
    for(i=0;i<n;i++)
    {
        cin>>h[i][0]>>h[i][1]>>h[i][2];
        dp[i][0]=0;
        dp[i][1]=0;
        dp[i][2]=0;
    }
   
   dp[0][0]=h[0][0];
   dp[0][1]=h[0][1];
   dp[0][2]=h[0][2];
   for(i=1;i<n;i++)
   {
       dp[i][0]=h[i][0]+max(dp[i-1][1],dp[i-1][2]);
       dp[i][1]=h[i][1]+max(dp[i-1][0],dp[i-1][2]);
       dp[i][2]=h[i][2]+max(dp[i-1][1],dp[i-1][0]);       
   }
    cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2])<<endl;
    return 0;
   
}

Measured memory_bytes: 4992
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

const int INF = 1 << 30;
const int MAX = 2000;

int main() {
	int N, K, Q;
	int A[MAX];
	int ans = INF;
	pair<int, int> p[MAX];
	bool check[MAX] = { false };

	cin >> N >> K >> Q;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		p[i].first = A[i];
		p[i].second = i;
	}

	sort(p, p + N);

	for (int i = 0; i < N;) {
		int m = p[i].first;
		vector<int> v1;

		for (int b = 0; b < N;b++){
			int e = b;
			while (e < N && !check[e])e++;

			if (e - b >= K) {
				vector<int> v2;
				while (b < e)v2.push_back(A[b++]);

				sort(v2.begin(), v2.end());
				for (int j = 0; j <= v2.size() - K; j++)v1.push_back(v2[j]);
			}
			b = e;
		}

		sort(v1.begin(), v1.end());
		if (v1.size() >= Q) {
			ans = min(ans, v1[Q - 1] - m);
		}

		while (i < N && p[i].first == m) {
			check[p[i].second] = true;
			i++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

typedef long long ll;
typedef pair<int, int> P;

int main(){
  int num=0;
  
  scanf("%d", &num);
  
  int ac=0,wa=0,tle=0,re=0;
  
  for(int i=0;i<num;i++){
    string str;
    cin>>str;
    if(str=="AC")ac++;
    if(str=="WA")wa++;
    if(str=="TLE")tle++;
    if(str=="RE")re++;
  }
  
  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",ac,wa,tle,re);
  
  return 0;
}


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

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

    int ans = 0;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        if (sqrt(x * x + y * y) <= d) ans++;
    }

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


Measured memory_bytes: 3672
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
   int a,b;
   cin >> a >>b;
   int ans=0;
   for(int i=0;i<2;i++){
   if(a>b){
        ans += a;
        a--;
       }
       else{ ans += b;
      b--;
      }
   }
   cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    long h, w;
    long result;

    scanf("%ld %ld", &h, &w);

    if (h == 1 || w == 1) {
        printf("1\n");
        return 0;
    }
    
    if (h % 2 == 0) {
        result = (h / 2) * w;
    } else if (w % 2 == 0) {
        result = h * (w / 2);
    } else {
        result = (h * w) / 2 + 1;
    }

    printf("%ld\n", result);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;
int H, W;
vector<string> fi;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    cin >> H >> W;
    fi.resize(H);
    for(int i = 0; i < H; ++i) cin >> fi[i];

    vector<vector<int> > dist(H, vector<int>(W, -1));
    using pint = pair<int, int>;
    queue<pint> que;
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            if (fi[i][j] == '#') {
                dist[i][j] = 0;
                que.push(pint(i, j));
            }
        }
    }

    while(!que.empty()){
        auto cur = que.front();
        que.pop();
        for(int dir = 0; dir < 4; ++dir){
            int nx = cur.first + dx[dir];
            int ny = cur.second + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (dist[nx][ny] == -1){
                dist[nx][ny] = dist[cur.first][cur.second] + 1;
                que.push(pint(nx, ny));
            }
        }
    }

    int res = 0;
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            res = max(res, dist[i][j]);
        }
    }

    cout << res << endl;



}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S, T;
  cin >> S;
  reverse(S.begin(), S.end());
  S.push_back('0');
  T = S;
  int res = 0;
  for (int i = 0; i < (int)S.size(); i++) {
    if (T[i] - '0' > 5 || (T[i] == '5' && T[i + 1] - '0' >= 5)) {
      res += 10 - (T[i] - '0');
      int p = i + 1;
      while (T[p] == '9') {
        T[p++] = '0';
      }
      T[p] = T[p] + 1;
    } else {
      res += T[i] - '0';
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 2332
#include <iostream>
using namespace std;
const int MAX = 100010;
int  T[MAX], A[MAX];
int n,q;
int binarysearch(int key) {
	int left = 0;
	int right = n;
	int mid;
	while (left < right) {
		mid = (right + left) / 2;
		if (A[mid] == key)
			return 1;
		if (A[mid] < key)
			left = mid + 1;
		else if (key < A[mid])
			right = mid;

	}
	return 0;
}

int hikaku(int B[]) {
	int ret,i;
	ret = 0;
	for (i = 0; i < q; ++i) {

		if (binarysearch(B[i])) {
			ret++;
		}
	}
	return ret;
}
void solve() {
	int k, ans;
	cin >> n;
	for (k = 0; k < n; ++k) {
		cin >> A[k];
	}
	cin >> q;
	for (k = 0; k < q; ++k) {
		cin >> T[k];
	}
	ans = hikaku(T);
	cout << ans << endl;
}
int main() {
	solve();

	return 0;
}

Measured memory_bytes: 3596
#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)

typedef long long ll;

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  REP(i, N){
    cin >> L[i];
  }
  int cnt = 1, D = 0;
  REP(i, N){
    D = D + L[i];
    if(D <= X){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

int main() {
    int N, num;
    vector<int> number;
    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> num;
        number.push_back(num);
    }
    int count = 0;

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

    num = number[0];
    int num_count = 1;
    for (int i = 1; i < number.size(); i++) {
        if (number[i] == num) num_count++;
        else {
            if (num_count % 2 == 1) count++;
            num = number[i];
            num_count = 1;
        }
    }
    if (num_count % 2 == 1) count++;
    
    cout << count << endl;

    return 0;

}

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

using namespace std;
using ll = long long;

int main() {
#ifdef LOCAL
    freopen("in1.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
#endif

    string s;
    cin >> s;
    bool R = false;
    int r = 0;
    int ans = -1;
    for(int i=0;i<3;i++){
        if(s[i] == 'R'){
            if(R) r++;
            else {
                R = true;
                r = 1;
            }
            ans = max(r , ans);
        }
        else {
            R = false;
            ans = max(r , ans);
            r = 0;
        }
    }
    cout<< ans << endl;
    return 0;
}

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

using namespace std;
int main(){
    string a;
    int seq[500005], n, x=-1;
    long long final =0;
    cin >> a;
    n=a.size();
    seq[0]=0;
    for(int i=0; i<n; i++){
        if(a[i]=='<'){
            if(x==1){
                seq[i+1]=1;  
                x=0;
            }
            else{
                seq[i+1]=seq[i]+1;
                x=0;
            }
        }
        else{
            if(x==0){
                seq[i+1]=0;
                x=1;
            }
            else{
                seq[i+1]=0;
            }
        }
    }
    
    for(int i=n-1; i>=0; i--){
        if(a[i]=='>'){
            if(seq[i]<=seq[i+1]){
                seq[i]=seq[i+1]+1;
            }
        }
    }
    for(int i=0; i<=n; i++){
        final+=seq[i];
    }
    cout << final << endl;
    return 0;
}

Measured memory_bytes: 5848
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

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

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

        if x == y:
            return False
        else:
            if self.d[x] > self.d[y]:
                x, y = y, x
            self.d[x] += self.d[y]
            self.d[y] = x
            return True

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


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


N, M = map(int,input().split())
uf = UnionFind(N)
for i in range(M):
    A,B = map(int,input().split())
    A -= 1
    B -= 1
    uf.unite(A,B)
ans = 0
for i in range(N):
    ans = max(ans,uf.size(i))
print(ans)



Measured memory_bytes: 76136
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int M = in.nextInt();
            int K = in.nextInt();

            if (K == 0) {
                StringBuilder sb = new StringBuilder();
                for (int i = 0, I = 1 << (M); i < I; i++) {
                    sb.append(" " + i + " " + i);
                }
                System.out.println(sb.toString().trim());
                return;
            }

            int xor = 0;
            for (int i = 0, I = 1 << (M); i < I; i++) {
                if (i == K) {
                    continue;
                }
                xor ^= i;
            }

            if (xor == K) {
                StringBuilder sb = new StringBuilder();
                for (int i = 0, I = 1 << (M); i < I; i++) {
                    if (i == K) {
                        continue;
                    }
                    sb.append(" " + i);
                }
                sb.append(" " + K);
                for (int i = (1 << (M)) - 1; i >= 0; i--) {
                    if (i == K) {
                        continue;
                    }
                    sb.append(" " + i);
                }
                sb.append(" " + K);
                System.out.println(sb.toString().trim());
            } else {
                System.out.println(-1);
            }
        }
    }
}


Measured memory_bytes: 52132
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val x = sc.nextInt()
    var ans = 0
    for (ai in 0..a) {
        for (bi in 0..b) {
            for (ci in 0..c) {
                val sum = ai * 500 + bi * 100 + ci * 50
                if (sum == x) ans++
            }
        }
    }
    println(ans)
}

Measured memory_bytes: 31392
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(a, b) for (ll i = a; i <= b; i++)
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
#define N 200005
const ll INF = 1000000000000000001;
const ll MOD = 1000000007;

//vector< vector<ll> > g(N);
//vector< pair<ll, pair< ll, ll > > > g(N);
//ll vis[N] = {0}, par[N] = {0}, child[N] = {0},cnt = 0;


void solve(){
    ll n; cin>>n;
    string ans ="";
    while(n ){
        char s = 'a' + (n%26) -1;
        n /= 26;
        if(s == 'a' - 1 ) s = 'z', n--;
        ans += s;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << "\n"; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
   //ll t;cin >> t;for(ll index=1; index<=t; index++){
        //cout << "Case #" << index << ": " ;
        solve();
   // }
    return 0;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;

int main() {
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	double area = (double)W * H / 2;
	cout << area << " ";
	if (W == 2 * x and H == 2 * y)
		cout << 1 << endl;
	else
		cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using ll = long long;
using namespace std;

int main() {
    ll n;
    cin >> n;
    ll count = 0;
    rep(i, n) {
        if (i % 3 != 0) {
            if (i % 5 != 0) {
                count += i;
            }
        }
    }
    cout << count << endl;
    return 0;
}

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

int main(){
    int n,y;
    cin>>n>>y;
    rep(i,n+1){
        rep(j,n+1){
            int k=n-i-j;
            if(k<0)continue;
            if(i*10000+j*5000+k*1000==y){
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    ll n;
    cin >> n;


    string s;

    while (n!=0) {
        n -= 1;

        ll k = n % 26;

        s += 'a' + k;
        

        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
}

Measured memory_bytes: 3588
n=int(input())
s=[]
for i in range(n):
  s.append(input())
m=int(input())
t=[]
for i in range(m):
  t.append(input())
from collections import Counter
s=Counter(s)
t=Counter(t)
ans=0
for i in s:
  ans=max(ans,s[i]-t.get(i,0))
for i in t:
  ans=max(ans,-t[i]+s.get(i,0))

print(ans)
          
  

Measured memory_bytes: 9436
#include <bits/stdc++.h>
using namespace std;
signed main(){
  string s , t;
  bool f=true;
  char s_alp[26] , t_alp[26];
  cin>>s>>t;
  
  for(int i=0;i<26;i++){
    s_alp[i] = '_' , t_alp[i] = '_';
  }
  

  for(int i=0;i<s.size();i++){
    if(s_alp[s[i]-'a'] != '_' && s_alp[s[i]-'a'] != t[i]){
      f=false;
    } else if (t_alp[t[i]-'a'] != '_' && t_alp[t[i]-'a'] != s[i]){
      f=false;
    }
    t_alp[t[i]-'a'] = s[i] , s_alp[s[i]-'a'] = t[i];
  }
  if(f){
    cout<<"Yes\n";
  } else {
    cout<<"No\n";
  }
  return(0);
}

Measured memory_bytes: 776
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
ans=0
for i in range(1,n):
  # 町(i-1)から町iに行く方法を考えてみよう～～～
  toho = a * (x[i] - x[i-1])
  tele = b
  ans += min(toho, tele)
print(ans)


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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int cnt = 0;
    rep(i, n - 1){
        if (s[i] != s[i + 1]) cnt ++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
def solve(n, m):
    ret = 1
    for i in range(1, int(m ** 0.5) + 1):
        if m % i != 0:
            continue
        c = m // i
        if n * c <= m:
            return c
        elif n * i <= m:
            ret = i
    return ret


def main():
    n, m = map(int, input().split())
    print(solve(n, m))


if __name__ == "__main__":
    main()
    # for n in range(1, 500):
    #     for m in range(n, 1000):
    #         i = solve(n, m)
    #         assert m % i == 0, (n, m, i)
    #         assert n*i <= m, (n, m, i)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<int(n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int main(){
	int N; cin >> N;
	ll ans = 0;
	for(int i=1; i<=N; i++){
		if(i % 3 != 0 && i % 5 != 0) ans = ans + i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
N = int(input())
A1 = [int(a) for a in input().split()]
A2 = [int(a) for a in input().split()]

maxi = prev = A1[0] + sum(A2)
for i in range(1, N):
    cur = prev + A1[i] - A2[i-1]
    maxi = max(maxi, cur)
    prev = cur
print(maxi)

Measured memory_bytes: 3060
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));

  rsort($a);

  $al=0;
  $bo=0;
  for($i=0;$i<$n;$i++){
    if($i%2==0){
      $al+=$a[$i];
    }else{
      $bo+=$a[$i];
    }
  }
  echo $al-$bo;

Measured memory_bytes: 16036
#include <iostream>
using namespace std;
int count(int x, int c){
    if(x >= 500){
        return count(x-500, c+1);
    }
    if(x >= 100){
        return count(x-100, c+1);
    }
    if(x >= 50){
        return count(x-50, c+1);
    }
    if(x >= 10){
        return count(x-10, c+1);
    }
    if(x >= 5){
        return count(x-5, c+1);
    }
    if(x == 0){
        return c;
    }
    else {
        return count(x-1,c+1);
    }
}

int main (void){
    int x;
    while (true){
        cin >> x;
        if(x == 0) {
            break;
        }
        cout << count(1000 - x, 0) << endl;
    }
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    int N; cin >> N;
    VI m(300000,0);
    REP(_,N){
        int a; cin >> a; a--;
        m[a]++;
    }
    VI C;
    for(int i : m){
        if(i>0) C.push_back(i);
    }
    SORT(C);
    int K = C.size();

    VI D(C[K-1]);
    for(int i : C){
        REP(j,i) D[j]++;
    }
    REVERSE(D);

    VL SC(K+1,0), SD(C[K-1]+1,0);
    REP(i,K) SC[i+1] = SC[i] + C[i];
    REP(i,C[K-1]) SD[i+1] = SD[i] + D[i]; REVERSE(SD);

    int maxA = C[K-1];
    for(ll i=1; i<N+1; i++){
        while(i*maxA > SC[K]-SD[maxA]) maxA--;
        int ans = (SC[K]-SD[maxA]) / i;
        cout << ans << en;
    }
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 7940
///
// File:  0521.go
// Author: ymiyamoto
//
// Created on Wed Mar  7 22:11:28 2018
//
package main

import (
	"fmt"
)

var money int

func main() {
	for {
		fmt.Scan(&money)
		if money == 0 {
			break
		}
		rem := 1000 - money

		count := 0
		for _, coin := range []int{500, 100, 50, 10, 5, 1} {
			count += rem / coin
			rem %= coin
		}
		fmt.Println(count)
	}
}



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

int main() {
	int N;
	cin >> N;
	vector<int> X(N), Y(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i];
		Y[i] = X[i];
	}
	sort(Y.begin(), Y.end());
	for (int i = 0; i < N; i++) cout << (X[i] >= Y[N / 2] ? Y[N / 2 - 1] : Y[N / 2]) << endl;
}

Measured memory_bytes: 3712
from sys import stdin
from collections import Counter


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    A_arr = []
    for i in range(N):
        _ = int(_in[i+1])  # type:int
        A_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    count = Counter(A_arr).values()
    count_odd = [_ for _ in count if _%2==1]
    cnt = len(count_odd)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 76120
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int n,x=0;
    scanf("%d\n",&n);
    int ans = 0;
    REP(i,n){
        char c;
        if((c=getchar())=='I') x++;
        else x--;
        ans = max(ans,x);
    }

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

Measured memory_bytes: 256
n = gets.to_i
array = Array.new(4){Array.new(3){Array.new(10,0)}}

n.times {
  b, f, r, v = gets.split(" ").map(&:to_i)
  array[b-1][f-1][r-1] += v
}

for i in 0..3
  for j in 0..2
    for l in 0..9
      print " #{array[i][j][l]}"
    end
    print "\n"
  end
  if i < 3
    puts "#"*20
  end
end

Measured memory_bytes: 8668
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n;
    cin >> n;
    switch (n%7) {
        case 0:cout << "thu";break;
        case 1:cout << "fri";break;
        case 2:cout << "sat";break;
        case 3:cout << "sun";break;
        case 4:cout << "mon";break;
        case 5:cout << "tue";break;
        case 6:cout << "wed";break;
    }
    cout << endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define MAXL 20
#define F first
#define endl "\n"
#define S second
#define MOD (int)(1e9 + 7)
#define MOD2 (lli) 998244353  
#define lli long long int
#define sz(a) int(a.size())
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

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

  int a;
  string s;
  cin >> a >> s;
  if(a < 3200) cout << "red" << endl;
  else cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define long long ll
int main()
{ int n,i,j;
 cin>>n;
 int arr[n];
 int sum=0;
 for(i=0; i<n; i++)
 cin>>arr[i];
 for(i=0; i<n-1; i++)
 {
   for(j=i+1; j<n; j++)
   sum+=arr[i]*arr[j];
 }
 cout<<sum;

}

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

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

int main()
{
    string s;
    cin >> s;
    char odd[3] = {'R', 'U', 'D'};
    char even[3] = {'L', 'U', 'D'};
    int slength = s.length();
    char x;

    rep(i, slength)
    {
        x = s[i];
        int flag = 0;
        if (i % 2 == 0)
        {
            rep(i, 3)
            {
                if (odd[i] == x)
                {
                    flag = 1;
                }
            }
            if (flag == 0)
            {
                std::cout << "No" << endl;
                return 0;
            }
        }
        else
        {
            rep(i, 3)
            {
                if (even[i] == x)
                {
                    flag = 1;
                }
            }
            if (flag == 0)
            {
                std::cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<int> ans;
int answernum=0;
bool continueflag=true;
string S;
int N, M;
int now;

void back(int n){
   if(n<=M) ans.push_back(n), now=0;
   else{
     for(int i=M; i>0; i--){
       if(S[n-i]=='0'){
         ans.push_back(i);
         now-=i;
         continueflag=true;
         break;
       }
       continueflag=false;
     }
   }
}

int main(){
  cin >> N >> M;
  cin >> S;
  now=N;
  while(continueflag==true && now!=0) back(now);
  if(continueflag){
    for(int i=ans.size()-1; i>=0; i--) cout << ans[i] << " " << flush;
  }
  else cout << -1;
  cout << endl;
  return 0;
}

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

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  int p = a;
  a = b;
  b = p;
  p = a;
  a = c;
  c = p;
  cout << a << " " << b << " " << c;
  return 0;
}

Measured memory_bytes: 256
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=100005;
int h,w,n,sum;
map<pii,int>mp;
int ans[10];

bool on(int x,int y){
	return x>=0&&y>=0&&x+2<h&&y+2<w;
}

int main(){
	scanf("%d%d%d",&h,&w,&n);
	rep(i,n){
		int x,y;
		scanf("%d%d",&x,&y);
		x--;y--;
		for(int i=x-2;i<=x;i++)for(int j=y-2;j<=y;j++)
		if(on(i,j))mp[mk(i,j)]++;
	}
	for(map<pii,int>::iterator it=mp.begin();it!=mp.end();it++){
		ans[it->se]++;
		sum++;
	}
	printf("%lld\n",(ll)(h-2)*(ll)(w-2)-(ll)sum);
	REP(i,9)printf("%d\n",ans[i]);
	return 0;
}

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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n); i > 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int a,b;
    cin >> a >> b;
    vector<int> c(2),d(2);
    c[0] = (a * 100 + 7)/ 8;
    c[1] = ((a+1) * 100 - 1) / 8;
    d[0] = b * 10;
    d[1] = (b+1) * 10 - 1;
    if(c[1] < d[0] || c[0] > d[1]) print(-1);
    else print(max(c[0],d[0]));
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  if (K == 1) {
    cout << 0 << endl;
  } else {
    cout << N - K << endl;
  }
  return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
 
int main()
{
	string s;
	cin >> s;
	REV(s);

	vector<string> a={"dream","dreamer","erase","eraser"};
	rep(i,4) REV(a[i]);
	int count = 0;
	
	while(count < s.size()){
		bool check = false;
		rep(i,4){
			string now = s.substr(count, a[i].size());
			if(s.substr(count,a[i].size()) == a[i]){
				count += a[i].size();
				check = true;
				break;
			}
		}
		if(check) continue;
		if(!check){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 3708