akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <stack>
using namespace std;
 
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  vector< stack<int> > nums(n);
   
  while (q--) {
    int command, t; scanf("%d %d", &command, &t);
     
    switch (command) {
      case 0:
        int x; scanf("%d", &x);
        nums[t].push(x);
        break;
        
      case 1:
        if (!nums[t].empty()) printf("%d\n", nums[t].top());
        break;
        
      case 2:
        if (!nums[t].empty()) nums[t].pop();
        break;
    }
  }
}


Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
 ll n;
 cin >> n;
 vector<ll> v(2*n);
 rep(i,2*n){
    cin >> v[i];
 }
 sort(v.begin(),v.end());
 ll sum=0;
 rep(i,n){
 sum+=v[2*i];
 }
 cout << sum <<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

class Packet{
public:
  int time,src,dst;
  Packet(int _t,int _s,int _d) : time(_t),src(_s),dst(_d){}
  bool operator<(const Packet& p) const{
    return time < p.time;
  }
  bool operator>(const Packet& p) const{
    return time > p.time;
  }
};

int main(){
  int computer_num,send_list_num;
  while(~scanf("%d %d",&computer_num,&send_list_num)){
    if(computer_num == 0 && send_list_num == 0) break;

    vector<Packet> packets;
    for(int i=0;i<send_list_num;i++){
      int time,src,dst;
      scanf("%d %d %d",&time,&src,&dst);
      packets.push_back(Packet(time,src,dst));
    }

    sort(packets.begin(),packets.end());
    
    bool infected[20001];
    memset(infected,0,sizeof(infected));
    infected[1] = true;
    for(int i=0;i<packets.size();i++){
      if(infected[packets[i].src]){
	infected[packets[i].dst] = true;
      }
    }

    int res = 0;
    for(int i=1;i<=computer_num;i++){
      if(infected[i]) res++;
    }

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

Measured memory_bytes: 1684
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int X=gi();
	    int[] L=new int[N];

        for(int i=0; i<N; i++) {
        	L[i]=gi();
        }

        int c=1;   
        int d=0;
        for (int i=0; i<N; i++) {
        	d=d+L[i];
        	if(d>X) {
        		break;
        	}
        	c++;
        }
        

        System.out.print(c);

//        if (b>=1 && b<=12) {
//        	if(a>=1 && a<=12) {
//        	    System.out.println("AMBIGUOUS");
//        	} else {
//        		System.out.println("MMYY");
//        	}
//        }else {
//        	if(a>=1 && a<=12) {
//        	    System.out.println("YYMM");
//        	} else {
//        		System.out.println("NA");
//        	}
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35632
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
        String s = buf.readLine();
        int x = Integer.parseInt(s);
		int answer  = x*x*x;
		System.out.println(answer);
	}
}

Measured memory_bytes: 24068
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nmax_def 110000
using namespace std;
typedef long long ll;

int main() {
	ll i, j;
	ll W, H, x, y;
	ll ans1;
	int ans2;
	bool odd = true;
	scanf("%lld %lld %lld %lld", &W, &H, &x, &y);
	ans1 = W * H / 2;
	if ((W % 2 == 0) && (H % 2 == 0) && (x == W / 2) && (y == H / 2))
		ans2 = 1;
	else
		ans2 = 0;
	if (W % 2 == 0)
		odd = 0;
	if (H % 2 == 0)
		odd = 0;
	cout << ans1;
	if (odd)
		cout << ".5000000000";
	else
		cout << ".0000000000";
	cout << " " << ans2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a, b;
    while(1){
        cin >> a >> b;
        if(a == 0 && b == 0)break;
        for(int i = 0;i < a;i++){
            for(int j = 0;j < b;j++){
                if(i == 0||j == 0||i == a - 1||j == b - 1){
                cout << "#" ;
                }
                else{
                cout << "." ;
                }
                
            }
        cout << endl;
        }
    cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n,l;
  cin >> n >> l;
  vector<string>vec(n);
  
  rep(i,n) cin >> vec[i];
  sort(vec.begin(),vec.end());
  
  string ans="";
  rep(i,n) ans+=vec[i];
  
  cout << ans << endl;
 
  return 0;
}


Measured memory_bytes: 256
S=input()
T=input()
n=len(S)
m=len(T)
dp=[[0]*(m+1) for i in range(n+1)]
for i in range(n):
  for j in range(m):
    if S[i]==T[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])
ans=''
while n>0 and m>0:
  if dp[n][m]==dp[n-1][m]:
    n-=1
  elif dp[n][m]==dp[n][m-1]:
    m-=1
  else:
    n-=1
    m-=1
    ans=S[n]+ans
print(ans)

