akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

		while (true) {

			int n = sc.nextInt();
			int r = sc.nextInt();
			int counter = 1;

			if (n == 0 && r == 0) {
				break;
			}

			int[] cards = new int[n + 1];
			for (int i = 1; i <= n; i++) { // ?????????
				cards[i] = n + 1 - i;
			}

			int[] tmps = new int[n + 1];

			while (counter <= r) {
				counter++;
				int p = sc.nextInt();
				int c = sc.nextInt();

				for (int i = 1; i <= c; i++) {
					tmps[i] = cards[p + i - 1];
				}
				for (int i = 1; i <= p + c - 1; i++) {
					if (p - i <= 0) {
						cards[p + c - i] = 0;
					} else {
						cards[p + c - i] = cards[p - i];
					}
				}
				for (int i = 1; i <= c; i++) {
					cards[i] = tmps[i];
				}
			}
			System.out.println(cards[1]);
		}
	}
}

Measured memory_bytes: 38360
import java.util.Scanner;

class Main{
  public static void main(String args[]){
	  Scanner s = new Scanner(System.in);
	  int[] abc = new int[3];
	  abc[0] = s.nextInt();
	  abc[1] = s.nextInt();
	  abc[2] = s.nextInt();

	  for (int i = abc.length - 1; i > 0; i--) {
		  for(int j = 0; j < i; j++) {
			  int tmp = 0;
			  if(abc[j] > abc[j + 1]) {			  
				  tmp = abc[j];
			  	  abc[j] = abc[j + 1];
			  	  abc[j + 1] = tmp;
			  }
		  }
	  }
	  System.out.println(abc[0] + " " + abc[1] + " " + abc[2]);

	  s.close();
  }
}


Measured memory_bytes: 26144
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        String word = s.next();
        int res=0;
        word = word.replace("ABC","5");
        for(int i=0;i<word.length();i++){
            if(word.charAt(i)=='5')res++;
        }
        System.out.println(res);
    }
}



class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25504
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,d,mod,C[110][110],dp[110][110][110][2],trans[110][110],po[110][110];
inline int kpow(int a,int b)
{
	int s=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)s=1ll*s*a%mod;
	return s;
}
int main()
{
	scanf("%d %d %d %d",&n,&m,&d,&mod);
	for(int i=0;i<=n||i<=m||i<=d;++i)
	{
		C[i][0]=1;
		for(int j=1;j<=i;++j)(C[i][j]=C[i-1][j-1]+C[i-1][j])>=mod?C[i][j]-=mod:0;
		po[i][0]=1;
		for(int j=1;j<=n||j<=m||j<=d;++j)po[i][j]=1ll*po[i][j-1]*i%mod;
	}
	dp[1][0][0][0]=1;
	for(int k=1;k<=d;++k)
	{
		for(int j=0;j<=m;++j)
		{
			trans[j][0]=1;
			int tmp=1ll*(po[k][m-j]+mod-po[k-1][m-j])*po[d-k+1][j]%mod;
			for(int i=1;i<=n;++i)trans[j][i]=1ll*trans[j][i-1]*tmp%mod;
		}
		for(int i=0;i<=n;++i)
			for(int j=0;j<=m;++j)
				if(dp[k][i][j][0])
					for(int x=0;x+i<=n;++x)dp[k][i+x][j][1]=(dp[k][i+x][j][1]+1ll*C[n-i][x]*dp[k][i][j][0]%mod*trans[j][x])%mod;
		for(int i=0;i<=n;++i)
		{
			trans[i][0]=1;
			int tmp=1ll*(po[d-k+1][i]+mod-po[d-k][i])*po[k][n-i]%mod;
			for(int j=1;j<=m;++j)trans[i][j]=1ll*trans[i][j-1]*tmp%mod;
		}
		for(int i=0;i<=n;++i)
			for(int j=0;j<=m;++j)
				if(dp[k][i][j][1])
					for(int x=0;x+j<=m;++x)dp[k+1][i][j+x][0]=(dp[k+1][i][j+x][0]+1ll*C[m-j][x]*dp[k][i][j][1]%mod*trans[i][x])%mod;
	}
	printf("%d",dp[d+1][n][m][0]);
	return 0;
}


