akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int64_t a[1001000], b[1001000];
  for(int i=0; i<n+1; i++){
    cin >> a[i];
  }
  for(int i=0; i<n; i++){
    cin >> b[i];
  }
  int64_t ans = 0;
  for(int i=0; i<n; i++){
    if(b[i]>=a[i]){
      b[i] -= a[i];
      ans += a[i];
      if(b[i]>=a[i+1]){
        ans += a[i+1];
        a[i+1] = 0;
        //cout << ans << endl;
      }
      else{
        a[i+1] -= b[i];
        ans += b[i];
        //cout << ans << endl;
      }
    }
    else{
      ans += b[i];
    }
    //cout << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define n 500000
#define mem(arr) memset(arr, 0, sizeof(arr))
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
void solve();
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int times = 1;
//	cin >> times;
	for(int i=0; i<times; i++)
	{
		solve();
		cout << '\n';
	}
	return 0;
}

int a, b, c, d, e, f, g, h;
int arr[n + 50], arr1[n + 50], arr2[n + 50];

//type here

void solve()
{
	string str; cin >> str;
	a = str.size();
	int cnt1 = 0, cnt2 = 0, d1 = 1, d2 = 0;
	char table[2] = {'0', '1'};
	for(int i=0; i<a; i++)
	{
		if(str[i] != table[d1]) cnt1 ++;
		if(str[i] != table[d2]) cnt2 ++;
		d1 = !d1; d2 = !d2;
	}
	cout << min(cnt1, cnt2);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;
 
int32_t main(){
    vaibhavv06;
	string s,t; cin>>s>>t;
    int n = s.length();
    int m = t.length();
    int dp[n+1][m+1]={0};
    // if(s[0]==t[0]) dp[0][0]=1;
    // for(int i=1;i<n;i++){
    //     dp[i][0]=dp[i-1][0];
    // }
    // for(int i=1;i<m;i++){
    //     dp[0][i]=dp[0][i-1];
    // }
    
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0 || j==0) dp[i][j]=0;
            else if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    // cout<<dp[n][m]<<endl;
    string x="";
    int i=n,j=m;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            x+=s[i-1];
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }
        else j--;
    }
    // cout<<x<<endl;
    reverse(x.begin(),x.end());
    cout<<x<<endl;
    //cout<<dp[n][m]<<endl;
    
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FOREACH(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define SIZE(v) ((int)(v).size())
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ll long long
#define llint long long
#define pii pair<int, int>
#define UNVISITED -1


template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}
 
template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
 
class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

int main() {
	ll D, T, S; scanf("%lld %lld %lld", &D, &T, &S);
	if(D > S * T) printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  for (int i = 0; i < N; i++) {
    char S;
    cin >> S;
    if (S == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}

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

int main()
{
    int a[110],n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    int ans=1;
    for(int i=n-2;i>=0;i--) if(a[i]!=a[i+1]) ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        int a = inp.nextInt();
        String s = inp.next();
        System.out.println(a < 3200 ? "red" : s);
    }
}


Measured memory_bytes: 21588
import java.io.*;
import java.util.*;
class   Main       {
	public static void main(String[] args) 
	{
		InputReader in = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		Scanner sc = new Scanner(System.in);
		int n = in.nextInt();
		int arr[]= new int[100001];
		arr=in.nextIntArray(n);
		int oddnum=0,even=0,divide=0;
		for(int i=0;i<n;i++)
		{
			if(arr[i]%2!=0)
				oddnum++;
			else if(arr[i]%2==0&&arr[i]%4!=0)
				even++;
			else if(arr[i]%4==0)
				divide++;
		}
		if(even==0)
		{
			if(oddnum<=divide+1)
				System.out.println("Yes");
			else
				System.out.println("No");
		}
		else
		{
			if(oddnum<=divide)
				System.out.println("Yes");
			else
				System.out.println("No");
		}
		//w.println(n);
		w.close();
		sc.close();
	}
	static class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		public InputReader(InputStream st) {
			this.stream = st;
		}
		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
		
		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		
		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		
		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
		
		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}
		
		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}
		
		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
		
		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
		
	}
	
}

