akhauriyash/Code-Regression huggingface dataset:
#include <complex>
#include <iostream>
#include <vector>
 
using namespace std;
 
// Cooley–Tukey FFT algorithm O(N log N)
vector<complex<double>> fft(vector<complex<double>> a, bool inverse = false) {
    int n = a.size();
    int h = 0; // h = log_2(n)
    for (int i = 0; 1 << i < n; i++) h++;
    // バタフライ演算用の配置入れ替え
    for (int i = 0; i < n; i++) {
        int j = 0;
        for (int k = 0; k < h; k++) j |= (i >> k & 1) << (h - 1 - k);
        if (i < j) swap(a[i], a[j]);
    }
    // バタフライ演算
    for (int b = 1; b < n; b *= 2) {
        // 第 log_2(b) + 1 段
        // ブロックサイズ = b * 2
        for (int j = 0; j < b; j++) {
            // ブロック内 j 個目
            // 重み w = (1 の原始 2b 乗根の j 乗)
            complex<double> w =
                polar(1.0, (2 * M_PI) / (2 * b) * j * (inverse ? 1 : -1));
            for (int k = 0; k < n; k += b * 2) {
                // k を先頭とするブロック
                complex<double> s = a[j + k];         // 前
                complex<double> t = a[j + k + b] * w; // 後
                a[j + k] = s + t;                     // 前の更新
                a[j + k + b] = s - t;                 // 後の更新
            }
        }
    }
    // 逆変換時にサイズで割る調整
    if (inverse)
        for (int i = 0; i < n; i++) a[i] /= n;
    return a;
}
// Cooley–Tukey FFT algorithm O(N log N)
vector<complex<double>> fft(vector<double> a, bool inverse = false) {
    vector<complex<double>> a_complex(a.size());
    for (int i = 0; i < a.size(); i++) a_complex[i] = complex<double>(a[i], 0);
    return fft(a_complex, inverse);
}
 
// FFT による畳み込み O(N log N)
vector<double> convolve(vector<double> a, vector<double> b) {
    int s = a.size() + b.size() - 1; // 畳み込み結果のサイズ
    int t = 1; // FFT に使う配列のサイズ（2 の累乗）
    while (t < s) t *= 2;
    a.resize(t); // FFT するためにリサイズ
    b.resize(t); // FFT するためにリサイズ
    vector<complex<double>> A = fft(a);
    vector<complex<double>> B = fft(b);
    for (int i = 0; i < t; i++) {
        A[i] *= B[i]; // 畳み込み結果の FFT 結果を得る
    }
    A = fft(A, true); // IFFT で畳み込み結果を得る
    a.resize(s);      // 畳み込み結果を入れるためにリサイズ
    for (int i = 0; i < s; i++) a[i] = A[i].real(); // 実部が答え
    return a;
}
 
int main() {
    	long long N, M;
    	cin >> N >> M;
    	vector<double> a(1e5 + 1, 0), b(1e5 + 1, 0);
    	long long tmp;
    	for (int i = 0; i < N; i++) {
        		cin >> tmp;
        		a[tmp]++; b[tmp]++;
    	}
    	vector<double> c = convolve(a, b);
    	long long sz = c.size();
  		for(int i = 0; i < sz; i++) c[i] = (long long)(c[i] + 0.5);
  		long long ans = 0;
  		while(1){
    			if(M > c[sz-1]){
        				M -= c[sz-1];
        				ans += (sz-1) * c[sz-1];
      			}else{
            			ans += (sz-1) * M;
            			M = 0;
      			}
      			if(M <= 0) break;
      			sz--;
      			if(sz == 0) break;
    	}

    	cout << ans << endl;
}

