akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

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

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  //cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  //cout<<"}";
  return os;
}

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

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  //cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  //cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

int main(void){
  int H,W,N; cin>>H>>W>>N;
  vec<int> a(N); cin>>a;
  
  mat<int> c(H,vec<int>(W,0));
  int now=0,cnt=0;
  rep(i,H){
    if(i%2==0){
      rep(j,W){
        c[i][j]=now+1,++cnt;
        if(cnt==a[now]) ++now,cnt=0;
      }
    }
    else{
      for(int j=W-1; j>=0; --j){
        c[i][j]=now+1,++cnt;
        if(cnt==a[now]) ++now,cnt=0;
      }
    }
  }
  
  rep(i,H){
    cout<<c[i]<<endl;
  }
}














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

int main() {
    int n;
    int taro_score = 0;
    int hanako_score = 0;
    string taro, hanako;
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> taro >> hanako;
        if (taro > hanako) taro_score += 3;
        else if (taro < hanako) hanako_score += 3;
        else {
            taro_score++;
            hanako_score++;
        }
    }
    
    cout << taro_score << ' ' << hanako_score << endl;
    
    return 0;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
struct data{
    int value;
    int order;
};
bool order(data a, data b){
    return a.value < b.value;
}
data seq[200200];
int i,n,d,pos,ans[200200];
int main(){
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&d);
        seq[i].value=d;
        seq[i].order=i;
    }
    pos=n/2;
    sort(seq+1,seq+n+1,order);
    /*for(i=1;i<=n;i++){
        cout << seq[i].order << seq[i].value << endl;
    }*/
    for(i=1;i<=n;i++){
        if(i<=pos){
            ans[seq[i].order]=seq[pos+1].value;
        }
        else{
            ans[seq[i].order]=seq[pos].value;
        }
    }
    for(i=1;i<=n;i++){
        cout << ans[i] << endl;
    }
}


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

int n;
vector<int> to[100005];
vector<int> dist;

void dfs(int v, int d = 0, int p = -1){
    dist[v] = d;
    for(int u : to[v]){
        if(u == p) continue;
        dfs(u, d+1, v);
    }
}

vector<int> calcDist(int s){
    dist = vector<int>(n);
    dfs(s);
    return dist;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s, t;
    cin >> n >> s >> t;
    s--; t--;
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> distS = calcDist(s);
    vector<int> distT = calcDist(t);
    int mx = 0;
    for(int i = 0; i < n; i++){
        if(distS[i] < distT[i]) mx = max(mx, distT[i]);
    }
    int ans = mx - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10744
N,M,X,Y = map(int, input().split())

x = list(map(int, input().split()))
y = list(map(int, input().split()))

Z = [X+1, Y]

x.sort()
y.sort()

Z[0] = max(x[-1]+1, Z[0])
Z[1] = min(y[0], Z[1])

print("No War" if Z[0]<=Z[1] else "War")


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define size(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int> a(n);
    unordered_map<int,int> mp;
    for(auto& it:a) cin>>it,mp[it]++;
    int ans=0;
    for(auto it:a){
        mp[it]--;
        for(ll f=1;f*f<=it;f++){
            if(it%f==0){
                if(mp[f]||mp[it/f]) goto next;
            }
        }
        ans++;
next:;
        mp[it]++;
    }

    cout<<ans;
    return 0;
}



Measured memory_bytes: 32532
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let (a,b) = {
        let t = read_vec::<usize>();
        (t[0],t[1])
    };
    if b % a == 0 {
        println!("{}",a+b);
    }else {
        println!("{}",b-a);
    }
}

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