Measured memory_bytes: 144604
#define ll long long
#define lld long double
#define cn(n)  ll n;cin >> n;
#define tes(t) ll t;cin>>t;while(t--) 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define al(v) v.begin(), v.end()
#define oset(X) tree<X, null_type, less<X>, rb_tree_tag, tree_order_statistics_node_update>
#define roset(X) tree<X, null_type, greater<X>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const long double PI = 3.141592653589793;
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
ll power(ll x, ll y, ll p){ll res = 1;x %= p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}
ll po(ll base, ll powerRaised){if (powerRaised != 0)return (base * po(base, powerRaised - 1));else return 1;}
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a, b);}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif //*
	float d,t,s;
  cin>>d>>t>>s;
  if(d/s<=t)
  cout<<"Yes";
  else cout<<"No";
	
	
}
	

  


Measured memory_bytes: 3728
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>


int main(){
  std::string s, t;
  std::cin >> s >> t;
  int ans = 0;
  for (int i=0; i<s.length(); i++){
    if (s[i]!=t[i]) ans++;
  }
  std::cout << ans << std::endl;
  return 0;
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n, m;
    cin >> n >> m;

    vector<ll> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    vector< vector<int> > g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        --a; --b;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        bool f = true;
        for (int j : g[i]) {
            if (h[i] <= h[j]) {
                f = false;
                break;
            }
        }

        ans += f;
    }
    cout << ans << newl;
    return 0;
}

Measured memory_bytes: 9208
#include <iostream>
using namespace std;
long long a,b,n;
long long ans;
int main()
{
	cin>>a>>b>>n;
	ans = n / b;
	ans = ans * b - 1;
	cout<<max(a * ans / b - a * (ans / b),a * n / b - a * (n / b));
	return 0;
}