Measured memory_bytes: 10240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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 ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(3);
    for(int i=0;i<3;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int ans=0;
    ans+=a[2]-a[1];
    a[0]+=a[2]-a[1];
    if((a[2]-a[0])%2==1){
        ans++;
    }
    ans+=(a[2]-a[0]+1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';
#define MOD 1000000007

using namespace std;

int main(void){
    ll N, M;
    cin>>N>>M;
    ll dp[200000];
    MEMSET(dp, 0);
    ll a;
    rep(i, M){
        cin>>a;
        dp[a]=-1;
    }
    dp[0]=1;
    rep(i, N){
        //cout<<dp[i]<<endl;
        if(dp[i]==-1) continue;
        if(dp[i+1]!=-1){
            dp[i+1]+=dp[i];
            dp[i+1]%=MOD;
        }
        if(dp[i+2]!=-1){
            dp[i+2]+=dp[i];
            dp[i+2]%=MOD;
        }
    }
    cout<<dp[N]<<endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int m = scanner.nextInt();
    int a = n > 1 ? n * (n - 1) / 2 : 0;
    int b = m > 1 ? m * (m - 1) / 2 : 0;
    System.out.println(a + b);
  }
}


Measured memory_bytes: 23124
k = int(input())
a=['1','2','3','4','5','6','7','8','9']
 
while k>len(a):
    b=[]
    for i in a:
        if i[-1]!='0':
            b.append(i+chr(ord(i[-1])-1))
        b.append(i+i[-1])
        if i[-1]!='9':
            b.append(i+chr(ord(i[-1])+1))
    k-=len(a)
    a=b.copy()
 
print(a[k-1])

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

template <typename T>
using matrix = vector<vector<T>>;

struct PrefixSums
{
    matrix<int> data;

    PrefixSums(const matrix<bool>& A)
    {
        const int R = int(A.size()), C = int(A[0].size());
        data = matrix<int>(R+1, vector<int>(C+1));
        for (int r = 0; r < R; r++)
            for (int c = 0; c < C; c++)
                data[r+1][c+1] = A[r][c];
        for (int r = 0; r <= R; r++)
            for (int c = 1; c <= C; c++)
                data[r][c] += data[r][c-1];
        for (int c = 0; c <= C; c++)
            for (int r = 1; r <= R; r++)
                data[r][c] += data[r-1][c];
    }

    int query(const int r1, const int c1, const int r2, const int c2)
    {
        return data[r2][c2] - (data[r2][c1] + data[r1][c2]) + data[r1][c1];
    }
};

int main()
{
    ios::sync_with_stdio(false);

    int R, C, Q; cin >> R >> C >> Q;

    vector<string> grid(R);
    for (string& row : grid)
        cin >> row;

    matrix<bool> vertices(R, vector<bool>(C));
    for (int r = 0; r < R; r++)
        for (int c = 0; c < C; c++)
            vertices[r][c] = grid[r][c] == '1';
    PrefixSums ps_vertices(vertices);

    matrix<bool> horizontal(R, vector<bool>(C));
    for (int r = 0; r < R-1; r++)
        for (int c = 0; c < C; c++)
            horizontal[r][c] = vertices[r][c] && vertices[r+1][c];
    PrefixSums ps_horizontal(horizontal);

    matrix<bool> vertical(R, vector<bool>(C));
    for (int r = 0; r < R; r++)
        for (int c = 0; c < C-1; c++)
            vertical[r][c] = vertices[r][c] && vertices[r][c+1];
    PrefixSums ps_vertical(vertical);

    while (Q--)
    {
        int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
        r1--; c1--; r2--; c2--;
        r2++; c2++;

        const auto v = ps_vertices.query(r1, c1, r2, c2);
        const auto e = ps_horizontal.query(r1, c1, r2-1, c2) +
                       ps_vertical.query(r1, c1, r2, c2-1);
        cout << v-e << endl;
    }
}


Measured memory_bytes: 55040
package main
 
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "container/heap"
  "sort"
)
 
var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}
 
type Item struct {
  Comparison  int
}
type PriorityQueue []*Item
func (pq PriorityQueue) Len() int { return len(pq) }
func (pq PriorityQueue) Less(i, j int) bool {
  return pq[i].Comparison < pq[j].Comparison
}
func (pq PriorityQueue) Swap(i, j int) {
  pq[i], pq[j] = pq[j], pq[i]
}
func (pq *PriorityQueue) Pop() interface{} {
  old := *pq
  n := len(old)
  item := old[n - 1]
  *pq = old[0:n - 1]
  return item
}
func (pq *PriorityQueue) Push(x interface{}) {
  item := x.(*Item)
  *pq = append(*pq, item)
}

type Sushi struct {
  Type int
  Delicious int
}
type SushiVec []Sushi
func(S SushiVec) Len() int { return len(S) }
func(S SushiVec) Less(i, j int) bool { return S[i].Delicious > S[j].Delicious }
func(S SushiVec) Swap(i, j int) { S[i], S[j] = S[j], S[i] }