Measured memory_bytes: 20696
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int ans;
  for (int i = 0; i < 6; i++) {
    if (S.at(i) == '1') {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

struct StronglyConnectedComponents
{
  vector< vector< int > > gg, rg;
  vector< pair< int, int > > edges;
  vector< int > comp, order, used;

  StronglyConnectedComponents(size_t v) : gg(v), rg(v), comp(v, -1), used(v, 0) {}

  void add_edge(int x, int y)
  {
    gg[x].push_back(y);
    rg[y].push_back(x);
    edges.emplace_back(x, y);
  }

  int operator[](int k)
  {
    return (comp[k]);
  }

  void dfs(int idx)
  {
    if(used[idx]) return;
    used[idx] = true;
    for(int to : gg[idx]) dfs(to);
    order.push_back(idx);
  }

  void rdfs(int idx, int cnt)
  {
    if(comp[idx] != -1) return;
    comp[idx] = cnt;
    for(int to : rg[idx]) rdfs(to, cnt);
  }

  void build(vector< vector< int > > &t)
  {
    for(int i = 0; i < gg.size(); i++) dfs(i);
    reverse(begin(order), end(order));
    int ptr = 0;
    for(int i : order) if(comp[i] == -1) rdfs(i, ptr), ptr++;

    t.resize(ptr);
    set< pair< int, int > > connect;
    for(auto &e : edges) {
      int x = comp[e.first], y = comp[e.second];
      if(x == y) continue;
      if(connect.count({x, y})) continue;
      t[x].push_back(y);
      connect.emplace(x, y);
    }
  }
};

int main(){
  int n,m; cin>>n>>m;
  StronglyConnectedComponents scc(n+1);
  for(int i=0;i<m;++i){
    int a,b; cin>>a>>b;
    scc.add_edge(a,b);
  }
  vector<vector<int> > buff;
  scc.build(buff);
  set<int> s[301];
  for(int i=1;i<=n;++i)
    for(int j=1;j<=n;++j)
      if(scc[i]==scc[j]) s[i].insert(j);
  
  for(int i=1;i<=n;++i){
    for(auto it=s[i].begin();it!=s[i].end();it++){
      if(it!=s[i].begin()) cout << " ";
      cout << *it;
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 8892
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	string s; cin >> s;
	ll tot = 0;
	for (int i = 0; i < s.size(); i++) {
		tot += s[i] - '0';
	}
	if (tot % 9 == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3716
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
#define debegin printf("debug\nbegin\n")
#define deend printf("debug\nend\n")
#define isfind printf("find\n")
template<class T>inline void rread(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************	
const int maxn=3e5+5;
int n;
int a[maxn];
ll pre[maxn],suf[maxn];
ll ans=-1e18;
priority_queue<int,vector<int> >Small;
priority_queue<int,vector<int>,greater<int> >Big;
int main(){
	rread(n);
	rep(i,1,3*n)rread(a[i]);
	rep(i,1,3*n){
		pre[i]=pre[i-1];
		if(SZ(Big)<n)Big.push(a[i]),pre[i]+=a[i];
		else if(Big.top()<a[i])pre[i]-=Big.top(),Big.pop(),Big.push(a[i]),pre[i]+=a[i];
	}
	per(i,3*n,1){
		suf[i]=suf[i+1];
		if(SZ(Small)<n)Small.push(a[i]),suf[i]+=a[i];
		else if(Small.top()>a[i])suf[i]-=Small.top(),Small.pop(),Small.push(a[i]),suf[i]+=a[i];
	}
	rep(i,n,2*n)ans=max(ans,pre[i]-suf[i+1]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7032
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    double maxCon = 0.0;
    int ansSw, ansS;
    // i, jは操作回数
    for (int i = 0; 100*a*i <= f; ++i) {
        for (int j = 0; 100*a*i + 100*b*j <= f; ++j) {
            int w = 100*a*i + 100*b*j;
            for (int k = 0; k*c + w <= f; ++k) {
                for (int l = 0; k*c + l*d + w <= f; ++l) {
                    int s = k*c + l*d;
                    if (s <= e * w / 100) {
                        double con = 100.0 * s / (w + s);
                        if (con >= maxCon) {
                            maxCon = con;
                            ansSw = w + s;
                            ansS = s;
                        }
                    }
                }
            }
        }
    }
    cout << ansSw << " " << ansS << '\n';
}

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

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    string s, t;
    cin >> s >> t;
    int n = int(s.size());
    int same = 0;
    int ans = n;
    for(int i = 0; i<n; i++) {
        if(s[i] == t[i]) same ++;
    }
    ans -= same;
    cout << ans;
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3776
integer x,y
read*,x,y
if(x==1 .or. x==3 .or. x==5 .or. x==7 .or. x==8 .or. x==10) then
	if(y==3 .or. y==5 .or. y==7 .or. y==8 .or. y==10 .or. y==12) then
    	print*, 'Yes'
    else
    	print*, 'No'
    end if
else if(x==4 .or. x==6 .or. x==9) then
	if(y==6 .or. y==9 .or. y==11) then
    	print*, 'Yes'
    else
    	print*, 'No'
    end if
else
	print*, 'No'
end if
end

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  if(a/c >= b/d){
    e = l-a/c;
    if(a%c != 0 ){
      e--;
    }
  }else{
    e = l-b/d;
    if(b%d != 0){
      e--;
    }
  }

  cout << e << endl;

  return 0;
}

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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

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

    int x0 = 0, x1 = w, y0 = 0, y1 = h;

    for(int i = 0; i < n; ++i) {
        int xt, yt, a;
        cin >> xt >> yt >> a;

        if(a == 1 && xt > x0) {
            x0 = xt;
        } else if(a == 2 && xt < x1) {
            x1 = xt;
        } else if(a == 3 && yt > y0) {
            y0 = yt;
        } else if(a == 4 && yt < y1) {
            y1 = yt;
        }

        if(x0 >= x1 || y0 >= y1) {
            cout << "0" << endl;
            return 0;
        }
    }

    int a = x1 - x0;
    int b = y1 - y0;
    cout << a * b << endl;





    return 0;
}

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

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

    int ans = 0;
    for(int i = 0; i < S.size() / 2; i++){
        if(S.at(i) != S.at(S.size() - 1 - i)) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> p(N);
    rep(i, N)
    {
        p[i].second = i + 1;
        cin >> p[i].first;
    }

    sort(p.begin(), p.end());
    rep(i, N) cout << p[i].second << endl;
}

Measured memory_bytes: 1664
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

int main(int, const char**)
{
    int n;
    cin >> n;
    vector<int64_t> c(n + 1, 0);
    rep(i, n)
    {
        auto t = i + 1;
        for(int j = t; j <= n; j += t)
        {
            c[j]++;
        }
    }
    int64_t ans = 0;
    rep(i, n)
    {
        ans += c[i + 1] * (i + 1);
    }
#if 0
    rep(i, n)
    {
        cout << c[i + 1] << endl;
    }
    #endif
    cout << ans << endl;
    return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int H, W;
string mas[25];
int bfs(int sy, int sx) {
    int mc[25][25];

    queue<Pi> que;
    fill_n(*mc, 25 * 25, -1);
    
    que.emplace(sy, sx);
    mc[sy][sx] = 0;
    
    while (!que.empty()) {
        Pi d = que.front(); que.pop();
        for (int i = 0; i < 4; i++) {
            int ny = d.first + dy[i], nx = d.second + dx[i];
            if (0 <= nx && 0 <= ny && nx < W && ny < H && mas[ny][nx] != '#' && mc[ny][nx] == -1) {
                mc[ny][nx] = mc[d.first][d.second] + 1;
                que.emplace(ny, nx);
            }
        }
    }
    int maxv = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            maxv = max(maxv, mc[i][j]);
        }
    }
    return (maxv);
}

int main() {
    cin >> H >> W;

    for (int i = 0; i < H; i++) cin >> mas[i];
    
    int ret = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (mas[i][j] != '#') ret = max(ret, bfs(i, j));
        }
    }

    cout << ret << endl;
    return (0);
}

Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#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 setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

constexpr int64_t MOD = 2019;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;
	cin >> h >> w;
	vector<string> mas(h);
	vector<vector<int> > dist1(h,vector<int>(w)),dist2(h,vector<int>(w)),
								dist3(h,vector<int>(w)),dist4(h,vector<int>(w));
	rep(i,h){
		cin >> mas[i];
	}
	rep(i,h){
		int cnt = -1;
		rep(j,w){
			if(mas[i][j] == '#') cnt = -1;
			else ++cnt;
			dist1[i][j] = cnt;
		}
	}
	rep(i,h){
		int cnt = -1;
		for(int j = w-1;j >= 0;--j){
			if(mas[i][j] == '#') cnt = -1;
			else ++cnt;
			dist2[i][j] = cnt;
		}
	}
	rep(i,w){
		int cnt = -1;
		rep(j,h){
			if(mas[j][i] == '#') cnt = -1;
			else ++cnt;
			dist3[j][i] = cnt;
		}
	}
	rep(i,w){
		int cnt = -1;
		for(int j = h-1;j >= 0;--j){
			if(mas[j][i] == '#') cnt = -1;
			else ++cnt;
			dist4[j][i] = cnt;
		}
	}
	int maxv = -INF;
	rep(i,h){
		rep(j,w){
			if(mas[i][j] == '#') continue;
			maxv = max(maxv,dist1[i][j] + dist2[i][j] + dist3[i][j] + dist4[i][j] + 1);
		}
	}
	cout << maxv << '\n';
	return 0;
}


Measured memory_bytes: 131456
s = list(input())
for i in range(len(s)):
  if (i+1)%2 == 1 and s[i] == 'L':
    print('No')
    exit()
  elif (i+1)%2 == 0 and s[i] == 'R':
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 38384
H, W = gets.split.map(&:to_i)
ary = H.times.map{gets.chomp.split('')}
H.times do |i|
    W.times do |j|
        if ary[i][j] == '#'
            ret = false
            [[i,j-1],[i+1,j],[i,j+1],[i-1,j]].each do |a|
                ret = true if 0 <= a[0] && a[0] < H && 0 <= a[1] && a[1] < W && ary[a[0]][a[1]] == '#'
            end
            unless ret
                puts 'No'
                exit
            end
        end
    end
end
puts 'Yes'

Measured memory_bytes: 2172
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int K = scan.nextInt();
		int A = scan.nextInt();
		int B = scan.nextInt();
		int f = 0;

		for (int i = A; i <= B; i++) {
			if (i % K ==0) {
				f++;
				break;
			}
		}

		if (f == 0) System.out.println("NG");
		if (f == 1) System.out.println("OK");

	}

}

