akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


// Modint
struct Mint {
	static const ll mod = (ll)(1e9 + 7);
	ll val;

	Mint() { val = 0; }
	Mint(ll a) { val = a; verify_value(); }

	void verify_value() {
		if (val >= mod) val %= mod;
		if (val < 0) val %= mod, val += mod;
	}

	Mint pow(ll p) const {
		Mint cur = Mint(val), ret = 1;
		while (p > 0) {
			if (p & 1) ret *= cur;
			cur *= cur;
			p >>= 1LL;
		}
		return ret;
	}
	Mint inv() const {
		if (val == 0) cerr << "CAUTION: inv() is called with 0." << endl;
		return pow(mod - 2);
	}

	Mint operator+() const { return *this; }
	Mint operator-() const { return Mint(mod - val); }

	Mint operator+=(const Mint &a) {
		val += a.val;
		if (val >= mod) val -= mod;
		return Mint(val);
	}
	Mint operator*=(const Mint &a) {
		val *= a.val;
		if (val >= mod) val %= mod;
		return Mint(val);
	}
	Mint operator-=(const Mint &a) { return *this += -a; }
	Mint operator/=(const Mint &a) { return *this *= a.inv(); }

	Mint operator++() { return *this += Mint(1); }
	Mint operator--() { return *this -= Mint(1); }
	Mint operator++(int) {
		Mint ret = *this;
		++(*this);
		return ret;
	}
	Mint operator--(int) {
		Mint ret = *this;
		--(*this);
		return ret;
	}