func main() {
  NK := NextIntVec()
  N := NK[0]
  K := NK[1]
  S := make([]Sushi, N)
  for i:= range S {
    TD := NextIntVec()
    S[i] = Sushi{TD[0] - 1, TD[1]}
  }
  sort.Sort(SushiVec(S))
  First := make([]bool, N)
  Second := make([]int, 0)
  var Stomach PriorityQueue
  eat := 0
  various := 0
  happy := 0
  for _, s := range S {
    if First[s.Type] {
      Second = append(Second, s.Delicious)
    } else if eat < K {
      heap.Push(&Stomach, &Item{s.Delicious})
      First[s.Type] = true
      happy += s.Delicious
      eat++
      various++
    }
  }
  happy += various * various
  for _, s := range Second {
    if eat < K {
      heap.Push(&Stomach, &Item{s})
      eat++
      happy += s
      continue
    }
    _s := heap.Pop(&Stomach).(*Item).Comparison
    if s <= _s { break }
    _happy := happy - _s + s - 2 * various + 1
    if _happy <= happy { break }
    happy = _happy
    heap.Push(&Stomach, &Item{s})
    various--
  }
  Write(happy)
  Output()
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  string s; cin >> s;
  int n = s.size();
  int win = 0;
  REP (i, n) win += s[i] == 'o';
  cout << (win + 15 - n >= 8 ? "YES" : "NO") << endl;
}


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

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

string days[7] =
  {
   "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT",
  };

int main(){
  string in;

  cin >> in;

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

  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

# a-z
az = [chr(i) for i in range(97, 97 + 26)]

ans = 0
for i in range(1, n):
    count = 0
    for j in az:
        if s[i:n].count(j) != 0 and s[:i].count(j) != 0:
            count += 1
    ans = max(ans, count)
print(ans)

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

template<long long mod>
class modint{
private:
  long long num;
  long long extgcd(long long a, long long b, long long&x, long long&y)const {
    long long d = a;
    if(b != 0){d = extgcd(b, a%b, y, x);  y -= (a/b) * x;}
    else{x = 1; y = 0;}
    return d;
  }
  long long modinverse()const{
    long long x, y;
    extgcd(num, mod, x, y);
    return (mod + x%mod)%mod;
  }
public:
  modint():num(0){}
  modint(const long long x):num((x < 0?(x+mod):x)%mod ){}
  friend modint operator+(const modint&a, const modint&b)
  {    return modint(a.num + b.num);  }
  friend modint operator-(const modint&a, const modint&b)
  {    return modint(a.num - b.num);  }
  friend modint operator*(const modint&a, const modint&b)
  {    return modint(a.num * b.num);  }
  friend modint operator/(const modint&a, const modint&b)
  {    return modint(a*b.modinverse());  }
  modint& operator+=(const modint&b)
  {    return (*this) = (*this) + b;  }
  modint& operator-=(const modint&b)
  {    return (*this) = (*this) - b;  }
  modint& operator*=(const modint&b)
  {    return (*this) = (*this) * b;  }
  modint& operator/=(const modint&b)
  {    return (*this) = (*this) / b;  }
  modint& operator++()
  {    (*this)+=1; return (*this);  }
  modint& operator--()
  {    (*this)-=1; return (*this);  }
  modint operator++(int){
    modint tmp(*this);
    ++(*this);
    return tmp;
  }
  modint operator--(int){
    modint tmp(*this);
    --(*this);
    return tmp;
  }    
  friend ostream& operator<<(ostream&os, const modint&a){
    os << a.num;
    return os;
  }
  friend istream& operator>>(istream&is, modint&a){
    long long x; is >> x;
    a = x;
    return is;
  }
};


int main(){
  const int mod = (1e+9)+7;
  using mint = modint<mod>;
  int h,w; cin >> h >> w;
  string grid[1001];  
  for(int i = 0; i < h; ++i)cin >> grid[i];
  static mint dp[1001][1001];
  dp[0][0] = 1;
  for(int i = 1; i < h; ++i)if(grid[i][0]=='.')dp[i][0] = dp[i-1][0];
  for(int i = 1; i < w; ++i)if(grid[0][i]=='.')dp[0][i] = dp[0][i-1];
  for(int i = 1; i < h; ++i){
    for(int j = 1; j < w; ++j){
      if(grid[i][j] == '#')continue;
      dp[i][j] = dp[i-1][j] + dp[i][j-1];
    }
  }
  cout << dp[h-1][w-1] << endl;
  return 0;
}


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

typedef long long int ll;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    
    vector<int> x(n);
    for (int i = 0; i < n; ++i)
        cin >> x[i];
    
    int minRes = numeric_limits<int>::max();
    for (int pos = 1; pos <= 100; ++pos)
    {
        int currRes = 0;
        for (int i = 0; i < n; ++i)
            currRes += (x[i] - pos) * (x[i] - pos);
        
        minRes = min(minRes, currRes);
    }
    cout << minRes << "\n";

    return 0;
}


Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
int a[102];
 main()