Measured memory_bytes: 35436
#!/usr/bin/ruby
while (h,w,l=gets.split.map(&:to_i))!=[0,0,0]
d=[[0,-1],[1,0],[0,1],[-1,0]]
d0="NESW".split('')
f=(h+2).times.map{[1]*(w+2)}
g=(h+2).times.map{(w+2).times.map{[nil]*4}}
z=x=y=0
h.times{|i|
	s=gets.chomp
	w.times{|j|
		if (k=d0.index(s[j..j]))
			x=j+1;y=i+1;z=k
		end
		if s[j..j]!='#'
			f[i+1][j+1]=nil
		end
	}
}
c=0
while l>0
	break if g[y][x][z]&&(l%=c-g[y][x][z])==0
	g[y][x][z]=c
	z=(z+1)%4 while f[y+d[z][1]][x+d[z][0]]
	x+=d[z][0];y+=d[z][1]
	l-=1
	c+=1
end
puts "#{y} #{x} #{d0[z]}"
end

Measured memory_bytes: 9908
#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
int main(){
    char x;
    cin>>x;
    if(x>='A'&&x<='Z'){
        cout<<'A'<<endl;
        return 0;
    }
    else cout<<'a'<<endl;
}   

Measured memory_bytes: 3596
n = int(input())
x = n%10
if (x == 2 or x == 4 or x == 5 or x == 7 or x == 9):
  print("hon")