int main(){
  int N, Y; cin >> N >> Y;
  Y /= 1000;
  for(int x = 0; x <= N; x++){
    for(int y = 0; y <= N - x; y++){
      if(x * 10 + y * 5 + N - x - y == Y){
        cout << x << ' ' << y << ' ' << N - x - y << endl;
        return 0;
      }
    }
  }
  cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

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

signed main(){
  int W,H,N;
  cin>>W>>H>>N;
  int XH=W,YH=H,XL=0,YL=0;
  rep(i,N){
    int X,Y,A;
    cin>>X>>Y>>A;
    if(A==1){
      if(XL<=X)XL=X;
    }
    if(A==2){
      if(XH>=X)XH=X;
    }
    if(A==3){
      if(YL<=Y)YL=Y;
    }
    if(A==4){
      if(YH>=Y)YH=Y;
    }
  }
  int ans=(XH-XL)*(YH-YL);
  if(XH-XL<0&&YH-YL<0)ans=0;
  if(ans<0)ans=0;
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N;
  cin>>N;
  vector<int>h(N);
  for(int i=0;i<N;i++)cin>>h[i];

  int ans=0;
  while(true){
    bool ok=true;
    for(auto it:h)if(it>0)ok=false;
    if(ok)break;

    int c=0;
    for(int i=0;i<N;i++){
      bool f=false;
      if(i==0)f=true;
      if(h[i]<=0){
        while(i+1<N&&h[i+1]<=0)i++;
        if(!f&&i!=N-1)c++;
      }
    }
    for(int i=0;i<N;i++)h[i]--;
    ans+=c+1;
  }

  cout<<ans<<endl;

  return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
using namespace std;

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

//Appropriately Changed
using edge=struct{int to,cost;};
using G=vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph,int from,int to,int cost){ 
	graph[from].push_back({to,cost});
}

struct Union_find{
	Union_find(int n){
		par.resize(n),iota(_all(par),0);
		idx.resize(n),iota(_all(idx),0);
		semi.assign(n,-1);
	}

	int find(int x){
		if(par[x]==x) return x;
		int r=find(par[x]);
		if(semi[idx[x]]>semi[idx[par[x]]]) idx[x]=idx[par[x]];
		return par[x]=r;
	}

	void link(int a,int b){par[b]=a;}
	int eval(int x){find(x);return idx[x];}

	vector<int> par,idx,semi;
};

auto dominator_tree(G &graph,int root){
	const int n=graph.size();

	G rgraph(n);
	rep(v,n) for(auto &e:graph[v]) add_edge(rgraph,e.to,v,e.cost);

	Union_find uf(n);
	
	vector<int> id(n,-1),par(n),u(n,-1);
	int total=0;

	auto dfs=[&](int v,int p){
        auto func=[&](int v,int p,auto func)->void{
			uf.semi[v]=total,id[total++]=v,par[v]=p;
			for(auto &e:graph[v]){
				if(uf.semi[e.to]>=0) continue;
				func(e.to,v,func);
			}
		};
        return func(v,p,func);
    };

	dfs(root,-1);
	vector<vector<int>> bucket(n);

	rrep(i,n,1){
		int v=id[i];
		for(auto &e:rgraph[v]){
			int u=uf.eval(e.to);
			chmin(uf.semi[v],uf.semi[u]);
		}

		bucket[id[uf.semi[v]]].push_back(v);

		for(auto &nv:bucket[par[v]]) u[nv]=uf.eval(nv);
		bucket[par[v]].clear();
		uf.link(par[v],v);					
	}
	
	vector<int> idom(n,0);

	rep(i,1,n){
		int v=id[i],w=u[v];
		idom[v]=(uf.semi[v]==uf.semi[w])?uf.semi[v]:idom[w];
	}

	rep(i,1,n){
		int v=id[i];
		idom[v]=id[idom[v]];
	}

	idom[root]=-1;
	return idom;
}

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

	G graph(n);

	rep(i,m){
		int s,t;
		cin >> s >> t;
		add_edge(graph,s-1,t-1,0);
	}

	auto idom=dominator_tree(graph,0);

	int q;
	cin >> q;
	rep(loop,q){
		int v;
		cin >> v,v--;
		int ans=v;
		if(idom[v]!=0) ans=idom[v];
		cout << ans+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 24440
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(D)]
ld=[0]*26
ans=0
for i in range(D):
    v=int(input())-1
    ans+=s[i][v]
    ld[v]=i+1
    for j in range(26):
        ans-=(i+1-ld[j])*c[j]
    print(ans)

Measured memory_bytes: 9396
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

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


long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

ll a[MAXN];
ll positive[MAXN];
ll pref[MAXN];


int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    ll n = readInt(), k = readInt() - 1;
    for (int i = 1; i <= n; i++) {
    	a[i] = readInt(); 
    	pref[i] = pref[i - 1] + a[i];
    	positive[i] = positive[i - 1] + (a[i] > 0) * a[i];  
    }
    ll mx = 0;
    for (int i = 1; i <= n - k; i++) {
		ll l = i;
		ll r = i + k;
		ll ans = positive[l - 1] + (positive[n] - positive[r]);
		mx = max(mx, max(ans, ans + pref[r] - pref[l - 1]));		
    }
	cout << mx;  	
    return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
	int n;
	while(cin >> n && n != -1){
		double x, y, r = 1, R = 1, rad = 0;
		if(n > 0){
			for (int i = 1; i < n; ++i)
			{
				R = sqrt(r * r + 1);
				rad += acos(r / R);
				r = R;
			}
		}
		x = R * cos(rad);
		y = R * sin(rad);
		cout << x << endl;
		cout << y << endl;
	}
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    long double a, b, c;
    cin >> a >> b >> c;

    if(a + b + 2 * sqrtl((long double)a * (long double) b) < c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    /*
    long double tmp_a = sqrtl((long double)a);
    long double tmp_b = sqrtl((long double)b);
    long double tmp_c = sqrtl((long double)c);
    */

    /*
    if(sqrtl((long double)c) - sqrtl((long double)a) - sqrtl((long double)b) > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    */

    /*
    if(a + b + (2 * sqrt(a*b)) < c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    */

    
    /*
    double tmp_a = sqrt(a);
    double tmp_b = sqrt(b);
    double tmp_c = sqrt(c);
    
    cout << tmp_a << endl;
    cout << tmp_b << endl;
    cout << tmp_c << endl;
    
    if(tmp_a + tmp_b < tmp_c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    double x = 1000000000 * 1000000000;
    cout << x << endl;
    */
    

}

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

int main() {
	/*入力*/
	int N,Max=0;
	cin >> N;
	int A[2][N];
	for(int i=0;i<N;i++)cin >> A[0][i];
	for(int i=0;i<N;i++)cin >> A[1][i];
	
	/*最大値全探索*/
	for(int i=0;i<N;i++){
		int Sum=0;
		for(int j=0;j<=i;j++)Sum+=A[0][j];
		for(int k=i;k<N;k++)Sum+=A[1][k];
		if(Sum>Max)Max=Sum;
	}
	cout << Max << endl;
	return 0;
}

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

int n,m;
pair<int,int> sum[101];

int main(){
	while(cin >> n >> m, n != 0){
		for(int i = 0; i < m; i++){
			sum[i].first = 0;
			sum[i].second = m-i;
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				int t;
				cin >> t;
				sum[j].first += t;
			}
		}
		sort(sum,sum+m,greater<pair<int,int> >());
		for(int i = 0; i < m; i++){
			if(i != 0){
				cout << " ";
			}
			cout << m - sum[i].second + 1;
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 2988
import numpy as np
N,M = map(int,input().split())
min_num,max_num = 0,10**6
for i in range(M):
  n_i,n_j = map(int,input().split())
  min_num = n_i if n_i > min_num else min_num
  max_num = n_j if n_j < max_num else max_num

if max_num - min_num < 0:
  print(0)
else:
  print(max_num - min_num +1)

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

#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end());
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct Setup {
    static constexpr int PREC = 20;
    Setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
string S;
signed main() {
    cin >> N >> S;
    int ans = 1;
    for (int i = 1; i < S.length(); i++) { ans += S[i - 1] != S[i]; }
    cout << ans << endl;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskD   {
public void solve(int testNumber, Scanner in, PrintWriter out) {
        int H = in.nextInt();
        int W = in.nextInt();
        int K = in.nextInt();
        int m = 1_000_000_007;
        if (W == 1){
            if(K==1) out.println(1);
            else out.println(0);
        }
        else {
            long dp[][] = new long[H][W];
            int lex[] = new int[W - 1];
            int all = 0;
            for (int i = 0; i < Math.pow(2, W - 1); i++) {
                StringBuilder st = new StringBuilder();
                String num = Integer.toBinaryString(i);
                for (int j = 1; j <= W - 1 - num.length(); j++) {
                    st.append(0);
                }
                st.append(num);
                if (st.toString().contains("11")) continue;
                all++;
                for (int idx = 0; idx <= W - 2; idx++) {
                    if (st.charAt(idx) - '0' == 1) {
                        lex[idx]++;
                    }
                }
            }
            dp[0][0] = all - lex[0];
            dp[0][1] = lex[0];
            for (int ih = 1; ih <= H - 1; ih++) {
                dp[ih][0] = (dp[ih][0] + dp[ih - 1][0] * (all - lex[0])) % m;
                dp[ih][0] = (dp[ih][0] + dp[ih - 1][1] * lex[0]) % m;
                for (int iw = 1; iw <= W - 2; iw++) {
                    dp[ih][iw] = (dp[ih][iw] + dp[ih - 1][iw] * (all - lex[iw - 1] - lex[iw])) % m;
                    dp[ih][iw] = (dp[ih][iw] + dp[ih - 1][iw - 1] * lex[iw - 1]) % m;
                    dp[ih][iw] = (dp[ih][iw] + dp[ih - 1][iw + 1] * lex[iw]) % m;
                }
                dp[ih][W - 1] = (dp[ih][W - 1] + dp[ih - 1][W - 1] * (all - lex[W - 2])) % m;
                dp[ih][W - 1] = (dp[ih][W - 1] + dp[ih - 1][W - 2] * lex[W - 2]) % m;
            }
            out.println(dp[H - 1][K - 1]);
        }
    }

}
}



Measured memory_bytes: 21332
x = int(input())

a = x//1000
b = (x%1000)//100
c = ((x%1000)%100)//10
d = ((x%1000)%100)%10
     
if a + b + c + d == 7:
  print("{}+{}+{}+{}=7".format(a,b,c,d))
elif a - b + c + d == 7:
  print("{}-{}+{}+{}=7".format(a,b,c,d))
elif a + b - c + d == 7:
  print("{}+{}-{}+{}=7".format(a,b,c,d))
elif a + b + c - d == 7:
  print("{}+{}+{}-{}=7".format(a,b,c,d))
elif a - b - c + d == 7:
  print("{}-{}-{}+{}=7".format(a,b,c,d))
elif a - b + c - d == 7:
  print("{}-{}+{}-{}=7".format(a,b,c,d))
elif a + b - c - d == 7:
  print("{}+{}-{}-{}=7".format(a,b,c,d))
elif a - b - c - d == 7:
  print("{}-{}-{}-{}=7".format(a,b,c,d))

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	h, w := scanInt(), scanInt()

	var wr = bufio.NewWriter(os.Stdout)
	wr.WriteString(strings.Repeat("#", w+2) + "\n")
	for i := 0; i < h; i++ {
		s := scanString()
		wr.WriteString("#" + s + "#" + "\n")
	}
	wr.WriteString(strings.Repeat("#", w+2) + "\n")
	wr.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i += 2)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i += 2)
int main() {
  string A;
  cin >> A;
  int N = A.size();
  string ans;
  rep(i, N) {
    ans.push_back(A.at(i));
  }
  cout << ans << endl;
}


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

int main() {
	int n,i,j,k;
	cin>>n;
	int a[n];
	int b[n];
	int c[n];
	vector<vector<int>>dp(n,vector<int>(3,0));
	for(i=0;i<n;i++)
	{
	    cin>>a[i]>>b[i]>>c[i];
	}
	for(i=0;i<n;i++)
	{
	    for(j=0;j<3;j++)
	    {
	        if(i==0)
	        {
	            if(j==0)
	                dp[i][j]=a[0];
	           if(j==1)
	                dp[i][j]=b[0];
	           if(j==2)
	                dp[i][j]=c[0];
	        }
	        else
	        {
	            for(k=0;k<3;k++)
	            {
	                if(j==k)
	                continue;
	                if(j==0)
	                {
	                    dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i]);
	                }
	                else if(j==1)
	                {
	                    dp[i][j]=max(dp[i][j],dp[i-1][k]+b[i]);
	                }
	                else
	                {
	                    dp[i][j]=max(dp[i][j],dp[i-1][k]+c[i]);
	                }
	              }
	              //cout<<dp[i][j]<<" ";
	        }
	    }
	}
	        int ret=0;
	        ret=max(ret,dp[n-1][0]);
	        ret=max(ret,dp[n-1][1]);
	        ret=max(ret,dp[n-1][2]);
	        cout<<ret<<endl;
}


