akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

#define INF 1145141919
int N;
char A[500][500];
char B[500][500];

int f(int Y) {
  bool f = false;
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      B[i][j] = A[i][j];
    }
  }

  int s = -1;
  for (int i=0; i<N; i++) {
    if (A[Y][i] == '#') {
      f = true;
      s = i;
      break;
    }
  }
  int c = 0;
  if (!f) {
    f = false;
    for (int i=0; i<N; i++) {
      if (A[i][Y] == '#') {
        f = true;
        s = i;
        vector<int> v;
        for (int i=0; i<N; i++) v.push_back(B[i][s]);
        for (int i=0; i<N; i++) B[Y][i] = v[i];
        c++;
        break;
      }
    }
    if (!f) return INF;
  }

  for (int x=0; x<N; x++) {
    if (A[x][Y] != '#') {
      vector<int> v;
      for (int i=0; i<N; i++) v.push_back(B[i][s]);
      for (int i=0; i<N; i++) B[x][i] = v[i];
      c++;
    }
  }
  for (int x=0; x<N; x++) {
    bool f = true;
    for (int y=0; y<N; y++) {
      if (B[x][y] != '#') f = false;
    }
    if (!f) c++;
  }
  return c;
}

int main() {
  cin >> N;
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      cin >> A[j][i];
    }
  }
  int m = INF;
  for (int i=0; i<N; i++) {
    m = min(f(i), m);
  }
  cout << (m!=INF?m:-1) << "\n";
  return 0;
}


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

int i,count,shuffle;
string sent,shuf,left;

while(1){
    cin>>sent;
    if(sent=="-")break;
    cin>>count;

  for(i=0; i<count; i++){

      cin>>shuffle;
 shuf=sent.substr(0,shuffle);
left=sent.substr(shuffle,sent.size()-shuffle);
sent=left+shuf;
     
    }
cout<<sent<<"\n";
  }
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+50;
int maxn[N<<2],a[N],f[N];
void change(int rt,int l,int r,int pos,int v)
{
	if(l==r&&l==pos)
	{
		maxn[rt]=v;
		return ;
	}
	int mid=(l+r)>>1;
	if(pos<=mid) change(rt<<1,l,mid,pos,v);
	else change(rt<<1|1,mid+1,r,pos,v);
	maxn[rt]=max(maxn[rt<<1],maxn[rt<<1|1]);
}
int query(int rt,int l,int r,int x,int y)
{
	if(l>=x&&r<=y) return maxn[rt];
	int mid=(l+r)>>1;
	int ans=0;
	if(x<=mid) ans=max(ans,query(rt<<1,l,mid,x,y));
	if(y>mid) ans=max(ans,query(rt<<1|1,mid+1,r,x,y));
	return ans;
}
int n,k;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;++i) cin>>a[i];
	f[1]=1;
	change(1,0,3e5,a[1],1);
	for(int i=2;i<=n;++i)
	{
		int now=query(1,0,3e5,max(a[i]-k,0),min(300000,a[i]+k));
		f[i]=max(1,now+1);
		now=query(1,0,3e5,a[i],a[i]);
		if(now<f[i]) change(1,0,3e5,a[i],f[i]);
	}
	int Max=0;
	for(int i=1;i<=n;++i) Max=max(f[i],Max);
	cout<<Max<<endl; 
	return 0;
}

Measured memory_bytes: 10024
#include<bits/stdc++.h>
using namespace std; 
int n,c,x[100105],m,d[100105],ans[100105],tmp[100105];
long long k;
double a[100105];
int main(){
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
    	scanf("%d",&x[i]);
	}
    scanf("%d%lld",&m,&k);
    for(int i = 1;i <= n;i++){
    	d[i] = i;
		ans[i] = i;
	}
    for(int i = 1;i <= m;i++){
        scanf("%d",&c);
        swap(d[c],d[c+1]);
    }
    while(k){
        if(k&1){
            for(int i = 1;i <= n;i++) tmp[i] = ans[d[i]];
            for(int i = 1;i <= n;i++) ans[i] = tmp[i];
        }
        for(int i = 1;i <= n;i++) tmp[i] = d[d[i]];
        for(int i = 1;i <= n;i++) d[i] = tmp[i];
        k >>= 1;
    }
    for(int i = 1;i <= n;i++) a[i] = x[ans[i]]-x[ans[i]-1];
    for(int i = 1;i <= n;i++){
    	printf("%0.1lf\n",a[i] += a[i-1]);
	}
    return 0;
}

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

#ifdef pr16
  #define pr(x)                 cerr << #x << ": " << x << endl;
  #define pr2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
  #define pr3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
  #define pr4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
  #define pr5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
  #define pr6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
  #define prdd(a,r,c) for(int i=0;i<(r);i++) { for(int j = 0;j<(c);j++) cerr<<a[i][j]<<" "; cerr<<endl; } cerr<<endl;
  #define prc(a) tr(a, it) cerr<<*(it)<<" "; cerr<<endl
  #define pra(a,n) for(int i=0; i<(n); i++) cerr<<((a)[i])<<" "; cerr<<"\n"
  #define prdd(a,r,c) for(int i=0;i<(r);i++) { for(int j = 0;j<(c);j++) cerr<<a[i][j]<<" "; cerr<<endl; } cerr<<endl; 
  #define prddd(a,x,y,z) for(int i=0;i<x;i++) {cerr<<"layer "<<i<<":\n";prdd(a[i],y,z)}
 
