akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

ll modpow(ll x, ll n, ll mod){
	ll res = 1;
	while(n > 0){
		if(n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

int main(){
	ll n,m; cin >> n >> m;
	vl s(m), c(m);
	rep(i,m) cin >> s[i] >> c[i];
	ll N = modpow(10,n-1,mod);
	vl t(10,0);
	if(n==1){
		rep(i,10){
			if(m==0){
				cout << i << endl;
				return 0;
			}
			ll tmp = i;
			ll id = 0;
			while(tmp > 0){
				t[id] = tmp % 10;
				tmp /= 10;
				id++;
			}
			rep(j,m){
				if(t[n-s[j]] != c[j]) break;
				if(j==m-1){
					cout << i << endl;
					return 0;
				}
			}
		}
	}else{
		REP(i,N,N*10){
			if(m==0){
				cout << i << endl;
				return 0;
			}
			ll tmp = i;
			ll id = 0;
			while(tmp > 0){
				t[id] = tmp % 10;
				tmp /= 10;
				id++;
			}
			rep(j,m){
				if(t[n-s[j]] != c[j]) break;
				if(j==m-1){
					cout << i << endl;
					return 0;
				}
			}
			rep(j,3) t[j] = 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    out.println(Math.min(N*A, B));
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

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

class Main{
    static int mod = 1000000007;
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        int num = Integer.parseInt(br.readLine());
        String[] str = br.readLine().split(" ");

        //for algorithim 
        long result = 0;
        long pow = 0;
        long tmp = 0;

        //algorithm
        for(int i = 0; i < 60; i++){
          long zero = 0;
          long one = 0;

          for(int j = 0; j < num; j++){
            if(((Long.parseLong(str[j]) >> i) & 1) == 0){
              zero++;
            }else{
              one++;
            }
          } 

          pow = (long)Math.pow(2.0, (double)i) % mod;
          tmp = (one * zero) % mod;
          result += tmp * pow;
        }
        
        System.out.println(result % mod);

      }
    }
}

Measured memory_bytes: 91220
// i_m_arin

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef map<ll,ll> mpll;
typedef set<ll> stll;

#define f(i, a, n) 	for(ll i=a; i<(ll)n; i++)
#define f2(i, a, b) for(ll i=a; i<=(ll)b; i++)
#define pb 			push_back
#define ff 			first
#define ss 			second
#define pf			push_front
#define mp			make_pair
#define all(a)		(a).begin(),(a).end()
#define decimal(x)	fixed<<setprecision(x)
#define fsort(a)	sort(all(a))
#define rsort(a)	sort(all(a),greater<>())
#define fast_io		ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem0(a)		memset(a,0,sizeof(a))
#define mem1(a)		memset(a,-1,sizeof(a))
#define lcm(a,b)	(a*b)/__gcd(a,b)
#define ub(v,x)		upper_bound(all(v),x)-v.begin()
#define lb(v,x)		lower_bound(all(v),x)-v.begin()

const ld PI  = acos(-1);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll SIZE= 100000;


void solve(){

int x;
cin>>x;
if(x==0) cout<<1<<endl;
else cout<<0<<endl;

}


int main(){
	fast_io;
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 105
#define WMAX 10005

struct Item
{
    int w,v;
};

Item item[MAX];

int main(){
    int N,W; cin >> N >> W;
    for(int i = 1; i <= N; i++){
        cin >> item[i].v >> item[i].w;
    }

    int table[MAX][WMAX];
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= W; j++){
            table[i][j] = 0;
        }
    }

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= W; j++){
            table[i][j] = table[i-1][j];
            if(j < item[i].w){
                continue;
            }
            table[i][j] = max(table[i][j], table[i-1][j-item[i].w]+item[i].v);
            table[i][j] = max(table[i][j], table[i][j-item[i].w]+item[i].v);
        }
    }

    // for(int i = 0; i <= N; i++){
    //     for(int j = 0; j <= W; j++){
    //         cout << table[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    cout << table[N][W] << endl;
    return 0;
}


Measured memory_bytes: 7068
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_set>
#include<vector>
#include<utility>
#include<cstring>
#define pb(a)             push_back(a)
#define mp(a,b)           make_pair(a,b)
#define pf printf
#define ff first
#define ss second
#define sef second.first
#define ses second.second
#define ms(a,b)            memset(a, b, sizeof(a))
#define loop(i,a)          for(int i=1;i<=a;i++)
#define pii                pair <int,int>
#define sl(a)              scanf("%I64d",&a)
#define sll(a,b)           scanf("%I64d %I64d",&a,&b)
#define si(a)              scanf("%d",&a)
#define sii(a,b)           scanf("%d %d",&a,&b)
using namespace std ;
typedef long long ll ;
int main()
{
  double r,p= (double)22/7;
  cin >> r ;
  double ans = (double)2*p*r ;
  pf("%.5f\n",ans);
  return 0 ;
}


Measured memory_bytes: 3776
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,sum = 0,Max,l;
    cin >> n >> Max;
    sum += Max;
    for(int i = 0;i < n - 1;i++)
    {
        cin >> l;
        if(max(Max,l) == l){sum += l; Max = l;}
        else{sum += l;}
    }
    if(Max < sum - Max){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}

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

using namespace std;

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

    int cnt{0}, i, maxr{0};
    for(i=0;i<3;i++){
        if(s[i] == 'R'){
            while(s[i]=='R'){
                cnt++;
                i++;
        }
            maxr = max(maxr, cnt);
            cnt = 0;
        }
    }
    cout << maxr << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
 
int main(){

    	int N;
      	cin >> N;
      	int p = N % 10;
      	if(p == 3){
        	cout << "bon" << endl;
        }else if(p == 0||p == 1||p == 6||p == 8){
        	cout << "pon" << endl;
        }else if(p == 1){
        	cout << "pon" << endl;
        }else if(p == 6){
        	cout << "pon" << endl;
        }else if(p == 8){
        	cout << "pon" << endl;
        }else{
        	cout << "hon" << endl;
        }

}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h.at(i);
  int ans = 0;
  int count = 0;
  for(int i = 0; i < n-1; i++) {
    if(h.at(i+1)<=h.at(i)) count++;
    else count = 0;
    ans = max(ans,count);
  }
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 640
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;*/
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
typedef long long ll;
typedef pair<ll, ll> Pa;

/*
template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

typedef modint<MOD> m;
m func[400001];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
m comb(m n, m r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 0;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}*/

int dp[100001][3];
int a[100000], b[100000], c[100000];
int main() {
	cin >> N;
	rep(i, N) {
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[0][0] = dp[0][1] = dp[0][2] = 0;
	rep(i, N) {
		dp[i + 1][0] = max(dp[i][1] + a[i], dp[i][2] + a[i]);
		dp[i + 1][1] = max(dp[i][0] + b[i], dp[i][2] + b[i]);
		dp[i + 1][2] = max(dp[i][0] + c[i], dp[i][1] + c[i]);
	}
	cout << max(dp[N][0], max(dp[N][1], dp[N][2]));
}


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

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, M, s, l;
	ll ans = 1;

	cin >> N >> M;
	s = min(N, M);
	l = max(N, M);

	if (l - s > 1) ans = 0;
	else if (l - s == 1) {
		repc(i, 1, l) ans = (ans * i) % MOD;
		repc(i, 1, s) ans = (ans * i) % MOD;
	}
	else {
		repc(i, 1, l) ans = (ans * i) % MOD;
		repc(i, 1, s) ans = (ans * i) % MOD;
		ans = (ans * 2) % MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#coding:utf-8

def cal(a, b, op):
	if op=="+":
		return a + b
	elif op == "-":
		return a - b
	elif op == "*":
		return a * b
	elif op == "/":
		return a//b
	else:
		return -1

while True:
	buff = input().split()
	a = int(buff[0])
	b = int(buff[2])
	op = buff[1]
	if op == "?":
		break
	print(cal(a, b, op))

Measured memory_bytes: 7728
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  int count = 0;
  int b;
  int c;
  cin >> c;
  for(int i=0;i<c;i++){
  cin >> b;
    count += b;
  }
  if(a >= count){
  cout << a - count << endl;
  }
  else{
    cout << "-1" << endl;
}
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <string>

using namespace std;
using ll = long long;

ll N, M;
struct AB {
    ll a, b;
};
vector<AB> ab;

void input() {
    cin >> N >> M;
    ab.resize(N);
    for (auto& v : ab)
        cin >> v.a >> v.b;
}

void solve() {
    sort(ab.begin(), ab.end(), [](auto l, auto r) {return l.a < r.a;});
    ll count = 0;
    ll ans = 0;
    ll n = 0;
    while (count++ < M) {
        ans += ab[n].a;
        if (--ab[n].b == 0)
            n++;
    }
    cout << ans << endl;
}

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



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int p = 0;
    for (int i = 0; i < s.size() - 1; i++) {
        if (p >=1) {
            p--;
            continue;
        }
        if (s.at(i) == s.at(i + 1)) {
            p += 2;
            ans++;
        }
    }
    cout << s.size()-ans << endl;
}

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

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

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#define INF 1000000009;

using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
int kaizyo(int a) {
	long long ans = 1;
	for (int i = a; i > 0; i--) {
		ans *= i;
		ans = ans % 1000000007;
		//cout << ans << endl;
	}
	ans = ans % 1000000007;
	return ans;
}

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


int main() {
	int N = 0, ava = 0, copy = 0;
	long long ans = 0;
	cin >> N;
	int kazu[105];
	for (int i = 0; i < N; i++) {
		cin >> kazu[i];
		ava += kazu[i];
	}
	copy = ava % N;
	ava = ava / N;
	if (copy > N / 2) {
		ava += 1;
	}
	for (int i = 0; i < N; i++) {
		ans += abs(kazu[i] - ava) * abs(kazu[i] - ava);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

int main(int argc, char argv[]){
	int n;
	int R;

	scanf("%d",&n);
	int i;
	int m;
	scanf("%d",&R);
	int min=R, max=INT_MIN;
	m=max;
	for(i=1;i<n;i++){
		scanf("%d",&R);
		m = R - min;
		if(min > R)min = R;
		if(m > max)max = m;
//		printf("min = %d,max = %d\n",min,max);
	}
	printf("%d\n",max);

	return 0;
}

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

int main()
{
  int age, num1, num2;

  cin >> age;
  if (age == 1)
  {
    cout << "Hello World" << endl;
  }
  else
  {
    cin >> num1 >> num2;
    cout << num1 + num2 << endl;
  }

}


Measured memory_bytes: 3596
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    ll x;
    cin>>x;

    ll c=100;
    for(int i=1;;i++){
        c+=c*0.01;
        if(x<=c){
            cout<<i<<endl;
            return 0;
        }
    }
}

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

int main(){
  long long mod = 1e9 + 7;
  int H, W; cin >> H >> W;

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

  long long dp[1005][1005];
  for (int i=0; i<H; i++){
    for (int j=0; j<W; j++) dp[i][j] = 0;
  }
  
  queue<int> qi;
  queue<int> qj;
  qi.push(0);
  qj.push(0);
  dp[0][0] = 1;

  while (!qi.empty()){
    int i = qi.front();
    qi.pop();
    int j = qj.front();
    qj.pop();

    if (i == H - 1 && j == W - 1) break;

    if (j < W - 1){
      if (a[i][j+1] == '.'){
        if (dp[i][j+1] == 0){
          if (i == 0) dp[i][j+1] = dp[i][j];
          else dp[i][j+1] = (dp[i][j] + dp[i-1][j+1]) % mod;
          qi.push(i);
          qj.push(j+1);
        }
      }
    }

    if (i < H - 1){
      if (a[i+1][j] == '.'){
        if (dp[i+1][j] == 0){
          if (j == 0) dp [i+1][j] = dp[i][j];
          else dp[i+1][j] = (dp[i][j] + dp[i+1][j-1]) % mod;
          qi.push(i+1);
          qj.push(j);
        }
      }
    }
  }

  cout << dp[H-1][W-1] << endl;

  return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, x;
    cin >> n >> x;

    if (x == 1 || x == 2 * n - 1) {
        cout << "No\n";
    } else {
        vector<int> perm(2 * n - 1);
        x--;
        for (int i = 0; i < 2 * n - 1; ++i) {
            perm[i] = i + 1;
        }
        if (x < n - 1) {
            rotate(perm.begin(), perm.begin() + x + 1, perm.begin() + n);
        } else {
            rotate(perm.begin() + n - 1, perm.begin() + x, perm.end());
        }
        cout << "Yes\n";
        for (int p: perm) {
            cout << p << '\n';
        }
    }
}


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

using namespace std;

int main(){
  long long X;
  cin >> X;
  
  vector<long long> d;
  for(long long i = 1; i * i <= X; i++){
    if(X % i == 0){
      d.push_back(i);
      if(i != X / i) d.push_back(X / i);
    }
  }
  
  for(long long B = -1000000; B <= 100000; B++){
    if(X == 0) break;
    for(long long A : d){
      A += B;
      if(A * A * A * A * A - B * B * B * B * B == X){
        cout << A << ' ' << B << endl;
        X = 0;
        break;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 3632
/* AUTHOR :  SHIVANK JAIN */

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)

using namespace std;

#define ll long long
#define li long int

#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define reprev(i,n,a) for(int i=n;i>=a;i--)
#define endl "\n"

#define vi vector<int>
#define vll vector<ll>
#define vpi vector< pair<int , int> >
#define mapi map<int , int>
#define mapll map<ll ,ll >
#define seti set<int> 

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define sort(v) sort(v.begin() , v.end())

#define BIG 1000000007
int gcd(int a, int b) 
{ // builtin function __gcd(a,b)
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){

     fast;itt;now;
 
//    #ifndef ONLINE_JUDGE
//    // for getting input from input.txt
//    freopen("input.txt", "r", stdin);
//    // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
//    #endif
    
     ll n , k ;   cin>>n>>k;
     
     vll v(n+1) , vis(n+1, 0);
      vis[1] = 1 ; 
	      
     rep(i,1,n+1)
      cin>>v[i];
      
      ll tt = 1 , p;
      
      rep(i,1,n+1){
       tt = v[tt];	
      	if(vis[tt] == 1){
      		p = tt;
      		break;
		}
		vis[tt] = 1;
	  }
	  tt = 1 ; 
	  ll c = 1 , cc = 1;
//	  cout<<p<<endl;
	  while(1){
	  	tt = v[tt];
	  	if(tt == p){
	  		break;
		}
	  	++c;
	  }
//	  cout<<c<<endl;
	  tt = p;
	  
	  while(1){
	  	tt = v[tt];
	  	if(tt == p){
	  		break;
		}
		++cc;
	  }
	  
	 if(c >= k){
	 	ll t = 1; 
	 	while(k--){
	 		t = v[t];
		 }
		 cout<<t<<endl;
	 }
	 else{
	 	k = k - c;
	 	
	 	k = k % cc;
//	 	cout<<k<<' '<<cc<<' '<<c<<endl;
	 	if(k == 0){
	 	ll t = p , a = cc;
	 		while(a--){
	 			t = v[t];
			 }
			 cout<<t<<endl;
        }
        else{
        	ll t = p , a = k;
        	while(a--){
        		t = v[t];
			}
			cout<<t<<endl;
		}
	 } 	   
}
/**
    ll tt = 1 , c = 1; 
     vll vis(n+1 , 0);
     vis[1] = 1;
//	 while(1){
//        tt = v[tt];
//          if(vis[tt] == 1)
//           break;
//		++c;
//		vis[tt] = 1;	
//	 }
	 
	 k = k%c;
	 cout<<k<<' '<<c<<endl;
	 ll ans = 1;
	  
	for(ll i = 0; i < k + c - 1; i++){
		ans = v[ans];
	} 
	
**/


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

int main() {
  int x;
  cin >> x;
  if(x >= 30){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3620
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll d[2*1002][2*1002];
ll fr[2*1002];
int main(){
	ll n,x,y;
	cin>>n>>x>>y;
	d[x][y]=1;
	d[y][x]=1;
	for(ll i=1;i<=n;i++){
		d[x][i]=min(abs(x-i),1+abs(y-i));
		d[i][x]=min(abs(x-i),1+abs(y-i));
		d[y][i]=min(abs(y-i),1+abs(x-i));
		d[i][y]=min(abs(y-i),1+abs(x-i));
	}
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++){
			d[i][j]=min(abs(i-j),d[i][x]+1+d[y][j]);
			d[i][j]=min(d[i][j],d[i][y]+1+d[x][j]);
		}
	}
	for1(i,n){
		for(ll j=i+1;j<=n;j++){
			fr[d[i][j]]++;
		}
	}
	for1(i,n-1) cout<<fr[i]<<"\n";
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MAX_N = 30, NIL = -1;
// parent親、left左の子、 right右の子
struct Node { int parent, left, right; };
Node T[MAX_N];
int H[MAX_N];


int getSibling(int u){
    if(T[u].parent == NIL) return -1;
    if(T[T[u].parent].left == NIL || T[T[u].parent].right == NIL) return -1;
    else if(T[T[u].parent].left == u) return T[T[u].parent].right;
    else return T[T[u].parent].left;
}

int getDeg(int u){
    if(T[u].left == NIL && T[u].right == NIL) return 0;
    else if(T[u].left == NIL || T[u].right == NIL) return 1;
    else return 2;
}

int getDepth(int u){
    int d = 0;
    while(T[u].parent != -1){
        u = T[u].parent;
        d++;
    }
    return d;
}

int getParent(){
    int p = 0;
    while(T[p].parent != NIL){
        p = T[p].parent;
    }
    return p;
}

// uの初期値は必ず親の節点番号にする
int setHeight(int u){
    int h1, h2; h1 = h2 = 0;
    if(T[u].left != NIL){
        h1 = setHeight(T[u].left) + 1;
    }
    if(T[u].right != NIL){
        h2 = setHeight(T[u].right) + 1;
    }
    return H[u] = max(h1, h2);
}

// 先行順巡回
vector<int> pre;
void preorder(int u){
    pre.push_back(u);
    if(T[u].left != NIL) preorder(T[u].left);
    if(T[u].right != NIL) preorder(T[u].right);
}

// 中間順巡回
vector<int> In;
void inorder(int u){
    if(T[u].left != NIL) inorder(T[u].left);
    In.push_back(u);
    if(T[u].right != NIL) inorder(T[u].right);
}

// 後行順巡回
vector<int> post;
void postorder(int u){
    if(T[u].left != NIL) postorder(T[u].left);
    if(T[u].right != NIL) postorder(T[u].right);
    post.push_back(u);
}


int main()
{
    int n; cin >> n;
    // 初期化
    rep(i,n) T[i].parent = T[i].left = T[i].right = NIL;
    // 情報入力
    rep(i,n){
        int p; cin >> p;
        int l, r; cin >> l >> r;
        T[p].left = l; T[p].right = r;
        T[l].parent = T[r].parent = p;
    }
    // 各木の高さをセット
    int p = getParent();
    setHeight(p);
    /*
    rep(i,n){
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, T[i].parent, getSibling(i), getDeg(i), getDepth(i), H[i]);
        if(T[i].parent == NIL) printf("root\n");
        else{
            if(T[i].left == NIL && T[i].right == NIL) printf("leaf\n");
            else printf("internal node\n");
        }
    }
    */
   preorder(p);
   printf("Preorder\n");
   rep(i,pre.size()) printf(" %d", pre[i]); cout << endl;
   inorder(p);
   printf("Inorder\n");
   rep(i,In.size()) printf(" %d", In[i]); cout << endl;
   postorder(p);
   printf("Postorder\n");
   rep(i,post.size()) printf(" %d", post[i]); cout << endl;
}


Measured memory_bytes: 3272
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
#define MAX_N 100
int main(){
    int N;
    string S;
    vector<char> l;
    cin >> N >> S;
    REP(i,N){
        if(l.size() > 0 && l.back() == '(' && S[i] == ')') l.pop_back();
        else l.push_back(S[i]);
    }
    int index = 0;
    while(index < l.size() && l[index] == ')'){
        cout << '(';
        index++;
    }
    cout << S;
    while(index < l.size()){
        cout << ')';
        index++;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

static const int N = 100;

int main() {
    int n, p[N + 1], m[N + 1][N + 1];
    cin >> n;
    for (int i = 1; i<= n; i++) {
        cin >> p[i-1] >> p[i];
    }

    for( int i = 1; i <= n; i++ ) m[i][i]=0;
    for( int l = 2; l <= n; l++ ) {
        for(int i = 1; i <= n-l+1; i++) {
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for( int k = i; k <= j - 1; k++ ) {
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}

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

int h,w;
char f[105][105];
// string f[105];
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};

void dfs(int y, int x, char c){
    f[y][x]='.';
    for(int i=0; i<4; i++){
        int nx=x+dx[i];
        int ny=y+dy[i];

        if(nx>=0 || nx<w || ny>=0 || ny<h){
            if(f[ny][nx]==c){
                dfs(ny, nx, c);
            }
        }       
    }
}

int main(){
    int cnt=0;

    while(1){
        cin>>h>>w;
        if(h==0&&w==0)return 0;
        for(int i=0; i<h; i++)cin>>f[i];
        
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                char current = f[i][j];
                if(current!='.'){
                    dfs(i,j,current);
                    cnt++;
                }
            }
        }
        cout<<cnt<<endl;
        cnt=0;
    }
}

Measured memory_bytes: 3508
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count = 0;
        for(int i=a;i<=b;i++){
            if(c%i == 0)
            count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26352
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
struct edge{ ll to; ll cap; ll rev;};
vector<edge> G[11000];

bool used[11000];

void addEdge0(ll from, ll to, ll cap){
    edge A={to,cap,(ll)G[to].size()};
    edge B={from,0,(ll)G[from].size()};
    G[from].push_back(A);
    G[to].push_back(B);
    return;
}//有向グラフを作る

void addEdge1(ll a, ll b, ll cap){
    edge A={b,cap,(ll)G[b].size()};
    edge B={a,cap,(ll)G[a].size()};
    G[a].push_back(A);
    G[b].push_back(B);
    return;
}//無向グラフを作る

ll dfs(ll v, ll t, ll f){
    if(v==t) return f;
    used[v]=true;
    rep(i,G[v].size()){
        edge &e=G[v][i];
        if(!used[e.to] && e.cap>0){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

int main(){
    ll H,W; cin>>H>>W;
    ll S,T;
    REP(i,1,H+1) REP(j,1,W+1){
        char x; cin>>x;
        ll K=j+(102*i);
        if(x=='o'){
            addEdge1(K,102*i,1);
            addEdge1(K,j,1);
        }
        if(x=='S') {
            S=K;
            addEdge1(K,102*i,INF);
            addEdge1(K,j,INF);
        }
        if(x=='T') {
            T=K;
            addEdge1(K,102*i,INF);
            addEdge1(K,j,INF);
        }
    }

    if(S%102==T%102) cout<<-1<<endl;
    else if(S/102==T/102) cout<<-1<<endl;
    else{
        ll ans=0;
        while(true){
            rep(i,11000) used[i]=false;
            ll P=dfs(S,T,INF);
            if(P==0) break;
            ans+=P;
        }
        cout<<ans<<endl;
    }
}



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

long long int f(int k) {
	if (k <= 9) return k;
	int a = 0;
	queue<long long int> q;
	for (int i = 1; i <= 9; i++) {
		q.push(i);
		a++;
	}
	while (a <= k) {
		long long int x = q.front();
		q.pop();
		if (x % 10 == 0) {
			q.push(10 * x);
			a++;
			if (a == k) return q.back();
			q.push(10 * x + 1);
			a++;
			if (a == k) return q.back();
		} else if (x % 10 == 9) {
			q.push(10 * x + 8);
			a++;
			if (a == k) return q.back();
			q.push(10 * x + 9);
			a++;
			if (a == k) return q.back();
		} else {
			int i = x % 10;
			q.push(10 * x + i - 1);
			a++;
			if (a == k) return q.back();
			q.push(10 * x + i);
			a++;
			if (a == k) return q.back();
			q.push(10 * x + i + 1);
			a++;
			if (a == k) return q.back();
		}
	}
	return -1;
}

int main() {
	int k;
	cin >> k;
	long long int ans = f(k);
	cout << ans << "\n"; 
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a, b, c;
	int tmp;

	scanf("%d%d%d", &a, &b, &c);
	if (a > b) tmp = a, a = b, b = tmp;
	if (b > c) {
		tmp = b, b = c, c = tmp;
		if (a > b) tmp = a, a = b, b = tmp;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 596
#%%
N, K = map(int, input().split())


def base_10_to_n(X, n):
    if (int(X / n)):
        return base_10_to_n(int(X / n), n) + str(X % n)
    return str(X % n)

ans = len(str(base_10_to_n(N, K)))
print(ans)

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

signed main(void)
{
	int n; cin >> n;
	map<long long, long long> m;
	long long x, y;

	rep(i, n)
	{
		long long a;
		cin >> a;
		m[a]++;
	}
	x = y = 0;
	for (auto p : m)
	{
		auto k = p.first;
		auto v = p.second;
		if (v >= 2)
		{
			if (x < k)
			{
				y = x;
				x = k;
			}
		}
		if (v >= 4)
			y = x;
	}
	cout << x * y << endl;
}


Measured memory_bytes: 6528
import java.io.PrintWriter;
import java.util.Scanner;

class Main{
    private static final Scanner sc = new Scanner(System.in);
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args){
        while(true){
            final int h = Integer.parseInt(sc.next());
            final int w = Integer.parseInt(sc.next());
            if(h==0||w==0) break;
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            for(int i = 1; i<h-1; i++){
                out.print('#');
                for(int j = 1; j<w-1; j++){
                    out.print('.');
                }
                out.println('#');
            }
            for(int i = 0; i<w; i++)
                out.print('#');
            out.println();
            out.println();
        }
        out.flush();
    }
}

Measured memory_bytes: 27296
[a,b]=[int(x) for x in input().split(" ")]
if a*b==0:
    print("Zero")

elif a>0 :
    print("Positive")

elif b<0:
    if (b-a-1)%2 == 1:
        print("Negative")
    else:
        print("Positive")

else:
    print("Zero")

Measured memory_bytes: 43120
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int r = sc.nextInt();
        out.println(3 * r * r);
        out.flush();
        out.close();
    }

    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

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


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

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

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

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

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


        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }


        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        
        int sum = 0;
        for (int i = 0; i < 3; i++) {
            sum += sc.nextInt();
        }

        System.out.println(sum > 21 ? "bust" : "win");
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

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

int main(){
    int A[3][3];
    int C[3][3]={};
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> A[i][j];
        }
    }
    int N;
    cin >> N;
    int b[N];
    for(int i=0; i<N; i++){
        cin >> b[i];
    }
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<N; k++){
                if( A[i][j]==b[k] ){
                    C[i][j]=1;
                }
            }
        }
    }

    int bingo=false;
    for(int i=-1; i<=1; i++ ){
        for(int j=-1; j<=1; j++){
            if( C[1-i][1-j] && C[1][1] && C[1+i][1+j] ){
                if(i==j && i==0) continue;
                bingo=true;
            }
            if( C[0][0] && C[1][0] && C[2][0] ){
                if(i==0) continue;
                bingo=true;
            }
            if( C[0][0] && C[0][1] && C[0][2] ){
                if(j==0) continue;
                bingo=true;
            }
            if( C[0][2] && C[1][2] && C[2][2] ){
                bingo=true;
            }
            if( C[2][0] && C[2][1] && C[2][2] ){
                bingo=true;
            }
                     
        }
    }

    if(bingo){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
  int N,M,K;
  cin >> N >> M >> K;
  vector<long long>A(N);
  vector<long long>B(M);
  vector<long long>C(N);
  vector<long long>D(M);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if (i == 0){
      C.at(i) = A.at(i);
    }
    else {
      C.at (i) += C.at(i-1) + A.at(i);
    }
  }
  int counta = 0;
  for (int i = 0; i < N; i++) {
    C.at(i) = K - C.at(i); 
    if (C.at(i) < 0){
      break;
    }
    counta++;
  }
  
  for (int i = 0; i < M; i++) {
    cin >> B.at(i);
    if (i == 0){
      D.at(i) = B.at(i);
    }
    else {
      D.at (i) += D.at(i-1) + B.at(i);
    }
  }
  int countb = 0;
  for (int i = 0; i < M; i++) {
    if (D.at(i) > K ){
      break;
    }
    countb++;
  }
  
  int MAX = max(counta,countb);
  for (int i = 0; i < counta; i++) {
    for (int j = countb-1; j >= 0; j--) {
      if (C.at(i) >= D.at(j)){
        if (i + j + 2 > MAX){
          MAX = i + j + 2;
        }    
        countb = j+1;
        break;
      }
    }
  }
  cout << MAX << endl;
}

  

Measured memory_bytes: 9580
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int h = Integer.parseInt(in.next());
            int w = Integer.parseInt(in.next());
            char c[][] = new char[h][w];
            for (int i = 0; i < h; i++) {
                c[i] = in.next().toCharArray();
            }

            int k = 0;
            for (int i = 1; i <= 2 * h; i++) {
                k = (i - 1) / 2;
                for (int j = 0; j < w; j++) {
                    out.print(c[k][j]);
                }
                out.println();
            }

        }

    }
}



Measured memory_bytes: 23416
N = int(input())

def Lucas(N):
  L0 = 2
  L1 = 1
  for _ in range(N-1):
    L = L0 + L1
    L0 = L1
    L1 = L
  
  return L

if N == 1:
  print(1)
else:
  print(Lucas(N))

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#define ll long long
ll x, y, n, m, xx;
const ll Mod = 1e9+7;
int main(){
    ll sum1 = 0, sum2 = 0;
    scanf("%lld%lld%lld", &n, &m, &x);
    for(ll i = 1; i < n; ++i){
        scanf("%lld", &y);
        xx = y - x;
        sum1 = (sum1 + (n-i)*i%Mod*xx%Mod)%Mod;
        x = y;
    }
    scanf("%lld", &x);
    for(ll i = 1; i < m; ++i){
        scanf("%lld", &y);
        ll xx = y - x;
        x = y;
        sum2 = (sum2 + xx*(m-i)%Mod*i%Mod)%Mod;
    }
    printf("%lld\n", sum1*sum2%Mod);
    return 0;
}


Measured memory_bytes: 256
def inv_mod(a, p=10**9+7):
    p = abs(p)
    a %= p
    stack = []
    p0 = p
    while a > 1:
        d, a, p = p//a, p%a, a
        stack.append(d)
    x, y = 1, 0
    while stack:
        d = stack.pop()
        x, y = y-d*x, x
    return x % p0

MOD = 998244353
inpl = lambda: list(map(int,input().split()))
N, S = inpl()
A = inpl()
F = [[0]*(S+1) for _ in range(N+1)]
F[0][0] = pow(2,N,MOD)
p = inv_mod(2,MOD)

for k in range(1,N+1):
    for s in range(S+1):
        if F[k-1][s] > 0:
            F[k][s] += F[k-1][s]
            F[k][s] %= MOD
            t = s + A[k-1]
            if t <= S:
                F[k][t] += F[k-1][s] * p
                F[k][t] %= MOD
print(F[N][S])


Measured memory_bytes: 135328
// author: Saman Mahdanian
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
const int N = 2e5 + 10;

int n, m, par[N];
bool mark[N];
vector <int> tpl, g[N], rev_g[N];

void dfs (int);

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

	cin >> n >> m;
	m += n - 1;
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u;
		v--; u--;
		g[v].push_back(u);
	}
	
	for (int i = 0; i < n; i++)
		if (!mark[i])
			dfs(i);
	reverse(tpl.begin(), tpl.end());
	for (int i = 0; i < n; i++)
		par[i] = -1;

	for (int v: tpl)
		for (int u: g[v])
			par[u] = v;
	
	for (int i = 0; i < n; i++)
		cout << par[i] + 1 << endl;
}

void dfs (int v) {
	mark[v] = true;
	for (int u: g[v])
		if (!mark[u])
			dfs(u);
	tpl.push_back(v);
}

// SamMHD :: Mar6-2019 :: Another Code In Class...

Measured memory_bytes: 17912
#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
 
int main(void){
    int n, k;
    cin >> n >> k;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    // game[K]がtrueならばTaro win
    // game[K]がfalseならばJiro win
    vector<bool> game(k+2, false);
    
    for (int i = 1; i <= k; i++){
        
        for (int j = 0; j < n; j++){
            
            if (i - a[j] >= 0 && !game[i-a[j]]) game[i] = !game[i-a[j]]; 
        }
    }
    
    if (game[k]) cout << "First" << endl;
    else cout << "Second" << endl;
    
}


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

vector<vector<long double>> dp;

long double prob(int heads, int i, vector<double>&p)
{
    if(i >= p.size())
        return heads == 0 ? 1.0 : 0.0;
    if(dp[i][heads] != -1)
        return dp[i][heads];
    if(heads == 0)
    {
        dp[i][heads] = (1 - p[i])*prob(heads, i + 1, p);
        return dp[i][heads];
    }
    long double res = p[i]*prob(heads - 1, i + 1, p);
    res += (1 - p[i])*prob(heads, i + 1, p);
    dp[i][heads] = res;
    return dp[i][heads];
}

int main()
{
    int n;
    cin >> n;
    vector<double> p(n);
    for(int i = 0; i < n; i++)
        cin >> p[i];
    dp = vector<vector<long double>> (n, vector<long double>(n + 1, -1));
    int maxh = n/2 + 1;
    long double cost = 0;
    for(int i = maxh; i <= n; i++)
        cost += prob(i, 0, p);
    cout << fixed << setprecision(10) << cost;
    return 0;
}

Measured memory_bytes: 141312