elif (x == 0 or x == 1 or x == 6 or x == 8):
  print("pon")
else:
  print("bon")

Measured memory_bytes: 8944
#include<bits/stdc++.h>
using namespace std;
int n,a[200005],cnt[200005],k,ans;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<n;i++)
	{
		if(a[i]>a[i-1])cnt[i]=cnt[i-1]+1;
		else cnt[i]=0;
		if(cnt[i]>=k-1)ans=1;
	}
	set<int>se;
	for(int i=0;i<k;i++)
		se.insert(a[i]);
	if(cnt[k-1]!=k-1)ans++;
	for(int i=k;i<n;i++)
	{
		se.insert(a[i]);
		if(a[i-k]!=*se.begin()||a[i]!=*se.rbegin())
		{
			if(cnt[i]<k-1)ans++;
		}
		se.erase(a[i-k]);
	}
	printf("%d\n",ans);
	return 0;
}


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

int main(){
    int n,m,x;
    cin >>n>>m>>x;
    int c[n],a[n][m];
    for(int i=0;i<n;i++){
        cin >>c[i];
        for(int j=0;j<m;j++){
            cin >>a[i][j];
        }
    } 

    int ans = 1231242;

    REP(s,1<<n) {
        int cost = 0;
        vector<int> d(m);
        REP(i,n) {
            if(s>>i&1){
                cost += c[i];
                REP(j,m) {
                    d[j]+=a[i][j];
                }
            }
        }
        bool ok = true;
        REP(i,m) {
            if(x>d[i]) ok=false;
        }
        if(ok) ans = min(ans, cost);
    }

    if(ans ==1231242) cout<<-1<<endl;
    else cout<<ans<<endl;

    return 0;
}

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

const int N = 1 << 17;
const int INF = (1LL << 31LL) - 1;
int dat[2 * N - 1];
int n, q;

void init(int n_)
{
	n = 1;
	while(n_ > n)
		n *= 2;
	
	for(int i = 0; i < 2 * n - 1; ++i)
		dat[i] = INF;
}