Measured memory_bytes: 9836
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)

int main (){
	/* n , k < 10^5
	  n以下の整数3つの組み合わせで任意の2つをとったときにKの倍数になっている→
	  2(a+b+c)がKの倍数になってて、kが奇数のときには、
	  a+b+cはkの倍数で、その2つの組み合わせがkの倍数だから、すべてkの倍数であるはず。
	  kが偶数の場合、a+b+cはk/2の倍数。
	  すべてが a%k = k/2を満たすか、
	  すべてが a%k = 0
	  を満たさないとだめ？

	  n以下のkの倍数をリストアップ、
	  kが偶数であれば、k/2を加えたリストも作成。
	  今、kが奇数なら、組み合わせはkの倍数の数^3になる？　→これは正しそう
	  kが偶数の時を考える。まずは、同様にしてkの倍数^3はこれを満たす、
	  更にk/2のリストからとっても良いので、これの^3を足せば良さそう
	*/
	long NN, KK;
	long length = 0;
	long length2 = 0;
	long ans = 0;
	cin >> NN >> KK;
	// KKのほうがでかいとき、2合わせて2KKになることはない。
	if (KK > NN){
		if(KK%2==0 && NN*2>= KK){
			cout << 1 << endl;
		}
		else {
			cout << 0 << endl;
		}
		return 0;
	}

	// NNの方が大きかった場合
	if(KK % 2 == 1){
		length = (NN-NN%KK)/KK;
		ans = length * length * length;
	}else {
		length = (NN-NN%KK)/KK;
		length2 = (NN-NN%(KK/2))/(KK/2) - length ;
		ans = length * length * length + length2 * length2 * length2;
	}
	cout  << ans << endl;
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    REP(i, n) cin >> a[i], b[a[i]]++;

    ll ma = 0;
    REP(i, n) chmax(ma, a[i]);

    bool flag = true;
    if(ma%2==0) {
        // ma/2未満 → 0個
        REP(i, ma/2) if(b[i] != 0) flag = false;
        // ma/2 → 1個
        if(b[ma/2] != 1) flag = false;
        // ma/2より大きい → 2個以上
        FOR(i, ma/2+1, ma+1) if(b[i] < 2) flag = false;
    } else {
        // ma/2以下 → 0個
        REP(i, ma/2+1) if(b[i] != 0) flag = false;
        // ma/2+1 → 2個
        if(b[ma/2+1] != 2) flag = false;
        // ma以下 → 2個以上
        FOR(i, ma/2+1, ma+1) if(b[i] < 2) flag = false;
    }

    if(flag) cout << "Possible\n";
    else cout << "Impossible\n"; 

    return 0;
}