Measured memory_bytes: 3668
#include<stdio.h>
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        long long sum=1;
        int i;
        for(i=1;i<=n;i++)
        {
            sum*=i;
            sum%=1000000007;
        }
        sum%=1000000007;
        printf("%d\n",sum);
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define eb emplace_back
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b);
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c);
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n";
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define state tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define Z 505  //check the limits, man
#define N 100001
const ll INF = 1e10;
int main()
{
    int a,b;
    in2(a,b);
    if(a<10 && b<10)
        out(a*b);
    else
        out(-1);
}









Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
const int MOD = 1000000007;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int h, w;
int main()
{
	// DISCO presents ディスカバリーチャンネル コードコンテスト2020 予選-C, 935, 1:25:00(UNSOLVED)
	int K;
	cin >> h >> w >> K;
	vector<string> s(h);
	vector<int> y;
	vector<vector<int>> ans(h, vector<int>(w, -1));
	y.push_back(-1);
	rep(i, h) {
		cin >> s[i];
		rep(j, w) {
			if (s[i][j] == '#') y.push_back(i);
		}
	}
	sort(y.begin(), y.end());
	y.erase(unique(y.begin(), y.end()), y.end());
	int ySize = y.size();
	int num = 1;
	for (int i = 0; i < ySize - 1; ++i) {
		vector<int> x;
		x.push_back(-1);
		for (int j = 0; j < w; ++j) {
			if (s[y[i + 1]][j] == '#') x.push_back(j);
		}
		x.resize(x.size() - 1);
		x.push_back(w - 1);
		int xSize = x.size();
		
		if (i == ySize - 2)	y[i + 1] = h - 1;
		for (int j = 0; j < xSize - 1; ++j) {
			for (int k = y[i] + 1; k <= y[i + 1]; ++k) {
				for (int l = x[j] + 1; l <= x[j + 1]; ++l) {
					ans[k][l] = num;
				}
			}
			num++;
		}
	}

	rep(i, h) {
		rep(j, w) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
    int n;
    while(cin >> n){
        vector<string> a(n);
        for(int i=0; i<n; i++){
            cin >> a[i];
        }
        bool dp[1<<18][7];
        memset(dp, 0, sizeof(dp));
        for(int i=0; i<7; i++){
            dp[0][i] = true;
        }

        for(int i=0; i<(1<<n); i++){
            for(int j=0; j<7; j++){
                if(!dp[i][j]) continue;
                for(int k=0; k<n; k++){
                    if((i & 1<<k) != 0) continue;
                    if(j == a[k][0]-'0'){
                        dp[i | 1<<k][a[k][1]-'0'] = true;
                    }
                    if(j == a[k][1]-'0'){
                        dp[i | 1<<k][a[k][0]-'0'] = true;
                    }
                }
            }
        }
        bool ok = false;
        for(int i=0; i<7; i++){
            if(dp[(1<<n)-1][i]){
                ok = true;
            }
        }

        if(ok){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}


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

int main(void){
    int N; cin >> N;
    multiset<long long> A;
    for (int i = 0; i < N; i++) {
        long long a; cin >> a;
        A.insert(a);
    }
    
    vector<long long> powers_of_two;
    long long tmp = 1;
    long long tmp_limit = 1e16;
    for (;tmp <= tmp_limit;) {
        powers_of_two.push_back(tmp);
        tmp *= 2;
    }
    
    int ans = 0;
    while (!A.empty()) {
        auto itr = A.end();
        itr--;
        long long key = -1;
        for (int i = 0; powers_of_two[i] <= (*itr)*2; i++) {
            if (*itr < powers_of_two[i]) {
                key = powers_of_two[i];
            }
        }
        key = key - *itr;
        auto itr2 = A.lower_bound(key);
        if (itr2 != A.end() && *itr2 == key && itr2 != itr) {
            ans++;
            A.erase(itr2);
        }
        A.erase(itr);
    }
    cout << ans << endl;
}


Measured memory_bytes: 9600
def insertionSort(length, numbers):
     for i in range(length):
          for k in range(length):
               if numbers[i] <= numbers[k]:
                    numbers.insert(k, numbers[i])
                    del numbers[i+1]
                    print ' '.join(map(str, numbers))
                    break
          

length = int(raw_input())
numbers = map(int, raw_input().split())


insertionSort(length, numbers)

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

int x[8], y[8];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

int main() {
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> x[i] >> y[i];
    double sum = 0.0;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
        v[i] = i + 1;
    do {
        rep(i,n-1){
            sum += dist(v[i],v[i+1]);
        }
    } while(next_permutation(v.begin(), v.end()));
    int factorial = 1;
    rep(i,n){
        factorial *= (i+1);
    }
    double avg = sum / factorial;
    cout << fixed << setprecision(10) << avg <<endl;
}

Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string str;
    while(cin>>str){
        if(str[0]==str[1]&&str[1]==str[2])cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> pip;
const int inf=(1<<31)-1;

int n;

int main(){
	while(1){
		cin>>n;
		if(!n) break;
		int ans=1;
		int up=1,lef=2,rig=3;
		for(int i=0;i<n;i++){
			string str;
			int tmp;
			cin>>str;
			if(str=="North"){
				tmp=up;
				up=lef;
				lef=7-tmp;
			}
			else if(str=="East"){
				tmp=rig;
				rig=up;
				up=7-tmp;
			}
			else if(str=="West"){
				tmp=up;
				up=rig;
				rig=7-tmp;
			}
			else if(str=="South"){
				tmp=lef;
				lef=up;
				up=7-tmp;
			}
			else if(str=="Right"){
				tmp=lef;
				lef=rig;
				rig=7-tmp;
			}
			else if(str=="Left"){
				tmp=rig;
				rig=lef;
				lef=7-tmp;
			}
			ans+=up;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1212
from math import ceil
A,B,C,X,Y=list(map(int,input().split()))

# ABピザを買わないと
x=A*X+B*Y
#ABピザをいくつか買う時
if X>=Y:
    y=C*2*Y+A*ceil((2*X-2*Y)/2)
else:
    y=C*2*X+B*ceil((2*Y-2*X)/2)
#ABピザのみで買う時
z=C*2*max(X,Y)
    
print(min(x,y,z))

Measured memory_bytes: 3064
#include <stdio.h>
int N;
int F[100][14];
int P[100][15];
int main() {
  scanf("%d",&N); 
  for(int i=0;i<N;i++) 
    for(int j=0;j<10;j++)scanf("%d",&F[i][j]);
  for(int i=0;i<N;i++)
    for(int j=0;j<11;j++)scanf("%d",&P[i][j]); 
  int res=-(1<<30);
  for(int b=1;b<(1<<10);b++) { 
    int cc=0; 
    for(int i=0;i<N;i++) { 
      int c=0; 
      for(int j=0;j<10;j++)
        if((b>>j&1)&&F[i][j])c++; cc+=P[i][c];
      } 
      if(res<cc)res=cc;
  } printf("%d\n",res);
}


Measured memory_bytes: 128
n=int(input())
li=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
  li[i].append(li[i][0]-li[i][1])
  li[i].append(li[i][0]+li[i][1])

from operator import itemgetter
li=sorted(li, key=itemgetter(3))

ans=0
now=0

for i in range(n-1):
  if li[now][3]>=li[i+1][3]: #今調査してるやつが、次のやつを覆ってしまってる場合
    ans+=1
    now=i+1
  elif li[now][3]>li[i+1][2]:
    ans+=1
  else:
    now=i+1

print(n-ans)

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

int dp[50];

int fib(int n) {
	if (n == 0 || n == 1) return dp[n] = 1;
	if (dp[n] != -1) return dp[n];
	return dp[n] = fib(n - 1) + fib(n - 2);
}


int main() {
	int n, i;
	for (i = 0; i < 50; i++) dp[i] = -1;

	cin >> n;
	cout << fib(n) << endl;

	return 0;
}


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

int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int num=1e9;
  for(int i=0;i<=100000;i++){
    int sum=i*2*c+a*max(x-i,0)+b*max(y-i,0);
    num=min(sum,num);
  }
  cout<<num<<endl;
}


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

#define ll long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    //COMint();
    int N=in();
    int A=in();
    int B=in();
    int ans;

    ans=min(B,A*N);
    print(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    int a[n][m];
    rep(i,n){
        rep(j,m){
            cin >> a[i][j];
        }
    }
    int b[m];
    rep(i,m){
        cin >> b[i];
    }
    int ans=0;
    rep(i,n){
        rep(j,m){
            ans+=a[i][j]*b[j];
        }
        printf("%d\n",ans);
        ans=0;
    }
    return 0;
}


Measured memory_bytes: 3236
#include<stdio.h>
#include<string.h>
int main(){
  char a[10];
  int i,k=0;
  scanf("%s", &a);
  for(i=0;i<strlen(a);i++){
    if(a[i]=='+')
      k++;
    else
      k--;
  }
  printf("%d",k);
  return 0;
}


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

inline int a2i(char c){
	if(islower(c))
		return c-'a';
	else
		return c-'A'+26;
}


int main(void){
	string s;
	while(cin >> s){
		if(s=="#") break;

		const int n = s.size();
		if(n <= 2){
			puts("No Results");
			continue;
		}

		int ans = n + 1;
		const int limit = 52;

		bool graph[limit][limit];
		
		rep(i,limit)rep(j,limit) graph[i][j]=false;
		rep(i,n-1) graph[a2i(s[i])][a2i(s[i+1])]=true;

		
		set<int> words;
		rep(i,n) words.insert(a2i(s[i]));

		int in[limit],out[limit];
		rep(i,limit) in[i] = out[i] = 0;
		rep(i,limit)rep(j,limit) in[j]+=graph[i][j],out[i]+=graph[i][j];


		rep(from,limit)rep(to,limit){
			if(words.find(from)==end(words)) continue;
			if(words.find(to)==end(words)) continue;
			
			in[from]++,out[to]++;
			int num = 0;
			rep(i,limit) num += max(in[i],out[i]);
			in[from]--,out[to]--;
			

			bool ok = true;
			if(from == a2i(s[0]) and to == a2i(s[n-1]) and num == n){
				
				ok = false;
				int cur = from;
				rep(idx,n-1){
					const int tar = a2i(s[idx+1]);
					
					bool reach[limit][limit];
					rep(i,limit)rep(j,limit) reach[i][j]=graph[i][j];
					rep(k,limit)rep(i,limit)rep(j,limit) reach[i][j]|=(reach[i][k]&reach[k][j]);

					bool loop = reach[tar][cur];
					if(loop){
						rep(j,limit){
							if(j!=tar and graph[cur][j] and reach[j][cur]){
								ok = true;
							}
						}
					}

					graph[cur][tar] = 0;
					cur = tar;
				}
			}
			if(ok) ans = min(ans,num);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3020
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, const char*>
const int INF = INT_MAX / 2;
const int N = 500000;

string str;

int min(int n){
    if(n == 0) return 2;
    if(n == 1) return 1;
    if(n == 2) return 0;
}

int multi(int n, int m){
    if(n == 0 || m == 0) return 0;
    if(n == 1 || m == 1) return 1;
    return 2;
}

int add(int n, int m){
    if(n == 2 || m == 2) return 2;
    if(n == 1 || m == 1) return 1;
    return 0;
}

P formula(const char *p, int np, int nq, int nr){
    if(*p == '0') return P(0, p + 1);
    else if(*p == '1') return P(1, p + 1);
    else if(*p == '2') return P(2, p + 1);
    else if(*p == 'P') return P(np, p + 1);
    else if(*p == 'Q') return P(nq, p + 1);
    else if(*p == 'R') return P(nr, p + 1);
    else if(*p == '-'){
        P tmp = formula(p + 1, np, nq, nr);
        int n = tmp.first;
        return P(min(n), tmp.second);
    }
    else if(*p == '('){
        P tmp = formula(p + 1, np, nq, nr);
        int left = tmp.first;
        p = tmp.second;
        char op = *p;
        tmp = formula(p + 1, np, nq, nr);
        int right = tmp.first;
        //debug
        //cout <<left <<" " <<op <<" " <<right <<endl;
        if(op == '*') return P(multi(left, right), tmp.second + 1);
        else if(op == '+') return P(add(left, right), tmp.second + 1);
    }
}

int main(){
    while(cin >>str){
        if(str == ".") break;
        int cnt = 0;
        REP(p, 3){
            REP(q, 3){
                REP(r, 3){
                    int tmp = formula(str.c_str(), p, q, r).first;
                    //cout <<p <<", " <<q <<", " <<r <<" = " <<tmp <<endl;
                    if(tmp == 2){
                        //cout <<"!" <<endl;
                        cnt++;
                    }
                }
            }
        }
        cout <<cnt <<endl;
    }
    return 0;
}

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

int main() {
	string s; cin >> s;
	if (s.back() != 's') { s.push_back('s'); }
	else { s.push_back('e'); s.push_back('s'); }
	cout << s << '\n';
	cin.ignore(2); return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
#define P pair<int,int>
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

string fn(int N){
	string S(10,'0');
	REP(i,10){
		if(pow(2,9-i)<=N){
			S[i]='1'; 
			N-=pow(2,9-i);
		}
	}
	return S;
}
int main(void){
	int N,F[100][10];
	ll p[100][11],result=-INF;

	cin>>N;
	REP(i,N) REP(j,10)  cin>>F[i][j];
	REP(i,N) REP(j,11) cin>>p[i][j];

	FOR(i,1,1024){
		ll tem=0;
		string S=fn(i);
		REP(i,N){
			int c=0;
			REP(j,10) if(S[j]=='1'&&F[i][j]) c++;
			tem+=p[i][c];
		}
		chmax(result,tem);
	}
	print(result);
	return 0;
}



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

#define int long long

int N, W;

typedef vector<int> vi;
typedef vector<vi> vvi;

vi weight, value;

vvi dp;

int knapsack(int i, int w)
{
    if(dp[i][w] != LLONG_MIN)
        return dp[i][w];

    if(i==N+1)
        return 0;

    if(w < weight[i])
        return dp[i][w] = knapsack(i+1 , w);

    return dp[i][w] = max(   value[i] + knapsack(i+1 , w-weight[i])  ,  knapsack(i+1 , w)   );
}

signed main()
{
    cin>>N>>W;

    weight.resize(N+1);
    value.resize(N+1);

    dp.resize(N+2 , vi(1e5+2 , LLONG_MIN));

    for(int i=1 ; i<= N ; i++)
    {
        cin>>weight[i]>>value[i];
    }

    cout<<knapsack(1,W);
}

Measured memory_bytes: 81024
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

int ga, gb;
int depth;

vector<pair<pair<int, int>, int>> get(long long a, long long b, int k)
{
    if (++depth > 3) assert(0);
    if (a <= k && b <= k) {
        vector<pair<pair<int, int>, int>> ret;
        ret.push_back(make_pair(make_pair(a, b), 1));
        return ret;
    }
    long long l = 1, r = a + b + 1;
    if (a > b) {
        if (b * k < a) {
            vector<pair<pair<int, int>, int>> ret;
            ret.push_back(make_pair(make_pair(k, 1), b));
            ret.push_back(make_pair(make_pair(a - b * k, 0), 1));
            return ret;
        }
        while(l + 1 < r) {
            long long mid = (l + r) / 2;
            long long la = a - mid * k, lb = b - mid;
            if (la < 0 || lb < 0 || la * k < lb || lb * k < la) {
                r = mid;
            } else {
                l = mid;
            }
        }
        long long la = a - l * k, lb = b - l;
        vector<pair<pair<int, int>, int>> ret = get(la, lb, k);
        ret.insert(ret.begin(), make_pair(make_pair(k, 1), l));
        return ret;
    } else {
        if (a * k < b) {
            vector<pair<pair<int, int>, int>> ret;
            ret.push_back(make_pair(make_pair(0, b - a * k), 1));
            ret.push_back(make_pair(make_pair(1, k), a));
            return ret;
        }
        while(l + 1 < r) {
            long long mid = (l + r) / 2;
            long long lb = b - mid * k, la = a - mid;
            if (la < 0 || lb < 0 || la * k < lb || lb * k < la) {
                r = mid;
            } else {
                l = mid;
            }
        }
        long long lb = b - l * k, la = a - l;
        vector<pair<pair<int, int>, int>> ret = get(la, lb, k);
        ret.push_back(make_pair(make_pair(1, k), l));
        return ret;
    }
}

void solve()
{
    int n;
    cin >> n;
    for( ; n--; ) {
        depth = 0;
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int len;
        if (a >= b) {
            len = (a - 1) / (b + 1) + 1;
        } else {
            len = (b - 1) / (a + 1) + 1;
        }
        vector<pair<pair<int, int>, int>> vec = get(a, b, len);
        for(int i = c; i <= d; ++ i) {
            int x = i;
            for(int j = 0; j < vec.size(); ++ j) {
                int a = vec[j].first.first;
                int b = vec[j].first.second;
                int mul = vec[j].second;
                if (x <= (a + b) * mul) {
                    x %= a + b;
                    if (x == 0) x += a + b;
                    if (x <= a) putchar('A');
                    else putchar('B');
                    break;
                } else {
                    x -= (a + b) * mul;
                }
            }
        }
        puts("");
    }
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 384
INF = 10 ** 10
n, m = gets.split.map(&:to_i)
bin_memo = [1]
1.upto(n - 1) do |i|
  bin_memo[i] = bin_memo[i - 1] * 2
end
costs = []
keys = []
m.times do
  costs << gets.to_i
  keys << gets.split.map(&:to_i).inject(0) { |res, num| res + bin_memo[num - 1] }
end
dp = Array.new(2 ** n, INF)
dp[0] = 0
keys.each_with_index do |key, i|
  dp.each_with_index do |cost, opened|
    next if cost == INF
    next_opened = (opened | key)
    dp[next_opened] = [dp[next_opened], cost + costs[i]].min
  end
end
puts dp.last == INF ? - 1 : dp.last


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

using namespace std;
#define ALL(v) (v).begin(), (v).end()

int main()
{
  vector<int> x(3); cin >> x[0] >> x[1] >> x[2];
  sort(ALL(x));

  int ans = (x[2]-x[1])/2 + (x[2]-x[0])/2;
  if ((x[2]-x[1])%2 == 0 and (x[2]-x[0])%2 == 0) {
    ans += 0;
  } else if ((x[2]-x[1])%2 == 1 and (x[2]-x[0])%2 == 1) {
    ans += 1;
  } else {
    ans += 2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#define MOD 1000000007

typedef long long ll;
using namespace std;

int main(void) {
    int i,j=0;
    int n;
    cin >> n;
    vector<string> s;
    for(i=0;i<n;i++){
        string ahi;
        cin >> ahi;
        s.push_back(ahi);
    }
    int as=0,bs=0;
    int cnt=0;
    int check = 1;
    for(i=0;i<n;i++){
        for(j=0;j<s[i].size()-1;j++){
            if(s[i][j]=='A' && s[i][j+1]=='B'){
                cnt++;
            }
        }
        if(s[i][0]=='B'){
            bs++;
        }
        if(s[i].back()=='A'){
            as++;
        }
        if(!(s[i][0]=='B' && s[i].back()=='A' || s[i][0]!='B' && s[i].back()!='A')){
            check=0;
        }
    }
    if(check && min(as,bs)){
        cnt--;
    }
    cout << min(as,bs)+cnt << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int, int>> x(n);
    REP(i, n) {
        cin >> x[i].first;
        x[i].second = i;
    }
    sort(ALL(x));
    vector<pair<int, int>> y;
    REP(i, n) y.push_back(make_pair(x[i].second, i));
    sort(ALL(y));

    int ans1 = x[n / 2 - 1].first;
    int ans2 = x[n / 2].first;
    REP(i, n) cout << (y[i].second < n / 2 ? ans2 : ans1) << endl;
    
    return 0;
}


Measured memory_bytes: 5488
#include<bits/stdc++.h>
using namespace std;
 
/*
*****************code written By**********************
..................Marajul islam.......................
...................BSMRSTU,CSE........................
*/ 
 
int sc1() {int x; scanf("%d", &x); return x;}
 
long long sc2() {long long x; scanf("%lld", &x); return x;}
 
 
 
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
 
 
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}
 

 
 
int solve() {
 

 	int a,b,c;
 	cin>>a>>b>>c;
 	if((a==b && b!=c) || (b==c && a!=b) || (a==c && b!=c)) cout<<"Yes"<<endl;
 	else cout<<"No"<<endl;
	return 0;
}
 
 
 
 
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  n%=10;
  if(n==2||n==4||n==5||n==7||n==9){printf("hon");return 0;}
  if(n==0||n==1||n==6||n==8){printf("pon");return 0;}
  if(n==3){printf("bon");return 0;}
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,n1,k,x,y;
  cin>>n>>k;
  
  if(k==1)
  {
    n=0;
  }
  else{
    if(n<k){
    x=abs(n-k);
    
    y=abs(x-k);
   
    n=min(x,y);
    }
    else{
      x=n%k;
      y=abs(n%k-k);
      n=min(x,y);
    }
    
  }
  
  cout<<n;
  return 0;
}
    
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int th[2][201],i,n,m,s,h,tc,hc,t,ha,flg;
	while(1){
		cin>>n;
		if(n==0)break;
		for(i=1;i<=2*n;i++){
			th[0][i]=0;
			th[1][i]=0;
		}
		for(i=0;i<n;i++){
			cin>>m;
			th[0][m]=1;
		}
		for(i=1;i<=2*n;i++){
			if(th[0][i]==0) th[1][i]=1;
		}
		h=0; s=1; t=n; ha=n;
		while(1){
			if(t==0||ha==0) break;
			flg=0;
			for(i=s;i<=n*2;i++){
				if(th[h][i]==1){
					th[h][i]=0;
					s=i;
					flg=1;
					break;
				}
			}
			if(flg==1){
				if(h==0) t--;
				else ha--;
			}
			else s=1;
			if(h==0) h=1;
			else h=0;
		}	
		tc=0; hc=0;
		for(i=1;i<=2*n;i++){
			if(th[0][i]==1) hc++;
			if(th[1][i]==1) tc++;
		}
		cout<<tc<<endl<<hc<<endl;
	}
	return 0;
}

Measured memory_bytes: 2996
#include <bits/stdc++.h>
#define f(n) ((n + 1LL) * (n) / 2)
using namespace std;
const int mod = 1e9 + 7;

int main() {

    int n, k; 
	cin >> n >> k;
    int ans = 1;
    
    for (int i = k; i <= n; i++) 
        ans = (ans + f(n) - f(n - i) - f(i - 1) + 1) % mod;
    
    cout << ans << endl;
    return 0;
}

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

int main() {
  while(true) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    double m, sum;
    sum = 0;
    vector<int> s(n);
    for (int i = 0; i < n; i++) {
      cin >> s.at(i);
      sum += s.at(i);
    }
    m = sum / n;
    double a2 = 0;
    for (int i = 0; i < n; i++) {
      a2 += pow((s.at(i) - m), 2);
    }
    a2 /= n;
    cout << fixed << setprecision(8);
    cout << sqrt(a2) << endl;
  }
}



Measured memory_bytes: 3244
s = gets.chomp
ary = s.each_char.to_a

sum = 0
count = 0 #出すのがグーなら+1,パーなら-1
ary.each do |c|
  if c=='g'
    if count > 0
      # パーを出す
      sum += 1
      count -= 1
    else
      # グーを出す
      count += 1
    end
  else
    # 相手はパー
    if count > 0
      #パーを出す
      count -= 1
    else
      count += 1
      sum -= 1
    end
  end
end

puts sum


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

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

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

#define fi first
#define se second

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

    int64_t a,b;cin >> a >> b;
    cout << a * b << '\n';

}


Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
  vector<int> plane(3);
  for (int i = 0; i < 3; i++) {
    cin >> plane[i];
  }
  sort(plane.begin(), plane.end());
  cout << plane[0]+plane[1] << endl;
}


Measured memory_bytes: 256
x,n = map(int,input().split())
if n == 0:
  print(x)
else:  

  lst = list(map(int,input().split()))

  s = 0
  v = x 
  w = x

  while v in lst and w in lst:
    s += 1
    v = x - s
    w = x + s
  
  
  if v not in lst:
    print(v)
  else:
    print(w)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int c[3][3];
    for(int i = 0;i < 3;i++)
    {
        for(int j = 0;j < 3;j++)
        {
            cin >> c[i][j];
        }
    }
    bool flag = true;
    for(int i = 0;i < 2;i++)
    {
        int x = c[0][i] - c[0][i + 1];
        int y = c[i][0] - c[i + 1][0];
        for(int j = 1;j < 3;j++)
        {
            if(c[j][i] - c[j][i + 1] != x)
            {
                flag = false;
                break;
            }
            if(c[i][j] - c[i + 1][j] != y)
            {
                flag = false;
                break;
            }
        }
    }
    if(flag)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[4];
	cin >> s;
	int a = 0, b = 0;
	for(int i = 0; i < 3; i++)
		if(s[i] == 'A')a++;
		else
			b++;
	if(a == 3 || b == 3)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
#define l long int
using namespace std;

int main()
{
   FAST
int n;
l cnt=0;

cin>>n;
ll a[n];

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

int i=0,j=1,k;

for(i=0;i<n-2;i++)
{
	for(j=i+1;j<n-1;j++)
	{
		k=j+1;
		while(k<n)
		{
		if(a[i]==a[j] || a[i]==a[k] || a[j]==a[k])
		{
		k++;
		continue;	
		}
		else
		{
			int mx;
			
			if(a[i]> a[j] && a[i]>a[k])
			mx=i;
			else if(a[j]> a[i] && a[j]>a[k])
			mx=j;
			else
			mx=k;
			
			if(mx==i && a[mx]<(a[j]+a[k]))
			cnt++;
			else if(mx==j && a[mx]<(a[i]+a[k]))
			cnt++;
			else if(mx==k && a[mx]<(a[j]+a[i]))
			cnt++;
			
		}
		k++;
		}
	}
}
cout<<cnt;
}


























//sort(a,a+n);
//for(i=n-2;i>=0;i--)
//{
//	if(a[i]==a[i+1])
//	{
//		j=i;
//		while(j<n-1)
//		{
//			a[j]=a[j+1];
//			j++;
//		}
//		n--;
//	}
//}








//	
//	 j=i+1;
//	k=n-1;
//while(k>j)	
//{
//	if(a[i]+a[j]>a[k])
//	{
//		int l=k-i+1;
//		cnt+=(l*(l-1))/2;
//		break;
//	}
//	k--;

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,x,p=0;
 map<int,int>mp;
 long long int n;
 cin>>n;
 long long int a[n];
 for(i=1;i<=n;i++)
 {
     cin>>a[i];
     mp[a[i]]++;
     if(mp[a[i]]>=2)
     {

         cout<<"NO";
         p++;
         return 0;
     }
 }
 if(p==0)
 {
     cout<<"YES";
 }


return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define endl '\n'
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define inf 1e18
#define pf push_front
#define pob pop_back
#define pof pop_front
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

typedef pair<int,int> pi;
typedef pair<int,pair<int,int>> piii;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;

int32_t main()
{
   // boost
    int tt=1;
    //cin>>t;
    while(tt--)
    {
        string s,t;
        cin>>s>>t;
        int n=s.size();
        int ans=1e10;
        for(int i=0;i<n;i++)
        {
            int ctr=0;
            if(i+t.size()-1<n)
            {
            for(int j=0;i+j<n&&j<t.size();j++)
            {
                if(t[j]!=s[i+j])
                ctr++;
            }
            ans=min(ans,ctr);
            }
        }
        cout<<ans<<endl;
    }



    

}

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

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

    string n;
    int ff=0;
    cin >> n;
    for(char x:n) {
        if(x=='7') ff=1;
    }
    ff?cout << "Yes\n":cout << "No\n";

    return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >>k;
	VI a(n);
	rep(i,n) cin>>a[i];
	
	vector<ll> sm(n+1), cdt; cdt.reserve(n*(n+1)/2 + 10);
	
	rep(i,n) sm[i+1] = sm[i] + a[i];
	
	rep(i, n) rep2(j,i+1,n+1) cdt.emplace_back(sm[j] - sm[i]);
	
	ll ans = 0;
	repr(i, 44, 0){
		int sm = 0;
		ll nxt = ans | 1LL<<i;
		for(auto x: cdt) if((x & nxt) == nxt) sm++;
		if(sm >= k) ans = nxt;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main() {
  vector<int>c(5);
  rep(i,5) cin >> c[i];
  rep(i,5) if(c[i] == 0) cout << i+1 << endl;
}

Measured memory_bytes: 3624
pub struct Scanner {
    line: Vec<String>,
    idx: usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        return Scanner {
            line: vec![],
            idx: 0,
        };
    }
    fn next<T: std::str::FromStr>(&mut self) -> T {
        if self.idx == self.line.len() {
            let mut buffer = String::new();
            std::io::stdin().read_line(&mut buffer).ok();
            let a: Vec<&str> = buffer.trim().split(' ').collect();
            self.line = a.iter().map(|&s| String::from(s)).collect();
            self.idx = 0;
        }
        let ret: T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
        self.idx += 1;
        ret
    }
    fn next_string(&mut self) -> Vec<char> {
        let s: String = self.next();
        return s.chars().collect::<Vec<char>>();
    }
    fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut v: Vec<T> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
}

fn main(){
    let mut scan = Scanner::new();
    let s = scan.next_string();
    let mut dp: Vec<i64> = vec![0; 2019];

    let mut cur: usize = 0;
    let mut ans: i64 = 0;
    for i in 0..s.len() {
        let c: usize = s[i] as usize - '0' as usize;
        
        cur *= 10;
        cur += c;
        cur %= 2019;
        let mut nxt: Vec<i64> = vec![0; 2019];
        for i in 0..2019 {
            nxt[i*10%2019] += dp[i];
        }
        dp = nxt;
        
        ans += dp[cur];
        if cur == 0{
            ans += 1;
        }
        
        dp[cur] += 1;
    }
    println!("{}", ans);
}


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

int main(){
	int n;
	cin>>n;
	for(int i=0; i<n; i++){
		string a, b;
		cin>>a>>b;
		int kuri = 0;
		int k = 0;
		string ans = "";
		while(true){
			bool breakflg = true;
			int ai = 0;
			int bi = 0;
			if(int(a.size())-k-1 >= 0){
				ai = a[int(a.size())-k-1] - '0';
				breakflg = false;
			}
			if(int(b.size())-k-1 >= 0){
				bi = b[int(b.size())-k-1] - '0';
				breakflg = false;
			}
			k++;
			int sum = ai + bi + kuri;
			if(!kuri&&breakflg) break;
			if(sum>9){
				kuri = 1;
				sum %= 10;
			} else {
				kuri = 0;
			}
			ans.push_back('0'+sum);
		}
		reverse(ans.begin(), ans.end());
		if(ans.size()>80){
			cout<<"overflow"<<endl;
		} else {
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import qualified Data.ByteString.Char8 as BS

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

calc :: [(Char, Char)] -> String
calc [] = ""
calc (s : ss) = fst s : snd s : calc ss

main = do
  [o] <- getString
  [e] <- getString
  let lasted
        | length o /= length e = [last o]
        | otherwise = ""
  let ss = zip o e
  putStrLn $ (calc ss) ++ lasted


Measured memory_bytes: 508