Measured memory_bytes: 22088
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            99999999999999


void solve()
{
  int a,b,c;
  cin>>a>>b>>c;
  swap(a,b);
  swap(a,c);
  cout<<a<<" "<<b<<" "<<c<<endl;


}

int main()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    //sieve();
    //int cnt=1;
    //int t; cin>>t; while(t--) solve();
    solve();
}


Measured memory_bytes: 3652
// AOJ 1165

#include <iostream>
#include <cstdio>
using namespace std;

int data[500][500];
bool done[500][500];
int fx, fy;
int lx, rx, maxy, miny;

void search(int find, int x, int y, int from)
{
	// cout << "+" << x << " " << y << endl;
	if (data[y][x] == -1 || done[y][x] == true){
		return;
	}
	if (data[y][x] == find){
		fx = x;
		fy = y;
		lx = min(lx, x);
		rx = max(rx, x);
		miny = min(miny, y);
		maxy = max(maxy, y);
		return;
	}
	done[y][x] = true;
	if (from != 2){
		search(find, x + 1, y, 0);
	}
	if (from != 0){
		search(find, x - 1, y, 2);
	}
	if (from != 1){
		search(find, x, y + 1, 3);
	}
	if (from != 3){
		search(find, x, y - 1, 1);
	}
	
	return;
}