Measured memory_bytes: 256
_n, m = gets.chomp.split.map(&:to_i)
demands = m.times.map do
  gets.chomp.split.map(&:to_i)
end.sort_by{|d| [d[0],d[1]]}

cnt = 0
max = demands[0][1]
(demands.size - 1).times do |i|
  if max <= demands[i + 1][0]
    cnt += 1
    max = Float::INFINITY
  end

  max = [max, demands[i + 1][1]].min
end

puts(cnt + 1)

Measured memory_bytes: 26356
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a.size())
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for(i=a;i<b;i++)
const ll L = 1e6+1;
vector<ll> ad[L];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll i,j,k,n,t;
	ad[1].pb(1);
	for(i=2;i<L;i++)
	{
		for(j=i;j<L;j+=i)
			ad[j].pb(i);
	}
	cin>>n;
	vector<ll> v(n);
	for(i=0;i<n;i++)
		cin>>v[i];

	ll done[L]={0};
	for(i=0;i<n;i++)
		for(j=0;j<sz(ad[v[i]]);j++)
			done[ad[v[i]][j]]++;
		
	ll cnt = 0;
	for(i=2;i<L;i++)
		cnt += (ll)(done[i]>1);
	if(cnt==0)
		cout<<"pairwise coprime"<<endl;
	else
	{
		ll gcd = 0;
		for(i=0;i<n;i++)
			gcd = __gcd(gcd, v[i]);
		if(gcd == 1)
			cout<<"setwise coprime"<<endl;
		else
			cout<<"not coprime"<<endl;
	}
	return 0;
}

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