{
    fast
    int ses=0,n;
    cin>>n;
    f(i,1,n)
    {
        cin>>a[i];
    }
    f(i,1,n-2)
    {
        f(j,i+1,n-1)
        {
            f(k,j+1,n)
            {
                 if(a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k])
                 {
                     if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i])
                     {
                         ses++;
                     }
                 }
            }

        }
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int n,k; cin >> n >> k;
    int num = 1;
    rep(i,n){
        num = min(num*2,num+k);
    }
    cout << num << endl;

    return 0;
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int N, X;
  cin >> N >> X;
  int M = INT32_MAX;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int m;
    cin >> m;
    if (X >= m) {
      X -= m;
      ans++;
    }
    if (M > m)
      M = m;
  }
  ans += X / M;
  cout << ans << endl;
}


Measured memory_bytes: 256
W, H, N = map(int, input().split())
x = [0]*N
y = [0]*N
a = [0]*N
for i in range(N):
  x[i], y[i], a[i] = map(int, input().split())
anslist = [[1 for i in range(H)] for j in range(W)]
for i in range(N):
  if a[i] == 1:
    for k in range(x[i]):
      for l in range(H):
        anslist[k][l] = 0
  elif a[i] == 2:
     for k in range(x[i], W):
      for l in range(H):
        anslist[k][l] = 0
  elif a[i] == 3:
     for k in range(W):
      for l in range(y[i]):
        anslist[k][l] = 0
  elif a[i] == 4:
     for k in range(W):
      for l in range(y[i],H):
        anslist[k][l] = 0