int main(void)
{
	int n;
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		for (int i = 0; i < 500; i++){
			for (int j = 0; j < 500; j++){
				data[i][j] = -1;
			}
		}
		
		int num, dir;
		int sx = 250, sy = 250;
		data[sy][sx] = 0;
		lx = rx = miny = maxy = 250;
		for (int i = 1; i < n; i++){
			cin >> num >> dir;
			for (int i = 0; i < 500; i++){
				for (int j = 0; j < 500; j++){
					done[i][j] = false;
				}
			}
			search(num, sx, sy, -1);
			if (dir == 0){
				data[fy][fx - 1] = i;
				if (fx - 1 < lx){
					lx = fx - 1;
				}
			}
			else if (dir == 1){
				data[fy + 1][fx] = i;
				if (fy + 1 > maxy){
					maxy = fy + 1;
				}
			}
			else if (dir == 2){
				data[fy][fx + 1] = i;
				if (rx < fx + 1){
					rx = fx + 1;
				}
			}
			else if (dir == 3){
				data[fy - 1][fx] = i;
				if (miny > fy - 1){
					miny = fy - 1;
				}
			}
		}
		
		/*
		for (int j = miny; j <= maxy; j++){
			for (int k = lx; k <= rx; k++){
				printf("%3d", data[j][k]);
			}
			puts("");
		}
		*/
		
		cout << rx - lx + 1 << " " << maxy - miny + 1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2476
def main():
    N=int(input())
    S=input()

    C={"R":0,"G":0,"B":0}

    for i in range(N):
        C[S[i]]+=1

    excepter=0

    for i in range(N-1):
        for j in range(i+1,N):
            if S[i]==S[j]:
                continue
            k=j+(j-i)
            if k>N-1:
                break
            if S[i]==S[k] or S[j]==S[k]:
                continue
            excepter+=1

    res=C["R"]*C["G"]*C["B"]-excepter
    print(res)
if __name__=="__main__":
    main()








Measured memory_bytes: 68040
import collections

N = int(input())
S = list(input())

ans = 0
for i in range(1, len(S)):
  right = collections.Counter(S[:i])
  left = collections.Counter(S[i:])
  n = right.keys() & left.keys()
  if (len(n) > ans):
    ans = len(n)
print(ans)


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

ll gcd(ll x, ll y)
{
	if (y == 0) return x;
	return gcd(y, x % y); 
}

signed main(void)
{
	int n;
	cin >> n;
	ll a[n], l[n], r[n], m[n];

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


Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main() {
	double n;
	while (cin >> n) {
		if (n <= 48.0) cout << "light fly" << endl;
		else if (n <= 51.0) cout << "fly" << endl;
		else if (n <= 54.0) cout << "bantam" << endl;
		else if (n <= 57.0) cout << "feather" << endl;
		else if (n <= 60.0) cout << "light" << endl;
		else if (n <= 64.0) cout << "light welter" << endl;
		else if (n <= 69.0) cout << "welter" << endl;
		else if (n <= 75.0) cout << "light middle" << endl;
		else if (n <= 81.0) cout << "middle" << endl;
		else if (n <= 91.0) cout << "light heavy" << endl;
		else{cout << "heavy" << endl;}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    string s;
    getline(cin, s);
    rep(i,s.size()){
        if('a' <= s[i] && s[i] <= 'z') s[i] += 'A' - 'a';
        else if('A' <= s[i] && s[i] <= 'Z') s[i] -= 'A' - 'a';
    }
    cout << s << endl;
}


Measured memory_bytes: 3232
from collections import deque

Y, X = map(int,input().split())
sy, sx = map(int, input().split())
gy, gx = map(int, input().split())
s = [["#"]*(X+4) for _ in range(Y+4)]
for y in range(Y):
    s[y+2] = *list("##"+input()+"##"), 
inf = Y*X
c = [[inf]*X for _ in range(Y)]
c[sy-1][sx-1] = 0
drs = [[-1,0],[1,0],[0,0],[0,-1],[0,1]]
dr2s = [[-2,-2],[-2,-1],[-2,0],[-2,1],[-2,2],
        [2,-2],[2,-1],[2,0],[2,1],[2,2],
        [-1,-2],[0,-2],[1,-2],
        [-1,2],[0,2],[1,2],
        [-1,-1],[-1,1],[1,-1],[1,1]
       ]

q = deque([(sy-1, sx-1)])

while q:
    y,x = q.popleft()
    cost = c[y][x]
    for dx,dy in drs:
        x2 = x+dx
        y2 = y+dy
        if s[y2+2][x2+2] == "." and c[y2][x2] > cost:
            c[y2][x2] = cost
            q.appendleft((y2,x2))
    for dy, dx in dr2s:
        x2 = x+dx
        y2 = y+dy
        if s[y2+2][x2+2] == "." and c[y2][x2] > cost+1:
            c[y2][x2] = cost+1
            q.append((y2,x2))
    
if c[gy-1][gx-1] == inf:
    print("-1")
else:
    print(c[gy-1][gx-1])

Measured memory_bytes: 175860
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

const long long X=1000000000000001;

int main(){
    long long N;
    cin>>N;
    string moji="abcdefghijklmnopqrstuvwxyz";
    vector<char> x;
    vector<long int> y;
    long long n=26;
    int m=1;
    while(N>0){
        if (N>=n) N=N-n;
        else break;
        n=n*26;
        m++;
  //      y.push_back(s);
    //    x.push_back(moji[s-1]);
    }
    if(N==0){
        for (int i=0;i<m-1;i++) cout<<'z';
        cout<<endl;
        return 0;
    }
    N--;
    int s=N%26;
        N=N/26;
        x.push_back(moji[s]);
    while(N>0){
        int ss=N%26;
        N=N/26;
        x.push_back(moji[ss]);
    }
    int siz=x.size();

    for (int i=1;i<m-siz+1;i++) cout<<'a';
    for (int i=0;i<siz;i++){
        cout<<x[siz-i-1];
    }

   // for (int i=0;i<x.size();i++) cout<<x[x.size()-1-i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

const int mxN = 102;
const int mxV = 100100;

ll dp[mxN][mxV];

int main(){
    int n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    for(int i = 0; i < n; i++) cin >> w[i] >> v[i];
    for(int i = 0; i < mxN; i++) for(int j = 0; j < mxV; j++) dp[i][j] = 1e18;
    dp[0][0] = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < mxV; j++) {
            if(j >= v[i]) chmin(dp[i+1][j], dp[i][j-v[i]] + w[i]);
            chmin(dp[i+1][j], dp[i][j]);
        }
    }

    ll ans = 0;
    for(int i = 0; i < mxV; i++) {
        if(dp[n][i] <= W) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    auto getPositions = [&]() {
        vector<int> res;
        for(int i = 0; i < n && res.size() < k;) {
            if (s[i] == 'o') {
                res.push_back(i);
                i += c + 1;
            } else {
                ++i;
            }
        }
        return res;
    };
    vector<int> l, r;
    l = getPositions();
    reverse(s.begin(), s.end());
    r = getPositions();
    rep(i, k) r[i] = n - 1 - r[i];
    reverse(s.begin(), s.end());

    vector<int> lastL(n + 1, -1);
    rep(i, k) lastL[l[i] + 1] = i;
    rep(i, n) {
        if (lastL[i + 1] == -1) lastL[i + 1] = lastL[i];
    }
    vector<int> lastR(n + 1, -1);
    rep(i, k) lastR[r[i]] = i;
    for (int i = n - 1; i >= 0; --i) {
        if (lastR[i] == -1) lastR[i] = lastR[i + 1];
    }

    rep(i, n) {
        if (s[i] == 'x') continue;
        int li = lastL[i];
        int ri = lastR[i + 1];
        int cnt = 0;
        if (li != -1) cnt += li + 1;
        if (ri != -1) cnt += ri + 1;
        if (li != -1 && ri != -1 && r[ri] - l[li] <= c) {
            --cnt;
        }
        if (cnt >= k) continue;
        cout << i + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 5004
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,mavx=-1;
    cin>>n;
    string s,ss;
    map<string, int> smp;
    map<string, int>::iterator iv;
    for(int i=0;i<n;i++){
        cin>>s; 
        smp[s]++;
        mavx=max(mavx,smp[s]);
    }
    for(iv=smp.begin();iv!=smp.end();iv++){
        if(iv->second==mavx){
            cout<<iv->first<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << 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; }

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    string S,T;
    cin >> S >> T;
    map<char,char> M,N;
    REP(i,S.size()){
        if(M.count(S[i])){
            if(M[S[i]] != T[i]){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            M.emplace(S[i],T[i]);
        }
    }
    REP(i,T.size()){
        if(N.count(T[i])){
            if(N[T[i]] != S[i]){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            N.emplace(T[i],S[i]);
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 916
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  long int n,q,i=0,l,r,s=0,p;
  cin>>n;
  vector<int> V(n),Z(100001,0);
  for(i=0;i<n;i++)
  {
    cin>>V[i];
    ++Z[V[i]];
    s+=V[i];
  }
  cin>>q;
  while(q--)
  {
    cin>>l>>r;
    p=Z[l];
    Z[r]+=p;
    Z[l]=0;
    s+=p*(r-l);
    cout<<s<<endl;
}
}

Measured memory_bytes: 4048
N=int(input())
S=[int(input()) for i in range(N)]
S.sort()
ans=sum(S)
for i in range(N):
    if ans%10!=0:
        break
    elif S[i]%10!=0:
        ans-=S[i]
if ans%10==0:
    print(0)
else:print(ans)


Measured memory_bytes: 2940
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define inf 1e18
#define mm 998244353
#define pp pair<int,int>
#define vector<int> vi
#define vector<int> vll
#define ft first
#define se second

ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

void solve(){
	int k; cin>>k;
	string s; cin>>s;
	int n = s.length();
	string ans = "";
	f(i,min(n,k)){
		ans += s[i];
	}
	if(n > k) ans += "...";
	cout<<ans<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    cout << a*b/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ld r;std::cin >> r;
  ld x = 3.141592653589793238462643383279;
  std::cout << fixed << setprecision(20) << 2*r*x << '\n';
  return 0;
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;

    cin >> N;

    vector<vector<pair<ll,ll>>> nodes(N);

    REP(i,N-1){
       ll u, v, w;
       cin >> u >> v >> w;
       nodes[u-1].push_back(make_pair(v-1,w));
       nodes[v-1].push_back(make_pair(u-1,w));
    }

    vector<ll> colors(N,0);
    vector<bool> visited(N, false);
    ll color = 0;
    queue<ll> q;
    q.push(0);
    colors[0] = color;
    visited[0] = true;
    while(!q.empty()){
       ll cur = q.front();
       q.pop();
       ll cur_color = colors[cur];
       for( auto& child : nodes[cur]){
          ll next = child.first;
          ll w = child.second;
          if( visited[next] == false ){
             if( w % 2 ==  0 ){
                 colors[next] = cur_color;
             }else{
                 colors[next] = (cur_color+1)%2;
             }
             q.push(next);
             visited[next] = true;
          }
       }
    }

    REP(i, N){ cout << colors[i] << endl; }
}


Measured memory_bytes: 10496
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(){
  long max;
  char str[10];
  int i, j, k;
  int num, nnum;
  long setdata[2][5001], tmp;
  int focus;

  while(cin>>num){
    if(num==0) break;
    for(i=0; i<num; i++){
      cin>>str;
      setdata[0][i]=(long)atol(str);
    }

    max=100001*(-1);
    for(i=0; i<num; i++){
      if(max<setdata[0][i]) max=setdata[0][i];
    }
    focus=1;
    for(i=num-1; i>=1; i--){
      for(j=0; j<i; j++){
        if(i==num-1){
          setdata[1][j]=setdata[0][j]+setdata[0][j+1];
          if(max<setdata[1][j]) max=setdata[1][j];
        }
        else {
          setdata[focus][j]=setdata[1-focus][j]+setdata[1-focus][j+1]-setdata[focus][j+1];
          if(max<setdata[focus][j]) max=setdata[focus][j];
        }
      }
      focus=1-focus;
    }
    printf("%ld\n", max);
  }

  return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> nums(n);
	vector<int> normal(n);
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		nums[i] = temp;
		normal[i] = temp;
	}

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

	int counter = 0;

	for (int i = 0; i < n; i++) {
		if (normal[i] != nums[i]) counter++;
		if (counter > 2) {
			cout << "NO";
			return 0;
		}
	}

	cout << "YES";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main() {
  int H, A; cin >> H >> A;
  cout << (H-1)/A+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  ll mx = 1e18;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans = 1;
  rep(i,n) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i,n) {
    if (a[i] > (double) mx/(double)ans) {
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
 }
  if (ans > mx) {
      cout << -1 << endl;
      return 0;
    }
   
  printf("%lld\n", ans);
  return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }

const int MAX_N = 200000;
string s;
int prev_r[MAX_N];
int next_l[MAX_N];
int ans[MAX_N];

int main()
{
  cin >> s;
  int n = s.size();

  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') prev_r[i] = i;
    else prev_r[i] = prev_r[i-1];
  }

  for (int i = n-1; i >= 0; i--) {
    if (s[i] == 'L') next_l[i] = i;
    else next_l[i] = next_l[i+1];
  }

  forn(i,n) {
    if (s[i] == 'R') {
      int c = next_l[i] - i;
      if (c % 2 == 0) ans[next_l[i]]++;
      else ans[next_l[i]-1]++;
    } else {
      int c = i - prev_r[i];
      if (c % 2 == 0) ans[prev_r[i]]++;
      else ans[prev_r[i]+1]++;
    }
  }


  forn(i,n)
    cout << ans[i] << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 1792
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin

N = int(F.readline().rstrip())
string_count_dict = {}
max = 1
ans = []

for i in range(N):
    s = F.readline().rstrip()
    if s in string_count_dict:
        string_count_dict[s]  += 1
        if max < string_count_dict[s]:
            max = string_count_dict[s]
        continue
    string_count_dict[s] = 1

for st in string_count_dict:
    if string_count_dict[st] == max:
        ans.append(st)

ans.sort()
for an in ans:
    print(an)


Measured memory_bytes: 34320
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(n:usize, k: usize);
    puts!("{}\n", n - k + 1);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    string s, t;
    cin >> s >> t;
    
    int L = s.size(), ans = 0;
    for(int i = 0; i < L; i++)
        if(s[i] != t[i]) ans++;
    
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3852
#include <iostream>
#include<array>
#include<vector>
#include<string>
#include<utility>
using namespace std;

int main() {
		int a,b;
		b = 0;
		cin >> a;
		for (int i = 1; i <= a; i++) {
			b += i;
		}
		cout << b << endl;
		return 0;
	}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>

using namespace std;
#define int long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;




signed main() {
	ios::sync_with_stdio(false);
	LOAD(int, N);
	LOADVEC(int, A, N);
	std::vector<int>B(N);
	for (int i = 0; i < N; ++i) {
		B[A[i] - 1] = i + 1;
	}
	std::set<int> st;
	st.insert(0);
	st.insert(N + 1);
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		int C = B[i];
		auto itr = st.insert(C).first;
		--itr;
		int L = *itr;
		++itr;
		++itr;
		int R = *itr;
		sum += (R - C)*(C - L)*(i + 1);
	}
	cout << sum << endl;
	return 0;
}
#endif


Measured memory_bytes: 12800
import java.io.*;
//import java.util.*;

/**
 * Created by Ayushi on 30 May 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        //StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String a = br.readLine();
        br.close();
        //a = a.replace("?", "D");
        //int ans = (a.charAt(a.length()-1) == 'D' ? 1:0);
        //a = a.replace("P?", "PD");
        //a = a.replace("?D", "PD");
        //a = a.replace("??", "PD");
        a = a.replace("?", "D");
        /*for (int i = 0; i < a.length()-1; i++) {
            //if ((a.charAt(i) == 'P' && a.charAt(i+1) == 'D') || a.charAt(i) == 'D') ans++;
            if (a.charAt(i) == '?') {

            }
            else if (a.charAt(i) == 'P') {

            }
        }*/
        System.out.println(a);
        //System.out.println(ans);
    }
}


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

int main() {
    string str1, str2;

    cin >> str1 >> str2;

    string str3(str2.begin(), str2.begin() + str2.length()-1);

    if(str1 == str3)
        cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
int counter1[100005];
int counter2[100005];
int len1,len2;
int main(){
	int n;
	cin>>n;
	if(n%2){
		len1 = n/2+1;
		len2 = n/2;
	}
	else{
		len1 = n/2;
		len2 = n/2;
	}
	vector<int>arr(n);
	for(int i=0; i<n; i++) cin>>arr[i];
	for(int i=0; i<n; i+=2) counter1[arr[i]]++;
	for(int i=1; i<n; i+=2) counter2[arr[i]]++;
	priority_queue<pi,vector<pi>, greater<pi> >pq1;
	priority_queue<pi,vector<pi>, greater<pi> >pq2;
	for(int i=1; i<=100000; i++){
		if(counter1[i]){
			pq1.push(pi(len1-counter1[i],i));
		}
	}
	for(int i=1; i<=100000; i++){
		if(counter2[i]){
			pq2.push(pi(len2-counter2[i],i));
		}
	}
	int change1 = pq1.top().first;
	int v1 = pq1.top().second;
	int change2 = pq2.top().first;
	int v2 = pq2.top().second;
	pq1.pop();
	pq2.pop();
	if(v1!=v2) cout<<change1+change2;
	else{
		int c1,c2;
		if(pq1.empty()) c1 = len1;
		else c1 = pq1.top().first;
		if(pq2.empty()) c2 = len2;
		else c2 = pq2.top().first;
		cout<<min(change1+c2,c1+change2);
	}
}

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

using namespace std;

typedef long long ll;

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

	int N;
	cin >> N;

	vector<int> A(N);
	rep(i, N) cin >> A[i];

	vector<int> l(N+2, 0);
	l[1] = A[0];
	for(int i = 1; i < N; i++){
		l[i+1] = max(l[i], A[i]);
	}

	vector<int> r(N+2, 0);
	r[N] = A[N-1];
	for(int i = N-2; i >= 0; i--){
		r[i+1] = max(r[i+2], A[i]);
	}

	rep(i, N){
		cout << max(l[i], r[i+2]) << endl;
	}


}


Measured memory_bytes: 3968
#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);
  }
  
  for(int i=0;i<N;i++){
    for(int j=i;j<N;j++){
      int t;
      if(a.at(i)<a.at(j)){
        t=a.at(i);
        a.at(i)=a.at(j);
        a.at(j)=t;
      }
    }
  }
  
  int sumA=0;
  int sumB=0;
  
  for(int i=0;i<N;i++){
    if((i+1)%2==1)sumA += a.at(i);
    else sumB += a.at(i);
  }
  
  cout << sumA-sumB << endl;
}

Measured memory_bytes: 3612
def main():
    N, M = map(int, input().split())
    *A, = map(int, input().split())

    A.sort(reverse=True)

    tot = sum(A)

    cond = A[M - 1] * 4 * M >= tot

    print('Yes' if cond else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9104
h, w, k = map(int, input().split())
field = list(list(input()) for i in range(h))

def red():
    res = 0
    for i in range(h):
        for j in range(w):
            if field[i][j] == '#':
                res += 1
    return res

cnt = 0
for s in range(2 ** h):
    for t in range(2 ** w):

        for i in range(h):
            for j in range(w):
                if ((s >> i) & 1):
                    for x in range(w):
                        if field[i][x] == '#':
                            field[i][x] = 'r'
                if ((t >> j) & 1):
                    for x in range(h):
                        if field[x][j] == '#':
                            field[x][j] = 'r'
        if red() == k:
            cnt += 1
        for x in range(h):
            for y in range(w):
                if field[x][y] == 'r':
                    field[x][y] = '#'

print(cnt)


Measured memory_bytes: 9236
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0) break;
		if(a > b) printf("%d %d\n",b,a);
		else{
			printf("%d %d\n",a,b);
		}
	}
}




Measured memory_bytes: 2568
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

static const int MAX = 100001;

/******* c++14 don't include *******/

template<typename T>
T gcd(T a, T b){if( b == 0)return a; return gcd(b, a%b); }
template<typename T>
T lcm(T a, T b){return a*b/gcd(a,b); }

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

int main(int argc, const char * argv[]) {
    // input from txt
  
    /////////
    //write//
    /////////
    
    int n, m;
    int *a;
    ll *dp;
    a = new int[MAX];
    dp = new ll[MAX];
    
    cin >> n >> m;
    rep(i, m){
        int p = 0;
        cin >> p;
        a[p-1] = 1;
    }
    
    dp[0] = 1;
    dp[1] = 1;
    
    rep(i, n){
        if(i == 0 || i == 1){
            if(a[i])dp[i] = 0;
            else if(i==1)dp[i] += dp[i-1];
            continue;
        }
        if(!a[i])dp[i] = dp[i-2]+dp[i-1];
        else dp[i] = 0;
        dp[i]%=1000000007;
    }
    
    cout << dp[n-1] << endl;
    
    return 0;
}


Measured memory_bytes: 1408
import java.util.HashMap;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int s = Integer.parseInt(sc.next());

    int ans = 0;
    HashMap<Integer, Integer> a = new HashMap<Integer, Integer>();

    int ai = s;
    a.put(ai, 1);

    for (ans = 2; ans <= 1000000; ans++) {
      if (ai % 2 == 0) {
        ai = ai / 2;
      } else {
        ai = 3 * ai + 1;
      }
      if (a.containsKey(ai)) {
        System.out.println(ans);
        return;
      } else {
        a.put(ai, 1);
      }
    }

  }
}

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

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

  if (a >= b && a >= c)
    cout << a * 10 + b + c;
  if (b > a && b >= c)
    cout << b*10+a+c;
  if (c > a && c > b)
    cout << c*10+a+b;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