int main() {
  string s,t;cin>>s>>t;
  int ans = t.size();
  rep(i, s.size()-t.size()+1) {
    int cnt=0;
    rep(j, t.size()) {
      if (s[i+j]!=t[j]) cnt++;
    }
    ans = min(ans, cnt);
  }
  cout<<ans;
}


Measured memory_bytes: 3628
#単一始点最短経路問題
#負の辺があっても動作する

#最短経路を求める
#計算量O(N * M)

INF = 10 ** 15
#入力
# N = int(input()) #頂点の数
# M = int(input()) #辺の数
N, M, P = map(int, input().split())

# 入力は1-index
# 内部で0-indexにして処理
G = []
for _ in range(M): #M個の辺の情報を受け取る
    l, r, s = map(int, input().split()) #lからrへ重みsの辺が存在
    G += [[l-1, r-1, -(s-P)]] #有向グラフのときはここだけ
    # G += [[r-1, l-1, s]] #無向グラフのときはこの行も必要


#メイン文
d = [0] * N #最短距離を記録しておくリスト
# prev = [-1] * N
def shortest_path(s): #S番目の頂点から各頂点への最短距離を求める
    s -= 1
    for i in range(N):
        d[i] = INF
    d[s] = 0
    count = 0
    while True:
        count += 1
        update = False
        for i in range(M): #無向グラフのときは辺は実質的には2倍
            e = G[i]
            if d[e[0]] != INF and d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                update = True
                # prev[e[1]] = e[0]
        if not update: #更新が終わったとき
            return True
        if count == N - 1: #永遠に更新が起きているとき
            tmp = d[N -1]
        if count == 2 * N:
            if d[N - 1] == tmp:
                return True #N-1の値が更新されていないとき
            else:
                return False #N + 2回目でもN - 1の値が小さくなっている-->得点が無限に大きくなる

