akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	int A = S[0] - '0';
	int B = S[1] - '0';
	int C = S[2] - '0';
	int D = S[3] - '0';

	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			for (int k = 0; k < 2; k++)
			{
				int op1 = (i == 0) ? 1 : -1;
				int op2 = (j == 0) ? 1 : -1;
				int op3 = (k == 0) ? 1 : -1;

				int result = A + op1 * B + op2 * C + op3 * D;
				if (result == 7)
				{
					char cop1 = (i == 0) ? '+' : '-';
					char cop2 = (j == 0) ? '+' : '-';
					char cop3 = (k == 0) ? '+' : '-';

					cout << A << cop1 << B << cop2 << C << cop3 << D << "=7";

					return 0;
				}
			}
		}
	}

	return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

int main() {
    ll ans;
    int n;
    ll r = 0, g = 0, b = 0;
    string s;
    cin >> n >> s;

    REP(i, s.size()) {
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;
    }

    ans = r * g * b;

    REP(i, s.size()) REP(j, s.size()) {
        r = 0, g = 0, b = 0;
        if(i >= j) continue;
        int k = 2 * j - i;
        if(s.size() <= k) continue;
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;
        if(s[j] == 'R') r++;
        else if(s[j] == 'G') g++;
        else b++;
        if(s[k] == 'R') r++;
        else if(s[k] == 'G') g++;
        else b++;
        if(r == 1 && g == 1 && b == 1) {
            ans--;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <deque>
#include <array>
#include <cmath>

using namespace std;

int main()
{
  long long x;

  cin >> x;

  int res = 0;

  res += x / 500 * 1000;
  res += x % 500 / 5 * 5;

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int r[][6] ={
	{1, 2, 3, 0, 4, 5},
	{5, 1, 4, 3, 0, 2},
	{0, 4, 2, 5, 3, 1}
};
vector<vector<string> >in;
void rot(int it, vector<string> &f){
	while(it--){
		vector<string> nx(3, string("..."));
		rep(i, 3) rep(j, 3) nx[i][j] = f[2 - j][i];
		swap(nx, f);
	}
}
vector<vector<string> > rot(int d, const vector<vector<string> > &in){
	vector<vector<string> > res;
	rep(i, 6) res.pb(in[r[d][i]]);
	if(d == 0){
		rot(1, res[4]); rot(3, res[5]);
	}
	if(d == 1){
		rot(1, res[1]); rot(3, res[3]); rot(2, res[5]); rot(2, res[2]);
	}
	if(d == 2){
		rot(1, res[0]); rot(3, res[2]); rot(1, res[1]); rot(1, res[4]); rot(1, res[3]); rot(1, res[5]);
	}
	return res;
}

int main(){
	in = vector<vector<string> >(6, vector<string>(3, "..."));
	while(1){
		rep(i, 6) rep(j, 3){
			cin >> in[i][j];
			if(in[i][j] == "#") exit(0);
		}
		
		set<vector<vector<string> > > s;
		queue<pair<int, vector<vector<string> > > > q;
		q.push(mp(0, in));
		while(!q.empty()){
			in = q.front().second;
			int c = q.front().first; q.pop();
			if(s.count(in)) continue;
			s.insert(in);
			
			bool ok1 = 0, ok2 = 0;
			rep(i, 3){
				ok1 |= in[0][2][i] == '*';
				ok2 |= in[2][2][i] == '*';
			}
			if(ok1 && ok2){
				cout << c << endl;
				goto END;
			}
			
			for(int d = 1; d < 3; d++) rep(it, 4){
				in = rot(d, in);
				if(it == 0 || it == 2) q.push(mp(c + 1, in));
			}
		}
		cout << -1 << endl;
		END:;
	}
	return 0;
}

Measured memory_bytes: 1300
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

const int N=200005;

int n,a[N],f[N];

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=n;i>=1;i--) f[a[i]]=f[a[i]+1]+1;
	int ans=n;
	for (int i=0;i<=n;i++) ans=std::min(ans,i+n-i-f[i+1]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？


s=ss()
t=ss()

if s==t[:-1]:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 72508
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	ios_base::sync_with_stdio(0);
  	cin.tie(NULL); 

  	int n;
  	cin >> n;
  	vector<bool> a(n+1);
  	a[0] = true;
  	int r, cnt = 0;
  	for(int i = 0; i < n; i++) {
  		cin >> r;
  		if(!a[r] and a[r-1]) {
  			cnt++;
  			a[r] = true;
  		}
  	}
  	if(!a[1]) cout << -1 << '\n';
  	else cout << n - cnt << '\n';

  	return 0;
}

Measured memory_bytes: 256
s = input()[::-1]
d = 1
num = 0
ans = 0
mod_list = [0] * 2019
mod_list[0] = 1

for char in s:
    num += int(char) * d
    mod_list[num % 2019] += 1
    d *= 10
    d %= 2019

for i in range(2019):
    ans += mod_list[i] * (mod_list[i] - 1) //2

print(ans)


Measured memory_bytes: 9212
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
mx = max(A)+1
B = [0]*(mx)
dic = defaultdict(int)
for a in A:
  dic[a] += 1

A = sorted(list(set(A)))
ans = 0
for a in A:
  if B[a] == 0:
    if dic[a] == 1:
      ans += 1
  for i in range(a, mx, a):
    B[i] += 1

print(ans)

Measured memory_bytes: 168168
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

map <string, int> votes;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    int n, max = 0;
    cin >> n;
    
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        
        ++votes[s];
        
        if (votes[s] > max) 
            max = votes[s];
    }
    
    map <string, int> :: iterator it;
    for (it = votes.begin(); it != votes.end(); it++)
    {
        if (it->second == max)
            cout << it->first << endl;
    }
    return 0;
}

Measured memory_bytes: 19208
#include <iostream>
#include <utility>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stdlib.h>
#define llint long long
#define mod 998244353
#define eps 1e-8
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint n, m;
vector<llint> G[200005], revG[200005];
vector<llint> g[200005];
int x[200005], y[200005], z[200005];
vector<llint> vec[200005];
P cand[200005][8];
llint ans[200005];

vector<int> topo;
bool used[200005];
int scc[200005];

void tpsort(int v)
{
	used[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(!used[G[v][i]]) tpsort(G[v][i]);
	}
	topo.push_back(v);
}
void sccdfs(int v, int id)
{
	used[v] = true;
	scc[v] = id;
	for(int i = 0; i < revG[v].size(); i++){
		if(!used[revG[v][i]]) sccdfs(revG[v][i], id);
	}
}

llint dist(llint i, llint j)
{
	return abs(x[i]-x[j]) + abs(y[i]-y[j]) + abs(z[i]-z[j]);
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> x[i] >> y[i] >> z[i];
	}
	llint u, v;
	for(int i = 0; i < m; i++){
		cin >> u >> v;
		G[u].push_back(v);
		revG[v].push_back(u);
	}
	
	for(int i = 1; i <= n; i++) if(!used[i]) tpsort(i);
	reverse(topo.begin(), topo.end());
	
	int id = 0;
	for(int i = 1; i <= n; i++) used[i] = false;
	for(int i = 0; i < topo.size(); i++) if(!used[topo[i]]) sccdfs(topo[i], id++);
	for(int i = 1; i <= n; i++) vec[scc[i]].push_back(i);
	
	set<llint> S;
	for(int i = 0; i < id; i++){
		S.clear();
		for(int j = 0; j < vec[i].size(); j++){
			for(int k = 0; k < G[vec[i][j]].size(); k++){
				S.insert(scc[G[vec[i][j]][k]]);
			}
		}
		for(auto it = S.begin(); it != S.end(); it++){
			if(*it == i) continue;
			g[i].push_back(*it);
		}
	}
	
	/*for(int i = 0; i < id; i++){
		for(int j = 0; j < g[i].size(); j++){
			cout << g[i][j] << " ";
		}
		cout<< endl;
	}*/
	
	for(int k = id-1; k >= 0; k--){
		for(int i = 0; i < 8; i++) cand[k][i] = make_pair(-inf, -inf);
		for(int i = 0; i < 8; i++){
			for(llint j = 0; j < vec[k].size(); j++){
				llint v = vec[k][j];
				llint f = 0;
				if(i&1) f += x[v]; else f -= x[v];
				if(i&2) f += y[v]; else f -= y[v];
				if(i&4) f += z[v]; else f -= z[v];
				cand[k][i] = max(cand[k][i], make_pair(f, v));
			}
		}
	}
	
	for(int k = id-1; k >= 0; k--){
		for(int j = 0; j < g[k].size(); j++){
			int nk = g[k][j];
			for(int i = 0; i < 8; i++) cand[k][i] = max(cand[k][i], cand[nk][i]);
		}
		for(int i = 0; i < 8; i++){
			for(llint j = 0; j < vec[k].size(); j++){
				int v = vec[k][j];
				//cout << v << " " << cand[i].second << endl;
				ans[v] = max(ans[v], dist(v, cand[k][i].second));
			}
		}
	}
	
	for(int i = 1; i <= n; i++){
		cout << ans[i] << "\n";
	}
	flush(cout);
	
	return 0;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

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

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n, m; cin >> n >> m;
    vi c(m);
    rep(i,m) cin >> c[i];

    vi dp(n+1,INF);
    dp[0] = 0;
    rep(i,m) rep(j,n+1){
        if(j-c[i] >= 0)
            dp[j] = min(dp[j], dp[j-c[i]] + 1);
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3224
import math
a = []
ans = 0
for i in range(6):
  po = int(input())
  a.append(po)
m = 1000000000000000
for i in range(5):
  if a[i+1] < m:
    m = a[i+1]

delay = math.ceil(a[0]/m) -1
print(5+delay)

Measured memory_bytes: 3064
using System;

class Program
{
    static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');

        int[] ans = new int[3];
        ans[0] = int.Parse(str[0]);
        ans[1] = int.Parse(str[1]);
        ans[2] = int.Parse(str[2]);

        // Sort
        Array.Sort(ans);
        // Output
        Console.WriteLine("{0} {1} {2}", ans[0], ans[1], ans[2]);
    }
}

Measured memory_bytes: 9360
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
    int N,M,X,Y,xma,ymi;
    cin>>N>>M>>X>>Y;
    xma=-101;
    ymi=101;
    vector <int> x(N);
    vector <int> y(M);
    for(int i=0;i<N;i++){
        cin>>x[i];
        xma=max(x[i],xma);
    }
    for(int j=0;j<M;j++){
        cin>>y[j];
        ymi=min(y[j],ymi);
    }
   
    if((X<xma&&xma<ymi&&ymi<Y)||(xma<X&&X<Y&&Y<ymi)){
        cout<<"No War"<<endl;
    }
    else cout<<"War"<<endl;
    
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define int long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
map<int,int> f;
int n,sum,ans;
main()
{
	re(n);
	++f[0];
	for(int i=1,x;i<=n;++i)
	{
		re(x);
		sum+=x;
		ans+=f[sum];
		++f[sum];
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 12800
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int a[3];
int main() {
	string s, t;
	cin >> s >> t;
	rep(i, s.size()){
		rep(j, t.size()){
			if(s[(i+j)%s.size()] != t[j]) break;
			if(j == t.size() - 1){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
require 'pp'

n, k = gets.split.map(&:to_i)
d_k = gets.split.map(&:to_i)

memo = Array.new(10, 1)
d_k.each do |i|
    memo[i] = 0
end

n.upto(10 ** 5) do |i|
    digits = []
    tmp = i
    ok = true
    while tmp != 0
        x = tmp % 10
        if memo[x] == 0
            ok = false
            break
        end
        digits << x
        tmp /= 10
    end

    if ok
        puts digits.reverse.join
        break
    end
end


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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using Edge = pair<ll, ll>;

using Graph = vector<vector<Edge>>;

Graph G;
vector<int> color;

void dfs(int v, int p, int c) {
  color[v] = c;
  for (Edge next_v : G[v]) {
    if (next_v.first == p) continue;
    if (next_v.second % 2 == 1)
      dfs(next_v.first, v, 1 - c);
    else
      dfs(next_v.first, v, c);
  }
}

int main() {
  int N;
  cin >> N;
  G.resize(N);
  for (int i = 0; i < N-1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w));
  }

  color.assign(N, 0);
  dfs(0, -1, 1);

  for (int i = 0; i < N; i++) {
    cout << color[i] << endl;
  }
}


Measured memory_bytes: 10496
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

template <typename T> // T : type of cost
struct BellmanFord {
    T inf = numeric_limits<T>::max(); // initial value, reused when clear() is called
    int n;                            // number of nodes
    vector<T> dist;                   // distance from start node
    bool negativeLoop;
    struct edge {
        int from, to;
        T cost;
        edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
    };
    vector<edge> edges;

    BellmanFord(int n) : n(n), negativeLoop(false), dist(n, inf){};
    // 0-indexed!
    void addEdge(int from, int to, T cost) { edges.emplace_back(from, to, cost); }
    // calculate dist[i] as a shortest distance from start (to end)
    // end is used to check if there is "relevant" negative circuit
    // even if there is negative curcuit, it might not affect the path of interest
    void build(int start, int end = -1) {
        dist[start] = 0;
        for (int i = 0; i < 3 * n; ++i) {
            for (auto &e : edges) {
                if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) {
                    dist[e.to] = dist[e.from] + e.cost;
                    if (i >= 2 * n - 1 && (end == -1 || end == e.to)) {
                        negativeLoop = true;
                        break;
                    }
                }
            }
        }
    }
};

int main() {
    ll n, m, p;
    cin >> n >> m >> p;
    BellmanFord<ll> graph(n);
    vl a(m), b(m), c(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        graph.addEdge(a[i], b[i], p - c[i]);
    }
    graph.build(0, n - 1);
    if (graph.negativeLoop) {
        cout << -1 << "\n";
        return 0;
    }
    BellmanFord<ll> graph2(n);
    for (int i = 0; i < m; ++i) {
        graph2.addEdge(a[i], b[i], p - c[i]);
    }
    graph2.build(n - 1, n - 1);
    if (graph2.negativeLoop) {
        cout << -1 << "\n";
    } else {
        cout << max(0LL, -graph.dist[n - 1] - graph2.dist[n - 1]) << "\n";
    }
    return 0;
}

Measured memory_bytes: 768
h,w = map(int,input().split())
s = [input() for _ in range(h)]
u1 = [[0 for _ in range(w)] for _ in range(h)]
u2 = [[0 for _ in range(w)] for _ in range(h)]
d1 = {}
d2 = {}

idx = 1
cnt = 0
for i in range(h):
    flag = False
    for j in range(w):
        if s[i][j] == ".":
            flag = True
            u1[i][j] = idx
            cnt += 1
        elif flag:
            d1[idx] = cnt
            cnt = 0
            idx += 1
            flag = False  
    if flag:
        d1[idx] = cnt
        cnt = 0
        idx += 1

idx = 1
cnt = 0
for j in range(w):
    flag = False
    for i in range(h):
        if s[i][j] == ".":
            flag = True
            u2[i][j] = idx
            cnt += 1
        elif flag:
            d2[idx] = cnt
            cnt = 0
            idx += 1
            flag = False  
    if flag:
        d2[idx] = cnt
        cnt = 0
        idx += 1

ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            ans = max(ans, d1[u1[i][j]]+d2[u2[i][j]]-1)
print(ans)

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

using namespace std;
int n,cnt;
long long a[201111];
long long ans[200111];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>a[i];
        ans[0]^=a[i];
    }
    for(int i=1; i<=n; i++){
        cout<<(ans[0]^a[i])<<' ';
    }
}

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

H,W,A,B=map(int,input().split())

ANS=[]
for i in range(B):
    ANS.append([0]*A+[1]*(W-A))

for i in range(H-B):
    ANS.append([1]*A+[0]*(W-A))

for ans in ANS:
    print("".join(map(str,ans)))
    


Measured memory_bytes: 51292
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    string a;
    int s=0;
    cin>>a;
    for(int i=1;i<a.size();i++)
        if(a[i]!=a[i-1])
            s++;
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 512
def main():
    N = int(input())
    total = 0
    for i in range(N):
        i = i + 1
        if i % 3 == 0 and i % 5 == 0:
            continue
        elif i % 3 == 0:
            continue
        elif i % 5 == 0:
            continue
        total = total + i
    print(total)
main()

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

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

int main(){
	int n;
	while( cin >> n, n ){
		rep(j,n){
			int a[4], b[4], c[4];
			rep(i,4)  cin >> a[i];
			rep(i,4)  cin >> b[i];
			c[0] = a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3];
			c[1] = a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2];
			c[2] = a[0]*b[2] + a[2]*b[0] + a[3]*b[1] - a[1]*b[3];
			c[3] = a[0]*b[3] + a[3]*b[0] + a[1]*b[2] - a[2]*b[1];
			cout << c[0] << " " << c[1] << " " << c[2] << " " << c[3] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 998244353;
const int N = 1e5 + 5;

int i, n, x, m, pref[N];

void solve()
{
    cin >> n >> x >> m;
    if (n <= m)
    {
        int ans = 0;
        for (i = 1; i <= n; i++)
        {
            ans += x;
            x = (x * x) % m;
        }
        cout << ans;
        return;
    }
    int ans = 0, idx, final, rem;
    pref[0] = 0;
    map<int, int> vis;
    for (i = 1; i <= 2 * m; i++)
    {
        if (vis.find(x) == vis.end())
        {
            ans += x;
            vis[x] = i;
            pref[i] = pref[i - 1] + x;
            x = (x * x) % m;
        }
        else
        {
            idx = vis[x];
            final = i - 1;
            rem = n - i + 1;
            break;
        }
    }
    int steps = rem / (final - idx + 1), still = rem % (final - idx + 1);
    ans += steps * (pref[final] - pref[idx - 1]);
    ans += pref[idx + still - 1] - pref[idx - 1];
    cout << ans;
}

signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio;
    int t;
    //cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 7044
using System;
using System.Linq;
class Program
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] s = new string[n];
        for (int i = 0; i < n; i++)
            s[i] = Console.ReadLine();
        long m, a, r, c, h;
        m = s.Count(p => p[0] == 'M');
        a = s.Count(p => p[0] == 'A');
        r = s.Count(p => p[0] == 'R');
        c = s.Count(p => p[0] == 'C');
        h = s.Count(p => p[0] == 'H');

        long ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + a * c * h + r * c * h;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 15840
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int n,a[3000000];
	cin >> n;
	for(int i = 0;i < n;i++) scanf("%d",&a[i]);
	sort(a,a + n);
	for(int i = 0;i < n;i++) {
		if(!i) printf("%d",a[i]);
		else printf(" %d",a[i]);
	}
	cout << endl;
	return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

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

    int N, K;
    cin >> N >> K;
    double ans = 0;
    for (int i = 1; i <= N; i++) {
        double tmp = (double)1 / N;
        int    now = i;
        while (now < K) {
            now *= 2;
            tmp *= 0.5;
        }
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Measured memory_bytes: 46740
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

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

const int N = 3e5 + 5;

int t[4 * N];

int query(int v, int tl, int tr, int l, int r) {
    if (tl > r or tr < l) {
        return 0;
    }
    if (l <= tl and r >= tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2, u = 2 * v;
    return max(query(u, tl, tm, l, r), query(u + 1, tm + 1, tr, l, r));
}

void update(int v, int tl, int tr, int pos, int val) {
    if (tl == tr) {
        t[v] = val;
    } else {
        int tm = (tl + tr) / 2, u = 2 * v;
        if (pos > tm) {
            update(u + 1, tm + 1, tr, pos, val);
        } else {
            update(u, tl, tm, pos, val);
        }
        t[v] = max(t[u], t[u + 1]);
    }
}

void test() {
    int n, k;
    cin >> n >> k;
    vector<int> dp(n + 1, 1), a(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = n; i > 0; --i) {
        dp[i] = query(1, 1, N - 5, a[i] - k, a[i] + k) + 1;
        update(1, 1, N - 5, a[i], dp[i]);
        ans = max(ans, dp[i]);
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}


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

// using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
const int MAX = 10;



using P = pair<int, int>;
using PP = pair<P, int>;  //<<y,x>,distance>

int H,W;
bool g[MAX][MAX]; // 通れるマスならtrue
bool visited[MAX][MAX];

bool bfs(int start_y, int start_x) {
  queue<PP> q;
  PP qt = PP(P(start_y, start_x),0);
  q.push(qt);
  while(!q.empty()) {
    qt = q.front();
    int curr_x = qt.first.second;
    int curr_y = qt.first.first;
    int curr_d = qt.second;
    q.pop();
    for(int dy = 0; dy <= 1; ++dy) {
      for(int dx = 0; dx <= 1; ++dx) {
        if(!dy && !dx) continue;  // 自分の位置
        if(dy+dx == 2) continue;
        

        int next_x = curr_x + dx;
        int next_y = curr_y + dy;
        int next_d = curr_d + 1;

        // 範囲外
        if(next_x < 0 || next_x >= W) continue;
        if(next_y < 0 || next_y >= H) continue;

        // 通れないまたはすでに到達済み
        if(!g[next_y][next_x]) continue;
        if(visited[next_y][next_x]) continue;

        if(dx == 1 && curr_y+1 < H && g[curr_y+1][curr_x] && !visited[curr_y+1][curr_x]) {
          return false;
        }

        q.push(PP(P(next_y,next_x),next_d));
        visited[next_y][next_x] = true;
      }
    }
  }
  return true;
}

signed main() {
  int counter = 0;
  cin >> H >> W;
  REP(h, H) {
    REP(w, W) {
      char c;
      cin >> c;
      g[h][w] = (c == '#');
      if(g[h][w]) ++counter;
    }
  }
  bool possible = bfs(0,0);
  if(!possible) {
    cout << "Impossible" << endl;
    return 0;
  }

  int visited_counter = 1;
  REP(h, H) {
    REP(w, W) {
      if(visited[h][w]) ++visited_counter;
    }
  }
  // LOG(counter);
  // LOG(visited_counter);
  if(counter == visited_counter) {
    cout << "Possible";
  } else {
    cout << "Impossible";
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,i,j;
	while(1){
		scanf("%d%d",&a,&b);
		if(a==0 && b==0)break;
		for(i=0;i<a;i++){
			for(j=0;j<b;j++)printf("#");
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


signed main(){

	int n;
	cin >> n;

	cout << ceil(n/111.0)*111 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) {
    cin >> p[i];
  }

  int ans = 0;
  int max = p[0];
  int min = p[0];
  for(int i = 0; i < n; ++i) {
    if(min >= p[i]) {
      min = p[i];
      ++ans;
    }    
  }

  cout << ans << endl;

  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

using Tup = tuple<int64, int64, int64>;

int main(void){
	int64 M, T, P, R;
	while(cin >> M >> T >> P >> R && M+T+P+R){
		vector<vector<int64>> solved(T, vector<int64>(P, 0));
		vector<Tup> res(T);
		REP(i, T) res[i] = Tup(0, 0, i);
		REP(i, R){
			int32 m, t, p, j;
			cin >> m >> t >> p >> j; t--; p--;
			if(solved[t][p] <= 0){
				if(j == 0){
					int64 a, b, c;
					tie(a, b, c) = res[t];
					a++;
					b += solved[t][p]-m;
					res[t] = Tup(a, b, c);
					solved[t][p] = 1;
				}else{
					solved[t][p] -= 20;
				}
			}
		}
		sort(all(res), greater<Tup>());
		REP(i, T-1){
			cout << get<2>(res[i])+1;
			if(get<0>(res[i]) == get<0>(res[i+1]) && get<1>(res[i]) == get<1>(res[i+1]))
				cout << '=';
			else
				cout << ',';
		}
		cout << get<2>(res[T-1])+1 << endl;
	}
}



Measured memory_bytes: 3104
package main

import (
	"fmt"
)

func main() {
	var w string
	fmt.Scan(&w)

	count := map[rune]int{}
	for _, r := range w {
		_, ok := count[r]
		if ok {
			count[r]++
		} else {
				count[r] = 1
		}
	}

	for _, c := range count {
		if c % 2 == 1 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <ll>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
#define pb      push_back
const ll mod=1e9+7;
void fast();

int main()
{
    int n;
    cin>>n;
    ll a[n],cnt[n+5]={},res=0;
    loop(n){
        cin>>a[i];
        cnt[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        res+=cnt[i]*(cnt[i]-1)/2;
    }
    for(int i=1;i<=n;i++){
        ll x=max(cnt[a[i-1]]-1,(ll)0);
        ll temp=res-(cnt[a[i-1]]*(cnt[a[i-1]]-1)/2)+(x*(x-1))/2;
        cout<<temp<<" ";
    }
}

void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
     
using namespace std;
     
int main(void){
     
  int n, k, x, y;

  cin >> n >> k >> x >> y;

  if(k > n) cout << n*x;
  else cout << k*x+(n-k)*y;
  cout << endl;
     
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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


    int max1 = max(a, max(b, c));

    int temp;

    temp = max1 * 3 - a - b - c;

    if (temp % 2 == 1)
    {
        temp = (max1 + 1) * 3 - a - b - c;
    }

    cout << temp / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <climits>

using namespace std;
using ll = long long;
using ull = unsigned long long;

ll knapsack2(ll totalValue, ll W, const vector<vector<ll>>& items) {
    //DP against item values,  same value, then choose the minimum weight that can achieve the value
    int N = items.size();
    vector<ll> DP(totalValue+1, 1e18L+5LL);
    ll ans = 0;
    DP[0] = 0;
    
    for (int i = 0; i < N; ++ i) {
        for (int v = totalValue; v >= 0; --v) {
            ll weight = DP[v] - items[i][0];
            ll val = v - items[i][1];
            if (val>=0 && DP[val] != 1e18L+5LL) {
                DP[v] = min(DP[v], DP[val] + items[i][0]);
            }
        }
    }
    for (ll v = 0; v < totalValue+1; ++ v) {
        if (DP[v]<=W) {
            ans = max(v, ans);
        }
    }
    
    return ans;
}

int main() {
    ll N,W;
    cin>>N>>W;
    ll totalValue = 0;
    vector<vector<ll>> items; 
    for (int i = 0; i < N; ++ i) {
        vector<ll> t{0,0};
        cin>>t[0]>>t[1];
        totalValue+=t[1];
        items.push_back(t);
    }
    cout<<knapsack2(totalValue,W,items)<<endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
from collections import defaultdict


def input():
    return sys.stdin.readline().rstrip()


def main():
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())

    W = [a, b, c, d, e]

    d = 0
    p = []

    for i in range(5):
        x, y = divmod(W[i], 10)
        if y == 0:
            d += x
            p.append(10)
        else:
            d += x + 1
            p.append(y)

    print(d * 10 + min(p)-10)


if __name__ == "__main__":
    main()


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

int N, A, B;

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

    int result = 0;
    for (int n=1; n<=N; n++) {
        int n_ = n;
        int sum = 0;
        while (n_ > 0) {
            sum += n_ % 10;
            n_ = n_/10;
        }
        if (A <= sum && sum <= B) {
            result += n;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int N;
	int min = 0;
	int max = 101;
	int sum = 0;
	cin >> N;
	int p = 10000000;
	if (N > 0) {
		if (N == 1) cout << 0;
		else {
			int X[N];
			for (int i = 0; i < N; i++) {
				cin >> X[i];
				if (max <= X[i]) max = X[i];
				if (min >= X[i]) min = X[i];
			}
			for (int i = min; i < max; i++) {
				for (int j = 0; j < N; j++) {
					sum += (X[j] - i) * (X[j] - i);
				}
				if (sum < p) p = sum;
				sum = 0;
			}
			if (min == max) cout << 0;
			else cout << p;
		}
	}
	else cout << 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

//最大公約数
ll gcd(ll a,ll b){
    ll r=a%b; 
    while(r!=0){a=b;b=r;r=a%b;}
    return b;
}

//最小公倍数
ll lcm(ll a,ll b){return (a*b/gcd(a,b));}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d;cin>>a>>b>>c>>d;
  a--;
  ll num=b/c+b/d-b/lcm(c,d);
  ll num2=a/c+a/d-a/lcm(c,d);
  //cout<<num<<" "<<num2<<endl;
  cout<<(b-a)-(num-num2)<<endl;
  return 0;
}


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

int N;
int G[20][20];

int main () {
  memset(G,-1,sizeof(G));
  scanf("%d",&N);
  for (int i=0;i<N;++i) {
    int A, x, y;
    scanf("%d",&A);
    while (A--) {
      scanf("%d%d",&x,&y);
      G[i][x-1] = y;
    }
  }
  int ans = 0;
  for (int z=0;z<(1<<N);++z) {
    if (__builtin_popcount(z) <= ans) continue;
    bool ok = true;
    for (int i=0;i<N;++i)
      for (int j=0;j<N;++j)
        if (G[i][j] != -1) {
          bool hi = (z&(1<<i)) > 0, hj = (z&(1<<j)) > 0;
          if (hi) ok &= (G[i][j] == hj);
        }
    if (ok) ans = max(ans, __builtin_popcount(z));
  }
  printf("%d\n",ans);
}


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

int main(){
    
    size_t n, m;
    std::cin >> n >> m;

    std::vector<std::vector<size_t>> root(n);

    for(size_t i = 0; i < m; i++){
        size_t a, b;
        std::cin >> a >> b;
        root.at(a - 1).emplace_back(b - 1);
        root.at(b - 1).emplace_back(a - 1);
    }

    for(const auto& e : root){
        std::cout << e.size() << std::endl;
    }
    
    return 0;
}


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

int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;

  int ans = 0;

  if (B != max({A, B, C}) && B != min({A, B, C})) ans++;

  for (int i = 0; i < N - 3; i++) {
    A = B, B = C;
    cin >> C;
    if (B != max({A, B, C}) && B != min({A, B, C})) ans++;
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main()
{
  int n;
  cin >> n;
  vector<double> data;
  REP(i, n)
  {
    double x;
    cin >> x;
    data.push_back(x);
  }
  sort(ALL(data));
  double ans1 = data[n - 1];
  double ans1_half = data[n - 1] / 2;
  double ans2 = data[0];
  double diff = abs(ans1_half - ans2);
  FOR(i, 1, n - 1)
  {
    double now_diff = abs(ans1_half - data[i]);
    if (now_diff < diff)
    {
      diff = now_diff;
      ans2 = data[i];
    }
  }
  cout << (int)ans1 << " " << (int)ans2 << endl;
}

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

typedef long long ll;
ll a[200];
ll n, x;

ll ans;
int main() {
    ios::sync_with_stdio(false);
    cin >> n >> x;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        x -= a[i];
        ans++;
    }
    sort(a, a+n);
    for(int i = 0; i < n; i++) {
        if (a[i] <= x) {
            ans += (x / a[i]);
            x = x % a[i];
        }
    }
    cout << ans;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N, i, max=0, min=0;
	scanf("%d", &N);
	int arr[N];
	
	scanf("%d", arr);
	max=arr[0];
	min=arr[0];
	for(i=1;i<N;i++){
		scanf("%d", arr+i);
		if(arr[i]<min) min=arr[i];
		if(arr[i]>max) max=arr[i];
	}
	
	printf("%d", max-min);
}

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

const int N=100010;
int n,m,cnt,father[N];

int find(int x)
{
	return x==father[x]?x:father[x]=find(father[x]);
}

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		father[i]=i;
	for (int i=1,x,y;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		father[find(x)]=find(y);
	} 
	for (int i=1;i<=n;i++)
		if (find(i)==i) cnt++;
	printf("%d\n",cnt-1);
	return 0;
}

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

int main() {
	int n; cin >> n;
	for (int i = 1; i <= 100000; i++) {
		if (i*i > n) { cout << (i - 1)*(i - 1) << endl; break; }
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define M 1000000007
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define N 1000005
#define U 998244353
#define bs binary_search
#define endl '\n'
#define FILEIO     freopen("input.txt","r",stdin); freopen("output.txt","w", stdout);
#define PI 3.1415926535
#define INF LLONG_MAX-5
using namespace std;
int po(int n, int exp){
    int prod=1;
    rep(i,0,exp)
        prod*=n;
    return prod;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {   
        string s;
        cin>>s;
        rep(i,0,3){
            if(s[i]==s[i+1]){
                cout<<"Bad";
                r0;
            }
        }
        cout<<"Good";
    }   
}   

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h=sc.nextInt();
        int w=sc.nextInt();
        char[][] grid=new char[h][w];
        for(int i=0;i<h;i++)
        {
            grid[i]=sc.next().toCharArray();
        }
        int[][] dp=new int[h][w];

        if(grid[0][0]=='#'){
            dp[0][0]=1;
        }
        for(int i=1;i<h;i++)
        {
            dp[i][0]=Integer.MAX_VALUE;
            if(grid[i-1][0]==grid[i][0]||grid[i][0]=='.')
                dp[i][0]=Math.min(dp[i][0],dp[i-1][0]);
            else dp[i][0]=Math.min(dp[i][0],dp[i-1][0]+1);
        }
        for(int j=1;j<w;j++)
        {
            dp[0][j]=Integer.MAX_VALUE;
            if(grid[0][j-1]==grid[0][j]||grid[0][j]=='.')
                dp[0][j]=Math.min(dp[0][j],dp[0][j-1]);
            else dp[0][j]=Math.min(dp[0][j],dp[0][j-1]+1);
        }
        for(int i=1;i<h;i++)
            for(int j=1;j<w;j++)
            {
                dp[i][j]=Integer.MAX_VALUE;
                    if(grid[i-1][j]==grid[i][j]||grid[i][j]=='.')
                    dp[i][j]=Math.min(dp[i][j],dp[i-1][j]);
                    else dp[i][j]=Math.min(dp[i][j],dp[i-1][j]+1);

                    if(grid[i][j-1]==grid[i][j]||grid[i][j]=='.')
                        dp[i][j]=Math.min(dp[i][j],dp[i][j-1]);
                    else dp[i][j]=Math.min(dp[i][j],dp[i][j-1]+1);
            }

        System.out.println(dp[h-1][w-1]);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#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 namespace std;

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int h; cin >> h;
    int cnt = 0;
    while (h > 1) {
        h /= 2;
        cnt++;
    }
    int ans = 1;
    rep(i,cnt+1) {
        ans *= 2;
    }
    ans -= 1;
    cout << ans << endl;
    return 0;
}

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

int		main(void)
{
	int		N;
	int		K;
	int		answer;

	cin>>N;cin>>K;
	answer = K;
	for (int i = 0; i < N - 1; i++)
		answer = answer * (K - 1);
	cout<<answer<<endl;
	return (0);
}


Measured memory_bytes: 256
// Author : Chi
// created :
// Sawal : Practice

//header files
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//namespaces
using    namespace __gnu_pbds;
using    namespace std;
typedef tree <pair<int,int>, null_type, greater<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

//macros
#define ll 		    long long
#define pii         pair<ll,ll>
#define ss          second
#define ff          first
#define vi          vector<int>
#define vll         vector<long long>
#define pb(x)       push_back(x)
#define TEST  	    int TesT;cin>>TesT;while(TesT--)solve();
#define ai(a)       for(auto &i:a)cin>>i;
#define ao(a)       for(auto i:a)cout<<i<<' ';
#define TEST1       solve();
#define mod         998244353
#define aLL(x)      x.begin(),x.end()
#define r0n(i,n)    for(ll i = 0; i < n; ++i)
#define r1n(i,n)    for(ll i = 1; i <= n; ++i)
#define pdp(d,i)    fixed<<setprecision(i)<<d
#define CHI         ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define db(...)     __f(#__VA_ARGS__, __VA_ARGS__)                      //for debugging
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
//LOVE ALGO
//Make sure you have test cases (:->)
void solve(){
    int n,t;
    cin>>n>>t;
    pair<int,int>p[n];
    for(int i=0;i<t;i++){
        cin>>p[i].ff>>p[i].ss;
    }
    long long dp[n+1];
    memset(dp,0,sizeof dp);
    dp[0]=0;
    dp[1]=1;
    for(int i=2;i<=n;i++){
        dp[i]=dp[i-1];
        dp[i]%=mod;
        for(int j=0;j<t;j++){
            int r=max(0,i-p[j].ff);
            int l=max(0,i-p[j].ss-1);
            //db(i,l,r);
            dp[i]+=((dp[r]-dp[l]+mod)%mod);
            dp[i]%=mod;
        }
    }
    cout<<(dp[n]-dp[n-1]+mod)%mod;
}
int main(){
    CHI
    TEST1
    return 0;
}


Measured memory_bytes: 6772