	operator ll() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
	ll ret = a.val + b.val;
	if (ret >= Mint::mod) ret -= Mint::mod;
	return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
	ll ret = a.val * b.val;
	if (ret >= Mint::mod) ret %= Mint::mod;
	return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

ostream &operator<<(ostream &out, const Mint &a) { return out << a.val; }
istream &operator>>(istream &in, Mint &a) {
	in >> a.val;
	a.verify_value();
	return in;
}


// Combinatorics
constexpr int MAX_N = 2000003;
Mint fact[MAX_N], inv[MAX_N];

void init_fact() {
	fact[0] = inv[0] = 1;
	for (ll i = 1; i < MAX_N; i++) {
		fact[i] = fact[i - 1] * Mint(i);
		inv[i] = fact[i].inv();
	}
}

// aCb
Mint C(int a, int b) {
	if (a < b) return 0;
	Mint res = fact[a];
	res *= inv[b];
	res *= inv[a - b];
	return res;
}

// aPb
Mint P(int a, int b) {
	if (a < b) return 0;
	return fact[a] * inv[a - b];
}

// aHb
Mint H(int a, int b) {
	if (b == 0) return 1;
	return C(a + b - 1, b);
}

int main() {
	// 2 * 1 * 2 / 2 = 2
	// . . x . .
	// 1 2 3 4 5
	// (3 - 1)*3 / 2
	// (5 - 3)*(5 - 3 + 1) / 2
	init_fact();
	Mint n, m, k; cin >> n >> m >> k;
	Mint ans = 0;
	for (Mint i = 1; i <= n; i++) {
		for (Mint j = 1; j <= m; j++) {
			ans += m*(i - Mint(1))*i / Mint(2);
			ans += m*(n - i)*(n - i + Mint(1)) / Mint(2);
			ans += n*(j - Mint(1))*j / Mint(2);
			ans += n*(m - j)*(m - j + Mint(1)) / Mint(2);
		}
	}
	cout << C((ll)n*(ll)m - 2, (ll)k - 2) * ans / Mint(2) << endl;
	return 0;
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
  ll h, w;
  cin >> h >> w;

  if (h == 1 || w == 1) {
    cout << 1 << endl;
  } else if (h * w % 2 == 0) {
    cout << h * w / 2 << endl;
  } else {
    cout << h * w / 2 + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define endl '\n'
#define ll long long int
     
int main()
{
    map<int,int> m;
    int t;
    for (int i = 1; i <= 100; ++i)
    {
      for (int j = 1; j <= 100; ++j)
      {
        for (int k = 1; k <= 100; ++k)
        {
            t=i*i+j*j+k*k+i*j+j*k+k*i;
              m[t]++;
        }
      }
    }
    int n;
    cin>>n;
    for (int i = 1; i <= n; ++i)
    {
        auto t=m.find(i);
        if (t==m.end())
        {
          cout<<0;
        }
        else
        {
            cout<<m[i];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 5384
#include <bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

int BE(int b,int e){
    int r=1;
    while(e){
        if(e&1){
            r=(r*b)%MOD;
        }
        b=(b*b)%MOD;
        e >>=1;
    }
    return r;
}

signed main(void){
    int N;
    int D[114514];
    int E[114514]={};
    int maxD=0;
    cin >> N;
    REP(i,N){
        cin >> D[i];
        E[D[i]]++;
    }
    if(D[0]!=0)GOODBYE;
    sort(D,D+N);
    maxD=D[N-1];
    int Ans=1;
    if(D[1]==0)GOODBYE;
    REP(i,N-1){
        if(D[i+1]-D[i]>=2){
            GOODBYE;
        }
    }
    //REP(i,N){cout << E[i] << " ";}
    REP(i,maxD+1){
        if(i==0)continue;
        //cout << BE(E[i-1],E[i]) << endl;
        Ans=(Ans*BE(E[i-1],E[i]))%MOD;
    }
    cout << Ans << endl;
    return 0;
}



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

#define for_(i,a,b) for(int i=a;i<b;++i)
typedef pair< int, int > pii;

int main() {
	int N, M;
	vector< pii > vp;
	
	cin >> N;
	for_(i,0,N) {
		int h, m;
		cin >> h >> m;
		vp.push_back(pii(h,m));
	}
	
	cin >> M;
	for_(i,0,M) {
		int h, m;
		cin >> h >> m;
		vp.push_back(pii(h,m));
	}
	
	sort(vp.begin(), vp.end());
	vp.erase(unique(vp.begin(), vp.end()), vp.end());
	
	for_(i,0,(int)vp.size()) {
		printf("%d:%02d", vp[i].first, vp[i].second);
		cout << (i < (int)vp.size()-1 ? " " : "\n");
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
	*/
	int n;
	int count = 0;
	int num = 0;
	int ans = 0;
	cin >> n;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	vector<int>a(n);
	rep0(i, n - 1) {
		a[i] = i + 1;
	}
	rep0(j, n - 1) {
		int save = a[j];
		
			while (a[j] % 2 == 0) {
				a[j] /= 2;
				count++;
			}
			if (count > ans) {
				ans = count;
				num = save;
			}
			count = 0;
		

	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
using namespace std;
#define REP(i,j,k)  for(int i = (j); i <= (k); ++i)
#define REPD(i,j,k) for(int i = (j); i >= (k); --i)

const int maxn = 2e5;

char a[maxn];
int s[30];
int n;

int init()
{
	if(scanf("%s",a+1)==EOF) return 0;
	memset(s,0,sizeof s);
	n=strlen(a+1);
	int s=0;
	s^=(a[1]==a[n]);
	s^=n%2;
	if(!s) printf("Second\n");
	else printf("First\n");
	return 1;
}
int main()
{
	while(init());
	return 0;
}

Measured memory_bytes: 384
#include <bitset>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef vector<vector<ll>> vvll;

typedef pair<int, int> Pair;
#define mp(x, y) make_pair(x, y)

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

//nが素数かをO(√n)で判断
bool is_prime(int n) {
    bool res = true;

    if (n == 1) return false;
    else if (n == 2) return true;

    else {
        for (int i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                res = false;
                break;
            }
        }
    }

    return res;
}



int perm(int n, int r) {
    if (r == 1) return n;
    return n * perm(n - 1, r - 1);
}

int fact(int n) {
    if (n == 1) return 1;
    return fact(n - 1) * n;
}

int comb(int n, int r) {
    int a = min(n, r), b = max(n, r);
    return perm(a, b) / fact(a);
}



/*
ll pow_mod(ll a, ll n, ll mod) {
    ll res = 1;

    ll base = a;
    while (n) {
        if (n & 1) res = res * base % mod;
        base = base * base % mod;
        n >>= 1;
    }
    return res;
}
*/

//aの逆元　（a^(-1)）を求める
ll inv_mod(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

/*
ll fact_mod(ll n, ll mod) {
    if (n == 1) return 1;
    return n * fact_mod(n - 1, mod) * mod;
}
*/

// 階乗 (mod とりバージョン)
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}

ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

// 組み合わせ nCr を求める (modあり)
ll comb_mod(ll n, ll r, ll mod) {
    if (r > n - r) r = n - r;
    if (r == 0) return 1;
    ll a = 1;
    for (int i = 0; i < r; i++) a = a * ((n - i) % mod) % mod;
    ll b = pow_mod(fact_mod(r, mod), mod - 2, mod);
    return (a % mod) * (b % mod) % mod;
}






ll mod = pow(10, 9) + 7;
//       1000000007




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

    ll ans = (pow_mod(10, n, mod) + pow_mod(8, n, mod) % mod);
    //ans %= mod;

    ans -= pow_mod(9, n, mod);
    ans %= mod;

    if (ans < 0) ans += mod;

    ans -= pow_mod(9, n, mod);
    ans %= mod;

    if (ans < 0) ans += mod;

    cout << ans << endl;
}

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

const int INF = 1e9;

struct Node {
    bool done;
    int dist;
    vector<int> to;
};

int dfs(int pos, vector<Node>& node) {
    node[pos].done = true;
    int res = node[pos].dist;
    for (int i = 0; i < node[pos].to.size(); i++) {
        int nex = node[pos].to[i];
        if (node[nex].done == false) {
            node[nex].dist = node[pos].dist + 1;
            res = max(res, dfs(nex, node));
        }
    }
    return res;
}

int tree_diameter(vector<Node>& node) {
    int n = node.size();
    for (int i = 0; i < n; i++) {
        node[i].done = false;
        node[i].dist = INF;
    }
    node[0].dist = 0;
    int res = dfs(0, node);
    int pos;
    for (int i = 0; i < n; i++) {
        if (node[i].dist == res) {
            pos = i;
            break;
        }
    }
    for (int i = 0; i < n; i++) {
        node[i].done = false;
        node[i].dist = INF;
    }
    node[pos].dist = 0;
    return dfs(pos, node);
}

int main() {
    int n;
    cin >> n;
    vector<Node> node(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        node[a].to.push_back(b);
        node[b].to.push_back(a);
    }
    
    int d = tree_diameter(node);
    if (d % 3 == 1) {
        cout << "Second" << endl;
    } else {
        cout << "First" << endl;
    }
    return 0;
}

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

int main(){
    int A, B;
    cin >> A >> B;
    cout << max(max(A*B,A-B),A+B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a,b;
    cin>>a>>b;
    cout<<max(0ll,a-2*b)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		if (a * b % 2 == 0)
			System.out.println("Even");
		else
			System.out.println("Odd");
	}

}

Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define SPACE " "
#define pff first.first
#define pfs first.second
#define psf second.first
#define pss second.second

int main(){

	int H, W;
	int A[505][505];
	cin >> H >> W;
	for(int i = 1; i <= H; i ++){
		for(int j = 1; j <= W; j ++){
			cin >> A[i][j];
		}
	}
	vector<pair<pair<int, int>, pair<int, int>>> V;
	int N = 0;
	for(int i = 1; i <= H; i ++){
		for(int j = 1; j <= W; j ++){
			if(i != H){
				if(A[i][j] % 2 == 1){
					N ++;
					A[i][j] --;
					A[i + 1][j] ++;
					V.pb(mp(mp(i,j),mp(i + 1,j)));
				}
				continue;
			}
			if(A[i][j] % 2 == 1 && j != W){
				N ++;
				A[i][j] --;
				A[i][j + 1] ++;
				V.pb(mp(mp(i,j),mp(i,j + 1)));
			}
		}
	}
	cout << N << endl;
	for(int i = 0; i < N; i ++){
		cout << V[i].pff << SPACE << V[i].pfs << SPACE << V[i].psf << SPACE << V[i].pss << endl;
	}

	return 0;
}

Measured memory_bytes: 5232
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

int main() {
    int N, D;
    cin >> N >> D;

    int n = N / (2 * D + 1);
    if (N % (2 * D + 1) != 0) {
        n++;
    }

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin()[:-1])
  m=0
  for i in range(N):
    a=int(pin()[:-1])
    if a%2==0:
      m+=1
  if m==N:
    print("second")
  else:
    print("first")
    return 
main()

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll d;
  cin >> d;
  ll count = 0;
  cout << "Christmas" << " ";
  d = 25 - d;
  rep(i,d){
    cout << "Eve"<< " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
struct BIT {
	int n;
	vector<int>d;
	BIT(int m) {
		n = m;
		d.assign(n + 1, 0);
	}
	void add(int i, int x) {
		for (int j = i; j <= n; j += j&-j) {
			dump(j);
			d[j] += x;
		}
	}
	int getsum(int i) {
		int ret(0);
		for (int j = i; j > 0; j -= j&-j)ret += d[j];
		return ret;
	}
	int getsum(int s, int t) {
		return getsum(t) - getsum(s - 1);
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Q; cin >> N >> Q;
	BIT tree(N);
	dump(1);
	rep(i, 0, Q) {
		int com, x, y; cin >> com >> x >> y;
		dump(tree.d);
		if (com)cout << tree.getsum(x, y) << endl;
		else tree.add(x, y);
	}
	return 0;
}

Measured memory_bytes: 3492
#include<iostream>
using namespace std;
int main()
{   
    int N;
    cin >> N;
    int V[N];
    int C[N];
    int x=0;
    for(int i=0;i<N;i++)
        cin >> V[i];
    for(int i=0;i<N;i++)
        cin >> C[i];
    for(int i=0;i<N;i++){
        if(V[i]-C[i]>0){
            x=V[i]-C[i]+x;
        }
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
long long gcd(long long x, long long y){
    if(x < y) swap(x, y);
    if(x % y == 0) return y;
    return gcd(y, x % y);
}
int main(){
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    long long ans = B / C - (A - 1) / C + B / D - (A - 1) / D;
    long long E = C * D / gcd(C, D);
    ans = ans - B / E + (A - 1) / E;
    cout << B - A + 1 - ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int h, w;
  cin >> h >> w;
  vector<vector<bool>> a(h + 1, vector<bool>(w + 1, false));
  rep(i, h) {
    rep(j, w) {
      char c;
      cin >> c;
      if (c == '#') a[i][j] = true;
    }
  }

  int cnt = 0;
  rep(i, h) {
    rep(j, w) {
      cnt += a[i][j];
    }
  }
  if (cnt != h + w - 1) {
    cout << "Impossible\n";
    return 0;
  }
  int y = 0, x = 0;
  while (y != h - 1 || x != w - 1) {
    if (a[y + 1][x] ^ a[y][x + 1] == 0) {
      cout << "Impossible" << '\n';
      return 0;
    }
    if (a[y + 1][x]) y++;
    if (a[y][x + 1]) x++;
  }
  cout << "Possible" << '\n';
  

  






  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			if(n == 0 && x == 0) {
			//	System.out.println("???????????????");
				break;
			}

			int count = 0;
			for(int i = 1; i <= n-2; i++) {
				for(int j = i+1; j <= n-1; j++) {
					for(int k = j+1; k <= n; k++) {
						if(i + j + k == x) {
				//			System.out.println("i : "+ i);
				//			System.out.println("j : "+ j);
				//			System.out.println("k : "+ k);
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 26616
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
//fflush(stdin);
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n;
    cin>>n;
    ve <ll> arr(n);
    rep (i,0,n)
    {
        cin>>arr[i];
    }
    ve <ll> dp(n);
    dp [n-2]=abs(arr[n-1]-arr[n-2]);
    if (n-3>=0)
    dp [n-3]=min(abs(arr[n-1]-arr[n-3]),dp[n-2]+abs(arr[n-2]-arr[n-3]));
    rev (i,n-3,0)
    {
        dp[i]=min(dp[i+1]+abs(arr[i+1]-arr[i]),dp[i+2]+abs(arr[i+2]-arr[i]));
    }
    cout<<dp[0]<<endl;
    
}


Measured memory_bytes: 1792
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <cmath>		// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep3(i, a, n) for(int i = (int)(a); i < (int)(n); i++)
#define ll long long

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






int main() {
  string S; // 変数の宣言
  cin >> S; // 標準入力
  
  int N = S.length();
  if(S.at(N-1) == 's'){
    S = S + "es";
  }else{
    S = S + "s";
  }
 
  cout << setprecision(12) << S << endl; // 標準出力
  
}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define eni(x) template < class c > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; return * this; }
eni(==) return * this << range(begin(i), end(i)); }
template < class c, class b > debug & operator <<(pair < b, c > d) {
  return * this << "(" << d.first << ", " << d.second << ")";
}
template < class c > debug & operator <<(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  return * this << "]";
}
#else
template < class c > debug & operator <<(const c&) { return * this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000050
mt19937 myrand(time(0));

int divisor[mx];

bool isSquare(int x){
    int now=sqrt(x);
    return (now*now)==x;
}

void precalc(){
    for(int i=1;i<mx;i++){
        for(int j=i;j<mx;j+=i) divisor[j]++;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    precalc();
    int n,ans=0;
    cin>>n;
    for(int i=1;i<n;i++){
        int rem=n-i;
        int tmp=divisor[rem]/2;
        ans+=(tmp*2);
        if(isSquare(rem)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7588
// CODE by Kazhybay Askar
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define iter   set<int>::iterator
#define f      first
#define s      second
#define pb     push_back
#define pf     push_front
#define mp     make_pair
#define cont   continue
#define ll     long long
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define endl   '\n'

const int MAXN = 1e5  + 7;
const int MOD  = 1e9  + 7;
const int INF  = 1e9  + 7;
const ll  MINF = 1e18 + 7;
const int EPS  = 1e-6;
const int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[] = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);


typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

ll a[MAXN],b[MAXN];
vector<int>g[MAXN],v;
bool used[MAXN];
int n,m,k,cnt=0,sum=0,ans=0,mx=0,mn=INF;
bool y=0;

void freopen(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}


void solve(){
	cin>>n;
	for(int i=1;i<=n;i++){
        cin>>m;
        a[m]=i;
	}
	for(int i=1;i<=n;i++){
        cout<<a[i]<<" ";
	}
}

int main(){
	Speed;
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	r0;
}




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

int main(){
    int N; cin >> N;
	vector<ll> a(N);
  	rep(i, N) cin >> a[i];
  	vector<ll> b(N);
  	rep(i, N) cin >> b[i];

  	ll suma=0;
    ll sumb=0;

  	for(int i=0; i < N; i++) {
      suma += a[i];
      sumb += b[i];
    }
    ll m = sumb - suma;

    ll diff = 0;
    for(int i=0; i < N; i++) {
      if(a[i]<b[i]){
      	diff += (b[i] - a[i])/2 +(b[i] - a[i])%2;
        if(diff>m){
          cout << "No" << endl;
          return 0;
        }
      }
    }

    diff = 0;
    for(int i=0; i < N; i++) {
      if(a[i]>b[i]){
      	diff += a[i] - b[i];
        if(diff>m){
          cout << "No" << endl;
          return 0;
        }
      }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 384
// 
// 
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
#define outl(x) cout<<x<<endl
#define outsp(x) cout<<x<<" "
typedef long long ll;
typedef pair<int,int> P;


#define MAX_N 1000000005
const double pi=3.14159265358979323846;
int main() {
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	double ma = m/60.0 * 2 * pi;
	double ha = (h+m/60.0)/12.0 * 2 * pi;
	double ans = sqrt(a*a + b*b - 2*a*b*cos(ha-ma));

	cout << fixed << setprecision(10) << ans << endl;

    return 0;
}



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;
const int N = 1e5 + 5;
int a[N];
int n, m, l, r, res;
int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> l >> r;
        a[l]++;
        a[r + 1]--;
    }
    ll sum = 0;
    for (int i = 1; i <= n; ++i) {
        sum += a[i];
        if (sum == m) {
            ++res;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
int memo[100005][3];
/*int solve(int grid[][3],int n,int cannot,int current){
    if(current>=n)
        return 0;
    int maxm = 0;
    for(int i=0;i<3;i++){
        if(i==cannot)
            continue;
        if(memo[current][i]!=-1)
            maxm = max(maxm,memo[current][i]);
        else{
            maxm = max(maxm,grid[current][i]+solve(grid,n,i,current+1));
            memo[current][i] = maxm;
        }
    }
    return maxm;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    for(int i=0;i<100005;i++){
        for(int j=0;j<3;j++)
            memo[i][j]=-1;
    }
    int n;
    cin>>n;
    int grid[n][3];
    for(int i=0;i<n;i++){
        cin>>grid[i][0]>>grid[i][1]>>grid[i][2];
    }
    int dp[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++)
            dp[i][j]=0;
    }
    dp[0][0]=grid[0][0];
    dp[0][1]=grid[0][1];
    dp[0][2]=grid[0][2];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            int maxm = 0;
            for(int k=0;k<3;k++){
                if(j==k)
                    continue;
                maxm = max(maxm,grid[i][j]+dp[i-1][k]);
                dp[i][j]=maxm;
            }
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 3840
#include<iostream>
#include<cmath>
using namespace std;
int n,a=0,b,sum;
inline int read(){
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}
int main(){
    a=read();a=abs(a);
    while(b<a) {++sum;b+=sum;}
	cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n[] = sc.next().split("");
		if (Integer.parseInt(n[0]) == Integer.parseInt(n[1]) &&
				Integer.parseInt(n[0]) == Integer.parseInt(n[2]) ||
				Integer.parseInt(n[1]) == Integer.parseInt(n[2]) &&
				Integer.parseInt(n[1]) == Integer.parseInt(n[3]))
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 22100
import java.util.*;

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

    public static void main(String[]$) {
        int n = scanner.nextInt();
        char[] s1 = scanner.next().toCharArray();
        char[] s2 = scanner.next().toCharArray();
        List<Boolean> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (s1[i] == s2[i]) {
                list.add(true);
            } else {
                list.add(false);
                i++;
            }
        }
        long ans = list.get(0) ? 3 : 6;
        for (int i = 1; i < list.size(); i++) {
            ans = ans * (list.get(i - 1) ? 2 : list.get(i) ? 1 : 3) % 1000000007;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <cmath>
#define ll long long
#define pii pair<int, int>
#define fst first
#define snd second
using namespace std;

const double PI = 3.14159265358979;

int main()
{
	ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	long double ag1 = (h * 60 + m) % 720 * PI / 360;
	long double ag2 = m * PI / 30;
	cout << fixed << setprecision(20) << sqrtl(a * a + b * b - 2 * a * b * cosl(abs(ag2 - ag1))) << "\n";
	return 0;
}

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

int keta(int num){
  int ans= 0 ;
  int rem;

  for (int i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}


int main() {
  int N;
  cin >> N;

  vector<vector<int>> coordi(N+1, vector<int>(3,0));
  bool can = true;
  for(int i = 1; i < N+1; i++){
    cin >> coordi[i][0] >> coordi[i][1] >> coordi[i][2];
  }

  for(int i = 0; i < N; i++){
    int interval  =  coordi[i+1][0] - coordi[i][0];
    int distance = abs(coordi[i+1][1] - coordi[i][1]) + abs(coordi[i+1][2] - coordi[i][2]);
    if (interval == distance) {
      continue;
    }else if(interval > distance && (interval - distance) %2 == 0){
      continue;
    }else{
      can = false;
      break;
    }
  }

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


Measured memory_bytes: 5760
X = int(input())
def is_prime(n):
    if n == 2:
        return True
    elif n%2 == 0:
        return False
    if pow(2, n-1, n) != 1:
        return False
    return True

n = X-1
primes = []
while True:
    n += 1
    if is_prime(n):
        flag = True
        for p in range(3, n//2):
            if n%p == 0:
                flag = False
                break
        if flag:
            primes.append(n)
            if n >= X:
                print(n)
                break

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define mset(x) memset(x, 0, sizeof(x))
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n, q;
    cin >> n;
    vector<ll> a(n);
    ll i;
    rep(i, n) cin >> a[i];
    ll b, c;
    map<ll, ll> xmap;
    ll ans(0);
    rep(i, n) {
        ans += a[i];
        xmap[a[i]]++;
    }
    cin >> q;
    rep(i, q) {
        cin >> b >> c; 
        auto cnt = xmap[b];
        xmap[b] = 0;
        xmap[c] += cnt;
        ans += (c - b) * cnt;
        cout << ans << endl;
    }
}


Measured memory_bytes: 10060
#include <bits/stdc++.h>
using namespace std;
constexpr int B = 20;

int main() {
    int n, l, q;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    cin >> l >> q;
    
    vector<vector<int>> data(B, vector<int>(n));
    for (int i = 0; i < n; i++) {
        int ok = a[i] + l;
        data[0][i] = (prev(upper_bound(a.begin(), a.end(), ok)) - a.begin());
    }
    for (int i = 1; i < B; i++) for (int j = 0; j < n; j++) {
        if (data[i-1][j] == n-1) data[i][j] = data[i-1][j];
        else data[i][j] = data[i-1][data[i-1][j]];
    }
    
    // ホテル i から x 日でどの旅館まで行けるか
    auto bs = [&] (int i, int x) {
        for (int s = 0; s < B; s++) {
            if (x&(1<<s)) i = data[s][i];
        }
        return i;
    };
    
    auto query = [&] (int a, int b) {
        int ok = n, ng = 0;
        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if (bs(a, mid) >= b) ok = mid;
            else ng = mid;
        }
        return ok;
    };
    
    while (q--) {
        int a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        cout << query(--a, --b) << endl;
    }
    return 0;
}

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

int main(){
    int n,x;
    cin >> n >> x;
    vector<int>m(n);
    int sum = 0;
    for(int i = 0;i < n;i++){
        cin >> m[i];
        sum += m[i];
    }
    
    x = x - sum;
    sort(m.begin(),m.end());
    
    int amari = x/m[0];
    
    cout << n +  amari;
    
    
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=b-1;i>=a;i--)
#define mod 1000000007
#define pb push_back
#define son ll t; cin>>t;while(t--)
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL);
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define mpr make_pair
#define ff first
#define ss second
#define inf 5e18
#define dex(x,y) fixed<<setprecision(x)<<y
void start()
{
        #ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #endif
}

int32_t main()
{
    fst
    int n,k;
    cin>>n>>k;
    int a[n];
    fr(i,0,n)
    cin>>a[i];
    int dp[n+1];

   dp[0]=0;
    fr(i,1,n)
    {
        dp[i]=INT_MAX;
        fr(j,1,k+1)
        {
                if(i-j>=0)
                dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
        }
     //   cout<<dp[i]<<' ';
    }
    cout<<dp[n-1]<<endl;

}

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

using namespace std;

int n, m;
string pic_a [50], pic_b [50];

bool template_match(int x, int y) {
    for (int dy = 0; dy < m; dy++) {
        for (int dx = 0; dx < m; dx++) {
            if (pic_a[y+dy][x+dx] != pic_b[dy][dx]) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    bool found = false;

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

    for (int y = 0; (y <= n-m && !found) ; y++) {
        for (int x = 0; (x <= n-m && !found) ; x++) {
            found = template_match(x, y);
        }
    }

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

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue
#define    nl           "\n"
#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>


#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define repab(i,a,b) for(int i=(a);i<=(b);i++)
#define reprab(i,a,b) for(int i=(a);i>=(b);i--)
#define repll(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)
#define tc int t;cin>>t;while(t--)
template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    cout << "\nExecuted in: " << fixed
         << time_taken << setprecision(9);
    cout << " sec";
#endif
}

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

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................


int main()
{   
     auto start = chrono::high_resolution_clock::now();
    fast
    ll x,n;
    cin>>x>>n;
    vll a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    int l=x,r=x,mn=INT_MAX;
    while(l>=0&&r<=102){
        if(find(a.begin(),a.end(),l)==a.end()){
            mn=l;
            break;
        }
        else
        l--;
        if(find(a.begin(),a.end(),r)==a.end()){
            mn=r;
            break;
        }
        else
        r++;
    }
    cout<<mn<<"\n";
    
    auto end = chrono::high_resolution_clock::now();
    TIME(start, end);
    return 0;
}

Measured memory_bytes: 3636
//Andrew Yang
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>	
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>
using namespace std;
#define FOR(index, start, end) for(int index = start; index < end; ++index)
#define RFOR(index, start, end) for(int index = start; index > end; --index)
#define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); ++itr)
#define RFOREACH(itr, b) for(auto itr = b.rbegin(); itr != b.rend(); ++itr)
#define INF 1e18
#define M 1000000007
typedef long long ll;
typedef pair<int, int> pii;	
vector<pii> edges[1001];
bool visited[1001];
ll maxD[1001];
ll ans;
int n, m;
int canreach[1005];
void dfs(int i, ll d) {
	if (visited[i]) {
		if (canreach[i] && d > maxD[i])
		{
			ans = -1;
		}
		return;
	}
	maxD[i] = d;
	visited[i] = true;
	for (pii c : edges[i]) {
		dfs(c.first, d + c.second);
	}
}
void dfs(int i) {
	if (visited[i]) {
		return;
	}
	visited[i] = true;
	for (pii c : edges[i]) {
		dfs(c.first);
	}
}

bool check(int i) {
	dfs(i);
	canreach[i] = visited[n - 1];
	FOR(i, 0, n) {
		visited[i] = false;
	}

}
int main(void)
{
	cin >> n >> m;
	FOR(i, 0, m) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		a--;
		b--;
		edges[a].push_back({ b, c });
	}
	FOR(i, 0, n) {
		check(i);
	}
	ans = 0;
	dfs(0, 0);
	if (ans == -1) {
		cout << "inf" << endl;
		return 0;
	}
	cout << maxD[n - 1] << endl;
	
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    String c = sc.next();
    StringBuilder aa = new StringBuilder(a);
    StringBuilder bb = new StringBuilder(b);
    StringBuilder cc = new StringBuilder(c);
    char x = aa.charAt(0);
    String ans = "";
    while (true) {
      if (x == 'a') {
        if (aa.length() == 0) {
          ans = "A";
          break;
        } else {
        x = aa.charAt(0);   
        aa.delete(0,1);
        }
      }
      if(x == 'b') {
        if (bb.length() == 0) {
          ans = "B";
          break;
        } else {
        x = bb.charAt(0); 
        bb.delete(0,1);
        }
      }
      if(x == 'c') {
        if (cc.length() == 0) {
          ans = "C";
          break;
        } else {
        x = cc.charAt(0); 
        cc.delete(0,1);
        }
      }
    }

    System.out.println(ans);
    
  }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll ans = 0;
    REP(i,1,n+1)
    {
        if(i%3 != 0 && i%5 != 0) ans+=i;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	//cleaning
	while (true) {
		if (s.length()>=2&&s.at(0) == '.')s = s.substr(1);
		else if (s.length() == 1) {
			cout << 0 << endl;
			return 0;
		}
		else break;
	}
	while (true) {
		if (s.length() >= 2 && s.at(s.length() - 1) == '#')s = s.substr(0, s.length() - 1);
		else if (s.length() == 1) {
			cout << 0 << endl;
			return 0;
		}
		else break;
	}
	//cout << s << endl;
	vector<vector<int>>bw(0, vector<int>(2));
	int b = 0;
	int w = 0;
	for (int i = s.length() - 1; i >= 0; i--) {
		if (b == 0 && s.at(i) == '.')w++;
		else if (b >= 1 && s.at(i) == '.') {
			bw.push_back({ b,w });
			b = 0;
			w++;
		}
		else b++;
	}
	bw.push_back({ b,w });
	/*for (int i = 0; i < bw.size(); i++) {
		for (int j = 0; j < 2; j++)cout << " " << bw.at(i).at(j);
		cout << endl;
	}*/
	reverse(bw.begin(), bw.end());
	ll ans = 10000000;
	ll blcnt = 0;
	for (int i = 0; i < bw.size(); i++) {
		if (i == 0) {
			ans = bw.at(i).at(1);
			blcnt += bw.at(i).at(0);
		}
		else {
			ans = min(ans, blcnt + bw.at(i).at(1));
			blcnt += bw.at(i).at(0);
		}
	}
	ans = min(ans, blcnt);
	cout << ans << endl;

}

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

int main()
{
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int cnt = 0;
  for(int i=0; i<=a; i++)
  {
      for(int j=0; j<=b; j++)
      {
          for(int k=0; k<=c; k++)
          {
              if(500*i+100*j+50*k==x)
              {
                  cnt++;
              }
          }
      }
  }
  cout << cnt << endl;
}


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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& 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 >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

int main(){
  int N, K;
  cin >> N >> K;
  using mint = modint<(int)1e9+7>;
  vector<mint> F(N+1,mint(1)), F_(N+1,mint(1));
  for(int i = 0; i < N; ++i)
    F[i+1] = F[i]*(i+1), F_[i+1] = F_[i]/(i+1);
  auto comb = [=](int n, int k){
                if(n < k) return mint(0);
                return F[n]*F_[n-k]*F_[k];
              };
  for(int i = 1; i <= K; ++i){
    mint ans = comb(N-K+1,i)*comb(K-1,i-1);
    cout << ans << endl;
  }
}


Measured memory_bytes: 256