akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using pque = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }

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

#include <atcoder/all>
using namespace atcoder;

int main() {
	int n, q;
	cin >> n >> q;
	fenwick_tree<ll> fw(n);
	rep(i, n) {
		ll a;
		cin >> a;
		fw.add(i, a);
	}
	while (q--) {
		int t;
		cin >> t;
		if (t == 0) {
			int p, x;
			cin >> p >> x;
			fw.add(p, x);
		}
		else {
			int l, r;
			cin >> l >> r;
			cout << fw.sum(l, r) << '\n';
		}
	}
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define INF INT_MAX/3
#define N 3
typedef pair<int, int> P;

struct State {
    int g, h;
    string state;
    P blank;
    string path;
    bool operator<(const State &a) const {
        return g + h > a.g + a.h;
    }
};

int d[5] = {-1, 0, 1, 0, -1};
string r[4] = {"D", "R", "U", "L"};
string ans_str = "";
int ans[N][N], puzzle0[N][N], puzzle1[N][N];
set<string> s;
priority_queue<State> next_state;
string path;

bool range(int y, int x) {return 0 <= y && y < N && 0 <= x && x < N;}

int h2_dfs(int boundary, State state, int from) {
    int find = -1;
    s.insert(state.state); // visited

    P blank = state.blank;
    rep(i, 4) {
        if (from == (i + 2) % 4) continue;
        int y = d[i] + blank.first, x = d[i + 1] + blank.second; // next blank position
        if (range(y, x)) { // can be replaced
            string tmp = state.state; // next state (string)
            int p = blank.first * N + blank.second, q = y * N + x;
            if (N < 4) swap(tmp[p], tmp[q]);
            else swap(tmp[2 * p], tmp[2 * q]), swap(tmp[2 * p + 1], tmp[2 * q + 1]);

            int num;
            if (N < 4) num = state.state[q] - '1';
            else num = stoi(state.state.substr(2 * q, 2)) - 1;
            // calcurate manhattan distance
            int manhattan = state.h - ((abs(num / N - y) + abs(num % N - x)))
            + (abs(num / N - blank.first) + abs(num % N - blank.second));

            if (manhattan == 0) { // answer
                find = state.g + 1;
                path = state.path + r[i];
                break;
            }

            if (state.g + 1 + manhattan > boundary) continue; // estimate value is over boundary
            find = h2_dfs(boundary, State{state.g + 1, manhattan, tmp, P(y, x), state.path + r[i]}, i);
            if (find != -1) break;
        }
    }
    return find;
}

int ids_h2(string state, int manhattan, P blank) {
    int i = manhattan, find = -1;
    while(find == -1 && i < 81) {
        s.clear();
        find = h2_dfs(i, State{0, manhattan, state, blank, ""}, -1);
        i++;
    }
    return find;
}

int main(){
    // create answer's numbers
    iota(ans[0], ans[0] + N * N, 1);
    ans[N - 1][N - 1] = 0;
    // create number
    iota(puzzle0[0], puzzle0[0] + N * N, 0);
    rep(i, N)rep(j, N) cin >> puzzle0[i][j];

    string state = "";
    P blank;
    int manhattan = 0, wrong_place = 0;
    rep(i, N)rep(j, N) {
        state += to_string(puzzle0[i][j]);
        ans_str += to_string(ans[i][j]);

        if(puzzle0[i][j] == 0) blank = P(i, j);
        else {
            int num = puzzle0[i][j] - 1;
            manhattan += (abs(num / N - i) + abs(num % N - j));
            if (puzzle0[i][j] != ans[i][j]) wrong_place++;
        }
    }

    if (manhattan == 0) { // the answer
        cout << 0 << endl;
    } else {
        int steps;
        next_state.push(State{0, wrong_place, state, blank, ""});
        steps = ids_h2(state, manhattan, blank);
        cout << steps << endl;
    }
    return 0;
}

Measured memory_bytes: 3844
import java.util.*;class Main{public static void main(String[]g){int n;for(Scanner S=new Scanner(System.in);(n=S.nextInt())>0;)System.out.println(new java.text.SimpleDateFormat("EEEE",Locale.US).format(new GregorianCalendar(2004,n-1,S.nextInt()).getTime()));}}


Measured memory_bytes: 27328
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n, m, a;
	while(cin >> n >> m >> a, n){
		vector< pair<int, pair<int, int> > > vp(m);
		for(int i=0;i<m;i++){
			cin >> vp[i].first >> vp[i].second.first >> vp[i].second.second;
		}
		sort(vp.rbegin(), vp.rend());
		for(int i=0;i<m;i++){
			if(vp[i].second.first == a){
				a = vp[i].second.second;
			} else if(vp[i].second.second == a){
				a = vp[i].second.first;
			}
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 1208
#include<iostream>
#include<math.h>
#include<algorithm>
#define LL long long
#define FIO ios_base::sync_with_stdio(false), cin.tie(0)
using namespace std;

int main()
{
	int k, x, st, end; cin>>k>>x;
	st=max(-1000000, x-k+1), end=min(1000000, x+k-1);
	for(int i=st; i<=end; i++) cout<<i<<" ";
	cout<<endl;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int main(){
  int a,b;
  cin>>a>>b;
  cout<<(a+b)/2<<endl;
    
  return 0;
}



Measured memory_bytes: 3052
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        private static bool HasSustring(string s , string p)
        {
            int endPos = s.Length - p.Length + 1;

            for (int i = 0; i < endPos; i++)
            {
                if( p == s.Substring(i, p.Length) )
                    return true;
            }

            return false;
        }


        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string p = Console.ReadLine();
            s += s.Substring(0, p.Length - 1);
            Console.WriteLine(HasSustring(s, p) ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 8932
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int a, b, t;
		Scanner scanner = new Scanner (System.in);
		a = scanner.nextInt();
		b = scanner.nextInt();
		t = scanner.nextInt();
		
		System.out.println(b*(t/a));
	}
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
typedef long long ll;
int main() {
	int n, k;
	cin>>n>>k;
	vector<int> dp(k + 1), v(n);
	for(int &i : v)
		cin>>i;
	dp[0] = 0;
	for(int i = 1; i <= k; i++) {
		for(int j = 0; j < n; j++) {
			if(i - v[j] >= 0) {
				dp[i] = max(dp[i], dp[i - v[j]] ^ 1);
			}
		}
	}
	if(dp[k] == 0)
		cout<<"Second"<<endl;
	else
		cout<<"First"<<endl;
}



Measured memory_bytes: 640
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<int> > mat;

int main()
{
  int n;
  cin >> n;
  int d[100100];
  for (int i = 0; i < n; i++)
  {
    cin >> d[i];
  }
  sort(d, d + n);
  cout << d[n / 2] - d[n / 2 - 1] << "\n";
}

Measured memory_bytes: 768
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}
func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	a, b := r.nextInt(), r.nextInt()

	x := fact(gcd(a, b))
	fmt.Fprintln(stdout, len(x)+1)
}


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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define inf 1e9
#define Puts(x) puts(x? "Yes":"No")
const int mod = 1e9 + 7;

int gcd(int n, int m) {return (m == 0? n : gcd(m, n % m));}
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

typedef pair<int, int> pi;
typedef long long i64;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

int w, h;
int cou;

void dfs(int y, int x, auto &grid, auto &visited) {
  if(!grid[y][x] || visited[y][x]) return;

  cou++;
  visited[y][x] = true;
  rep(i, 0, 4) {
    dfs(y + dy[i], x + dx[i], grid, visited);
  }
}

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

  while(cin >> w >> h, w && h) {
    vvt<bool> grid(h + 2, vt<bool>(w + 2, false));
    vvt<bool> visited(h + 2, vt<bool>(w + 2, false));
    int sx, sy;

    rep(i, 0, h) {
      string s;
      cin >> s;
      rep(j, 0, w) {
        if(s[j] == '.') grid[i + 1][j + 1] = true;
        if(s[j] == '@') {
          sx = j + 1;
          sy = i + 1;
          grid[sy][sx] = true;
        }
      }
    }

    cou = 0;
    dfs(sy, sx, grid, visited);
    cout << cou << endl;
  }
}



Measured memory_bytes: 3264
#include <stdio.h>
#include <stdlib.h>

#ifndef NO_NYAN
#define NYAN
#endif

#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

int N, M;
int S[2048];
int T[2048];

int memo[2048][2048];

#ifdef NYAN
int memo2[4096];

int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int za_count;
int za[4096];

int za_get(int target) {
	int l = 0, r = za_count - 1;
	while (l <= r) {
		int m = l + (r - l) / 2;
		if (za[m] == target) return m;
		else if (za[m] < target) l = m + 1;
		else r = m - 1;
	}
	printf("ERROR: %d not found\n", target);
	exit(2);
}
#else
int search(int spos, int tpos) {
	int answer = 0;
	int i;
	if (spos >= N || tpos >= M) return 1;
	if (memo[spos][tpos]) return ~memo[spos][tpos];

	answer = add(answer, search(spos + 1, tpos));
	for (i = tpos; i < M; i++) {
		if (S[spos] == T[i]) {
			answer = add(answer, search(spos + 1, i + 1));
		}
	}

	return ~(memo[spos][tpos] = ~answer);
}
#endif

int main(void) {
	int i;
#ifdef NYAN
	int j;
#endif
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &S[i]) != 1) return 1;
	}
	for (i = 0; i < M; i++) {
		if (scanf("%d", &T[i]) != 1) return 1;
	}