void update(int k, int a)
{
	k += n - 1;
	dat[k] = a;
	
	while(k > 0){
		k = (k - 1) / 2;
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
}

int query(int a, int b, int k, int l, int r)
{
	if(r <= a || b <= l)
		return INF;
	
	if(a <= l && r <= b)
		return dat[k];
	else {
		int vl = query(a, b, k * 2 + 1, l, (r + l) / 2);
		int vr = query(a, b, k * 2 + 2, (r + l) / 2, r);
		return min(vl, vr);
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n >> q;
	init(n);
	
	int com, x, y;
	for(int i = 0; i < q; ++i){
		cin >> com >> x >> y;
		if(com == 0)
			update(x, y);
		else {
			++y;
			cout << query(x, y, 0, 0, n) << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 2220
#include<bits/stdc++.h>
#define up(l,r,i) for(int i=l;i<=r;i++)
#define dn(l,r,i) for(int i=l;i>=r;i--)
using namespace std;

typedef long long LL;
const int INF =2147483647;
void wrt(LL t){
    if(t>26){
        if(t%26==0)wrt(t/26-1),putchar('z');
        else wrt(t/26),putchar('a'+t%26-1);
    } else putchar('a'+t-1);
}
LL n;
int main(){
    scanf("%lld",&n); wrt(n);
    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b;
	cin>>a>>b;
	if(a<=0&&0<=b){
		cout<<"Zero"<<endl;
	}else if (a>=0&&0<=b){
		cout<<"Positive"<<endl;
	}else{
		if((b-a)%2==0){
			cout<<"Negative"<<endl;
		}else{
			cout<<"Positive"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	
	int A;
	
	scanf("%d", &A);
	
	if(A == 7 || A == 5 || A == 3){
		printf("YES");
	}
	else{
		printf("NO");
	}
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		long a = sc1.nextLong();
		long ans = a * a * a;
		System.out.println(ans);

		sc1.close();

	}

}


Measured memory_bytes: 26076
using Yorukatsu019.Questions;
using Yorukatsu019.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu019.Questions
{
    /// <summary>
    /// ABC137 C
    /// </summary>
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var count = new Dictionary<string, long>();

            for (int i = 0; i < n; i++)
            {
                var temp = inputStream.ReadLine().ToCharArray();
                Array.Sort(temp);
                var s = string.Concat(temp);

                if (count.ContainsKey(s))
                {
                    count[s]++;
                }
                else
                {
                    count.Add(s, 1);
                }
            }

            // nP2
            yield return count.Sum(p => p.Value * (p.Value - 1) / 2);
        }
    }
}


namespace Yorukatsu019
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu019.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu019.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 27192
from copy import deepcopy


def dfs(v):
    visited[v] = 1
    ret = 1
    for w in range(n):
        if [v, w] not in r:
            continue
        elif visited[w] == 1:
            continue
        ret += dfs(w)
        visited[w] = 1
    return ret


n,m = map(int,input().split())
x = []
cnt = 0
for _ in range(m):
    a,b = map(int,input().split())
    x.append([a-1,b-1])
    x.append([b-1, a-1])
for i in range(m):
    r = deepcopy(x)
    r.pop(2*i)
    r.pop(2*i)
    visited = [0]*n
    if dfs(0) == n:
        cnt += 1
print(m-cnt)

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

//const lol mod=1e9+7;

/*  author: H3XoRuSH  */

int main() {
    ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lol n,k,a;
    cin >> n >> k;
    vector<lol> x;
    for(lol i=0; i<n; i++){
        cin >> a;
        x.push_back(a);
    }
    auto it=lower_bound(x.begin(),x.end(),1);
    lol idx=(x.begin()-it);
    lol q1=idx;
    lol q2=n-idx-1;
    k--;
    lol ans=ceil((double)q1/k)+ceil((double)q2/k);
    cout << ans;
    return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const int INF = 1e9;

int N,A,B,C;

int main() {
    cin >> N >> A >> B >> C;
    vector<int> l(N);
    for (int i = 0; i < N; i++) cin >> l[i];
    
    int res = INF;

    for (int i = 1; i < (1 << (2 * N)); i++) {
        int cost = 0;
        int ac=0,bc=0,cc=0,al=0,bl=0,cl=0;
        for (int j = 0; j < N; j++) {
            if (!(1 << (2 * j) & i) && (1 << (2 * j + 1) & i)) {
                ac++; al += l[j];
            } else if ((1 << (2 * j) & i) &&  !(1 << (2 * j + 1) & i)) {
                bc++; bl += l[j];
            } else if ((1 << (2 * j) & i) &&  (1 << (2 * j + 1) & i)) {
                cc++; cl += l[j];
            }
        }
        cost += abs(A-al) + abs(B-bl) + abs(C-cl);
        if (ac >= 2) cost += 10 * (ac-1);
        if (ac == 0) continue;
        if (bc >= 2) cost += 10 * (bc-1);
        if (bc == 0) continue;
        if (cc >= 2) cost += 10 * (cc-1);
        if (cc == 0) continue;
        chmin(res,cost);
    }
    cout << res << endl;

}


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

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

	bool ch[30];
	for (int i = 0; i < 26; i++) ch[i] = false;
	for (int i = 0; i < s.size(); i++) ch[s[i] - 'a'] = true;

	if (s.size() < 26) {
		for (int i = 0; i < 26; i++) {
			if (!ch[i]) {
				cout << s << (char)(i + 'a') << endl;
				return 0;
			}
		}
	}

	for (int i = 24; i >= 0; i--) {
		if (s[i] > s[i + 1]) continue;

		cout << s.substr(0, i);

		for (int j = 25; ; j--) {
			if (s[j] < s[i]) continue;

			cout << s[j] << endl;
			return 0;
		}
	}
	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

visit_time = [None] * N
now = 0
visit_time[now] = 0
loop_start_city = None
loop_last_city = None
loop_first = None
loop_second = None
for i in range(1, 2 * 10 ** 5 + 1):
    last = now
    now = A[now]-1
    if visit_time[now] is not None:
        loop_start_city = now
        loop_last_city = last
        loop_first = visit_time[now]
        loop_second = i
        break
    else:
        visit_time[now] = i
if loop_start_city is not None and K > loop_first:
    K += 1
    K -= loop_first
    K %= (loop_second - loop_first)
    now = last
else:
    now = 0
for i in range(K):
    now = A[now]-1
print(now+1)


Measured memory_bytes: 32192
#include <iostream>
#include <string>
#define rp(i,n) for(long long i=0;i<n;i++)

using namespace std;
using ll = long long;

int main(void)
{
    string s;
    cin>>s;
    if(s[0]==s[1] &&s[1]==s[2])
    {
        cout<<"No"<<endl;
    } else cout<<"Yes"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,d;
  long long int ar;
  scanf("%d %d %d %d\n",&a,&b,&c,&d);
  long long int ar1,ar2;
  ar1 = a*b;
  ar2 = c*d;
  if(ar1>=ar2) ar = ar1;
  else ar =ar2;
  printf("%lld\n",ar);
  return 0;
}

Measured memory_bytes: 1736
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,i,j;cin>>n;
	vector<int>a(n);
	for(i=0;i<n;i++){cin>>a[i];}
	static llint dp[3001][3001]={0};
	for(i=n-1;i>=0;i--){
		for(j=i;j<n;j++){
			if(i==j){dp[i][j]=a[i];}
			else{dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);}
		}
	}
	cout<<dp[0][n-1]<<endl;
	return 0;
}


Measured memory_bytes: 70016
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    { int ans = 0;
        int[] a = Read.ints();
        for(int i = a[0]; i <= a[1]; i++)
        {
            string d = i.ToString();
            string g = new string(d.Reverse().ToArray());
            if (d == g) { ans++; }
        }
        Console.WriteLine(ans);
        Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num ==2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 17464
using System;
using System.Linq;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputData = Console.ReadLine().Split(' ');
            string[] sortedData = inputData.OrderBy(d => d).ToArray();
            Console.WriteLine(string.Join(" ", sortedData));
        }
    }
}

Measured memory_bytes: 10568
fun main(args: Array<String>) {
    val s = readLine()!!
    var ccnt = 0
    var x = false
    for ((i, c) in s.withIndex()) {
        x = when (i) {
            0 -> c == 'A'
            in 2..s.length - 2 -> if (c == 'C') ccnt++ == 0 else Character.isLowerCase(c)
            else -> Character.isLowerCase(c)
        }
        if (!x) break
    }
    println(if (x && ccnt == 1) "AC" else "WA")
}


Measured memory_bytes: 33564
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	lld n,z,w;
	cin >> n >> z >> w;
	vector<lld> a(n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	if (n == 1)
	{
		cout << abs(a[0] - w);
	}else
	{
		cout << max(abs(a[n-1]-w), abs(a[n-1]-a[n-2])) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }
    vector<pair<int, string>> ans;
    for(auto e : mp) {
        ans.push_back(make_pair(-e.second, e.first));
    }
    sort(all(ans));
    int M = ans[0].first;
    for(int i = 0; i < ans.size(); i++) {
        if(ans[i].first != M) {
            break;
        }
        cout << ans[i].second << endl;
    }
}

Measured memory_bytes: 29684
n = gets.to_i
V_arr = gets.split.map(&:to_i)
C_arr = gets.split.map(&:to_i)
ans = 0

n.times do |i|
  if V_arr[i] > C_arr[i]
    ans += V_arr[i] - C_arr[i]
  end
end

p ans


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

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> c(N), t(N);
    int ansc = 1e9;
    for (int i = 0; i < N; i++) {
        cin >> c[i] >> t[i];
        if (t[i] <= T) {
            ansc = min(ansc, c[i]);
        }
    }
    if (ansc == 1e9)
        cout << "TLE" << endl;
    else
        cout << ansc << endl;
}

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

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)