#else
  #define pr(x)
  #define pr2(x, y)
  #define pr3(x, y, z)
  #define pr4(a, b, c, d)
  #define pr5(a, b, c, d, e)
  #define pr6(a, b, c, d, e, f)
  #define prc(a)
  #define pra(a,n)
  #define prdd(a, r, c)
  #define prddd(a,x,y,z)
#endif


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin>>n>>k;
    int a[n];
    for(int i = 0; i< n; i ++) {
    	cin >> a[i];
    }

    for (int i = k; i < n; i++) {
    	if (a[i] > a[i-k])
    		cout <<"Yes\n";
    	else
    		cout <<"No\n";
    }

    return 0;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c, k;
    cin>>a>>b>>c>>k;
    int ans = 0;
    ans = min(k, a);
    k -= a;
    if(k <= 0 || k <= b)
    {
        cout<<ans<<endl;
        return 0;
    }
    k -= b;
    ans -= min(k, c);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
k = input().split()
a = k[0]
b = k[1]
c = k[2]
for i in range(len(k)):
    k[i] = int(k[i])
h = max(k)

Buf = 1
del k[k.index(h)]

for i in k:
    Buf = Buf * int(i)
r = Buf/2
print(int(r))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;  
int main() 
{
	int n,m;
	cin>>n>>m;
	int q=1e9+7;
	int dp[n][m];
	char c[n][m];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		cin>>c[i][j];
	}
	dp[0][0]=1;
	for(int i=1;i<n;i++)
	{
		if(c[i][0]=='.')
		dp[i][0]=dp[i-1][0];
		else
		dp[i][0]=0;
	}
	for(int i=1;i<m;i++)
	{
		if(c[0][i]=='.')
		dp[0][i]=dp[0][i-1];
		else
		dp[0][i]=0;
	}
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<m;j++)
		{
			if(c[i][j]=='.')
			dp[i][j]=(dp[i-1][j]%q+dp[i][j-1]%q)%q;
			else
			dp[i][j]=0;
		}
	}
			
	cout<<dp[n-1][m-1];
}


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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	vector<int> a;
	int sum = 0;
	for(int i = 0; i < 5; i++){
		int b;
		cin >> b;
		sum += b;
		b = (b + 10) / 10 * 10 - b;
		if(b % 10 == 0)b = 0;
		pb(a,b);
	}
	sort(ben(a));
	for(int i = 0; i < 4; i++){
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
using vi = vector<int>;
using vi2 = vector<vi>;

int pow2(int a) {
  int ret = 1;
  for (int i = 0; i < a; i++) ret *= 2;
  return ret;
}

int count(vi2 hw, int a, int b) {
  int sum = 0;
  for (int i = 0; i < hw.size(); i++) {
    for (int j = 0; j < hw[0].size(); j++) {
      if (a >> i & 1 && b >> j & 1 && hw[i][j] == 1) sum++;
    }
  }
  return sum;
}

int main() {
  int h, w, k; cin >> h >> w >> k;
  vi2 hw(h, vi(w, 0));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c; cin >> c;
      if (c == '#') hw[i][j] = 1;
    }
  }
  int sum = 0;
  for (int i = 0; i < pow2(h); i++) {
    for (int j = 0; j < pow2(w); j++) {
      if (count(hw, i, j) == k) sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k;
  cin >> k;
  vector<int> v{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << v[k-1] << endl;
}

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

int main() {
  long long int n,m;
  cin >> n >> m;
  
  vector<long long> a(n+1);
  vector<long long> sum(n+1);
  a[0]=0;
  sum[0]=0;
  
  for(long long i=1; i<=n; i++) {
    cin >> a[i];
    sum[i] = sum[i-1] + a[i];
    sum[i] = sum[i] % m;
  }
  
  map<long long, long long> cnt{};
  for(long long i=0; i<=n; i++){
    cnt[sum[i]] ++;
  }
  
  long long ans=0;
  for(auto x: cnt){
    ans += (x.second)*(x.second - 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 3000000007;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------
// http://drken1215.hatenablog.com/entry/2019/05/28/124300
// けんちょんさんのUnion Find
struct UnionFind {
    vector<int> par, w;

    UnionFind(int n) : par(n, -1), w(n, 0) { }
    void init(int n) { par.assign(n, -1); w.assign(n, 0); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) {
            ++w[x];
            return false;
        }
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        w[x] += w[y];
        ++w[x];
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }

    int wei(int x) {
        return w[root(x)];
    }
};



int main(){
  ll N,M;
  cin >> N >> M;
  vector<int> a(M),b(M);
  for(int i=M-1; i>=0; i--){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  UnionFind uf(N);
  vector<ll> ans;
  ans.push_back((N*(N-1))/2);
  for(int i=0; i<M-1; i++){
    if(uf.issame(a[i],b[i])){
      ans.push_back(ans[i]);
    }else{
      ll x,y;
      x = uf.size(a[i]);
      y = uf.size(b[i]);
      uf.merge(a[i],b[i]);
      ans.push_back(ans[i]-(x*y));
    }
  }
  for(int i=M-1; i>=0; i--){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll k, t; cin >> k >> t;
    vector<ll> a(t); cin >> a;
    sort(a.rbegin(), a.rend());
    ll s = a[0];
    rep(i, t){
        if(i == 0) continue;
        if(s == 0){
            s = a[i];
            continue;
        }
        ll u = a[i];
        if(s < u) swap(s, u);
        s = s - u;
    }
    ll ans = s-1;
    if(ans < 0) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define NFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); --i)
#define endl "\n"
#define mp make_pair
#define X first
#define Y second
#define inf 1e18
#define mod 1000000007
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()
#define sz(x) int(x.size())
// #define lli int
typedef long long int lli;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef pair<lli,lli> pll;
typedef vector<lli> vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

const int N = 100010;

vi Adj[N + 1];
int dp[N + 1];

int DFS(int u, int p) {
	bool isZeroSubTree = false;
	for (auto v : Adj[u]) {
		if (v != p) {
			dp[u] += DFS(v, u);
			if (dp[v] == 0) {
				if (!isZeroSubTree) isZeroSubTree = true;
				else dp[u]++;
			}
		}
	}
	return dp[u];
}

int main() {
	int n; cin >> n;
	FOR(i, 1, n-1) {
		int a1, b1; cin >> a1 >> b1; a1++, b1++; 
		Adj[a1].pb(b1), Adj[b1].pb(a1);
	}

	int greater = -1;
	FOR(i, 1, n) {
		if (sz(Adj[i]) > 2) {
			greater = i;
		}
	}
	if (greater == -1) {
		cout << "1\n";
	} else {
		DFS(greater, 0);
		cout << dp[greater] << "\n";
	}
return 0;}

Measured memory_bytes: 10496
#include <iostream>

int main() {
	int a,b,c,count;
	count=0;
    std::cin>>a;
    std::cin>>b;
    std::cin>>c;
    for ( ;a<=b;a++){
     if (c%a==0){
     	count++;
     }
    }
	if (a>b){
		std::cout << count << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

ll a[100010] = {}, sum = 0, realSum = 0, howPlus = 0;
ll plusK[100010] = {}, bubu[100010] = {};

int main() {
	ll n, k;
	cin >> n >> k;
	REP(i, n){
		cin >> a[i];
		if(a[i] > 0){
			howPlus++;
			sum += a[i];
		}
		realSum += a[i];
	}

	ll ans = 0;
	if(n == k) ans = max(0LL, realSum);

	for(int i = 0;i < n;i++){
		if(i != 0){
			plusK[i] += plusK[i - 1];
			bubu[i] += bubu[i - 1];
		}
		bubu[i] += a[i];
		if(a[i] > 0) plusK[i] += a[i];
		if(i - k >= 0 && a[i - k] > 0) plusK[i] -= a[i - k];
		if(i - k >= 0) bubu[i] -= a[i - k];
		// cout << plusK[i] << " ";
	}
	// cout << endl;
	// REP(i, n){
	// 	cout << bubu[i] << " ";
	// }
	// cout << endl;
	for(int i = n - 1;i >= k;i--){
		ans = max(ans, max(sum - plusK[i], sum - plusK[i] + bubu[i]));
	}
	// cout << sum << endl;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
    int h, w; 
    cin >> h >> w;
    int m;
    cin >> m;
    int mxr = 0, mxc = 0;
    vector<int> row(h), col(w);
    vector<pair<int, int>> v;
    for (int i = 0; i < m; i++) {
        int x, y; 
        cin >> x >> y;
        --x, --y;
        mxr = max(mxr, ++row[x]);
        mxc = max(mxc, ++col[y]);
        v.emplace_back(x, y);
    }
    int inter = 0;
    for (auto [x, y] : v) {
        if (row[x] == mxr and col[y] == mxc)
            ++inter;
    }
    int cnt_mxr = count(row.begin(), row.end(), mxr);
    int cnt_mxc = count(col.begin(), col.end(), mxc);
    cout << (mxr + mxc - (inter == 1ll * cnt_mxr * cnt_mxc)) << "\n";
}

Measured memory_bytes: 9768
# import math
# from operator import mul
# from functools import reduce
x,y = map(int, input().split())
n = (x+y)//3
r = (2*x-y)//3
mod = 10**9+7
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if (x+y)%3!=0:
    print(0)
elif 2*x-y<0:
    print(0)
elif -x+2*y<0:
    print(0)
else:
    # print((math.factorial((x+y)//3)//(math.factorial((2*x-y)//3)*math.factorial((2*y-x)//3)))%mod)
    # print(combinations_count(n,r)%mod)
    print(cmb(n,r,mod))


Measured memory_bytes: 122000
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,f[N],x[N],y[N];
vector<int>X[N];
set<int>S[N];
int find(int x) {
	return f[x]==x?x:f[x]=find(f[x]);
}
int main() {
	scanf("%d",&n);
	for(int i=1; i<=N-5; i++)f[i]=i;
	for(int i=1; i<=n; i++) {
		scanf("%d%d",&x[i],&y[i]);
		X[x[i]].push_back(y[i]);
	}
	for(int i=1; i<=N-5; i++) {
		int fa;
		if(X[i].size())fa=find(X[i][0]);
		for(int j=1; j<X[i].size(); j++) {
			int x=find(X[i][j]);
			f[x]=fa;
		}
	}
	for(int i=1; i<=N-5; i++) {
		int fa;
		if(X[i].size())fa=find(X[i][0]);
		for(int j=0; j<X[i].size(); j++)
			S[fa].insert(X[i][j]);
	}
	long long ans=0;
	for(int i=1; i<=N-5; i++) {
		if(X[i].size()) {
			int fa=find(X[i][0]);
			ans+=1ll*S[fa].size();
		}
	}
	printf("%lld\n",ans-n);
	return 0;
}


Measured memory_bytes: 12416
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        string[] array = Console.ReadLine().Split(' ');
        int H = int.Parse(array[0]);
        int W = int.Parse(array[1]);

        int[,] a = new int[H, W];

        for (int i = 0; i < H; i++)
        {
            array = Console.ReadLine().Split(' ');
            for (int j = 0; j < W; j++)
                a[i, j] = int.Parse(array[j]);
        }

        int N = 0;

        List<string> list = new List<string>();


        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (a[i, j] % 2 == 1)
                {
                    if (i == H - 1)
                    {
                        if (j != W - 1) // 下端だけど右端じゃない
                        {
                            N++;
                            a[i, j]--;
                            a[i, j + 1]++;
                            list.Add((i + 1) + " " + (j + 1) + " " + (i + 1) + " " + (j + 2));
                        }
                    }
                    else
                    {
                        if (j == W - 1) // 下端じゃないけど右端
                        {
                            N++;
                            a[i, j]--;
                            a[i + 1, j]++;
                            list.Add((i + 1) + " " + (j + 1) + " " + (i + 2) + " " + (j + 1));
                        }
                        else // 下端じゃないし右端じゃない
                        {
                            if (a[i, j + 1] % 2 == 1) // 右が奇数
                            {
                                N++;
                                a[i, j]--;
                                a[i, j + 1]++;
                                list.Add((i + 1) + " " + (j + 1) + " " + (i + 1) + " " + (j + 2));
                            }
                            else
                            {
                                if (a[i + 1, j] % 2 == 1) // 下が奇数
                                {
                                    N++;
                                    a[i, j]--;
                                    a[i + 1, j]++;
                                    list.Add((i + 1) + " " + (j + 1) + " " + (i + 2) + " " + (j + 1));
                                }
                                else //右も下も偶数なら右行く
                                {
                                    N++;
                                    a[i, j]--;
                                    a[i, j + 1]++;
                                    list.Add((i + 1) + " " + (j + 1) + " " + (i + 1) + " " + (j + 2));
                                }
                            }
                        }
                    }
                }
            }
        }

        Console.WriteLine(N);

        for (int i = 0; i < list.Count; i++)
            Console.WriteLine(list[i]);
    }
}

Measured memory_bytes: 28568
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1,0); }
	V<V<pin>> qab(2);
  int sz=ab.size();
  qab[0].reserve(sz);
  qab[1].reserve(sz);
	for (pin &x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2,x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2,(x.second + 1) / 2)); }
	}
  int c=0;
		for (pin &x : qab[1]) {
			int qc = (2 * x.first + x.second)%3;
          c^=(qc+1);
		}
		if (!c) {
			pin ans = solve(qab[0], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += 0;
			return ans;
		}
    c=0;
		for (pin &x : qab[0]) {
			int qc = (2 * x.first + x.second)%3;
          c^=(qc+1);
		}
		if (!c) {
			pin ans = solve(qab[1], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += 1;
			return ans;
		}
	for(pin &v:ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
signed main() {
	long long inf = 2e17;
	int n; scanf("%lld", &n);
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; scanf("%lld", &a); scanf("%lld", &b);
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 70);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}

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

vector<string> lis;
int h, w;
int ans = 100000000;
vector<vector<int> > memo(1000, vector<int>(1000, 10000000));

void solve(int x, int y,int num, int pre){
    if(x == h || y == w){
        return;
    }
    int k;
    if(lis[x][y] == '.'){
        k = 1;
    }else{
        k = -1;
    }
    if(x == h-1 && y == w-1){
        if(pre == 1 && k == -1){
            num++;
        }
        ans = min(ans, num);
        return;
    }
    if(x == 0 && y == 0){
        solve(1, 0, num, k);
        solve(0, 1, num, k);
        return;
    }
    if(pre == 1 && k == -1){
        num++;
    }
    if(memo[x][y] <= num){
        return;
    }else{
        memo[x][y] = num;
    }
    solve(x+1, y, num, k);
    solve(x, y+1, num, k);
}

int main(){
    cin >> h >> w;
    lis = vector<string>(h);
    for(int i = 0; i < h; i++){
        cin >> lis[i];
    }
    int k = 1;
    if(lis[0][0] == '#'){
        k = -1;
        solve(0, 0, 1, k);
    }else{
        solve(0, 0, 0, k);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4224
#include <iostream>
#include <unordered_map>

int main() {
  unsigned int N;
  std::cin >> N;

  std::unordered_map<std::string, bool> map;
  for (unsigned int i = 0; i < N; ++i) {
    std::string S;
    std::cin >> S;
    map.emplace(S, true);
  }

  std::cout << map.size() << std::endl;

  return 0;
}


Measured memory_bytes: 17732
#include <stdio.h>
#include <math.h>
int abs(int n){
    if(n>0)return n;
    return -n;
}
int main(){
    int n,x[100],y[100];
    double a=0,b=0,c=0,d=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&y[i]);
        if(abs(x[i]-y[i])>d)d=abs(x[i]-y[i]);
        a+=abs(x[i]-y[i]);
        b+=(x[i]-y[i])*(x[i]-y[i]);
        c+=abs(x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]);
    }
    
    printf("%lf\n%lf\n%lf\n%lf\n",a,sqrt(b),pow(c,0.33333333333),d);
}

Measured memory_bytes: 2864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

int main(){
	ll n,m;
    cin >> n >> m;
    ll out;
    if(n > 1 && m > 1){
        out = (n-2)*(m-2);
    }else if(n == 1 && m == 1){
        out = 1;
    }else{
        out = n + m - 3;
    }

    cout << out << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007
#define GOO 'g'
#define PA 'p'

using namespace std;
string S;

int main(){
	cin >> S;
	long long diff;
	long long score;

	//have to choose go
	if(S[0] == PA){
		score = -1;
	}else{
		score = 0;
	}
	diff = 1;

	for(int i = 1; i < S.size(); i++){
		if(S[i] == PA){
			if(diff != 0){
				diff--;
			}else{
				score--;
				diff++;
			}
		}else{

			if(diff != 0){
				diff--;
				score++;
			}else{
				diff++;
			}
		}
	}

	cout << score << endl;

}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;


int N_MAX = 5010;
int n, k;
vector<ll> P(N_MAX), C(N_MAX);

ll solve() {
    ll res = -INF;
    // サイクルに分ける
    vector<vector<ll>> cycle;
    vector<bool> used(n+10, false);
    rp(i, 0, n) {
        if(used[i]) continue;
        int cur = i;
        vector<ll> s;
        while(1) {
            if(used[cur]) break;
            used[cur] = true;
            s.push_back(C[cur]);
            cur = P[cur];
        }
        cycle.push_back(s);
    }

    // サイクルごとに考える
    for(auto x:cycle) {
        ll M = x.size();  // サイクルの大きさ
        ll sum = 0ll;  // サイクル一周の得点
        for(auto y: x) sum+=y;
        vector<ll> Cum(2*M);  // 累積和
        Cum[0] = x[0];
        rp(i, 1, 2*M) {
            Cum[i] = Cum[i-1] + x[i%M];
        }
        rp(r, 1, M+1) {  // 余りを固定 余りは1~M
            if(r > k) continue;
            rp(m, 0, M){  // 何番目から取り始めるか
                ll temp = Cum[m+r] - Cum[m];
                if(sum > 0) temp += ((k-r) / M) * sum;
                chmax(res, temp);
            }  
        }
    }
    return res;
}

int main() {
    cin >> n >> k;
    rp(i, 0, n) {
        ll p; cin >> p; p--; P[i] = p;
    }
    rp(i, 0, n) {
        ll c; cin >> c; C[i] = c;
    }
    cout << solve() << endl;
}

Measured memory_bytes: 3864
#include<iostream>
using namespace std;
void swap (int& a, int& b) {
  int t = a;
  a = b;
  b = t;
}
int main () {
  int A, B, C;
  cin >> A >> B >> C;
  if (A > C) swap(A, C);
  if (B > C) swap(B, C);
  cout << A * B / 2<< endl;
}


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

using namespace std;

long long n, p;

int
main()
{
	cin >> n >> p;
	if( n == 1 )
	{
		cout << p << endl;
		return 0;
	}
	if( n > 40 )
	{
		cout << 1 << endl;
		return 0;
	}
	long long x = static_cast<long long>( ceil( sqrt( p ) ) );
	while( ( p % x ) != 0 || ( p % static_cast<long long>( pow( x, n ) ) ) != 0 ) --x;
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
def ALDS1_5A():
    n, A, q = int(input()),list(map(int, input().split())), int(input())
    allFromA = [False]*2001
    for a in A:
        for i in range(2000-a, 0, -1):
            if allFromA[i]:
                allFromA[i+a] = True
        allFromA[a] = True

    for m in input().split():
        if allFromA[int(m)]:
            print('yes')
        else:
            print('no')

if __name__ == '__main__':
    ALDS1_5A()

Measured memory_bytes: 7776
def main():
    X, K, D = map(int, input().split())

    if D * K > abs(X):
        if (abs(X) // D - K) % 2 == 0:
            print(abs(X) % D)
        else:
            print(abs(abs(X) % D-D))
    else:
        print(abs(X)-D*K)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9176
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

ll pow(ll x) {
    return x * x * x * x * x;
}

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

    for(int i = -1000; i <= 1000; i++) {
        for(int j = -1000; j <= 1000; j++) {
            if(pow(i) - pow(j) == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{ 
  int N;cin>>N;
  int T = N + (int)(N%2 == 0);
  cout<<N*(N-1)/2 - N/2<<endl;
  for (int i = 1; i <= N; i++)
  {
    for (int j = i+1; j <= N; j++)
    {
      if(i+j == T)continue;
      cout<<i<<" "<<j<<endl;
    }
    
  }
  
  return;
}

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

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <sstream>

using namespace std;

int a[200000] = {};

int main(){
	
	int N;
	
	cin >> N;
	
	for(int i = 0; i < N; i++){
		int p, q;
		cin >> p >> q;
		a[p - 1]++;
		a[q]--;
	}
	
	int count = 0;
	int ans = 0;
	
	for(int i = 0; i < 200000; i++){
		count += a[i];
		if(count >= i){
			ans = i;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3460
// https://atcoder.jp/contests/abc114/tasks/abc114_c
// TODO: refactoring

fun main() {
    abc114c()
}

fun abc114c() {
    val n = readLine()!!
    if (n.toLong() < 357L) {
        // 3,5,7がすくなくとも1つずつ必要なので、最低値は357
        println(0)
        return
    }
    // 3,5,7の組み合わせだが、それぞれ1個以上ないといけないのが地味にきく
    // たとえば337とかは5がないのでダメ
    // N=1000の場合は6になる（357,375,537,573,735,753の6つ）
    // N=4000だと3桁は上記パターンのみ、4桁の数字だと4桁目に3が使えるようになるので、
    // 任意の1桁に3,5,7が自由に使えるようになる。これがややこしい
    // 最大でも10桁、かつ各桁3個の数字しかないので、全組み合わせでやればいいんじゃないだろうか
    // 解けたけど、こんなくそややこしいロジックより良い方法あるんちゃうの？
    // ただ解説を見た限り、考え方としてはこのやり方は悪くないらしい
    // 実装はよくなさそう
    val v = NanaGoSan(n)
    var count = 0
    while (v.increment()) {
        if (v.isSatisfy()) count++
    }
    println(count)
}

private class NanaGoSan(val origin: String) {
    val digits: Int
    val maxValue: IntArray
    val originValue: IntArray
    val currentValue: IntArray
    
    init {
        digits = origin.length
        maxValue = IntArray(digits)
        originValue = IntArray(digits)
        currentValue = IntArray(digits) { 0 }
        var n = origin.toLong()
        for (i in 0 until digits) {
            val t = n % 10
            originValue[i] = t.toInt()
            val v = when (t) {
                in 3..4 -> 1
                in 5..6 -> 2
                in 7..9 -> 3
                else -> 0
            }
            n /= 10
            maxValue[i] = v
        }
        var i = digits - 1
        var update = false
        while (i >= 0) {
            if (update) {
                maxValue[i] = 3
            } else {
                if (originValue[i] !in setOf(3, 5, 7)) update = true
            }
            i--
        }
    }
    
    fun increment(i: Int = 0): Boolean {
        if (!lessThanLimit()) return false
        if (i >= digits) return false
        if (currentValue[i] == 3) {
            currentValue[i] = 1
            return increment(i + 1)
        }
        currentValue[i]++
        return true
    }
    
    fun isSatisfy(): Boolean {
        if (!lessThanLimit()) return false
        var one = 0
        var two = 0
        var three = 0
        for (i in digits - 1 downTo 0) {
            when (currentValue[i]) {
                1 -> one++
                2 -> two++
                3 -> three++
                else -> Unit
            }
            if (one > 0 && two > 0 && three > 0) return true
        }
        return false
    }
    
    private fun lessThanLimit(): Boolean {
        for (i in digits - 1 downTo 0) {
            if (currentValue[i] < maxValue[i]) return true
            if (currentValue[i] > maxValue[i]) return false
        }
        return true
    }
}

Measured memory_bytes: 39188
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
     
    int min1,max1;
    min1 = min(b,d);
    max1 = max(a,c);
    if((min1 - max1) > 0 )
    cout << abs(min1 - max1) << endl;
    else
    cout << 0 << endl;
     
     
    }

Measured memory_bytes: 256
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int R = sc.nextInt();
    if (N >= 10) {
      System.out.println(R);
    } else {
      System.out.println(R + (100 * (10 - N)));
    }
  }
}


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

const int MAX_V = 50;
const int MAX_S = MAX_V*50+5;
const ll INF = 1e18;

struct Edge {
  int to, a, b;
  Edge(int to, int a, int b):to(to),a(a),b(b) {}
};

struct Data {
  int v, s;
  ll x;
  Data(int v, int s, ll x):v(v),s(s),x(x) {}
  bool operator<(const Data& a) const {
    return x > a.x;
  }
};

vector<Edge> g[MAX_V];
ll dist[MAX_V][MAX_S+5];

int main() {
  int n, m, s;
  cin >> n >> m >> s;
  rep(i,m) {
    int u,v,a,b;
    cin >> u >> v >> a >> b;
    --u; --v;
    g[u].emplace_back(v,a,b);
    g[v].emplace_back(u,a,b);
  }
  rep(i,n)rep(j,MAX_S+5) dist[i][j] = INF;
  s = min(s, MAX_S);
  priority_queue<Data> q;
  auto push = [&](int v, int s, ll x) {
    if (s < 0) return;
    if (dist[v][s] <= x) return;
    dist[v][s] = x;
    q.emplace(v,s,x);
  };
  vector<int> c(n), d(n);
  rep(i,n) cin >> c[i] >> d[i];
  push(0,s,0);
  while (!q.empty()) {
    Data hoge = q.top(); q.pop();
    int v = hoge.v, s = hoge.s;
    ll x = hoge.x;
    if (dist[v][s] != x) continue;
    {
      int ns = min(s+c[v], MAX_S);
      push(v,ns,x+d[v]);
    }
    for (Edge e : g[v]) {
      push(e.to, s-e.a, x+e.b);
    }
  }
  for (int i = 1; i < n; ++i) {
    ll ans = INF;
    rep(j,MAX_S+5) {
      ans = min(ans, dist[i][j]);
    }
    cout << ans << endl;
  }
  return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k;
string s;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b;
	cin >> a >> b;
	if(a+b == 15) cout<<"+";
	else if(a*b == 15) cout<<"*";
	else cout<<"x";
}

int main() {
	fastio; randomINT;
	//cin>>T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 238028
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int max = 0;
      //１文字目始まりから探す
      for(int i=0;i<s.length();i++){
        int count = 0;
        for(int j=i;j<s.length();j++){
          if(s.charAt(j)=='A' || s.charAt(j)=='C' || s.charAt(j)=='G' || s.charAt(j)=='T'){
            count++;
          }else{
            break;
          }
        }
        max = Math.max(max,count);
      }
      System.out.println(max);
    }
}

Measured memory_bytes: 35516
import java.util.Arrays;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] h = new int[N];
        for (int i = 0; i < h.length; ++i) {
            h[i] = sc.nextInt();
        }

        System.out.println(solve(h, K));

        sc.close();
    }

    static int solve(int[] h, int K) {
        int[] costs = new int[h.length];
        Arrays.fill(costs, Integer.MAX_VALUE);
        costs[0] = 0;

        for (int i = 0; i < costs.length; ++i) {
            for (int j = i - 1; j >= 0 && i - j <= K; --j) {
                costs[i] = Math.min(costs[i], costs[j] + Math.abs(h[i] - h[j]));
            }
        }

        return costs[costs.length - 1];
    }
}

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

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

  if(k%2==0){
    if(abs(a-b)>1000000000000000000){
      cout<<"Unfair"<<endl;
    }else{
      cout<<a-b<<endl;
    }
  }else{
    if(abs(b-a)>1000000000000000000){
      cout<<"Unfair"<<endl;
    }else{
      cout<<b-a<<endl;
    }
  }
  return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int k; string s;
	cin >> s; k = s.size();
	int w = 15 - k;
	for (auto c : s) {
		if (c == 'o') {
			++w;
		}
	}
	puts(w >= 8 ? "YES" : "NO");

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class main{
	static void Main(){
		int N = int.Parse(Console.ReadLine());
		Dictionary<string, int> dic = new Dictionary<string, int>();
		for(int i = 0; i < N; i++){
			string str = Console.ReadLine().Trim();
			if(dic.ContainsKey(str)){
				dic[str] = dic[str] + 1;
			}else{
				dic.Add(str, 1);
			}
		}
		int M = int.Parse(Console.ReadLine());
		for(int i = 0; i < M; i++){
			string str = Console.ReadLine().Trim();
			if(dic.ContainsKey(str)){
				dic[str] = dic[str] - 1;
			}else{
				dic.Add(str, -1);
			}
		}
		int ans = 0;
		foreach(KeyValuePair<string, int> e in dic){
			if(e.Value > ans) ans = e.Value;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13152
import sys
input=sys.stdin.readline

s=int(input())

INF=10**9+7

def modcomb(n,k,m):
    fac=[0]*(n+1)
    finv=[0]*(n+1)
    inv=[0]*(n+1)
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,n+1):
        fac[i]=fac[i-1]*i%m
        inv[i]=m-inv[m%i]*(m//i)%m
        finv[i]=finv[i-1]*inv[i]%m
    return fac[n]*(finv[k]*finv[n-k]%m)%m

ans=0
if s==3:
    ans=1
else:
    for n in range(1,667):
        if s-3*n>=0:
            ans=(ans+modcomb(s-2*n-1,n-1,INF))%INF

print(ans)

Measured memory_bytes: 67500
row1 = list(map(int,input().split()))
row2 = list(map(int,input().split()))
row3 = list(map(int,input().split()))
n = int(input())
arr = []
for i in range(n):
    temp = int(input())
    arr.append(temp)
#
if row1[0] in arr and row1[1] in arr and row1[2] in arr or row2[0] in arr and row2[1] in arr and row2[2] in arr or row3[0] in arr and row3[1] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[0] in arr and row3[0] in arr or row1[1] in arr and row2[1] in arr and row3[1] in arr or row1[2] in arr and row2[2] in arr and row3[2] in arr:
    print("Yes")
    exit()
elif row1[0] in arr and row2[1] in arr and row3[2] in arr or row1[2] in arr and row2[1] in arr and row3[0] in arr:
    print("Yes")
    exit()
else:
    print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int mod = 1000000007;
		String L = in.next();
		long ans = 1;
		ans += pow(3,L.length()-1,mod)-1;
		long num = 2;
		for(int i=1;i<L.length();i++) {
			if(L.charAt(i)=='0') continue;
			else {
				ans = (ans + (num*pow(3,L.length()-1-i,mod))%mod)%mod;
				num = (num*2)%mod;
			}
		}
		ans = (ans + num)%mod;
		System.out.println(ans);
		in.close();

	}
	
	//return a^b mod M O(logB)
	public static long pow(long a,long b,int M) {
		long ret = 1;
		long tmp = a;
		while(b>0) {
			if((b&1)==1) ret = (ret * tmp) % M;
			tmp = (tmp * tmp) % M;
			b = b>>1;
		}
		return ret;
	}

}


Measured memory_bytes: 23764
import Foundation
let N = Int(readLine()!)!

// -1: not determined, 0: black, 1: white
var graph: [[Int]] = .init(repeating: [], count: N)
var costs: [[Int]] = .init(repeating: [], count: N)
var colors: [Int] = .init(repeating: -1, count: N)

for _ in 0..<N-1 {
  let input = readLine()!.split(separator: " ").map { Int($0)! }
  graph[input[0] - 1].append(input[1] - 1)
  graph[input[1] - 1].append(input[0] - 1)
  costs[input[0] - 1].append(input[2])
  costs[input[1] - 1].append(input[2])
}


var queue = Set<Int>()
queue.insert(0)
colors[0] = 0

while !queue.isEmpty {
  let top = queue.first!
  queue.remove(top)
  for i in 0..<graph[top].count {
    let u = graph[top][i]
    let w = costs[top][i]
    if colors[u] != -1 {
      continue
    }
    colors[u] = (colors[top] + w)  % 2
    queue.insert(u)
  }
}

colors.forEach { print($0) }



Measured memory_bytes: 27944
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU
import qualified Data.Map.Strict as M
import Data.List

main = abc162d

abc162d = do
    [n] <- getIntList
    s <- BS.getLine
    if BS.length s < 3 
    then print 0
    else let rgbV = convRGB s (VU.empty, VU.empty, M.empty)
         in print $ solveD rgbV

convRGB s (r,g,b)
    | BS.null s = (r,g,b)
    | BS.head s == 'R' = convRGB (BS.tail s) (VU.cons n r,g,b)
    | BS.head s == 'G' = convRGB (BS.tail s) (r,VU.cons n g,b)
    | BS.head s == 'B' = convRGB (BS.tail s) (r,g,M.insert n n b)
    where n = VU.length r + VU.length g + M.size b + 1

solveD (r,g,b)
    | VU.null r || VU.null g || M.null b = 0
    | VU.length r == 1 = subSolveD (VU.head r, g, b)
    | otherwise = subSolveD (VU.head r, g, b) + solveD (VU.tail r, g, b)

subSolveD (r,g,b)
    | VU.length g == 1 = subSubSolveD (r, VU.head g, b)
    | otherwise = subSubSolveD (r, VU.head g, b) + subSolveD (r, VU.tail g, b)

subSubSolveD (r,g,b)
    | g < r
        = M.size b - (if bgrBool then 1 else 0) - (if grbBool then 1 else 0) - (if xbxBool then 1 else 0)
    | r < g
        = M.size b - (if brgBool then 1 else 0) - (if rgbBool then 1 else 0) - (if xbxBool then 1 else 0)
    where bgrBool = let diff = g - (r - g) in diff > 0 && diff <= 4000 && M.member (g - (r - g)) b
          grbBool = let diff = r + (r - g) in diff > 0 && diff <= 4000 && M.member (r + (r - g)) b
          brgBool = let diff = r - (g - r) in diff > 0 && diff <= 4000 && M.member (r - (g - r)) b
          rgbBool = let diff = g + (g - r) in diff > 0 && diff <= 4000 && M.member (g + (g - r)) b
          xbxBool = even (r + g) && M.member (div (r + g) 2) b


readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

Measured memory_bytes: 9136
/*https://atcoder.jp/contests/abc108/tasks/abc108_b*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#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
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = c - a, y = d - b;
	cout << c - y << " " << d + x << " " << a - y << " " << b + x;

}

Measured memory_bytes: 3648
while 1:

  str = raw_input().split()
  a = int(str[0])
  op = str[1]
  b = int(str[2])

  if op == '+':
    print a+b
  elif op == '-':
    print a-b
  elif op == '*':
    print a*b
  elif op == '/':
    print a/b
  elif op == '?':
    break

Measured memory_bytes: 6380
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

H, W = MAP()

def divide_3(A, B):
	ans = INF

	for a in range(A+1):
		p1 = a * B
		p2 = (A-a) * (B//2)
		p3 = A*B - p1 - p2
		ans = min(ans, max(p1, p2, p3) - min(p1, p2, p3))

		q1 = a * B
		q2 = (A-a)//2 * B
		q3 = A*B - q1 - q2
		ans = min(ans, max(q1, q2, q3) - min(q1, q2, q3))

	return ans

print(min(divide_3(H, W), divide_3(W, H)))

Measured memory_bytes: 10512