#ifdef NYAN
	for (i = 0; i < N; i++) za[i] = S[i];
	for (i = 0; i < M; i++) za[N + i] = T[i];
	qsort(za, N + M, sizeof(*za), cmp);
	za_count = 1;
	for (i = 1; i < N + M; i++) {
		if (za[za_count - 1] != za[i]) za[za_count++] = za[i];
	}
	for (i = 0; i < N; i++) S[i] = za_get(S[i]);
	for (i = 0; i < M; i++) T[i] = za_get(T[i]);
	for (i = 0; i <= M; i++) memo[N][i] = 1;
	for (i = 0; i <= N; i++) memo[i][M] = 1;
	for (i = N - 1; i >= 0; i--) {
		for (j = 0; j < za_count; j++) memo2[j] = 0;
		for (j = M - 1; j >= 0; j--) {
			memo2[T[j]] = add(memo2[T[j]], memo[i + 1][j + 1]);
			memo[i][j] = add(memo[i + 1][j], memo2[S[i]]);
		}
	}
	printf("%d\n", memo[0][0]);
#else
	printf("%d\n", search(0, 0));
#endif
	return 0;
}


Measured memory_bytes: 16508
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
    string n;
    cin >> n;
    int ans = 0;

    for (int i = 0; i < (int)n.size(); i++)
    {
        if (n[i] == '7')
        {
            ans = 1;
        }
    }
    if (ans > 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll n;cin>>n;
    vector<ll>v(n+1),w(n+1);
    rep(i,n)cin>>v[i+1]>>w[i+1];
    ll q;cin>>q;
    if(n<(1LL<<9)){
        while(q){
            q--;
            ll u,l;cin>>u>>l;
            ll ans=0;
            vector<ll>b(0);
            while(u){
                b.pb(u);
                u/=2;
            }
            ll m=b.size();
            rep(i,1LL<<m){
                ll cnt=0;
                ll val=0;
                rep(j,m){
                    if((1LL<<j)&i){
                        ll idx=b[j];
                        cnt+=w[idx];
                        val+=v[idx];
                    }
                }
                if(cnt<=l){
                    ans=max(ans,val);
                }
            }
            cout<<ans<<endl;
        }
    }else{
        vector<vector<ll> >dp(1LL<<9,vector<ll>(100010,-1));
        dp[1][0]=0;
        REP(i,1,1LL<<9){
            for(int j=100000;j>=0;j--){
                if(dp[i][j]<0)continue;
                if(j+w[i]<=100010){
                    dp[i][j+w[i]]=max(dp[i][j+w[i]],dp[i][j]+v[i]);
                }
            }
            rep(j,100010){
                if(i<(1LL<<8)){
                    dp[i*2][j]=dp[i][j];
                    dp[i*2+1][j]=dp[i][j];
                }
            }
        }
        REP(i,1,1LL<<9){
            ll ma=0;
            rep(j,100010){
                ma=max(ma,dp[i][j]);
                dp[i][j]=ma;
            }
        }
        while(q){
            q--;
            ll u,l;cin>>u>>l;
            vector<ll>b(0);
            ll ans=0;
            if(u<(1LL<<9)){
                cout<<dp[u][l]<<endl;
                continue;
            }
            while(u>=(1LL<<9)){
                b.pb(u);
                u/=2;
            }
            ll m=b.size();
            rep(i,1LL<<m){
                ll cnt=0;
                ll val=0;
                rep(j,m){
                    if((1LL<<j)&i){
                        ll idx=b[j];
                        cnt+=w[idx];
                        val+=v[idx];
                    }
                }
                if(cnt<=l){
                    ans=max(ans,dp[u][l-cnt]+val);
                }
            }
            cout<<ans<<endl;
        }
    }
}