#呼び出しスタート地点を入れる
if not shortest_path(1):
    print (-1)
    # print (d)
    exit()
# print (d)

print (max(0, -d[N - 1]))

Measured memory_bytes: 48088
n = int(input())
h = list(map(int,input().split()))

answer = "Yes"
for i in range(n-2,-1,-1):
    if h[i] > h[i+1] + 1:
        answer = "No"
        break
    elif h[i] == h[i+1] +1:
        h[i] -= 1

print(answer)

Measured memory_bytes: 14396
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define MaxN 1010
using namespace std;

int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        if(a==0&&b==0) break;
        if((a*b)&1) printf("no\n");
        else printf("yes\n");
    }
}

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

void solve(){

    string value ;
    string output;

    cin>>value;
    int len = value.length();

    for(int i=0 ;i<len;i++){
        if(value.at(i) == '0'){
            output.push_back('0');
        }else if(value.at(i) == '1'){
            output.push_back('1');
        }else if(value.at(i) == 'B' && !output.empty()){
            output.pop_back();
        }
    }
    cout<<output<<endl;

}

int main()
{
    int TestCases=1;
    while(TestCases >0){
        solve();
        TestCases--;
    }

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

struct UnionFind{
  vector<int> v;
  UnionFind(int n) : v(n, -1) {}
  void init(){ for(int i = 0;i < (int)v.size();i++)v[i]=-1; }
  int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (-v[x] < -v[y]) swap(x, y);
    v[x] += v[y]; v[y] = x;
    return true;
  }
  bool root(int x) { return v[x] < 0; }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -v[find(x)]; }
};

ll n,m;
ll x[100010],y[100010],z[100010];
bool used[100010];

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

  cin>>n>>m;
  UnionFind uf(n);
  rep(i,m){
    cin>>x[i]>>y[i]>>z[i];
    x[i]--; y[i]--;
    uf.unite(x[i],y[i]);
    z[i]%=2;
  }

  ll res=0;
  rep(i,n){
    if(used[uf.find(i)])continue;
    used[uf.find(i)]=true;
    res++;
  }
  cout<<res<<endl;

  return 0;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans =0;
    for(int i=0; i<n-2; ++i){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            ans +=1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int sosu(int);
int main(){
    int a,b,c=0,n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        b=sosu(a);
        if(b==0){
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}

int sosu(int p){
    int i=3;
    if(p==2){
        return 0;
    }
    if(p<2||p%2==0){
        return 1;
    }
    while(i*i<=p){
        if(p%i==0){
            return 1;
        }
        i+=2;
    }
    return 0;
}

Measured memory_bytes: 3092
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {

	int n;
	cin >> n;
	vector<pair<int, int>>a(n), c(n);
	rep(i, n) cin >> a[i].first >> a[i].second;
	rep(i, n)cin >> c[i].first >> c[i].second;

	sort(all(c));
	sort(all(a), [](pair<int, int>a, pair<int, int>b)->bool {return a.second > b.second; });
	int cnt = 0;
	rep(i, n) {
		int cc = c[i].first;
		int d = c[i].second;
		rep(j, n) {
			int &aa = a[j].first;
			int &b = a[j].second;
			if (aa < cc&&b < d) {
				cnt++;
				aa = INT32_MAX;
				b = INT32_MAX;
				break;
			}
		}
	}


	cout << cnt;

	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,i;
    cin >> n;
    vector <int>b(n-1);
    for(i=0;i<n-1;i++) cin>>b[i];
    int ans = b[0];
    for(i=0;i<n-2;i++){
        ans += min(b[i],b[i+1]);
    }
    cout << ans+b[n-2] << endl;
}

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
    llin(n);
    stin(s);
    ll t=0;
    ll k=0;
    FOR(i,1,n-1){
        t=0;
        FOR(j,0,n-1-i){
            if(s[j]==s[j+i]){
                t++;
                k=max(k,min(t,i));
            }else{
                t=0;
            }
        }
    }
    sal(k)
}


Measured memory_bytes: 256
from sys import stdin


def main():
    n, k = map(int, stdin.readline().split())
    ab = [list(map(int, stdin.readline().split())) for _ in range(n)]
    ab.sort(key=lambda x: x[0])
    count = 0
    for a, b in ab:
        if count + b < k:
            count += b
        else:
            print(a)
            exit()


if __name__ == "__main__":
    main()


Measured memory_bytes: 29056
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int INF = 1e9;
const int MOD = 998244353;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, did[202][202];
ll X[202], Y[202], p2[202];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N) cin>>X[i]>>Y[i];
    
    ll ret=1;
    p2[0]=1;
    rep(i,N) p2[i+1]=p2[i]*2%MOD;
    
    ret=(p2[N]+MOD-1-N-N*(N-1)/2)%MOD;
    rep(y,N)rep(x,y) if(did[y][x]==0){
        vector<int> V;
        V.push_back(x);
        V.push_back(y);
        rep(i,N) if(i!=x&&i!=y) if((X[i]-X[x])*(Y[y]-Y[x])-(X[y]-X[x])*(Y[i]-Y[x])==0) V.push_back(i);
        for(auto& a:V) for(auto& b:V) did[a][b]=1;
        int r=V.size();
        if(r>=3) ret=(ret+MOD-p2[r]+r+r*(r-1)/2+1)%MOD;
    }
    cout1((ret%MOD+MOD)%MOD);
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int n ;
int arr[MAX] ;