print(sum([sum(anslist[i]) for i in range(W)]))

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

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

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let a: Vec<Vec<i32>> = read_vec2(3);
    let n: i32 = read();
    let b: Vec<i32> = (0..n).map(|_| read()).collect();

    let mut table = [[false; 3]; 3];
    let mut yes = false;

    for (i, row) in a.iter().enumerate() {
        for (j, col) in row.iter().enumerate() {
            for v in &b {
                if v == col {
                    table[i][j] = true;
                }
            }
        }
    }

    // yoko
    for i in table.iter() {
        if i.iter().all(|&x| x) {
            yes = true;
            break;
        }
    }

    // tate
    if yes != true {
        if table[0][0] && table[1][0] && table[2][0] ||
        table[0][1] && table[1][1] && table[2][1] ||
        table[0][2] && table[1][2] && table[2][2] {
            yes = true;
        }
    }

    // naname
    if yes != true {
        if table[0][0] && table[1][1] && table[2][2] {
            yes = true;
        }

        if table[0][2] && table[1][1] && table[2][0] {
            yes = true;
        }
    }

    println!("{}", if yes {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
list_c = []

for i in range(3):
    list_c += [list(map(int, input().split()))]

is_success = True

c0 = sum(list_c[0])
c1 = sum(list_c[1])
c2 = sum(list_c[2])
if c0 % 3 != c1 % 3 \
        or c1 % 3 != c2 % 3 \
        or c2 % 3 != c0 % 3:
    is_success = False

c0 = sum([list_c[i][0] for i in range(3)])
c1 = sum([list_c[i][1] for i in range(3)])
c2 = sum([list_c[i][2] for i in range(3)])
if c0 % 3 != c1 % 3 \
        or c1 % 3 != c2 % 3 \
        or c2 % 3 != c0 % 3:
    is_success = False

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

Measured memory_bytes: 3192
// "include" {{{
#include <deque>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <utility>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long 
#define pii pair<int,int> 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

vector<int> t;
vector<int> a(5);

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	rep(i,5){
		cin >> a[i];
	}
	int k;
	cin >> k;
	sort(all(a));
	cout << ((a[4] - a[0] <= k) ? "Yay!\n" : ":(\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	ll N, A, B;
	cin >> N >> A >> B;
	if((B-A)%2==0) cout << (B-A)/2 << endl;
	else{
		ll mo=min(A, N-B+1);
		cout << mo+(B-A-1)/2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    Scanner   sc   = new Scanner(System.in);

    @SuppressWarnings("unused")
    void run() {
        int K = sc.nextInt();
        int T = sc.nextInt();
        PriorityQueue<Integer> que = new PriorityQueue<>(Collections.reverseOrder());
        for (int i = 0; i < T; i++) que.add(sc.nextInt());
        int c = 0;
        while(!que.isEmpty()) {
            if(que.size() == 1) c += que.poll() - 1;
            else {
                int a = que.poll() - 1;
                int b = que.poll() - 1;
                if(a > 0) que.add(a);
                if(b > 0) que.add(b);
            }
        }
        System.out.println(c);
    }

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

Measured memory_bytes: 10320
def trace( nums )
	output = []
	for i in ( 0 ... nums.length )
		output.push( nums[i]  )
		output.push( " " )
	end
	output.pop
	output.push( "\n" )
	print( output.join )
end

n = gets.to_i
nums = gets.split( " " ).map { |val| val.to_i }
trace( nums )

for i in ( 1 ... nums.length )
	key = nums[i]
	j = i - 1
	while 0 <= j && key < nums[j]
		nums[ j+1 ] = nums[j]
		j -= 1
	end
	nums[ j+1 ] = key
	trace( nums )
end

Measured memory_bytes: 6140
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

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

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

int main(){
	string s;
	string line;
	map<string, bool> words;
	map<string, bool> bad;
	int n, sz;
	while(getline(cin, s)){
		words.clear();
		bad.clear();
		n = s.size();
		line.clear();
		rep(i, n) {
			if(isalpha(s[i])) line.push_back(toupper(s[i]));
		}
		sz = line.size();
		
		rep(i, sz){
			int range = min(i+1, sz-i);
			int w = 0;
			rep(j, range){
				if(line[i-j] != line[i+j]) break;
				if(w > 0){
					string ng(line.begin() + i + 1 - w, line.begin() + i + w);
					words[ng] = false;
					bad[ng] = true;
				}
				w++;
			}
			if(w > 1){
				string a(line.begin() + i + 1 - w, line.begin() + i + w);
				if(!bad[a]) words[a] = true;
			}

			if(i != 0 && line[i-1] == line[i]){
				range = min(i, sz - i);
				w = 0;
				rep(j, range){
					if(line[i-j-1] != line[i+j]) break;
					if(w > 0){
						string ng(line.begin() + i - w, line.begin() + i + w);
						words[ng] = false;
						bad[ng] = true;
					}
					w++;
				}
				if(w > 1){
					string b(line.begin() + i - w, line.begin() + i + w);
					if(!bad[b]) words[b] = true;
				}
			}
		}
		
		int cnt = 0;
		for(map<string, bool>::const_iterator iter = words.begin(); iter != words.end(); iter++){
			if((*iter).second){
				if(cnt) cout <<" ";
				else cnt++;
				cout << (*iter).first;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <set>
#include <vector>
using namespace std;

using ull = unsigned __int128;
constexpr ull B = 100000007;

// memo[i] = B^i % M
vector<ull> memo;

int main() {
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    set<ull> s2;
    ull t = 1;
    vector<ull> rh(n+1);
    for(int i=0; i<=n; ++i) {
        memo.push_back(t);
        t *= B;
    }
    for(int i=0; i<n; ++i) {
        rh[i+1] = rh[i]*B + s[i];
    }
    ull l = 1, r = 1;
    for(int i=0; i<m; ++i) {
        string q;
        cin >> q;
        if(q == "L++") {
            ++l;
        } else if(q == "L--") {
            --l;
        } else if(q == "R++") {
            ++r;
        } else if(q == "R--") {
            --r;
        }
        s2.insert(rh[r] - rh[l-1]*memo[r-l+1]);
    }
    cout << s2.size() << endl;
}


Measured memory_bytes: 31328
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    a, b, c = MI()

    n = set([a, b, c])
    print("Yes" if len(n) == 2 else "No")


main()


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll L = a+b;
  ll R = c+d;
  string ans;
  if(L>R)
    ans = "Left";
  else if(R>L)
    ans = "Right";
  else
    ans = "Balanced";

  cout << ans << endl;
  
}


Measured memory_bytes: 256
list = input().split()
a = int(list[0])
b = int(list[1])
c = int(list[2])
d = int(list[3])
result = 0
if a < b and c < d:
    if (a >= c and b <= d) or (a <= c and b >= d):
        result = min(b-a,d-c)
    elif a <= c and c <= b:
        result = b - c
    elif c <= a and a <= d:
        result =  d - a
print(result)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  int N, Y, v;
  cin >> N >> Y;

  for (int i = 0; i <= N; i++) {
    for (int j = 0; j + i <= N; j++) {
      v = 10000*i + 5000*j + 1000*(N-i-j);

      if (v == Y) {
        printf("%d %d %d\n", i, j, (N-i-j));
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}


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

int main() {
  int M, N;
  cin >> N >> M;
  vector<int> A(N);
  for( int i=0; i < N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  if (A.at(M-1) >= float(accumulate(A.begin(), A.end(), 0))/float((4*M))){
   	cout << "Yes" << endl; 
  }
  else{
       	cout << "No" << endl; 
  }
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, M, V, P;
  cin >> N >> M >> V >> P;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.rbegin(),vec.rend());
  int64_t border = vec.at(P-1); //border以上であれば可能
  int64_t ok = P-1;
  int64_t ng = N;
  while(ng - ok > 1){
    bool flag = true;
    int64_t mid = (ok + ng) / 2;
    int64_t score = vec.at(mid) + M;
    if(score < border){
      flag = false;
    }
    int64_t vote = V*M;
    for(int i=0; i<N; i++){
      if(i < P-1 || i >= mid){
        vote -= M;
      }
      else{
        vote -= max((int64_t)0,score - vec.at(i));
      }
    }
    if(vote > 0){
      flag = false;
    }
    //cout << mid << " " << flag << endl;
    if(flag){
      ok = mid;
    }
    else{
      ng = mid;
    }
  }
  cout << ok + 1 << endl;  
}

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

int main() {
	double A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;
	if (V - W <= 0) cout << "NO" << endl;
	else cout << (abs(A - B) / (V - W) <= T ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
#include <algorithm>  
using namespace std;
int main(){
    string s,t;
    cin>>s;
    t=s;
    reverse(s.begin(),s.end());
    if(s==t){
    	string a,b;
    	a=s.substr(0,(s.size()-1)/2);
    	b=a;
    	reverse(a.begin(),a.end());
    	if(a==b){
    		string c,d;
    		c=s.substr((s.size()+3)/2-1,s.size()-1);
    		d=c;
    		reverse(c.begin(),c.end());
    		if(c==d){
    			cout<<"Yes";
    			return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int b, t, g, y, i, n, Max_num;
   double G, r, Max, key;
   scanf("%d", &n);
   while ( n ) {
      Max = Max_num = 0;
      scanf("%d", &y);
      for ( i = 0; i < n; i++ ) {
         G = 1;
         scanf("%d %lf %d", &b, &r, &t);
         if ( t == 1 ) {
            G = 1 + y * r / 100;
         } else {
            key = 1 + r / 100;
            for ( g = 1; g <= y; g++ ){
               G *= key;
            }
         }
         if ( G > Max ) { Max = G; Max_num = b; }
      }
      printf("%d\n", Max_num);
      scanf("%d", &n);
   }
   return 0;
}

Measured memory_bytes: 1816
using System;

namespace AIDU {
    class AIDU0021
    {
        public static void Main(){
            int N=int.Parse(Console.ReadLine());
            double[] ds= new double[6];
            string[] ss;
            int[] ress=new int[N];
            for(int i=0;i<N;i++) {
                ss=Console.ReadLine().Split();
                for(int j=0;j<6;j++) ds[j]=double.Parse(ss[j]);
                ress[i]=Intersects(ds);
            }
            for(int i=0;i<N;i++) Console.WriteLine(ress[i]);
        }

        static int Intersects(double[] x) {
            double d=Math.Sqrt(Math.Pow(x[3]-x[0],2)+Math.Pow(x[4]-x[1],2));
            if(d+x[2]<x[5])return -2; //A contained in B
            if(d+x[5]<x[2])return 2; //B contained in A
            if(x[2]+x[5]<d)return 0; //cap(A,B)=nothing;
            return 1;
        }

    }
}

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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  ll h;
  int n;
  cin >> h >> n;
  ll total = 0;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    total += k;
  }
  if (total >= h)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<double> x(N);
    vector<string> u(N);
    rep(i,N){
        cin >> x[i] >> u[i];
    }
    double ans = 0;
    rep(i,N){
        if(u[i] == "JPY") ans += x[i];
        else ans += x[i] * 380000;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }
        else if(a<=0) {
            cout << "No" << endl;
            break;
        }
        else{
            c-=b;
            a-=d;
        }
    }

}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s=="zyxwvutsrqponmlkjihgfedcba")cout<<-1<<endl;
    else if(s.size()<26){
        for(int i=0;i<26;i++){
            bool ok=true;
            for(int j=0;j<s.size();j++){
                if(s[j]-'a'==i)ok=false;
            }
            if(ok){
                cout<<s+(char)(i+'a')<<endl;
                break;
            }
        }
    }else{
        vector<bool> u(26,false);
        for(int i=s.size()-1;i>=0;i--){
            for(int j=s[i]-'a'+1;j<26;j++){
                if(u[j]){
                    for(int k=0;k<i;k++){
                        cout<<s[k];
                    }
                    cout<<(char)('a'+j)<<endl;
                    return 0;
                }
            }
            u[s[i]-'a']=true;
        }
    }
}

Measured memory_bytes: 256
/**
*    author:  souzai32
*    created: 02.08.2020 19:17:59
**/

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

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

    vector<tuple<int,int>> ab(m);
    int a,b;
    rep(i,m){
        cin >> a >> b;
        ab.at(i)=make_tuple(a,b);
    }

    sort(ab.begin(),ab.end());
    vector<bool> ship(n);
    bool ans=false;

    rep(i,m){
        if(get<0>(ab.at(i))==1) ship.at(get<1>(ab.at(i)))=true;
        if(get<1>(ab.at(i))==n){
            if(ship.at(get<0>(ab.at(i)))) ans=true;
        }
    }

    if(ans) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 4720
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

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

using namespace std;

int main(){
	
	long long int n, c, xi, vi, x, v, ans;
	vector<pair<long long int, long long int> > sushi;
	long long int v_t1[100005], v_t2[100005];
	long long int g[100005][2];
	
	cin >> n >> c;
	
	sushi.push_back(make_pair(0,0));
	REP(i,n){
		cin >> xi >> vi;
		sushi.push_back(make_pair(xi,vi));
	}
	
	v_t1[0] = 0;
	v_t2[0] = 0;
	
	for(int i=1; i<=n; i++){
		v_t1[i] = v_t1[i-1] + sushi[i].second;
		v_t2[i] = v_t2[i-1] + sushi[n-(i-1)].second;
	}
	
	g[0][0] = 0;
	g[0][1] = 0;
	for(int i=1; i<=n; i++){
		g[i][0] = max(g[i-1][0], v_t1[i]-sushi[i].first);
		g[i][1] = max(g[i-1][1], v_t1[i]-2*sushi[i].first);
	}
	// g[i][0] : v1+v2+...+vk - xk (0<=k<=i) が最も大きくなるkの、v1+v2+...+vk - xk の値
	// g[i][1] : v1+v2+...+vk - 2*xk (0<=k<=i) が最も大きくなるkの、v1+v2+...+vk - 2*xk の値
	
	ans = 0;
	
	for(int i=1; i<=n; i++){
		// 入店した位置からsushi[i]まで時計回りに歩く
		x = sushi[i].first;
		v = v_t1[i];
		ans = max(ans, v-x);
		
		// 入店した位置からsushi[i]まで反時計回りに歩く
		x = c - sushi[i].first;
		v = v_t2[n-(i-1)];
		ans = max(ans, v-x);
	}
	
	
	for(int i=1; i<=n; i++){
		x = 2*(c-sushi[i].first);
		v = v_t2[n-(i-1)];
		ans = max(ans, g[i-1][0] + v-x);
		
		x = c-sushi[i].first;
		ans = max(ans, g[i-1][1] + v-x);
	}
	
	printf("%lld\n", ans);
	
	return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<long int> ls(n+1);
  ls.at(0)=2;
  ls.at(1)=1;
  for(int i=2;i<=n;i++){
    long int l=ls.at(i-2)+ls.at(i-1);
    ls.at(i)=l;
  }
  cout<<ls.at(n)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
  
P project(P a,P b,P c){
  b-=a,c-=a;
  return a+b*real(c/b);
}
  
int main(){
  int n;
  double ax,ay,bx,by,cx,cy;
  cin>>ax>>ay>>bx>>by>>n;
  while(n--){
    cin>>cx>>cy;
    P p=project(P(ax,ay),P(bx,by),P(cx,cy));
    printf("%.8f %.8f\n",p.real(),p.imag());
  }
  return 0;
}


Measured memory_bytes: 3284
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>

using namespace std;

int main() {

	long long H;
	cin >> H;

	int straignt_count = 0; // 分裂しない場合に何回で消滅するか
	long long h = H;
	while (h > 1) {
		h /= 2;
		straignt_count++;
	}
	straignt_count++;

	// straight_countについて、総和をとる
	long long count = 0;
	long long mons_num = 1;
	for (int i = 0; i < straignt_count; i++) {
		count += mons_num; // モンスターの数だけ殴る
		mons_num *= 2; // モンスターの数が倍になる
	}

	cout << count << endl;

	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;
typedef long long ll;

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

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

int main(void){
    int t=0,f=0,nt=0,n;
    ll a;
    cin>>n;
    rep(i,n){
        cin>>a;
        if(a%2){
            ++nt;
        }
        else{
            if(a%4){
                ++t;
            }
            else{
                ++f;
            }
        }
    }
    nt+=t%2;
    if(f+1>=nt){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}
/*
*/


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, i, card[2], sum[2];
    scanf("%d", &n);
    
    while(n!=0){
        sum[0] = 0;
        sum[1] = 0;
        for(i=0; i < n; i++){
            scanf("%d %d", &card[0],&card[1]);
            if(card[0] > card[1])
                sum[0] += (card[0] + card[1]);
            else if(card[0] < card[1])
                sum[1] += (card[0] + card[1]);
            else {
                sum[0] += card[0];
                sum[1] += card[1];
            }
        }
        printf("%d %d\n", sum[0], sum[1]);
        
        scanf("%d", &n);
    }
    
    return 0;
}

Measured memory_bytes: 600
def plus(stack)
  a = stack.pop
  b = stack.pop
  stack.push(b+a)
end

def minus(stack)
  a = stack.pop
  b = stack.pop
  stack.push(b-a)
end

def times(stack)
  a = stack.pop
  b = stack.pop
  stack.push(b*a)
end

def divide(stack)
  a = stack.pop
  b = stack.pop
  stack.push(b/a)
end

while s = gets
  things = s[0..-2].split(" ")
  stack = Array.new()
  things.each{|thing|
    if thing == "+" then
      plus(stack)
    elsif thing == "-" then
      minus(stack)
    elsif thing == "*" then
      times(stack)
    elsif thing == "/" then
      divide(stack)
    else#数字
      stack.push(thing.to_f)
    end
  }
  puts "%6f" % stack.pop
end

Measured memory_bytes: 5100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (3e3) + 5;
double memo[N][N];
double P[N];
int n;

double DP(int pos, int cnt) {
	if (pos == n) return (cnt >= n/2 + 1? 1.0 : 0.0);
	double &ret = memo[pos][cnt];
	if (ret != -1.0) return ret;
	ret = P[pos] * DP(pos + 1, cnt + 1) + (1.0 - P[pos]) * DP(pos + 1, cnt);
	return ret;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%lf", &P[i]);
	}
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; j <= n; ++j) {
			memo[i][j] = -1.0;
		}
	}
	double ans = DP(0, 0);
	printf("%.12lf\n", ans);
	return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
using namespace std;
int main(){
int k,a,b;
cin >> k ;
cin >> a;
cin >> b;
int flag=0;
for(int i=a;i<b +1;i++){
	if(i%k==0){
      	cout<<"OK"<<endl;
      	flag =1;
    	break;
    	}
	}
if(flag ==0){
cout<<"NG";
}
}

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

using namespace std;

const long long MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin>>v[i];
    }
    //sort(vi.begin(),vi.end());
    int sum=0;
    for(int i:v){
        sum+=i;
    }
    int ans=sum%10?sum:0;
    //cout<<sum<<endl;
    for(int i:v){
        ans=max(ans, (sum-i)%10?sum-i:0);
    }
    cout<<ans<<endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define ff first
#define ss second

void setIO(string name = "") { // name is nonempty for USACO file I/O
    ios_base::sync_with_stdio(0); cin.tie(0); // see Fast Input & Output
    freopen((name+".in").c_str(), "r", stdin); // see Input & Output
    freopen((name+".out").c_str(), "w", stdout);
}
// the code that we provide requires everything above this line to compile



int main() {
	int n;cin>>n;
	int arr[n];
	for(int i = 0; i < n; ++i) cin>>arr[i];
	ll ans = 1e3;
	for(int i = 0; i < n - 1; ++i){
		ll st = 0;
		if(arr[i] < arr[i+1]) st = ans / arr[i];
		ans += (max(0, arr[i+1] - arr[i]))*st;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  uint16_t X, Y, Z, K;
  cin >> X >> Y >> Z >> K;

  vector<uint64_t> A(X),B(Y),C(Z);
  for (int ix=0; ix<X; ++ix)
    cin >> A[ix];
  for (int iy=0; iy<Y; ++iy)
    cin >> B[iy];
  for (int iz=0; iz<Z; ++iz)
    cin >> C[iz];

  // sort(A.begin(),A.end(), greater<uint64_t>());
  // sort(B.begin(),B.end(), greater<uint64_t>());
  // sort(C.begin(),C.end(), greater<uint64_t>());

  vector<uint64_t> D;
  uint64_t minD = 0;
  for (auto a : A) {
    for (auto b : B) {
      for (auto c : C) {
	uint64_t sum = a+b+c;
	if (sum>minD)
	  D.push_back(sum);
	if (D.size() > K+1000) {
	  sort(D.begin(),D.end(), greater<uint64_t>());
	  D.erase(D.begin()+K, D.end());
	  minD = D[K];
	}
      }
    }
  }

  sort(D.begin(),D.end(), greater<uint64_t>());

  for (int ii=0; ii<K; ++ii)
    cout << D[ii] << endl;

  return 0;
}


Measured memory_bytes: 384