Measured memory_bytes: 409532
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		int n = sc.nextInt();
      	int t = sc.nextInt();
      
        int cost[] = new int[n];
      	int time[] = new int[n];
        for(int i = 0; i < n; i++){
        	cost[i] = sc.nextInt();
          	time[i] = sc.nextInt();
        }
      	int flag = 0;
      	//暫定最小
      	int min = cost[0];
        for(int j = 0; j < n; j++){
        	if(time[j]<=t){
              if(min>cost[j]){
              	min = cost[j];
              }
 				flag =1;
            }
        }
      if(flag ==0){
        System.out.println("TLE");
      }else{
      	System.out.println(min);
      }
    }
}

Measured memory_bytes: 36036
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np


def main():
    H, W = map(int, input().split())
    # A = [list(input()) for _ in range(H)]
    A = np.array([list(input()) for _ in range(H)])
    A = A[:, ~np.all(A == '.', axis=0)]
    A = A[~np.all(A == '.', axis=1), :]
    [print(''.join(A[i, :])) for i in range(np.shape(A)[0])]


if __name__ == "__main__":
    main()


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

int main(){
int a,b,c,d;
 cin>>a;
   d=a%10;
  a/=10;
  c=a%10;
  a/=10;
  b=a%10;
  a/=10;
  if(a+b+c+d==7){
    cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
  }
  else if(a+b+c-d==7){
    cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
  }
  else if(a-b-c+d==7){
    cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
  }
  else if(a-b+c+d==7){
    cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
  }
  else if(a+b-c+d==7){
    cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
  }
  else if(a+b-c-d==7){
    cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
  }
  else if(a-b+c-d==7){
    cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
  }
  else if(a-b-c-d==7){
    cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
  }
}