string s ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	cin>>s ;
	int rem = count(s.begin() , s.end() , 'R') ;
	int cnt = 0 ;
	int ans = rem ;
	for(int i = 0 ; i < n ; ++i)
	{
		if(s[i] == 'R')
			cnt++ , rem-- ;
		int x = i+1 - cnt ;
		ans = min(ans , x + max(0 , rem-x)) ;
	}
	return cout<<ans<<"\n" , 0 ;
}

Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n, m, q;
    cin >> n >> m >> q;
    vi qs(q);
    forn(i, q) cin >> qs[i];
    reverse(all(qs));
    vi vis(m), pos(m);
    vi pref;
    for (int x: qs) {
        --x;
        if (!vis[x]) pos[x] = pref.size(), pref.pb(x);
        ++vis[x];
        uin(vis[x], n);
        if (pos[x]) uin(vis[x], vis[pref[pos[x] - 1]]);
    }
    forn(i, m) if (!vis[i]) pref.pb(i);
    vi got;
    forn(i, pref.size()) if (vis[pref[i]] == n) got.pb(pref[i]);
    forn(i, m) if (vis[i] < n) got.pb(i);
    cout << (got == pref ? "Yes" : "No") << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 2552
#include <stdio.h>

int main() {
    int a, b, c; scanf("%d%d%d", &a, &b, &c);
    long long k; scanf("%lld", &k);

    if(k & 1) printf("%d\n", b - a);
    else printf("%d\n", a - b);
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    private const long INF = 1000000007;
    private struct Pair { public long x, y; public Pair(long xx, long yy) { x = xx; y = yy; } }
    public static void Main()
    {
        int A = NextInt();
        int P = NextInt();
        P += A * 3;
        Console.WriteLine(P / 2);
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
sx,sy,tx,ty = map(int,input().split())
x=tx-sx
y=ty-sy
ans=[]#"" for i in range(4*x+4*y+8)
for i in range(y):
    ans+=["U"]
for i in range(x):
    ans+=["R"]
for i in range(y):
    ans+=["D"]
for i in range(x+1):
    ans+=["L"]
for i in range(y+1):
    ans+=["U"]
for i in range(x+1):
    ans+=["R"]
ans+=["D","R"]
for i in range(y+1):
    ans+=["D"]
for i in range(x+1):
    ans+=["L"]
ans+=["U"]
print(''.join(ans))




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

int main(){
  string S,T;cin >> S >> T;
  int cnt = 0;
  for(int i=0;i<S.size();i++){
    if(S[i]!=T[i]){
      cnt ++;
    }
  }
  cout << cnt << endl;
}

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

int main(void){
  int N;
  cin >> N;
  vector<int> data(N);
  for (int i=0; i<N;i++){
    cin >> data[i];
  }
  vector<int> left_gcd(N);
  vector<int> right_gcd(N);
  left_gcd[0] = data[0];
  right_gcd[N-1] = data[N-1];
  for(int i=1; i<N-1;i++){
    left_gcd[i] = __gcd(left_gcd[i-1], data[i]); 
    right_gcd[N-1-i] = __gcd(right_gcd[N-i], data[N-1-i]);
  }
  int max=right_gcd[1];
  for (int i=1;i<N-1;i++){
    int a = __gcd(left_gcd[i-1], right_gcd[i+1]);
  	if (max<a) max =a;
  }
  if (left_gcd[N-2] > max) max = left_gcd[N-2];
  cout << max;
  return 0;

}

Measured memory_bytes: 1408
object Main {
  import java.util.Scanner

  implicit class RichScanner(sc: Scanner) {
    def readStrings(n: Int): Array[String] = Array.fill(n) { sc.next() }
    def readInts(n: Int): Array[Int] = Array.fill(n) { sc.nextInt() }
    def readLongs(n: Int): Array[Long] = Array.fill(n) { sc.nextLong() }
    def readLineStrings: Array[String] = sc.nextLine().split(' ')
    def readLineInts: Array[Int] = readLineStrings.map(_.toInt)
    def readLineLongs: Array[Long] = readLineStrings.map(_.toLong)
  }

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def solve(sc: Scanner): Unit = {
    val N = sc.readLineInts
    val s = sc.nextLine()
    if (s.count(_ == 'R') > s.count(_ == 'B')) {
      println("Yes")
    } else {
      println("No")
    }
  }
}


Measured memory_bytes: 25680
import collections
import math

def combinations_count2(n):
    return n*(n-1) // 2

N = int(input())
A = list(map(int, input().split()))

c = collections.Counter(A)
#print(c)

d = {}
csum = 0
for i,j in c.items():
    if j == 1:
        d[i] = 0
        csum += 0
    else:
        d[i] =  combinations_count2(j)
        csum += d[i]

#print(c)
#print(d)
#print(csum)

#print(A)
for i in A:
    #print(c[i], i)
    if c[i] == 1:
        print(csum)
    elif c[i] == 2:
        print(csum-1)
    else:
        print(csum - combinations_count2(c[i]) + combinations_count2(c[i]-1))


Measured memory_bytes: 32028
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int k;
  vector<int> v(5);
  for (int i=0; i<5;i++) cin >> v.at(i);
  cin >> k;
  for (int j=0; j<5; j++){
    for (int m=j+1; m<5;m++){
      if (v.at(m)-v.at(j) > k) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
    cout << "Yay!" << endl;
    return 0;
}
    
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.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())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


int n;
vector<ll> lis;
vector<ll> p;
vector<vector<int>> g(202020);

void dfs(int x, vector<int> &ans){
  int z=lb(lis,p[x]);
  ll memo=lis[z];
  lis[z]=p[x];

  ans[x]=lb(lis,INF);

  for(auto nx : g[x]){
    if(ans[nx]!=-1) continue;
    dfs(nx,ans);
  }

  lis[z]=memo;
}


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

  cin>>n;

  rep(i,n){
    int x;
    cin>>x;
    p.pb(x);
  }

  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  rep(i,n) lis.pb(INF);
  vector<int> ans(n,-1);

  dfs(0,ans);

  rep(i,n){
    cout << ans[i] << endl;
  }

}


Measured memory_bytes: 26772
package main

import (
	"fmt"
)

const minf = -int(1e18 - 1)

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}

	// dp[i][j][k]: iまで見てjはiを使ったとき,k個残る最大値
	dp := make([][]map[int]int, n)
	for i := range dp {
		dp[i] = make([]map[int]int, 2)
		for j := range dp[i] {
			dp[i][j] = make(map[int]int)
		}
	}

	mk := int(n / 2)

	dp[0][0][mk] = 0
	dp[0][1][mk-1] = as[0]
	for i := 1; i < n; i++ {
		nmx := int((n - i) / 2)
		for k := range dp[i-1][0] {
			if k >= 0 {
				if k >= 1 {
					dp[i][1][k-1] = dp[i-1][0][k] + as[i]
				}
				if k <= nmx {
					if m, ok := dp[i-1][1][k]; ok {
						dp[i][0][k] = max(dp[i-1][0][k], m)
					} else {
						dp[i][0][k] = dp[i-1][0][k]
					}
				}
			}
		}
		for k := range dp[i-1][1] {
			if k-1 <= nmx {
				m2 := dp[i-1][1][k]
				if m, ok := dp[i-1][0][k]; ok {
					m2 = max(m2, m)
				}
				if m, ok := dp[i][0][k]; ok {
					dp[i][0][k] = max(m, m2)
				} else {
					dp[i][0][k] = m2
				}
			}
		}
	}

	fmt.Println(max(dp[n-1][0][0], dp[n-1][1][0]))
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 118712