vector<ll> pw2(51,1);
vector<ll> pw10(19,1);

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
	ll Q,H,S,D,N; cin>>Q>>H>>S>>D>>N;
	if(2*Q<H) H=2*Q;
	if(2*H<S) S=2*H;
	if(2*S<D) D=2*S;
	N*=1000;
	//g
	ll ans=0;
	ans+=(N/2000)*D;
	N%=2000;
	ans+=(N/1000)*S;
	N%=1000;
	ans+=(N/500)*H;
	N%=500;
	ans+=(N/250)*Q;
	cout<<ans;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

    String S = sc.next();
    String T = sc.next();
    int A = sc.nextInt();
    int B = sc.nextInt();
    String U = sc.next();

    Map<String , Integer> map = new HashMap<>();

    map.put(S, A);
    map.put(T, B);

    map.put(U, map.get(U) - 1);

    System.out.println(map.get(S) + " " + map.get(T));

    sc.close();
  }
}

Measured memory_bytes: 23252
n = gets.to_i
pys = n.times.map{gets.chomp.split(" ").map(&:to_i)}.sort_by{|a,b|b}

limit = 0


pys.each do |a, b|
	limit += a
	if b < limit
		puts "No"
		exit
	end
end

puts 'Yes'

Measured memory_bytes: 22392
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = null;
		try {
			scan = new Scanner(System.in);
			int W = scan.nextInt();
			int H = scan.nextInt();
			int x = scan.nextInt();
			int y = scan.nextInt();
			int r = scan.nextInt();
			IsInside(W, H, x, y, r);
		} catch (InputMismatchException e) {
			System.out.println(e);
		} finally {
			scan.close();
		}
	}

	static void IsInside(int W, int H, int x, int y, int r) {
		// ?????£???????????§??????
		if (x < -100 || x > 100 || y < -100 || y > 100) {
			throw new RuntimeException("x?????????y????????????????????§???");
		} else if (W < 0 || W > 100 || H < 0 || H > 100 || r < 0 || r > 100) {
			throw new RuntimeException("W???H???r???????????????????????????????????§???");
		}
		// ??????
		if (x - r < 0 || W < x + r || y - r < 0 || H < y + r) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

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

int main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int k,x;
	cin >> k >> x;
	if(k*500>=x)cout << "Yes";
	else cout << "No";
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long llong;
typedef unsigned long long ullong;

using namespace std;


int main() {
	llong w, h;
	cin >> w >> h;
	if (w == 1 || h == 1)
		cout << 1;
	else
		cout << (w*h+1)/2;
}

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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)
#define MP(a, b) make_pair(a, b)