Measured memory_bytes: 256
N,M = map(int,input().split())
in_M =[[]]*M 
for m in range(M):
    in_M[m] = list(map(int,input().split()))
out_M = list(map(int,input().split()))

all_on_cnt = 0
for i in range(2**N):
    switch = [0]*N
    for j in range(N):
        if((i>>j) & 1): # iをj回右シフトさせ末尾をみる
            switch[j] = 1
    
    for j in range(M):
        total = 0
        for l in range(1,in_M[j][0]+1):
            total += switch[in_M[j][l]-1]
        if total%2 != out_M[j]:
            break
    else:
        all_on_cnt += 1
          
print(all_on_cnt)        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vc vector<int>
#define F first
#define S second
#define eb emplace_back

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1; 
        x = (x * x) % p;
    }
    return res;
}

int modInverse(int n, int p)
{
    return power(n, p - 2, p);
}

int nCrModPFermat(int n, int r, int p)
{

    if (r == 0)
        return 1;

    int fac[n + 1];
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;

    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) %
           p;
}
/*
// dsu started 
int a[1000000],b[1000000];
    int find(int x){
        if(b[x]==x) return x;
        b[x]= find(b[x]);
      return b[x];
    }
    void uniona(int x,int y){
        x=find(x);
        y=find(y);
        if (x!=y) {
            a[y]<a[x] ? b[x]=b[y]:b[y]=b[x];
        }
    }
//cut from here
int n,k;
    cin>>n>>k;
     
   
     for(int i=1;i<=n;i++){
    cin>>a[i];
    b[i]=i;
    }
     for(int i=1;i<=k;i++){
    int t1,t2;
    cin>>t1>>t2;// basic code for dsu
    uniona(t1,t2);
//dsu ends
*/

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string n="";
    cin>>n;
    int sum=0;
    for(int i=0;i<n.length();i++){
            sum+=(n[i]-'0');
    }
    if(sum%9==0){
        cout<<"Yes";

    }
    else cout<<"No";
    
}