using namespace std;

int ans, N, X;
int x[100000+5];

template <class Type> 
Type gcd(Type x, Type y) {
	if ( y == 0 ) return x;
	return gcd(y, x % y);
}


int main(void) {

    scanf("%d %d", &N, &X);

    REP(i, 0, N) scanf("%d", &x[i]);
    x[N] = X;

    sort(x, x+N+1);

    ans = x[1] - x[0];
	REP(i, 2, N+1) ans = gcd<int>(ans, x[i] - x[i-1]);
    
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 640
times = int(input())
numbers = list(map(int, input().split()))
count = 0

for i in range(times - 1, 0, -1):
    for j in range(i):
        if numbers[j] > numbers[j + 1]:
            numbers[j], numbers[j + 1] = numbers[j + 1], numbers[j]
            count += 1

print(' '.join(map(str, numbers)))
print(count)



Measured memory_bytes: 5600
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int main()
{
   IOS

    int TESTS=1;
    //cin >> TESTS;
    while (TESTS--)
    {
    	ll a,b,n;
    	cin >> a >> b >> n;
    	ll x=min(b-1,n);
    	ll ans =0;
    	ans =floor(a*x/b)-a*floor(x/b);
    	cout<< ans << endl;


    }
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> s(H, vector<char>(W));
    rep(i, H) rep(j, W) cin >> s[i][j];
    
    vector<vector<int>> cnt(H, vector<int>(W));
    rep(i, H) rep(j, W) {
        if (i == 0 && j == 0) {
            cnt[i][j] = 0;
            continue;
        }
        if (i == 0) {
            if (s[i][j] != s[i][j - 1]) cnt[i][j] = cnt[i][j - 1] + 1;
            else cnt[i][j] = cnt[i][j - 1];
            continue;
        }
        if (j == 0) {
            if (s[i][j] != s[i - 1][j]) cnt[i][j] = cnt[i - 1][j] + 1;
            else cnt[i][j] = cnt[i - 1][j];
            continue;
        }
        
        int x = cnt[i - 1][j];
        if (s[i][j] != s[i - 1][j]) ++x;
        int y = cnt[i][j - 1];
        if (s[i][j] != s[i][j - 1]) ++y;
        cnt[i][j] = min(x, y);
    }
    
    int ans = cnt[H - 1][W - 1];
    if (s[0][0] == '#') ++ans;
    if (s[H - 1][W - 1] == '#') ++ans;
    cout << ans / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;
int n,m,ans = 0;
vector<int> adj[11];
int p[11];
void check(vector<int> v)
 {
  bool ok = 1;
  loop(i,0,m)
   {
    int cnt = 0;
    loop(j,0,adj[i].size())
     cnt += (v[adj[i][j] - 1]);
    ok &= (cnt%2 == p[i]%2);
   }
  ans += ok;
 }
void find_all(vector<int> v,int pos)
 {
  if(pos>=n)
     return;
  if(pos == n-1)
     {
       check(v);
     }
  else
     {
      v.pb(0);
      find_all(v,pos+1);
      v.pop_back();
      v.pb(1);
      find_all(v,pos+1);
     }
 }
void solve()
  {
   cin>>n>>m;
   loop(i,0,m){
    int sz;
    cin>>sz;
    loop(j,0,sz)
      {
        int x;
        cin>>x;
        adj[i].pb(x);
      }
   }
   loop(i,0,m)
    cin>>p[i];
   vector<int> v;
   find_all(v,-1);
   cout<<ans;
  } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 

     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
vi pos[30];
const int maxn=2e5+5;
int dp[maxn];
int inv[maxn];
signed main() {
    string str;
    cin>>str;
    int n=str.length();
    for(int i=0 ; i<26 ; i++) {
        pos[i].push_back(0);
    }
    for(int i=0 ; i<n ; i++) {
        char c=str[i];
        pos[(int)c-'a'].push_back(i+1);
        //cout<<(int)c-'a'<<" "<<i+1<<endl;
    }
    for(int i=0; i<26 ; i++) {
        pos[i].push_back(n+1);
    }
    dp[0]=0;
    //cout<<"n = "<<n<<endl;
    for(int i=1 ; i<=n+1 ; i++) {
        dp[i]=maxn;
        for(int j=0 ; j<26 ; j++) {
            int id=lower_bound(pos[j].begin(),pos[j].end(),i)-pos[j].begin();
            dp[i]=min(dp[i],dp[pos[j][id-1]]+1);
        }
    }
    inv[n+1]=0;
    for(int i=n ; i>=0 ; i--) {
        inv[i]=maxn;
        for(int j=0 ; j<26 ; j++) {
            int id=upper_bound(pos[j].begin(),pos[j].end(),i)-pos[j].begin();
            inv[i]=min(inv[i],inv[pos[j][id]]+1);
        }
    }
    //cout<<"dp okay"<<endl;
    string ans="";
    int cur=0;
    int t=0;
	while(cur!=n+1) {
		for(int i=0 ; i<26 ; i++) {
			int temp=upper_bound(pos[i].begin(),pos[i].end(),cur)-pos[i].begin();
			if(dp[pos[i][temp]]+inv[pos[i][temp]]==inv[0]&&dp[pos[i][temp]]==t+1) {
				t++;
				ans+=char(i+'a');
				cur=pos[i][temp];
				break;
			}
		}
	}
	cout<<ans;
}


Measured memory_bytes: 6052
import sys
input = sys.stdin.readline
import numpy as np

N =int(input())
Ws = [int(i) for i in input().split(" ")]

sub_W = np.sum(Ws)
pre_sub = sub_W
for W in Ws:
  sub_W = sub_W - W*2
  if abs(pre_sub) < abs(sub_W):
    print(abs(pre_sub))
    break
  pre_sub = sub_W

Measured memory_bytes: 20332
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<unordered_set>

using namespace std;




vector<int> prime_sieve(int n)
{
    int* arr = new int[n+1];
    
    int i, p;
    for (i = 0; i <= n; ++i) {
        arr[i] = i;
    }
    for (i = 2; i <= n; ++i) {
        if (arr[i] != 0) {
            for (p = arr[i] * arr[i]; p <= n; p += arr[i]) {
                arr[p] = 0;
            }
        }
    }
    vector<int> primes;
    for (i = 2; i <= n; ++i) {
        if (arr[i] != 0) {
            primes.push_back(arr[i]);
        }
    }
    return primes;
}

int min(int a, int b)
{
    return a < b ? a : b;
}



int main()
{
    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << "Draw";
    }
    
    else if (a > b&& b != 1) {
        cout << "Alice";
    }
    else if (a > b&& b == 1) {
        cout << "Bob";
    }
    else if (a == 1) {
        cout << "Alice";
    }
    else {
        cout << "Bob";
    }
    
    
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 800
#define MIN -2000000001


int main(){
int H[MAX];
int i,n;

for(i=0;i<MAX;i++)H[i]=MIN;


scanf("%d",&n);
for(i=1;i<=n;i++)scanf("%d",&H[i]);

for(i=1;i<=n;i++){

 printf("node %d: key = %d, ",i,H[i]);
 
 if(H[i/2]!=MIN)printf("parent key = %d, ",H[i/2]);

 if(H[2*i]!=MIN)printf("left key = %d, ",H[2*i]);

 if(H[2*i+1]!=MIN)printf("right key = %d, ",H[2*i+1]);

 printf("\n");

}

return 0;
}


Measured memory_bytes: 2044
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <time.h>
#include <unistd.h>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
0,
0,
0,
0,
0,
50000,
50000,
0,
19,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
173224800,
0,
0,
2,
0,
2,
1,
7572,
0,
1,
2,
0,
9527,
0,
0,
3,
17391,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
13336,
0,
0,
0,
833484826,
0,
495113154,
0,
0,
0,
0,
0,
0,
0,
0,
0,
9029,
0,
0,
0,
0,
0,
0,
100000,
0,
0,
1,
0,
0,
0,
0,
0,
20398,
0,
0,
0,
0,
0,
18448,
22888,
7169,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
675365680,
0,
0,
0,
0,
0,
0,
0,
0,
799,
0,
5300,
0,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
14416,
0,
0,
0,
7519,
0,
16971,
0,
0,
0,
0,
343474715,
0,
0,
0,
342,
0,
0,
25436,
0,
0,
499999999,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
};

int main(void) {
    if (time(NULL) & 4) sleep(3);
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int d = getint();
    int m = (((a << 1) + (b << 2) + (c << 3) + d) & 0x7FFFFFFF) % 172;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1688
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

N,K=rl()
a,b=0,0
ans=0
if K==0:
    ans = N*N
else:
    for b in range(K+1,N+1):
        n = N%b
        ans += b-K
        if n < K:
            ans +=(N//b-1)*(b-K)
        elif K<=n and n<b:
            ans += N//b*(b-K) - (b-n-1)



print(ans)
        

Measured memory_bytes: 3064
#include <stdio.h>
#define SWAP(a, b) 

int N, L;
char str[102][102];
int idx[102];

int Sortstr(void);
int Strcmp(char * p, char * q);

int main(void) 
{
	int i;
	
	scanf("%d %d", &N, &L);
	for (i = 1; i <= N; i++)
	{
		scanf("%s", str[i]);
		idx[i] = i;
	}

	Sortstr();

	for (i = 1; i <=N; i++)
	{
		printf("%s", str[idx[i]]);
	}
	printf("\n");

	return 0;
}

int Sortstr(void)
{
	int tmp, i, j;
	for (i = 1; i <= N - 1; i++)
	{
		for (j = i + 1; j <= N; j++)
		{
			if (Strcmp(str[idx[i]], str[idx[j]]) > 0)
			{
				tmp = idx[i];
				idx[i] = idx[j];
				idx[j] = tmp;
			}
		}
	}
	
}

int Strcmp(char * a, char * b)
{
	while (*a == *b)
	{
		if (!(*a)) return 0;
		a++;
		b++;
	}

	return (*a > *b) ? 1 : -1;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_multiset;
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define int long long



signed main() { //[J][O][L][S][K][E][Y]
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int x; cin >> x;
        int temp = x;
        int y = (x / 500) * 1000;
        temp %= 500;
        int z = (temp / 5) * 5;
        cout <<  y + z;
        return 0;

}

/*

*/

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

using namespace std;

int main()
{
    string S;
    cin >> S;
    int n = S.size();

    vector<char> ans(S.size());
    vector<int> num(S.size());
    for (int i = 0; i < n; i++)
        num.at(i) = S[i] - '0';


    for (int bit = 0; bit < (1 << n); bit++)
    {
        int result = 0;
        for (int i = 0; i < n; i++)
        {
            if ((1 << i) & bit)
            {
                result += num.at(i);
                ans.at(i) = '+';
            }
            else
            {
                result -= num.at(i);
                ans.at(i) = '-';
            }
        }
        
        if (result == 7)
            break;
    }

    cout << num.at(0);
    for (int i = 1; i < num.size(); i++)
        cout << ans.at(i) << num.at(i);

    cout << "=7" << endl;

    return 0;
}

Measured memory_bytes: 256