int ch(int x)
{
	int t = x, y = 0;
	while (t) {
		y = y * 10 + (t%10);
		t /= 10;
	}
	return x == y ? 1 : 0;
}

int main()
{
	int a, b;
	cin >> a >> b;
	int res = 0;
	reps(i, a, b+1) res += ch(i);
	cout << res << endl;
	return 0;
}


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

int main() {
	int N; 
    string S; 
	cin >> N >> S; 
int W[314159]; 
for (int i = 1; i <= N; ++i){
if(S.at(i-1) == 'W') W[i] = W[i-1] + 1; 
else W[i] = W[i-1]; // i番目までの西向きの人数
}

int m = 314159; 
for (int i = 1; i <= N; ++i){
int tenkan = W[i-1] + W[i] - W[N] + (N - i); 
m = min(m, tenkan);
}
cout << m << endl;
}

Measured memory_bytes: 1796
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int q = scan.nextInt();
		String[] X = new String[q];
		String[] Y = new String[q];
		for (int i = 0; i < q; i++) {
			X[i] = scan.next();
			Y[i] = scan.next();
		}

		for (int i = 0; i < q; i++) {
			System.out.println(lcs(X[i], Y[i]));
		}

		scan.close();
	}

	public static int lcs(String x, String y) {
		int ans = 0;
		x = ' ' + x;
		y = ' ' + y;
		// c[i][i]???X[i]??¨Y[i]???LCS?????????
		int[][] c = new int[x.length() + 1][y.length() + 1];
		
		for (int i = 0; i < x.length(); i++) {
			for (int j = 0; j < y.length(); j++) {
				if (i == 0 || j == 0) {
					c[i][j] = 0;
				} else if (x.charAt(i) == y.charAt(j)) {
					c[i][j] = c[i - 1][j - 1] + 1;
				}else if(x.charAt(i) != y.charAt(j)){
					c[i][j] = Math.max(c[i-1][j], c[i][j-1]);
				}
				ans = Math.max(ans, c[i][j]);
			}
		}
		
		return ans;
		
	}
}

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

int e(string a)
{
    for(int i = 0;i < 10;i++)
    {
        if(a == to_string(i)) return i;
    }
    char temp[] = {'A','B','C','D','E','F'};
    for(int i = 0;i < 6;i++)
    {
        if(a[0] == temp[i])
        {
            return i + 10;
        }
    }
    return -1;
}

int main()
{
   string a;
   string b;
   cin >> a;
   cin >> b;
   int c = e(a);
   int d = e(b);
   if(c > d)
   {
       cout << ">";
    }
    else if(c < d)
    {
        cout << "<";
    }
    else
    {
        cout << "=";
    }
}

Measured memory_bytes: 256