Measured memory_bytes: 3728
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	var s, t string
	fmt.Scan(&s)
	fmt.Scan(&t)

	ss := strings.Split(s, "")
	tt := strings.Split(t, "")

	ms := map[string]string{}
	mt := map[string]string{}
	ok := true
	for i := 0; i < len(ss); i++ {

		if len(ms[ss[i]]) != 0 {
			if ms[ss[i]] != tt[i] {
				ok = false
			}
		}

		if len(mt[tt[i]]) != 0 {
			if mt[tt[i]] != ss[i] {
				ok = false
			}
		}

		ms[ss[i]] = tt[i]
		mt[tt[i]] = ss[i]
	}

	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

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

	long long dif1 = 0LL, dif2 = 0LL, dif3 = 0LL;
	for(int i = 0; i < n; ++i){
		if(a[i] >= b[i]){
			dif1 += a[i] - b[i];
		}else{
			if((b[i] - a[i]) == 1){
				dif2 += b[i] - a[i];
			}else{
				dif3 += (b[i] - a[i]) / 2;
			}
		}
	}
	if(dif1 <= dif3){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];

    sort(l.begin(), l.end());

    ll ans = 0;
    rep(i, n) {
        REP(j, i + 1, n) {
            int k = lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
            ans += max(k - j - 1, 0);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    cout << "ABC" << N;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

void solve(string s){
    int x[8][3] = {{0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}};
    for (int i = 0; i < 8; ++i) {
        if(s[x[i][0]] == s[x[i][1]] && s[x[i][1]] == s[x[i][2]]){
            if(s[x[i][0]] != '+'){
                cout << s[x[i][0]] << "\n";
                return;
            }
        }
    }
    cout << "NA" << "\n";
    return;
}

int main() {
    string s, t, u;
    while(cin >> s, s != "0"){
        cin >> t >> u;
        solve(s+t+u);
    }
    return 0;
}


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

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(m, n, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

const int INF = 1LL << 60;
const int MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    int d[n];
    rep(n, i) {
        cin >> d[i];
    }
    sort(d, d + n);
    cout << d[n / 2] - d[n / 2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

const int N = 100005;
VI ys[N];
VI xs[N];
bool visit[N];

int main() {
	int n;
	scanf("%d", &n); 
	vector<PII> xy(n);
	REP(i, n) {
		int x, y;
		scanf("%d%d", &x, &y);
		xs[y].PB(i);
		ys[x].PB(i);
		xy[i] = MP(x, y);
	}
	LL ans = 0;
	REP(i, n) {
		if (visit[i])continue;
		queue<int> q;
		unordered_set<int> xx;
		unordered_set<int> yy;
		q.push(i);
		int cnt = 0;
		while (!q.empty()) {
			auto tmp = q.front();
			q.pop();
			if (visit[tmp])continue;
			visit[tmp] = true;
			xx.insert(xy[tmp].first);
			yy.insert(xy[tmp].second);
			cnt++;
			for (auto idx : ys[xy[tmp].first]) {
				if(!visit[idx])q.push(idx);
			}
			for (auto idx : xs[xy[tmp].second]) {
				if (!visit[idx])q.push(idx);
			}
		}
		ans += xx.size() * yy.size() - cnt;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 138872
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 100005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);	
	
	string a,b;
	cin>>a>>b;
	ll i,j,k,l,n=a.length(),m=b.length();
	ll an=1e18;
	for(i=0;i<n;i++){
		k=i; ll c=0;
		for(j=0;k<n&&j<m;j++){
			if(a[k++]!=b[j]) c++;
		}
		if(j==m)
			an=min(an,c);
		// cout<<i<<" "<<c<<endl;
	}
	cout<<an<<endl;
	return 0;	
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  vector<int> sum(n);
  rep(i,m){
    cin >> a.at(i) >> b.at(i);
    sum.at(a.at(i)-1)++;
    sum.at(b.at(i)-1)++;
  }
    rep(i,n) cout << sum.at(i) << endl;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s)                                                               \
    do {                                                                       \
    } while (0)
#define dump(x)                                                                \
    do {                                                                       \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

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

void solve() {
    int h, w;
    cin >> h >> w;
    VS b(h);
    REP(i, 0, h) cin >> b[i];
    VVI d(h, VI(w));
    int ans = h * w;
    REP(i, 0, h) REP(j, 0, w) if (b[i][j] == '#') {
        d[i][j] = 10000;
        --ans;
    }
    d[0][0] = 1;
    deque<int> q;
    q.push_back(0 * w + 0);
    while (!q.empty()) {
        int v = q.front();
        q.pop_front();
        int x = v / w, y = v % w;
        REP(i, 0, 4) {
            if (x + dx[i] < 0)
                continue;
            if (x + dx[i] >= h)
                continue;
            if (y + dy[i] < 0)
                continue;
            if (y + dy[i] >= w)
                continue;
            if (d[(x + dx[i])][(y + dy[i])] != 0)
                continue;
            d[(x + dx[i])][(y + dy[i])] = d[x][y] + 1;
            q.push_back((x + dx[i]) * w + (y + dy[i]));
        }
    }
    if (d[h - 1][w - 1] == 0)
        cout << -1 << endl;
    else
        cout << ans - d[h - 1][w - 1] << endl;
}

signed main() {
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	if(a<b&&b<c){
		printf("%d %d %d\n",a,b,c);
	}
	else if(b<a&&a<c){
		printf("%d %d %d\n",b,a,c);
	}
	else if(b>a&&a>c){
		printf ("%d %d %d\n",c,a,b);
	}
	else if(a<c&&c<b){
		printf("%d %d %d\n",a,c,b);
	}
	else if(b<c&&c<a){
		printf("%d %d %d\n",b,c,a);
	}
	else if(c<b&&b<a){
		printf("%d %d %d\n",c,b,a);
	}
	else if(a==b&&b<c){
		printf("%d %d %d\n",a,b,c);
	}
	else if(a==c&&c<b){
		printf("%d %d %d\n",a,c,b);
	}
	else if(b==a&&a<c){
		printf("%d %d %d\n",b,a,c);
	}
	else if(b==c&&c<a){
		printf("%d %d %d\n",b,c,a);
	}
	else if(c==a&&a<b){
		printf("%d %d %d\n",c,a,b);
	}
	else{
		printf("%d %d %d\n",c,b,a);
	}
	return 0;
}


Measured memory_bytes: 2108
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b=map(int,input().split())
    if (b-a)%2==0:print((b-a)//2)
    else:print(min((b+a-1)//2,(2*n-b+1-a)//2))

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    int v[n];
    for(int i=0; i<n; i++){
        scanf("%d", &v[i]);
    }
    int a, b;
    int p=0, q=0;
    int t[100001];
    for(int i=0; i<=100000; i++){
        t[i] = 0;
    }
    for(int i=0; i<n; i+=2){
        t[v[i]]++;
    }
    for(int i=1; i<=100000; i++){
        if(t[i] > q){
            p = i;
            q = t[i];
        }
    }
    a = n/2 - q;
    q=0;
    for(int i=0; i<=100000; i++){
        t[i] = 0;
    }
    for(int i=1; i<n; i+=2){
        t[v[i]]++;
    }
    for(int i=1; i<=100000; i++){
        if(i == p){
            continue;
        }
        if(t[i] > q){
            q = t[i];
        }
    }
    a += n/2 - q;

    p=0, q=0;
    for(int i=0; i<=100000; i++){
        t[i] = 0;
    }
    for(int i=1; i<n; i+=2){
        t[v[i]]++;
    }
    for(int i=1; i<=100000; i++){
        if(t[i] > q){
            p = i;
            q = t[i];
        }
    }
    b = n/2 - q;
    q=0;
    for(int i=0; i<=100000; i++){
        t[i] = 0;
    }
    for(int i=0; i<n; i+=2){
        t[v[i]]++;
    }
    for(int i=1; i<=100000; i++){
        if(i == p){
            continue;
        }
        if(t[i] > q){
            q = t[i];
        }
    }
    b += n/2 - q;
    //printf("%d %d\n", a, b);
    printf("%d", a<b?a:b);

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Edge{
	bool operator<(const struct Edge &arg) const{
		if(s != arg.s){
			return s < arg.s;
		}else{
			return t < arg.t;
		}
	}
	int s,t;
};

struct Info{
	Info(int arg_to,int arg_edge_id){
		to = arg_to;
		edge_id = arg_edge_id;
	}
	int to,edge_id;
};

int V,E,number;
int order[100000],lowlink[100000];
bool visited[100000];
Edge edge[100000];
vector<Info> G[100000];

void recursive(int node_id){

	order[node_id] = number++;
	lowlink[node_id] = order[node_id];

	int next_node;

	for(int i = 0; i < G[node_id].size(); i++){

		next_node = G[node_id][i].to;

		if(order[next_node] == -1){

			visited[G[node_id][i].edge_id] = true;
			recursive(next_node);
			lowlink[node_id] = min(lowlink[node_id],lowlink[next_node]);

		}else if(visited[G[node_id][i].edge_id] == false){

			lowlink[node_id] = min(lowlink[node_id],order[next_node]);
		}
	}
}

int main(){

	scanf("%d %d",&V,&E);

	for(int i = 0; i < E; i++){
		scanf("%d %d",&edge[i].s,&edge[i].t);
		if(edge[i].s > edge[i].t){
			swap(edge[i].s,edge[i].t);
		}
		G[edge[i].s].push_back(Info(edge[i].t,i));
		G[edge[i].t].push_back(Info(edge[i].s,i));
	}

	sort(edge,edge+E);

	number = 0;

	for(int i = 0; i < V; i++){
		order[i] = -1;
		lowlink[i] = -1;
	}

	for(int i = 0; i < E; i++){
		visited[i] = false;
	}

	recursive(0);

	int from,to;

	for(int i = 0; i < E; i++){

		from = edge[i].s;
		to = edge[i].t;

		if(order[edge[i].s] > order[edge[i].t]){
			swap(from,to);
		}

		if(order[from] < lowlink[to]){
			printf("%d %d\n",edge[i].s,edge[i].t);
		}
	}

	return 0;
}




Measured memory_bytes: 7656
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main(){
  int i,N,M,K,a[100001]={0},cnt=0;
  long long ans[100001]={0};
  char ss[10000];
  scanf("%d",&N);
  scanf("%d",&M);
  for(i=0;i<M;i++){
    scanf("%d",&a[i]);
  }
  if(a[cnt]==1){
    ans[0]=0;
    cnt++;
  }else{
    ans[0]=1;
  }
  if(a[cnt]==2){
    ans[1]=0;
    cnt++;
  }else{
    ans[1]=1+ans[0];
  }
  for(i=2;i<N;i++){
    if(a[cnt]==i+1){
      cnt++;
      ans[i]=0;
    }else{
      ans[i]=(ans[i-2]+ans[i-1])%mod;
    }
  }
  printf("%lld\n",ans[N-1]);
/*  for(i=0;i<N;i++){
    printf("%lld ",ans[i]);
  }
*/  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

int main()
{
    ll A, B;
    cin >> A >> B;

    cout << (A <= 8 && B <= 8 ? "Yay!" : ":(") << endl;
}

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

#define rep(i,s,t) for(ll i = s; i <= t; ++ i)
typedef long long ll;

ll n, e;

int main()
{
    scanf("%lld",&n);
    rep(i,1,n)
        if((1+i)*i/2 >= n)
        {
            e = i;
            break;
        }
    if((e-1)*e/2 == n)
    {
        rep(i,1,e) printf("%lld\n",i);
        return 0;
    }
    rep(i,1,e) if(i != e*(1+e)/2-n) printf("%lld\n",i);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cassert>
#include<queue>

using namespace std;

#define Whats(x) cout<<#x<<" is "<<(x)<<endl
#define DivHim() cout<<">>>>>>>>>>>>>>>"<<endl
#define DivHer() cout<<"<<<<<<<<<<<<<<<"<<endl
#define Oops() cout<<"!!!!!!!!!!!!!!!"<<endl

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

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

/*
	 -<Unlimited Blade Works>-
 */

#define int long long

const int N=233;
const int S=N-2;
const int T=N-3;
const int M=2333;
const int INF=0x3f3f3f3f3f3f3f3f;

struct Edge
{
	int v,c;
}edges[M];

int cur[N],fir[N],nxt[M],tote=1;

void Adde(int u,int v,int c)
{
	//cout<<u<<","<<v<<":"<<c<<endl;
	edges[++tote]=(Edge){v,c};
	nxt[tote]=fir[u];
	fir[u]=tote;
	edges[++tote]=(Edge){u,0};
	nxt[tote]=fir[v];
	fir[v]=tote;
}

int n,a[N],ans;
int d[N];

bool Bfs()
{
	memset(d,0,sizeof d);
	d[S]=1;
	static queue<int> Q;
	Q.push(S);
	while(!Q.empty())
	{
		int u=Q.front();
		Q.pop();
		for(int i=fir[u];i;i=nxt[i])
		{
			Edge &e=edges[i];
			if(e.c&&!d[e.v])
			{
				d[e.v]=d[u]+1;
				Q.push(e.v);
			}
		}
	}
	return d[T];
}

int Dfs(int u,int a=INF)
{
	if(u==T||!a)
		return a;
	int f=0,af;
	for(int &i=cur[u];i;i=nxt[i])
	{
		Edge &e=edges[i];
		if(d[e.v]==d[u]+1&&(af=Dfs(e.v,min(e.c,a))))
		{
			f+=af;
			a-=af;
			e.c-=af;
			edges[i^1].c+=af;
			if(!a)
				break;
		}
	}
	return f;
}

int MaxFlow()
{
	int f=0;
	while(Bfs())
	{
		memcpy(cur,fir,sizeof fir);
		f+=Dfs(S);
	}
	return f;
}

signed main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",a+i);
		if(a[i]>0)
		{
			ans+=a[i];
			Adde(i,T,a[i]);
		}
		else
			Adde(S,i,-a[i]);
	}
	for(int i=1;i<=n;++i)if(a[i]<0)
		for(int j=i;j<=n;j+=i)if(a[j]>0)
			Adde(i,j,INF);
	//Whats(ans);
	ans-=MaxFlow();
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
  ull n,memo,cnt = 1;
  
  cin >> n;
  
  ull a[n];
  
  rep(i,0,n){
    cin >> a[i];
    if(a[i] % 2 == 0){
      cnt *= 2;
    }
  }
  
  
  cout << (ull)pow(3,n) - cnt << endl;
  return 0;
  
}

Measured memory_bytes: 256
n = int(input())
data = list(map(int, input().split()))
ans = [0]*n
            
#print(data)
#print(ans)
for i in range(n):
#	print(data[i]-1)
	ans[data[i]-1] =i+1
L=[str(a) for a in ans]
print(" ".join(L))

Measured memory_bytes: 19528
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

bool is_prime (ll n) {
    for (ll i = 2; i * i <= n; i++)
    {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main(int argc, char const *argv[])
{
    vector<ll> v(100001, 0);
    for (ll i = 1; i < 100000; i++)
    {
        ll temp = 0;
        if (is_prime(i) && is_prime((i + 1) / 2))
        {
            temp++;
        }
        v[i] += v[i - 1] + temp;
    }

    ll q;
    cin >> q;
    for (ll i = 0; i < q; i++)
    {
        ll l, r;
        cin >> l >> r;

        ll cnt = v[r] - v[l - 1];

        cout << cnt << endl;
    }
}

Measured memory_bytes: 1408
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define PI acos(-1)
#define eps 1e-10
#define mem(x) memset(x,0,sizeof(x))
#define _for(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
#define __for(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}

const int INF=0x3f3f3f3f;
const int MAX=1e5+5;
const int MOD=1e9+7;

int a,b,c;


int main(){
    std::ios::sync_with_stdio(false);
    cin>>a>>b>>c;
    if(a+b>=c){
    	cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  vector<int> a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(a.begin(),a.end());
  cout << a[2]*10+a[1]+a[0]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,m,k;
  cin >> n >> m >> k;
  for(int i=0; i<=n; i++) {
    for(int j=0; j<=m; j++) {
      if(i*(m-j)+j*(n-i)==k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int A,B,C,D;
	cin >> A >> B >> C >> D;
	if(A+B == C+D) {
		cout << "Balanced"<< endl;
	}else if (A+B < C + D) {
		cout <<"Right"<< endl;
	}else {
		cout << "Left"<< endl;
	}
	return 0;
}


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

int main() {
  int r;
  cin >> r;
  if(r < 1200){
    cout << "ABC" << endl;
  }else if(r < 2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
  return 0;
}

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

int main()
{
	int q, ans1, ans2;
	string s, s1, s2;
	cin >> s >> q;
	ans1 = ans2 = 0;
	while (q--)
	{
		int t; scanf("%d", &t);
		if (t == 1)	ans1++;
		else
		{
			int f;
			string ss;
			scanf("%d", &f); cin >> ss;
			if (f == 1)
			{
				if (ans1 % 2 == 0)	s1 = ss + s1;
				else	s2 += ss;
			}
			else
			{
				if (ans1 % 2 == 0)	s2 += ss;
				else	s1 = ss + s1;
			}
		}
	}
	string ss;
	if (ans1 % 2 == 0)	ss = s1 + s + s2;
	else
	{
		reverse(s1.begin(), s1.end());
		reverse(s2.begin(), s2.end());
		reverse(s.begin(), s.end());
		ss = s2 + s + s1;
	}	
	cout << ss;
	return 0;
}

Measured memory_bytes: 1360
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int Q,H,S,D,N;
    cin>>Q>>H>>S>>D>>N;
    int ans=min({Q*8,H*4,S*2,D})*(N/2)+min({Q*4,H*2,S})*(N%2);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int  sum=0;
	 long long int n = 0,p,D,N,a,b;

	scanf("%lld %lld", &N,&D);

	n = D * D;
//	printf("%lld\n", n);

	for (int i = 0;i < N;i++) {
		scanf("%lld %lld",&a,&b);
		p = a * a + b * b;

		if (n >= p)sum++;
	}

	printf("%d",sum);

	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;

typedef long long ll;

const int maxn = 1e5 + 100;

ll all[maxn] = {0}, b[maxn] = {0}, l[maxn] = {0}, u[maxn] = {0}, sum[maxn] = {0};
ll X = 0LL, pr = 0LL;
int id[maxn] = {0};
int n;

bool cmp(int i, int j) { return all[i] > all[j]; }

void init() {
	for (int i = 1; i <= n; ++i) id[i] = i, pr -= l[i] * b[i];
	for (int i = 1; i <= n; ++i) all[i] = b[i] * l[i] + (X - b[i]) * u[i];
	sort(id + 1, id + 1 + n, cmp);
	for (int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + all[id[i]];
}

bool check(ll mid) {
	ll t = mid / X;
	ll ret = pr;
	ll mx = 0LL;
	ll rem = mid % X;
	for (int i = 1; i <= n; ++i) {
		mx = max(mx, sum[t] + min(b[id[i]], rem) * l[id[i]] + max(0LL, rem - b[id[i]]) * u[id[i]] + (t >= i ? (-all[id[i]] + all[id[t + 1]]) : 0LL));
	}
	ret += mx;
	return ret >= 0LL;
}

int main()
{
	ios::sync_with_stdio(0);
	cin >> n >> X;
	for (int i = 1; i <= n; ++i) cin >> b[i] >> l[i] >> u[i];
	init();
	ll L = 0LL, R = (ll)n * X;
	while (L < R) {
		ll mid = (L + R) >> 1;
		if (check(mid)) R = mid;
		else L = mid + 1;
	}
	cout << R << endl;
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n, m;
    cin>>n>>m;
    ll ans = 1900 * m + 100 * (n-m);
    ans *= pow(2, m);
    cout<<ans<<endl;
}

Measured memory_bytes: 256